| | |
| | | import SubTable from './subTable' |
| | | import './index.scss' |
| | | |
| | | const { confirm } = Modal |
| | | |
| | | class InvoiceModule extends Component { |
| | | static propTpyes = { |
| | | config: PropTypes.object |
| | |
| | | tax_type: '', |
| | | reqfields: [], |
| | | requireds: [], |
| | | timestamp: new Date().getTime() + '' |
| | | invoice_no: '', |
| | | invoice_code: '', |
| | | invoice_date: '', |
| | | read_only: false, |
| | | invoice_type_name: '', |
| | | timestamp: '' |
| | | } |
| | | |
| | | UNSAFE_componentWillMount () { |
| | |
| | | |
| | | _config.buyer = this.formatSetting(_config.buyer, 'buyer') |
| | | _config.detail = this.formatSetting(_config.detail, 'detail') |
| | | _config.detail.uuid = _config.uuid |
| | | |
| | | let book = null |
| | | let pas = {} |
| | |
| | | cell.Hide = 'true' |
| | | } else if (['from_to_email', 'from_to_mob'].includes(cell.field)) { |
| | | cell.Width = 80 |
| | | } else if (['from_to_name'].includes(cell.field)) { |
| | | cell.Width = 140 |
| | | } |
| | | return cell |
| | | }) |
| | |
| | | cell.field = 'tax_rate' |
| | | cell.label = '税率' |
| | | } |
| | | if (['Description', 'id', 'small_tax_rate', 'free_tax_mark', 'vat_special_management'].includes(cell.field)) { |
| | | if (['Description', 'id', 'small_tax_rate', 'free_tax_mark', 'vat_special_management', 'tax_item', 'tax_method'].includes(cell.field)) { |
| | | cell.Hide = 'true' |
| | | } else if (['spec'].includes(cell.field)) { |
| | | cell.Width = 150 |
| | |
| | | } |
| | | }) |
| | | |
| | | let invoice_type_name = '' |
| | | if (line.read_only === 'true') { |
| | | let types = book.invoice_type || [] |
| | | types.forEach(item => { |
| | | if (item.value === line.invoice_type) { |
| | | invoice_type_name = item.label |
| | | } |
| | | }) |
| | | invoice_type_name = invoice_type_name || line.invoice_type |
| | | } |
| | | |
| | | this.setState({ |
| | | ID: line[config.setting.primaryKey] || Utils.getguid(), |
| | | io: line.io, |
| | |
| | | reviewer: line.reviewer, |
| | | drawer: line.drawer, |
| | | details: details, |
| | | invoice_no: line.invoice_no, |
| | | invoice_code: line.invoice_code, |
| | | invoice_date: line.read_only === 'true' ? line.invoice_date : '', |
| | | read_only: line.read_only === 'true', |
| | | invoice_type_name: invoice_type_name, |
| | | oriDetails: fromJS(details).toJS(), |
| | | timestamp: new Date().getTime() + '', |
| | | loading: false |
| | |
| | | } |
| | | |
| | | clearData = () => { |
| | | const { from_to_tax_no, oriDetails, details } = this.state |
| | | |
| | | if (from_to_tax_no || oriDetails.length || details.length) { |
| | | this.setState({ |
| | | 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: '', |
| | | from_to_code: '', |
| | | business_type: '', |
| | | details: [], |
| | | oriDetails: [], |
| | | timestamp: new Date().getTime() + '', |
| | | }) |
| | | } |
| | | this.setState({ |
| | | ID: Utils.getguid(), |
| | | 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: '', |
| | | from_to_code: '', |
| | | business_type: '', |
| | | details: [], |
| | | oriDetails: [], |
| | | timestamp: new Date().getTime() + '', |
| | | }) |
| | | } |
| | | |
| | | changeType = (val) => { |
| | |
| | | saveType: '' |
| | | }) |
| | | if (res.status) { |
| | | const that = this |
| | | |
| | | confirm({ |
| | | title: '保存成功。', |
| | | okText: '继续填开', |
| | | cancelText: '关闭', |
| | | onOk() { |
| | | if (config.billSaveBtn.reTabId) { |
| | | MKEmitter.emit('reloadMenuView', config.billSaveBtn.reTabId, 'table') |
| | | } |
| | | if (config.billSaveBtn.syncComId) { |
| | | MKEmitter.emit('reloadData', config.billSaveBtn.syncComId) |
| | | } |
| | | that.clearData() |
| | | }, |
| | | onCancel() { |
| | | if (config.billSaveBtn.reTabId) { |
| | | MKEmitter.emit('reloadMenuView', config.billSaveBtn.reTabId, 'table') |
| | | } |
| | | if (config.billSaveBtn.syncComId) { |
| | | MKEmitter.emit('reloadData', config.billSaveBtn.syncComId) |
| | | } |
| | | MKEmitter.emit('closeTabView', config.$pageId) |
| | | } |
| | | if (config.billSaveBtn.reTabId) { |
| | | MKEmitter.emit('reloadMenuView', config.billSaveBtn.reTabId, 'table') |
| | | } |
| | | if (config.billSaveBtn.syncComId) { |
| | | MKEmitter.emit('reloadData', config.billSaveBtn.syncComId) |
| | | } |
| | | notification.success({ |
| | | top: 92, |
| | | message: '保存成功。', |
| | | duration: 5 |
| | | }) |
| | | } else { |
| | | notification.warning({ |
| | |
| | | |
| | | outBill = () => { |
| | | const { config, BID, saveType } = this.state |
| | | |
| | | if (window.GLOB.storeFiles) { |
| | | if (!window.GLOB.storeDate || window.GLOB.storeDate < 0) { |
| | | Modal.warning({ |
| | | title: `电子档案存储包已过期。`, |
| | | okText: '知道了' |
| | | }) |
| | | return |
| | | } else if (window.GLOB.storeDate < 30) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: `电子档案存储包还剩${window.GLOB.storeDate}天。`, |
| | | duration: 5 |
| | | }) |
| | | } |
| | | } |
| | | |
| | | if (window.GLOB.systemType === 'production' && !config.billOutBtn.proInterface) { |
| | | notification.warning({ |
| | |
| | | |
| | | param.data.invoiceTypeCode = trans[param.data.invoiceTypeCode] || '' |
| | | |
| | | if (window.GLOB.storeFiles) { |
| | | param.store = true |
| | | } |
| | | |
| | | let url = '' |
| | | if (window.GLOB.systemType === 'production') { |
| | | url = config.billOutBtn.proInterface |
| | | } else { |
| | | url = config.billOutBtn.interface |
| | | } |
| | | if (!/^http/.test(url)) { |
| | | url = window.location.origin + url |
| | | } |
| | | |
| | | let _params = { |
| | |
| | | }) |
| | | |
| | | keys = keys.join(',') |
| | | vals = vals.join(',') |
| | | |
| | | lines.push({ |
| | | table: md5(tb + keys), |
| | | insert: `Insert into ${tbName} (${keys},[mk_level],[mk_id],[mk_bid])`, |
| | | select: `Select ${vals.join(',')},'${level}','${id}','${bid}'` |
| | | insert: `Insert into ${tbName} (${keys ? keys + ',' : ''}[mk_level],[mk_id],[mk_bid])`, |
| | | select: `Select ${keys ? vals + ',' : ''}'${level}','${id}','${bid}'` |
| | | }) |
| | | |
| | | subObjs.forEach(item => { |
| | |
| | | } |
| | | |
| | | Api.genericInterface(param).then(res => { |
| | | this.setState({ |
| | | saveType: '' |
| | | }) |
| | | if (res.status) { |
| | | const that = this |
| | | if (config.billOutBtn.reTabId) { |
| | | MKEmitter.emit('reloadMenuView', config.billOutBtn.reTabId, 'table') |
| | | } |
| | | if (config.billOutBtn.syncComId) { |
| | | MKEmitter.emit('reloadData', config.billOutBtn.syncComId) |
| | | } |
| | | this.clearData() |
| | | |
| | | confirm({ |
| | | title: '保存成功。', |
| | | okText: '继续填开', |
| | | cancelText: '关闭', |
| | | onOk() { |
| | | if (config.billOutBtn.reTabId) { |
| | | MKEmitter.emit('reloadMenuView', config.billOutBtn.reTabId, 'table') |
| | | } |
| | | if (config.billOutBtn.syncComId) { |
| | | MKEmitter.emit('reloadData', config.billOutBtn.syncComId) |
| | | } |
| | | that.clearData() |
| | | }, |
| | | onCancel() { |
| | | if (config.billOutBtn.reTabId) { |
| | | MKEmitter.emit('reloadMenuView', config.billOutBtn.reTabId, 'table') |
| | | } |
| | | if (config.billOutBtn.syncComId) { |
| | | MKEmitter.emit('reloadData', config.billOutBtn.syncComId) |
| | | } |
| | | MKEmitter.emit('closeTabView', config.$pageId) |
| | | } |
| | | notification.success({ |
| | | top: 92, |
| | | message: '开票成功。', |
| | | duration: 5 |
| | | }) |
| | | } else { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: res.message, |
| | | duration: 5 |
| | | }) |
| | | this.setState({ |
| | | saveType: '' |
| | | }) |
| | | } |
| | | }) |
| | |
| | | }) |
| | | } |
| | | |
| | | render() { |
| | | const { config, book, loading, invTypes, reqfields, saveType, date, timestamp, invoice_type, 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 |
| | | addInvice = () => { |
| | | const { saveType } = this.state |
| | | |
| | | if (!book || (config.wrap.datatype === 'dynamic' && !tax_no)) { |
| | | if (saveType) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: saveType === 'bill' ? '单据保存中,请稍后。' : '开票中,请稍后。', |
| | | duration: 3 |
| | | }) |
| | | return |
| | | } |
| | | |
| | | this.clearData() |
| | | |
| | | notification.success({ |
| | | top: 92, |
| | | message: '单据已更新。', |
| | | duration: 3 |
| | | }) |
| | | } |
| | | |
| | | // jumpSys = () => { |
| | | // window.open(`${window.location.origin}/kgcs/thirdPlatFormLogin?userName=admin&taxCode=91120222MA07GMNW97&taxName=天津畅享数字科技有限公司`) |
| | | // } |
| | | |
| | | render() { |
| | | const { config, book, loading, invTypes, reqfields, saveType, date, timestamp, invoice_type, 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, invoice_no, invoice_code, invoice_date, read_only, invoice_type_name } = this.state |
| | | |
| | | if (!book || (config.wrap.datatype === 'dynamic' && !timestamp)) { |
| | | return <div className="menu-invoice-wrap" style={config.style}> |
| | | <div className="loading-mask"> |
| | | <div className="ant-spin-blur"></div> |
| | | <Spin /> |
| | | </div> |
| | | </div> |
| | | } |
| | | |
| | | if (read_only) { |
| | | return ( |
| | | <div className="menu-invoice-wrap read_only" style={config.style}> |
| | | {loading ? |
| | | <div className="loading-mask"> |
| | | <div className="ant-spin-blur"></div> |
| | | <Spin /> |
| | | </div> : null |
| | | } |
| | | <div className="inv-action"> |
| | | {config.wrap.backBtn === 'show' ? <Button className="mk-back" onClick={this.goback}><LeftOutlined />返回</Button> : null} |
| | | </div> |
| | | <div className="inv-header"> |
| | | <div className="inv-type">{invoice_type_name}</div> |
| | | <div className="inv-msg"> |
| | | {invoice_no ? <div>发票号码:{invoice_no}</div> : null} |
| | | {invoice_code ? <div>发票代码:{invoice_code}</div> : null} |
| | | {invoice_date ? <div>开票日期:{invoice_date}</div> : null} |
| | | </div> |
| | | </div> |
| | | <div className="inv-body"> |
| | | <div className="inv-main-content"> |
| | | <div className="inv-buyer"> |
| | | <div className="inv-label">购买方</div> |
| | | <div className="inv-content"> |
| | | <Form.Item className="mk-name" label={<>名<span></span>称</>}> |
| | | {from_to_name} |
| | | </Form.Item> |
| | | <Form.Item label="纳税人识别号"> |
| | | {from_to_tax_no} |
| | | </Form.Item> |
| | | <Form.Item label={<>地<span></span>址<span></span>、<span></span>电<span></span>话</>}> |
| | | {from_to_addr + ' ' + from_to_tel} |
| | | </Form.Item> |
| | | <Form.Item label="开户行及账号"> |
| | | {from_to_bank_name + ' ' + from_to_account_no} |
| | | </Form.Item> |
| | | </div> |
| | | </div> |
| | | <div className="inv-notice"> |
| | | <div className="inv-label">通知到</div> |
| | | <div className="inv-content"> |
| | | <Form.Item label={<>手<span></span>机<span></span>号</>}> |
| | | {from_to_mob} |
| | | </Form.Item> |
| | | <Form.Item label={<>邮<span></span>箱</>}> |
| | | {from_to_email} |
| | | </Form.Item> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | <div className="inv-details"> |
| | | <InvoiceTable data={details} timestamp={timestamp} read_only={true} config={config.detail} tax_type={tax_type} onChange={(details) => this.setState({details})}/> |
| | | </div> |
| | | <div className="inv-main-content"> |
| | | <div className="inv-buyer"> |
| | | <div className="inv-label">销售方</div> |
| | | <div className="inv-content"> |
| | | <Form.Item label={<>名<span></span>称</>}> |
| | | {orgname} |
| | | </Form.Item> |
| | | <Form.Item label="纳税人识别号"> |
| | | {tax_no} |
| | | </Form.Item> |
| | | <Form.Item label={<>地<span></span>址<span></span>、<span></span>电<span></span>话</>}> |
| | | {addr + ' ' + tel} |
| | | </Form.Item> |
| | | <Form.Item label="开户行及账号"> |
| | | {bank_name + ' ' + account_no} |
| | | </Form.Item> |
| | | </div> |
| | | </div> |
| | | <div className="inv-notice"> |
| | | <div className="inv-label">备注</div> |
| | | <div className="inv-content" style={{paddingTop: '30px'}}> |
| | | <Form.Item label=""> |
| | | {remark} |
| | | </Form.Item> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | <div className="inv-tail"> |
| | | <Form.Item label="收款人"> |
| | | {payee} |
| | | </Form.Item> |
| | | <Form.Item label="复核人"> |
| | | {reviewer} |
| | | </Form.Item> |
| | | <Form.Item label="开票人"> |
| | | {drawer} |
| | | </Form.Item> |
| | | </div> |
| | | </div> |
| | | ) |
| | | } |
| | | |
| | | return ( |
| | |
| | | } |
| | | <div className="inv-action"> |
| | | {config.wrap.backBtn === 'show' ? <Button className="mk-back" onClick={this.goback}><LeftOutlined />返回</Button> : null} |
| | | {/* <Button className="mk-addinv" onClick={this.jumpSys}>跳转</Button> */} |
| | | <Button className="mk-addinv" onClick={this.addInvice}>新增发票</Button> |
| | | <Button className="mk-bill" loading={saveType === 'bill'} onClick={this.saveBill}>保存单据</Button> |
| | | <Button className="mk-submit" loading={saveType === 'out'} onClick={this.outBill}>提交开票</Button> |
| | | </div> |
| | |
| | | <div className="inv-buyer"> |
| | | <div className="inv-label">购买方</div> |
| | | <div className="inv-content"> |
| | | <Form.Item required={reqfields.includes('from_to_name')} label={<>名<span></span>称</>} extra={<EllipsisOutlined onClick={() => this.setState({visible: true})}/>}> |
| | | <Form.Item className="mk-name" required={reqfields.includes('from_to_name')} label={<>名<span></span>称</>} extra={<EllipsisOutlined onClick={() => this.setState({visible: true})}/>}> |
| | | <Input placeholder="请输入购买方名称" allowClear value={from_to_name} autoComplete="off" onChange={(e) => this.setState({from_to_name: e.target.value})}/> |
| | | </Form.Item> |
| | | <Form.Item required={reqfields.includes('from_to_tax_no')} label="纳税人识别号"> |
| | |
| | | </div> |
| | | </div> |
| | | <div className="inv-details"> |
| | | <InvoiceTable data={details} timestamp={timestamp} config={config.detail} tax_type={tax_type} onChange={(details) => this.setState({details})}/> |
| | | <InvoiceTable data={details} timestamp={timestamp} read_only={false} config={config.detail} tax_type={tax_type} onChange={(details) => this.setState({details})}/> |
| | | </div> |
| | | <div className="inv-main-content"> |
| | | <div className="inv-buyer"> |
| | |
| | | <Modal |
| | | title="客户信息" |
| | | visible={visible} |
| | | width="70vw" |
| | | width="75vw" |
| | | maskClosable={false} |
| | | onCancel={() => { this.setState({ visible: false }) }} |
| | | footer={null} |