From d0e8c7cb64d7d219f7cfec8bc87cf699b9cfe7b2 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期二, 08 十一月 2022 12:35:25 +0800
Subject: [PATCH] 2022-11-08

---
 src/menu/replaceField/settingform/index.jsx              |    4 
 src/menu/components/table/base-table/columns/index.scss  |    3 +
 src/menu/components/table/base-table/columns/index.jsx   |   35 ++++++++++-
 src/menu/components/table/normal-table/columns/index.jsx |    3 
 src/templates/comtableconfig/updatetable/index.jsx       |   39 +++++++------
 src/menu/replaceField/index.jsx                          |   57 ++++++++++++++++--
 src/menu/components/table/edit-table/columns/index.jsx   |    1 
 7 files changed, 109 insertions(+), 33 deletions(-)

diff --git a/src/menu/components/table/base-table/columns/index.jsx b/src/menu/components/table/base-table/columns/index.jsx
index 3aa43cd..cea83cd 100644
--- a/src/menu/components/table/base-table/columns/index.jsx
+++ b/src/menu/components/table/base-table/columns/index.jsx
@@ -12,7 +12,7 @@
 import './index.scss'
 
 const { confirm } = Modal
-const EditColumn = asyncIconComponent(() => import('./editColumn'))
+const EditColumn = asyncComponent(() => import('./editColumn'))
 const MarkColumn = asyncIconComponent(() => import('@/menu/components/share/markcomponent'))
 const CardCellComponent = asyncComponent(() => import('@/menu/components/card/cardcellcomponent'))
 const PasteComponent = asyncIconComponent(() => import('@/components/paste'))
@@ -576,6 +576,16 @@
     }
 
     const columns = this.handlecolumns(this.state.columns, fields, config)
+    let groups = null
+    if (columns.length > 12) {
+      let g = Math.ceil(columns.length / 8)
+      let n = Math.ceil(columns.length / g)
+      groups = []
+
+      for (let i = 0, len = columns.length; i < len; i += n) {
+        groups.push(columns.slice(i, i + n))
+      }
+    }
 
     return (
       <div className={`normal-table-columns ${config.setting.laypage} ${config.wrap.tableType} ${config.wrap.mode || ''}`} id={tableId}>
@@ -585,10 +595,29 @@
           <MarkColumn columns={fields} type="line" marks={lineMarks} onSubmit={this.updateLineMarks} />
         </div>
         <DndProvider>
+          {groups ? groups.map((group, i) => {
+            return <Table
+              key={i}
+              rowKey="uuid"
+              size={config.wrap.size || 'middle'}
+              bordered={config.wrap.bordered !== 'false'}
+              components={components}
+              dataSource={this.state.data}
+              rowSelection={config.wrap.tableType && i === 0 ? { type: 'radio' } : null}
+              columns={group}
+              pagination={i === groups.length - 1 ? {
+                current: 1,
+                pageSize: 10,
+                pageSizeOptions: ['10', '25', '50', '100', '500', '1000'],
+                showSizeChanger: true,
+                total: 58,
+                showTotal: (total, range) => `${range[0]}-${range[1]} 鍏� ${total} 鏉
+              } : false}
+            />
+          }) :
           <Table
             rowKey="uuid"
             size={config.wrap.size || 'middle'}
-            rowClassName="editable-row"
             bordered={config.wrap.bordered !== 'false'}
             components={components}
             dataSource={this.state.data}
@@ -602,7 +631,7 @@
               total: 58,
               showTotal: (total, range) => `${range[0]}-${range[1]} 鍏� ${total} 鏉
             }}
-          />
+          />}
         </DndProvider>
         <EditColumn column={card} fields={fields} submitCol={this.submitCol} cancelCol={this.cancelCol}/>
       </div>
diff --git a/src/menu/components/table/base-table/columns/index.scss b/src/menu/components/table/base-table/columns/index.scss
index 97ae93b..8e6ee37 100644
--- a/src/menu/components/table/base-table/columns/index.scss
+++ b/src/menu/components/table/base-table/columns/index.scss
@@ -5,6 +5,9 @@
   --mk-table-font-size: 14px;
   --mk-table-font-weight: normal;
 
+  .ant-table-wrapper + .ant-table-wrapper {
+    margin-top: 10px;
+  }
   .ant-table {
     color: inherit;
     font-size: inherit;
diff --git a/src/menu/components/table/edit-table/columns/index.jsx b/src/menu/components/table/edit-table/columns/index.jsx
index bf073d4..bbe4bf2 100644
--- a/src/menu/components/table/edit-table/columns/index.jsx
+++ b/src/menu/components/table/edit-table/columns/index.jsx
@@ -605,7 +605,6 @@
           <Table
             rowKey="uuid"
             size={config.wrap.size || 'middle'}
-            rowClassName="editable-row"
             bordered={config.wrap.bordered !== 'false'}
             rowSelection={rowSelection}
             components={components}
diff --git a/src/menu/components/table/normal-table/columns/index.jsx b/src/menu/components/table/normal-table/columns/index.jsx
index bc1cf3d..cd313c3 100644
--- a/src/menu/components/table/normal-table/columns/index.jsx
+++ b/src/menu/components/table/normal-table/columns/index.jsx
@@ -13,7 +13,7 @@
 
 const { confirm } = Modal
 const { Paragraph } = Typography 
-const EditColumn = asyncIconComponent(() => import('./editColumn'))
+const EditColumn = asyncComponent(() => import('./editColumn'))
 const MarkColumn = asyncIconComponent(() => import('@/menu/components/share/markcomponent'))
 const CardCellComponent = asyncComponent(() => import('@/menu/components/card/cardcellcomponent'))
 const MobPagination = asyncIconComponent(() => import('@/menu/components/share/mobPagination'))
@@ -604,7 +604,6 @@
           <Table
             rowKey="uuid"
             size={config.wrap.size || 'middle'}
-            rowClassName="editable-row"
             bordered={config.wrap.bordered !== 'false'}
             components={components}
             dataSource={this.state.data}
diff --git a/src/menu/replaceField/index.jsx b/src/menu/replaceField/index.jsx
index 81e4921..64353b0 100644
--- a/src/menu/replaceField/index.jsx
+++ b/src/menu/replaceField/index.jsx
@@ -154,10 +154,12 @@
     })
   }
 
+  // 渚濇嵁鍘熷瓧娈垫浛鎹负鏂板瓧娈�
   exec = (map) => {
+    const { type } = this.props
     let config = fromJS(this.props.config).toJS()
 
-    if (this.props.type === 'custom') {
+    if (type === 'custom') {
       let _replace = (components) => {
         return components.map(item => {
           if (item.type === 'tabs') {
@@ -209,6 +211,9 @@
                   return col
                 })
               }
+              if (m.config && m.config.components) {
+                m.config.components = _replace(m.config.components)
+              }
             })
           }
 
@@ -235,6 +240,9 @@
                       return col
                     })
                   }
