From 072227ec43346c50c93cda3bf21c346f463eb551 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期四, 19 十月 2023 22:28:56 +0800
Subject: [PATCH] 2023-10-19

---
 src/menu/components/table/normal-table/columns/editColumn/formconfig.jsx |   10 ++++
 src/menu/components/table/base-table/columns/editColumn/index.jsx        |   16 +++++---
 src/menu/components/table/normal-table/columns/editColumn/index.jsx      |   16 +++++---
 src/tabviews/custom/components/share/normalTable/index.jsx               |    4 +
 src/menu/components/table/edit-table/columns/editColumn/index.jsx        |   14 +++++-
 src/menu/components/table/base-table/columns/editColumn/formconfig.jsx   |   10 ++++
 src/menu/components/table/edit-table/columns/editColumn/formconfig.jsx   |   10 ++++
 src/tabviews/custom/components/table/edit-table/normalTable/index.jsx    |    4 +
 8 files changed, 64 insertions(+), 20 deletions(-)

diff --git a/src/menu/components/table/base-table/columns/editColumn/formconfig.jsx b/src/menu/components/table/base-table/columns/editColumn/formconfig.jsx
index aed7101..afb5789 100644
--- a/src/menu/components/table/base-table/columns/editColumn/formconfig.jsx
+++ b/src/menu/components/table/base-table/columns/editColumn/formconfig.jsx
@@ -151,7 +151,7 @@
       type: 'radio',
       key: 'IsSort',
       label: '鎺掑簭',
-      initVal: card.IsSort || (card.isSub ? 'false' : 'true'),
+      initVal: card.IsSort || (card.isSub || card.type === 'custom' ? 'false' : 'true'),
       required: true,
       options: [{
         value: 'true',
@@ -162,6 +162,14 @@
       }]
     },
     {
+      type: 'select',
+      key: 'sortField',
+      label: '鎺掑簭瀛楁',
+      initVal: card.sortField || '',
+      required: true,
+      options: fields
+    },
+    {
       type: 'radio',
       key: 'eval',
       label: '瑙f瀽鏂瑰紡',
diff --git a/src/menu/components/table/base-table/columns/editColumn/index.jsx b/src/menu/components/table/base-table/columns/editColumn/index.jsx
index 7318054..3c5bc6b 100644
--- a/src/menu/components/table/base-table/columns/editColumn/index.jsx
+++ b/src/menu/components/table/base-table/columns/editColumn/index.jsx
@@ -16,7 +16,7 @@
   picture: ['label', 'field', 'type', 'Align', 'Hide', 'IsSort', 'Width', 'fieldlength', 'blacklist', 'scale', 'lenWidRadio', 'backgroundSize', 'span'],
   video: ['label', 'field', 'type', 'Align', 'Hide', 'startTime', 'Width', 'fieldlength', 'blacklist', 'aspectRatio'],
   colspan: ['label', 'type', 'Align', 'Hide', 'blacklist'],
-  custom: ['label', 'type', 'Align', 'Width', 'blacklist'],
+  custom: ['label', 'type', 'Align', 'Width', 'blacklist', 'IsSort'],
   action: ['label', 'type', 'Align', 'Width'],
   formula: ['label', 'type', 'Align', 'Hide', 'Width', 'prefix', 'postfix', 'eval', 'formula', 'blacklist'],
   index: ['label', 'type', 'Align', 'Width']
@@ -95,10 +95,10 @@
       } else if (this.record.perspective === 'linkurl') {
         _options.push('linkurl', 'linkfields', 'open')
       }
-    }
-    
-    if (this.record.type === 'formula' && this.record.eval === 'true') {
+    } else if (this.record.type === 'formula' && this.record.eval === 'true') {
       _options.push('decimal')
+    } else if (this.record.type === 'custom' && this.record.IsSort === 'true') {
+      _options.push('sortField')
     }
 
     return _options
