From 623296e22addf29ff90eff05de5d31c60a247b58 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期一, 10 十月 2022 00:06:00 +0800
Subject: [PATCH] Merge branch 'develop'

---
 src/menu/components/card/balcony/index.jsx |   86 ++++++++++++++++++++++++++-----------------
 1 files changed, 52 insertions(+), 34 deletions(-)

diff --git a/src/menu/components/card/balcony/index.jsx b/src/menu/components/card/balcony/index.jsx
index 6cec481..0fc9a44 100644
--- a/src/menu/components/card/balcony/index.jsx
+++ b/src/menu/components/card/balcony/index.jsx
@@ -2,11 +2,11 @@
 import PropTypes from 'prop-types'
 import { is, fromJS } from 'immutable'
 import { Popover, Checkbox } from 'antd'
-import { PlusOutlined, PlusSquareOutlined, EditOutlined, FontColorsOutlined, DeleteOutlined, SettingOutlined, ToolOutlined } from '@ant-design/icons'
+import { PlusOutlined, PlusSquareOutlined, EditOutlined, FontColorsOutlined, DeleteOutlined, SettingOutlined, ToolOutlined, ClockCircleOutlined } from '@ant-design/icons'
 
 import asyncComponent from '@/utils/asyncComponent'
 import asyncIconComponent from '@/utils/asyncIconComponent'
-import { resetStyle } from '@/utils/utils-custom.js'
+import { resetStyle, getTables } from '@/utils/utils-custom.js'
 import MKEmitter from '@/utils/events.js'
 import Utils from '@/utils/utils.js'
 import getWrapForm from './options'
@@ -85,12 +85,31 @@
     return !is(fromJS(this.state), fromJS(nextState))
   }
 
+  componentDidMount () {
+    MKEmitter.addListener('mkUpdateInter', this.mkUpdateInter)
+  }
+
   /**
    * @description 缁勪欢閿�姣侊紝娓呴櫎state鏇存柊锛屾竻闄ゅ揩鎹烽敭璁剧疆
    */
   componentWillUnmount () {
     this.setState = () => {
       return
+    }
+    MKEmitter.removeListener('mkUpdateInter', this.mkUpdateInter)
+  }
+
+  mkUpdateInter = (inter, split) => {
+    const { card } = this.state
+    
+    if (card.wrap.datatype === 'public' && card.wrap.publicId === inter.uuid) {
+      let _card = {...card, columns: fromJS(inter.columns).toJS()}
+
+      split.delay = split.delay + 10
+
+      setTimeout(() => {
+        this.updateComponent(_card)
+      }, split.delay)
     }
   }
 
