From 7b0dbecd1d6155d26ec67be0a47a16264c738c85 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期二, 09 五月 2023 14:48:10 +0800 Subject: [PATCH] 2023-05-09 --- src/menu/components/table/edit-table/columns/editColumn/index.jsx | 46 ++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 42 insertions(+), 4 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 ba7f32b..6e92415 100644 --- a/src/menu/components/table/edit-table/columns/editColumn/index.jsx +++ b/src/menu/components/table/edit-table/columns/editColumn/index.jsx @@ -1,7 +1,7 @@ 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 } from 'antd' +import { Form, Row, Col, Input, Select, InputNumber, Radio, Tooltip, Modal, notification, Popover } from 'antd' import { QuestionCircleOutlined } from '@ant-design/icons' import { getColumnForm } from './formconfig' @@ -14,12 +14,12 @@ const { TextArea } = Input const columnTypeOptions = { text: ['label', 'field', 'type', 'Align', 'Hide', 'IsSort', 'Width', 'prefix', 'postfix', 'textFormat', 'editable', 'initval', 'blacklist'], - number: ['label', 'field', 'type', 'Align', 'Hide', 'IsSort', 'Width', 'decimal', 'format', 'prefix', 'postfix', 'editable', 'initval', 'sum', 'blacklist'], + number: ['label', 'field', 'type', 'Align', 'Hide', 'IsSort', 'Width', 'decimal', 'format', 'prefix', 'postfix', 'editable', 'initval', 'sum', 'blacklist', 'noValue'], textarea: ['label', 'field', 'type', 'Align', 'Hide', 'Width', 'prefix', 'initval', 'postfix', 'blacklist'], custom: ['label', 'type', 'Align', 'Width', 'blacklist'], colspan: ['label', 'type', 'Align', 'Hide', 'blacklist'], action: ['label', 'type', 'Align', 'Width'], - formula: ['label', 'type', 'Align', 'Hide', 'Width', 'prefix', 'postfix', 'eval', 'formula', 'blacklist'], + formula: ['label', 'type', 'Align', 'Hide', 'Width', 'prefix', 'postfix', 'eval', 'formula', 'blacklist', 'noValue'], index: ['label', 'type', 'Align', 'Width'] } @@ -107,6 +107,11 @@ formlist: formlist.map(item => { item.hidden = !_options.includes(item.key) + if (item.key === 'formula') { + item.fields = this.props.fields.map(col => col.field) + item.fields = item.fields.join(', ') + } + return item }) }) @@ -128,6 +133,11 @@ if (key === 'type') { let _options = this.getOptions() + let _field = '' + if (value === 'formula') { + _field = this.props.form.getFieldValue('field') || '' + } + this.setState({ formlist: this.state.formlist.map(item => { item.initVal = this.column[item.key] || item.initVal @@ -136,8 +146,14 @@ return item }) }, () => { - if (value === 'action' || value === 'colspan') { + if (value === 'colspan') { this.props.form.setFieldsValue({Align: 'center'}) + } else if (value === 'formula' && _field) { + this.props.form.setFieldsValue({formula: '@' + _field + '@'}) + } else if (value === 'action') { + this.props.form.setFieldsValue({Align: 'center', label: '鎿嶄綔'}) + } else if (value === 'index') { + this.props.form.setFieldsValue({label: '搴忓彿'}) } }) } else if (key === 'field') { @@ -314,6 +330,28 @@ { required: item.required, message: '璇疯緭鍏�' + item.label + '!' } ] + 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 + }> + {getFieldDecorator(item.key, { + initialValue: initVal, + rules: rules + })(<TextArea rows={item.rows || 2}/>)} + </Form.Item> + <Popover overlayClassName="formula-fields" placement="topLeft" title="" content={<div>{item.fields}</div>} trigger="click"> + <span className="formula-icon">瀛楁闆�</span> + </Popover> + </Col> + ) + return + } + content = <TextArea rows={item.rows || 2}/> } else if (item.type === 'codemirror') { rules = [ -- Gitblit v1.8.0