king
2024-04-29 f9816a4078fdba44115c69025d9982997f23b484
src/tabviews/zshare/actionList/newpagebutton/index.jsx
@@ -16,6 +16,7 @@
    btn: PropTypes.object,            // 按钮
    selectedData: PropTypes.any,      // 子表中选择数据
    disabled: PropTypes.any,          // 行按钮禁用
    name: PropTypes.any
  }
  state = {
@@ -159,18 +160,75 @@
    if (btn.pageTemplate === 'billprint') {
      _name = '单据打印'
      if (btn.Ot === 'required') {
        data.forEach(item => {
          let _id = item.$$uuid || ''
          let url = '#/billprint/' + window.btoa(window.encodeURIComponent(JSON.stringify({ id: _id, tempId: btn.printTemp, pageId: btn.$MenuID || '', dataM: sessionStorage.getItem('dataM') })))
          window.open(url)
        })
      } else if (btn.Ot === 'requiredOnce') {
        Id = data.map(item => item.$$uuid).filter(Boolean).join(',')
      if (btn.preHandle === 'true' && btn.pre_func) {
        MKEmitter.emit('queryModuleParam', btn.$menuId, (res) => {
          let searches = {}
          res.search && res.search.forEach(item => {
            searches[item.key] = item.value
          })
        window.open('#/billprint/' + window.btoa(window.encodeURIComponent(JSON.stringify({ id: Id, tempId: btn.printTemp, pageId: btn.$MenuID || '', dataM: sessionStorage.getItem('dataM') }))))
          if (btn.Ot === 'requiredOnce') {
            Id = data.map(item => item.$$uuid).filter(Boolean).join(',')
          }
          if (btn.Ot === 'required') {
            data.forEach(item => {
              let _param = { id: item.$$uuid || '', tempId: btn.printTemp, pageId: btn.$MenuID || '', dataM: sessionStorage.getItem('dataM')}
              try {
                // eslint-disable-next-line
                let func = new Function('btn', 'searches', 'data', 'param', 'systemType', btn.pre_func)
                _param = func(btn, searches, [item], _param, window.GLOB.systemType)
              } catch (e) {
                console.warn(e)
              }
              if (!_param || _param.error) {
                notification.warning({
                  top: 92,
                  message: _param ? _param.error : '未获取到打印参数,自定义脚本错误!',
                  duration: 5
                })
                return
              }
              window.open('#/billprint/' + window.btoa(window.encodeURIComponent(JSON.stringify(_param))))
            })
          } else {
            let _param = { id: Id, tempId: btn.printTemp, pageId: btn.$MenuID || '', dataM: sessionStorage.getItem('dataM')}
            try {
              // eslint-disable-next-line
              let func = new Function('btn', 'searches', 'data', 'param', 'systemType', btn.pre_func)
              _param = func(btn, searches, data, _param, window.GLOB.systemType)
            } catch (e) {
              console.warn(e)
            }
            if (!_param || _param.error) {
              notification.warning({
                top: 92,
                message: _param ? _param.error : '未获取到打印参数,自定义脚本错误!',
                duration: 5
              })
              return
            }
            window.open('#/billprint/' + window.btoa(window.encodeURIComponent(JSON.stringify(_param))))
          }
        })
      } else {
        window.open('#/billprint/' + window.btoa(window.encodeURIComponent(JSON.stringify({ id: Id, tempId: btn.printTemp, pageId: btn.$MenuID || '', dataM: sessionStorage.getItem('dataM') }))))
        if (btn.Ot === 'required') {
          data.forEach(item => {
            let _id = item.$$uuid || ''
            let url = '#/billprint/' + window.btoa(window.encodeURIComponent(JSON.stringify({ id: _id, tempId: btn.printTemp, pageId: btn.$MenuID || '', dataM: sessionStorage.getItem('dataM') })))
            window.open(url)
          })
        } else if (btn.Ot === 'requiredOnce') {
          Id = data.map(item => item.$$uuid).filter(Boolean).join(',')
          window.open('#/billprint/' + window.btoa(window.encodeURIComponent(JSON.stringify({ id: Id, tempId: btn.printTemp, pageId: btn.$MenuID || '', dataM: sessionStorage.getItem('dataM') }))))
        } else {
          window.open('#/billprint/' + window.btoa(window.encodeURIComponent(JSON.stringify({ id: Id, tempId: btn.printTemp, pageId: btn.$MenuID || '', dataM: sessionStorage.getItem('dataM') }))))
        }
      }
    } else if (btn.pageTemplate === 'billprintTemp') {
      let src = '#/menudesign/' + window.btoa(window.encodeURIComponent(JSON.stringify({ MenuType: 'billPrint', MenuId: Id, MenuNo: MenuNo, MenuName: name || '打印', Remark: Remark })))
@@ -250,44 +308,29 @@
  }
  render() {
    const { btn } = this.props
    const { btn, name } = this.props
    const { disabled, hidden } = this.state
    if (hidden) return null
    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
      label = <MkIcon type={btn.icon} />
    } else {
      type = ''
      icon = btn.icon || ''
      label = btn.label
      className = 'mk-btn mk-' + btn.class
      label = <span>{btn.icon ? <MkIcon style={{marginRight: '8px'}} type={btn.icon} /> : ''}{name || btn.label}</span>
    }
    return (
      <Button
        type={type}
        type="link"
        id={'button' + btn.uuid}
        title={disabled ? (btn.reason || '') : (btn.show === 'icon' ? btn.label : '')}
        style={btn.style || null}
        disabled={disabled}
        icon={icon}
        className={className}
        className={btn.$toolbtn ? (btn.hover || '') : ''}
        onClick={(e) => {e.stopPropagation(); this.actionTrigger()}}
      >{label}</Button>
    )