From 6b72e0d7751fba6af94a64020ac1fb1199612d05 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期日, 14 五月 2023 20:56:03 +0800
Subject: [PATCH] 2023-05-14

---
 src/menu/components/table/edit-table/columns/tableIn/index.jsx         |   62 +--------------
 src/utils/utils.js                                                     |    2 
 src/menu/components/table/edit-table/columns/editColumn/formconfig.jsx |   20 ++--
 src/tabviews/custom/components/table/edit-table/normalTable/index.jsx  |  112 +++++++++++++++------------
 4 files changed, 79 insertions(+), 117 deletions(-)

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 a4d00e0..72898a7 100644
--- a/src/menu/components/table/edit-table/columns/editColumn/formconfig.jsx
+++ b/src/menu/components/table/edit-table/columns/editColumn/formconfig.jsx
@@ -259,16 +259,16 @@
         text: '鏁版嵁婧�'
       }]
     },
-    {
-      type: 'select',
-      key: 'editField',
-      label: '缂栬緫瀛楁',
-      initVal: card.editField || '',
-      tooltip: '褰撳�间笌鎻愮ず鏂囧瓧涓嶅悓鏃讹紝鍙澶栨坊鍔犵紪杈戝瓧娈碉紝浣滀负瀹為檯鍊肩殑褰曞叆瀛楁銆�',
-      allowClear: true,
-      required: false,
-      options: fields
-    },
+    // {
+    //   type: 'select',
+    //   key: 'editField',
+    //   label: '缂栬緫瀛楁',
+    //   initVal: card.editField || '',
+    //   tooltip: '褰撳�间笌鎻愮ず鏂囧瓧涓嶅悓鏃讹紝鍙澶栨坊鍔犵紪杈戝瓧娈碉紝浣滀负瀹為檯鍊肩殑褰曞叆瀛楁銆�',
+    //   allowClear: true,
+    //   required: false,
+    //   options: fields
+    // },
     {
       type: 'options',
       key: 'options',
diff --git a/src/menu/components/table/edit-table/columns/tableIn/index.jsx b/src/menu/components/table/edit-table/columns/tableIn/index.jsx
index e5b5702..e604816 100644
--- a/src/menu/components/table/edit-table/columns/tableIn/index.jsx
+++ b/src/menu/components/table/edit-table/columns/tableIn/index.jsx
@@ -1,8 +1,8 @@
 import React, {Component} from 'react'
 import PropTypes from 'prop-types'
 import { fromJS } from 'immutable'
-import { Form, Tabs, Row, Col, Input, Button, Table, Popconfirm, notification, Modal, message, InputNumber, Radio, Typography } from 'antd'
-import { StopTwoTone, CheckCircleTwoTone, EditOutlined, ArrowUpOutlined, ArrowDownOutlined, SwapOutlined, DeleteOutlined } from '@ant-design/icons'
+import { Form, Tabs, Row, Col, Input, Button, Popconfirm, notification, Modal, message, InputNumber, Radio, Typography } from 'antd'
+import { StopTwoTone, CheckCircleTwoTone, EditOutlined, SwapOutlined, DeleteOutlined } from '@ant-design/icons'
 import moment from 'moment'
 
 import Api from '@/api'
@@ -160,10 +160,8 @@
         width: '20%',
         dataIndex: 'operation',
         render: (text, record) =>
-          (<div>
+          (<div style={{textAlign: 'center'}}>
             <span className="operation-btn" onClick={() => this.handleEdit(record, 'scripts')} style={{color: '#1890ff'}}><EditOutlined /></span>
-            <span className="operation-btn" onClick={() => this.handleUpDown(record, 'scripts', 'up')} style={{color: '#1890ff'}}><ArrowUpOutlined /></span>
-            <span className="operation-btn" onClick={() => this.handleUpDown(record, 'scripts', 'down')} style={{color: '#ff4d4f'}}><ArrowDownOutlined /></span>
             <span className="operation-btn" title="鐘舵�佸垏鎹�" onClick={() => this.handleStatus(record, 'scripts')} style={{color: '#8E44AD'}}><SwapOutlined /></span>
             <Popconfirm
               overlayClassName="popover-confirm"
@@ -389,51 +387,6 @@
     })
   }
 
