king
2022-02-25 d82fec9e2a4238ff1833e67c01bc9b34e525d904
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, Icon } from 'antd'
import { Button, Modal, notification, message, Drawer, Switch, Checkbox } from 'antd'
import Api from '@/api'
import Utils, { getSysDefaultSql } from '@/utils/utils.js'
@@ -13,7 +13,8 @@
import asyncSpinComponent from '@/utils/asyncSpinComponent'
import { updateForm } from '@/utils/utils-update.js'
import MKEmitter from '@/utils/events.js'
import './index.scss'
import MkIcon from '@/components/mk-icon'
// import './index.scss'
const MutilForm = asyncSpinComponent(() => import('@/tabviews/zshare/mutilform'))
const { confirm } = Modal
@@ -31,25 +32,30 @@
    columns: PropTypes.any,           // 字段列
    setting: PropTypes.any,           // 页面通用设置
    ContainerId: PropTypes.any,       // tab页面ID,用于弹窗控制
    disabled: PropTypes.any,          // 行按钮禁用
    lineId: PropTypes.any,            // 行索引+主键值,用于行按钮双击
  }
  state = {
    dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS,
    visible: false,
    formdata: null,
    tabledata: null,
    selines: null,
    confirmLoading: false,
    btnconfig: null,
    loading: false,
    loadingNumber: '',
    disabled: false,
    checkParam: null
    hidden: false,
    checkParam: null,
    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) { // 表格中按钮隐藏控制
@@ -59,7 +65,30 @@
          disabled = true
        }
      })
      this.setState({disabled})
      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 || []
      })
    }
  }
@@ -68,21 +97,24 @@
  }
  componentDidMount () {
    const { position } = this.props
    const { position, btn } = this.props
    MKEmitter.addListener('triggerBtnId', this.actionTrigger)
    if (position === 'form') {
      MKEmitter.addListener('triggerFormSubmit', this.actionSubmit)
    }
    MKEmitter.addListener('returnModuleParam', this.resetModuleParam)
    if (btn.autoMatic) {
      MKEmitter.addListener('triggerBtnPopSubmit', this.triggerBtnPopSubmit)
    }
  }
  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] + ''
@@ -91,7 +123,33 @@
          }
        })
      }
      this.setState({disabled})
      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 || []
      })
    }
  }
@@ -102,18 +160,51 @@
    MKEmitter.removeListener('triggerBtnId', this.actionTrigger)
    MKEmitter.removeListener('triggerFormSubmit', this.actionSubmit)
    MKEmitter.removeListener('returnModuleParam', this.resetModuleParam)
    MKEmitter.removeListener('triggerBtnPopSubmit', this.triggerBtnPopSubmit)
  }
  triggerBtnPopSubmit = (id) => {
    const { btn } = this.props
    if (btn.uuid !== id) return
    this.handleOk()
  }
  actionSubmit = (res) => {
    const { btn } = this.props
    const { btn, setting, BID } = this.props
    const { selines } = this.state
    if (btn.uuid !== res.menuId) return
    this.setState({
      loading: true
    })
    let data = selines || []
    this.execSubmit(this.state.tabledata, () => {}, res.form)
    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(data, () => {}, res.form)
  }
  resetModuleParam = (menuId, btnId, param) => {
@@ -127,27 +218,28 @@
  /**
   * @description 按钮状态改变
   */
  updateStatus = (type) => {
    if (type === 'start') {
      this.setState({
        loading: true
      })
    } else if (type === 'over') {
      this.setState({
        loading: false,
        visible: false
      })
    }
  updateStatus = () => {
    this.setState({
      loading: false,
      visible: false,
      confirmLoading: false
    })
  }
  
  /**
   * @description 触发按钮操作
   */
  actionTrigger = (triggerId, record) => {
  actionTrigger = (triggerId, record, type) => {
    const { Tab, BID, btn, selectedData, setting } = this.props
    const { loading } = this.state
    const { loading, disabled } = this.state
    if ((triggerId && btn.uuid !== triggerId) || loading) return
    if (loading || disabled) return
    if (triggerId) {
      if (btn.uuid !== triggerId) return
      if (this.props.lineId && record && record[0] && this.props.lineId !== record[0].$$key) {
        return
      }
    }
    if (((Tab && Tab.supMenu) || setting.supModule) && !BID) {
      notification.warning({
@@ -156,7 +248,13 @@
        duration: 5
      })
      return
    } else if (type === 'linkbtn' && selectedData && selectedData.length === 1) {
      if (record[0].$Index !== selectedData[0].$Index) {
        return
      }
    }
    this.setState({autoMatic: type === 'autoMatic'})
    let _this = this
    let data = record || selectedData || []
@@ -231,41 +329,67 @@
      return
    }
    this.setState({
      selines: data
    })
    if (btn.OpenType === 'formSubmit') {
      this.setState({
        tabledata: data
      this.setState({}, () => {
        MKEmitter.emit('mkFormSubmit', btn.uuid)
      })
      MKEmitter.emit('mkFormSubmit', btn.uuid)
      return
    } else if (btn.OpenType === 'prompt') {
      this.updateStatus('start')
      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)
          })
        },
        onCancel() {
          _this.updateStatus('over')
          _this.setState({loading: false})
        }
      })
    } else if (btn.OpenType === 'exec') {
      this.updateStatus('start')
      this.setState({loading: true})
      this.execSubmit(data, () => { this.setState({loading: false})})
    } else if (btn.OpenType === 'pop') {
      this.updateStatus('start')
      let modal = this.state.btnconfig
      if (!modal && btn.modal) {
        modal = this.handleModelConfig(btn.modal)
      }
      this.setState({
        tabledata: data,
        loading: true,
        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])
      })
    }
