From ab262bbe2c64ba086a14f181e5a27eba4b46b555 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期五, 13 十月 2023 17:59:53 +0800 Subject: [PATCH] 2023-10-13 --- src/menu/components/table/edit-table/columns/editColumn/index.jsx | 62 ++++++++++++++++++++++++++++++ 1 files changed, 61 insertions(+), 1 deletions(-) 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 bfc6cad..595109f 100644 --- a/src/menu/components/table/edit-table/columns/editColumn/index.jsx +++ b/src/menu/components/table/edit-table/columns/editColumn/index.jsx @@ -382,8 +382,19 @@ className = 'text-area' let linkSubFields = this.record.linkSubField || [] + + let columns = [] + + columns.push({ title: 'Value', key: 'Value', strict: true }) + columns.push({ title: 'Text', key: 'Text' }) + + linkSubFields.forEach(field => { + if (field === 'Value' || field === 'Text') return + + columns.push({ title: transfield[field] || field, key: field }) + }) - content = <EditTable type={'select'} module="form" transfield={transfield} linkSubFields={linkSubFields} onChange={this.changeOptions}/> + content = <EditTable columns={columns} module="form" onChange={this.changeOptions}/> } fields.push( @@ -403,6 +414,29 @@ ) }) return fields + } + + transfer = (options) => { + if (options.length === 0) return options + + let isNumber = true + options.forEach(item => { + if (!item.Value || isNaN(item.Value)) { + isNumber = false + } + }) + + if (isNumber) { + return options.map(item => { + item.Value = +item.Value + return item + }) + } else { + return options.map(item => { + item.Value = item.Value + '' + return item + }) + } } handleSubmit = () => { @@ -431,6 +465,32 @@ cols.forEach(col => { values.formula = values.formula.replace(col.reg, col.value) }) + } else if (values.type === 'text' && values.editable === 'true' && values.editType === 'select') { + if (values.resourceType === '0') { + values.options = values.options || [] + + values.options = this.transfer(values.options) + + if (values.options.filter(op => op.Text === '').length > 0) { + notification.warning({ + top: 92, + message: '鎻愮ず鏂囨湰锛圱ext锛変笉鍙负绌猴紒', + duration: 5 + }) + return + } else { + let arr = values.options.map(m => m.Value) + let _arr = Array.from(new Set(arr)) + if (arr.length > _arr.length) { + notification.warning({ + top: 92, + message: 'Value鍊间笉鍙噸澶嶏紒', + duration: 5 + }) + return + } + } + } } if (values.dataSource && /\s/.test(values.dataSource)) { -- Gitblit v1.8.0