-  handleUpDown = (record, type, direction) => {
-    let verify = JSON.parse(JSON.stringify(this.state.verify))
-    let index = 0
-
-    if (type === 'unique') {
-      verify.uniques = verify.uniques.filter((item, i) => {
-        if (item.uuid === record.uuid) {
-          index = i
-        }
-
-        return item.uuid !== record.uuid
-      })
-      if ((index === 0 && direction === 'up') || (index === verify.uniques.length && direction === 'down')) {
-        return
-      }
-
-      if (direction === 'up') {
-        verify.uniques.splice(index - 1, 0, record)
-      } else {
-        verify.uniques.splice(index + 1, 0, record)
-      }
-    } else if (type === 'scripts') {
-      verify.scripts = verify.scripts.filter((item, i) => {
-        if (item.uuid === record.uuid) {
-          index = i
-        }
-
-        return item.uuid !== record.uuid
-      })
-      if ((index === 0 && direction === 'up') || (index === verify.scripts.length && direction === 'down')) {
-        return
-      }
-
-      if (direction === 'up') {
-        verify.scripts.splice(index - 1, 0, record)
-      } else {
-        verify.scripts.splice(index + 1, 0, record)
-      }
-    }
-
-    this.setState({
-      verify: verify
-    })
-  }
-
   handleConfirm = () => {
     const { verify } = this.state
     
@@ -634,14 +587,7 @@
               scriptsChange={this.scriptsChange}
               wrappedComponentRef={(inst) => this.scriptsForm = inst}
             />
-            <Table
-              bordered
-              rowKey="uuid"
-              className="custom-table"
-              dataSource={verify.scripts}
-              columns={scriptsColumns}
-              pagination={false}
-            />
+            <EditTable actions={['move']} data={verify.scripts} columns={scriptsColumns} onChange={(scripts) => {this.setState({verify: {...verify, scripts}})}}/>
           </TabPane>
           <TabPane tab="淇℃伅鎻愮ず" key="tip">
             <Form {...formItemLayout}>
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 2329e72..2a2e40f 100644
--- a/src/tabviews/custom/components/table/edit-table/normalTable/index.jsx
+++ b/src/tabviews/custom/components/table/edit-table/normalTable/index.jsx
@@ -221,12 +221,12 @@
     }, 50)
 
     let values = {}
-    if (col.editField) {
-      values[col.field] = label
-      values[col.editField] = val
-    } else {
+    // if (col.editField) {
+    //   values[col.field] = label
+    //   values[col.editField] = val
+    // } else {
       values[col.field] = val
-    }
+    // }
 
     MKEmitter.emit('changeRecord', col.tableId, {...record, ...values})
   }
@@ -244,12 +244,12 @@
         })
       }
 
-      if (col.editField) {
-        values[col.field] = _option.label
-        values[col.editField] = val
-      } else {
+      // if (col.editField) {
+      //   values[col.field] = _option.label
+      //   values[col.editField] = val
+      // } else {
         values[col.field] = val
-      }
+      // }
     }
 
     this.setState({editing: false})
@@ -292,6 +292,10 @@
         content = `${record[col.field]}`
       }
 
+      if (col.editType === 'select' && col.options.length > 0) {
+        content = col.map.get(content) || content
+      }
+
       if (content !== '') {
         if (col.textFormat === 'YYYY-MM-DD' && /^[1-9]\d{3}(-|\/)(0[1-9]|1[0-2])(-|\/)(0[1-9]|[1-2][0-9]|3[0-1])/.test(content)) {
           content = `${content.substr(0, 4)}-${content.substr(5, 2)}-${content.substr(8, 2)}`
@@ -330,21 +334,21 @@
             </td>)
           } else if (col.editType === 'switch') {
             let _value = ''
-            if (col.editField) {
-              _value = record[col.editField] !== undefined ? record[col.editField] : ''
-            } else {
+            // if (col.editField) {
+            //   _value = record[col.editField] !== undefined ? record[col.editField] : ''
+            // } else {
               _value = record[col.field] !== undefined ? record[col.field] : ''
-            }
+            // }
             return (<td className="editing_table_cell">
               <CusSwitch config={col} defaultValue={_value} autoFocus={true} onChange={this.onSwitchChange} onBlur={this.switchBlur}/>
             </td>)
           } else {
             let _value = ''
-            if (col.editField) {
-              _value = record[col.editField] !== undefined ? record[col.editField] : ''
-            } else {
+            // if (col.editField) {
+            //   _value = record[col.editField] !== undefined ? record[col.editField] : ''
+            // } else {
               _value = record[col.field] !== undefined ? record[col.field] : ''
-            }
+            // }
             return (<td className="editing_table_cell">
               <Select
                 showSearch
@@ -637,12 +641,12 @@
     }, 50)
 
     let values = {}