@@ -310,6 +434,9 @@
          param.$callbacksql = callbacksql
        } else {
          param.LText = getSysDefaultSql(btn, setting, '', param, data[0], columns, this.props.Tab, false, this.moduleParams, Utils.getAllSearchOptions) // 数据源
          if (btn.output) {
            param.key_back_type = 'Y'
          }
        }
        if (sessionStorage.getItem('dataM') === 'true') { // 数据权限
@@ -333,7 +460,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 = ''
@@ -352,7 +479,7 @@
            param.$callbacksql = callbacksql
          } else {
            param.LText = getSysDefaultSql(btn, setting, formdata, param, data[0], columns, this.props.Tab, false, this.moduleParams, Utils.getAllSearchOptions) // 数据源
            if (btn.OpenType === 'formSubmit' && btn.output) {
            if (btn.output) {
              param.key_back_type = 'Y'
            }
          }
@@ -387,6 +514,9 @@
            param.$callbacksql = callbacksql
          } else {
            param.LText = getSysDefaultSql(btn, setting, formdata, param, data[0], columns, this.props.Tab, false, this.moduleParams, Utils.getAllSearchOptions) // 数据源
            if (btn.output) {
              param.key_back_type = 'Y'
            }
          }
          
          if (sessionStorage.getItem('dataM') === 'true') { // 数据权限
@@ -422,6 +552,10 @@
      param.menuname = btn.logLabel
      if (window.GLOB.probation) {
        param.s_debug_type = 'Y'
      }
      if (check_param) {
        check_param.menuname = btn.logLabel
        this.setState({checkParam: check_param})
@@ -449,6 +583,9 @@
            param.$callbacksql = callbacksql
          } else {
            param.LText = getSysDefaultSql(btn, setting, '', param, cell, columns, this.props.Tab, false, this.moduleParams, Utils.getAllSearchOptions, Utils.getAllSearchOptions) // 数据源
            if (btn.output) {
              param.key_back_type = 'Y'
            }
          }
          
          if (sessionStorage.getItem('dataM') === 'true') { // 数据权限
@@ -482,6 +619,9 @@
              param.$callbacksql = callbacksql
            } else {
              param.LText = getSysDefaultSql(btn, setting, formdata, param, cell, columns, this.props.Tab, false, this.moduleParams, Utils.getAllSearchOptions) // 数据源
              if (btn.output) {
                param.key_back_type = 'Y'
              }
            }
            
            if (sessionStorage.getItem('dataM') === 'true') { // 数据权限
@@ -505,6 +645,9 @@
              param.$callbacksql = callbacksql
            } else {
              param.LText = getSysDefaultSql(btn, setting, formdata, param, cell, columns, this.props.Tab, false, this.moduleParams, Utils.getAllSearchOptions) // 数据源
              if (btn.output) {
                param.key_back_type = 'Y'
              }
            }
            
            if (sessionStorage.getItem('dataM') === 'true') { // 数据权限
@@ -528,6 +671,9 @@
        if (param.func === 'sPC_TableData_InUpDe') {
          param.menuname = btn.logLabel
          if (window.GLOB.probation) {
            param.s_debug_type = 'Y'
          }
        }
        return param
@@ -562,7 +708,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
        })
