From 8f9f9322f32e0553cb58068b39ae57e3d997ec65 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期一, 20 五月 2024 15:16:23 +0800 Subject: [PATCH] 2024-05-20 --- src/tabviews/zshare/mutilform/index.jsx | 4 + src/templates/zshare/modalform/index.jsx | 2 src/templates/zshare/formconfig.jsx | 13 ++++++ src/menu/components/table/edit-table/columns/editColumn/index.jsx | 46 +++++++++++++++++------ src/menu/components/table/edit-table/columns/editColumn/formconfig.jsx | 28 +++++++------- src/tabviews/custom/components/table/edit-table/normalTable/index.jsx | 12 +++++- 6 files changed, 75 insertions(+), 30 deletions(-) diff --git a/src/menu/components/table/edit-table/columns/editColumn/formconfig.jsx b/src/menu/components/table/edit-table/columns/editColumn/formconfig.jsx index 05f72dd..4379c5c 100644 --- a/src/menu/components/table/edit-table/columns/editColumn/formconfig.jsx +++ b/src/menu/components/table/edit-table/columns/editColumn/formconfig.jsx @@ -371,6 +371,20 @@ }] }, { + type: 'radio', + key: 'required', + label: '蹇呭~', + initVal: card.required || 'false', + required: false, + options: [{ + value: 'false', + text: '鍚�' + }, { + value: 'true', + text: '鏄�' + }] + }, + { type: 'text', key: 'initval', label: '榛樿鍊�', @@ -668,20 +682,6 @@ }, { value: 'fixed', text: '瀹氬' - }] - }, - { - type: 'radio', - key: 'required', - label: '蹇呭~', - initVal: card.required || 'false', - required: false, - options: [{ - value: 'false', - text: '鍚�' - }, { - value: 'true', - text: '鏄�' }] }, { diff --git a/src/menu/components/table/edit-table/columns/editColumn/index.jsx b/src/menu/components/table/edit-table/columns/editColumn/index.jsx index 716a8c8..dd97ea0 100644 --- a/src/menu/components/table/edit-table/columns/editColumn/index.jsx +++ b/src/menu/components/table/edit-table/columns/editColumn/index.jsx @@ -66,6 +66,8 @@ getOptions = () => { let _options = fromJS(columnTypeOptions[this.record.type]).toJS() + let reLabel = {} + if (['number', 'text'].includes(this.record.type) && this.record.editable === 'true') { _options.push('ctrlField') if (this.record.ctrlField) { @@ -91,8 +93,12 @@ } else { _options.push('required', 'enter') } + + reLabel.required = '蹇呭~' } else if (this.record.type === 'number') { - _options.push('max', 'min', 'enter', 'clearField') + _options.push('max', 'min', 'required', 'enter', 'clearField') + + reLabel.required = '涓嶇瓑浜�0' } } else if (this.record.type === 'extend') { if (this.record.colUnit === 'day') { @@ -115,7 +121,7 @@ } } - return _options + return {options: _options, reLabel} } editColumn = (column) => { @@ -131,12 +137,16 @@ this.record[item.key] = item.initVal }) - let _options = this.getOptions() + let { options, reLabel } = this.getOptions() this.setState({ visible: true, formlist: formlist.map(item => { - item.hidden = !_options.includes(item.key) + item.hidden = !options.includes(item.key) + + if (reLabel[item.key]) { + item.label = reLabel[item.key] + } if (item.key === 'formula') { item.fields = this.props.fields.map(col => col.field) @@ -166,7 +176,7 @@ this.record.IsSort = 'false' } - let _options = this.getOptions() + let { options, reLabel } = this.getOptions() let _field = '' if (value === 'formula') { @@ -180,7 +190,10 @@ } item.initVal = this.record[item.key] - item.hidden = !_options.includes(item.key) + item.hidden = !options.includes(item.key) + if (reLabel[item.key]) { + item.label = reLabel[item.key] + } return item }) @@ -212,12 +225,15 @@ this.record.type = values.type if (values.type !== _type) { - let _options = this.getOptions() + let { options, reLabel } = this.getOptions() this.setState({ formlist: this.state.formlist.map(item => { item.initVal = this.record[item.key] - item.hidden = !_options.includes(item.key) + item.hidden = !options.includes(item.key) + if (reLabel[item.key]) { + item.label = reLabel[item.key] + } return item }) @@ -230,7 +246,7 @@ } else if (key === 'format' && value === 'percent') { this.props.form.setFieldsValue({postfix: '%'}) } else if (key === 'editType') { - let _options = this.getOptions() + let { options, reLabel } = this.getOptions() this.setState({ formlist: this.state.formlist.map(item => { @@ -239,18 +255,24 @@ } item.initVal = this.record[item.key] - item.hidden = !_options.includes(item.key) + item.hidden = !options.includes(item.key) + if (reLabel[item.key]) { + item.label = reLabel[item.key] + } return item }) }) } else if (['editable', 'editType', 'resourceType', 'ctrlField', 'eval', 'Hide', 'IsSort', 'textFormat'].includes(key)) { - let _options = this.getOptions() + let { options, reLabel } = this.getOptions() this.setState({ formlist: this.state.formlist.map(item => { item.initVal = this.record[item.key] - item.hidden = !_options.includes(item.key) + item.hidden = !options.includes(item.key) + if (reLabel[item.key]) { + item.label = reLabel[item.key] + } return item }) diff --git a/src/tabviews/custom/components/table/edit-table/normalTable/index.jsx b/src/tabviews/custom/components/table/edit-table/normalTable/index.jsx index 5763bcc..762b303 100644 --- a/src/tabviews/custom/components/table/edit-table/normalTable/index.jsx +++ b/src/tabviews/custom/components/table/edit-table/normalTable/index.jsx @@ -562,6 +562,10 @@ if (config.noValue === 'hide' && !value) { value = 0 + } + + if (config.required === 'true' && !value) { + err = `${config.label}涓嶅彲涓�${config.noValue === 'hide' ? '绌�' : '0'}` } else { if (typeof(config.max) === 'number' && value > config.max) { err = config.label + '鏈�澶т负' + config.max @@ -1662,7 +1666,9 @@ } else if (col.type === 'number') { let val = record[col.field] - if (col.noValue === 'hide' && !val) { + if (col.required === 'true' && !val) { + err = `${col.label}涓嶅彲涓�${col.noValue === 'hide' ? '绌�' : '0'}` + } else if (col.noValue === 'hide' && !val) { if (col.clearField && checkForms.includes(col.clearField) && !record[col.clearField]) { err = `璇峰~鍐� ${col.label} 鎴� ${col.clearName}` } @@ -2279,7 +2285,9 @@ item[col.field] = val } else if (col.type === 'number') { let val = item[col.field] - if (col.noValue === 'hide' && !val) { + if (col.required === 'true' && !val) { + err = `${col.label}涓嶅彲涓�${col.noValue === 'hide' ? '绌�' : '0'}` + } else if (col.noValue === 'hide' && !val) { if (col.clearField && checkForms.includes(col.clearField) && !item[col.clearField]) { let msg = `璇峰~鍐� ${col.label} 鎴� ${col.clearName}` if (!line.includes(msg)) { diff --git a/src/tabviews/zshare/mutilform/index.jsx b/src/tabviews/zshare/mutilform/index.jsx index f3de88e..1017e55 100644 --- a/src/tabviews/zshare/mutilform/index.jsx +++ b/src/tabviews/zshare/mutilform/index.jsx @@ -393,11 +393,13 @@ message: item.label + '涓嶅彲涓虹┖!' }] - if (typeof(item.min) === 'number' || typeof(item.max) === 'number') { + if (typeof(item.min) === 'number' || typeof(item.max) === 'number' || item.notZero === 'true') { item.rules.push({ validator: (rule, value, callback) => { if (isNaN(value)) { callback() + } else if (item.notZero === 'true' && value === 0) { + callback(item.label + '涓嶅彲涓�0') } else if (typeof(item.min) === 'number' && value < item.min) { if (item.min < 1e-6) { if (item.min === 1e-6) { diff --git a/src/templates/zshare/formconfig.jsx b/src/templates/zshare/formconfig.jsx index 6ca893d..eef8041 100644 --- a/src/templates/zshare/formconfig.jsx +++ b/src/templates/zshare/formconfig.jsx @@ -1794,6 +1794,19 @@ }, { type: 'radio', + key: 'notZero', + label: "涓嶅彲涓�0", + initVal: card.notZero || 'false', + options: [{ + value: 'true', + text: '鏄�' + }, { + value: 'false', + text: '鍚�' + }] + }, + { + type: 'radio', key: 'database', label: '鏁版嵁搴�', initVal: card.database || 'local', diff --git a/src/templates/zshare/modalform/index.jsx b/src/templates/zshare/modalform/index.jsx index e1311da..17b3585 100644 --- a/src/templates/zshare/modalform/index.jsx +++ b/src/templates/zshare/modalform/index.jsx @@ -21,7 +21,7 @@ const modalTypeOptions = { text: ['initval', 'readonly', 'required', 'hidden', 'readin', 'fieldlength', 'regular', 'interception', 'span', 'labelwidth', 'encryption', 'tooltip', 'extra', 'enter', 'cursor', 'scan', 'splitline', 'placeholder', 'place', 'marginTop', 'marginBottom', 'lenControl', 'inputType', 'constant', 'mkfocus'], - number: ['initval', 'readonly', 'hidden', 'decimal', 'min', 'max', 'readin', 'span', 'labelwidth', 'tooltip', 'extra', 'enter', 'cursor', 'splitline', 'place', 'marginTop', 'marginBottom', 'mkfocus', 'format'], + number: ['initval', 'readonly', 'notZero', 'hidden', 'decimal', 'min', 'max', 'readin', 'span', 'labelwidth', 'tooltip', 'extra', 'enter', 'cursor', 'splitline', 'place', 'marginTop', 'marginBottom', 'mkfocus', 'format'], select: ['initval', 'readonly', 'required', 'hidden', 'readin', 'resourceType', 'declare', 'linkSubField', 'span', 'labelwidth', 'tooltip', 'extra', 'place', 'enter', 'splitline', 'dropdown', 'marginTop', 'marginBottom', 'pickerMode'], checkbox: ['initval', 'readonly', 'required', 'hidden', 'readin', 'resourceType', 'fieldlength', 'span', 'labelwidth', 'tooltip', 'extra', 'place', 'splitline', 'arrange', 'marginTop', 'marginBottom'], radio: ['initval', 'readonly', 'required', 'hidden', 'readin', 'resourceType', 'declare', 'linkSubField', 'span', 'labelwidth', 'tooltip', 'extra', 'place', 'splitline', 'arrange', 'marginTop', 'marginBottom'], -- Gitblit v1.8.0