From b20a4d7c75c2ff8951e93d9c0394df9277fc6093 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期一, 15 五月 2023 21:05:17 +0800
Subject: [PATCH] 2023-05-15

---
 src/menu/components/table/normal-table/columns/editColumn/index.jsx |  115 +++++++++++++++++++++++++++++++++++++++++++--------------
 1 files changed, 87 insertions(+), 28 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 eb2f413..d971c8e 100644
--- a/src/menu/components/table/normal-table/columns/editColumn/index.jsx
+++ b/src/menu/components/table/normal-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, Cascader, Modal } from 'antd'
+import { Form, Row, Col, Input, Select, InputNumber, Radio, Tooltip, Cascader, Modal, Checkbox, Popover } from 'antd'
 import { QuestionCircleOutlined } from '@ant-design/icons'
 
 import { getColumnForm } from './formconfig'
@@ -14,10 +14,10 @@
   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', 'span'],
+  picture: ['label', 'field', 'type', 'Align', 'Hide', 'IsSort', 'Width', 'blacklist', 'scale', 'lenWidRadio', 'backgroundSize', 'span'],
   video: ['label', 'field', 'type', 'Align', 'Hide', 'startTime', 'Width', 'blacklist', 'aspectRatio'],
   colspan: ['label', 'type', 'Align', 'Hide', 'blacklist'],
-  custom: ['label', 'type', 'Align', 'Hide', 'Width', 'blacklist'],
+  custom: ['label', 'type', 'Align', 'Width', 'blacklist'],
   action: ['label', 'type', 'Align', 'Width'],
   formula: ['label', 'type', 'Align', 'Hide', 'Width', 'prefix', 'postfix', 'eval', 'formula', 'blacklist'],
   index: ['label', 'type', 'Align', 'Width']
@@ -45,9 +45,7 @@
 
   editColumn = (column) => {
     let fields = fromJS(this.props.fields).toJS().map(item => {
-      if (item.label.toLowerCase() !== item.field.toLowerCase()) {
-        item.text = item.label + '锛�' + item.field + '锛�'
-      }
+      item.text = `${item.field}锛�${item.label}锛塦
       return item
     })
     
@@ -66,6 +64,11 @@
       type: column.type,
       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
       })
@@ -86,6 +89,11 @@
     if (key === 'type') {
       let _options = fromJS(columnTypeOptions[value]).toJS()
 
+      let _field = ''
+      if (value === 'formula') {
+        _field = this.props.form.getFieldValue('field') || ''
+      }
+
       this.setState({
         type: value,
         formlist: this.state.formlist.map(item => {
@@ -98,8 +106,14 @@
           this.props.form.setFieldsValue({IsSort: 'false'})
         } else if (value === 'text' || value === 'number') {
           this.props.form.setFieldsValue({perspective: ''})
-        } else if (value === 'action' || value === 'colspan') {
+        } else 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') {
@@ -165,7 +179,7 @@
     if (!formlist) return null
 
     formlist.forEach((item, index) => {
-      if (item.hidden || item.forbidden) return
+      if (item.hidden || item.forbid) return
 
       if (item.type === 'text') {
         let rules = []
@@ -278,6 +292,25 @@
             </Form.Item>
           </Col>
         )
+      } else if (item.type === 'checkbox') {
+        fields.push(
+          <Col span={12} key={index}>
+            <Form.Item label={item.tooltip ?
+              <Tooltip placement="topLeft" title={item.tooltip}>
+                <QuestionCircleOutlined className="mk-form-tip" />
+                {item.label}
+              </Tooltip> : item.label
+            }>
+              {getFieldDecorator(item.key, {
+                initialValue: item.initVal
+              })(
+                <Checkbox.Group>
+                  {item.options.map(option => <Checkbox key={option.value} value={option.value}>{option.text}</Checkbox>)}
+                </Checkbox.Group>
+              )}
+            </Form.Item>
+          </Col>
+        )
       } else if (item.type === 'multiselect') { // 澶氶��
         fields.push(
           <Col span={12} key={index}>
@@ -321,26 +354,52 @@
           </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}>
-                <QuestionCircleOutlined className="mk-form-tip" />
-                {item.label}
-              </Tooltip> : item.label
-            }>
-              {getFieldDecorator(item.key, {
-                initialValue: item.initVal || '',
-                rules: [
-                  {
-                    required: !!item.required,
-                    message: '璇疯緭鍏�' + item.label + '!'
-                  }
-                ]
-              })(<TextArea rows={2} disabled={item.readonly} placeholder={item.placeholder || ''}/>)}
-            </Form.Item>
-          </Col>
-        )
+        if (item.key === 'formula') {
+          fields.push(
+            <Col span={24} className="textarea" key={index}>
+              <Form.Item label={item.tooltip ?
+                <Tooltip placement="topLeft" title={item.tooltip}>
+                  <QuestionCircleOutlined className="mk-form-tip" />
+                  {item.label}
+                </Tooltip> : item.label
+              }>
+                {getFieldDecorator(item.key, {
+                  initialValue: item.initVal || '',
+                  rules: [
+                    {
+                      required: !!item.required,
+                      message: '璇疯緭鍏�' + item.label + '!'
+                    }
+                  ]
+                })(<TextArea autoSize={{minRows: 2}} disabled={item.readonly} placeholder={item.placeholder || ''} />)}
+              </Form.Item>
+              <Popover overlayClassName="formula-fields" placement="topLeft" title="" content={<div>{item.fields}</div>} trigger="click">
+                <span className="formula-icon">瀛楁闆�</span>
+              </Popover>
+            </Col>
+          )
+        } else {
+          fields.push(
+            <Col span={24} key={index} className="textarea">
+              <Form.Item label={item.tooltip ?
+                <Tooltip placement="topLeft" title={item.tooltip}>
+                  <QuestionCircleOutlined className="mk-form-tip" />
+                  {item.label}
+                </Tooltip> : item.label
+              }>
+                {getFieldDecorator(item.key, {
+                  initialValue: item.initVal || '',
+                  rules: [
+                    {
+                      required: !!item.required,
+                      message: '璇疯緭鍏�' + item.label + '!'
+                    }
+                  ]
+                })(<TextArea rows={2} disabled={item.readonly} placeholder={item.placeholder || ''}/>)}
+              </Form.Item>
+            </Col>
+          )
+        }
       }
     })
     return fields

--
Gitblit v1.8.0