From 400fee62fb40006a9839f1c3a8244b82566b5057 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期四, 08 五月 2025 16:30:39 +0800
Subject: [PATCH] Merge branch 'develop'

---
 src/tabviews/zshare/actionList/newpagebutton/index.jsx |  710 ++++++++++++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 586 insertions(+), 124 deletions(-)

diff --git a/src/tabviews/zshare/actionList/newpagebutton/index.jsx b/src/tabviews/zshare/actionList/newpagebutton/index.jsx
index 517e7fa..bab817a 100644
--- a/src/tabviews/zshare/actionList/newpagebutton/index.jsx
+++ b/src/tabviews/zshare/actionList/newpagebutton/index.jsx
@@ -1,10 +1,12 @@
 import React, {Component} from 'react'
 import PropTypes from 'prop-types'
 import { is, fromJS } from 'immutable'
-import { Button, notification, Modal } from 'antd'
+import { Button, notification, Modal, message } from 'antd'
+import moment from 'moment'
+import md5 from 'md5'
 
-import zhCN from '@/locales/zh-CN/main.js'
-import enUS from '@/locales/en-US/main.js'
+import Api from '@/api'
+import Utils from '@/utils/utils.js'
 import MKEmitter from '@/utils/events.js'
 import MkIcon from '@/components/mk-icon'
 import './index.scss'
@@ -13,32 +15,29 @@
 
 class NewPageButton extends Component {
   static propTpyes = {
-    show: PropTypes.any,              // 鎸夐挳鏄剧ず鏍峰紡鎺у埗
+    BID: PropTypes.any,               // BID
     BData: PropTypes.any,             // 涓昏〃鏁版嵁
     btn: PropTypes.object,            // 鎸夐挳
     selectedData: PropTypes.any,      // 瀛愯〃涓�夋嫨鏁版嵁
-    setting: PropTypes.any,           // 椤甸潰閫氱敤璁剧疆
+    disabled: PropTypes.any,          // 琛屾寜閽鐢�
+    name: PropTypes.any
   }
 
   state = {
-    dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS,
     disabled: false,
+    loading: false,
     hidden: false,
-    visible: false
+    visible: false,
+    dict: window.GLOB.dict
   }
 
   UNSAFE_componentWillMount () {
-    const { btn, selectedData } = this.props
-    let disabled = false
+    const { btn, selectedData, BData, disabled } = this.props
 
-    if (btn.controlField && selectedData && selectedData.length > 0) { // 琛ㄦ牸涓寜閽殣钘忔帶鍒�
-      selectedData.forEach(item => {
-        let s = item[btn.controlField] + ''
-        if (s === btn.controlVal || (btn.controlVal && btn.controlVal.split(',').includes(s))) {
-          disabled = true
-        }
-      })
-      this.setState({disabled, hidden: disabled && btn.control === 'hidden'})
+    if (btn.controlField) {
+      this.setStatus(btn, selectedData || [], BData, disabled)
+    } else if (disabled) {
+      this.setState({disabled: true})
     }
   }
 
@@ -51,20 +50,12 @@
   }
 
   UNSAFE_componentWillReceiveProps (nextProps) {
-    const { btn, selectedData } = this.props
+    const { btn } = this.props
 
-    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] + ''
-          if (s === btn.controlVal || (btn.controlVal && btn.controlVal.split(',').includes(s))) {
-            disabled = true
-          }
-        })
-      }
-      this.setState({disabled, hidden: disabled && btn.control === 'hidden'})
+    if (btn.controlField) {
+      this.setStatus(btn, nextProps.selectedData || [], nextProps.BData, nextProps.disabled)
+    } else {
+      this.setState({disabled: nextProps.disabled === true})
     }
   }
 
@@ -74,29 +65,62 @@
     }
     MKEmitter.removeListener('triggerBtnId', this.actionTrigger)
   }
