king
2024-04-23 59002c8182d10c21a1becdff4e566ee11cd1cd91
src/menu/components/module/invoice/index.jsx
@@ -1,7 +1,7 @@
import React, {Component} from 'react'
import PropTypes from 'prop-types'
import { is, fromJS } from 'immutable'
import { Popover, Button } from 'antd'
import { Popover, Button, Modal } from 'antd'
import { EditOutlined, ToolOutlined, DeleteOutlined, FontColorsOutlined, EllipsisOutlined, SettingOutlined } from '@ant-design/icons'
import moment from 'moment'
@@ -9,6 +9,7 @@
import asyncIconComponent from '@/utils/asyncIconComponent'
import { getTables, checkComponent } from '@/utils/utils-custom.js'
import MKEmitter from '@/utils/events.js'
import VerifyCard from './verifycard'
import getWrapForm from './options'
import './index.scss'
@@ -25,7 +26,8 @@
  state = {
    card: null,
    date: moment().format('YYYY年MM月')
    date: moment().format('YYYY年MM月'),
    btn: null
  }
  UNSAFE_componentWillMount () {
@@ -69,7 +71,9 @@
            {field: 'productname', label: '商品名称', initval: '', type: 'text', match: 'like', uuid: Utils.getuuid()},
            {field: 'productcode', label: '商品编码', initval: '', type: 'text', match: 'like', uuid: Utils.getuuid()},
          ],
        }
        },
        billSaveBtn: {type: 'billsave', intertype: 'system', label: '保存单据'},
        billOutBtn: {type: 'billout', intertype: 'custom', label: '提交开票', procMode: 'system'},
      }
      let buys = [
@@ -149,8 +153,8 @@
    } else {
      let _card = fromJS(card).toJS()
      // _card.buyer.format = 'array'
      // _card.detail.format = 'array'
      // _card.billSaveBtn = _card.billSaveBtn || {type: 'billsave', intertype: 'system', label: '保存单据'}
      // _card.billOutBtn = _card.billOutBtn || {type: 'billout', intertype: 'custom', label: '提交开票', procMode: 'system'}
      this.setState({
        card: _card
@@ -205,6 +209,14 @@
      }
    }
    if (!card.billSaveBtn.scripts || card.billSaveBtn.scripts.length === 0) {
      card.errors.push({ level: 0, detail: '未添加单据保存脚本!'})
    // } else if (!card.billOutBtn.scripts || card.billOutBtn.scripts.length === 0) {
    //   card.errors.push({ level: 0, detail: '未添加提交开票前置脚本!'})
    // } else if (card.billSaveBtn.cbScripts.length === 0) {
    //   card.errors.push({ level: 0, detail: '未添加提交开票回调脚本!'})
    }
    if (card.errors.length === 0) {
      card.$tables = getTables(card)
      card.$tables = [...card.$tables, ...getTables(card.buyer)]
@@ -240,8 +252,20 @@
    this.updateComponent({...this.state.card, wrap: res})
  }
  verifySubmit = () => {
    this.verifyRef.handleConfirm().then(res => {
      if (res.type === 'billout') {
        this.updateComponent({...this.state.card, billOutBtn: res})
      } else {
        this.updateComponent({...this.state.card, billSaveBtn: res})
      }
      this.setState({ btn: null })
    })
  }
  render() {
    const { card, date } = this.state
    const { card, date, btn } = this.state
    let style = {...card.style}
    if (card.wrap.invColor) {
@@ -263,8 +287,20 @@
          <ToolOutlined />
        </Popover>
        <div className="inv-action">
          <Button className="mk-bill">保存单据</Button>
          <Button className="mk-submit">提交开票</Button>
          <Popover overlayClassName="mk-popover-control-wrap" mouseLeaveDelay={0.2} mouseEnterDelay={0.2} content={
            <div className="mk-popover-control">
              <EditOutlined style={{color: '#1890ff'}} onClick={() => this.setState({btn: card.billSaveBtn})} title="编辑"/>
            </div>
          } trigger="hover">
            <Button className="mk-bill">保存单据</Button>
          </Popover>
          <Popover overlayClassName="mk-popover-control-wrap" mouseLeaveDelay={0.2} mouseEnterDelay={0.2} content={
            <div className="mk-popover-control">
              <EditOutlined style={{color: '#1890ff'}} onClick={() => this.setState({btn: card.billOutBtn})} title="编辑"/>
            </div>
          } trigger="hover">
            <Button className="mk-submit">提交开票</Button>
          </Popover>
        </div>
        <div className="inv-header">
          <div className="mk-select">请选择发票种类</div>
@@ -413,6 +449,26 @@
            <span className="content">开票人</span>
          </div>
        </div>
        <Modal
          wrapClassName="mk-pop-modal"
          visible={btn !== null}
          width={'90vw'}
          maskClosable={false}
          okText="提交"
          onOk={this.verifySubmit}
          onCancel={() => {
            if (this.verifyRef.handleCancel) {
              this.verifyRef.handleCancel().then(() => {
                this.setState({ btn: null })
              })
            } else {
              this.setState({ btn: null })
            }
          }}
          destroyOnClose
        >
          <VerifyCard card={btn} wrappedComponentRef={(inst) => this.verifyRef = inst}/>
        </Modal>
      </div>
    )
  }