-    if (col.editField) {
-      values[col.field] = label
-      values[col.editField] = val
-    } else {
+    // if (col.editField) {
+    //   values[col.field] = label
+    //   values[col.editField] = val
+    // } else {
       values[col.field] = val
-    }
+    // }
 
     MKEmitter.emit('changeRecord', col.tableId, {...record, ...values})
   }
@@ -660,12 +664,12 @@
         })
       }
 
-      if (col.editField) {
-        values[col.field] = _option.label
-        values[col.editField] = val
-      } else {
+      // if (col.editField) {
+      //   values[col.field] = _option.label
+      //   values[col.editField] = val
+      // } else {
         values[col.field] = val
-      }
+      // }
     }
 
     setTimeout(() => {
@@ -703,11 +707,11 @@
     if (col.type === 'text') {
       if (col.editable === 'true' && !disabled) {
         let _value = ''
-        if (col.editField) {
-          _value = record[col.editField] !== undefined ? record[col.editField] : ''
-        } else {
+        // if (col.editField) {
+        //   _value = record[col.editField] !== undefined ? record[col.editField] : ''
+        // } else {
           _value = record[col.field] !== undefined ? record[col.field] : ''
-        }
+        // }
         
         if (!col.editType || col.editType === 'text') {
           children = (<>
@@ -736,6 +740,10 @@
         let content = ''
         if (record[col.field] !== undefined) {
           content = `${record[col.field]}`
+        }
+
+        if (col.editType === 'select' && col.options.length > 0) {
+          content = col.map.get(content) || content
         }
 
         if (content !== '') {
@@ -967,17 +975,24 @@
               item.ctrlValue = item.ctrlValue.split(',')
             }
             
-            if (item.type === 'text' && item.editType === 'select' && item.resourceType === '1') {
-              let _option = Utils.getSelectQueryOptions(item)
-
-              if (/@BID@/ig.test(_option.sql)) {
-                hasBid = true
+            if (item.type === 'text' && item.editType === 'select') {
+              item.map = new Map()
+              if (item.resourceType === '1') {
+                let _option = Utils.getSelectQueryOptions(item)
+  
+                if (/@BID@/ig.test(_option.sql)) {
+                  hasBid = true
+                }
+        
+                item.base_sql = _option.sql
+                item.arr_field = _option.field
+        
+                deForms.push(item)
+              } else {
+                item.options.forEach(cell => {
+                  item.map.set(cell.value, cell.label)
+                })
               }
-      
-              item.base_sql = _option.sql
-              item.arr_field = _option.field
-      
-              deForms.push(item)
             }
           }
     
@@ -1234,7 +1249,7 @@
   }
 
   resetFormList = (result) => {
-    const { columns } = this.state
+    const { columns, edData } = this.state
 
     let _edColumns = []
 
@@ -1242,7 +1257,6 @@
     this.props.columns.forEach(item => {
       if (item.resourceType === '1' && result[item.uuid] && result[item.uuid].length > 0) {
         let options = []
-        let _map = new Map()
         let all = false
         result[item.uuid].forEach(cell => {
           let _cell = {key: Utils.getuuid()}
@@ -1259,8 +1273,8 @@
             }
           }
 
-          if (_map.has(_cell.value)) return
-          _map.set(_cell.value, 0)
+          if (item.map.has(_cell.value)) return
+          item.map.set(_cell.value, _cell.label)
 
           if (item.linkSubField) {
             item.linkSubField.forEach(m => {
@@ -1277,7 +1291,7 @@
 
         item.options = options
 
-        reCols[item.uuid] = item
+        reCols[item.uuid] = fromJS(item).toJS()
       }
     })
 
@@ -1292,8 +1306,8 @@
       return item
     })
 
-    this.setState({columns: []}, () => {
-      this.setState({columns: _edColumns})
+    this.setState({columns: [], edData: []}, () => {
+      this.setState({columns: _edColumns, edData: edData})
     })
   }
   
diff --git a/src/utils/utils.js b/src/utils/utils.js
index f09195e..ba54ce5 100644
--- a/src/utils/utils.js
+++ b/src/utils/utils.js
@@ -808,6 +808,8 @@
     }
     if (['select', 'radio', 'link', 'checkcard'].includes(item.type) && item.linkSubField && item.linkSubField.length > 0) {
       arrfield.push(...item.linkSubField)
+    } else if (item.type === 'text' && item.editType === 'select' && item.linkSubField && item.linkSubField.length > 0) { // 鍙紪杈戣〃
+      arrfield.push(...item.linkSubField)
     }
     if (item.disableField) {
       arrfield.push(item.disableField)

--
Gitblit v1.8.0