From d52169be5ed98d6846bb07f75e5a305271e374d4 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期四, 27 四月 2023 18:07:05 +0800
Subject: [PATCH] 2023-04-27

---
 src/menu/components/table/edit-table/columns/editColumn/index.jsx |   34 +++++++++++++++++++++++-----------
 1 files changed, 23 insertions(+), 11 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 e445b43..ed167a3 100644
--- a/src/menu/components/table/edit-table/columns/editColumn/index.jsx
+++ b/src/menu/components/table/edit-table/columns/editColumn/index.jsx
@@ -16,7 +16,7 @@
   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'],
   textarea: ['label', 'field', 'type', 'Align', 'Hide', 'Width', 'prefix', 'initval', 'postfix', 'blacklist'],
-  custom: ['label', 'type', 'Align', 'Hide', 'Width', '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'],
@@ -60,6 +60,10 @@
     let _options = fromJS(columnTypeOptions[this.column.type]).toJS()
 
     if (this.column.editable === 'true') {
+      _options.push('ctrlField')
+      if (this.column.ctrlField) {
+        _options.push('ctrlValue')
+      }
       if (this.column.type === 'text') {
         _options.push('editType')
 
@@ -124,6 +128,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
@@ -134,6 +143,8 @@
       }, () => {
         if (value === 'action' || value === 'colspan') {
           this.props.form.setFieldsValue({Align: 'center'})
+        } else if (value === 'formula' && _field) {
+          this.props.form.setFieldsValue({formula: '@' + _field + '@'})
         }
       })
     } else if (key === 'field') {
@@ -170,7 +181,7 @@
       }
     } else if (key === 'format' && value === 'percent') {
       this.props.form.setFieldsValue({postfix: '%'})
-    } else if (key === 'editable' || key === 'editType' || key === 'resourceType') {
+    } else if (key === 'editable' || key === 'editType' || key === 'resourceType' || key === 'ctrlField') {
       let _options = this.getOptions()
 
       this.setState({
@@ -350,18 +361,19 @@
   }
 
   handleSubmit = () => {
-    // const { columns } = this.props
     // 琛ㄥ崟鎻愪氦鏃舵鏌ヨ緭鍏ュ�兼槸鍚︽纭�
     this.props.form.validateFieldsAndScroll((err, values) => {
       if (!err) {
-        // if (values.field && columns.filter(col => col.field && col.uuid !== values.uuid && col.field === values.field).length > 0) {
-        //   notification.warning({
-        //     top: 92,
-        //     message: '瀛楁宸叉坊鍔狅紒',
-        //     duration: 5
-        //   })
-        //   return
-        // }
+        if (values.type === 'number' && values.editable === 'true') {
+          if (typeof(values.max) === 'number' && typeof(values.min) === 'number' && values.max < values.min) {
+            notification.warning({
+              top: 92,
+              message: '鏈�澶у�间笉鍙皬浜庢渶灏忓�硷紒',
+              duration: 5
+            })
+            return
+          }
+        }
         this.setState({visible: false, formlist: null})
         this.props.submitCol(values)
 

--
Gitblit v1.8.0