+                  if (m.config && m.config.components) {
+                    m.config.components = _replace(m.config.components)
+                  }
                   return m
                 })
               }
@@ -259,6 +267,9 @@
                       }
                       return col
                     })
+                  }
+                  if (m.config && m.config.components) {
+                    m.config.components = _replace(m.config.components)
                   }
                   return m
                 })
@@ -295,6 +306,9 @@
                   }
                   return col
                 })
+              }
+              if (m.config && m.config.components) {
+                m.config.components = _replace(m.config.components)
               }
               return m
             })
@@ -363,6 +377,9 @@
                         return col
                       })
                     }
+                    if (m.config && m.config.components) {
+                      m.config.components = _replace(m.config.components)
+                    }
 
                     return m
                   })
@@ -389,12 +406,21 @@
             item.cols = _update(item.cols)
           }
 
+          if (item.subtype === 'basetable') {
+            item.cols = item.cols.map(col => {
+              if (col.field && map[col.field.toLowerCase()]) {
+                col.field = map[col.field.toLowerCase()].FieldName
+              }
+              return col
+            })
+          }
+
           return item
         })
       }
-  
+
       config.components = _replace(config.components)
-    } else if (this.props.type === 'table') {
+    } else if (type === 'table') {
       config.columns = config.columns.map(col => {
         if (col.field && map[col.field.toLowerCase()]) {
           col.field = map[col.field.toLowerCase()].FieldName
@@ -423,7 +449,7 @@
         }
         return m
       })
-    } else if (this.props.type === 'form') {
+    } else if (type === 'form') {
       config.fields = config.fields.map(col => {
         if (col.field && map[col.field.toLowerCase()]) {
           col.field = map[col.field.toLowerCase()].FieldName
@@ -449,10 +475,12 @@
     }, 300)
   }
 
+  // 渚濇嵁瀛楁鏇挎崲鍚嶇О
   execLabel = (map) => {
+    const { type } = this.props
     let config = fromJS(this.props.config).toJS()
 
-    if (this.props.type === 'custom') {
+    if (type === 'custom') {
       let _replace = (components) => {
         return components.map(item => {
           if (item.type === 'tabs') {
@@ -500,6 +528,9 @@
                   return col
                 })
               }
+              if (m.config && m.config.components) {
+                m.config.components = _replace(m.config.components)
+              }
             })
           }
 
@@ -524,6 +555,9 @@
                         return col
                       })
                     }
+                    if (m.config && m.config.components) {
+                      m.config.components = _replace(m.config.components)
+                    }
 
                     return m
                   })
@@ -542,12 +576,21 @@
             item.cols = _update(item.cols)
           }
 
+          if (item.subtype === 'basetable') {
+            item.cols = item.cols.map(col => {
+              if (col.field && map[col.field.toLowerCase()]) {
+                col.label = map[col.field.toLowerCase()].FieldDec
+              }
+              return col
+            })
+          }
+
           return item
         })
       }
 
       config.components = _replace(config.components)