@@ -100,7 +119,6 @@
   updateComponent = (card) => {
     card.width = card.wrap.width
     card.name = card.wrap.name
-    card.btnlog = []
 
     if (window.GLOB.styling && card.errors) { // 鏍峰紡淇敼鏃朵笉鍋氱瓫鏌�
       this.setState({
@@ -114,39 +132,35 @@
     card.errors = []
 
     if (card.wrap.datatype === 'static') {
-      // let supModule = card.wrap.linkType === 'static' ? '' : 'has'
-
       card.elements.forEach(cell => {
         if (cell.eleType === 'button') {
           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}鈥濅腑琛ㄥ崟灏氭湭娣诲姞`})
-            // } else if (!supModule) {
-            //   cell.modal.fields.forEach(m => {
-            //     if (m.type === 'linkMain') {
-            //       card.errors.push({ level: 1, detail: `鎸夐挳鈥�${cell.label}鈥濅腑鍏宠仈涓昏〃琛ㄥ崟鈥�${m.label}鈥濇棤鏁坄})
-            //     }
-            //   })
             }
           }
         } else if (cell.datatype === 'dynamic' && cell.field) {
           card.errors.push({ level: 1, detail: `鍗$墖涓姩鎬佸瓧娈碘��${cell.field}鈥濇棤鏁坄})
         }
       })
+      card.$tables = getTables(card)
     } else {
-      // let supModule = card.wrap.linkType === 'static' ? '' : 'has'
-
       let columns = card.columns.map(c => c.field)
-      // let lowcols = card.columns.map(c => c.field.toLowerCase())
 
-      if (card.setting.interType === 'system' && card.setting.execute !== 'false' && !card.setting.dataresource) {
-        card.errors.push({ level: 0, detail: '鏈缃暟鎹簮锛�'})
-      } else if (card.setting.interType === 'system' && card.setting.execute === 'false' && card.scripts.filter(script => script.status !== 'false').length === 0) {
-        card.errors.push({ level: 0, detail: '鏁版嵁婧愪腑鏃犲彲鐢ㄨ剼鏈紒'})
-      } else if (!card.setting.primaryKey) {
-        card.errors.push({ level: 0, detail: '鏈缃富閿紒'})
-      } else if (!columns.includes(card.setting.primaryKey)) {
-        card.errors.push({ level: 0, detail: '涓婚敭宸插け鏁堬紒'})
+      if (card.wrap.datatype === 'dynamic') {
+        if (card.setting.interType === 'system' && card.setting.execute !== 'false' && !card.setting.dataresource) {
+          card.errors.push({ level: 0, detail: '鏈缃暟鎹簮锛�'})
+        } else if (card.setting.interType === 'system' && card.setting.execute === 'false' && card.scripts.filter(script => script.status !== 'false').length === 0) {
+          card.errors.push({ level: 0, detail: '鏁版嵁婧愪腑鏃犲彲鐢ㄨ剼鏈紒'})
+        } else if (!card.setting.primaryKey) {
+          card.errors.push({ level: 0, detail: '鏈缃富閿紒'})
+        } else if (!columns.includes(card.setting.primaryKey)) {
+          card.errors.push({ level: 0, detail: '涓婚敭宸插け鏁堬紒'})
+        }
+      }
+
+      if (card.errors.length === 0) {
+        card.$tables = getTables(card)
       }
 
       card.elements.forEach(cell => {
@@ -154,14 +168,6 @@
           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}鈥濅腑琛ㄥ崟灏氭湭娣诲姞`})
-            // } else {
-            //   cell.modal.fields.forEach(m => {
-            //     if (m.type === 'linkMain' && !supModule) {
-            //       card.errors.push({ level: 1, detail: `鎸夐挳鈥�${cell.label}鈥濅腑鍏宠仈涓昏〃琛ㄥ崟鈥�${m.label}鈥濇棤鏁坄})
-            //     } else if (m.field && card.wrap.linkType !== 'sync' && !columns.includes(m.field) && lowcols.includes(m.field.toLowerCase())) {
-            //       card.errors.push({ level: 1, detail: `鎸夐挳鈥�${cell.label}鈥濅腑琛ㄥ崟鈥�${m.label}鈥濆ぇ灏忓啓涓庡瓧娈甸泦涓嶄竴鑷碻})
-            //     }
-            //   })
             }
           }
         } else if (cell.datatype === 'dynamic' && cell.field && !columns.includes(cell.field)) {
@@ -249,7 +255,20 @@
 
   updateWrap = (res) => {
     delete res.quick
-    this.updateComponent({...this.state.card, wrap: res})
+
+    let _card = {...this.state.card, wrap: res}
+
+    if (res.datatype === 'public') {
+      let interfaces = window.GLOB.customMenu.interfaces || []
+
+      let d = interfaces.filter(m => m.uuid === res.publicId && m.status === 'true')[0]
+
+      if (d) {
+        _card.columns = fromJS(d.columns).toJS()
+      }
+    }
+
+    this.updateComponent(_card)
   }
 
   render() {
@@ -269,11 +288,10 @@
             <CopyComponent type="balcony" card={card}/>
             <PasteComponent options={['action', 'customCardElement']} updateConfig={this.pasteComponent} />
             <FontColorsOutlined className="style" title="璋冩暣鏍峰紡" onClick={this.changeStyle} />
-            <ClockComponent config={card} updateConfig={this.updateComponent}/>
+            {card.wrap.datatype === 'dynamic' ? <ClockComponent config={card} updateConfig={this.updateComponent}/> : <ClockCircleOutlined style={{color: '#eeeeee', cursor: 'not-allowed'}}/>}
             <UserComponent config={card}/>
             <DeleteOutlined className="close" title="鍒犻櫎缁勪欢" onClick={() => this.props.deletecomponent(card.uuid)} />
-            {card.wrap.datatype !== 'static' ? <SettingComponent config={card} updateConfig={this.updateComponent} /> : null}
-            {card.wrap.datatype === 'static' ? <SettingOutlined style={{color: '#eeeeee', cursor: 'not-allowed'}}/> : null}
+            {card.wrap.datatype === 'dynamic' ? <SettingComponent config={card} updateConfig={this.updateComponent} /> : <SettingOutlined style={{color: '#eeeeee', cursor: 'not-allowed'}}/>}
           </div>
         } trigger="hover">
           <ToolOutlined />

--
Gitblit v1.8.0