From 67036fb0ed31d77ca33b660ce5f9f47c29ae65c0 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期日, 03 三月 2024 11:47:46 +0800 Subject: [PATCH] 2024-03-03 --- src/menu/components/table/edit-table/columns/editColumn/index.jsx | 63 ++++++++++++++++++++----------- 1 files changed, 40 insertions(+), 23 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 25e6c22..fd16488 100644 --- a/src/menu/components/table/edit-table/columns/editColumn/index.jsx +++ b/src/menu/components/table/edit-table/columns/editColumn/index.jsx @@ -6,6 +6,7 @@ import Api from '@/api' import Utils from '@/utils/utils.js' +import { checkSQL } from '@/utils/utils-custom.js' import { getColumnForm } from './formconfig' import asyncComponent from '@/utils/asyncComponent' import { formRule } from '@/utils/option.js' @@ -30,6 +31,7 @@ class EdiTableColumn extends Component { static propTpyes = { column: PropTypes.object, + wrap: PropTypes.object, columns: PropTypes.array, fields: PropTypes.array, submitCol: PropTypes.func, // 鎻愪氦浜嬩欢 @@ -76,7 +78,7 @@ } else if (this.record.editType === 'date') { _options.push('required', 'precision', 'enter', 'declareType') } else if (this.record.editType === 'popSelect') { - _options.push('required', 'enter', 'linkSubField', 'columns', 'dataSource', 'primaryKey', 'order', 'showField', 'controlField', 'searchKey', 'popWidth', 'laypage', 'onload') + _options.push('required', 'enter', 'linkSubField', 'columns', 'dataSource', 'primaryKey', 'order', 'showField', 'controlField', 'searchKey', 'popWidth', 'laypage', 'cache', 'onload') } else if (this.record.editType === 'select') { _options.push('required', 'enter', 'resourceType', 'linkSubField', 'dropdown') @@ -89,7 +91,7 @@ _options.push('required', 'enter') } } else if (this.record.type === 'number') { - _options.push('max', 'min', 'enter') + _options.push('max', 'min', 'enter', 'clearField') } } if (this.record.type === 'formula' && this.record.eval === 'true') { @@ -97,8 +99,13 @@ } else if (this.record.type === 'custom' && this.record.IsSort === 'true') { _options.push('sortField') } - if (['number', 'formula'].includes(this.record.type) && this.record.Hide !== 'true') { - _options.push('noValue') + + if (this.record.Hide !== 'true') { + if (['number', 'formula'].includes(this.record.type)) { + _options.push('noValue') + } else if (this.record.type === 'text' && ['YYYY-MM-DD', 'YYYY-MM-DD HH:mm:ss'].includes(this.record.textFormat)) { + _options.push('noValue') + } } return _options @@ -110,7 +117,7 @@ return item }) - let formlist = getColumnForm(column, fields, this.props.columns) + let formlist = getColumnForm(column, fields, this.props.columns, this.props.wrap) this.record = {} formlist.forEach(item => { @@ -215,7 +222,22 @@ } } else if (key === 'format' && value === 'percent') { this.props.form.setFieldsValue({postfix: '%'}) - } else if (['editable', 'editType', 'resourceType', 'ctrlField', 'eval', 'Hide', 'IsSort'].includes(key)) { + } else if (key === 'editType') { + let _options = this.getOptions() + + this.setState({ + formlist: this.state.formlist.map(item => { + if (item.key === 'enter' && item.options && item.options[item.options.length - 1].field === '$noActX') { + item.options[item.options.length - 1].disabled = value !== 'select' + } + + item.initVal = this.record[item.key] + item.hidden = !_options.includes(item.key) + + return item + }) + }) + } else if (['editable', 'editType', 'resourceType', 'ctrlField', 'eval', 'Hide', 'IsSort', 'textFormat'].includes(key)) { let _options = this.getOptions() this.setState({ @@ -329,7 +351,7 @@ getPopupContainer={() => document.getElementById('edit-table-column-winter')} > {options.map((option, i) => - <Select.Option key={i} datatype={option.datatype || ''} label={option.label || ''} value={(option.value || option.field || option.MenuID)}> + <Select.Option key={i} disabled={option.disabled === true} datatype={option.datatype || ''} label={option.label || ''} value={(option.value || option.field || option.MenuID)}> {(option.text || option.label || option.MenuName)} </Select.Option> )} @@ -519,17 +541,16 @@ } } - if (values.dataSource) { - let error = Utils.verifySql(values.dataSource) - - if (error) { - notification.warning({ - top: 92, - message: '鏁版嵁婧愪腑涓嶅彲浣跨敤' + error, - duration: 5 - }) - return + if (values.type === 'text' && values.editable === 'true') { + if (values.editType !== 'select' && values.enter === '$noActX') { + values.enter = '$noAct' } + } + + if (values.dataSource) { + let pass = checkSQL(values.dataSource) + + if (!pass) return } if (values.editType === 'select' && values.resourceType === '1' && values.dataSource) { @@ -539,7 +560,7 @@ ${_option.sql}` // LoginUID|SessionUid|UserID|Appkey 宸叉浛鎹� - sql = sql.replace(/@\$|\$@/ig, '').replace(/@(BID|ID|time_id)@/ig, `'1949-10-01 15:00:00'`) + sql = sql.replace(/@\$|\$@/ig, '') let rduri = '' if (window.GLOB.mainSystemApi && values.database === 'sso') { @@ -596,11 +617,7 @@ sql = `declare @mk_departmentcode nvarchar(512),@mk_organization nvarchar(512),@mk_user_type nvarchar(20) ${sql}` - sql = sql.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, '\'\'') - sql = sql.replace(/@LoginUID@/ig, `'${sessionStorage.getItem('LoginUID') || ''}'`) - sql = sql.replace(/@SessionUid@/ig, `'${localStorage.getItem('SessionUid') || ''}'`) - sql = sql.replace(/@UserID@/ig, `'${sessionStorage.getItem('UserID') || ''}'`) - sql = sql.replace(/@Appkey@/ig, `'${window.GLOB.appkey || ''}'`) + sql = sql.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, `''`) Api.sDebug(sql).then(result => { if (result.status || result.ErrCode === '-2') { -- Gitblit v1.8.0