From 5046d0d13dc6a8563b8e54e31913bc44cfa1072f Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期二, 26 四月 2022 19:23:18 +0800
Subject: [PATCH] 2022-04-26

---
 src/tabviews/zshare/actionList/normalbutton/index.jsx |   85 ++++++++++++++++++++++++++++++++++--------
 1 files changed, 69 insertions(+), 16 deletions(-)

diff --git a/src/tabviews/zshare/actionList/normalbutton/index.jsx b/src/tabviews/zshare/actionList/normalbutton/index.jsx
index 4b71efb..ac2b71c 100644
--- a/src/tabviews/zshare/actionList/normalbutton/index.jsx
+++ b/src/tabviews/zshare/actionList/normalbutton/index.jsx
@@ -60,7 +60,7 @@
 
     if (btn.controlField && selectedData && selectedData.length > 0) { // 琛ㄦ牸涓寜閽殣钘忔帶鍒�
       selectedData.forEach(item => {
-        let s = item[btn.controlField] + ''
+        let s = item[btn.controlField] !== undefined ? item[btn.controlField] + '' : ''
         if (s === btn.controlVal || (btn.controlVal && btn.controlVal.split(',').includes(s))) {
           disabled = true
         }
@@ -85,6 +85,10 @@
     if (btn.OpenType === 'form') {
       let data = selectedData && selectedData[0] ? selectedData[0] : null
       this.setState({check: data && data[btn.field] === btn.openVal})
+    } else if (btn.OpenType === 'formSubmit') {
+      this.setState({
+        selines: selectedData || []
+      })
     }
   }
 
@@ -113,7 +117,7 @@
     if (btn.controlField && !is(fromJS(nextProps.selectedData || []), fromJS(selectedData || []))) {
       if (nextProps.selectedData && nextProps.selectedData.length > 0) { // 琛ㄦ牸涓寜閽殣钘忔帶鍒�
         nextProps.selectedData.forEach(item => {
-          let s = item[btn.controlField] + ''
+          let s = item[btn.controlField] !== undefined ? item[btn.controlField] + '' : ''
           if (s === btn.controlVal || (btn.controlVal && btn.controlVal.split(',').includes(s))) {
             disabled = true
           }
@@ -142,6 +146,10 @@
     if (btn.OpenType === 'form') {
       let data = nextProps.selectedData && nextProps.selectedData[0] ? nextProps.selectedData[0] : null
       this.setState({check: data && data[btn.field] === btn.openVal})
+    } else if (btn.OpenType === 'formSubmit') {
+      this.setState({
+        selines: nextProps.selectedData || []
+      })
     }
   }
 
@@ -164,13 +172,39 @@
   }
 
   actionSubmit = (res) => {
-    const { btn } = this.props
+    const { btn, setting, BID } = this.props
+    const { selines } = this.state
 
     if (btn.uuid !== res.menuId) return
 
+    let data = selines || []
+
+    if (setting.supModule && !BID) {
+      notification.warning({
+        top: 92,
+        message: '闇�瑕佷笂绾т富閿�硷紒',
+        duration: 3
+      })
+      return
+    } else if (btn.Ot !== 'notRequired' && data.length === 0) {
+      notification.warning({
+        top: 92,
+        message: '璇烽�夋嫨琛岋紒',
+        duration: 5
+      })
+      return
+    } else if (btn.Ot === 'requiredSgl' && data.length !== 1) {
+      notification.warning({
+        top: 92,
+        message: '璇烽�夋嫨鍗曡鏁版嵁锛�',
+        duration: 5
+      })
+      return
+    }
+
     this.setState({ loading: true })
 
-    this.execSubmit(this.state.selines, () => {}, res.form)
+    this.execSubmit(data, () => {}, res.form)
   }
 
   resetModuleParam = (menuId, btnId, param) => {
@@ -300,12 +334,14 @@
     })
     
     if (btn.OpenType === 'formSubmit') {
-      MKEmitter.emit('mkFormSubmit', btn.uuid)
+      this.setState({}, () => {
+        MKEmitter.emit('mkFormSubmit', btn.uuid)
+      })
       return
     } else if (btn.OpenType === 'prompt') {
       this.setState({loading: true})
       confirm({
-        title: this.state.dict['main.action.confirm.tip'],
+        title: btn.tipTitle || this.state.dict['main.action.confirm.tip'],
         onOk() {
           return new Promise(resolve => {
             _this.execSubmit(data, resolve)
@@ -985,6 +1021,12 @@
       _resolve()
     })
   }
+  // xml璋冪敤鏂瑰紡
+  // Api.directRequest('http://localhost:3001/test.xml', 'get', null, 'true').then(res => {
+  //   let $x2js = new x2js()
+  //   let jsonObj = $x2js.xml2js(res);
+  //   console.info(jsonObj)
+  // })
 
   /**
    * @description 鑷畾涔夎姹傚惊鐜墽琛�
@@ -1172,7 +1214,7 @@
       sql = _prevCustomScript + sql
       sql = sql + _backCustomScript
 
-      if ((window.GLOB.systemType !== 'production' && options.sysType !== 'cloud') || window.debugger === true) {
+      if (window.GLOB.debugger === true || (window.debugger === true && options.sysType !== 'cloud')) {
         console.info(sql.replace(/\n\s{8}/ig, '\n'))
       }
 
@@ -1209,7 +1251,7 @@
         Sort: index + 1
       }))
 
-      if ((window.GLOB.systemType !== 'production' && options.sysType !== 'cloud') || window.debugger === true) {
+      if (window.GLOB.debugger === true || (window.debugger === true && options.sysType !== 'cloud')) {
         let sql = [...lineMap.values()].map(item => (`
           ${item.insert}
           ${item.selects.join(` union all
@@ -1449,7 +1491,7 @@
     const { btn } = this.props
     const { btnconfig, autoMatic } = this.state
 
-    if ((res && res.ErrCode === 'S') || autoMatic) { // 鎵ц鎴愬姛
+    if ((res && (res.ErrCode === 'S' || !res.ErrCode)) || autoMatic) { // 鎵ц鎴愬姛
       notification.success({
         top: 92,
         message: res.ErrMesg || this.state.dict['main.action.confirm.success'],
@@ -1485,6 +1527,15 @@
     if (btn.output) {
       id = res.mk_b_id || res[btn.output] || ''
     }
+    let tabId = ''
+    if (btn.refreshTab && btn.refreshTab.length > 0) {
+      tabId = btn.refreshTab[btn.refreshTab.length - 1]
+    }
+
+    if (tabId && btn.$MenuID === tabId) { // 鍒锋柊褰撳墠鑿滃崟鏃讹紝鍋滄鍏朵粬鎿嶄綔
+      MKEmitter.emit('reloadMenuView', tabId, 'table')
+      return
+    }
 
     if (btn.execSuccess === 'closetab') {
       MKEmitter.emit('closeTabView', btn.$MenuID)
@@ -1494,9 +1545,10 @@
       MKEmitter.emit('refreshByButtonResult', btn.$menuId, btn.execSuccess, btn, id, this.state.selines)
     }
 
-    if (btn.refreshTab && btn.refreshTab.length > 0) {
-      MKEmitter.emit('reloadMenuView', btn.refreshTab[btn.refreshTab.length - 1], 'table')
+    if (tabId) {
+      MKEmitter.emit('reloadMenuView', tabId, 'table')
     }
+    
     if (btn.switchTab && btn.switchTab.length > 0) {
       let id = btn.switchTab[btn.switchTab.length - 1]
       let node = document.getElementById('tab' + id)
@@ -1855,7 +1907,7 @@
   }
 
   modelconfirm = () => {
-    const { BData } = this.props
+    const { BData, btn } = this.props
     const { btnconfig, selines } = this.state
     let _this = this
 
@@ -1931,7 +1983,7 @@
       this.execSubmit(selines, () => {}, result)
     } else {
       confirm({
-        title: this.state.dict['main.action.confirm.tip'],
+        title: btn.tipTitle || this.state.dict['main.action.confirm.tip'],
         onOk() {
           return new Promise(resolve => {
             _this.execSubmit(selines, resolve, result)
@@ -2041,9 +2093,9 @@
 
     if (btn.OpenType === 'form') {
       if (btn.formType === 'switch') {
-        return <Switch loading={loading} checked={check} disabled={disabled || loading} onChange={(val,e) => {e.stopPropagation();this.actionTrigger()}} style={style} size={btn.size} checkedChildren={btn.openText || ''} unCheckedChildren={btn.closeText || ''}/>
+        return <Switch loading={loading} checked={check} disabled={disabled || loading} title={disabled ? (btn.reason || '') : ''} onChange={(val,e) => {e.stopPropagation();this.actionTrigger()}} style={style} className={btn.size === 'large' ? 'ant-switch-large' : ''} size={btn.size} checkedChildren={btn.openText || ''} unCheckedChildren={btn.closeText || ''}/>
       } else {
-        return <Checkbox disabled={disabled || loading} checked={check} onChange={(e) => {e.stopPropagation();this.actionTrigger()}} style={style}></Checkbox>
+        return <Checkbox disabled={disabled || loading} title={disabled ? (btn.reason || '') : ''} checked={check} onChange={(e) => {e.stopPropagation();this.actionTrigger()}} style={style}></Checkbox>
       }
     } else if (show === 'actionList') {
       return <div style={{display: 'inline-block'}} onClick={(e) => e.stopPropagation()}>
@@ -2052,6 +2104,7 @@
           icon={btn.icon}
           loading={loading}
           disabled={disabled}
+          title={disabled ? (btn.reason || '') : ''}
           className={'mk-btn mk-' + btn.class}
           onClick={() => {this.actionTrigger()}}
         >{(loadingNumber ? `(${loadingNumber})` : '') + btn.label}</Button>
@@ -2087,7 +2140,7 @@
       return <div style={{display: 'inline-block'}} onClick={(e) => e.stopPropagation()}>
         <Button
           type="link"
-          title={show === 'icon' ? btn.label : ''}
+          title={disabled ? (btn.reason || '') : (show === 'icon' ? btn.label : '')}
           loading={loading}
           disabled={disabled}
           style={btn.style || style}

--
Gitblit v1.8.0