From cbeffcc0902631909c0373f274752a97ddaf2d4e Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期六, 06 八月 2022 01:41:54 +0800
Subject: [PATCH] 2022-08-06

---
 src/tabviews/zshare/actionList/normalbutton/index.jsx | 1184 ++++++++++++++++++++++++++++++++++++++++------------------
 1 files changed, 811 insertions(+), 373 deletions(-)

diff --git a/src/tabviews/zshare/actionList/normalbutton/index.jsx b/src/tabviews/zshare/actionList/normalbutton/index.jsx
index ba6f77f..37d57c9 100644
--- a/src/tabviews/zshare/actionList/normalbutton/index.jsx
+++ b/src/tabviews/zshare/actionList/normalbutton/index.jsx
@@ -1,9 +1,8 @@
 import React, {Component} from 'react'
 import PropTypes from 'prop-types'
 import moment from 'moment'
-import {connect} from 'react-redux'
 import { is, fromJS } from 'immutable'
-import { Button, Modal, notification, message, Drawer } from 'antd'
+import { Button, Modal, notification, message, Drawer, Switch, Checkbox, Progress } from 'antd'
 
 import Api from '@/api'
 import Utils, { getSysDefaultSql } from '@/utils/utils.js'
@@ -21,8 +20,6 @@
 
 class NormalButton extends Component {
   static propTpyes = {
-    show: PropTypes.any,              // 鎸夐挳鏄剧ず鏍峰紡鎺у埗
-    position: PropTypes.any,          // 鎸夐挳浣嶇疆锛屽伐鍏锋爮涓簍oolbar
     BID: PropTypes.string,            // 涓昏〃ID
     BData: PropTypes.any,             // 涓昏〃鏁版嵁
     style: PropTypes.any,             // 鎸夐挳鏍峰紡
@@ -32,6 +29,7 @@
     columns: PropTypes.any,           // 瀛楁鍒�
     setting: PropTypes.any,           // 椤甸潰閫氱敤璁剧疆
     ContainerId: PropTypes.any,       // tab椤甸潰ID锛岀敤浜庡脊绐楁帶鍒�
+    disabled: PropTypes.any,          // 琛屾寜閽鐢�
   }
 
   state = {
@@ -43,26 +41,51 @@
     btnconfig: null,
     loading: false,
     loadingNumber: '',
+    loadingTotal: '',
     disabled: false,
     hidden: false,
     checkParam: null,
-    autoMatic: false
+    autoMatic: false,
+    check: false
   }
 
   moduleParams = null
 
   UNSAFE_componentWillMount () {
-    const { btn, selectedData } = this.props
+    const { btn, selectedData, BData } = this.props
     let disabled = false
 
     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
         }
       })
-      this.setState({disabled, hidden: disabled && btn.control === 'hidden'})
+      this.setState({hidden: disabled && btn.control === 'hidden'})
+    } else if (btn.control === 'parent') {
+      if (!BData || !BData.hasOwnProperty(btn.controlField)) {
+        this.setState({hidden: true})
+      } else {
+        let s = BData[btn.controlField] + ''
+        if (s === btn.controlVal || (btn.controlVal && btn.controlVal.split(',').includes(s))) {
+          this.setState({hidden: true})
+        } else {
+          this.setState({hidden: false})
+        }
+      }
+    }
+    if (this.props.disabled || disabled) {
+      this.setState({disabled: true})
+    }
+    
+    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 || []
+      })
     }
   }
 
@@ -71,10 +94,10 @@
   }
 
   componentDidMount () {
-    const { position, btn } = this.props
+    const { btn } = this.props
 
     MKEmitter.addListener('triggerBtnId', this.actionTrigger)
-    if (position === 'form') {
+    if (btn.OpenType === 'formSubmit') {
       MKEmitter.addListener('triggerFormSubmit', this.actionSubmit)
     }
     MKEmitter.addListener('returnModuleParam', this.resetModuleParam)
@@ -85,20 +108,45 @@
   }
 
   UNSAFE_componentWillReceiveProps (nextProps) {
-    const { btn, selectedData } = this.props
+    const { btn, selectedData, BData } = this.props
 
+    let disabled = false
     if (btn.controlField && !is(fromJS(nextProps.selectedData || []), fromJS(selectedData || []))) {
-      let disabled = false
-
       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
           }
         })
       }
-      this.setState({disabled, hidden: disabled && btn.control === 'hidden'})
+      this.setState({hidden: disabled && btn.control === 'hidden'})
+    } else if (btn.control === 'parent' && !is(fromJS(nextProps.BData || {}), fromJS(BData || {}))) {
+      if (!nextProps.BData || !nextProps.BData.hasOwnProperty(btn.controlField)) {
+        this.setState({hidden: true})
+      } else {
+        let s = nextProps.BData[btn.controlField] + ''
+        if (s === btn.controlVal || (btn.controlVal && btn.controlVal.split(',').includes(s))) {
+          this.setState({hidden: true})
+        } else {
+          this.setState({hidden: false})
+        }
+      }
+    }
+
+    if (nextProps.disabled || disabled) {
+      this.setState({disabled: true})
+    } else {
+      this.setState({disabled: false})
+    }
+
+    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 || []
+      })
     }
   }
 
