From f6626b05f1275cc2f8ca77f773d4f6a6af1b0a89 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期一, 21 十一月 2022 16:11:55 +0800
Subject: [PATCH] 2022-11-21

---
 src/menu/components/table/base-table/index.jsx |   99 ++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 72 insertions(+), 27 deletions(-)

diff --git a/src/menu/components/table/base-table/index.jsx b/src/menu/components/table/base-table/index.jsx
index 9620ec9..5b982cd 100644
--- a/src/menu/components/table/base-table/index.jsx
+++ b/src/menu/components/table/base-table/index.jsx
@@ -6,6 +6,7 @@
 
 import asyncComponent from '@/utils/asyncComponent'
 import asyncIconComponent from '@/utils/asyncIconComponent'
+import { getTables } from '@/utils/utils-custom.js'
 import MKEmitter from '@/utils/events.js'
 import getWrapForm from './options'
 import Utils from '@/utils/utils.js'
@@ -38,6 +39,7 @@
       let _card = {
         uuid: card.uuid,
         type: card.type,
+        name: card.name || '',
         format: 'array',    // 缁勪欢灞炴�� - 鏁版嵁鏍煎紡
         pageable: true,     // 缁勪欢灞炴�� - 鏄惁鍙垎椤�
         switchable: true,   // 缁勪欢灞炴�� - 鏁版嵁鏄惁鍙垏鎹�
@@ -53,8 +55,8 @@
         subtype: card.subtype,
         setting: { interType: 'system' },
         wrap: { bordered: 'true', tableType: 'checkbox', show: 'true' },
-        style: { marginLeft: '8px', marginRight: '8px', marginTop: '8px', marginBottom: '8px' },
-        headerStyle: { fontSize: '16px', borderBottomWidth: '1px', borderBottomColor: '#e8e8e8' },
+        style: {},
+        headerStyle: {},
         columns: [],
         cols: [
           { origin: true, uuid: Utils.getuuid(), Align: 'left', label: 'label1', field: '', Hide: 'false', type: 'text', Width: 120 },
@@ -63,6 +65,10 @@
         ],
         scripts: [],
         isNew: true
+      }
+
+      if (card.name === '涓昏〃') {
+        _card.setting.supModule = ['empty']
       }
 
       this.updateComponent(_card)
@@ -76,7 +82,6 @@
   }
 
   componentDidMount () {
-    MKEmitter.addListener('submitModal', this.handleSave)
     MKEmitter.addListener('completeSave', this.completeSave)
   }
 
@@ -91,7 +96,6 @@
     this.setState = () => {
       return
     }
-    MKEmitter.removeListener('submitModal', this.handleSave)
     MKEmitter.removeListener('completeSave', this.completeSave)
   }
 
@@ -105,7 +109,6 @@
       item.cols = item.cols.filter(a => !a.origin)
 
       delete item.isNew
-
       this.setState({card: item}, () => { MKEmitter.emit('revert') })
     }
   }
@@ -148,6 +151,10 @@
         card.errors.push({ level: 0, detail: '涓婚敭宸插け鏁堬紒'})
       } else if (!card.setting.supModule) {
         card.errors.push({ level: 0, detail: '鏈缃笂绾х粍浠讹紒'})
+      }
+
+      if (card.errors.length === 0) {
+        card.$tables = getTables(card)
       }
 
       card.action.forEach(cell => {
@@ -257,26 +264,6 @@
     }
   }
 
-  handleSave = (_cards, btn, modal) => {
-    let card = fromJS(this.state.card).toJS()
-
-    if (card.uuid !== _cards.uuid) return
-
-    let _index = card.action.findIndex(cell => cell.uuid === btn.uuid)
-
-    if (_index === -1) return
-
-    card.action = card.action.map(cell => {
-      if (cell.uuid === btn.uuid) {
-        cell.modal = modal
-      }
-
-      return cell
-    })
-
-    this.updateComponent(card)
-  }
-
   getWrapForms = () => {
     const { wrap, action, columns, cols } = this.state.card
 
@@ -307,6 +294,64 @@
     this.updateComponent({...card, wrap: res})
   }
 
+  updatecolumn = (config) => {
+    config.columns = []
+    config.absFields = []
+    config.cols.forEach(col => {
+      if (!col.field) return
+      if (['text', 'picture', 'video', 'textarea'].includes(col.type)) {
+        config.columns.push({
+          datatype: `Nvarchar(${col.fieldlength || 50})`,
+          field: col.field,
+          fieldlength: col.fieldlength || 50,
+          label: col.label,
+          type: 'text',
+          uuid: col.uuid
+        })
+      } else if (col.type === 'link') {
+        config.columns.push({
+          datatype: `Nvarchar(${col.fieldlength || 50})`,
+          field: col.field,
+          fieldlength: col.fieldlength || 50,
+          label: col.label,
+          type: 'text',
+          uuid: col.uuid
+        })
+        if (col.nameField) {
+          config.columns.push({
+            datatype: `Nvarchar(${col.fieldlength || 50})`,
+            field: col.nameField,
+            fieldlength: col.fieldlength || 50,
+            label: col.label + '(鍚嶇О)',
+            type: 'text',
+            uuid: col.uuid + 'name'
+          })
+        }
+      } else if (col.type === 'number') {
+        config.columns.push({
+          datatype: `Decimal(18,${col.decimal || 0})`,
+          field: col.field,
+          decimal: col.decimal || 0,
+          label: col.label,
+          type: 'number',
+          uuid: col.uuid
+        })
+
+        if (col.format === 'abs') {
+          config.absFields.push(col.field)
+        }
+      }
+    })
+
+    if (config.absFields.length) {
+      config.absFields = Array.from(new Set(config.absFields))
+    } else {
+      config.absFields = null
+    }
+
+    this.updateComponent(config)
+  }
+
   render() {
     const { card } = this.state
     let options = ['action', 'search', 'form', 'cols']
@@ -318,7 +363,7 @@
             <NormalForm title="琛ㄦ牸璁剧疆" width={800} update={this.updateWrap} getForms={this.getWrapForms}>
               <EditOutlined style={{color: '#1890ff'}} title="缂栬緫"/>
             </NormalForm>
-            <CopyComponent type="normaltable" card={card}/>
+            <CopyComponent type="basetable" card={card}/>
             <PasteComponent config={card} options={options} updateConfig={this.updateComponent} />
             <FontColorsOutlined className="style" title="璋冩暣鏍峰紡" onClick={this.changeStyle}/>
             <SettingComponent config={card} updateConfig={this.updateComponent} />
@@ -328,7 +373,7 @@
         </Popover>
         <SearchComponent config={card} updatesearch={this.updateComponent}/>
         <ActionComponent config={card} setSubConfig={this.setSubConfig} updateaction={this.updateComponent}/>
-        <ColumnComponent config={card} updatecolumn={this.updateComponent}/>
+        <ColumnComponent config={card} updatecolumn={this.updatecolumn}/>
       </div>
     )
   }

--
Gitblit v1.8.0