| | |
| | | import React, {Component} from 'react' |
| | | import PropTypes from 'prop-types' |
| | | import { is, fromJS } from 'immutable' |
| | | import { Popover, Button } from 'antd' |
| | | import { EditOutlined, ToolOutlined, DeleteOutlined, FontColorsOutlined, EllipsisOutlined, SettingOutlined } from '@ant-design/icons' |
| | | import { Popover, Button, Modal } from 'antd' |
| | | import { EditOutlined, ToolOutlined, DeleteOutlined, LeftOutlined, FontColorsOutlined, EllipsisOutlined, SettingOutlined } from '@ant-design/icons' |
| | | import moment from 'moment' |
| | | |
| | | import Utils from '@/utils/utils.js' |
| | | 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' |
| | |
| | | |
| | | state = { |
| | | card: null, |
| | | date: moment().format('YYYY年MM月') |
| | | date: moment().format('YYYY年MM月'), |
| | | btn: null |
| | | } |
| | | |
| | | UNSAFE_componentWillMount () { |
| | |
| | | let _card = { |
| | | uuid: card.uuid, |
| | | type: card.type, |
| | | format: 'object', // 组件属性 - 数据格式 |
| | | format: 'array', // 组件属性 - 数据格式 |
| | | pageable: false, // 组件属性 - 是否可分页 |
| | | switchable: false, // 组件属性 - 数据是否可切换 |
| | | width: card.width || 24, |
| | | name: '发票', |
| | | subtype: card.subtype, |
| | | fixedCol: true, |
| | | wrap: { name: '发票', width: card.width || 24, datatype: 'static' }, |
| | | style: { paddingLeft: '20px', paddingRight: '20px', paddingTop: '10px', paddingBottom: '10px' }, |
| | | setting: { interType: 'system' }, |
| | | setting: { interType: 'system', primaryKey: 'ID' }, |
| | | columns: [], |
| | | scripts: [], |
| | | buyer: { |
| | | pageable: true, |
| | | format: 'array', |
| | | fixedCol: true, |
| | | subtype: 'invTable', |
| | | setting: { interType: 'system' }, |
| | | columns: [], |
| | |
| | | detail: { |
| | | pageable: true, |
| | | format: 'array', |
| | | fixedCol: true, |
| | | subtype: 'invTable', |
| | | setting: { interType: 'system' }, |
| | | columns: [], |
| | |
| | | {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', parId: card.uuid, intertype: 'system', label: '保存单据'}, |
| | | billOutBtn: {type: 'billout', parId: card.uuid, intertype: 'custom', label: '提交开票', procMode: 'system'}, |
| | | } |
| | | |
| | | let buys = [ |
| | |
| | | ['单价', 'unitprice', 'Decimal(18,10)'], |
| | | ['税务分类编码', 'tax_classify_code'], |
| | | ['税务分类名称', 'tax_classify_name'], |
| | | // ['税率', 'tax_rate', 'Decimal(18,2)'], |
| | | ['一般纳税人税率', 'general_tax_rate', 'Decimal(18,2)'], |
| | | ['小规模纳税人征收率', 'small_tax_rate', 'Decimal(18,2)'], |
| | | ['是否享受优惠政策', 'free_tax_mark'], |
| | | ['优惠政策类型', 'vat_special_management'], |
| | | ['征税项目', 'tax_item'], |
| | | ['计税方法', 'tax_method'], |
| | | ] |
| | | |
| | | details.forEach((cell, index) => { |
| | |
| | | }) |
| | | |
| | | let cols = [ |
| | | ['ID', 'ID'], |
| | | ['开票申请单号', 'io'], |
| | | ['发票种类', 'invoice_type'], |
| | | ['开票类型', 'business_type', 'Nvarchar(20)'], |
| | | ['购买方名称', 'from_to_name'], |
| | | ['购买方税号', 'from_to_tax_no'], |
| | | ['购买方地址', 'from_to_addr', 'Nvarchar(100)'], |
| | |
| | | ['收款人', 'payee'], |
| | | ['复核人', 'reviewer'], |
| | | ['开票人', 'drawer'], |
| | | ['jskey', 'jskey'], |
| | | ['行号', 'invoice_lp'], |
| | | ['商品编码', 'productcode'], |
| | | ['商品名称', 'productname'], |
| | | ['规格型号', 'spec'], |
| | |
| | | ['税务分类名称', 'tax_classify_name'], |
| | | ['税率', 'tax_rate', 'Decimal(18,2)'], |
| | | ['税额', 'tax_amount', 'Decimal(18,2)'], |
| | | ['是否享受优惠政策', 'free_tax_mark'], |
| | | ['优惠政策类型', 'vat_special_management'], |
| | | ['征税项目', 'tax_item'], |
| | | ['计税方法', 'tax_method'], |
| | | ['发票号码', 'invoice_no'], |
| | | ['发票代码', 'invoice_code'], |
| | | ['开票日期', 'invoice_date'], |
| | | ['只读(true)', 'read_only'], |
| | | ] |
| | | |
| | | cols.forEach((cell, index) => { |
| | |
| | | this.updateComponent(_card) |
| | | } else { |
| | | let _card = fromJS(card).toJS() |
| | | |
| | | // _card.buyer.format = 'array' |
| | | // _card.detail.format = 'array' |
| | | |
| | | this.setState({ |
| | | card: _card |
| | |
| | | card.$c_ds = card.wrap.datatype === 'dynamic' |
| | | card.errors = checkComponent(card) |
| | | |
| | | delete card.$c_ds |
| | | |
| | | if (card.errors.length === 0) { |
| | | if (card.buyer.setting.interType === 'system' && card.buyer.setting.execute !== 'false' && !card.buyer.setting.dataresource) { |
| | | card.errors.push({ level: 0, detail: '-购买方 未设置数据源!'}) |
| | |
| | | } else if (card.detail.setting.interType === 'system' && card.detail.setting.execute === 'false' && card.detail.scripts.filter(script => script.status !== 'false').length === 0) { |
| | | card.errors.push({ level: 0, detail: '-明细 数据源中无可用脚本!'}) |
| | | } |
| | | } |
| | | |
| | | 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) { |
| | |
| | | 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) { |
| | |
| | | <ToolOutlined /> |
| | | </Popover> |
| | | <div className="inv-action"> |
| | | <Button className="mk-bill">保存单据</Button> |
| | | <Button className="mk-submit">提交开票</Button> |
| | | {card.wrap.backBtn === 'show' ? <Button className="mk-back"><LeftOutlined />返回</Button> : null} |
| | | <Button className="mk-addinv">新增发票</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> |
| | |
| | | <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> |
| | | ) |
| | | } |