From 682a74e858e5a6cd24d36183931d3afafd6443d7 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期三, 31 三月 2021 10:56:48 +0800 Subject: [PATCH] 2021-03-31 --- src/menu/components/table/normal-table/columns/editColumn/index.jsx | 71 +++++++++++++++++++++++++---------- 1 files changed, 51 insertions(+), 20 deletions(-) diff --git a/src/menu/components/table/normal-table/columns/editColumn/index.jsx b/src/menu/components/table/normal-table/columns/editColumn/index.jsx index 2c86c2c..43c63ac 100644 --- a/src/menu/components/table/normal-table/columns/editColumn/index.jsx +++ b/src/menu/components/table/normal-table/columns/editColumn/index.jsx @@ -7,12 +7,13 @@ import { formRule } from '@/utils/option.js' import './index.scss' +const { TextArea } = Input const columnTypeOptions = { text: ['label', 'field', 'type', 'Align', 'Hide', 'IsSort', 'Width', 'prefix', 'postfix', 'textFormat', 'blacklist', 'perspective', 'rowspan'], - number: ['label', 'field', 'type', 'Align', 'Hide', 'IsSort', 'Width', 'decimal', 'format', 'prefix', 'postfix', 'blacklist', 'perspective', 'sum'], - link: ['label', 'field', 'type', 'Align', 'Hide', 'IsSort', 'joint', 'Width', 'blacklist'], + number: ['label', 'field', 'type', 'Align', 'Hide', 'IsSort', 'Width', 'decimal', 'format', 'prefix', 'postfix', 'blacklist', 'perspective', 'sum', 'rowspan'], + link: ['label', 'field', 'type', 'Align', 'Hide', 'IsSort', 'joint', 'Width', 'blacklist', 'nameField'], textarea: ['label', 'field', 'type', 'Align', 'Hide', 'IsSort', 'Width', 'prefix', 'postfix', 'blacklist'], - picture: ['label', 'field', 'type', 'Align', 'Hide', 'IsSort', 'Width', 'blacklist', 'scale', 'lenWidRadio'], + picture: ['label', 'field', 'type', 'Align', 'Hide', 'IsSort', 'Width', 'blacklist', 'scale', 'lenWidRadio', 'picSort'], colspan: ['label', 'type', 'Align', 'Hide', 'blacklist'], custom: ['label', 'type', 'Align', 'Hide', 'Width', 'blacklist'], action: ['label', 'type', 'Align', 'Width'] @@ -54,10 +55,10 @@ let formlist = getColumnForm(column, menulist, this.props.fields) let _options = fromJS(columnTypeOptions[column.type]).toJS() if (column.type === 'text' || column.type === 'number') { - if (column.perspective !== 'linkurl') { - _options.push('linkmenu') - } else { - _options.push('linkurl') + if (column.perspective === 'linkmenu') { + _options.push('linkmenu', 'linkfields') + } else if (column.perspective === 'linkurl') { + _options.push('linkurl', 'linkfields') } } @@ -85,10 +86,6 @@ if (key === 'type') { let _options = fromJS(columnTypeOptions[value]).toJS() - if (value === 'text' || value === 'number') { - _options.push('linkmenu') - } - this.setState({ type: value, formlist: this.state.formlist.map(item => { @@ -100,13 +97,20 @@ if (value === 'link' || value === 'textarea' || value === 'picture') { this.props.form.setFieldsValue({IsSort: 'false'}) } else if (value === 'text' || value === 'number') { - this.props.form.setFieldsValue({perspective: 'linkmenu'}) + this.props.form.setFieldsValue({perspective: ''}) } else if (value === 'action' || value === 'colspan') { this.props.form.setFieldsValue({Align: 'center'}) } }) } else if (key === 'field') { this.props.form.setFieldsValue({label: option.props.children}) + if (this.state.type === 'number') { + let decimal = 0 + if (/Decimal/ig.test(option.props.datatype)) { + decimal = +option.props.datatype.replace(/Decimal\(18,/ig, '').replace(')', '') + } + this.props.form.setFieldsValue({decimal}) + } } else if (key === 'format' && value === 'percent') { this.props.form.setFieldsValue({postfix: '%'}) } @@ -116,10 +120,10 @@ if (key === 'perspective') { let _options = fromJS(columnTypeOptions[this.state.type]).toJS() - if (value !== 'linkurl') { - _options.push('linkmenu') - } else { - _options.push('linkurl') + if (value === 'linkmenu') { + _options.push('linkmenu', 'linkfields') + } else if (value === 'linkurl') { + _options.push('linkurl', 'linkfields') } this.setState({ @@ -140,7 +144,7 @@ if (!formlist) return null formlist.forEach((item, index) => { - if (item.hidden) return + if (item.hidden || item.forbidden) return if (item.type === 'text') { // 鏂囨湰鎼滅储 let rules = [] @@ -213,7 +217,7 @@ getPopupContainer={() => document.getElementById('columnwinter')} > {item.options.map((option, index) => - <Select.Option key={`${index}`} value={option.value || option.field}> + <Select.Option key={`${option.value || option.field}${index}`} datatype={option.datatype || ''} value={option.value || option.field}> {option.text || option.label} </Select.Option> )} @@ -266,7 +270,7 @@ filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0} > {item.options.map((option, i) => - <Select.Option id={i} key={i} value={option.value}>{option.text}</Select.Option> + <Select.Option id={i} key={i} value={option.value || option.field}>{option.text || option.label}</Select.Option> )} </Select> )} @@ -278,7 +282,13 @@ <Col span={12} key={index}> <Form.Item label={item.label}> {getFieldDecorator(item.key, { - initialValue: item.initVal || [] + initialValue: item.initVal || [], + rules: [ + { + required: !!item.required, + message: this.props.dict['form.required.select'] + item.label + '!' + } + ] })( <Cascader options={item.options} @@ -289,6 +299,27 @@ </Form.Item> </Col> ) + } else if (item.type === 'textarea') { // 鏂囨湰鎼滅储 + fields.push( + <Col span={24} key={index} className="textarea"> + <Form.Item label={item.tooltip ? + <Tooltip placement="topLeft" title={item.tooltip}> + <Icon type="question-circle" /> + {item.label} + </Tooltip> : item.label + }> + {getFieldDecorator(item.key, { + initialValue: item.initVal || '', + rules: [ + { + required: !!item.required, + message: this.props.dict['form.required.input'] + item.label + '!' + } + ] + })(<TextArea rows={2} disabled={item.readonly} onPressEnter={this.handleSubmit} />)} + </Form.Item> + </Col> + ) } }) return fields -- Gitblit v1.8.0