From fe21d23b147ed5cec22b4f76a88840b05495d4ad Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期六, 18 六月 2022 22:33:59 +0800
Subject: [PATCH] 2022-06-18

---
 src/tabviews/zshare/actionList/normalbutton/index.jsx |  361 ++++++++++++++++++++++++++++++++++++---------------
 1 files changed, 256 insertions(+), 105 deletions(-)

diff --git a/src/tabviews/zshare/actionList/normalbutton/index.jsx b/src/tabviews/zshare/actionList/normalbutton/index.jsx
index ba6f77f..296ae6e 100644
--- a/src/tabviews/zshare/actionList/normalbutton/index.jsx
+++ b/src/tabviews/zshare/actionList/normalbutton/index.jsx
@@ -3,7 +3,7 @@
 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 +21,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 +30,7 @@
     columns: PropTypes.any,           // 瀛楁鍒�
     setting: PropTypes.any,           // 椤甸潰閫氱敤璁剧疆
     ContainerId: PropTypes.any,       // tab椤甸潰ID锛岀敤浜庡脊绐楁帶鍒�
+    disabled: PropTypes.any,          // 琛屾寜閽鐢�
   }
 
   state = {
@@ -43,26 +42,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 +95,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 +109,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 +170,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 +231,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 +241,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({
@@ -251,12 +325,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 +356,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 +451,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 = ''
 
@@ -598,7 +699,7 @@
         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
         })
@@ -760,6 +861,11 @@
           _resolve()
         })
       } else { // 瓒呭嚭20涓姹傛椂寰幆鎵ц
+        if (btn.progress === 'progressbar' && btn.$toolbtn) {
+          this.setState({
+            loadingTotal: params.length
+          })
+        }
         this.innerLoopRequest(params, btn, _resolve)
       }
     } else if (btn.intertype === 'outer') {
@@ -773,7 +879,7 @@
           param.BID = this.props.BID
         }
 
-        if ((btn.OpenType === 'pop' || btn.OpenType === 'formSubmit') && formdata) { // 琛ㄥ崟
+        if ((btn.OpenType === 'pop' || btn.OpenType === 'formSubmit' || btn.OpenType === 'form') && formdata) { // 琛ㄥ崟
           formdata.forEach(_data => {
             param[_data.key] = _data.value
           })
@@ -820,8 +926,14 @@
         })
       }
 
+      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, btn, _resolve)
     } else if (btn.intertype === 'custom') { // 绯荤粺鎺ュ彛
       let params = []
 
@@ -835,6 +947,12 @@
         params = this.getInnerParam(data, formdata)
       }
 
+      if (params.length > 1 && btn.progress === 'progressbar' && btn.$toolbtn) {
+        this.setState({
+          loadingTotal: params.length
+        })
+      }
+
       this.customLoopRequest(params, _resolve)
     }
   }
@@ -846,7 +964,7 @@
     let param = params.shift()
 
     this.setState({
-      loadingNumber: params.length || ''
+      loadingNumber: params.length
     })
 
     let record = {
@@ -911,6 +1029,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 鑷畾涔夎姹傚惊鐜墽琛�
@@ -1098,7 +1222,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'))
       }
 
@@ -1135,7 +1259,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
@@ -1171,7 +1295,7 @@
     let param = params.shift()
 
     this.setState({
-      loadingNumber: params.length || ''
+      loadingNumber: params.length
     })
 
     let _param = null
@@ -1222,17 +1346,15 @@
   /**
    * @description 澶栭儴璇锋眰寰幆鎵ц
    */
-  outerLoopRequest = (params, btn, _resolve, widthNumber) => {
+  outerLoopRequest = (params, btn, _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
+    })
 
     new Promise(resolve => {
       // 鍐呴儴璇锋眰
@@ -1339,7 +1461,7 @@
             this.execSuccess(response)
             _resolve()
           } else {
-            this.outerLoopRequest(params, btn, _resolve, widthNumber)
+            this.outerLoopRequest(params, btn, _resolve)
           }
         } else {
           this.execError(response)
@@ -1354,7 +1476,7 @@
           this.execSuccess(res)
           _resolve()
         } else {
-          this.outerLoopRequest(params, btn, _resolve, widthNumber)
+          this.outerLoopRequest(params, btn, _resolve)
         }
       } else {
         this.execError(res)
@@ -1375,7 +1497,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 +1510,11 @@
     } else if (res && res.ErrCode === '-1') { // 瀹屾垚鍚庝笉鎻愮ず
 
     }
+
+    this.setState({
+      loadingNumber: '',
+      loadingTotal: '',
+    })
     
     if (autoMatic) {
       this.setState({
@@ -1411,6 +1538,18 @@
     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') {
       MKEmitter.emit('closeTabView', btn.$MenuID)
@@ -1419,17 +1558,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,
@@ -1591,6 +1738,7 @@
       this.setState({
         loading: false,
         loadingNumber: '',
+        loadingTotal: '',
         visible: false
       })
       MKEmitter.emit('autoExecOver', btn.uuid, 'error')
@@ -1599,7 +1747,8 @@
     
     this.setState({
       loading: false,
-      loadingNumber: ''
+      loadingNumber: '',
+      loadingTotal: '',
     })
 
     if (res.ErrCode === 'C') {
@@ -1652,6 +1801,9 @@
       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})
     }
   }
 
@@ -1694,10 +1846,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 +1893,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 +1911,7 @@
    */
   handleOk = () => {
     if (!this.formRef) return
+    
     this.formRef.handleConfirm().then(res => {
       this.setState({ confirmLoading: true })
 
@@ -1778,7 +1931,7 @@
   }
 
   modelconfirm = () => {
-    const { BData } = this.props
+    const { BData, btn } = this.props
     const { btnconfig, selines } = this.state
     let _this = this
 
@@ -1854,7 +2007,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 +2029,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
@@ -1925,7 +2078,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 (
@@ -1957,63 +2110,61 @@
   }
 
   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
+    } else {
+      type = ''
+      icon = btn.icon || ''
+      label = btn.label
+      className = 'mk-btn mk-' + btn.class
+    }
+
+    if (loadingNumber && !loadingTotal && btn.$toolbtn && (!btn.show || btn.show === 'button')) {
+      label = (loadingNumber && !loadingTotal ? `(${loadingNumber})` : '') + btn.label
+    }
+
+    return <div style={{display: 'inline-block'}} onClick={(e) => e.stopPropagation()}>
+      <Button
+        type={type}
+        icon={icon}
+        title={disabled ? (btn.reason || '') : (btn.show === 'icon' ? btn.label : '')}
+        loading={loading}
+        disabled={disabled}
+        style={btn.style || null}
+        className={className}
+        onClick={() => {this.actionTrigger()}}
+      >{label}</Button>
+      {this.getModels()}
+      {loadingTotal ? <Progress className="mk-button-progress" percent={(loadingTotal - loadingNumber) / loadingTotal * 100} size="small" showInfo={false} /> : null}
+    </div>
   }
 }
 

--
Gitblit v1.8.0