-    } else if (this.props.type === 'table') {
+    } else if (type === 'table') {
       config.columns = config.columns.map(col => {
         if (col.field && map[col.field.toLowerCase()]) {
           col.label = map[col.field.toLowerCase()].FieldDec
@@ -573,7 +616,7 @@
         }
         return m
       })
-    } else if (this.props.type === 'form') {
+    } else if (type === 'form') {
       config.fields = config.fields.map(col => {
         if (col.field && map[col.field.toLowerCase()]) {
           col.label = map[col.field.toLowerCase()].FieldDec
diff --git a/src/menu/replaceField/settingform/index.jsx b/src/menu/replaceField/settingform/index.jsx
index 1bc080f..941c3f3 100644
--- a/src/menu/replaceField/settingform/index.jsx
+++ b/src/menu/replaceField/settingform/index.jsx
@@ -121,7 +121,7 @@
               {getFieldDecorator('resource', {
                 initialValue: 'custom'
               })(
-                <Radio.Group onChange={(e) => this.setState({resource: e.target.value})}>
+                <Radio.Group onChange={(e) => {this.setState({resource: e.target.value});this.props.form.setFieldsValue({reType: 'field'})}}>
                   <Radio value="dict">鏁版嵁瀛楀吀</Radio>
                   <Radio value="custom">鑷畾涔�</Radio>
                 </Radio.Group>
@@ -135,7 +135,7 @@
               })(
                 <Radio.Group onChange={(e) => this.setState({reType: e.target.value})}>
                   <Radio value="field">瀛楁 <SwapRightOutlined /> 鍚嶇О</Radio>
-                  <Radio value="name">鍘熷瓧娈� <SwapRightOutlined /> 鏂板瓧娈�</Radio>
+                  <Radio disabled={resource === 'dict'} value="name">鍘熷瓧娈� <SwapRightOutlined /> 鏂板瓧娈�</Radio>
                 </Radio.Group>
               )}
             </Form.Item>
diff --git a/src/templates/comtableconfig/updatetable/index.jsx b/src/templates/comtableconfig/updatetable/index.jsx
index 9bac7bf..39b7c6c 100644
--- a/src/templates/comtableconfig/updatetable/index.jsx
+++ b/src/templates/comtableconfig/updatetable/index.jsx
@@ -20,6 +20,7 @@
   }
 
   state = {}
+  delButtons = []
 
   shouldComponentUpdate (nextProps, nextState) {
     return !is(fromJS(this.state), fromJS(nextState))
@@ -52,22 +53,19 @@
 
   execUpdate = (_resolve) => {
     const { config } = this.props
-
-    let uuid = config.uuid
-    let trail = md5(uuid).slice(-10) + 'mk'
-    uuid = uuid.replace(/.{12}$/, trail)
+    this.delButtons = []
 
     let _config = {
       version: 1.0,
-      uuid: uuid,
-      MenuID: uuid,
+      uuid: config.uuid,
+      MenuID: config.uuid,
       fstMenuId: config.fstMenuId,
       parentId: config.ParentId,
       Template: 'BaseTable',
       easyCode: config.easyCode,
       enabled: false,
-      MenuName: config.MenuName + '_new',
-      MenuNo: config.MenuNo + '_new',
+      MenuName: config.MenuName,
+      MenuNo: config.MenuNo,
       OpenType: 'newtab',
       tables: config.tables || [],
       urlFields: config.urlFields || [],
@@ -126,7 +124,7 @@
                 equalTab: n.equalTab && n.equalTab.length > 0 ? n.equalTab[0] : ''
               }
             ]}
-
+            this.delButtons.push(n.linkTab)
             oldtabs[n.uuid] = tab.components[0].uuid
 
             _tbs.push(tab.components[0])
@@ -688,13 +686,15 @@
       Api.getSystemConfig(param).then(res => {
         resolve(res)
       })
-    // }).then(res => { // 鍒犻櫎鍘熻彍鍗�
-    //   if (!res || !res.status) return res
+    }).then(res => { // 鍒犻櫎鍘熻彍鍗�
+      if (!res || !res.status) return res
 
-    //   return Api.getSystemConfig({
-    //     func: 'sPC_MainMenu_Del',
-    //     MenuID: this.props.config.uuid
-    //   })
+      if (this.delButtons.length === 0) return res
+
+      return Api.getSystemConfig({
+        func: 'sPC_MainMenu_Del',
+        MenuID: this.delButtons.join(',')
+      })
     }).then(res => {
       if (!res) return
 
@@ -714,9 +714,10 @@
 
         let _param = window.btoa(window.encodeURIComponent(JSON.stringify(urlparam)))
 
-        // window.history.replaceState(null, null, window.location.href.split('#')[0] + `#/tabledesign/${_param}`)
-        // window.location.reload()
-        window.open(`#/tabledesign/${_param}`)
+        setTimeout(() => {
+          window.history.replaceState(null, null, window.location.href.split('#')[0] + `#/tabledesign/${_param}`)
+          window.location.reload()
+        }, 2000)
       } else {
         notification.warning({
           top: 92,
@@ -968,6 +969,8 @@
       delete _btn.position
       delete _btn.linkTab
 
+      this.delButtons.push(btn.uuid)
+
       _btn.show = 'button'
 
       if (_btn.execSuccess === 'equaltab') {

--
Gitblit v1.8.0