From e8edfdadb561cd83bf6e1c3e00d55b8cc2aee6d5 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期一, 17 十月 2022 17:57:34 +0800
Subject: [PATCH] 2022-10-17

---
 src/menu/components/form/step-form/index.jsx |   65 +++++++++++---------------------
 1 files changed, 22 insertions(+), 43 deletions(-)

diff --git a/src/menu/components/form/step-form/index.jsx b/src/menu/components/form/step-form/index.jsx
index 0a05e41..83e0c76 100644
--- a/src/menu/components/form/step-form/index.jsx
+++ b/src/menu/components/form/step-form/index.jsx
@@ -9,12 +9,10 @@
 import asyncComponent from '@/utils/asyncComponent'
 import asyncIconComponent from '@/utils/asyncIconComponent'
 import { getModalForm } from '@/templates/zshare/formconfig'
-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'
-import zhCN from '@/locales/zh-CN/model.js'
-import enUS from '@/locales/en-US/model.js'
 import './index.scss'
 
 const ModalForm = asyncComponent(() => import('@/templates/zshare/modalform'))
@@ -39,7 +37,6 @@
   }
 
   state = {
-    dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS,
     appType: sessionStorage.getItem('appType'),
     card: null,
     back: false,
@@ -64,7 +61,6 @@
         format: 'object',   // 缁勪欢灞炴�� - 鏁版嵁鏍煎紡
         pageable: false,    // 缁勪欢灞炴�� - 鏄惁鍙垎椤�
         switchable: false,  // 缁勪欢灞炴�� - 鏁版嵁鏄惁鍙垏鎹�
-        dataName: card.dataName || '',
         width: card.width || 24,
         name: card.name,
         subtype: card.subtype,
@@ -119,7 +115,6 @@
   }
 
   componentDidMount () {
-    MKEmitter.addListener('submitStyle', this.getStyle)
     MKEmitter.addListener('submitComponentStyle', this.updateComponentStyle)
   }
 
@@ -134,7 +129,6 @@
     this.setState = () => {
       return
     }
-    MKEmitter.removeListener('submitStyle', this.getStyle)
     MKEmitter.removeListener('submitComponentStyle', this.updateComponentStyle)
   }
 
@@ -164,39 +158,44 @@
     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)
+
       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 = ''
+      if (card.errors.length === 0) {
+        card.$tables = getTables(card)
       }
-      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}鈥濆ぇ灏忓啓涓庡瓧娈甸泦涓嶄竴鑷碻})
+            card.errors.push({ level: 1, detail: `璇锋鏌ュ垎缁勨��${item.setting.title}鈥濅腑鍏宠仈涓昏〃鈥�${m.label}鈥濇槸鍚︽湁鏁坄})
           }
         })
       })
     } else {
       let supModule = card.wrap.supModule ? card.wrap.supModule[card.wrap.supModule.length - 1] : ''
 
+      card.$tables = getTables(card)
+
       card.subcards.forEach(item => {
         item.fields.forEach(m => {
           if (m.type === 'linkMain' && !supModule) {
-            card.errors.push({ level: 1, detail: `鍒嗙粍鈥�${item.setting.title}鈥濅腑鍏宠仈涓昏〃琛ㄥ崟鈥�${m.label}鈥濇棤鏁坄})
+            card.errors.push({ level: 1, detail: `璇锋鏌ュ垎缁勨��${item.setting.title}鈥濅腑鍏宠仈涓昏〃鈥�${m.label}鈥濇槸鍚︽湁鏁坄})
           }
         })
       })
@@ -226,29 +225,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)
   }
@@ -633,7 +614,7 @@
           param.rduri = window.GLOB.mainSystemApi
         }
         
-        Api.getLocalConfig(param).then(result => {
+        Api.genericInterface(param).then(result => {
           if (result.status) {
             this.setState({
               sqlVerifing: false,
@@ -751,7 +732,7 @@
   }
 
   render() {
-    const { card, dict, group, appType } = this.state
+    const { card, group, appType } = this.state
 
     return (
       <div className="menu-normal-form-edit-box" style={resetStyle(card.style)} onClick={this.clickComponent} id={card.uuid}>
@@ -783,7 +764,7 @@
         {group ? <div className="form-area">
           <PlusOutlined className="plus" title="娣诲姞琛ㄥ崟" onClick={this.addForm}/>
           <FieldsComponent config={group} type="form" plusFields={this.plusFields} />
-          <Switch checkedChildren={dict['model.switch.open']} unCheckedChildren={dict['model.switch.close']} defaultChecked={this.state.showField} onChange={(val) => this.setState({showField: val})} />
+          <Switch checkedChildren="寮�" unCheckedChildren="鍏�" defaultChecked={this.state.showField} onChange={(val) => this.setState({showField: val})} />
           {appType !== 'mob' ? <Button className="mk-cols-change" onClick={() => this.changecols(1)}>1鍒�</Button> : null}
           {appType !== 'mob' ? <Button className="mk-cols-change" onClick={() => this.changecols(2)}>2鍒�</Button> : null}
           {appType !== 'mob' ? <Button className="mk-cols-change" onClick={() => this.changecols(3)}>3鍒�</Button> : null}
@@ -793,7 +774,6 @@
             list={group.fields}
             setting={group.setting}
             showField={this.state.showField}
-            placeholder={dict['header.form.modal.placeholder']}
             handleList={this.handleList}
             handleForm={this.handleForm}
             closeForm={this.closeForm}
@@ -822,7 +802,7 @@
           </div>
         </div>
         <Modal
-          title={this.state.dict['model.edit']}
+          title="缂栬緫"
           visible={this.state.visible}
           width={950}
           maskClosable={false}
@@ -832,7 +812,6 @@
           destroyOnClose
         >
           <ModalForm
-            dict={this.state.dict}
             card={this.state.editform}
             formlist={this.state.formlist}
             inputSubmit={this.handleSubmit}

--
Gitblit v1.8.0