@@ -121,13 +169,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) => {
@@ -156,7 +230,8 @@
     const { Tab, BID, btn, selectedData, setting } = this.props
     const { loading, disabled } = this.state
 
-    if ((triggerId && btn.uuid !== triggerId) || loading || disabled) return
+    if (loading || disabled) return
+    if (triggerId && btn.uuid !== triggerId) return
 
     if (((Tab && Tab.supMenu) || setting.supModule) && !BID) {
       notification.warning({
@@ -165,17 +240,15 @@
         duration: 5
       })
       return
-    } else if (type === 'linkbtn' && selectedData && selectedData.length === 1) {
-      if (record[0].$Index !== selectedData[0].$Index) {
-        return
-      }
+    } else if (type === 'linkbtn' && !btn.$toolbtn && !is(fromJS(selectedData || []), fromJS(record))) {
+      return
     }
 
     this.setState({autoMatic: type === 'autoMatic'})
 
     let _this = this
     let data = record || selectedData || []
-
+    
     if (btn.Ot !== 'notRequired' && data.length === 0) {
       // 闇�瑕侀�夋嫨琛屾椂锛屾牎楠屾暟鎹�
       notification.warning({
@@ -194,12 +267,20 @@
       return
     } else if (!['requiredSgl', 'notRequired', 'requiredOnce', 'required'].includes(btn.Ot)) {
       // 鏁版嵁閫夋嫨绫诲瀷鏍¢獙
-      this.actionSettingError()
+      notification.warning({
+        top: 92,
+        message: '鎸夐挳琛岃缃敊璇紒',
+        duration: 5
+      })
       return
     } else if (btn.intertype === 'system') {
       // 浣跨敤鍐呴儴鎺ュ彛鏃讹紝鎿嶄綔绫诲瀷鍜屾暟鎹簮涓嶅彲涓虹┖
       if (!btn.sql || !btn.sqlType) {
-        this.actionSettingError()
+        notification.warning({
+          top: 92,
+          message: '鎸夐挳鎿嶄綔绫诲瀷閿欒锛�',
+          duration: 5
+        })
         return
       } else if (data.length === 0 && btn.verify && btn.verify.voucher && btn.verify.voucher.enabled) {
         notification.warning({
@@ -212,12 +293,20 @@
     } else if (btn.intertype === 'inner') {
       // 浣跨敤鍐呴儴鎺ュ彛鏃讹紝鍐呴儴鍑芥暟涓嶅彲涓虹┖
       if (!btn.innerFunc) {
-        this.actionSettingError()
+        notification.warning({
+          top: 92,
+          message: '鎸夐挳鍐呴儴鍑芥暟涓嶅彲涓虹┖锛�',
+          duration: 5
+        })
         return
       }
-    } else if (btn.intertype === 'custom') {
+    } else if (btn.intertype === 'custom' || btn.intertype === 'outer') {
       if (btn.callbackType === 'script' && (!btn.verify || !btn.verify.cbScripts || !btn.verify.cbScripts.filter(item => item.status !== 'false').length === 0)) {
-        this.actionSettingError()
+        notification.warning({
+          top: 92,
+          message: '浣跨敤鑷畾涔夎剼鏈洖璋冩椂锛屽洖璋冭剼鏈笉鍙负绌猴紒',
+          duration: 5
+        })
         return
       } else if (btn.procMode === 'system' && data.length === 0 && btn.verify && btn.verify.voucher && btn.verify.voucher.enabled) {
         notification.warning({
@@ -226,7 +315,7 @@
           duration: 5
         })
         return
-      } else if (window.GLOB.systemType === 'production' && !btn.proInterface) {
+      } else if (btn.intertype === 'custom' && window.GLOB.systemType === 'production' && !btn.proInterface) {
         notification.warning({
           top: 92,
           message: '灏氭湭璁剧疆姝e紡绯荤粺鎺ュ彛鍦板潃锛�',
@@ -234,15 +323,13 @@
         })
         return
       }
-    } else if (btn.intertype === 'outer') {
-      // 鎺ュ彛鍦板潃涓嶅瓨鍦ㄦ椂鎶ラ敊
-      if (!btn.interface && btn.sysInterface !== 'true') {
-        this.actionSettingError()
-        return
-      }
     } else if (!['inner', 'outer', 'system', 'custom'].includes(btn.intertype)) {
       // 鎺ュ彛绫诲瀷閿欒
-      this.actionSettingError()
+      notification.warning({
+        top: 92,
+        message: '鎸夐挳鎺ュ彛绫诲瀷閿欒锛�',
+        duration: 5
+      })
       return
     }
 
@@ -251,12 +338,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)
@@ -280,6 +369,31 @@
         btnconfig: modal
       }, () => {
         this.improveAction()
+      })
+    } else if (btn.OpenType === 'form') {
+      this.setState({
+        loading: true,
+        check: !this.state.check
+      }, () => {
+        let type = 'text'
+        let fieldlen = 50
+        let value = this.state.check ? btn.openVal : btn.closeVal
+
+        if (typeof(value) === 'number') {
+          type = 'number'
+          fieldlen = 0
+        }
+        
+        let item = {
+          type: type,
+          readonly: false,
+          readin: true,
+          writein: true,
+          fieldlen: fieldlen,
+          key: btn.field,
+          value: value
+        }
+        this.execSubmit(data, () => { this.setState({loading: false})}, [item])
       })
     }
 
@@ -350,7 +464,7 @@
         }
 
         param.LText = Utils.formatOptions(param.LText)
-      } else if (btn.OpenType === 'pop' || btn.OpenType === 'formSubmit') { // 琛ㄥ崟
+      } else if (btn.OpenType === 'pop' || btn.OpenType === 'formSubmit' || btn.OpenType === 'form') { // 琛ㄥ崟
         if (btn.sqlType === 'insert') { // 绯荤粺鍑芥暟娣诲姞鏃讹紝鐢熸垚uuid
           primaryId = ''
 
@@ -433,7 +547,7 @@
         }
       }
 
-      if (this.props.menuType === 'HS') { // 鍑芥暟 sPC_TableData_InUpDe 浜戠楠岃瘉
+      if (window.GLOB.mkHS) { // 鍑芥暟 sPC_TableData_InUpDe 浜戠楠岃瘉
         param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp)
         if (check_param) {
           check_param.open_key = Utils.encryptOpenKey(check_param.secretkey, check_param.timestamp)
@@ -555,7 +669,7 @@
           }
         }
 
-        if (this.props.menuType === 'HS') { // 鍑芥暟 sPC_TableData_InUpDe 浜戠楠岃瘉
+        if (window.GLOB.mkHS) { // 鍑芥暟 sPC_TableData_InUpDe 浜戠楠岃瘉
           param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp)
         }
 
@@ -573,13 +687,13 @@
     return _params
   }
 