@@ -646,7 +792,18 @@
  }
  execRealSubmit = (data, _resolve, formdata) => {
    const { setting, btn } = this.props
    const { setting, btn, Tab, BID } = this.props
    if (((Tab && Tab.supMenu) || setting.supModule) && !BID) {
      notification.warning({
        top: 92,
        message: '需要上级主键值!',
        duration: 5
      })
      _resolve()
      return
    }
    if (btn.intertype === 'system' || btn.intertype === 'inner') { // 系统接口
      let params = []
@@ -657,14 +814,41 @@
      }
      if (params.length <= 20) {
        let deffers = params.map(param => {
        let deffers = params.map((param, i) => {
          return new Promise(resolve => {
            Api.genericInterface(param).then(res => {
              resolve(res)
            }, () => {
              this.updateStatus('over')
              _resolve()
            })
            setTimeout(() => {
              let _param = null
              if (btn.preFunc) {
                _param = fromJS(param).toJS()
                param.func = btn.preFunc
              }
              Api.genericInterface(param).then(res => {
                if (btn.preFunc && res.status && res.ErrCode !== '-1') {
                  _param = {..._param, ...res}
                  delete _param.status
                  delete _param.ErrCode
                  delete _param.ErrMesg
                  delete _param.message
                  setTimeout(() => {
                    Api.genericInterface(_param).then(result => {
                      if (!result.status) {
                        notification.warning({
                          top: 92,
                          message: result.message,
                          duration: 5
                        })
                      }
                    })
                  }, 600)
                }
                resolve(res)
              }, () => {
                this.updateStatus()
                _resolve()
              })
            }, 100 * i)
          })
        })
        Promise.all(deffers).then(result => {
@@ -699,7 +883,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
          })
@@ -816,7 +1000,7 @@
                }
                resolve()
              }, () => {
                _this.updateStatus('over')
                _this.updateStatus()
                resolve()
                _resolve()
              })
@@ -833,10 +1017,16 @@
        _resolve()
      }
    }, () => {
      this.updateStatus('over')
      this.updateStatus()
      _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 自定义请求循环执行
@@ -1044,6 +1234,10 @@
      param.LText = Utils.formatOptions(param.LText)
      param.menuname = btn.logLabel
      if (window.GLOB.probation) {
        param.s_debug_type = 'Y'
      }
      if (this.props.menuType === 'HS') { // 函数 sPC_TableData_InUpDe 云端验证
        param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp)
      }
@@ -1081,7 +1275,7 @@
        _resolve()
      }
    }, () => {
      this.updateStatus('over')
      this.updateStatus()
      _resolve()
    })
  }
@@ -1096,8 +1290,35 @@
      loadingNumber: params.length || ''
    })
    let _param = null
    if (btn.preFunc) {
      _param = fromJS(param).toJS()
      param.func = btn.preFunc
    }
    Api.genericInterface(param).then(res => {
      if (res.status) {
        if (btn.preFunc && res.ErrCode !== '-1') {
          _param = {..._param, ...res}
          delete _param.status
          delete _param.ErrCode
          delete _param.ErrMesg
          delete _param.message
          setTimeout(() => {
            Api.genericInterface(_param).then(result => {
              if (!result.status) {
                notification.warning({
                  top: 92,
                  message: result.message,
                  duration: 5
                })
              }
            })
          }, 600)
        }
        if (params.length === 0) {
          this.execSuccess(res)
          _resolve()
@@ -1109,7 +1330,7 @@
        _resolve()
      }
    }, () => {
      this.updateStatus('over')
      this.updateStatus()
      _resolve()
    })
  }