@@ -109,6 +109,10 @@
     this.record[key] = value
 
     if (key === 'type') {
+      if (['link', 'textarea', 'picture', 'custom'].includes(value)) {
+        this.record.IsSort = 'false'
+      }
+
       let _options = this.getOptions()
 
       this.setState({
@@ -126,7 +130,7 @@
           return item
         })
       }, () => {
-        if (value === 'link' || value === 'textarea' || value === 'picture') {
+        if (['link', 'textarea', 'picture', 'custom'].includes(value)) {
           this.props.form.setFieldsValue({IsSort: 'false'})
         } else if (value === 'text' || value === 'number') {
           this.props.form.setFieldsValue({perspective: ''})
@@ -173,7 +177,7 @@
       }
     } else if (key === 'format' && value === 'percent') {
       this.props.form.setFieldsValue({postfix: '%'})
-    } else if (['perspective', 'eval'].includes(key)) {
+    } else if (['perspective', 'eval', 'IsSort'].includes(key)) {
       let _options = this.getOptions()
 
       this.setState({
diff --git a/src/menu/components/table/edit-table/columns/editColumn/formconfig.jsx b/src/menu/components/table/edit-table/columns/editColumn/formconfig.jsx
index 0254d8b..9142ee4 100644
--- a/src/menu/components/table/edit-table/columns/editColumn/formconfig.jsx
+++ b/src/menu/components/table/edit-table/columns/editColumn/formconfig.jsx
@@ -133,7 +133,7 @@
       type: 'radio',
       key: 'IsSort',
       label: '鎺掑簭',
-      initVal: card.IsSort || (card.isSub ? 'false' : 'true'),
+      initVal: card.IsSort || (card.isSub || card.type === 'custom' ? 'false' : 'true'),
       required: true,
       options: [{
         value: 'true',
@@ -144,6 +144,14 @@
       }]
     },
     {
+      type: 'select',
+      key: 'sortField',
+      label: '鎺掑簭瀛楁',
+      initVal: card.sortField || '',
+      required: true,
+      options: fields
+    },
+    {
       type: 'radio',
       key: 'eval',
       label: '瑙f瀽鏂瑰紡',
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 9a107bb..796a764 100644
--- a/src/menu/components/table/edit-table/columns/editColumn/index.jsx
+++ b/src/menu/components/table/edit-table/columns/editColumn/index.jsx
@@ -18,7 +18,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', 'Width', 'blacklist'],
+  custom: ['label', 'type', 'Align', 'Width', 'blacklist', 'IsSort'],
   colspan: ['label', 'type', 'Align', 'Hide', 'blacklist'],
   action: ['label', 'type', 'Align', 'Width'],
   formula: ['label', 'type', 'Align', 'Hide', 'Width', 'prefix', 'postfix', 'eval', 'formula', 'blacklist'],
@@ -90,6 +90,8 @@
     }
     if (this.record.type === 'formula' && this.record.eval === 'true') {
       _options.push('decimal')
+    } else if (this.record.type === 'custom' && this.record.IsSort === 'true') {
+      _options.push('sortField')
     }
     if (['number', 'formula'].includes(this.record.type) && this.record.Hide !== 'true') {
       _options.push('noValue')
@@ -142,6 +144,10 @@
     this.record[key] = value
 
     if (key === 'type') {
+      if (['textarea', 'custom'].includes(value)) {
+        this.record.IsSort = 'false'
+      }
+
       let _options = this.getOptions()
 
       let _field = ''
@@ -161,7 +167,9 @@
           return item
         })
       }, () => {
-        if (value === 'colspan') {
+        if (['textarea', 'custom'].includes(value)) {
+          this.props.form.setFieldsValue({IsSort: 'false'})
+        } else if (value === 'colspan') {
           this.props.form.setFieldsValue({Align: 'center'})
         } else if (value === 'formula' && _field) {
           this.props.form.setFieldsValue({formula: '@' + _field + '@'})
@@ -203,7 +211,7 @@
       }
     } else if (key === 'format' && value === 'percent') {
       this.props.form.setFieldsValue({postfix: '%'})
-    } else if (['editable', 'editType', 'resourceType', 'ctrlField', 'eval', 'Hide'].includes(key)) {
+    } else if (['editable', 'editType', 'resourceType', 'ctrlField', 'eval', 'Hide', 'IsSort'].includes(key)) {
       let _options = this.getOptions()
 
       this.setState({
diff --git a/src/menu/components/table/normal-table/columns/editColumn/formconfig.jsx b/src/menu/components/table/normal-table/columns/editColumn/formconfig.jsx
index 8dd1c49..ccd6013 100644
--- a/src/menu/components/table/normal-table/columns/editColumn/formconfig.jsx
+++ b/src/menu/components/table/normal-table/columns/editColumn/formconfig.jsx
@@ -143,7 +143,7 @@
       type: 'radio',
       key: 'IsSort',
       label: '鎺掑簭',
-      initVal: card.IsSort || (card.isSub ? 'false' : 'true'),
+      initVal: card.IsSort || (card.isSub || card.type === 'custom' ? 'false' : 'true'),
       required: true,
       options: [{
         value: 'true',
@@ -154,6 +154,14 @@
       }]
     },
     {
+      type: 'select',
+      key: 'sortField',
+      label: '鎺掑簭瀛楁',
+      initVal: card.sortField || '',
+      required: true,
+      options: fields
+    },
+    {
       type: 'radio',
       key: 'eval',
       label: '瑙f瀽鏂瑰紡',
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 6f51d09..8c88120 100644
--- a/src/menu/components/table/normal-table/columns/editColumn/index.jsx
+++ b/src/menu/components/table/normal-table/columns/editColumn/index.jsx
@@ -17,7 +17,7 @@
   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', 'Width', 'blacklist'],
+  custom: ['label', 'type', 'Align', 'Width', 'blacklist', 'IsSort'],
   action: ['label', 'type', 'Align', 'Width'],
   formula: ['label', 'type', 'Align', 'Hide', 'Width', 'prefix', 'postfix', 'eval', 'formula', 'blacklist'],
   index: ['label', 'type', 'Align', 'Width']
@@ -93,10 +93,10 @@
       } else if (this.record.perspective === 'linkurl') {
         _options.push('linkurl', 'linkfields', 'open')
       }
-    }
-    
-    if (this.record.type === 'formula' && this.record.eval === 'true') {
+    } else if (this.record.type === 'formula' && this.record.eval === 'true') {
       _options.push('decimal')
+    } else if (this.record.type === 'custom' && this.record.IsSort === 'true') {
+      _options.push('sortField')
     }
 
     return _options
@@ -106,6 +106,10 @@
     this.record[key] = value
 
     if (key === 'type') {
+      if (['link', 'textarea', 'picture', 'custom'].includes(value)) {
+        this.record.IsSort = 'false'
+      }
+      
       let _options = this.getOptions()
 
       let _field = ''
@@ -125,7 +129,7 @@
           return item
         })
       }, () => {
-        if (value === 'link' || value === 'textarea' || value === 'picture') {
+        if (['link', 'textarea', 'picture', 'custom'].includes(value)) {
           this.props.form.setFieldsValue({IsSort: 'false'})
         } else if (value === 'text' || value === 'number') {
           this.props.form.setFieldsValue({perspective: ''})
@@ -174,7 +178,7 @@
       }
     } else if (key === 'format' && value === 'percent') {
       this.props.form.setFieldsValue({postfix: '%'})
-    } else if (['perspective', 'eval'].includes(key)) {
+    } else if (['perspective', 'eval', 'IsSort'].includes(key)) {
       let _options = this.getOptions()
 
       this.setState({
diff --git a/src/tabviews/custom/components/share/normalTable/index.jsx b/src/tabviews/custom/components/share/normalTable/index.jsx
index be531d2..01f6363 100644
--- a/src/tabviews/custom/components/share/normalTable/index.jsx
+++ b/src/tabviews/custom/components/share/normalTable/index.jsx
@@ -502,13 +502,15 @@
   
             if (item.field) {
               orderfields[item.uuid] = item.field
+            } else if (item.sortField) {
+              orderfields[item.uuid] = item.sortField
             }
   
             cell = {
               align: item.Align,
               dataIndex: item.uuid,
               title: item.label,
-              sorter: item.field && item.IsSort === 'true',
+              sorter: (item.field || item.sortField) && item.IsSort === 'true',
               width: item.Width || 120,
               onCell: record => ({
                 record,
diff --git a/src/tabviews/custom/components/table/edit-table/normalTable/index.jsx b/src/tabviews/custom/components/table/edit-table/normalTable/index.jsx
index 95e8350..b858fbf 100644
--- a/src/tabviews/custom/components/table/edit-table/normalTable/index.jsx
+++ b/src/tabviews/custom/components/table/edit-table/normalTable/index.jsx
@@ -1200,13 +1200,15 @@
     
           if (item.field) {
             orderfields[item.uuid] = item.field
+          } else if (item.sortField) {
+            orderfields[item.uuid] = item.sortField
           }
 
           cell = {
             align: item.Align,
             dataIndex: item.uuid,
             title: item.editable === 'true' ? <span>{item.label}<EditOutlined className="system-color mk-edit-sign"/></span> : item.label,
-            sorter: !!(item.field && item.IsSort === 'true'),
+            sorter: (item.field || item.sortField) && item.IsSort === 'true',
             width: item.Width || 120,
             $type: item.type,
             onCell: record => ({

--
Gitblit v1.8.0