From c33ac9ddcdbed91bd2267bed2a96199441806a04 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期四, 22 九月 2022 17:00:15 +0800
Subject: [PATCH] 2022-09-22

---
 src/menu/components/form/simple-form/index.jsx |   54 ++++++++++++++++++++----------------------------------
 1 files changed, 20 insertions(+), 34 deletions(-)

diff --git a/src/menu/components/form/simple-form/index.jsx b/src/menu/components/form/simple-form/index.jsx
index d5c0926..7aa4c24 100644
--- a/src/menu/components/form/simple-form/index.jsx
+++ b/src/menu/components/form/simple-form/index.jsx
@@ -112,7 +112,6 @@
   }
 
   componentDidMount () {
-    MKEmitter.addListener('submitStyle', this.getStyle)
     MKEmitter.addListener('submitComponentStyle', this.updateComponentStyle)
   }
 
@@ -127,7 +126,6 @@
     this.setState = () => {
       return
     }
-    MKEmitter.removeListener('submitStyle', this.getStyle)
     MKEmitter.removeListener('submitComponentStyle', this.updateComponentStyle)
   }
 
@@ -157,29 +155,31 @@
     card.errors = []
 
     if (card.wrap.datatype !== 'static') {
+      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: '鏈缃笂绾х粍浠讹紒'})
       }
-
-      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())
 
       card.subcards.forEach(item => {
         item.fields.forEach(m => {
           if (m.type === 'linkMain' && !supModule) {
             card.errors.push({ level: 1, detail: `鍏宠仈涓昏〃琛ㄥ崟鈥�${m.label}鈥濇棤鏁坄})
-          } else if (m.field && !columns.includes(m.field) && lowcols.includes(m.field.toLowerCase())) {
-            card.errors.push({ level: 1, detail: `琛ㄥ崟鈥�${m.label}鈥濆ぇ灏忓啓涓庡瓧娈甸泦涓嶄竴鑷碻})
+          // } else if (m.field && !columns.includes(m.field) && lowcols.includes(m.field.toLowerCase())) {
+          //   card.errors.push({ level: 1, detail: `琛ㄥ崟鈥�${m.label}鈥濆ぇ灏忓啓涓庡瓧娈甸泦涓嶄竴鑷碻})
           }
         })
       })
@@ -219,29 +219,11 @@
   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[0] === 'form') {
-      let Index = card.subcards[0].fields.findIndex(n => n.uuid === comIds[1])
-
-      if (Index === -1) return
-      
-      let _card = fromJS(card).toJS()
-
-      _card.subcards[0].fields[Index].style = style
-
-      this.updateComponent(_card)
-
-      return
-    }
-
-    if (comIds.length !== 1 || comIds[0] !== card.uuid) return
-
-    let _card = {...card, style}
+  getStyle = (style) => {
+    let _card = {...this.state.card, style}
 
     this.updateComponent(_card)
   }
@@ -532,7 +514,7 @@
           param.rduri = window.GLOB.mainSystemApi
         }
         
-        Api.getLocalConfig(param).then(result => {
+        Api.genericInterface(param).then(result => {
           if (result.status) {
             this.setState({
               sqlVerifing: false,
@@ -575,8 +557,12 @@
       _config.wrap.enable = res.enable
       _config.wrap.verticalSpace = res.verticalSpace || ''
 
-      _config.subcards[0].fields = res.fields
       _config.subcards[0].subButton = res.subButton
+      
+      _config.subcards[0].fields = res.fields.map(item => {
+        item.uuid = Utils.getuuid()
+        return item
+      })
 
       confirm({
         content: `鏇挎崲琛ㄥ崟鍙婃寜閽厤缃紵`,

--
Gitblit v1.8.0