From 99c0ccd473e30f029b81feb65975d654528bc3e5 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期四, 20 四月 2023 17:58:02 +0800
Subject: [PATCH] 2023-04-20

---
 src/menu/components/table/edit-table/index.jsx |   91 +++++++++++++++++++++++++++++----------------
 1 files changed, 59 insertions(+), 32 deletions(-)

diff --git a/src/menu/components/table/edit-table/index.jsx b/src/menu/components/table/edit-table/index.jsx
index 029fcd2..7002129 100644
--- a/src/menu/components/table/edit-table/index.jsx
+++ b/src/menu/components/table/edit-table/index.jsx
@@ -1,7 +1,7 @@
 import React, {Component} from 'react'
 import PropTypes from 'prop-types'
 import { is, fromJS } from 'immutable'
-import { Popover } from 'antd'
+import { Popover, message } from 'antd'
 import { PlusOutlined, PlusCircleOutlined, PlusSquareOutlined, EditOutlined, ToolOutlined, DeleteOutlined, FontColorsOutlined } from '@ant-design/icons'
 
 import asyncComponent from '@/utils/asyncComponent'
@@ -43,8 +43,6 @@
       let _card = {
         uuid: card.uuid,
         type: card.type,
-        tabId: card.tabId || '',
-        parentId: card.parentId || '',
         format: 'array',    // 缁勪欢灞炴�� - 鏁版嵁鏍煎紡
         pageable: true,     // 缁勪欢灞炴�� - 鏄惁鍙垎椤�
         switchable: false,  // 缁勪欢灞炴�� - 鏁版嵁鏄惁鍙垏鎹�
@@ -121,7 +119,6 @@
   }
 
   componentDidMount () {
-    MKEmitter.addListener('submitModal', this.handleSave)
     MKEmitter.addListener('completeSave', this.completeSave)
   }
 
@@ -136,7 +133,6 @@
     this.setState = () => {
       return
     }
-    MKEmitter.removeListener('submitModal', this.handleSave)
     MKEmitter.removeListener('completeSave', this.completeSave)
   }
 
