From f3d4db769ba9b51b799d981511a710fd443d0e08 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期一, 21 四月 2025 12:18:03 +0800 Subject: [PATCH] Merge branch 'master' into positec --- src/menu/components/table/edit-table/columns/editColumn/index.jsx | 166 ++++++++++++++++++++++++++++++++++++------------------ 1 files changed, 110 insertions(+), 56 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 baca4f6..bec94a9 100644 --- a/src/menu/components/table/edit-table/columns/editColumn/index.jsx +++ b/src/menu/components/table/edit-table/columns/editColumn/index.jsx @@ -1,11 +1,12 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' import { is, fromJS } from 'immutable' -import { Form, Row, Col, Input, Select, InputNumber, Radio, Tooltip, Modal, notification, Popover } from 'antd' +import { Form, Row, Col, Input, Select, InputNumber, Radio, Checkbox, Tooltip, Modal, notification, Popover } from 'antd' import { QuestionCircleOutlined } from '@ant-design/icons' 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' @@ -22,6 +23,7 @@ textarea: ['label', 'field', 'type', 'Align', 'Hide', 'Width', 'prefix', 'initval', 'postfix', 'blacklist'], custom: ['label', 'type', 'Align', 'Width', 'blacklist', 'IsSort'], colspan: ['label', 'type', 'Align', 'Hide', 'blacklist'], + extend: ['label', 'field', 'type', 'Align', 'Width', 'colUnit', 'shift', 'quota', 'supField'], action: ['label', 'type', 'Align', 'Width'], formula: ['label', 'type', 'Align', 'Hide', 'Width', 'prefix', 'postfix', 'eval', 'formula', 'blacklist'], index: ['label', 'type', 'Align', 'Width'] @@ -30,6 +32,7 @@ class EdiTableColumn extends Component { static propTpyes = { column: PropTypes.object, + wrap: PropTypes.object, columns: PropTypes.array, fields: PropTypes.array, submitCol: PropTypes.func, // 鎻愪氦浜嬩欢 @@ -63,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) { @@ -76,9 +81,9 @@ } 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') + _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') + _options.push('required', 'enter', 'resourceType', 'linkSubField', 'dropdown', 'showValue') if (this.record.resourceType === '0') { _options.push('options') @@ -88,20 +93,40 @@ } else { _options.push('required', 'enter') } + + reLabel.required = '蹇呭~' } else if (this.record.type === 'number') { - _options.push('max', 'min', 'enter') + _options.push('max', 'min', 'required', 'enter', 'clearField') + + reLabel.required = '涓嶇瓑浜�0' + } + } else if (this.record.type === 'extend') { + if (this.record.colUnit === 'day') { + _options.push('dayFormat') + } else { + _options.push('hourFormat') } } - if (this.record.type === 'formula' && this.record.eval === 'true') { - _options.push('decimal') + if (this.record.type === 'formula') { + if (this.record.eval === 'true') { + _options.push('decimal') + } + if (this.record.eval !== 'func') { + _options.push('evalchars') + } } 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 + return {options: _options, reLabel} } editColumn = (column) => { @@ -110,19 +135,23 @@ 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 => { 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) @@ -152,7 +181,7 @@ this.record.IsSort = 'false' } - let _options = this.getOptions() + let { options, reLabel } = this.getOptions() let _field = '' if (value === 'formula') { @@ -166,7 +195,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 }) @@ -198,12 +230,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 }) @@ -215,13 +250,34 @@ } } else if (key === 'format' && value === 'percent') { this.props.form.setFieldsValue({postfix: '%'}) - } else if (['editable', 'editType', 'resourceType', 'ctrlField', 'eval', 'Hide', 'IsSort'].includes(key)) { - let _options = this.getOptions() + } else if (key === 'editType') { + let { options, reLabel } = 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) + 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, 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 }) @@ -289,6 +345,14 @@ let content = null let extra = null let initVal = item.initVal || '' + let label = item.label + if (item.tooltip) { + if (item.toolWidth) { + label = <Tooltip placement="topLeft" overlayStyle={{maxWidth: item.toolWidth}} title={<div onClick={(e) => e.stopPropagation()}>{item.tooltip}</div>}><QuestionCircleOutlined className="mk-form-tip" />{item.label}</Tooltip> + } else { + label = <Tooltip placement="topLeft" title={<div onClick={(e) => e.stopPropagation()}>{item.tooltip}</div>}><QuestionCircleOutlined className="mk-form-tip" />{item.label}</Tooltip> + } + } if (item.type === 'text') { rules = [ @@ -329,7 +393,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> )} @@ -343,6 +407,15 @@ content = <Radio.Group onChange={(e) => {this.typeChange(item.key, e.target.value)}}> {item.options.map(option => <Radio key={option.value} value={option.value}>{option.text}</Radio>)} </Radio.Group> + } else if (item.type === 'checkbox') { + rules = [ + { required: item.required, message: '璇烽�夋嫨' + item.label + '!' } + ] + initVal = item.initVal + + content = <Checkbox.Group onChange={(e) => {this.typeChange(item.key, e.target.value)}}> + {item.options.map(option => <Checkbox key={option.value} value={option.value}>{option.text}</Checkbox>)} + </Checkbox.Group> } else if (item.type === 'multiselect') { // 澶氶�� content = <Select showSearch @@ -363,12 +436,7 @@ if (item.key === 'formula') { fields.push( <Col span={span} key={index}> - <Form.Item className={className} extra={extra} label={item.tooltip ? - <Tooltip placement="topLeft" title={item.tooltip}> - <QuestionCircleOutlined className="mk-form-tip" /> - {item.label} - </Tooltip> : item.label - }> + <Form.Item className={className} extra={extra} label={label}> {getFieldDecorator(item.key, { initialValue: initVal, rules: rules @@ -393,6 +461,7 @@ extra = <span className="add-resource-empty" onClick={this.handleEmpty}>绌�</span> } if (item.placeholder) { + className = 'show-public-var' extra = <><span className="resource-public-var">{item.placeholder}</span>{extra}</> } @@ -425,12 +494,7 @@ fields.push( <Col span={span} key={index}> - <Form.Item className={className} extra={extra} label={item.tooltip ? - <Tooltip placement="topLeft" title={item.tooltip}> - <QuestionCircleOutlined className="mk-form-tip" /> - {item.label} - </Tooltip> : item.label - }> + <Form.Item className={className} extra={extra} label={label}> {getFieldDecorator(item.key, { initialValue: initVal, rules: rules @@ -519,34 +583,28 @@ } } - 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.editType === 'select' && values.resourceType === '1' && values.dataSource) { + if (values.dataSource) { + let pass = checkSQL(values.dataSource) + + if (!pass) return + } + + if (values.editType === 'select' && values.resourceType === '1' && values.database !== 'sso' && values.dataSource) { let _option = Utils.getSelectQueryOptions(values) let sql = `declare @mk_departmentcode nvarchar(512),@mk_organization nvarchar(512),@mk_user_type nvarchar(20) ${_option.sql}` // LoginUID|SessionUid|UserID|Appkey 宸叉浛鎹� - sql = sql.replace(/@\$|\$@/ig, '').replace(/@(BID|ID|time_id)@/ig, `'1949-10-01 15:00:00'`) - - let rduri = '' - if (window.GLOB.mainSystemApi && values.database === 'sso') { - rduri = window.GLOB.mainSystemApi - } + sql = sql.replace(/@\$|\$@/ig, '') - Api.sDebug(sql, rduri).then(result => { + Api.sDebug(sql).then(result => { if (result.status || result.ErrCode === '-2') { this.setState({visible: false, loading: false, formlist: null}) this.props.submitCol(values) @@ -596,11 +654,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') { @@ -648,7 +702,7 @@ title="鏄剧ず鍒楃紪杈�" wrapClassName="mk-scroll-modal" visible={visible} - width={900} + width={950} maskClosable={false} onOk={this.handleSubmit} onCancel={this.editModalCancel} -- Gitblit v1.8.0