| | |
| | | import React, {Component} from 'react' |
| | | import PropTypes from 'prop-types' |
| | | import { is, fromJS } from 'immutable' |
| | | import { Button, Select, Input, DatePicker } from 'antd' |
| | | // import { EditOutlined, ToolOutlined, DeleteOutlined, FontColorsOutlined } from '@ant-design/icons' |
| | | import { Button, Select, Input, DatePicker, notification } from 'antd' |
| | | import moment from 'moment' |
| | | |
| | | import Api from '@/api' |
| | | import asyncComponent from '@/utils/asyncComponent' |
| | | // import MKEmitter from '@/utils/events.js' |
| | | import MKEmitter from '@/utils/events.js' |
| | | import './index.scss' |
| | | |
| | | const VoucherTable = asyncComponent(() => import('./voucherTable')) |
| | |
| | | |
| | | state = { |
| | | BID: '', |
| | | type: '', |
| | | config: null, |
| | | loading: false, |
| | | data: null, |
| | | searchkey: null, |
| | | disableAdd: true, |
| | | disableSave: true, |
| | | typeOptions: [] |
| | | disableAdd: false, |
| | | disableSave: false, |
| | | typeOptions: [], |
| | | book: null |
| | | } |
| | | |
| | | UNSAFE_componentWillMount () { |
| | |
| | | this.setState({ |
| | | config: fromJS(config).toJS(), |
| | | BID: BID || '', |
| | | type: config.wrap.type |
| | | book: window.GLOB.CacheData.get(config.wrap.supBook) || null |
| | | }, () => { |
| | | this.loadData() |
| | | }) |
| | | } |
| | | |
| | | componentDidMount () { |
| | | |
| | | MKEmitter.addListener('resetSelectLine', this.resetParentParam) |
| | | } |
| | | |
| | | shouldComponentUpdate (nextProps, nextState) { |
| | |
| | | this.setState = () => { |
| | | return |
| | | } |
| | | |
| | | MKEmitter.removeListener('resetSelectLine', this.resetParentParam) |
| | | } |
| | | |
| | | resetParentParam = (MenuID, id, data) => { |
| | | const { config } = this.state |
| | | |
| | | if (config.wrap.supBook === MenuID) { |
| | | this.setState({ book: data }, () => { |
| | | this.loadData() |
| | | }) |
| | | return |
| | | } |
| | | |
| | | if (!config.wrap.supModule || config.wrap.supModule !== MenuID) return |
| | | if (id !== this.state.BID || id !== '') { |
| | | this.setState({ BID: id, BData: data }, () => { |
| | | this.loadData() |
| | | }) |
| | | } |
| | | } |
| | | |
| | | loadData = () => { |
| | | let param = { |
| | | func: 's_get_fcc_account_data' |
| | | } |
| | | Api.genericInterface(param) |
| | | const { book } = this.state |
| | | |
| | | let _param = { |
| | | func: 's_get_fcc_book_data' |
| | | if (!book) return |
| | | |
| | | let param = { |
| | | func: 's_get_fcc_account_data', |
| | | account_code: book.account_code || '', |
| | | fcc_date: book.months ? book.months + '-01' : moment().format('YYYY-MM-DD') |
| | | } |
| | | Api.genericInterface(_param) |
| | | |
| | | Api.genericInterface(param).then(res => { |
| | | if (!res.status) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: res.message, |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } |
| | | |
| | | |
| | | }) |
| | | } |
| | | |
| | | triggeradd = () => { |
| | |
| | | } |
| | | |
| | | render() { |
| | | const { config, disableSave, disableAdd, typeOptions, data, type } = this.state |
| | | const { config, disableSave, disableAdd, typeOptions, data } = this.state |
| | | |
| | | return ( |
| | | <div className="menu-voucher-wrap" style={config.style}> |
| | | <div className="voucher-header"> |
| | | <Button className="system-background header-btn" disabled={disableAdd} onClick={this.triggeradd}>新增</Button> |
| | | <Button className="system-background header-btn" disabled={disableSave} onClick={this.triggersave}>保存</Button> |
| | | <Button className="system-background header-btn" disabled={disableSave} onClick={this.triggerprint}>打印</Button> |
| | | <Button className="add-background header-btn" disabled={disableAdd} onClick={this.triggeradd}>新增</Button> |
| | | <Button className="add-background header-btn" disabled={disableSave} onClick={this.triggersave}>保存</Button> |
| | | <Button className="print-background header-btn" disabled={disableSave} onClick={this.triggerprint}>打印</Button> |
| | | <Button className="system-background header-btn" disabled={disableSave} onClick={this.triggerprint}>导入</Button> |
| | | <Button className="system-background header-btn" disabled={disableSave} onClick={this.triggerprint}>导出</Button> |
| | | <Button className="out-background header-btn" disabled={disableSave} onClick={this.triggerprint}>导出</Button> |
| | | </div> |
| | | {type === 'edit' ? <div className="voucher-body"> |
| | | {config.wrap.type === 'edit' ? <div className="voucher-body"> |
| | | <div className="pre-wrap"> |
| | | <div className="voucher-code"> |
| | | <Select> |
| | | <Select dropdownClassName="mk-vcode-dropdown"> |
| | | {typeOptions.map(option => |
| | | <Select.Option value={option.value}>{option.label}</Select.Option> |
| | | )} |
| | |
| | | </div> |
| | | <VoucherTable config={config} data={data}/> |
| | | </div> : null} |
| | | {type === 'check' ? <div className="voucher-body"> |
| | | {config.wrap.type === 'check' ? <div className="voucher-body"> |
| | | <div className="pre-wrap"> |
| | | <div className="voucher-code"> |
| | | 记 1 号 |