+
+  setStatus = (btn, data, BData, disprop) => {
+    let disabled = false
+    let hidden = false
+
+    if (btn.control !== 'parent') {
+      if (data.length > 0) {
+        data.forEach(item => {
+          let s = item[btn.controlField] !== undefined ? item[btn.controlField] + '' : ''
+          if (btn.controlVals.includes(s) || item.$lock) {
+            disabled = true
+          }
+        })
+      } else if (btn.controlVals.includes('')) {
+        disabled = true
+      }
+    } else {
+      if (!BData || !BData.hasOwnProperty(btn.controlField)) {
+        hidden = true
+      } else {
+        let s = BData[btn.controlField] + ''
+        if (btn.controlVals.includes(s)) {
+          hidden = true
+        }
+      }
+    }
+
+    if (disabled && btn.control === 'hidden') {
+      hidden = true
+    }
+
+    if (disprop) {
+      disabled = true
+    }
+
+    this.setState({hidden, disabled})
+  }
   
   /**
    * @description 瑙﹀彂鎸夐挳鎿嶄綔
    */
-  actionTrigger = (triggerId, record, type) => {
-    const { setting, btn, selectedData } = this.props
-    const { disabled } = this.state
+  actionTrigger = (triggerId, record, type, lid) => {
+    const { btn, selectedData, BID, LID } = this.props
+    const { disabled, dict } = this.state
 
-    if ((triggerId && btn.uuid !== triggerId) || disabled) return
-
-    if (type === 'linkbtn' && selectedData && selectedData.length === 1) {
-      if (record[0].$Index !== selectedData[0].$Index) {
-        return
-      }
-    }
+    if (disabled) return
+    if (triggerId && btn.uuid !== triggerId) return
+    if (type === 'linkbtn' && !btn.$toolbtn && LID !== lid) return
 
     let data = record || selectedData || []
 
-    if (btn.Ot && btn.Ot !== 'notRequired' && data.length === 0) {
+    if (btn.Ot !== 'notRequired' && data.length === 0) {
       // 闇�瑕侀�夋嫨琛屾椂锛屾牎楠屾暟鎹�
       notification.warning({
         top: 92,
-        message: this.state.dict['main.action.confirm.selectline'],
+        message: dict['select_row'] || '璇烽�夋嫨琛岋紒',
         duration: 5
       })
       return
@@ -104,7 +128,14 @@
       // 闇�瑕侀�夋嫨鍗曡鏃讹紝鏍¢獙鏁版嵁
       notification.warning({
         top: 92,
-        message: this.state.dict['main.action.confirm.selectSingleLine'],
+        message: dict['select_single_row'] || '璇烽�夋嫨鍗曡鏁版嵁锛�',
+        duration: 5
+      })
+      return
+    } else if (btn.pageTemplate === 'custom' && window.GLOB.systemType === 'production' && !btn.proUrl) {
+      notification.warning({
+        top: 92,
+        message: dict['no_prod_link'] || '灏氭湭璁剧疆姝e紡绯荤粺閾炬帴鍦板潃锛�',
         duration: 5
       })
       return
@@ -120,122 +151,553 @@
     let Id = ''
     let name = ''
     let MenuNo = ''
-    let Remark = ''
+    let lang = ''
     if (btn.Ot === 'requiredSgl' && data[0]) {
-      Id = setting.primaryKey ? (data[0][setting.primaryKey] || '') : ''
+      Id = data[0].$$uuid || ''
       name = data[0].PrintTempName || ''
       MenuNo = data[0].PrintTempNO || ''
-      Remark = data[0].Remark || ''
+      lang = data[0].lang_s || ''
     }
 
-    let _name = '鏂伴〉闈�'
-
     if (btn.pageTemplate === 'billprint') {
-      _name = '鍗曟嵁鎵撳嵃'
-      if (btn.Ot === 'required' && data && data.length > 0) {
-        data.forEach((item, i) => {
-          let _id = setting.primaryKey ? (item[setting.primaryKey] || '') : ''
-          let url = '#/billprint/' + window.btoa(window.encodeURIComponent(JSON.stringify({ id: _id, tempId: btn.printTemp, dataM: sessionStorage.getItem('dataM') })))
-          window.open(url)
+      if (btn.preHandle === 'true' && btn.pre_func) {
+        MKEmitter.emit('queryModuleParam', btn.$menuId, (res) => {
+          let searches = {}
+          res.search && res.search.forEach(item => {
+            searches[item.key] = item.value
+          })
+
+          if (btn.Ot === 'requiredOnce') {
+            Id = data.map(item => item.$$uuid).filter(Boolean).join(',')
+          }
+
+          if (btn.Ot === 'required') {
+            data.forEach(item => {
+              let _param = { id: item.$$uuid || '', tempId: btn.printTemp, pageId: btn.$MenuID || '', dataM: sessionStorage.getItem('dataM')}
+              try {
+                // eslint-disable-next-line
+                let func = new Function('btn', 'searches', 'data', 'param', 'systemType', btn.pre_func)
+                _param = func(btn, searches, [item], _param, window.GLOB.systemType)
+              } catch (e) {
+                console.warn(e)
+              }
+
+              if (!_param || _param.error) {
+                notification.warning({
+                  top: 92,
+                  message: _param ? _param.error : '鏈幏鍙栧埌鎵撳嵃鍙傛暟锛岃嚜瀹氫箟鑴氭湰閿欒锛�',
+                  duration: 5
+                })
+                return
+              }
+              
+              window.open('#/billprint/' + window.btoa(window.encodeURIComponent(JSON.stringify(_param))))
+            })
+          } else {
+            let _param = { id: Id, tempId: btn.printTemp, pageId: btn.$MenuID || '', dataM: sessionStorage.getItem('dataM')}
+            try {
+              // eslint-disable-next-line
+              let func = new Function('btn', 'searches', 'data', 'param', 'systemType', btn.pre_func)
+              _param = func(btn, searches, data, _param, window.GLOB.systemType)
+            } catch (e) {
+              console.warn(e)
+            }
+
+            if (!_param || _param.error) {
+              notification.warning({
+                top: 92,
+                message: _param ? _param.error : '鏈幏鍙栧埌鎵撳嵃鍙傛暟锛岃嚜瀹氫箟鑴氭湰閿欒锛�',
+                duration: 5
+              })
+              return
+            }
+
+            window.open('#/billprint/' + window.btoa(window.encodeURIComponent(JSON.stringify(_param))))
+          }
         })
       } else {
-        window.open('#/billprint/' + window.btoa(window.encodeURIComponent(JSON.stringify({ id: Id, tempId: btn.printTemp, dataM: sessionStorage.getItem('dataM') }))))
+        if (btn.Ot === 'required') {
+          data.forEach(item => {
+            let _param = { id: item.$$uuid || '', tempId: btn.printTemp, pageId: btn.$MenuID || '', dataM: sessionStorage.getItem('dataM')}
+
+            Object.keys(item).forEach(key => {
+              if (/^\$/.test(key)) return
+              if (typeof(item[key]) !== 'string' && typeof(item[key]) !== 'number') return
+              if (typeof(item[key]) === 'string' && item[key].length > 50) return
+              if (['id', 'tempid', 'pageid', 'datam'].includes(key.toLowerCase())) return
+
+              _param[key.toLowerCase()] = item[key]
+            })
+
+            let url = '#/billprint/' + window.btoa(window.encodeURIComponent(JSON.stringify(_param)))
+            window.open(url)
+          })
+        } else if (btn.Ot === 'requiredOnce') {
+          Id = data.map(item => item.$$uuid).filter(Boolean).join(',')
+          let _param = { id: Id, tempId: btn.printTemp, pageId: btn.$MenuID || '', dataM: sessionStorage.getItem('dataM')}
+          let item = data[0]
+
+          Object.keys(item).forEach(key => {
+            if (/^\$/.test(key)) return
+            if (typeof(item[key]) !== 'string' && typeof(item[key]) !== 'number') return
+            if (typeof(item[key]) === 'string' && item[key].length > 50) return
+            if (['id', 'tempid', 'pageid', 'datam'].includes(key.toLowerCase())) return
+
+            _param[key.toLowerCase()] = item[key]
+          })
+  
+          window.open('#/billprint/' + window.btoa(window.encodeURIComponent(JSON.stringify(_param))))
+        } else {
+          let _param = { id: Id, tempId: btn.printTemp, pageId: btn.$MenuID || '', dataM: sessionStorage.getItem('dataM')}
+          let item = data[0]
+
+          if (item) {
+            Object.keys(item).forEach(key => {
+              if (/^\$/.test(key)) return
+              if (typeof(item[key]) !== 'string' && typeof(item[key]) !== 'number') return
+              if (typeof(item[key]) === 'string' && item[key].length > 50) return
+              if (['id', 'tempid', 'pageid', 'datam'].includes(key.toLowerCase())) return
+  
+              _param[key.toLowerCase()] = item[key]
+            })
+          }
+
+          window.open('#/billprint/' + window.btoa(window.encodeURIComponent(JSON.stringify(_param))))
+        }
       }
     } else if (btn.pageTemplate === 'billprintTemp') {
-      let src = '#/menudesign/' + window.btoa(window.encodeURIComponent(JSON.stringify({ MenuType: 'billPrint', MenuId: Id, MenuNo: MenuNo, MenuName: name || '鎵撳嵃', Remark: Remark })))
+      let src = '#/menudesign/' + window.btoa(window.encodeURIComponent(JSON.stringify({ MenuType: 'billPrint', MenuId: Id, MenuNo: MenuNo, MenuName: name || '鎵撳嵃', lang })))
       window.open(src)
     } else if (btn.pageTemplate === 'print') {
-      let cloudmsg = '&cuid=' + (sessionStorage.getItem('CloudUserID') || '') + '&clid=' + (sessionStorage.getItem('CloudLoginUID') || '') + '&cun=' + (sessionStorage.getItem('CloudUserName') || '')
-      let msg = '&uid=' + sessionStorage.getItem('UserID') + '&lid=' + sessionStorage.getItem('LoginUID') + '&un=' + sessionStorage.getItem('User_Name')
-      let src = '#/print/' + window.btoa('ID=' + Id + msg + cloudmsg)
+      let src = '#/print/' + window.btoa(window.encodeURIComponent(JSON.stringify({ ID: Id, lang })))
       window.open(src)
     } else if (btn.pageTemplate === 'pay') {
-      let _p = `ID=${Id}&userid=${sessionStorage.getItem('UserID')}&LoginUID=${sessionStorage.getItem('LoginUID')}&logo=${window.GLOB.doclogo}&name=${sessionStorage.getItem('Full_Name')}&icp=${window.GLOB.ICP}&copyRight=${window.GLOB.copyRight}`
-      let url = '#/pay/' +  window.btoa(window.encodeURIComponent(_p))
-      _name = '鏀粯'
-      
-      confirm({
-        title: '璇峰湪浠樻椤甸潰瀹屾垚璁㈠崟鏀粯銆�',
-        content: '',
-        className: 'pay-query',
-        okText: '鏀粯鎴愬姛',
-        cancelText: '鏀粯閬囧埌闂',
-        onOk() {
-          // 鏀粯鍚庡埛鏂扮晫闈�
-          MKEmitter.emit('refreshByButtonResult', btn.$menuId, 'grid', btn)
-        },
-        onCancel() {
-          MKEmitter.emit('refreshByButtonResult', btn.$menuId, 'grid', btn)
-        },
-      })
-      window.open(url)
+      let appId = ''
+      let merchId = ''
+
+      if (btn.wxApp) {
+        appId = btn.wxApp
+        if (!window.GLOB.WXApps || window.GLOB.WXApps.findIndex(item => item.appId === btn.wxApp) === -1) {
+          notification.warning({
+            top: 92,
+            message: '鎸夐挳鍏宠仈搴旂敤涓嶅湪鍙敤鍒楄〃涓紝璇烽噸鏂颁繚瀛樻寜閽厤缃紒',
+            duration: 5
+          })
+          return
+        }
+      }
+      if (btn.wxMerch) {
+        merchId = btn.wxMerch
+        if (!window.GLOB.WXApps || window.GLOB.WXApps.findIndex(item => item.appId === btn.wxMerch) === -1) {
+          notification.warning({
+            top: 92,
+            message: '鎸夐挳鍏宠仈鍟嗘埛涓嶅湪鍙敤鍒楄〃涓紝璇烽噸鏂颁繚瀛樻寜閽厤缃紒',
+            duration: 5
+          })
+          return
+        }
+      }
+
+      if (btn.payMode === 'system' || btn.payMode === 'inner') {
+        this.prequest(Id, data[0] || {}, appId, merchId)
+      } else {
+        confirm({
+          title: '璇峰湪浠樻椤甸潰瀹屾垚璁㈠崟鏀粯銆�',
+          content: '',
+          className: 'pay-query',
+          okText: '鏀粯鎴愬姛',
+          cancelText: '鏀粯閬囧埌闂',
+          onOk() {
+            // 鏀粯鍚庡埛鏂扮晫闈�
+            MKEmitter.emit('reloadMenuView', btn.$MenuID)
+          },
+          onCancel() {
+            MKEmitter.emit('refreshByButtonResult', btn.$menuId, 'grid', btn)
+          },
+        })
+
+        window.open('#/pay/' + window.btoa(window.encodeURIComponent(JSON.stringify({ ID: Id, appId, merchId }))))
+      }
     } else if (btn.pageTemplate === 'custom') {
       let url = btn.url
-      let con = '?'
+      if (window.GLOB.systemType === 'production') {
+        url = btn.proUrl
+      }
 
-      if (/\?/ig.test(url)) {
-        con = '&'
+      if (btn.Ot === 'notRequired' && BID) {
+        Id = BID
       }
       
-      if (btn.Ot === 'requiredSgl' && btn.joint !== 'false') {
+      if (/#\/iframe\//.test(url)) {
+        url = url.replace(/@loginuid@/ig, sessionStorage.getItem('LoginUID'))
+        url = url + '/' + Id
+
+        let menu = {
+          MenuID: btn.uuid,
+          MenuName: btn.label,
+          type: 'iframe',
+          OpenType: 'newtab',
+          src: url
+        }
+        MKEmitter.emit('modifyTabs', menu)
+
+        return
+      }
+      
+      if (btn.joint === 'true') {
+        let con = '?'
+  
+        if (/\?/ig.test(url)) {
+          con = '&'
+        }
         url = url + `${con}id=${Id}&appkey=${window.GLOB.appkey}&userid=${sessionStorage.getItem('UserID')}&LoginUID=${sessionStorage.getItem('LoginUID') || ''}`
-      } else if (btn.Ot === 'requiredSgl' && btn.joint === 'false') {
-        url = url + `${con}id=${Id}`
-      } else if (btn.joint !== 'false') {
-        url = url + `${con}appkey=${window.GLOB.appkey}&userid=${sessionStorage.getItem('UserID')}&LoginUID=${sessionStorage.getItem('LoginUID') || ''}`
+      } else if (/@/.test(url)) {
+        url = url.replace(/@id@/ig, Id)
+        url = url.replace(/@appkey@/ig, window.GLOB.appkey)
+        url = url.replace(/@userid@/ig, sessionStorage.getItem('UserID'))
+        url = url.replace(/@LoginUID@/ig, sessionStorage.getItem('LoginUID'))
+
+        if (btn.Ot === 'requiredSgl' && data[0]) {
+          Object.keys(data[0]).forEach(key => {
+            if (/^\$/.test(key)) return
+            let reg = new RegExp('@' + key + '@', 'ig')
+            url = url.replace(reg, data[0][key])
+          })
+        }
       }
 
       window.open(url)
     }
 
     if (window.GLOB.systemType === 'production') {
-      MKEmitter.emit('queryTrigger', {menuId: btn.uuid, name: _name})
+      let _temname = {
+        billprint: '鍗曟嵁鎵撳嵃',
+        pay: '鐩存帴鎵ц',
+      }
+
+      MKEmitter.emit('queryTrigger', {menuId: btn.uuid, name: _temname[btn.pageTemplate] || '鏂伴〉闈�'})
+    }
+  }
+
+  prequest = (ID, data, appId, merchId) => {
+    const { btn, BID } = this.props
+
+    let param = null
+    if (btn.payMode === 'inner') {
+      param = {
+        func: btn.innerFunc || '',
+        BID: BID || '',
+        username: sessionStorage.getItem('User_Name') || '',
+        fullname: sessionStorage.getItem('Full_Name') || '',
+        dataM: sessionStorage.getItem('dataM') === 'true' ? 'Y' : '',
+        ID: ID
+      }
+    } else if (window.backend && window.GLOB.CacheData.has('sql_' + btn.uuid)) {
+      param = this.getbackParam(ID, data)
+    } else {
+      let sql = this.getSysDeclareSql(ID, data)
+
+      param = {
+        func: 'sPC_TableData_InUpDe',
+        BID: BID || '',
+        exec_type: window.GLOB.execType || 'y',
+        timestamp: moment().format('YYYY-MM-DD HH:mm:ss')
+      }
+
+      param.secretkey = Utils.encrypt('', param.timestamp)
+      param.LText = Utils.formatOptions(sql, param.exec_type)
+
+      if (btn.output) {
+        param.key_back_type = 'Y'
+      }
+
+      if (window.GLOB.mkHS) { // 鍑芥暟 sPC_TableData_InUpDe 浜戠楠岃瘉
+        param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp)
+      }
+
+      param.menuname = btn.logLabel
+
+      if (window.GLOB.probation) {
+        param.s_debug_type = 'Y'
+      }
+    }
+
+    this.setState({loading: true})
+    Api.genericInterface(param).then(res => {
+      this.setState({loading: false})
+      if (res.status) {
+        let id = ID
+        if (btn.output) {
+          id = res.mk_b_id || res[btn.output] || ID
+        }
+
+        confirm({
+          title: '璇峰湪浠樻椤甸潰瀹屾垚璁㈠崟鏀粯銆�',
+          content: '',
+          className: 'pay-query',
+          okText: '鏀粯鎴愬姛',
+          cancelText: '鏀粯閬囧埌闂',
+          onOk() {
+            // 鏀粯鍚庡埛鏂扮晫闈�
+            MKEmitter.emit('reloadMenuView', btn.$MenuID)
+          },
+          onCancel() {
+            MKEmitter.emit('refreshByButtonResult', btn.$menuId, 'grid', btn)
+          },
+        })
+
+        window.open('#/pay/' + window.btoa(window.encodeURIComponent(JSON.stringify({ ID: id, appId, merchId }))))
+      } else {
+        this.execError(res)
+      }
+    })
+  }
+
+  getbackParam = (ID, data) => {
+    const { columns, btn, BID } = this.props
+
+    let ex = window.GLOB.CacheData.get('sql_' + btn.uuid)
+    let exps = []
+    let values = {
+      time_id: Utils.getguid(),
+      roleid: sessionStorage.getItem('role_id') || '',
+      mk_departmentcode: sessionStorage.getItem('departmentcode') || '',
+      mk_organization: sessionStorage.getItem('organization') || '',
+      mk_user_type: sessionStorage.getItem('mk_user_type') || '',
+      mk_nation: sessionStorage.getItem('nation') || '',
+      mk_province: sessionStorage.getItem('province') || '',
+      mk_city: sessionStorage.getItem('city') || '',
+      mk_district: sessionStorage.getItem('district') || '',
+      mk_address: sessionStorage.getItem('address') || '',
+      id: ID || '',
+      bid: BID || '',
+      typename: 'admin',
+      datam: sessionStorage.getItem('dataM') === 'true' ? 'Y' : '',
+      datam_begin: sessionStorage.getItem('dataM') === 'true' ? 'Y' : '',
+      datam_end: sessionStorage.getItem('dataM') === 'true' ? 'Y' : '',
+    }
+  
+    if (window.GLOB.externalDatabase !== null) {
+      values.db = window.GLOB.externalDatabase
+    }
+
+    ex.reps.forEach(n => {
+      let key = n.toLowerCase()
+      if (values.hasOwnProperty(key)) {
+        exps.push({
+          key: n,
+          value: values[key]
+        })
+      }
+    })
+
+    let _data = {}
+    Object.keys(data).forEach(key => {
+      _data[key.toLowerCase()] = data[key]
+    })
+  
+    columns.forEach(col => {
+      if (!ex.reps.includes(col.field)) return
+      if (!col.datatype) return
+
+      let _key = col.field.toLowerCase()
+      let _val = _data.hasOwnProperty(_key) ? _data[_key] : ''
+
+      if (/^date/ig.test(col.datatype) && !_val) {
+        _val = '1949-10-01'
+      }
+
+      exps.push({
+        key: 'mk_' + col.field + '_mk',
+        value: _val
+      })
+    })
+
+    let md5_id = ''
+    if (window.GLOB.probation) {
+      md5_id = md5(ex.id + JSON.stringify(exps) + Math.floor(new Date().getTime() / 600000))
+      md5_id = moment().format('YYYYMMDDHHmmss') + md5_id.slice(-18)
+    }
+
+    return {
+      $backend: true,
+      $type: 's_TableData_InUpDe',
+      data: [{
+        id: ex.id,
+        menuname: btn.logLabel || '',
+        exps: exps,
+        md5_id: md5_id
+      }]
+    }
+  }
+
+  getSysDeclareSql = (ID, data) => {
+    const { columns, btn, BID } = this.props
+
+    // 绯荤粺鍙橀噺
+    let _vars = ['tbid', 'errorcode', 'retmsg', 'username', 'fullname', 'roleid', 'mk_departmentcode', 'mk_organization', 'mk_user_type', 'mk_nation', 'mk_province', 'mk_city', 'mk_district', 'mk_address', 'bid']
+    let _declare = []
+    let _initVal = []
+  
+    let _data = {}
+    Object.keys(data).forEach(key => {
+      _data[key.toLowerCase()] = data[key]
+    })
+  
+    columns.forEach(col => {
+      let _key = col.field.toLowerCase()
+
+      if (_vars.includes(_key)) return
+
+      _declare.push(`@${_key} ${col.datatype}`)
+
+      let _val = _data.hasOwnProperty(_key) ? _data[_key] : ''
+
+      if (/^date/ig.test(col.datatype) && !_val) {
+        _val = '1949-10-01'
+      }
+
+      if (/'/.test(_val)) {
+        _val = _val.replace(/'/ig, '"')
+      }
+
+      _initVal.push(`@${_key}='${_val}'`)
+    })
+  
+    // 鍙橀噺澹版槑
+    _declare = _declare.join(',')
+    if (_declare) {
+      _declare = ',' + _declare
+    }
+
+    let _sql = `/* 绯荤粺鐢熸垚 */
+      Declare @ErrorCode nvarchar(50),@retmsg nvarchar(4000), @UserName nvarchar(50),@FullName nvarchar(50),@RoleID nvarchar(512),@mk_departmentcode nvarchar(512),@mk_organization nvarchar(512),@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),@tbid nvarchar(50)${_declare}
+    `
+  
+    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') || ''
+  
+    // 鍒濆鍖栧嚟璇佸強鐢ㄦ埛淇℃伅瀛楁
+    _sql += `
+      /* 鐢ㄦ埛淇℃伅鍒濆鍖栬祴鍊� */
+      select @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}', @bid='${BID}'
+    `
+    _sql += `
+      /* 鏄剧ず鍒楀彉閲忚祴鍊� */
+      select ${_initVal.join(',')}
+    `
+
+    btn.verify.scripts.forEach(item => {
+      if (item.status === 'false') return
+
+      _sql += `
+      ${item.sql}
+      `
+    })
+
+    if (btn.output) {
+      _sql += `
+        aaa: select @ErrorCode as ErrorCode,@retmsg as retmsg,${btn.output} as mk_b_id`
+    } else {
+      _sql += `
+        aaa: select @ErrorCode as ErrorCode,@retmsg as retmsg`
+    }
+
+    _sql = _sql.replace(/@ID@/ig, `'${ID || ''}'`)
+    _sql = _sql.replace(/@BID@/ig, `'${BID || ''}'`)
+    _sql = _sql.replace(/@LoginUID@/ig, `'${sessionStorage.getItem('LoginUID') || ''}'`)
+    _sql = _sql.replace(/@SessionUid@/ig, `'${localStorage.getItem('SessionUid') || ''}'`)
+    _sql = _sql.replace(/@UserID@/ig, `'${sessionStorage.getItem('UserID') || ''}'`)
+    _sql = _sql.replace(/@Appkey@/ig, `'${window.GLOB.appkey || ''}'`)
+    _sql = _sql.replace(/@lang@/ig, `'${sessionStorage.getItem('lang')}'`)
+    _sql = _sql.replace(/@typename@/ig, `'admin'`)
+
+    if (window.GLOB.externalDatabase !== null) {
+      _sql = _sql.replace(/@db@/ig, window.GLOB.externalDatabase)
+    }
+
+    if (sessionStorage.getItem('dataM') === 'true') { // 鏁版嵁鏉冮檺
+      _sql = _sql.replace(/\$@/ig, '/*').replace(/@\$/ig, '*/').replace(/@datam@/ig, `'Y'`)
+    } else {
+      _sql = _sql.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, `''`)
+    }
+
+    if (window.GLOB.debugger === true) {
+      window.mkInfo('%c' + btn.logLabel, 'color: blue')
+      window.mkInfo(_sql)
+    }
+
+    return _sql
+  }
+
+  execError = (res) => {
+    const { btn } = this.props
+    const { dict } = this.state
+
+    if (!['LoginError', 'C', '-2', 'E', 'N', 'F', 'NM'].includes(res.ErrCode)) {
+      res.ErrCode = 'E'
+    }
+
+    if (res.ErrCode === 'E') {
+      Modal.error({
+        title: res.message || dict['exc_fail'] || '鎵ц澶辫触锛�',
+        okText: dict['got_it'] || '鐭ラ亾浜�'
+      })
+    } else if (res.ErrCode === 'N') {
+      notification.error({
+        top: 92,
+        message: res.message || dict['exc_fail'] || '鎵ц澶辫触锛�',
+        duration: btn.verify && btn.verify.ntime ? btn.verify.ntime : 10
+      })
+    } else if (res.ErrCode === 'F') {
+      notification.error({
+        className: 'notification-custom-error',
+        top: 92,
+        message: res.message || dict['exc_fail'] || '鎵ц澶辫触锛�',
+        duration: btn.verify && btn.verify.ftime ? btn.verify.ftime : 10
+      })
+    } else if (res.ErrCode === 'NM') {
+      message.error(res.message || dict['exc_fail'] || '鎵ц澶辫触锛�')
     }
   }
 
   render() {
-    const { btn, show } = this.props
-    const { disabled, hidden } = this.state
+    const { btn, name } = this.props
+    const { disabled, hidden, loading } = this.state
 
     if (hidden) return null
 
-    if (show === 'actionList') {
-      return (
-        <Button
-          className={'mk-btn mk-' + btn.class}
-          icon={btn.icon}
-          disabled={disabled}
-          onClick={(e) => {e.stopPropagation(); this.actionTrigger()}}
-        >{btn.label}</Button>
-      )
-    } else { // icon銆乼ext銆� all 鍗$墖
-      let label = ''
-      let icon = ''
+    let label = ''
 
-      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 || ''
-      // } else if (show === 'text') {
-      } else {
-        label = btn.label
-      }
-
-      return (
-        <Button
-          type="link"
-          title={show === 'icon' ? btn.label : ''}
-          style={btn.style}
-          disabled={disabled}
-          icon={icon}
-          onClick={(e) => {e.stopPropagation(); this.actionTrigger()}}
-        >{label}</Button>
-      )
+    if (btn.show === 'link') {
+      label = <span>{name || btn.label}{btn.icon ? <MkIcon style={{marginLeft: '8px'}} type={btn.icon} /> : ''}</span>
+    } else if (btn.show === 'icon') {
+      label = <MkIcon type={btn.icon} />
+    } else {
+      label = <span>{btn.icon ? <MkIcon style={{marginRight: '8px'}} type={btn.icon} /> : ''}{name || btn.label}</span>
     }
+
+    return (
+      <Button
+        type="link"
+        id={'button' + btn.uuid}
+        title={disabled ? (btn.reason || '') : (btn.show === 'icon' ? btn.label : '')}
+        style={btn.style || null}
+        loading={loading}
+        disabled={disabled}
+        className={btn.hover || ''}
+        onClick={(e) => {e.stopPropagation(); this.actionTrigger()}}
+      >{label}</Button>
+    )
   }
 }
 

--
Gitblit v1.8.0