-  getInnerParam = (data, formdata) => {
-    const { setting, btn } = this.props
+  getInnerParam = (data, formdata, retmsg) => {
+    const { setting, btn, columns } = this.props
     let _params = []
 
     if ( btn.Ot === 'notRequired' || btn.Ot === 'requiredSgl' || btn.Ot === 'requiredOnce' ) {
       let param = {
-        func: btn.innerFunc
+        func: btn.innerFunc || ''
       }
 
       if (this.props.BID) {
@@ -598,16 +712,20 @@
         param[setting.primaryKey] = primaryId // 璁剧疆涓婚敭鍙傛暟
       }
 
-      if (btn.OpenType === 'pop' || btn.OpenType === 'formSubmit') { // 琛ㄥ崟
+      if (btn.OpenType === 'pop' || btn.OpenType === 'formSubmit' || btn.OpenType === 'form') { // 琛ㄥ崟
         formdata.forEach(_data => {
           param[_data.key] = _data.value
         })
       }
 
-      if (this.props.menuType === 'HS' && param.func === 's_sDataDictb_TBBack' && param.LTextOut) { // 鍑芥暟 s_sDataDictb_TBBack 浜戠楠岃瘉
+      if (window.GLOB.mkHS && param.func === 's_sDataDictb_TBBack' && param.LTextOut) { // 鍑芥暟 s_sDataDictb_TBBack 浜戠楠岃瘉
         param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
         param.secretkey = Utils.encrypt(param.LTextOut, param.timestamp)
         param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp)
+      }
+
+      if (retmsg) {
+        param.$callbacksql = this.getSysDeclareSql(btn, formdata, data[0], columns)
       }
 
       _params.push(param)
@@ -641,10 +759,14 @@
           param[setting.primaryKey] = primaryId
         }
 
-        if (this.props.menuType === 'HS' && param.func === 's_sDataDictb_TBBack' && param.LTextOut) { // 鍑芥暟 s_sDataDictb_TBBack 浜戠楠岃瘉
+        if (window.GLOB.mkHS && param.func === 's_sDataDictb_TBBack' && param.LTextOut) { // 鍑芥暟 s_sDataDictb_TBBack 浜戠楠岃瘉
           param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
           param.secretkey = Utils.encrypt(param.LTextOut, param.timestamp)
           param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp)
+        }
+
+        if (retmsg) {
+          param.$callbacksql = this.getSysDeclareSql(btn, formdata, cell, columns)
         }
 
         return param
@@ -652,6 +774,179 @@
     }
 
     return _params
+  }
+
+  /**
+   * @description 鑾峰彇鍥炶皟鑴氭湰鐨勫瓧娈靛畾涔�
+   */
+  getSysDeclareSql = (btn, formdata, data, columns) => {
+    let datavars = {}                 // 澹版槑鐨勫彉閲忥紝琛ㄥ崟鍙婃樉绀哄垪
+    // 闇�瑕佸0鏄庣殑鍙橀噺闆�
+    let _vars = ['tbid', 'errorcode', 'retmsg', 'billcode', 'bvoucher', 'fibvoucherdate', 'fiyear', 'username', 'fullname', 'modulardetailcode', 'roleid', 'mk_departmentcode', 'mk_organization', 'mk_user_type', 'mk_nation', 'mk_province', 'mk_city', 'mk_district', 'mk_address', 'bid']
+  
+    // sql璇彞
+    let _sql = ''
+  
+    let _initvars = [] // 宸茶祴鍊煎瓧娈甸泦
+    let _initFormfields = []
+    let _initColfields = []
+    let _declarefields = []
+  
+    // 鑾峰彇瀛楁閿�煎
+    formdata && formdata.forEach(form => {
+      let _key = form.key.toLowerCase()
+      datavars[_key] = form.value
+  
+      if (!_initvars.includes(_key)) {
+        _initvars.push(_key)
+  
+        if (form.type === 'number' || form.type === 'rate') {
+          let val = form.value
+          if (typeof(val) !== 'number') {
+            val = parseFloat(val)
+            if (isNaN(val)) {
+              val = 0
+            }
+          }
+          _initFormfields.push(`@${_key}=${val}`)
+        } else if (['date', 'datemonth', 'datetime'].includes(form.type)) {
+          _initFormfields.push(`@${_key}='${form.value || '1949-10-01'}'`)
+        } else {
+          _initFormfields.push(`@${_key}='${form.value}'`)
+        }
+      }
+      
+      if (!_vars.includes(_key)) {
+        _vars.push(_key)
+  
+        if (form.fieldlen && form.fieldlen > 2048) {
+          form.fieldlen = 'max'
+        }
+  
+        let _type = `nvarchar(${form.fieldlen})`
+  
+        if (form.type.match(/date/ig)) {
+          _type = 'datetime'
+        } else if (form.type === 'number') {
+          _type = `decimal(18,${form.fieldlen})`
+        } else if (form.type === 'rate') {
+          _type = `decimal(18,2)`
+        }
+  
+        _declarefields.push(`@${_key} ${_type}`)
+      }
+    })
+  
+    if (data) {
+      Object.keys(data).forEach(key => {
+        data[key.toLowerCase()] = data[key]
+      })
+    }
+  
+    // 娣诲姞鏁版嵁涓瓧娈碉紝琛ㄥ崟鍊间紭鍏�(鎸夐挳涓嶉�夎鎴栧琛屾嫾鎺ユ椂璺宠繃)
+    if (data && btn.Ot !== 'notRequired' && btn.Ot !== 'requiredOnce') {
+      datavars = {...data, ...datavars}
+  
+      const setField = (col) => {
+        if (!col.field) return
+        let _key = col.field.toLowerCase()
+  
+        if (!_initvars.includes(_key)) {
+          let _val = datavars.hasOwnProperty(_key) ? datavars[_key] : ''
+  
+          if (col.datatype && /^date/ig.test(col.datatype) && !_val) {
+            _val = '1949-10-01'
+          }
+  
+          _initvars.push(_key)
+          _initColfields.push(`@${_key}='${_val}'`)
+        }
+        
+        if (!_vars.includes(_key)) {
+          _vars.push(_key)
+  
+          if (col.datatype) {
+            _declarefields.push(`@${_key} ${col.datatype}`)
+          } else {
+            if (col.fieldlength && col.fieldlength > 2048) {
+              col.fieldlength = 'max'
+            }
+  
+            let _type = `nvarchar(${col.fieldlength || 50})`
+  
+            if (col.type === 'number') {
+              let _length = col.decimal ? col.decimal : 0
+              _type = `decimal(18,${_length})`
+            } else if (col.type === 'picture' || col.type === 'textarea') {
+              _type = `nvarchar(${col.fieldlength || 512})`
+            }
+  
+            _declarefields.push(`@${_key} ${_type}`)
+          }
+        }
+      }
+  
+      if (columns && columns.length > 0) {
+        columns.forEach(col => {
+          if (col.type === 'colspan' || col.type === 'old_colspan') {
+            col.subcols.forEach(cell => {
+              setField(cell)
+            })
+          } else {
+            setField(col)
+          }
+        })
+      }
+    }
+  
+    // 鍙橀噺澹版槑
+    _declarefields = _declarefields.join(',')
+    if (_declarefields) {
+      _declarefields = ',' + _declarefields
+    }
+    _sql = `/* 绯荤粺鐢熸垚 */
+        Declare @tbid nvarchar(50),@ErrorCode nvarchar(50),@retmsg nvarchar(4000),@BillCode nvarchar(50),@BVoucher nvarchar(50),@FIBVoucherDate nvarchar(50), @FiYear nvarchar(50),@ModularDetailCode nvarchar(50), @UserName nvarchar(50),@FullName nvarchar(50),@RoleID nvarchar(512),@mk_departmentcode nvarchar(50),@mk_organization nvarchar(50),@mk_user_type nvarchar(20),@mk_nation nvarchar(50),@mk_province nvarchar(50),@mk_city nvarchar(50),@mk_district nvarchar(50),@mk_address nvarchar(100),@bid nvarchar(50)${_declarefields}
+      `
+  
+    let userName = sessionStorage.getItem('User_Name') || ''
+    let fullName = sessionStorage.getItem('Full_Name') || ''
+    let RoleID = sessionStorage.getItem('role_id') || ''
+    let departmentcode = sessionStorage.getItem('departmentcode') || ''
+    let organization = sessionStorage.getItem('organization') || ''
+    let mk_user_type = sessionStorage.getItem('mk_user_type') || ''
+    let nation = sessionStorage.getItem('nation') || ''
+    let province = sessionStorage.getItem('province') || ''
+    let city = sessionStorage.getItem('city') || ''
+    let district = sessionStorage.getItem('district') || ''
+    let address = sessionStorage.getItem('address') || ''
+  
+    if (sessionStorage.getItem('isEditState') === 'true') {
+      userName = sessionStorage.getItem('CloudUserName') || ''
+      fullName = sessionStorage.getItem('CloudFullName') || ''
+    }
+  
+    // 鍒濆鍖栧嚟璇佸強鐢ㄦ埛淇℃伅瀛楁
+    _sql += `
+        /* 鍑瘉鍙婄敤鎴蜂俊鎭垵濮嬪寲璧嬪�� */
+        select @BVoucher='',@FIBVoucherDate='',@FiYear='',@ErrorCode='',@retmsg='',@UserName='${userName}', @FullName='${fullName}', @RoleID='${RoleID}', @mk_departmentcode='${departmentcode}', @mk_organization='${organization}', @mk_user_type='${mk_user_type}', @mk_nation='${nation}', @mk_province='${province}', @mk_city='${city}', @mk_district='${district}', @mk_address='${address}', @BillCode='', @ModularDetailCode=''
+        `
+  
+    // 琛ㄥ崟鍙橀噺璧嬪��
+    if (_initFormfields.length > 0) {
+      _sql += `
+        /* 琛ㄥ崟鍙橀噺璧嬪�� */
+        select ${_initFormfields.join(',')}
+        `
+    }
+    // 鏄剧ず鍒楀彉閲忚祴鍊�
+    if (_initColfields.length > 0) {
+      _sql += `
+        /* 鏄剧ず鍒楀彉閲忚祴鍊� */
+        select ${_initColfields.join(',')}
+        `
+    }
+
+    return _sql
   }
 
   /**
@@ -733,6 +1028,10 @@
                     })
                   }, 600)
                 }
+
+                if (res.status) {
+                  this.triggerNote(res) // 娑堟伅
+                }
                 resolve(res)
               }, () => {
                 this.updateStatus()
@@ -760,79 +1059,48 @@
           _resolve()
         })
       } else { // 瓒呭嚭20涓姹傛椂寰幆鎵ц
+        if (btn.progress === 'progressbar' && btn.$toolbtn) {
+          this.setState({
+            loadingTotal: params.length
+          })
+        }
         this.innerLoopRequest(params, btn, _resolve)
       }
     } else if (btn.intertype === 'outer') {
       /** *********************璋冪敤澶栭儴鎺ュ彛************************* */
       let _params = [] // 璇锋眰鍙傛暟鏁扮粍
 
-      if (btn.Ot === 'notRequired' || btn.Ot === 'requiredSgl' || btn.Ot === 'requiredOnce') {
-        let param = {}
+      if (btn.procMode === 'system') {
+        _params = this.getSystemParam(data, formdata, btn.callbackType === 'script')
+      } else {
+        _params = this.getInnerParam(data, formdata, btn.callbackType === 'script')
+      }
 
-        if (this.props.BID) {
-          param.BID = this.props.BID
-        }
-
-        if ((btn.OpenType === 'pop' || btn.OpenType === 'formSubmit') && formdata) { // 琛ㄥ崟
-          formdata.forEach(_data => {
-            param[_data.key] = _data.value
-          })
-        }
-
-        // 鑾峰彇id
-        if (btn.Ot === 'notRequired') {
-          
-        } else if (btn.Ot === 'requiredSgl' && setting.primaryKey) {
-          param[setting.primaryKey] = data[0][setting.primaryKey]
-        } else if (btn.Ot === 'requiredOnce' && setting.primaryKey) {
-          let ids = data.map(d => { return d[setting.primaryKey]})
-          param[setting.primaryKey] = ids.join(',')
-        }
-
-        _params.push(param)
-      } else if (btn.Ot === 'required') {
-        // 閫夋嫨澶氳锛屽惊鐜皟鐢�
-        _params = data.map((cell, index) => {
-          let _cell = {}
-
-          if (this.props.BID) {
-            _cell.BID = this.props.BID
-          }
-
-          let _formparam = {}
-          if (btn.OpenType === 'pop' && formdata) { // 琛ㄥ崟
-            formdata.forEach(_data => {
-              if (index !== 0 && _data.readin && cell.hasOwnProperty(_data.key)) {
-                _formparam[_data.key] = cell[_data.key]
-              } else {
-                _formparam[_data.key] = _data.value
-              }
-            })
-          }
-
-          if (setting.primaryKey) {
-            _cell[setting.primaryKey] = cell[setting.primaryKey]
-          }
-
-          _cell = {..._formparam, ..._cell}
-
-          return _cell
+      if (_params.length > 1 && btn.progress === 'progressbar' && btn.$toolbtn) {
+        this.setState({
+          loadingTotal: _params.length
         })
       }
 
       // 寰幆璋冪敤澶栭儴鎺ュ彛锛堝寘鎷唴閮ㄥ強鍥炶皟鍑芥暟锛�
-      this.outerLoopRequest(_params, btn, _resolve, _params.length > 20)
+      this.outerLoopRequest(_params, _resolve)
     } else if (btn.intertype === 'custom') { // 绯荤粺鎺ュ彛
       let params = []
 
       if (btn.procMode === 'system') {
-        params = this.getSystemParam(data, formdata, true)
+        params = this.getSystemParam(data, formdata, btn.callbackType === 'script')
         params = params.map(item => {
           item.script_type = 'Y'
           return item
         })
       } else {
-        params = this.getInnerParam(data, formdata)
+        params = this.getInnerParam(data, formdata, btn.callbackType === 'script')
+      }
+
+      if (params.length > 1 && btn.progress === 'progressbar' && btn.$toolbtn) {
+        this.setState({
+          loadingTotal: params.length
+        })
       }
 
       this.customLoopRequest(params, _resolve)
@@ -846,7 +1114,7 @@
     let param = params.shift()
 
     this.setState({
-      loadingNumber: params.length || ''
+      loadingNumber: params.length
     })
 
     let record = {
@@ -856,6 +1124,11 @@
     }
 
     delete param.$callbacksql
+
+    if (!param.func) {
+      this.customOuterRequest(params, param, record, _resolve)
+      return
+    }
 
     Api.genericInterface(param).then(res => {
       if (res.status) {
@@ -867,41 +1140,6 @@
         } else {
           this.customOuterRequest(params, res, record, _resolve)
         }
-      } else if (res.ErrCode === 'C' && this.state.checkParam) {
-        const _this = this
-        confirm({
-          title: res.message || res.ErrMesg,
-          content: '缁х画鎵ц锛�',
-          onOk() {
-            return new Promise(resolve => {
-              Api.genericInterface(_this.state.checkParam).then((result) => {
-                if (result.status) {
-                  if ((result.mk_ex_invoke === 'false' || result.mk_ex_invoke === false) && params.length === 0) {
-                    _this.execSuccess(result)
-                    _resolve()
-                  } else if ((result.mk_ex_invoke === 'false' || result.mk_ex_invoke === false) && params.length > 0) {
-                    _this.customLoopRequest(params, _resolve)
-                  } else {
-                    _this.customOuterRequest(params, result, record, _resolve)
-                  }
-                } else {
-                  _this.execError(result)
-                  _resolve()
-                }
-                resolve()
-              }, () => {
-                _this.updateStatus()
-                resolve()
-                _resolve()
-              })
-            })
-          },
-          onCancel() {
-            _this.execError({...res, ErrCode: 'P'})
-            _resolve()
-          }
-        })
-        this.setState({checkParam: null})
       } else {
         this.execError(res)
         _resolve()
@@ -911,6 +1149,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 鑷畾涔夎姹傚惊鐜墽琛�
@@ -978,6 +1222,68 @@
    * @description 鍥炶皟璇锋眰寰幆鎵ц
    */
   customCallbackRequest = (params, result, record, _resolve) => {
+    const { btn } = this.props
+
+    let param = null
+
+    if (btn.callbackType === 'script' || btn.callbackType === 'default') {
+      param = this.getCallBackSql(result, record)
+    } else if (btn.callbackType === 'func') {
+      param = {
+        func: btn.callbackFunc,
+        ...result
+      }
+      if (result.$ErrCode === 'E') {
+        delete param.$ErrCode
+        delete param.$ErrMesg
+
+        param.ErrCode = 'E'
+      }
+    } else {
+      if (result.$ErrCode === 'E') {
+        result.status = false
+        result.message = result.$ErrMesg
+        result.ErrCode = 'E'
+        result.ErrMesg = result.$ErrMesg
+      } else {
+        result.status = result.status !== false
+        result.ErrCode = result.ErrCode || '-1'
+      }
+
+      if (result.status) {
+        if (params.length === 0) {
+          this.execSuccess(result)
+          _resolve()
+        } else {
+          this.customLoopRequest(params, _resolve)
+        }
+      } else {
+        this.execError(result)
+        _resolve()
+      }
+
+      return
+    }
+
+    Api.genericInterface(param).then(res => {
+      if (res.status) {
+        if (params.length === 0) {
+          this.execSuccess(res)
+          _resolve()
+        } else {
+          this.customLoopRequest(params, _resolve)
+        }
+      } else {
+        this.execError(res)
+        _resolve()
+      }
+    }, () => {
+      this.updateStatus()
+      _resolve()
+    })
+  }
+
+  getCallBackSql = (result, record) => {
     const { btn } = this.props
     let lines = []
     let pre = btn.callbackType === 'script' ? '@' : ''
@@ -1098,7 +1404,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'))
       }
 
@@ -1122,7 +1428,7 @@
         param.s_debug_type = 'Y'
       }
 
-      if (this.props.menuType === 'HS') { // 鍑芥暟 sPC_TableData_InUpDe 浜戠楠岃瘉
+      if (window.GLOB.mkHS) { // 鍑芥暟 sPC_TableData_InUpDe 浜戠楠岃瘉
         param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp)
       }
     } else {
@@ -1135,7 +1441,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
@@ -1146,22 +1452,7 @@
       }
     }
 
-    Api.genericInterface(param).then(res => {
-      if (res.status) {
-        if (params.length === 0) {
-          this.execSuccess(res)
-          _resolve()
-        } else {
-          this.customLoopRequest(params, _resolve)
-        }
-      } else {
-        this.execError(res)
-        _resolve()
-      }
-    }, () => {
-      this.updateStatus()
-      _resolve()
-    })
+    return param
   }
 
   /**
@@ -1171,7 +1462,7 @@
     let param = params.shift()
 
     this.setState({
-      loadingNumber: params.length || ''
+      loadingNumber: params.length
     })
 
     let _param = null
@@ -1203,6 +1494,9 @@
             })
           }, 600)
         }
+
+        this.triggerNote(res) // 娑堟伅
+
         if (params.length === 0) {
           this.execSuccess(res)
           _resolve()
@@ -1222,139 +1516,153 @@
   /**
    * @description 澶栭儴璇锋眰寰幆鎵ц
    */
-  outerLoopRequest = (params, btn, _resolve, widthNumber) => {
+  outerLoopRequest = (params, _resolve) => {
     if (!params && params.length === 0) return
 
     let param = params.shift()
-    let _outParam = null
 
-    if (widthNumber) {
-      this.setState({
-        loadingNumber: params.length || ''
-      })
+    this.setState({
+      loadingNumber: params.length
+    })
+
+    let record = {
+      BID: param.BID || '',
+      ID: param.ID || '',
+      callbacksql: param.$callbacksql || ''
     }
 
-    new Promise(resolve => {
-      // 鍐呴儴璇锋眰
-      if (btn.innerFunc) {
-        param.func = btn.innerFunc
+    delete param.$callbacksql
 
-        // 鍑芥暟 s_sDataDictb_TBBack 浜戠楠岃瘉
-        if (this.props.menuType === 'HS' && param.func === 's_sDataDictb_TBBack' && param.LTextOut) {
-          param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
-          param.secretkey = Utils.encrypt(param.LTextOut, param.timestamp)
-          param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp)
-        }
+    if (!param.func) {
+      this.outerOuterRequest(params, param, record, _resolve)
+      return
+    }
 
-        // 瀛樺湪鍐呴儴鍑芥暟鏃讹紝鏁版嵁棰勫鐞�
-        Api.genericInterface(param).then(res => {
-          if (res.status) {
-            delete res.ErrCode
-            delete res.ErrMesg
-            delete res.message
-            delete res.status
-
-            // 浣跨敤澶勭悊鍚庣殑鏁版嵁璋冪敤澶栭儴鎺ュ彛
-            let keys = Object.keys(res) // 鎻愪氦澶栭儴鎺ュ彛鍓嶏紝娣诲姞BID
-            if (this.props.BID && keys.filter(key => key.toLowerCase() === 'bid').length === 0) {
-              res.BID = this.props.BID
-            }
-            
-            resolve(res)
-          } else {
-            this.execError(res, btn)
-            resolve(false)
-            _resolve()
-          }
-        }, () => {
-          this.updateStatus()
-          _resolve()
-        })
-      } else {
-        resolve(param)
-      }
-    }).then(res => {
-      if (!res) return
-      // 澶栭儴璇锋眰
-      _outParam = JSON.parse(JSON.stringify(res))
-
-      if (btn.outerFunc) {
-        res.func = btn.outerFunc
-      }
-      if (this.props.menuType === 'HS') {
-        if (btn.sysInterface === 'true' && options.cloudServiceApi) {
-          res.rduri = options.cloudServiceApi
-        } else if (btn.sysInterface !== 'true') {
-          if (window.GLOB.systemType === 'production' && btn.proInterface) {
-            res.rduri = btn.proInterface
-          } else {
-            res.rduri = btn.interface
-          }
-        }
-
-        // 鍑芥暟 s_sDataDictb_TBBack 浜戠楠岃瘉
-        if (res.func === 's_sDataDictb_TBBack' && res.LTextOut) {
-          res.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
-          res.secretkey = Utils.encrypt(res.LTextOut, res.timestamp)
-          res.open_key = Utils.encryptOpenKey(res.secretkey, res.timestamp)
-        }
-      } else {
-        if (btn.sysInterface === 'true' && window.GLOB.mainSystemApi) {
-          res.rduri = window.GLOB.mainSystemApi
-        } else if (btn.sysInterface !== 'true') {
-          if (window.GLOB.systemType === 'production' && btn.proInterface) {
-            res.rduri = btn.proInterface
-          } else {
-            res.rduri = btn.interface
-          }
-        }
-      }
-
-      return Api.genericInterface(res)
-    }).then(response => {
-      if (!response) return
-      // 鍥炶皟璇锋眰
-      if (btn.callbackFunc) {
-        // 瀛樺湪鍥炶皟鍑芥暟鏃讹紝璋冪敤
-        delete response.message
-        delete response.status
-
-        response.func = btn.callbackFunc
-
-        let _callbackparam = {..._outParam, ...response}
-
-        // 鍑芥暟 s_sDataDictb_TBBack 浜戠楠岃瘉
-        if (this.props.menuType === 'HS' && _callbackparam.func === 's_sDataDictb_TBBack' && _callbackparam.LTextOut) {
-          _callbackparam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
-          _callbackparam.secretkey = Utils.encrypt(_callbackparam.LTextOut, _callbackparam.timestamp)
-          _callbackparam.open_key = Utils.encryptOpenKey(_callbackparam.secretkey, _callbackparam.timestamp)
-        }
-
-        return Api.genericInterface(_callbackparam)
-      } else {
-        if (response.status) {
-          // 涓�娆¤姹傛垚鍔燂紝杩涜涓嬩竴椤硅姹�
-
-          if (params.length === 0) {
-            this.execSuccess(response)
-            _resolve()
-          } else {
-            this.outerLoopRequest(params, btn, _resolve, widthNumber)
-          }
-        } else {
-          this.execError(response)
-          _resolve()
-        }
-      }
-    }).then(res => {
-      if (!res) return
-
+    Api.genericInterface(param).then(res => {
       if (res.status) {
+        if ((res.mk_ex_invoke === 'false' || res.mk_ex_invoke === false) && params.length === 0) {
+          this.execSuccess(res)
+          _resolve()
+        } else if ((res.mk_ex_invoke === 'false' || res.mk_ex_invoke === false) && params.length > 0) {
+          this.outerLoopRequest(params, _resolve)
+        } else {
+          delete res.mk_ex_invoke
+          delete res.ErrCode
+          delete res.ErrMesg
+          delete res.message
+          delete res.status
+
+          // 浣跨敤澶勭悊鍚庣殑鏁版嵁璋冪敤澶栭儴鎺ュ彛
+          let keys = Object.keys(res) // 鎻愪氦澶栭儴鎺ュ彛鍓嶏紝娣诲姞BID
+          if (this.props.BID && keys.filter(key => key.toLowerCase() === 'bid').length === 0) {
+            res.BID = this.props.BID
+          }
+
+          this.outerOuterRequest(params, res, record, _resolve)
+        }
+      } else {
+        this.execError(res)
+        _resolve()
+      }
+    }, () => {
+      this.updateStatus()
+      _resolve()
+    })
+  }
+
+  outerOuterRequest = (params, result, record, _resolve) => {
+    const { btn } = this.props
+    let outParam = JSON.parse(JSON.stringify(result))
+
+    if (btn.outerFunc) {
+      result.func = btn.outerFunc
+    }
+    if (window.GLOB.mkHS) {
+      if (btn.sysInterface === 'true' && options.cloudServiceApi) {
+        result.rduri = options.cloudServiceApi
+      } else if (btn.sysInterface !== 'true') {
+        if (window.GLOB.systemType === 'production' && btn.proInterface) {
+          result.rduri = btn.proInterface
+        } else {
+          result.rduri = btn.interface
+        }
+      }
+
+      // 鍑芥暟 s_sDataDictb_TBBack 浜戠楠岃瘉
+      if (result.func === 's_sDataDictb_TBBack' && result.LTextOut) {
+        result.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
+        result.secretkey = Utils.encrypt(result.LTextOut, result.timestamp)
+        result.open_key = Utils.encryptOpenKey(result.secretkey, result.timestamp)
+      }
+    } else {
+      if (btn.sysInterface === 'true' && window.GLOB.mainSystemApi) {
+        result.rduri = window.GLOB.mainSystemApi
+      } else if (btn.sysInterface !== 'true') {
+        if (window.GLOB.systemType === 'production' && btn.proInterface) {
+          result.rduri = btn.proInterface
+        } else {
+          result.rduri = btn.interface
+        }
+      }
+    }
+
+    Api.genericInterface(result).then(res => {
+      this.outerCallbackRequest(params, res, record, outParam, _resolve)
+    }, () => {
+      this.outerCallbackRequest(params, {status: false, message: 500, ErrCode: 'E', ErrMesg: 500}, record, outParam, _resolve)
+    })
+  }
+
+  /**
+   * @description 鍥炶皟璇锋眰寰幆鎵ц
+   */
+  outerCallbackRequest = (params, result, record, outParam, _resolve) => {
+    const { btn } = this.props
+
+    let param = null
+
+    if (btn.callbackType === 'script' || btn.callbackType === 'default') {
+      param = this.getCallBackSql(result, record)
+    } else if (btn.callbackType === 'func' || btn.callbackFunc) {
+      delete result.message
+      delete result.status
+
+      param = {
+        func: btn.callbackFunc,
+        ...outParam,
+        ...result
+      }
+
+      // 鍑芥暟 s_sDataDictb_TBBack 浜戠楠岃瘉
+      if (window.GLOB.mkHS && param.func === 's_sDataDictb_TBBack' && param.LTextOut) {
+        param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
+        param.secretkey = Utils.encrypt(param.LTextOut, param.timestamp)
+        param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp)
+      }
+    } else {
+      if (result.status) {
+        if (params.length === 0) {
+          this.execSuccess(result)
+          _resolve()
+        } else {
+          this.outerLoopRequest(params, _resolve)
+        }
+      } else {
+        this.execError(result)
+        _resolve()
+      }
+
+      return
+    }
+
+    Api.genericInterface(param).then(res => {
+      if (res.status) {
+        // 涓�娆¤姹傛垚鍔燂紝杩涜涓嬩竴椤硅姹�
         if (params.length === 0) {
           this.execSuccess(res)
           _resolve()
         } else {
-          this.outerLoopRequest(params, btn, _resolve, widthNumber)
+          this.outerLoopRequest(params, _resolve)
         }
       } else {
         this.execError(res)
@@ -1375,7 +1683,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'],
@@ -1388,6 +1696,11 @@
     } else if (res && res.ErrCode === '-1') { // 瀹屾垚鍚庝笉鎻愮ず
 
     }
+
+    this.setState({
+      loadingNumber: '',
+      loadingTotal: '',
+    })
     
     if (autoMatic) {
       this.setState({
@@ -1403,13 +1716,22 @@
       })
     }
 
-    if (btn.verify && btn.verify.noteEnable === 'true') {
-      this.sendMessage()
-    }
-
     let id = ''
     if (btn.output) {
       id = res.mk_b_id || res[btn.output] || ''
+    }
+
+    if (res.mk_icon) {
+      sessionStorage.setItem('avatar', res.mk_icon)
+    }
+    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') {
@@ -1419,17 +1741,25 @@
     } else if (btn.execSuccess !== 'never') {
       MKEmitter.emit('refreshByButtonResult', btn.$menuId, btn.execSuccess, btn, id, this.state.selines)
     }
+    
+    btn.syncComponentId && MKEmitter.emit('reloadData', btn.syncComponentId)
 
-    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)
       node && node.click()
     }
+    if (btn.anchors && btn.anchors.length > 0) {
+      let id = btn.anchors[btn.anchors.length - 1]
+      let node = document.getElementById('anchor' + id)
+      node && node.scrollIntoView({behavior: 'smooth', block: 'center', inline: 'nearest'})
+    }
 
-    if (btn.openmenu && btn.openmenu.length > 0 && btn.MenuID) {
+    if (btn.MenuID && Array.isArray(btn.openmenu) && btn.openmenu.length > 0) {
       let newtab = {
         MenuID: btn.MenuID,
         MenuName: btn.MenuName,
@@ -1448,13 +1778,139 @@
     }
   }
 
-  sendMessage = () => {
-    const { btn : { verify } } = this.props
+  triggerNote = (res) => {
+    const { btn } = this.props
 
+    if (!btn.verify) return
+    if (btn.verify.noteEnable !== 'true' && btn.verify.wxNote !== 'true') return
+
+    let id = ''
+    if (btn.output) {
+      id = res.mk_b_id || res[btn.output] || ''
+    }
+
+    if (!id) return
+
+    if (btn.verify.noteEnable === 'true') {
+      this.sendMessage(btn.verify, id)
+    }
+    if (btn.verify.wxNote === 'true') {
+      this.sendWxMessage(btn.verify, id)
+    }
+  }
+
+  sendWxMessage = (verify, id) => {
+    let param = {
+      func: 's_get_sms_weixin_local',
+      upid: id
+    }
+
+    param.LText = Utils.formatOptions(Utils.getuuid())
+    param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
+    param.secretkey = Utils.encrypt(param.LText, param.timestamp)
+
+    Api.genericInterface(param).then(res => {
+      // res.data = [{openid: 'o2E7gvoSFvQRG7I8_gZxf4y3ONkQ', send_id: '2223333', first: '鎮ㄧ殑缂磋垂淇℃伅濡備笅', keyword1: '010000000001', keyword2: '2022骞�07鏈�03鏃�', keyword3: '渚涙殩缂磋垂', keyword4: '20鍏�', keyword5: '鎴愬姛', remark: '鎰熻阿鎮ㄧ殑浣跨敤锛�'}]
+      if (!res.status) {
+        notification.warning({
+          top: 92,
+          message: res.message,
+          duration: 5
+        })
+        return
+      } else if (!res.send_data || res.send_data.length === 0) {
+        return
+      }
+
+      let _param = {
+        touser: '',
+        template_id: verify.wxTemplateId,
+        data: {}
+      }
+
+      if (verify.wxNoteLink === 'url' && verify.wxNoteLinkUrl) {
+        _param.url = verify.wxNoteLinkUrl
+      } else if (verify.wxNoteLink === 'miniProgram' && window.GLOB.WXminiAppID) {
+        _param.miniprogram = {
+          appid: window.GLOB.WXminiAppID,
+          pagepath: '/pages/index/index'
+        }
+
+        if (verify.wxNoteLinkMenuId) {
+          _param.miniprogram.pagepath = `/pages/index/index?MenuId=${verify.wxNoteLinkMenuId}`
+        }
+      }
+
+      let keys = []
+      verify.wxNoteKeys.forEach(item => {
+        keys.push(item.key)
+
+        _param.data[item.key] = {value: '', color: item.color}
+      })
+
+      let params = res.send_data.map(item => {
+        let m = fromJS(_param).toJS()
+
+        m.touser = item.openid || ''
+        if (item.bid && m.miniprogram && m.miniprogram.pagepath.indexOf('MenuId') > -1) {
+          m.miniprogram.pagepath = m.miniprogram.pagepath + `&BID=${item.bid}`
+        }
+
+        if (item.send_id) { // 闃查噸鍏d
+          m.client_msg_id = item.send_id
+        }
+
+        keys.forEach(key => {
+          if (item[key] !== undefined) {
+            m.data[key].value = item[key]
+          }
+        })
+
+        return m
+      })
+
+      Api.wxAccessToken().then(res => {
+        if (!res.oa_access_token) return
+  
+        params.forEach(n => {
+          if (!n.touser) return
+
+          Api.wxNginxRequest(`cgi-bin/message/template/send?access_token=${res.oa_access_token}`, 'post', n).then(re => {
+            if (verify.wxNoteCallback === 'true') {
+              let _p = {
+                func: 's_get_sms_weixin_local_suc_err',
+                upid: id,
+                send_id: n.client_msg_id || '',
+                status_result: re.errcode === 0 ? 'S' : 'E',
+                msg_result: re.errmsg
+              }
+
+              _p.LText = Utils.formatOptions(Utils.getuuid())
+              _p.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
+              _p.secretkey = Utils.encrypt(_p.LText, _p.timestamp)
+
+              Api.genericInterface(_p).then(result => {
+                if (!result.status) {
+                  notification.warning({
+                    top: 92,
+                    message: result.message,
+                    duration: 5
+                  })
+                }
+              })
+            }
+          })
+        })
+      })
+    })
+  }
+
+  sendMessage = (verify, id) => {
     let param = {
       func: 's_get_sms_local',
       TypeCharOne: verify.noteTemp, // N涓嶅悓鍐呭锛孻鐩稿悓鍐呭
-      TypeCharTwo: verify.noteType  // N瀹氭椂锛孻瀹炴椂
+      TypeCharTwo: verify.noteType, // N瀹氭椂锛孻瀹炴椂
+      upid: id
     }
 
     param.LText = Utils.formatOptions(Utils.getuuid())
@@ -1533,13 +1989,14 @@
       }
 
       if (Ltext.length === 0) return
+
       Ltext = Ltext.join(';')
 
       _param.LText = window.btoa(window.encodeURIComponent(Ltext))
       _param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
       _param.secretkey = Utils.encrypt(_param.LText, _param.timestamp)
 
-      _param.rduri = 'http://sso.mk9h.cn/webapi/dostars'
+      _param.rduri = 'https://sso.mk9h.cn/webapi/dostars'
 
       _param.userid = 'bh0bapabtd45epsgra79segbch6c1ibk'
       _param.LoginUID = 'bh0bapabtd45epsgra79segbch6c1ibk'
@@ -1591,6 +2048,7 @@
       this.setState({
         loading: false,
         loadingNumber: '',
+        loadingTotal: '',
         visible: false
       })
       MKEmitter.emit('autoExecOver', btn.uuid, 'error')
@@ -1599,7 +2057,8 @@
     
     this.setState({
       loading: false,
-      loadingNumber: ''
+      loadingNumber: '',
+      loadingTotal: '',
     })
 
     if (res.ErrCode === 'C') {
@@ -1652,18 +2111,10 @@
       MKEmitter.emit('popclose')
     } else if (btn.execError !== 'never') {
       MKEmitter.emit('refreshByButtonResult', btn.$menuId, btn.execError, btn, '', this.state.selines)
+    } else if (btn.OpenType === 'form') {
+      let data = this.props.selectedData && this.props.selectedData[0] ? this.props.selectedData[0] : null
+      this.setState({check: data && data[btn.field] === btn.openVal})
     }
-  }
-
-  /**
-   * @description 鎸夐挳閰嶇疆淇℃伅閿欒鎻愮ず
-   */
-  actionSettingError = () => {
-    notification.warning({
-      top: 92,
-      message: this.state.dict['main.action.settingerror'],
-      duration: 5
-    })
   }
 
   handleModelConfig = (config) => {
@@ -1694,10 +2145,10 @@
    */
   improveAction = () => {
     const { btn } = this.props
-    const { btnconfig, autoMatic } = this.state
+    const { btnconfig } = this.state
 
     if (btnconfig) {
-      if (!autoMatic && (btnconfig.setting.display === 'prompt' || btnconfig.setting.display === 'exec')) { // 濡傛灉琛ㄥ崟浠ユ槸鍚︽灞曠ず
+      if (btnconfig.setting.display === 'prompt' || btnconfig.setting.display === 'exec') { // 濡傛灉琛ㄥ崟浠ユ槸鍚︽灞曠ず
         this.modelconfirm()
       } else {
         this.setState({
@@ -1741,7 +2192,7 @@
           this.setState({
             btnconfig: _LongParam
           }, () => {
-            if (!autoMatic && (_LongParam.setting.display === 'prompt' || _LongParam.setting.display === 'exec')) { // 濡傛灉琛ㄥ崟浠ユ槸鍚︽灞曠ず
+            if (_LongParam.setting.display === 'prompt' || _LongParam.setting.display === 'exec') { // 濡傛灉琛ㄥ崟浠ユ槸鍚︽灞曠ず
               this.modelconfirm()
             } else {
               this.setState({
@@ -1759,6 +2210,7 @@
    */
   handleOk = () => {
     if (!this.formRef) return
+    
     this.formRef.handleConfirm().then(res => {
       this.setState({ confirmLoading: true })
 
@@ -1778,7 +2230,7 @@
   }
 
   modelconfirm = () => {
-    const { BData } = this.props
+    const { BData, btn } = this.props
     const { btnconfig, selines } = this.state
     let _this = this
 
@@ -1854,7 +2306,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)
@@ -1876,15 +2328,15 @@
 
     if (!btnconfig || !btnconfig.setting) return null
 
-    let title = btnconfig.setting.title
-    let width = btnconfig.setting.width + 'vw'
+    let title = btn.label
+    let width = btnconfig.setting.width > 100 ? btnconfig.setting.width : btnconfig.setting.width + 'vw'
     let clickouter = btnconfig.setting.clickouter === 'close'
 
     if (btnconfig.setting.display === 'drawer') {
       let height = '100vh'
       if (btnconfig.setting.placement === 'top' || btnconfig.setting.placement === 'bottom') {
         width = '100vw'
-        height = btnconfig.setting.width + 'vh'
+        height = btnconfig.setting.width > 100 ? btnconfig.setting.width : btnconfig.setting.width + 'vh'
       }
       return (
         <Drawer
@@ -1901,7 +2353,6 @@
           <MutilForm
             BID={BID}
             dict={this.state.dict}
-            menuType={this.props.menuType}
             action={btnconfig}
             inputSubmit={this.handleOk}
             data={this.state.selines[0]}
@@ -1925,7 +2376,7 @@
         (setting.tabType === 'main' && btnconfig.setting.container === 'tab' && this.props.ContainerId) ||
         (btnconfig.setting.container === 'tab' && btn.ContainerId)
       ) {
-        width = btnconfig.setting.width + '%'
+        width = btnconfig.setting.width > 100 ? btnconfig.setting.width : btnconfig.setting.width + '%'
         container = () => document.getElementById(this.props.ContainerId || btn.ContainerId)
       }
       return (
@@ -1944,7 +2395,6 @@
           <MutilForm
             BID={BID}
             dict={this.state.dict}
-            menuType={this.props.menuType}
             action={btnconfig}
             inputSubmit={this.handleOk}
             data={this.state.selines[0]}
@@ -1957,74 +2407,62 @@
   }
 
   render() {
-    const { btn, show, style } = this.props
-    const { loadingNumber, loading, disabled, hidden } = this.state
+    const { btn } = this.props
+    const { loadingNumber, loadingTotal, loading, disabled, hidden, check } = this.state
 
     if (hidden) return null
 
-    if (show === 'actionList') {
-      return <div style={{display: 'inline-block'}} onClick={(e) => e.stopPropagation()}>
-        <Button
-          style={style}
-          icon={btn.icon}
-          loading={loading}
-          disabled={disabled}
-          className={'mk-btn mk-' + btn.class}
-          onClick={() => {this.actionTrigger()}}
-        >{(loadingNumber ? `(${loadingNumber})` : '') + btn.label}</Button>
-        {this.getModels()}
-      </div>
-    } else if (show && show.indexOf('plus') > -1) {
-      return <div style={{display: 'inline-block'}}>
-        <Button
-          type="link"
-          loading={loading}
-          icon={btn.icon || 'plus'}
-          style={{fontSize: show.substring(4) + 'px'}}
-          onClick={() => {this.actionTrigger()}}
-        ></Button>
-        {this.getModels()}
-      </div>
-    } else { // icon銆乼ext銆� all 鍗$墖
-      let label = ''
-      let icon = ''
-
-      if (show === 'button') {
-        label = btn.label
-        icon = btn.icon || ''
-      } else if (show === 'link') {
-        label = <span>{btn.label}{btn.icon ? <MkIcon style={{marginLeft: '8px'}} type={btn.icon}/> : ''}</span>
-        icon = ''
-      } else if (show === 'icon') {
-        icon = btn.icon || ''
+    if (btn.OpenType === 'form') {
+      if (btn.formType === 'switch') {
+        return <Switch loading={loading} checked={check} disabled={disabled || loading} title={disabled ? (btn.reason || '') : ''} onChange={(val,e) => {e.stopPropagation();this.actionTrigger()}} style={btn.style} className={btn.size === 'large' ? 'ant-switch-large' : ''} size={btn.size} checkedChildren={btn.openText || ''} unCheckedChildren={btn.closeText || ''}/>
       } else {
-        label = btn.label
+        return <Checkbox disabled={disabled || loading} title={disabled ? (btn.reason || '') : ''} checked={check} onChange={(e) => {e.stopPropagation();this.actionTrigger()}} style={btn.style}></Checkbox>
       }
-
-      return <div style={{display: 'inline-block'}} onClick={(e) => e.stopPropagation()}>
-        <Button
-          type="link"
-          title={show === 'icon' ? btn.label : ''}
-          loading={loading}
-          disabled={disabled}
-          style={btn.style || style}
-          icon={icon}
-          onClick={() => {this.actionTrigger()}}
-        >{label}</Button>
-        {this.getModels()}
-      </div>
     }
+
+    let label = ''
+    let icon = ''
+    let type = 'link'
+    let className = ''
+
+    if (btn.show === 'button') {
+      label = btn.label
+      icon = btn.icon || ''
+    } else if (btn.show === 'link') {
+      label = <span>{btn.label}{btn.icon ? <MkIcon style={{marginLeft: '8px'}} type={btn.icon}/> : ''}</span>
+      icon = ''
+    } else if (btn.show === 'icon') {
+      icon = btn.icon || ''
+    } else if (!btn.$toolbtn) {
+      icon = btn.icon || ''
+      label = btn.label
+      className = 'mk-btn mk-' + (btn.class || 'unset')
+    } else {
+      type = ''
+      icon = btn.icon || ''
+      label = btn.label
+      className = 'mk-btn mk-' + (btn.class || 'unset')
+    }
+
+    if (loadingNumber && !loadingTotal && btn.$toolbtn && (!btn.show || btn.show === 'button')) {
+      label = (loadingNumber && !loadingTotal ? `(${loadingNumber})` : '') + btn.label
+    }
+
+    return <>
+      <Button
+        type={type}
+        icon={icon}
+        title={disabled ? (btn.reason || '') : (btn.show === 'icon' ? btn.label : '')}
+        loading={loading}
+        disabled={disabled}
+        style={btn.style}
+        className={className}
+        onClick={(e) => {e.stopPropagation(); this.actionTrigger()}}
+      >{label}</Button>
+      <span onClick={(e) => {e.stopPropagation()}}>{this.getModels()}</span>
+      {loadingTotal ? <Progress className="mk-button-progress" percent={(loadingTotal - loadingNumber) / loadingTotal * 100} size="small" showInfo={false} /> : null}
+    </>
   }
 }
 
-const mapStateToProps = (state) => {
-  return {
-    menuType: state.editLevel
-  }
-}
-
-const mapDispatchToProps = () => {
-  return {}
-}
-
-export default connect(mapStateToProps, mapDispatchToProps)(NormalButton)
\ No newline at end of file
+export default NormalButton
\ No newline at end of file

--
Gitblit v1.8.0