@@ -1162,7 +1383,7 @@
            _resolve()
          }
        }, () => {
          this.updateStatus('over')
          this.updateStatus()
          _resolve()
        })
      } else {
@@ -1268,9 +1489,9 @@
   */
  execSuccess = (res) => {
    const { btn } = this.props
    const { btnconfig } = this.state
    const { btnconfig, autoMatic } = this.state
    if (res && res.ErrCode === 'S') { // 执行成功
    if ((res && (res.ErrCode === 'S' || !res.ErrCode)) || autoMatic) { // 执行成功
      notification.success({
        top: 92,
        message: res.ErrMesg || this.state.dict['main.action.confirm.success'],
@@ -1284,7 +1505,14 @@
    }
    
    if (btn.OpenType !== 'pop' || !btnconfig || btnconfig.setting.finish !== 'unclose') {
    if (autoMatic) {
      this.setState({
        loading: false,
        visible: false
      })
      MKEmitter.emit('autoExecOver', btn.uuid, 'success')
      return
    } else if (btn.OpenType !== 'pop' || !btnconfig || btnconfig.setting.finish !== 'unclose') {
      this.setState({
        loading: false,
        visible: false
@@ -1299,9 +1527,50 @@
    if (btn.output) {
      id = res.mk_b_id || res[btn.output] || ''
    }
    let tabId = ''
    if (btn.refreshTab && btn.refreshTab.length > 0) {
      tabId = btn.refreshTab[btn.refreshTab.length - 1]
    }
    if (btn.execSuccess !== 'never') {
      MKEmitter.emit('refreshByButtonResult', btn.$menuId, btn.execSuccess, btn, id)
    if (tabId && btn.$MenuID === tabId) { // 刷新当前菜单时,停止其他操作
      MKEmitter.emit('reloadMenuView', tabId, 'table')
      return
    }
    if (btn.execSuccess === 'closetab') {
      MKEmitter.emit('closeTabView', btn.$MenuID)
    } else if (btn.execSuccess === 'closepoptab') {
      MKEmitter.emit('popclose')
    } else if (btn.execSuccess !== 'never') {
      MKEmitter.emit('refreshByButtonResult', btn.$menuId, btn.execSuccess, btn, id, this.state.selines)
    }
    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.openmenu && btn.openmenu.length > 0 && btn.MenuID) {
      let newtab = {
        MenuID: btn.MenuID,
        MenuName: btn.MenuName,
        MenuNo: btn.MenuNo,
        type: btn.tabType,
        param: {
          $BID: id
        }
      }
      if (['linkage_navigation', 'linkage', 'menu_board'].includes(window.GLOB.navBar)) {
        MKEmitter.emit('modifyTabs', newtab, 'replace')
      } else {
        MKEmitter.emit('modifyTabs', newtab, 'plus', true)
      }
    }
  }
@@ -1421,12 +1690,13 @@
   */
  execError = (res) => {
    const { btn } = this.props
    const { btnconfig, autoMatic } = this.state
    if (res.ErrCode === 'E') {
    if (res.ErrCode === 'E' && !autoMatic) {
      Modal.error({
        title: res.message || res.ErrMesg,
      })
    } else if (res.ErrCode === 'N') {
    } else if (res.ErrCode === 'N' || autoMatic) {
      notification.error({
        top: 92,
        message: res.message || res.ErrMesg,
@@ -1441,6 +1711,16 @@
      })
    } else if (res.ErrCode === 'NM') {
      message.error(res.message || res.ErrMesg)
    }
    if (autoMatic) {
      this.setState({
        loading: false,
        loadingNumber: '',
        visible: false
      })
      MKEmitter.emit('autoExecOver', btn.uuid, 'error')
      return
    }
    
    this.setState({
@@ -1477,7 +1757,7 @@
              visible: false
            })
            if (btn.execError !== 'never') {
              MKEmitter.emit('refreshByButtonResult', btn.$menuId, btn.execError, btn)
              MKEmitter.emit('refreshByButtonResult', btn.$menuId, btn.execError, btn, '', this.state.selines)
            }
          }
        })
@@ -1490,8 +1770,17 @@
      }
    }
    if (btn.execError !== 'never') {
      MKEmitter.emit('refreshByButtonResult', btn.$menuId, btn.execError, btn)
    if (btnconfig && btnconfig.setting && btnconfig.setting.errFocus) {
      MKEmitter.emit('mkFC', 'focus', btnconfig.setting.errFocus)
    }
    if (btn.execError === 'closepoptab') {
      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})
    }
  }
@@ -1534,10 +1823,10 @@
   */
  improveAction = () => {
    const { btn } = this.props
    const { btnconfig } = this.state
    const { btnconfig, autoMatic } = this.state
    if (btnconfig) {
      if (btnconfig.setting.display === 'prompt') { // 如果表单以是否框展示
      if (!autoMatic && (btnconfig.setting.display === 'prompt' || btnconfig.setting.display === 'exec')) { // 如果表单以是否框展示
        this.modelconfirm()
      } else {
        this.setState({
@@ -1566,14 +1855,14 @@
            message: res.message,
            duration: 5
          })
          this.updateStatus('over')
          this.setState({ loading: false })
        } else if (!_LongParam || (btn.OpenType === 'pop' && _LongParam.type !== 'Modal')) {
          notification.warning({
            top: 92,
            message: '未获取到按钮配置信息!',
            duration: 5
          })
          this.updateStatus('over')
          this.setState({ loading: false })
        } else {
          _LongParam = updateForm(_LongParam)
          _LongParam = this.handleModelConfig(_LongParam)
@@ -1581,7 +1870,7 @@
          this.setState({
            btnconfig: _LongParam
          }, () => {
            if (_LongParam.setting.display === 'prompt') { // 如果表单以是否框展示
            if (!autoMatic && (_LongParam.setting.display === 'prompt' || _LongParam.setting.display === 'exec')) { // 如果表单以是否框展示
              this.modelconfirm()
            } else {
              this.setState({
@@ -1598,16 +1887,11 @@
   * @description 模态框(表单),确认
   */
  handleOk = () => {
    if (!this.formRef) return
    this.formRef.handleConfirm().then(res => {
      this.setState({
        confirmLoading: true
      })
      this.setState({ confirmLoading: true })
      this.execSubmit(this.state.tabledata, () => {
        this.setState({
          confirmLoading: false
        })
      }, res)
      this.execSubmit(this.state.selines, () => { this.setState({ confirmLoading: false }) }, res)
    })
  }
@@ -1616,15 +1900,15 @@
   */
  handleCancel = () => {
    this.setState({
      loading: false,
      visible: false,
      confirmLoading: false
    })
    this.updateStatus('over')
  }
  modelconfirm = () => {
    const { BData } = this.props
    const { btnconfig, tabledata } = this.state
    const { BData, btn } = this.props
    const { btnconfig, selines } = this.state
    let _this = this
    let result = []
@@ -1639,8 +1923,8 @@
      if (item.type === 'linkMain' && BData && BData.hasOwnProperty(item.field)) {
        _initval = BData[item.field]
      } else if (_readin && tabledata[0] && tabledata[0].hasOwnProperty(item.field)) {
        _initval = tabledata[0][item.field]
      } else if (_readin && selines[0] && selines[0].hasOwnProperty(item.field)) {
        _initval = selines[0][item.field]
      } else if (item.type === 'date' && _initval) {
        _initval = moment().subtract(_initval, 'days').format('YYYY-MM-DD')
      } else if (item.type === 'datemonth' && _initval) {
@@ -1664,12 +1948,30 @@
      if (['date', 'datemonth', 'datetime'].includes(_type) && item.declareType === 'nvarchar(50)') {
        _type = 'text'
      } else if (item.type === 'rate') {
        item.rateCount = item.rateCount || 5
        let allowHalf = item.allowHalf === 'true'
        if (allowHalf) {
          _initval = parseFloat(_initval)
          if (_initval % 0.5 !== 0) {
            _initval = parseInt(_initval)
          }
        } else {
          _initval = parseInt(_initval)
        }
        if (isNaN(_initval) || _initval < 0) {
          _initval = 0
        } else if (_initval > item.rateCount) {
          _initval = item.rateCount
        }
      }
      result.push({
        key: item.field,
        readonly: item.readonly === 'true',
        readin: _readin,
        readin: item.readin !== 'false' && item.readin !== 'top',
        fieldlen: _fieldlen,
        writein: item.writein !== 'false',
        type: _type,
@@ -1677,37 +1979,41 @@
      })
    })
    confirm({
      title: this.state.dict['main.action.confirm.tip'],
      onOk() {
        return new Promise(resolve => {
          _this.execSubmit(tabledata, resolve, result)
        })
      },
      onCancel() {
        _this.updateStatus('over')
      }
    })
    if (btnconfig.setting.display === 'exec') {
      this.execSubmit(selines, () => {}, result)
    } else {
      confirm({
        title: btn.tipTitle || this.state.dict['main.action.confirm.tip'],
        onOk() {
          return new Promise(resolve => {
            _this.execSubmit(selines, resolve, result)
          })
        },
        onCancel() {
          _this.setState({ loading: false })
        }
      })
    }
  }
  /**
   * @description 显示模态框
   */
  getModels = () => {
    const { setting, BID, btn } = this.props
    const { setting, BID, btn, BData } = this.props
    const { btnconfig, visible } = this.state
    if (!btnconfig || !btnconfig.setting) return null
    let title = btnconfig.setting.title
    let width = btnconfig.setting.width + 'vw'
    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
@@ -1727,17 +2033,17 @@
            menuType={this.props.menuType}
            action={btnconfig}
            inputSubmit={this.handleOk}
            data={this.state.tabledata[0]}
            BData={this.props.BData}
            data={this.state.selines[0]}
            BData={BData}
            wrappedComponentRef={(inst) => this.formRef = inst}
          />
          <div style={{ position: 'absolute', zIndex: 1, right: 0, bottom: 0, width: '100%', borderTop: '1px solid #e9e9e9', padding: '10px 16px', background: '#fff', textAlign: 'right'}}>
          <div className="ant-drawer-footer" style={{ position: 'absolute', zIndex: 1, right: 0, bottom: 0, width: '100%', borderTop: '1px solid #e9e9e9', padding: '10px 16px', background: '#fff', textAlign: 'right'}}>
            <Button onClick={this.handleCancel} style={{ marginRight: 8 }}>
              取消
              {btnconfig.setting.formType !== 'check' ? '取消' : '关闭'}
            </Button>
            <Button onClick={this.handleOk} loading={this.state.confirmLoading} type="primary">
            {btnconfig.setting.formType !== 'check' ? <Button onClick={this.handleOk} loading={this.state.confirmLoading} type="primary">
              确定
            </Button>
            </Button> : null}
          </div>
        </Drawer>
      )
@@ -1748,7 +2054,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 (
@@ -1770,8 +2076,8 @@
            menuType={this.props.menuType}
            action={btnconfig}
            inputSubmit={this.handleOk}
            data={this.state.tabledata[0]}
            BData={this.props.BData}
            data={this.state.selines[0]}
            BData={BData}
            wrappedComponentRef={(inst) => this.formRef = inst}
          />
        </Modal>
@@ -1781,9 +2087,17 @@
  render() {
    const { btn, show, style } = this.props
    const { loadingNumber, loading, disabled } = this.state
    const { loadingNumber, loading, disabled, hidden, check } = this.state
    if (show === 'actionList') {
    if (hidden) return null
    if (btn.OpenType === 'form') {
      if (btn.formType === 'switch') {
        return <Switch loading={loading} checked={check} disabled={disabled || loading} onChange={(val,e) => {e.stopPropagation();this.actionTrigger()}} style={style} size={btn.size} checkedChildren={btn.openText || ''} unCheckedChildren={btn.closeText || ''}/>
      } else {
        return <Checkbox disabled={disabled || loading} checked={check} onChange={(e) => {e.stopPropagation();this.actionTrigger()}} style={style}></Checkbox>
      }
    } else if (show === 'actionList') {
      return <div style={{display: 'inline-block'}} onClick={(e) => e.stopPropagation()}>
        <Button
          style={style}
@@ -1796,7 +2110,7 @@
        {this.getModels()}
      </div>
    } else if (show && show.indexOf('plus') > -1) {
      return <div className="mk-btn-wrap">
      return <div style={{display: 'inline-block'}}>
        <Button
          type="link"
          loading={loading}
@@ -1814,11 +2128,10 @@
        label = btn.label
        icon = btn.icon || ''
      } else if (show === 'link') {
        label = <span>{btn.label}{btn.icon ? <Icon style={{marginLeft: '8px'}} type={btn.icon}/> : ''}</span>
        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
      }
@@ -1841,7 +2154,6 @@
const mapStateToProps = (state) => {
  return {
    tabviews: state.tabviews,
    menuType: state.editLevel
  }
}