From 2aa5ab63b4bbce5c36dbb3511b205b3b5f6af9bd Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期二, 07 五月 2024 11:34:20 +0800
Subject: [PATCH] 2024-05-07

---
 src/menu/components/form/simple-form/index.jsx |  138 ++++++++++++++++++++++++++--------------------
 1 files changed, 78 insertions(+), 60 deletions(-)

diff --git a/src/menu/components/form/simple-form/index.jsx b/src/menu/components/form/simple-form/index.jsx
index ba3c39c..2d1855a 100644
--- a/src/menu/components/form/simple-form/index.jsx
+++ b/src/menu/components/form/simple-form/index.jsx
@@ -1,10 +1,9 @@
 import React, {Component} from 'react'
 import PropTypes from 'prop-types'
 import { is, fromJS } from 'immutable'
-import { Popover, Modal, Button, Switch, notification, message } from 'antd'
+import { Popover, Modal, Button, Switch, message } from 'antd'
 import { PlusOutlined, SettingOutlined, EditOutlined, ToolOutlined, DeleteOutlined, FontColorsOutlined } from '@ant-design/icons'
 
-import Api from '@/api'
 import asyncComponent from '@/utils/asyncComponent'
 import asyncIconComponent from '@/utils/asyncIconComponent'
 import { getModalForm } from '@/templates/zshare/formconfig'
@@ -70,7 +69,7 @@
           setting: {title: '', align: 'left_right', enable: 'true'},
           style: {},
           fields: [],
-          subButton: {label: '鎻愪氦', type: 'submit', intertype: 'system', reload: 'false', sqlType: 'update', sql: '', Ot: 'notRequired', execSuccess: 'never', enable: 'true', style: {backgroundColor: '#1890ff', color: '#ffffff', paddingLeft: '25px', paddingRight: '25px', paddingTop: '5px', paddingBottom: '5px'}},
+          subButton: {label: '鎻愪氦', type: 'submit', intertype: 'system', reload: 'false', sqlType: '', sql: '', Ot: 'notRequired', execSuccess: 'never', enable: 'true', style: {backgroundColor: '#1890ff', color: '#ffffff', paddingLeft: '25px', paddingRight: '25px', paddingTop: '5px', paddingBottom: '5px'}},
         }]
       }
 
@@ -81,6 +80,10 @@
         card: _card
       })
     }
+  }
+
+  componentDidMount () {
+    MKEmitter.addListener('mkUpdateInter', this.mkUpdateInter)
   }
 
   shouldComponentUpdate (nextProps, nextState) {
@@ -94,6 +97,21 @@
     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)
