Commit b6c6f20f3018f1b26208669f04ac04ead0587d40

Authored by 邱嘉伟
1 parent 7ba06aa9

fix:参数设计器 默认值字段修改 输入框增加校验

... ... @@ -156,7 +156,7 @@ const ParameterModal: React.FC<ParameterSettingProps> = (props) => {
156 156 </div>
157 157 ),
158 158 dataIndex: 'code',
159   - width: '15%',
  159 + width: '12%',
160 160 editable: true,
161 161 key: 'code',
162 162 // render: (text, record) => (
... ... @@ -184,7 +184,7 @@ const ParameterModal: React.FC<ParameterSettingProps> = (props) => {
184 184 </div>
185 185 ),
186 186 dataIndex: 'title',
187   - width: '15%',
  187 + width: '12%',
188 188 editable: true,
189 189 key: 'title',
190 190 // render: (text, record) => (
... ... @@ -254,14 +254,14 @@ const ParameterModal: React.FC<ParameterSettingProps> = (props) => {
254 254 </div>
255 255 </> : <>
256 256 <div key={record.id}>
257   - <span>{record.type == 'TIME' ? moment(text?.min).format(
258   - formatEnum[text?.format] || 'YYYY-MM-DD') : text?.min}
  257 + <span>{record.type == 'TIME' ? text?.min ? moment(text.min).format(
  258 + formatEnum[text?.format] || 'YYYY-MM-DD') : undefined : text?.min}
259 259 </span>
260   - {text?.min && (
  260 + {!!text?.min || text?.min >= 0 && (
261 261 <Space style={{ marginLeft: 5, marginRight: 5 }}>-</Space>
262 262 )}
263   - <span>{record.type == 'TIME' ? moment(text?.max).format(
264   - formatEnum[text?.format] || 'YYYY-MM-DD') : text?.max}
  263 + <span>{record.type == 'TIME' ? text?.max ? moment(text.max).format(
  264 + formatEnum[text?.format] || 'YYYY-MM-DD') : undefined : text?.max}
265 265 </span>
266 266 </div>
267 267 </>}
... ... @@ -294,27 +294,43 @@ const ParameterModal: React.FC<ParameterSettingProps> = (props) => {
294 294 },
295 295 {
296 296 title: '默认值',
297   - dataIndex: 'qxProps',
298   - width: '10%',
  297 + dataIndex: 'mappingValues',
  298 + width: '12%',
299 299 editable: true,
300   - key: 'qxProps',
301   - render: (text, record) => (
302   - // console.log('text', text)
303   - <span key={record.id}>{text?.default}</span>
  300 + key: 'mappingValues',
  301 + render: (text) =>
  302 + text || [].map((item) => {
  303 + // if (item.indexOf('-') > -1) {
  304 + // if (text == item.key) {
  305 + return <span key={item}>{item.indexOf('-') > -1 ? item : ''}</span>;
  306 + // }
  307 + }),
  308 + // }
304 309
305   - // <Form.Item
306   - // name={'default' + record.id}
307   - // initialValue={text?.default}
308   - // >
309   - // <Input disabled={record.disabled} onBlur={(e) => props.handleChange(e, record, 'qxProps-default')} />
310   - // </Form.Item>
311   - ),
  310 + // }
  311 + // )
  312 + // text || [].map((item ) => {
  313 + // return console.log('123', item.indexOf('-'))
  314 + // if (item.indexOf('-') > -1) {
  315 +
  316 + // <span key={item.type + record.id}>{item.value}</span>;
  317 + // }
  318 + // }),
  319 + // console.log('text', text)
  320 + // <span key={record.id}>{text?.default}</span>
  321 +
  322 + // <Form.Item
  323 + // name={'default' + record.id}
  324 + // initialValue={text?.default}
  325 + // >
  326 + // <Input disabled={record.disabled} onBlur={(e) => props.handleChange(e, record, 'qxProps-default')} />
  327 + // </Form.Item>
  328 + // ),
312 329 },
313 330 {
314 331 title: '参数说明',
315 332 dataIndex: 'description',
316 333 editable: true,
317   - width: '10%',
318 334 key: 'description',
319 335 render: (text, record) => (
320 336 <span key={record.id}>{text}</span>
... ... @@ -484,6 +500,8 @@ const ParameterModal: React.FC<ParameterSettingProps> = (props) => {
484 500 initialValue={qxProps.min}
485 501 >
486 502 <InputNumber
  503 + min={0}
  504 + precision={0}
487 505 // defaultValue={qxProps.min}
488 506 // onChange={onQxpropsChangen}
489 507 // onBlur={() => save('qxProps-min')}
... ... @@ -497,6 +515,8 @@ const ParameterModal: React.FC<ParameterSettingProps> = (props) => {
497 515 initialValue={qxProps.max}
498 516 >
499 517 <InputNumber
  518 + min={0}
  519 + precision={0}
500 520 // dataIndex={["qxProps", "max"]}
501 521 // defaultValue={qxProps.max}
502 522 // onBlur={() => save('qxProps-max')}
... ... @@ -522,6 +542,8 @@ const ParameterModal: React.FC<ParameterSettingProps> = (props) => {
522 542 style={{ margin: 0 }}
523 543 >
524 544 <InputNumber
  545 + precision={qxProps.precision || 0}
  546 + size='small'
525 547 // defaultValue={qxProps.min}
526 548 // onBlur={() => save('qxProps-min')}
527 549 style={{ width: '110px' }}
... ... @@ -536,6 +558,8 @@ const ParameterModal: React.FC<ParameterSettingProps> = (props) => {
536 558 name={['newQxProps', 'max']}
537 559 >
538 560 <InputNumber
  561 + size='small'
  562 + precision={qxProps.precision || 0}
539 563 // defaultValue={qxProps.max}
540 564 // onBlur={() => save('qxProps-max')}
541 565 style={{ width: '110px' }}
... ... @@ -550,6 +574,11 @@ const ParameterModal: React.FC<ParameterSettingProps> = (props) => {
550 574 name={['newQxProps', 'precision']}
551 575 >
552 576 <InputNumber
  577 + size='small'
  578 + // formatter={decimalCheck}
  579 + precision={0}
  580 + min={0}
  581 + max={8}
553 582 // defaultValue={qxProps.precision}
554 583 // onBlur={() => save('qxProps-precision')}
555 584 placeholder="小数位数"
... ... @@ -569,6 +598,7 @@ const ParameterModal: React.FC<ParameterSettingProps> = (props) => {
569 598 >
570 599 <div>
571 600 <DatePicker
  601 + size='small'
572 602 defaultValue={
573 603 qxProps?.min
574 604 ? moment(qxProps.min)
... ... @@ -576,7 +606,7 @@ const ParameterModal: React.FC<ParameterSettingProps> = (props) => {
576 606 }
577 607 format={formatEnum[qxProps?.format]}
578 608 // onChange={dateChange}
579   - style={{ width: '130px' }}
  609 + style={{ width: '110px' }}
580 610 // onBlur={() => save('qxProps-min')}
581 611 showTime
582 612 onSelect={(e) => props.handleChange(e, record, 'qxProps-min')}
... ... @@ -585,13 +615,14 @@ const ParameterModal: React.FC<ParameterSettingProps> = (props) => {
585 615 {/* <DatePicker defaultValue={moment(qxProps.min)} onBlur={() => save('qxProps-min')} placeholder='开始日期' /> */}
586 616 &nbsp; ~ &nbsp;
587 617 <DatePicker
  618 + size='small'
588 619 defaultValue={
589 620 qxProps?.min
590 621 ? moment(qxProps.max)
591 622 : undefined
592 623 }
593 624 format={formatEnum[qxProps?.format]}
594   - style={{ width: '130px' }}
  625 + style={{ width: '110px' }}
595 626 // onChange={dateChange}
596 627 showTime
597 628 // onBlur={toggleEdit}
... ... @@ -601,6 +632,7 @@ const ParameterModal: React.FC<ParameterSettingProps> = (props) => {
601 632 {/* <DatePicker defaultValue={moment(qxProps.max)} onBlur={() => save('qxProps-max')} placeholder='结束日期' /> */}
602 633 </div>
603 634 <Select
  635 + size='small'
604 636 style={{ width: '90px' }}
605 637 placeholder="格式"
606 638 popupMatchSelectWidth={false}
... ... @@ -691,16 +723,11 @@ const ParameterModal: React.FC<ParameterSettingProps> = (props) => {
691 723 const qxPropsDefault = () => {
692 724 const valuesObj = [{
693 725 type: typeTranslateItemtype(record.type),
694   - value: record?.qxProps?.default || '',
  726 + value: record.mappingValues || [],
695 727 }]
696   - record.valuesObj = valuesObj
  728 + record.valuesObj = !record.valuesObj ? valuesObj : record.valuesObj
697 729 return (
698 730 <div>
699   - {/* <Input
700   - defaultValue={record?.qxProps?.default}
701   - ref={inputRef}
702   - onBlur={() => save('qxProps-default')}
703   - /> */}
704 731 <QxFieldSetter
705 732 value={record.valuesObj || []}
706 733 params={{ appCode: 'appCode', useId: true }}
... ... @@ -763,19 +790,19 @@ const ParameterModal: React.FC<ParameterSettingProps> = (props) => {
763 790 ) : dataIndex == 'qxProps' ? (
764 791 title == '取值范围' ? (
765 792 qxPropsRange()
766   - ) : title == '默认值' ? (
767   - qxPropsDefault()
768 793 ) : (
769 794 qxPropsRemark()
770 795 )
771   - ) : (
772   - // @ts-ignore
773   - <Input
774   - ref={inputRef}
775   - onPressEnter={save}
776   - onBlur={() => save(dataIndex)}
777   - />
778   - )}
  796 + ) : dataIndex == 'mappingValues' ?
  797 + qxPropsDefault() :
  798 + (
  799 + // @ts-ignore
  800 + <Input
  801 + ref={inputRef}
  802 + onPressEnter={save}
  803 + onBlur={() => save(dataIndex)}
  804 + />
  805 + )}
779 806 </Form.Item>
780 807 ) : (
781 808 <div
... ...
... ... @@ -23,7 +23,7 @@ import {
23 23 typeTranslateItemtype,
24 24 } from './constant';
25 25
26   -import { cloneDeep } from 'lodash-es';
  26 +import { cloneDeep, isEmpty } from 'lodash-es';
27 27 import moment from 'dayjs';
28 28 import type { ParamDesignModel } from './constant';
29 29 import { uidGen } from './stringUtil';
... ... @@ -526,6 +526,7 @@ export const QxParameterSetting: React.FC<ParameterSettingProps> = (props) => {
526 526 };
527 527
528 528 const changeField = (val: any, data: any) => {
  529 + console.log('changeField', val)
529 530 if (!val || isEmpty(val)) {
530 531 return;
531 532 }
... ... @@ -583,9 +584,9 @@ export const QxParameterSetting: React.FC<ParameterSettingProps> = (props) => {
583 584 // const strCode = nodeData.code as string;
584 585 const valuesObj = [{
585 586 type: typeTranslateItemtype(nodeData.type),
586   - value: nodeData?.qxProps?.default || '',
  587 + value: nodeData.mappingValues || [],
587 588 }]
588   - nodeData.valuesObj = valuesObj
  589 + nodeData.valuesObj = !nodeData.valuesObj ? valuesObj : nodeData.valuesObj
589 590 // const index = strTitle.indexOf(searchValue);
590 591 const isShowTree = checkShowTree(nodeData);
591 592 const disabled = nodeData.disabled;
... ...