From 3b103caa6bfc9ed410e67156c3ca1785bf1cecc9 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期五, 19 八月 2022 01:15:31 +0800
Subject: [PATCH] 2022-08-19

---
 src/menu/components/form/tab-form/index.jsx |   57 +++++++++++++++++++++------------------------------------
 1 files changed, 21 insertions(+), 36 deletions(-)

diff --git a/src/menu/components/form/tab-form/index.jsx b/src/menu/components/form/tab-form/index.jsx
index f937c07..ff6e32b 100644
--- a/src/menu/components/form/tab-form/index.jsx
+++ b/src/menu/components/form/tab-form/index.jsx
@@ -12,7 +12,7 @@
 import { resetStyle } from '@/utils/utils-custom.js'
 import MKEmitter from '@/utils/events.js'
 import Utils from '@/utils/utils.js'
-import getWrapForm from '../normal-form/options'
+import getWrapForm from '../step-form/options'
 import zhCN from '@/locales/zh-CN/model.js'
 import enUS from '@/locales/en-US/model.js'
 import './index.scss'
@@ -31,7 +31,7 @@
 
 const { confirm } = Modal
 
-class PropCardEditComponent extends Component {
+class TabFormComponent extends Component {
   static propTpyes = {
     card: PropTypes.object,
     deletecomponent: PropTypes.func,
@@ -131,7 +131,6 @@
   }
 
   componentDidMount () {
-    MKEmitter.addListener('submitStyle', this.getStyle)
     MKEmitter.addListener('submitComponentStyle', this.updateComponentStyle)
   }
 
@@ -146,7 +145,6 @@
     this.setState = () => {
       return
     }
-    MKEmitter.removeListener('submitStyle', this.getStyle)
     MKEmitter.removeListener('submitComponentStyle', this.updateComponentStyle)
   }
 
@@ -176,29 +174,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: `鍒嗙粍鈥�${item.setting.title}鈥濅腑鍏宠仈涓昏〃琛ㄥ崟鈥�${m.label}鈥濇棤鏁坄})
-          } else if (m.field && !columns.includes(m.field) && lowcols.includes(m.field.toLowerCase())) {
-            card.errors.push({ level: 1, detail: `鍒嗙粍鈥�${item.setting.title}鈥濅腑琛ㄥ崟鈥�${m.label}鈥濆ぇ灏忓啓涓庡瓧娈甸泦涓嶄竴鑷碻})
+          // } else if (m.field && !columns.includes(m.field) && lowcols.includes(m.field.toLowerCase())) {
+          //   card.errors.push({ level: 1, detail: `鍒嗙粍鈥�${item.setting.title}鈥濅腑琛ㄥ崟鈥�${m.label}鈥濆ぇ灏忓啓涓庡瓧娈甸泦涓嶄竴鑷碻})
           }
         })
       })
@@ -238,29 +238,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, group } = this.state
-
-    if (comIds[0] === 'form') {
-      let Index = group.fields.findIndex(n => n.uuid === comIds[1])
-
-      if (Index === -1) return
-      
-      let _group = fromJS(group).toJS()
-
-      _group.fields[Index].style = style
-
-      this.updateGroup(_group)
-
-      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)
   }
@@ -666,6 +648,9 @@
   }
 
   pasteForm = (res) => {
+    if (res.subtype === 'simpleform') {
+      res = res.subcards[0]
+    }
     if (res.subButton) {
       let card = fromJS(this.state.card).toJS()
 
@@ -785,7 +770,7 @@
               <EditOutlined style={{color: '#1890ff'}} title="缂栬緫"/>
             </NormalForm>
             <CopyComponent type="tabform" card={card}/>
-            <PasteComponent config={card} options={['form', 'formgroup']} updateConfig={this.pasteForm} />
+            <PasteComponent config={card} options={['form', 'formgroup', 'simpleform']} updateConfig={this.pasteForm} />
             <FontColorsOutlined className="style" title="璋冩暣鏍峰紡" onClick={this.changeStyle}/>
             <UserComponent config={card}/>
             <DeleteOutlined className="close" title="鍒犻櫎缁勪欢" onClick={() => this.props.deletecomponent(card.uuid)} />
@@ -870,4 +855,4 @@
   }
 }
 
-export default PropCardEditComponent
\ No newline at end of file
+export default TabFormComponent
\ No newline at end of file

--
Gitblit v1.8.0