| | |
| | | import React, {Component} from 'react' |
| | | import PropTypes from 'prop-types' |
| | | import { is, fromJS } from 'immutable' |
| | | import { Select, Form, Input, Button, Modal } from 'antd' |
| | | import { Select, Form, Input, Button, Modal, Spin } from 'antd' |
| | | import { EllipsisOutlined } from '@ant-design/icons' |
| | | import moment from 'moment' |
| | | |
| | | // import Api from '@/api' |
| | | import Api from '@/api' |
| | | import UtilsDM from '@/utils/utils-datamanage.js' |
| | | // import Utils from '@/utils/utils.js' |
| | | import MKEmitter from '@/utils/events.js' |
| | | import InvoiceTable from './invoiceTable' |
| | |
| | | payee: '', |
| | | reviewer: '', |
| | | drawer: '', |
| | | details: [] |
| | | details: [], |
| | | book: null, |
| | | loading: false, |
| | | tax_type: '' |
| | | } |
| | | |
| | | UNSAFE_componentWillMount () { |
| | |
| | | _config.buyer = this.formatSetting(_config.buyer, 'buyer') |
| | | _config.detail = this.formatSetting(_config.detail, 'detail') |
| | | |
| | | let book = null |
| | | let pas = {} |
| | | if (config.wrap.supBook) { |
| | | book = window.GLOB.CacheData.get(config.wrap.supBook) || null |
| | | |
| | | if (book) { |
| | | pas = this.resetParam(book) |
| | | } |
| | | } |
| | | |
| | | this.setState({ |
| | | BID: BID || '', |
| | | config: _config |
| | | config: _config, |
| | | book, |
| | | ...pas |
| | | }) |
| | | } |
| | | |
| | | componentDidMount () { |
| | | this.loadData() |
| | | const { config } = this.props |
| | | |
| | | MKEmitter.addListener('reloadData', this.reloadData) |
| | | MKEmitter.addListener('resetSelectLine', this.resetParentParam) |
| | | |
| | | if (config.wrap.datatype === 'dynamic' && config.setting.onload === 'true') { |
| | | setTimeout(() => { |
| | | this.loadData() |
| | | }, config.setting.delay || 0) |
| | | } |
| | | } |
| | | |
| | | shouldComponentUpdate (nextProps, nextState) { |
| | |
| | | return |
| | | } |
| | | MKEmitter.removeListener('reloadData', this.reloadData) |
| | | MKEmitter.removeListener('resetSelectLine', this.resetParentParam) |
| | | } |
| | | |
| | | formatSetting = (item, type) => { |
| | |
| | | }) |
| | | } else { |
| | | item.columns = item.columns.map(cell => { |
| | | if (['Description', 'id'].includes(cell.field)) { |
| | | if (cell.field === 'general_tax_rate') { |
| | | cell.field = 'tax_rate' |
| | | cell.label = '税率' |
| | | } |
| | | if (['Description', 'id', 'small_tax_rate'].includes(cell.field)) { |
| | | cell.Hide = 'true' |
| | | } else if (['spec'].includes(cell.field)) { |
| | | cell.Width = 150 |
| | | } else if (['unit', 'unitprice', 'tax_rate'].includes(cell.field)) { |
| | | cell.Width = 80 |
| | | } |
| | | |
| | | return cell |
| | | }) |
| | | } |
| | |
| | | return item |
| | | } |
| | | |
| | | reloadData = (menuId) => { |
| | | // const { config } = this.props |
| | | // const { activeItem } = this.state |
| | | |
| | | // if (config.uuid !== menuId) return |
| | | resetParentParam = (MenuID, id, data) => { |
| | | const { config } = this.state |
| | | |
| | | // if (activeItem) { |
| | | // MKEmitter.emit('resetSelectLine', config.uuid, activeItem.id, activeItem) |
| | | // } else { |
| | | // this.loadData() |
| | | // } |
| | | if (config.wrap.supBook === MenuID) { |
| | | let pas = this.resetParam(data) |
| | | |
| | | this.setState({ book: data, ...pas }, () => { |
| | | this.loadData() |
| | | }) |
| | | return |
| | | } |
| | | |
| | | if (!config.wrap.supModule || config.wrap.supModule !== MenuID) return |
| | | if (id !== this.state.BID || id !== '') { |
| | | this.setState({ BID: id }, () => { |
| | | this.loadData() |
| | | }) |
| | | } |
| | | } |
| | | |
| | | loadData = () => { |
| | | // let param = { |
| | | // func: 's_get_fcc_book_data', |
| | | // dataM: sessionStorage.getItem('dataM') === 'true' ? 'Y' : '', |
| | | // mk_organization: sessionStorage.getItem('organization') || '' |
| | | // } |
| | | resetParam = (book) => { |
| | | return { |
| | | invTypes: book.invoice_type || [], |
| | | orgname: book.orgname || '', |
| | | tax_no: book.tax_no || '', |
| | | addr: book.addr || '', |
| | | tel: book.tel || '', |
| | | bank_name: book.bank_name || '', |
| | | account_no: book.account_no || '', |
| | | payee: book.payee || '', |
| | | reviewer: book.reviewer || '', |
| | | drawer: book.drawer || '', |
| | | tax_type: book.tax_type || '' |
| | | } |
| | | } |
| | | |
| | | // Api.genericInterface(param).then(res => { |
| | | // if (!res.status) { |
| | | // notification.warning({ |
| | | // top: 92, |
| | | // message: res.message, |
| | | // duration: 5 |
| | | // }) |
| | | // return |
| | | // } |
| | | reloadData = (menuId) => { |
| | | const { config } = this.state |
| | | |
| | | if (config.uuid !== menuId) return |
| | | |
| | | // let books = res.book || [] |
| | | // let activeItem = null |
| | | // let map = new Map() |
| | | // books = books.filter(item => { |
| | | // if (!item.id) return false |
| | | // if (map.has(item.id)) return false |
| | | // map.set(item.id, true) |
| | | this.loadData() |
| | | } |
| | | |
| | | // if (item.selected === 'true' && !activeItem) { |
| | | // activeItem = item |
| | | // } |
| | | // if (item.months) { |
| | | // item.date = item.months.replace('-', '年') + '月' |
| | | // } |
| | | // return true |
| | | // }) |
| | | async loadData() { |
| | | const { config, BID } = this.state |
| | | |
| | | // this.setState({books, activeItem}) |
| | | if (config.wrap.datatype !== 'dynamic') return |
| | | |
| | | // if (activeItem) { |
| | | // MKEmitter.emit('resetSelectLine', this.props.config.uuid, activeItem.id, activeItem) |
| | | // } |
| | | // }) |
| | | let param = UtilsDM.getQueryDataParams(config.setting, [], config.setting.order, 1, 1, BID) |
| | | |
| | | this.setState({ |
| | | loading: true |
| | | }) |
| | | |
| | | let result = await Api.genericInterface(param) |
| | | if (result.status) { |
| | | |
| | | this.setState({ |
| | | loading: false |
| | | }) |
| | | |
| | | UtilsDM.querySuccess(result) |
| | | } else { |
| | | this.setState({ |
| | | loading: false |
| | | }) |
| | | this.timer && this.timer.stop() |
| | | |
| | | UtilsDM.queryFail(result) |
| | | } |
| | | } |
| | | |
| | | changeType = (val) => { |
| | |
| | | } |
| | | |
| | | render() { |
| | | const { config, invTypes, date, from_to_name, from_to_tax_no, from_to_addr, from_to_tel, from_to_bank_name, from_to_account_no, from_to_mob, from_to_email, orgname, tax_no, addr, tel, bank_name, account_no, remark, reviewer, drawer, payee, details, visible } = this.state |
| | | const { config, book, loading, invTypes, date, from_to_name, from_to_tax_no, from_to_addr, from_to_tel, from_to_bank_name, from_to_account_no, from_to_mob, from_to_email, orgname, tax_no, addr, tel, bank_name, account_no, remark, reviewer, drawer, payee, details, visible, tax_type } = this.state |
| | | |
| | | if (!book || (config.wrap.datatype === 'dynamic' && !tax_no)) { |
| | | return <div className="menu-invoice-wrap" style={config.style}> |
| | | <div className="loading-mask"> |
| | | <div className="ant-spin-blur"></div> |
| | | <Spin /> |
| | | </div> |
| | | </div> |
| | | } |
| | | |
| | | return ( |
| | | <div className="menu-invoice-wrap" style={config.style}> |
| | | {loading ? |
| | | <div className="loading-mask"> |
| | | <div className="ant-spin-blur"></div> |
| | | <Spin /> |
| | | </div> : null |
| | | } |
| | | <div className="inv-action"> |
| | | <Button className="mk-bill">保存单据</Button> |
| | | <Button className="mk-submit">提交开票</Button> |
| | |
| | | </div> |
| | | </div> |
| | | <div className="inv-details"> |
| | | <InvoiceTable data={details} config={config.detail} onChange={(details) => this.setState({details})}/> |
| | | <InvoiceTable data={details} config={config.detail} tax_type={tax_type} onChange={(details) => this.setState({details})}/> |
| | | </div> |
| | | <div className="inv-main-content"> |
| | | <div className="inv-buyer"> |