From c5e5a7580632bc39a9e0c78d548f22a8be5f2019 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期三, 18 十月 2023 18:04:51 +0800 Subject: [PATCH] 2023-10-18 --- src/menu/components/table/edit-table/columns/editColumn/index.jsx | 91 +++++++++++++++++++++++++++++++++++---------- 1 files changed, 71 insertions(+), 20 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 14f0606..595109f 100644 --- a/src/menu/components/table/edit-table/columns/editColumn/index.jsx +++ b/src/menu/components/table/edit-table/columns/editColumn/index.jsx @@ -3,7 +3,6 @@ import { is, fromJS } from 'immutable' import { Form, Row, Col, Input, Select, InputNumber, Radio, Tooltip, Modal, notification, Popover } from 'antd' import { QuestionCircleOutlined } from '@ant-design/icons' -import moment from 'moment' import Api from '@/api' import Utils from '@/utils/utils.js' @@ -383,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( @@ -404,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 = () => { @@ -432,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)) { @@ -449,27 +508,19 @@ this.setState({ loading: true }) - - let param = { - func: 's_debug_sql', - exec_type: 'y', - LText: `declare @mk_departmentcode nvarchar(512),@mk_organization nvarchar(512),@mk_user_type nvarchar(20) - ${values.dataSource}` - } - - param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') - param.LText = param.LText.replace(/@\$|\$@/ig, '').replace(/@(BID|ID|LoginUID|SessionUid|UserID|Appkey|time_id)@/ig, `'${param.timestamp}'`) - param.LText = param.LText.replace(/\n/g, ' ') - - param.LText = Utils.formatOptions(param.LText) - param.secretkey = Utils.encrypt('', param.timestamp) - + + let sql = `declare @mk_departmentcode nvarchar(512),@mk_organization nvarchar(512),@mk_user_type nvarchar(20) + ${values.dataSource}` + + sql = sql.replace(/@\$|\$@/ig, '').replace(/@(BID|ID|LoginUID|SessionUid|UserID|Appkey|time_id)@/ig, `'1949-10-01 15:00:00'`) + + let rduri = '' if (window.GLOB.mainSystemApi && values.database === 'sso') { - param.rduri = window.GLOB.mainSystemApi + rduri = window.GLOB.mainSystemApi } - Api.genericInterface(param).then(result => { - if (result.status) { + Api.sDebug(sql, rduri).then(result => { + if (result.status || result.ErrCode === '-2') { this.setState({visible: false, loading: false, formlist: null}) this.props.submitCol(values) this.record = null -- Gitblit v1.8.0