king
2021-08-01 55a1b8402fd258da084df9b8a3935eef8450247c
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 } from 'antd'
import { Button, Modal, notification, message, Drawer, Icon } from 'antd'
import Api from '@/api'
import Utils, { getSysDefaultSql } from '@/utils/utils.js'
@@ -70,9 +70,8 @@
  componentDidMount () {
    const { position } = this.props
    if (position === 'toolbar') {
      MKEmitter.addListener('triggerBtnId', this.actionTrigger)
    } else if (position === 'form') {
    MKEmitter.addListener('triggerBtnId', this.actionTrigger)
    if (position === 'form') {
      MKEmitter.addListener('triggerFormSubmit', this.actionSubmit)
    }
    MKEmitter.addListener('returnModuleParam', this.resetModuleParam)
@@ -156,6 +155,11 @@
        message: '需要上级主键值!',
        duration: 5
      })
      return
    }
    if (btn.$syncModule && !triggerId) {
      MKEmitter.emit('getSyncData', btn.$syncModule, btn.uuid)
      return
    }
@@ -866,7 +870,7 @@
    })
    Api.directRequest(url, btn.method, param, btn.cross).then(res => {
      if (typeof(res) !== 'object' || Array.isArray(res)) {
      if (typeof(res) !== 'object') {
        let error = '未知的返回结果!'
        if (typeof(res) === 'string') {
@@ -881,6 +885,9 @@
        this.customCallbackRequest(params, result, record, _resolve)
      } else {
        if (Array.isArray(res)) {
          res = { data: res }
        }
        res.mk_api_key = mkey
        this.customCallbackRequest(params, res, record, _resolve)
      }
@@ -1691,51 +1698,87 @@
    let title = btnconfig.setting.title
    let width = btnconfig.setting.width + 'vw'
    let clickouter = false
    let container = document.body
    let clickouter = btnconfig.setting.clickouter === 'close'
    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 || btn.ContainerId)
    if (btnconfig.setting.display === 'drawer') {
      let height = '100vh'
      if (btnconfig.setting.placement === 'top' || btnconfig.setting.placement === 'bottom') {
        width = '100vw'
        height = btnconfig.setting.width + 'vh'
      }
      return (
        <Drawer
          title={title}
          width={width}
          height={height}
          maskClosable={clickouter}
          onClose={this.handleCancel}
          visible={visible}
          placement={btnconfig.setting.placement || 'right'}
          bodyStyle={{ paddingBottom: 80 }}
          destroyOnClose
        >
          <MutilForm
            BID={BID}
            dict={this.state.dict}
            menuType={this.props.menuType}
            action={btnconfig}
            inputSubmit={this.handleOk}
            data={this.state.tabledata[0]}
            BData={this.props.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'}}>
            <Button onClick={this.handleCancel} style={{ marginRight: 8 }}>
              取消
            </Button>
            <Button onClick={this.handleOk} loading={this.state.confirmLoading} type="primary">
              确定
            </Button>
          </div>
        </Drawer>
      )
    } else {
      let container = document.body
      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 || btn.ContainerId)
      }
      return (
        <Modal
          title={title}
          maskClosable={clickouter}
          getContainer={container}
          wrapClassName='action-modal'
          visible={visible}
          width={width}
          onOk={this.handleOk}
          confirmLoading={this.state.confirmLoading}
          onCancel={this.handleCancel}
          destroyOnClose
        >
          <MutilForm
            BID={BID}
            dict={this.state.dict}
            menuType={this.props.menuType}
            action={btnconfig}
            inputSubmit={this.handleOk}
            data={this.state.tabledata[0]}
            BData={this.props.BData}
            wrappedComponentRef={(inst) => this.formRef = inst}
          />
        </Modal>
      )
    }
    if (btnconfig.setting.clickouter === 'close') {
      clickouter = true
    }
    return (
      <Modal
        title={title}
        maskClosable={clickouter}
        getContainer={container}
        wrapClassName='action-modal'
        visible={visible}
        width={width}
        onOk={this.handleOk}
        confirmLoading={this.state.confirmLoading}
        onCancel={this.handleCancel}
        destroyOnClose
      >
        <MutilForm
          BID={BID}
          dict={this.state.dict}
          menuType={this.props.menuType}
          action={btnconfig}
          inputSubmit={this.handleOk}
          data={this.state.tabledata[0]}
          BData={this.props.BData}
          wrappedComponentRef={(inst) => this.formRef = inst}
        />
      </Modal>
    )
  }
  render() {
    const { btn, show, style } = this.props
    const { loadingNumber, loading, visible, disabled } = this.state
    const { loadingNumber, loading, disabled } = this.state
    if (show === 'actionList') {
      return <div style={{display: 'inline-block'}} onClick={(e) => e.stopPropagation()}>
@@ -1747,7 +1790,7 @@
          className={'mk-btn mk-' + btn.class}
          onClick={() => {this.actionTrigger()}}
        >{(loadingNumber ? `(${loadingNumber})` : '') + btn.label}</Button>
        {visible ? this.getModels() : null}
        {this.getModels()}
      </div>
    } else if (show && show.indexOf('plus') > -1) {
      return <div className="mk-btn-wrap">
@@ -1758,9 +1801,25 @@
          style={{fontSize: show.substring(4) + 'px'}}
          onClick={() => {this.actionTrigger()}}
        ></Button>
        {visible ? this.getModels() : null}
        {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 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"
@@ -1768,10 +1827,10 @@
          loading={loading}
          disabled={disabled}
          style={btn.style || style}
          icon={show === 'text' ? '' : (btn.icon || '')}
          icon={icon}
          onClick={() => {this.actionTrigger()}}
        >{show === 'icon' && btn.icon ? '' : btn.label}</Button>
        {visible ? this.getModels() : null}
        >{label}</Button>
        {this.getModels()}
      </div>
    }
  }