@@ -182,20 +178,30 @@
       }
   
       card.action.forEach(cell => {
+        if (cell.hidden === 'true') return
         if (cell.OpenType === 'pop' || (cell.OpenType === 'funcbutton' && cell.execMode === 'pop')) {
           if (!cell.modal || cell.modal.fields.length === 0) {
-            card.errors.push({ level: 1, detail: `鎸夐挳鈥�${cell.label}鈥濅腑琛ㄥ崟灏氭湭娣诲姞`})
+            card.errors.push({ level: 0, detail: `鎸夐挳鈥�${cell.label}鈥濅腑琛ㄥ崟灏氭湭娣诲姞`})
           }
+        } else if (cell.OpenType === 'excelIn' && (!cell.verify || !cell.verify.sheet || !cell.verify.columns || cell.verify.columns.length === 0)) {
+          card.errors.push({ level: 0, detail: `鎸夐挳鈥�${cell.label}鈥濅腑瀵煎叆鍒楁湭璁剧疆锛乣})
+        } else if (cell.OpenType === 'excelOut' && (!cell.verify || !cell.verify.columns || cell.verify.columns.length === 0)) {
+          card.errors.push({ level: 0, detail: `鎸夐挳鈥�${cell.label}鈥濅腑瀵煎嚭鍒楁湭璁剧疆锛乣})
         }
       })
   
       card.cols.forEach(col => {
         if (col.type === 'action') {
           col.elements.forEach(cell => {
+            if (cell.hidden === 'true') return
             if (cell.OpenType === 'pop' || (cell.OpenType === 'funcbutton' && cell.execMode === 'pop')) {
               if (!cell.modal || cell.modal.fields.length === 0) {
-                card.errors.push({ level: 1, detail: `鎸夐挳鈥�${cell.label}鈥濅腑琛ㄥ崟灏氭湭娣诲姞`})
+                card.errors.push({ level: 0, detail: `鎸夐挳鈥�${cell.label}鈥濅腑琛ㄥ崟灏氭湭娣诲姞`})
               }
+            } else if (cell.OpenType === 'excelIn' && (!cell.verify || !cell.verify.sheet || !cell.verify.columns || cell.verify.columns.length === 0)) {
+              card.errors.push({ level: 0, detail: `鎸夐挳鈥�${cell.label}鈥濅腑瀵煎叆鍒楁湭璁剧疆锛乣})
+            } else if (cell.OpenType === 'excelOut' && (!cell.verify || !cell.verify.columns || cell.verify.columns.length === 0)) {
+              card.errors.push({ level: 0, detail: `鎸夐挳鈥�${cell.label}鈥濅腑瀵煎嚭鍒楁湭璁剧疆锛乣})
             }
           })
         } else if (col.type === 'custom') {
@@ -232,7 +238,7 @@
     style.fontSize = card.wrap.fontSize || 14
     style.fontWeight = card.wrap.fontWeight || 'normal'
 
-    MKEmitter.emit('changeStyle', ['font1', 'background', 'border', 'padding', 'margin', 'shadow'], style, this.getStyle)
+    MKEmitter.emit('changeStyle', ['font1', 'background', 'border', 'padding', 'margin', 'shadow', 'clear', 'minHeight'], style, this.getStyle)
   }
 
   getStyle = (style) => {
@@ -318,26 +324,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 } = this.state.card
 
@@ -367,10 +353,43 @@
     this.updateComponent(_card)
   }
 
+  updatecolumn = (config) => {
+    config.absFields = []
+    config.cols.forEach(col => {
+      if (col.type === 'number') {
+        if (col.format === 'abs') {
+          config.absFields.push(col.field)
+        }
+      } else if (col.type === 'colspan' && col.subcols) {
+        col.subcols.forEach(scol => {
+          if (scol.type === 'number') {
+            if (scol.format === 'abs') {
+              config.absFields.push(scol.field)
+            }
+          }
+        })
+      }
+    })
+
+    if (config.absFields.length) {
+      config.absFields = Array.from(new Set(config.absFields))
+    } else {
+      config.absFields = null
+    }
+
+    this.updateComponent(config)
+  }
+
   clickComponent = (e) => {
     if (sessionStorage.getItem('style-control') === 'true' || sessionStorage.getItem('style-control') === 'component') {
       e.stopPropagation()
-      MKEmitter.emit('clickComponent', this.state.card)
+      MKEmitter.emit('clickComponent', this.state.card.uuid, null, (style) => {
+        let _card = {...this.state.card}
+        _card.style = {..._card.style, ...style}
+
+        this.setState({ card: _card })
+        this.props.updateConfig(_card)
+      })
     }
   }
 
@@ -389,7 +408,7 @@
             <NormalForm title="琛ㄦ牸璁剧疆" width={800} update={this.updateWrap} getForms={this.getWrapForms}>
               <EditOutlined style={{color: '#1890ff'}} title="缂栬緫"/>
             </NormalForm>
-            <CopyComponent type="normaltable" card={card}/>
+            <CopyComponent type="editable" card={card}/>
             <PasteComponent config={card} options={['action', 'search', 'form', 'cols']} updateConfig={this.updateComponent} />
             <FontColorsOutlined className="style" title="璋冩暣鏍峰紡" onClick={this.changeStyle}/>
             <UserComponent config={card}/>
@@ -401,10 +420,18 @@
         </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 className="component-name">
           <div className="center">
-            <div className="title">{card.name}</div>
+            <div className="title" onDoubleClick={() => {
+              let oInput = document.createElement('input')
+              oInput.value = 'anchor' + card.uuid
+              document.body.appendChild(oInput)
+              oInput.select()
+              document.execCommand('Copy')
+              document.body.removeChild(oInput)
+              message.success('澶嶅埗鎴愬姛銆�')
+            }}>{card.name}</div>
             <div className="content">
               {card.errors && card.errors.map((err, index) => {
                 if (err.level === 0) {

--
Gitblit v1.8.0