From fc8c8d714687a22f711d642d192bd4149f3b7e88 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期一, 22 四月 2024 11:15:14 +0800 Subject: [PATCH] 2024-04-22 --- src/tabviews/custom/components/module/invoice/index.jsx | 169 ++++++++++++++++++++++++++++++++++++++----------------- 1 files changed, 116 insertions(+), 53 deletions(-) diff --git a/src/tabviews/custom/components/module/invoice/index.jsx b/src/tabviews/custom/components/module/invoice/index.jsx index 6307d89..7be4d48 100644 --- a/src/tabviews/custom/components/module/invoice/index.jsx +++ b/src/tabviews/custom/components/module/invoice/index.jsx @@ -1,11 +1,12 @@ 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' @@ -48,7 +49,10 @@ payee: '', reviewer: '', drawer: '', - details: [] + details: [], + book: null, + loading: false, + tax_type: '' } UNSAFE_componentWillMount () { @@ -74,15 +78,35 @@ _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) { @@ -97,6 +121,7 @@ return } MKEmitter.removeListener('reloadData', this.reloadData) + MKEmitter.removeListener('resetSelectLine', this.resetParentParam) } formatSetting = (item, type) => { @@ -114,13 +139,18 @@ }) } 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 }) } @@ -191,59 +221,77 @@ 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) => { @@ -266,10 +314,25 @@ } 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> @@ -316,7 +379,7 @@ </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"> -- Gitblit v1.8.0