+    }
   }
 
   /**
@@ -105,7 +123,7 @@
     card.errors = []
     let idCtrl = false
 
-    if (card.wrap.datatype !== 'static') {
+    if (card.wrap.datatype === 'dynamic') {
       let supModule = card.setting.supModule ? card.setting.supModule[card.setting.supModule.length - 1] || '' : ''
       if (supModule === 'empty') {
         supModule = ''
@@ -119,6 +137,16 @@
       }
 
       card.subcards.forEach(item => {
+        if (item.subButton.intertype === 'system' && !item.subButton.sqlType) {
+          card.errors.push({ level: 0, detail: `${item.subButton.label} 鎸夐挳璇疯缃搷浣滅被鍨媊})
+        }
+        if (item.subButton.verify && !item.subButton.output) {
+          if (item.subButton.verify.noteEnable === 'true') {
+            card.errors.push({ level: 0, detail: `${item.subButton.label} 鎸夐挳鏈缃繑鍥炲�肩煭淇″彂閫佹棤鏁堬紒`})
+          } else if (item.subButton.verify.emailEnable === 'true') {
+            card.errors.push({ level: 0, detail: `${item.subButton.label} 鎸夐挳鏈缃繑鍥炲�奸偖浠跺彂閫佹棤鏁堬紒`})
+          }
+        }
         item.fields.forEach(m => {
           if (m.dataSource && /@ID@/ig.test(m.dataSource)) {
             idCtrl = true
@@ -129,16 +157,29 @@
         })
       })
     } else {
-      let supModule = card.wrap.supModule ? card.wrap.supModule[card.wrap.supModule.length - 1] : ''
+      let supModule = ''
+      if (card.wrap.datatype === 'static') {
+        supModule = card.wrap.supModule ? card.wrap.supModule[card.wrap.supModule.length - 1] : ''
+      }
 
       card.$tables = getTables(card)
 
       card.subcards.forEach(item => {
+        if (item.subButton.intertype === 'system' && !item.subButton.sqlType) {
+          card.errors.push({ level: 0, detail: `${item.subButton.label} 鎸夐挳璇疯缃搷浣滅被鍨媊})
+        }
+        if (item.subButton.verify && !item.subButton.output) {
+          if (item.subButton.verify.noteEnable === 'true') {
+            card.errors.push({ level: 0, detail: `${item.subButton.label} 鎸夐挳鏈缃繑鍥炲�肩煭淇″彂閫佹棤鏁堬紒`})
+          } else if (item.subButton.verify.emailEnable === 'true') {
+            card.errors.push({ level: 0, detail: `${item.subButton.label} 鎸夐挳鏈缃繑鍥炲�奸偖浠跺彂閫佹棤鏁堬紒`})
+          }
+        }
         item.fields.forEach(m => {
           if (m.dataSource && /@ID@/ig.test(m.dataSource)) {
             idCtrl = true
           }
-          if (m.type === 'linkMain' && !supModule) {
+          if (m.type === 'linkMain' && !supModule && card.wrap.datatype === 'static') {
             card.errors.push({ level: 1, detail: `璇锋鏌ュ叧鑱斾富琛ㄢ��${m.label}鈥濇槸鍚︽湁鏁坄})
           }
         })
@@ -334,7 +375,7 @@
         })
       }
 
-      if (item.type === 'switch' || item.type === 'check') {
+      if (['switch', 'check', 'popSelect'].includes(item.type)) {
         _linksupFields.push({
           field: item.field,
           label: item.label
@@ -399,68 +440,33 @@
    * 3銆侀�氳繃loading鍒锋柊
    */
   handleSubmit = () => {
-    this.formRef.handleConfirm().then(res => {
-      let _config = fromJS(this.state.card).toJS()
-      let fieldrepet = false // 瀛楁閲嶅
+    let _config = fromJS(this.state.card).toJS()
 
+    this.formRef.handleConfirm(_config.subcards[0].fields).then(res => {
       _config.subcards[0].fields = _config.subcards[0].fields.map(item => {
-        if (item.uuid !== res.uuid && res.field && item.field && item.field.toLowerCase() === res.field.toLowerCase()) {
-          fieldrepet = true
-        }
-
         delete item.focus
 
-        if (item.uuid === res.uuid) {
-          if (item.style) {
-            res.style = item.style
-          }
-          return res
+        if (item.uuid === res.values.uuid) {
+          return res.values
         } else {
           return item
         }
       })
 
-      if (fieldrepet) {
-        notification.warning({
-          top: 92,
-          message: '瀛楁宸插瓨鍦紒',
-          duration: 10
-        })
-        return
-      }
-
-      window.GLOB.formId = res.uuid
-      
-      if (['select', 'multiselect', 'link', 'checkbox', 'radio', 'checkcard'].includes(res.type) && res.resourceType === '1' && /\s/.test(res.dataSource)) {
+      if (res.loading) {
         this.setState({
           sqlVerifing: true
         })
 
-        let sql = `declare @mk_departmentcode nvarchar(512),@mk_organization nvarchar(512),@mk_user_type nvarchar(20)
-        ${res.dataSource}`
-
-        sql = sql.replace(/@\$|\$@/ig, '').replace(/@(BID|ID|LoginUID|SessionUid|UserID|Appkey|time_id)@/ig, `'1949-10-01 15:00:00'`)
-
-        let rduri = ''
-        if (window.GLOB.mainSystemApi && res.database === 'sso') {
-          rduri = window.GLOB.mainSystemApi
-        }
-        
-        Api.sDebug(sql, rduri).then(result => {
-          if (result.status || result.ErrCode === '-2') {
-            this.setState({
-              sqlVerifing: false,
-              editform: null,
-              visible: false
-            })
-            this.updateComponent(_config)
-          } else {
-            this.setState({sqlVerifing: false})
-            
-            Modal.error({
-              title: result.message
-            })
-          }
+        res.promise().then(() => {
+          this.setState({
+            sqlVerifing: false,
+            editform: null,
+            visible: false
+          })
+          this.updateComponent(_config)
+        }, () => {
+          this.setState({sqlVerifing: false})
         })
       } else {
         this.setState({
@@ -474,6 +480,10 @@
 
   pasteForm = (forms, res) => {
     let _config = fromJS(this.state.card).toJS()
+
+    forms.forEach(item => {
+      delete item.focus
+    })
 
     _config.subcards[0].fields = forms
 
@@ -505,8 +515,6 @@
         }
       })
     } else {
-      _config.subcards[0].fields = forms
-
       this.updateComponent(_config)
     }
   }
@@ -532,6 +540,17 @@
         _card.setting.supModule = res.supModule
       } else {
         _card.setting.supModule = ''
+      }
+    } else 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()
+
+        _card.setting = { interType: 'system' }
+        _card.scripts = []
       }
     }
 
@@ -599,8 +618,7 @@
             <PasteForms config={card.subcards[0]} update={this.pasteForm} />
             <FontColorsOutlined className="style" title="璋冩暣鏍峰紡" onClick={this.changeStyle}/>
             <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