king
2021-09-01 31ec63f0419895876cbaba99637a884a32d33d0d
src/tabviews/zshare/actionList/printbutton/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 } from 'antd'
import { Button, Modal, notification, message, Icon } from 'antd'
import Api from '@/api'
import Utils from '@/utils/utils.js'
@@ -11,6 +11,8 @@
import zhCN from '@/locales/zh-CN/main.js'
import enUS from '@/locales/en-US/main.js'
import asyncSpinComponent from '@/utils/asyncSpinComponent'
import { updateForm } from '@/utils/utils-update.js'
import MKEmitter from '@/utils/events.js'
import './index.scss'
const MutilForm = asyncSpinComponent(() => import('@/tabviews/zshare/mutilform'))
@@ -20,6 +22,7 @@
class PrintButton extends Component {
  static propTpyes = {
    show: PropTypes.any,              // 按钮显示样式控制
    position: PropTypes.any,          // 按钮位置,工具栏为toolbar
    BID: PropTypes.string,            // 主表ID
    BData: PropTypes.any,             // 主表数据
    selectedData: PropTypes.any,      // 子表中选择数据
@@ -28,8 +31,6 @@
    btn: PropTypes.object,            // 按钮
    setting: PropTypes.any,           // 页面通用设置
    ContainerId: PropTypes.any,       // tab页面ID,用于弹窗控制
    updateStatus: PropTypes.func,     // 按钮状态更新
    triggerBtn: PropTypes.any,
  }
  state = {
@@ -39,20 +40,60 @@
    tabledata: null,
    btnconfig: null,
    loading: false,
    disabled: false,
    loadingNumber: ''
  }
  /**
   * @description 外部触发按钮点击
   */
  UNSAFE_componentWillReceiveProps(nextProps) {
    if (nextProps.triggerBtn && !is(fromJS(this.props.triggerBtn), fromJS(nextProps.triggerBtn)) && nextProps.triggerBtn.button.uuid === this.props.btn.uuid) {
      this.actionTrigger(nextProps.triggerBtn.data)
  UNSAFE_componentWillMount () {
    const { btn, selectedData } = this.props
    let disabled = false
    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})
    }
  }
  shouldComponentUpdate (nextProps, nextState) {
    return !is(fromJS(this.props), fromJS(nextProps)) || !is(fromJS(this.state), fromJS(nextState))
  }
  componentDidMount () {
    const { position } = this.props
    if (position === 'toolbar') {
      MKEmitter.addListener('triggerBtnId', this.actionTrigger)
    }
  }
  UNSAFE_componentWillReceiveProps (nextProps) {
    const { btn, selectedData } = 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})
    }
  }
  componentWillUnmount () {
    this.setState = () => {
      return
    }
    MKEmitter.removeListener('triggerBtnId', this.actionTrigger)
  }
  /**
@@ -63,22 +104,23 @@
      this.setState({
        loading: true
      })
      this.props.updateStatus('start')
    } else if (type === 'over') {
      this.setState({
        loading: false
      })
      this.props.updateStatus('over')
    }
  }
  
  /**
   * @description 触发按钮操作
   */
  actionTrigger = (record) => {
    const { setting, Tab, BID, btn, selectedData } = this.props
  actionTrigger = (triggerId, record) => {
    const { Tab, BID, btn, selectedData, setting } = this.props
    const { loading } = this.state
    if (Tab && Tab.supMenu && !BID) {
    if ((triggerId && btn.uuid !== triggerId) || loading) return
    if (((Tab && Tab.supMenu) || setting.supModule) && !BID) {
      notification.warning({
        top: 92,
        message: '需要上级主键值!',
@@ -88,13 +130,7 @@
    }
    let _this = this
    let data = []
    if (record) { // 表格中触发按钮
      data = [record]
    } else {
      data = selectedData || []
    }
    let data = record || selectedData || []
    if (btn.Ot !== 'notRequired' && data.length === 0) {
      // 需要选择行时,校验数据
@@ -109,14 +145,6 @@
      notification.warning({
        top: 92,
        message: this.state.dict['main.action.confirm.selectSingleLine'],
        duration: 5
      })
      return
    } else if (!setting.primaryKey) {
      // 需要选择行时,校验是否设置主键
      notification.warning({
        top: 92,
        message: '未设置主键!',
        duration: 5
      })
      return
@@ -139,8 +167,14 @@
    if (btn.execMode === 'pop') {
      this.updateStatus('start')
      let modal = this.state.btnconfig
      if (!modal && btn.modal) {
        modal = this.handleModelConfig(btn.modal)
      }
      this.setState({
        tabledata: data
        tabledata: data,
        btnconfig: modal
      }, () => {
        this.improveAction()
      })
@@ -157,6 +191,10 @@
      })
    } else {
      this.triggerPrint(data)
    }
    if (window.GLOB.systemType === 'production') {
      MKEmitter.emit('queryTrigger', {menuId: btn.uuid, name: '标签打印'})
    }
  }
@@ -180,7 +218,7 @@
    }
    new Promise(resolve => {
      if (btn.intertype === 'inner' && !btn.innerFunc) {
      if (btn.intertype === 'system') { // 使用系统时,直接从表格或表单中选取数据
        let printcell = {}
        printcell.printType = formdata.printType || ''
@@ -203,7 +241,10 @@
      } else {
        this.getprintdata(btn, data, formdata, formlist).then(result => {
          if (result.next) {
            printlist = result.list.map(cell => {
            result.list.forEach(cell => {
              // 系统打印数据,校验data字段
              if (btn.verify.printMode !== 'custom' && (!cell.data || cell.data.length === 0)) return
              cell.templateID = cell.templateID || btn.verify.Template
              cell.printType = cell.printType || formdata.printType || ''
@@ -216,7 +257,7 @@
              templates.push(cell.templateID)
              return cell
              printlist.push(cell)
            })
          }
          
@@ -261,6 +302,7 @@
      let errorMsg = ''
      let _temps = {}
      let images = []
      result.forEach(res => {
        if (res.status && !errorMsg) {
@@ -274,6 +316,7 @@
              status: false
            }
          } else {
            images = [...images, ..._temp.imgs]
            _temps[res.tempId] = _temp
          }
        } else if (!errorMsg) {
@@ -282,7 +325,38 @@
      })
      if (!errorMsg) {
        this.execPrint(printlist, _temps, formdata)
        if (images.length > 0) {
          let errorUrls = []
          images.forEach(url => {
            let img = new Image()
            img.onerror = () => {
              errorUrls.push(url)
            }
            img.src = url
          })
          setTimeout(() => {
            if (errorUrls.length > 0) {
              notification.warning({
                top: 92,
                message: '模板中图片 ' + errorUrls.join(',') + ' 已失效!',
                duration: 5
              })
              Object.keys(_temps).forEach(key => {
                _temps[key].config.ReportHeader.Control = _temps[key].config.ReportHeader.Control.map(item => {
                  if (item.Type === 'image' && errorUrls.includes(item.Value)) {
                    item.Value = ''
                  }
                  return item
                })
              })
            }
            this.execPrint(printlist, _temps, formdata)
          }, 500)
        } else {
          this.execPrint(printlist, _temps, formdata)
        }
      } else {
        this.execError(errorMsg)
      }
@@ -306,6 +380,177 @@
      // eslint-disable-next-line
      let func = new Function('data', 'form', 'printer', 'notification', btn.verify.printFunc)
      func(printlist, formdata, btn.verify, notification)
      // 自定义打印示例
      // let defaultPrinter = printer.defaultPrinter || 'lackprinter'
      // let printers = {}
      // if (printer.printerTypeList && printer.printerTypeList.length > 0) {
      //   printer.printerTypeList.forEach(cell => {
      //     if (cell.printer) {
      //       printers[cell.Value] = cell.printer
      //     }
      //   })
      // }
      // let jdList = []
      // let otherList = []
      // data.forEach(item => {
      //   if (item.CustomData) {
      //     item.CustomData = JSON.parse(item.CustomData.replace(/\n/g,"\\n").replace(/\r/g,"\\r"))
      //   }
      //   if (item.PrintData) {
      //     item.PrintData = JSON.parse(item.PrintData.replace(/\n/g,"\\n").replace(/\r/g,"\\r"))
      //     item.PrintData.data = {...form, ...item.PrintData.data}
      //   }
      //   if (!item.PrintData) {
      //     return
      //   }
      //   if (item.PrintData.ectype === 'jdpop') {
      //     jdList.push(item)
      //   } else {
      //     otherList.push(item)
      //   }
      // })
      // if (jdList.length === 0 && otherList.length === 0) {
      //   notification.warning({
      //     top: 92,
      //     message: '无打印数据!',
      //     duration: 5
      //   })
      //   return
      // }
      // let execPrint = (list, linkUrl) => {
      //   let printdata = {}
      //   list.forEach(res => {
      //     let _printer = defaultPrinter
      //     if (res.printType && printers[res.printType]) {
      //       _printer = printers[res.printType]
      //     }
      //     printdata[_printer] = printdata[_printer] || []
      //     printdata[_printer].push(res)
      //   })
      //   let printerList = []
      //   Object.keys(printdata).forEach(printer => {
      //     let _documents = []
      //     printdata[printer].forEach(item => {
      //       let _cell = {
      //         documentID: new Date().getTime().toString(),
      //         contents: []
      //       }
      //       if (item.PrintData) {
      //         _cell.contents.push(item.PrintData)
      //       }
      //       if (item.CustomData) {
      //         _cell.contents.push(item.CustomData)
      //       }
      //       for (let i = 0; i < item.printCount; i++) {
      //         _documents.push(_cell)
      //       }
      //     })
      //     printerList.push({
      //       cmd: 'print',
      //       requestID: '',
      //       version: '',
      //       task: {
      //         taskID: new Date().getTime().toString(),
      //         preview: false,
      //         printer: printer,
      //         documents: _documents
      //       }
      //     })
      //   })
      //   let lackItems = printerList.filter(cell => cell.task.printer === 'lackprinter')[0]
      //   let socket = new WebSocket('ws://' + linkUrl)
      //   // 打开Socket
      //   socket.onopen = () =>{
      //     if (lackItems) {
      //       let request  = {
      //         requestID: '',
      //         version: '',
      //         cmd: 'getPrinters'
      //       }
      //       socket.send(JSON.stringify(request))
      //     } else {
      //       printerList.forEach(cell => {
      //         socket.send(JSON.stringify(cell).replace(/\\r/g,"\r").replace(/\\n/g,"\n"))
      //       })
      //       notification.success({
      //         top: 92,
      //         message: '打印请求已发出。',
      //         duration: 2
      //       })
      //     }
      //   }
      //   // 监听消息
      //   socket.onmessage = (event) => {
      //     let data = ''
      //     if (event.data) {
      //       try {
      //         data = JSON.parse(event.data)
      //       } catch (e) {
      //         notification.warning({
      //           top: 92,
      //           message: event.data,
      //           duration: 10
      //         })
      //         data = ''
      //       }
      //     }
      //     if (data && data.cmd === 'getPrinters' && data.status) {
      //       printerList.forEach(cell => {
      //         if (cell.task.printer === 'lackprinter') {
      //           cell.task.printer = data.defaultPrinter
      //         }
      //         socket.send(JSON.stringify(cell).replace(/\\r/g,"\r").replace(/\\n/g,"\n"))
      //       })
      //       notification.success({
      //         top: 92,
      //         message: '打印请求已发出。',
      //         duration: 2
      //       })
      //     } else if (data && data.message && !data.status) {
      //       notification.warning({
      //         top: 92,
      //         message: data.message,
      //         duration: 10
      //       })
      //     }
      //   }
      //   socket.onerror = () => {
      //     notification.warning({
      //       top: 92,
      //       message: '无法连接到:' + linkUrl,
      //       duration: 10
      //     })
      //   }
      // }
      // if (jdList.length > 0) {
      //   execPrint(jdList, '127.0.0.1:13529')
      // }
      // if (otherList.length > 0) {
      //   execPrint(otherList, '127.0.0.1:13528')
      // }
    } catch (e) {
      console.warn(e)
@@ -343,17 +588,21 @@
        let _param = { ...param, ...formdata }
        params.push(_param)
      } else if (btn.Ot === 'requiredSgl') {
        param[setting.primaryKey] = data[0][setting.primaryKey]
        if (setting.primaryKey) {
          param[setting.primaryKey] = data[0][setting.primaryKey]
        }
        let _param = { ...param, ...formdata }
        params.push(_param)
      } else if (btn.Ot === 'requiredOnce') {
        let ids = data.map(d => { return d[setting.primaryKey]})
        ids = ids.filter(Boolean)
        ids = ids.join(',')
        param[setting.primaryKey] = ids
        if (setting.primaryKey) {
          let ids = data.map(d => { return d[setting.primaryKey]})
          ids = ids.filter(Boolean)
          ids = ids.join(',')
          param[setting.primaryKey] = ids
        }
        let _param = { ...param, ...formdata }
@@ -361,7 +610,10 @@
      } else if (btn.Ot === 'required') {
        params = data.map((cell, index) => {
          let _param = { ...param }
          _param[setting.primaryKey] = cell[setting.primaryKey]
          if (setting.primaryKey) {
            _param[setting.primaryKey] = cell[setting.primaryKey]
          }
          formlist.forEach(_data => {
            if (index !== 0 && _data.readin && cell.hasOwnProperty(_data.key)) {
@@ -456,13 +708,21 @@
        if (btn.sysInterface === 'true' && options.cloudServiceApi) {
          res.rduri = options.cloudServiceApi
        } else if (btn.sysInterface !== 'true') {
          res.rduri = btn.interface
          if (window.GLOB.systemType === 'production' && btn.proInterface) {
            res.rduri = btn.proInterface
          } else {
            res.rduri = btn.interface
          }
        }
      } else {
        if (btn.sysInterface === 'true' && window.GLOB.mainSystemApi) {
          res.rduri = window.GLOB.mainSystemApi
        } else if (btn.sysInterface !== 'true') {
          res.rduri = btn.interface
          if (window.GLOB.systemType === 'production' && btn.proInterface) {
            res.rduri = btn.proInterface
          } else {
            res.rduri = btn.interface
          }
        }
      }
@@ -545,6 +805,7 @@
    let _configparam = ''  // 打印配置信息
    let fields = []        // 模板中所需字段
    let nonEFields = []    // 非空字段
    let imgs = []
    if (!res.ConfigParam) {
      error = '未获取到打印模板信息!'
@@ -558,7 +819,6 @@
      if (!configParam) {
        error = '打印模板解析错误!'
      } else {
        let control = configParam.elements.map(element => {
          let _field = element.field
@@ -605,6 +865,12 @@
            item.ImageWidth = element.imgWidth
            item.ImageHeight = element.imgHeight
            item.Trimming = ''
            if (element.productValue && window.GLOB.systemType === 'production') {
              item.Value = element.productValue
              imgs.push(item.Value)
            } else if (item.Value) {
              imgs.push(item.Value)
            }
          } else if (item.Type === 'text') {
            item.FontFamily = element.fontFamily
            item.FontSize = element.fontSize
@@ -665,7 +931,8 @@
      error: error,
      config: _configparam,
      fields: fields,
      nonEFields: nonEFields
      nonEFields: nonEFields,
      imgs: imgs
    }
  }
@@ -700,73 +967,76 @@
    let printerList = []
    Object.keys(printdata).forEach(printer => {
      let _documents = []
      Object.keys(template).forEach(key => {
        let _datalist = printdata[printer].filter(cell => cell.templateID === key)
        if (_datalist.length > 0) {
          let _data = []
          _datalist.forEach(res => {
            res.data.forEach(_cell => {
              for (let i = 0; i < res.printCount; i++) {
                _data.push({...formdata, ..._cell})
              }
            })
          })
          let _fields = Array.from(new Set(template[key].fields))
          let _nonEFields = Array.from(new Set(template[key].nonEFields))
          let lacks = []
          let emptys = []
          _data.forEach(d => {
            _fields.forEach(f => {
              if (!d.hasOwnProperty(f)) {
                lacks.push(f)
              } else if (_nonEFields.includes(f) && !d[f] && d[f] !== 0) {
                emptys.push(f)
              }
            })
        if (_datalist.length === 0) return
        let _data = []
        _datalist.forEach(res => {
          res.data.forEach(_cell => {
            for (let i = 0; i < res.printCount; i++) {
              _data.push({...formdata, ..._cell})
            }
          })
        })
        let _fields = Array.from(new Set(template[key].fields))
        let _nonEFields = Array.from(new Set(template[key].nonEFields))
        let lacks = []
        let emptys = []
        _data.forEach(d => {
          _fields.forEach(f => {
            if (!d.hasOwnProperty(f)) {
              lacks.push(f)
            } else if (_nonEFields.includes(f) && !d[f] && d[f] !== 0) {
              emptys.push(f)
            }
          })
        })
        if (lacks.length > 0 || emptys.length > 0) {
          lacks = Array.from(new Set(lacks))
          emptys = Array.from(new Set(emptys))
          _errors.push({
            title: template[key].config.Title,
            lacks: lacks,
            emptys: emptys
          })
        }
        let results = []
        let num = 100
        for(let i = 0, len = _data.length; i < len; i += num){
          results.push(_data.slice(i, i + num))
        }
        results.forEach(result => {
          let _cell = {
            documentID: Utils.getuuid(),
            contents: [
              {
                data: _data,
                data: result,
                templateURL: JSON.stringify(template[key].config)
              }
            ]
          }
  
          if (lacks.length > 0 || emptys.length > 0) {
            lacks = Array.from(new Set(lacks))
            emptys = Array.from(new Set(emptys))
            _errors.push({
              title: template[key].config.Title,
              lacks: lacks,
              emptys: emptys
            })
          }
          _documents.push(_cell)
        }
      })
      if (_documents.length > 0) {
        printerList.push({
          cmd: 'print',
          requestID: Utils.getuuid(),
          version: Utils.getuuid(),
          task: {
            taskID: Utils.getuuid(),
            preview: false,
            printer: printer,
            documents: _documents
          }
          printerList.push({
            cmd: 'print',
            requestID: Utils.getuuid(),
            version: Utils.getuuid(),
            task: {
              taskID: Utils.getuuid(),
              preview: false,
              printer: printer,
              documents: [_cell]
            }
          })
        })
      }
      })
    })
    if (list.length === 0) {
@@ -821,9 +1091,7 @@
        }
        socket.send(JSON.stringify(request))
      } else {
        printerList.forEach(cell => {
          socket.send(JSON.stringify(cell))
        })
        this.syncMessageSend(printerList)
        this.execSuccess({
          ErrCode: 'S',
@@ -833,6 +1101,7 @@
        })
      }
    }
    // 打开Socket
    socket.onopen = () =>{
      if (lackItems) {
@@ -843,9 +1112,7 @@
        }
        socket.send(JSON.stringify(request))
      } else {
        printerList.forEach(cell => {
          socket.send(JSON.stringify(cell))
        })
        this.syncMessageSend(printerList)
        this.execSuccess({
          ErrCode: 'S',
@@ -862,7 +1129,7 @@
      if (event.data) {
        try {
          data = JSON.parse(event.data)
        } catch {
        } catch (e) {
          this.execError({
            ErrCode: 'N',
            message: event.data,
@@ -875,12 +1142,14 @@
      }
      if (data && data.cmd === 'getPrinters' && data.status) {
        printerList.forEach(cell => {
        printerList = printerList.map(cell => {
          if (cell.task.printer === 'lackprinter') {
            cell.task.printer = data.defaultPrinter
          }
          socket.send(JSON.stringify(cell))
          return cell
        })
        this.syncMessageSend(printerList)
        this.execSuccess({
          ErrCode: 'S',
@@ -905,6 +1174,18 @@
        ErrMesg: '',
        status: false
      })
    }
  }
  syncMessageSend = (list) => {
    let param = list.shift()
    if (socket && param) {
      socket.send(JSON.stringify(param))
    }
    if (list && list.length > 0) {
      setTimeout(() => {this.syncMessageSend(list)}, 3000)
    }
  }
  /**
@@ -936,7 +1217,9 @@
      loading: false
    })
    this.props.updateStatus('refresh', btn.execSuccess)
    if (btn.execSuccess !== 'never') {
      MKEmitter.emit('refreshByButtonResult', btn.$menuId, btn.execSuccess, btn)
    }
  }
  /**
@@ -973,7 +1256,9 @@
      loading: false
    })
    this.props.updateStatus('refresh', btn.execError)
    if (btn.execError !== 'never') {
      MKEmitter.emit('refreshByButtonResult', btn.$menuId, btn.execError, btn)
    }
  }
  /**
@@ -985,6 +1270,29 @@
      message: this.state.dict['main.action.settingerror'],
      duration: 5
    })
  }
  handleModelConfig = (config) => {
    let roleId = sessionStorage.getItem('role_id') || '' // 角色ID
    config.fields = config.fields.map(cell => {
      // 数据源sql语句,预处理,权限黑名单字段设置为隐藏表单
      if (['select', 'link', 'multiselect', 'radio', 'checkbox', 'checkcard'].includes(cell.type) && cell.resourceType === '1') {
        let _option = Utils.getSelectQueryOptions(cell)
        cell.data_sql = Utils.formatOptions(_option.sql)
        cell.base_sql = window.btoa(window.encodeURIComponent(_option.sql))
        cell.arr_field = _option.field
      }
      // 字段权限黑名单
      if (!cell.blacklist || cell.blacklist.length === 0) return cell
      if (cell.blacklist.filter(v => roleId.indexOf(v) > -1).length > 0) {
        cell.hidden = 'true'
      }
      return cell
    })
    return config
  }
  /**
@@ -1003,7 +1311,7 @@
        })
      }
    } else {
      Api.getSystemCacheConfig({
      Api.getCacheConfig({
        func: 'sPC_Get_LongParam',
        MenuID: btn.uuid
      }).then(res => {
@@ -1025,7 +1333,7 @@
            duration: 5
          })
          this.updateStatus('over')
        } else if (!_LongParam || (btn.OpenType === 'pop' && _LongParam.type !== 'Modal')) {
        } else if (!_LongParam || (btn.execMode === 'pop' && _LongParam.type !== 'Modal')) {
          notification.warning({
            top: 92,
            message: '未获取到按钮配置信息!',
@@ -1033,69 +1341,8 @@
          })
          this.updateStatus('over')
        } else {
          if (_LongParam.groups.length > 0) {
            _LongParam.groups.forEach(group => {
              group.sublist = group.sublist.filter(cell => {
                // 数据源sql语句,预处理
                if (['select', 'link', 'multiselect'].includes(cell.type) && cell.resourceType === '1') {
                  let _option = Utils.getSelectQueryOptions(cell)
                  if (this.props.dataManager) { // 数据权限
                    _option.sql = _option.sql.replace(/\$@/ig, '/*')
                    _option.sql = _option.sql.replace(/@\$/ig, '*/')
                  } else {
                    _option.sql = _option.sql.replace(/@\$|\$@/ig, '')
                  }
                  cell.data_sql = Utils.formatOptions(_option.sql)
                  cell.arr_field = _option.field
                }
                // 字段权限黑名单
                if (!cell.blacklist || cell.blacklist.length === 0) return true
                let _black = cell.blacklist.filter(v => {
                  return this.props.permRoles.indexOf(v) !== -1
                })
                if (_black.length > 0) {
                  return false
                } else {
                  return true
                }
              })
            })
          } else {
            _LongParam.fields = _LongParam.fields.filter(cell => {
              // 数据源sql语句,预处理
              if (['select', 'link', 'multiselect'].includes(cell.type) && cell.resourceType === '1') {
                let _option = Utils.getSelectQueryOptions(cell)
                if (this.props.dataManager) { // 数据权限
                  _option.sql = _option.sql.replace(/\$@/ig, '/*')
                  _option.sql = _option.sql.replace(/@\$/ig, '*/')
                } else {
                  _option.sql = _option.sql.replace(/@\$|\$@/ig, '')
                }
                cell.data_sql = Utils.formatOptions(_option.sql)
                cell.arr_field = _option.field
              }
              // 字段权限黑名单
              if (!cell.blacklist || cell.blacklist.length === 0) return true
              let _black = cell.blacklist.filter(v => {
                return this.props.permRoles.indexOf(v) !== -1
              })
              if (_black.length > 0) {
                return false
              } else {
                return true
              }
            })
          }
          _LongParam = updateForm(_LongParam)
          _LongParam = this.handleModelConfig(_LongParam)
          this.setState({
            btnconfig: _LongParam
@@ -1139,17 +1386,10 @@
    const { BData } = this.props
    const { btnconfig, tabledata } = this.state
    let _this = this
    let _fields = []
    let result = []
    
    if (btnconfig.groups.length > 0) {
      btnconfig.groups.forEach(group => {
        _fields = [..._fields, ...group.sublist]
      })
    } else {
      _fields = btnconfig.fields
    }
    let result = _fields.map(item => {
    btnconfig.fields.forEach(item => {
      if (!item.field) return
      let _readin = item.readin !== 'false'
      let _initval = item.initval
@@ -1176,14 +1416,18 @@
        _fieldlen = item.decimal ? item.decimal : 0
      }
      return {
      if (_initval === undefined) {
        _initval = ''
      }
      result.push({
        key: item.field,
        readonly: item.readonly === 'true',
        readin: _readin,
        fieldlen: _fieldlen,
        type: item.type,
        value: _initval
      }
      })
    })
    confirm({
@@ -1201,7 +1445,7 @@
   * @description 显示模态框
   */
  getModels = () => {
    const { setting, BID } = this.props
    const { setting, BID, btn } = this.props
    const { btnconfig } = this.state
    if (!this.state.visible || !btnconfig || !btnconfig.setting) return null
@@ -1211,9 +1455,12 @@
    let clickouter = false
    let container = document.body
    if (setting.tabType === 'main' && btnconfig.setting.container === 'tab' && this.props.ContainerId) {
    if (
      (setting.tabType === 'main' && btnconfig.setting.container === 'tab' && this.props.ContainerId) ||
      (btnconfig.setting.container === 'tab' && btn.ContainerId)
    ) {
      width = btnconfig.setting.width + '%'
      container = () => document.getElementById(this.props.ContainerId)
      container = () => document.getElementById(this.props.ContainerId || btn.ContainerId)
    }
    if (btnconfig.setting.clickouter === 'close') {
@@ -1248,31 +1495,56 @@
  render() {
    const { btn, show } = this.props
    const { loadingNumber, loading } = this.state
    const { loadingNumber, loading, disabled } = this.state
    return (
      <div className="mk-btn-wrap">
        {!show ? <Button
          className={'mk-btn mk-' + btn.class}
    if (show === 'actionList') {
      return <div style={{display: 'inline-block'}} onClick={(e) => e.stopPropagation()}>
        <Button
          icon={btn.icon}
          onClick={() => {this.actionTrigger()}}
          loading={loading}
        >{loadingNumber ? `(${loadingNumber})` : '' + btn.label}</Button> : null}
        {show === 'icon' ? <Button className="action-cell" icon={btn.icon || 'dash'} loading={loading} onClick={() => {this.actionTrigger()}}></Button> : null}
        {show === 'text' ? <Button className="action-cell" loading={loading} onClick={() => {this.actionTrigger()}}>{btn.label}</Button> : null}
        {show === 'all' ? <Button className="action-cell" icon={btn.icon || ''} loading={loading} onClick={() => {this.actionTrigger()}}>{btn.label}</Button> : null}
          disabled={disabled}
          className={'mk-btn mk-' + btn.class}
          onClick={() => {this.actionTrigger()}}
        >{loadingNumber ? `(${loadingNumber})` : '' + btn.label}</Button>
        {this.getModels()}
      </div>
    )
    } else { // icon、text、 all 卡片
      let label = ''
      let icon = ''
      if (show === 'button') {
        label = btn.label
        icon = btn.icon || ''
      } else if (show === 'link') {
        label = <span>{btn.label}{btn.icon ? <Icon style={{marginLeft: '8px'}} type={btn.icon}/> : ''}</span>
        icon = ''
      } else if (show === 'icon') {
        icon = btn.icon || ''
      // } else if (show === 'text') {
      } else {
        label = btn.label
      }
      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}
          icon={icon}
          onClick={() => {this.actionTrigger()}}
        >{label}</Button>
        {this.getModels()}
      </div>
    }
  }
}
const mapStateToProps = (state) => {
  return {
    tabviews: state.tabviews,
    menuType: state.editLevel,
    permRoles: state.permRoles,
    dataManager: state.dataManager
    menuType: state.editLevel
  }
}