From fa381753ef2a2b25b1c0722549ac17e333da79be Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期二, 06 九月 2022 22:50:54 +0800
Subject: [PATCH] 2022-09-06

---
 src/menu/components/timeline/normal-timeline/index.jsx |  111 +++++++++++++++++++++++++++++++++++++++----------------
 1 files changed, 79 insertions(+), 32 deletions(-)

diff --git a/src/menu/components/timeline/normal-timeline/index.jsx b/src/menu/components/timeline/normal-timeline/index.jsx
index d6ad7e9..87c2fe4 100644
--- a/src/menu/components/timeline/normal-timeline/index.jsx
+++ b/src/menu/components/timeline/normal-timeline/index.jsx
@@ -48,8 +48,9 @@
         name: card.name,
         subtype: card.subtype,
         setting: { interType: 'system' },
-        wrap: { title: '', name: card.name, width: card.width || 24, color: '#1890ff', mode: 'left' },
+        wrap: { title: '', name: card.name, direction: 'vertical', width: card.width || 24, color: '#1890ff', mode: 'left' },
         style: { marginLeft: '0px', marginRight: '0px', marginTop: '0px', marginBottom: '0px' },
+        headerStyle: { fontSize: '16px', borderBottomWidth: '1px', borderBottomColor: '#e8e8e8' },
         subcards: [{
           uuid: Utils.getuuid(),
           setting: { width: 24, type: 'simple'},
@@ -82,19 +83,13 @@
           return scard
         })
       }
-      this.setState({
-        card: _card
-      })
-      this.props.updateConfig(_card)
+
+      this.updateComponent(_card)
     } else {
       this.setState({
         card: fromJS(card).toJS()
       })
     }
-  }
-
-  componentDidMount () {
-    MKEmitter.addListener('submitStyle', this.getStyle)
   }
 
   shouldComponentUpdate (nextProps, nextState) {
@@ -108,21 +103,64 @@
     this.setState = () => {
       return
     }
-    MKEmitter.removeListener('submitStyle', this.getStyle)
   }
 
   /**
    * @description 鍗$墖琛屽灞備俊鎭洿鏂帮紙鏁版嵁婧愶紝鏍峰紡绛夛級
    */
-  updateComponent = (component) => {
+  updateComponent = (card) => {
+    card.width = card.wrap.width
+    card.name = card.wrap.name
+    if (!window.GLOB.styling || !card.errors) { // 鏍峰紡淇敼鏃朵笉鍋氱瓫鏌�
+      card.errors = []
+
+      // let supModule = card.setting.supModule ? card.setting.supModule[card.setting.supModule.length - 1] || '' : ''
+      // if (supModule === 'empty') {
+      //   supModule = ''
+      // }
+      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: '涓婚敭宸插け鏁堬紒'})
+      } else if (!card.setting.supModule) {
+        card.errors.push({ level: 0, detail: '鏈缃笂绾х粍浠讹紒'})
+      }
+
+      card.subcards.forEach(col => {
+        col.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 {
+              //   cell.modal.fields.forEach(m => {
+              //     if (m.type === 'linkMain' && !supModule) {
+              //       card.errors.push({ level: 1, detail: `鎸夐挳鈥�${cell.label}鈥濅腑鍏宠仈涓昏〃琛ㄥ崟鈥�${m.label}鈥濇棤鏁坄})
+              //     } else if (m.field && !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)) {
+            card.errors.push({ level: 1, detail: `鍗$墖涓姩鎬佸瓧娈碘��${cell.field}鈥濇棤鏁坄})
+          }
+        })
+      })
+    }
+    
     this.setState({
-      card: component
+      card: card
     })
 
-    component.width = component.wrap.width
-    component.name = component.wrap.name
-
-    this.props.updateConfig(component)
+    this.props.updateConfig(card)
   }
 
   updateCard = (cell) => {
@@ -133,29 +171,19 @@
       return item
     })
 
-    this.setState({card})
-
-    this.props.updateConfig(card)
+    this.updateComponent(card)
   }
 
   changeStyle = () => {
     const { card } = this.state
 
-    MKEmitter.emit('changeStyle', [card.uuid], ['height', 'background', 'border', 'padding', 'margin', 'shadow'], card.style)
+    MKEmitter.emit('changeStyle', ['height', 'background', 'border', 'padding', 'margin', 'shadow'], card.style, this.getStyle)
   }
 
-  getStyle = (comIds, style) => {
-    const { card } = this.state
-
-    if (comIds.length !== 1 || comIds[0] !== card.uuid) return
-
-    let _card = {...card, style}
-
-    this.setState({
-      card: _card
-    })
+  getStyle = (style) => {
+    let _card = {...this.state.card, style}
     
-    this.props.updateConfig(_card)
+    this.updateComponent(_card)
   }
 
   getWrapForms = () => {
@@ -166,6 +194,12 @@
 
   updateWrap = (res) => {
     delete res.quick
+
+    if (res.hmode) {
+      res.mode = res.hmode
+      delete res.hmode
+    }
+    
     this.updateComponent({...this.state.card, wrap: res})
   }
 
@@ -192,7 +226,20 @@
         </Popover>
         <NormalHeader hideSearch="true" config={card} updateComponent={this.updateComponent}/>
         {card.subcards.map(subcard => (<CardSimpleComponent key={subcard.uuid} cards={card} card={subcard} updateElement={this.updateCard}/>))}
-        <div className="component-name"><div className="center">{card.name}</div></div>
+        <div className="component-name">
+          <div className="center">
+            <div className="title">{card.name}</div>
+            <div className="content">
+              {card.errors && card.errors.map((err, index) => {
+                if (err.level === 0) {
+                  return <span key={index} className="error">{err.detail}</span>
+                } else {
+                  return <span key={index} className="waring">{err.detail}锛�</span>
+                }
+              })}
+            </div>
+          </div>
+        </div>
       </div>
     )
   }

--
Gitblit v1.8.0