From 24bba05db141f358bf1a8bb7213a2432c9de355e Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期五, 08 十月 2021 19:14:22 +0800
Subject: [PATCH] 2021-10-08

---
 src/menu/components/table/edit-table/columns/editColumn/index.jsx |   53 +++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 51 insertions(+), 2 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 10a6f8c..17cfbda 100644
--- a/src/menu/components/table/edit-table/columns/editColumn/index.jsx
+++ b/src/menu/components/table/edit-table/columns/editColumn/index.jsx
@@ -9,7 +9,7 @@
 
 const columnTypeOptions = {
   text: ['label', 'field', 'type', 'Align', 'Hide', 'IsSort', 'Width', 'prefix', 'postfix', 'textFormat', 'editable', 'blacklist'],
-  number: ['label', 'field', 'type', 'Align', 'Hide', 'IsSort', 'Width', 'decimal', 'format', 'prefix', 'postfix', 'editable', 'blacklist'],
+  number: ['label', 'field', 'type', 'Align', 'Hide', 'IsSort', 'Width', 'decimal', 'format', 'prefix', 'postfix', 'editable', 'sum', 'blacklist'],
   textarea: ['label', 'field', 'type', 'Align', 'Hide', 'Width', 'prefix', 'postfix', 'blacklist'],
   custom: ['label', 'type', 'Align', 'Hide', 'Width', 'blacklist'],
   action: ['label', 'type', 'Align', 'Width'],
@@ -21,6 +21,7 @@
     dict: PropTypes.object,     // 瀛楀吀椤�
     visible: PropTypes.bool,
     column: PropTypes.object,
+    columns: PropTypes.array,
     fields: PropTypes.array,
     submitCol: PropTypes.func,  // 鎻愪氦浜嬩欢
     cancelCol: PropTypes.func   // 鍙栨秷鏃跺垹闄や簨浠�
@@ -38,8 +39,16 @@
   }
 
   editColumn = (column) => {
-    let formlist = getColumnForm(column, this.props.fields)
+    let formlist = getColumnForm(column, this.props.fields, this.props.columns)
     let _options = fromJS(columnTypeOptions[column.type]).toJS()
+
+    if (column.editable === 'true') {
+      if (column.type === 'text') {
+        _options.push('required', 'initval', 'enter', 'footEnter')
+      } else if (column.type === 'number') {
+        _options.push('max', 'min', 'initval', 'enter', 'footEnter')
+      }
+    }
 
     this.setState({
       visible: true,
@@ -63,12 +72,24 @@
   }
 
   typeChange = (key, value, option) => {
+    const { editable, type } = this.state
     if (key === 'type') {
       let _options = fromJS(columnTypeOptions[value]).toJS()
+
+      if (editable === 'true') {
+        if (value === 'text') {
+          _options.push('required', 'initval', 'enter', 'footEnter')
+        } else if (value === 'number') {
+          _options.push('max', 'min', 'initval', 'enter', 'footEnter')
+        }
+      }
 
       this.setState({
         type: value,
         formlist: this.state.formlist.map(item => {
+          if (item.key === 'editable') {
+            item.initVal = editable
+          }
           item.hidden = !_options.includes(item.key)
 
           return item
@@ -94,9 +115,20 @@
       if (values.type !== this.state.type) {
         let _options = fromJS(columnTypeOptions[values.type]).toJS()
 
+        if (editable === 'true') {
+          if (values.type === 'text') {
+            _options.push('required', 'initval', 'enter', 'footEnter')
+          } else if (values.type === 'number') {
+            _options.push('max', 'min', 'initval', 'enter', 'footEnter')
+          }
+        }
+
         this.setState({
           type: values.type,
           formlist: this.state.formlist.map(item => {
+            if (item.key === 'editable') {
+              item.initVal = editable
+            }
             item.hidden = !_options.includes(item.key)
 
             return item
@@ -110,7 +142,24 @@
     } else if (key === 'format' && value === 'percent') {
       this.props.form.setFieldsValue({postfix: '%'})
     } else if (key === 'editable') {
+      let _options = fromJS(columnTypeOptions[type]).toJS()
 
+      if (value === 'true') {
+        if (type === 'text') {
+          _options.push('required', 'initval', 'enter', 'footEnter')
+        } else if (type === 'number') {
+          _options.push('max', 'min', 'initval', 'enter', 'footEnter')
+        }
+      }
+
+      this.setState({
+        editable: value,
+        formlist: this.state.formlist.map(item => {
+          item.hidden = !_options.includes(item.key)
+
+          return item
+        })
+      })
     }
   }
 

--
Gitblit v1.8.0