king
2024-05-16 b69b5f6329ca5f87932436b7a6c1ddfc3377e10f
src/tabviews/zshare/actionList/normalbutton/index.jsx
@@ -28,6 +28,7 @@
    columns: PropTypes.any,           // 字段列
    setting: PropTypes.any,           // 页面通用设置
    disabled: PropTypes.any,          // 行按钮禁用
    name: PropTypes.any
  }
  state = {
@@ -203,8 +204,8 @@
  /**
   * @description 触发按钮操作
   */
  actionTrigger = (triggerId, record, type, callback) => {
    const { btn, selectedData } = this.props
  actionTrigger = (triggerId, record, type, lid, callback) => {
    const { btn, selectedData, LID } = this.props
    const { loading, disabled } = this.state
    if (type === 'preButton') {
@@ -218,7 +219,7 @@
    if (loading || disabled) return
    if (triggerId && btn.uuid !== triggerId) return
    if (type === 'linkbtn' && !btn.$toolbtn && !is(fromJS(selectedData || []), fromJS(record))) return
    if (type === 'linkbtn' && !btn.$toolbtn && LID !== lid) return
    if (btn.OpenType === 'form' && btn.formType === 'count_line') return
    this.setState({autoMatic: type === 'autoMatic'})
@@ -755,6 +756,9 @@
        param.username = sessionStorage.getItem('User_Name') || ''
        param.fullname = sessionStorage.getItem('Full_Name') || ''
      }
      if (btn.dataM === 'true') {
        param.dataM = sessionStorage.getItem('dataM') === 'true' ? 'Y' : ''
      }
      
      let primaryId = ''
@@ -796,6 +800,9 @@
        if (btn.recordUser === 'true') {
          param.username = sessionStorage.getItem('User_Name') || ''
          param.fullname = sessionStorage.getItem('Full_Name') || ''
        }
        if (btn.dataM === 'true') {
          param.dataM = sessionStorage.getItem('dataM') === 'true' ? 'Y' : ''
        }
        let primaryId = setting.primaryKey ? cell[setting.primaryKey] || '' : ''
@@ -1086,7 +1093,7 @@
    let node = document.getElementById('button' + btnId)
    if (node) {
      MKEmitter.emit('triggerBtnId', btnId, null, 'preButton', (res) => {
      MKEmitter.emit('triggerBtnId', btnId, null, 'preButton', null, (res) => {
        if (!res) {
          this.setState({loading: false})
          resolve()
@@ -1631,11 +1638,12 @@
      })
      keys = keys.join(',')
      vals = vals.join(',')
      lines.push({
        table: md5(tb + keys),
        insert: `Insert into ${tbName} (${keys},[mk_level],[mk_id],[mk_bid])`,
        select: `Select ${vals.join(',')},'${level}','${id}','${bid}'`
        insert: `Insert into ${tbName} (${keys ? keys + ',' : ''}[mk_level],[mk_id],[mk_bid])`,
        select: `Select ${keys ? vals + ',' : ''}'${level}','${id}','${bid}'`
      })
      subObjs.forEach(item => {
@@ -1721,9 +1729,9 @@
      sql = sql.replace(/@typename@/ig, `'admin'`)
      if (sessionStorage.getItem('dataM') === 'true') { // 数据权限
        sql = sql.replace(/\$@/ig, '/*').replace(/@\$/ig, '*/').replace(/@datam@/ig, '\'Y\'')
        sql = sql.replace(/\$@/ig, '/*').replace(/@\$/ig, '*/').replace(/@datam@/ig, `'Y'`)
      } else {
        sql = sql.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, '\'\'')
        sql = sql.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, `''`)
      }
      if (window.GLOB.debugger === true) {
@@ -2344,9 +2352,9 @@
      tabId = btn.refreshTab[btn.refreshTab.length - 1]
    }
    if (btn.formCache === 'clear') { // 清除表单缓存
      window.GLOB.CacheMap = new Map()
    }
    // if (btn.formCache === 'clear') { // 清除表单缓存
    //   window.GLOB.CacheMap = new Map()
    // }
    if (tabId && btn.$MenuID === tabId) { // 刷新当前菜单时,停止其他操作
      MKEmitter.emit('reloadMenuView', tabId, 'table')
@@ -2428,6 +2436,24 @@
    if (btn.execSuccess === 'popclose' && btn.$tabId) { // 标签关闭刷新
      MKEmitter.emit('refreshPopButton', btn.$tabId)
    }
    if (btn.verify && btn.verify.linkEnable === 'true') {
      let url = ''
      if (window.GLOB.systemType === 'production') {
        url = btn.verify.linkProUrl
        if (!url) {
          notification.warning({
            top: 92,
            message: '尚未添加正式系统链接地址!',
            duration: 5
          })
          return
        }
      } else {
        url = btn.verify.linkUrl
      }
      window.open(url)
    }
  }
  triggerNote = (res, ID) => {
@@ -2474,9 +2500,38 @@
    if (!id) return
    setTimeout(() => {
      window.open('#/billprint/' + window.btoa(window.encodeURIComponent(JSON.stringify({ id: id, tempId: btn.verify.printTempId, pageId: btn.$MenuID || '', dataM: sessionStorage.getItem('dataM') }))))
    }, 500)
    if (btn.verify.preHandle === 'true' && btn.verify.pre_func && /#position-print/.test(btn.verify.pre_func)) {
      MKEmitter.emit('queryModuleParam', btn.$menuId, (res) => {
        let searches = {}
        res.search && res.search.forEach(item => {
          searches[item.key] = item.value
        })
        let _param = { id: id || '', tempId: btn.verify.printTempId, pageId: btn.$MenuID || '', dataM: sessionStorage.getItem('dataM')}
        try {
          // eslint-disable-next-line
          let func = new Function('btn', 'searches', 'param', 'systemType', btn.verify.pre_func)
          _param = func(btn, searches, _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 {
      setTimeout(() => {
        window.open('#/billprint/' + window.btoa(window.encodeURIComponent(JSON.stringify({ id: id, tempId: btn.verify.printTempId, pageId: btn.$MenuID || '', dataM: sessionStorage.getItem('dataM') }))))
      }, 200)
    }
  }
  sendWxMessage = (verify, id) => {
@@ -3169,7 +3224,7 @@
  }
  modelconfirm = () => {
    const { btn, BID } = this.props
    const { BID } = this.props
    const { btnconfig, selines } = this.state
    let _this = this
@@ -3254,6 +3309,20 @@
              console.warn(e)
              _item.value = ''
            }
          } else if (item.interception === 'charTure') {
            let str = _item.value.replace(/(^\s*|\s*$)/g, '')
            let result = ''
            for (let i = 0 ; i < str.length; i++) {
              let code = str.charCodeAt(i)
              if (code >= 65281 && code <= 65373) {
                result += String.fromCharCode(str.charCodeAt(i) - 65248)
              } else if (code === 12288) {
                result += String.fromCharCode(str.charCodeAt(i) - 12288 + 32)
              } else {
                result += str.charAt(i)
              }
            }
            _item.value = result
          } else {
            _item.value = _item.value.replace(/(^\s*|\s*$)/g, '')
          }
@@ -3300,7 +3369,7 @@
      this.execSubmit(selines, () => {}, result)
    } else {
      confirm({
        title: btn.tipTitle || '确定要执行吗?',
        title: btnconfig.setting.tipTitle || '确定要执行吗?',
        onOk() {
          return new Promise(resolve => {
            _this.execSubmit(selines, resolve, result)
@@ -3480,7 +3549,7 @@
  }
  render() {
    const { btn } = this.props
    const { btn, name } = this.props
    const { loadingNumber, loadingTotal, loading, disabled, hidden, check, count } = this.state
    if (hidden) return null
@@ -3499,42 +3568,25 @@
    }
    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 = ''
    if (btn.show === 'link') {
      label = <span>{name || btn.label}{btn.icon ? <MkIcon style={{marginLeft: '8px'}} type={btn.icon} /> : ''}</span>
    } else if (btn.show === 'icon') {
      icon = btn.icon || ''
    } else if (!btn.$toolbtn) {
      icon = btn.icon || ''
      label = btn.label
      className = 'mk-btn mk-' + (btn.class || 'unset')
      label = !loading ? <MkIcon type={btn.icon} /> : null
    } else if (btn.$toolbtn) {
      label = <span>{!loading && btn.icon ? <MkIcon style={{marginRight: '8px'}} type={btn.icon} /> : ''}{loadingNumber && !loadingTotal ? `(${loadingNumber})` : ''}{btn.label}</span>
    } else {
      type = ''
      icon = btn.icon || ''
      label = btn.label
      className = 'mk-btn mk-' + (btn.class || 'unset')
    }
    if (loadingNumber && btn.progress !== 'progressbar' && btn.$toolbtn && (!btn.show || btn.show === 'button')) {
      label = (loadingNumber ? `(${loadingNumber})` : '') + btn.label
      label = <span>{!loading && btn.icon ? <MkIcon style={{marginRight: '8px'}} type={btn.icon} /> : ''}{name || btn.label}</span>
    }
    let BTN = <Button
      type={type}
      icon={icon}
      type="link"
      id={'button' + btn.uuid}
      title={disabled ? (btn.reason || '') : (btn.show === 'icon' ? btn.label : '')}
      loading={loading}
      disabled={disabled}
      style={btn.style}
      className={className}
      className={btn.hover || ''}
      onClick={(e) => {e.stopPropagation(); this.actionTrigger()}}
    >{label}</Button>