| | |
| | | import './index.scss' |
| | | |
| | | const { confirm } = Modal |
| | | const { TextArea } = Input |
| | | const VoucherTable = asyncComponent(() => import('./voucherTable')) |
| | | const ResetRemark = asyncComponent(() => import('./resetRemark')) |
| | | const ResetAttach = asyncComponent(() => import('./resetAttach')) |
| | | |
| | | class VoucherModule extends Component { |
| | | static propTpyes = { |
| | |
| | | book: null, |
| | | username: sessionStorage.getItem('User_Name'), |
| | | remark: '', |
| | | remarkVisible: false, |
| | | attachments: 0, |
| | | attachlist: [], |
| | | title: '', |
| | | orgcode: '', |
| | | orgname: '', |
| | | status: '' // 新建时,empty、change、saved |
| | | status: '', // 新建时,empty、change、saved |
| | | saved: false |
| | | } |
| | | |
| | | UNSAFE_componentWillMount () { |
| | |
| | | voucherSave = (list, t) => { |
| | | const { type, data, config, charInt, charType, vouDate, book, remark, charName, attachments, title, orgcode, orgname } = this.state |
| | | |
| | | let err = '' |
| | | if (!book) { |
| | | err = '请选择账套!' |
| | | } else if (!vouDate) { |
| | | err = '请选择日期!' |
| | | } else if (!charName || !charInt) { |
| | | err = '请选择凭证号!' |
| | | } |
| | | |
| | | if (err) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '请选择账套!', |
| | | message: err, |
| | | duration: 5 |
| | | }) |
| | | return |
| | |
| | | remark: '', |
| | | tbdata: [], |
| | | charInt: res.voucher_char_int + 1, |
| | | BID: Utils.getguid() |
| | | BID: Utils.getguid(), |
| | | saved: false |
| | | }) |
| | | MKEmitter.emit('cleartable', config.uuid) |
| | | } else { |
| | | this.setState({ |
| | | status: 'saved', |
| | | charInt: res.voucher_char_int || charInt, |
| | | data: fromJS(list).toJS() |
| | | data: fromJS(list).toJS(), |
| | | saved: true |
| | | }) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | triggerprint = () => { |
| | | this.setState({remarkVisible: true}) |
| | | } |
| | | |
| | | remarkSubmit = () => { |
| | | const { config } = this.state |
| | | let node = document.getElementById(config.uuid + 'remark') |
| | | let val = node.value |
| | | |
| | | if (val && val.length > 512) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '当前内容超长,备注最多512个字符。', |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } |
| | | this.setState({remark: val, remarkVisible: false}) |
| | | } |
| | | |
| | | dataChange = (data) => { |
| | |
| | | this.setState({attachments: _val}) |
| | | } |
| | | |
| | | changeVouDate = (val) => { |
| | | const { type, status, saved } = this.state |
| | | this.setState({vouDate: val}) |
| | | |
| | | if (type === 'createVoucher' && val && !saved && (status === 'empty' || status === 'change')) { |
| | | this.updateVoucherChar(val) |
| | | } |
| | | } |
| | | |
| | | updateVoucherChar = (val) => { |
| | | const { book, config } = this.state |
| | | |
| | | if (!book) return |
| | | |
| | | let param = { |
| | | func: 's_get_fcc_account_data', |
| | | search_type: 'Y', |
| | | fcc_date: book.months ? book.months + '-01' : moment().format('YYYY-MM-DD'), |
| | | account_year_code: book.account_year_code || '', |
| | | months: moment(val).format('YYYY-MM'), |
| | | BID: book.id |
| | | } |
| | | |
| | | Api.genericInterface(param).then(res => { |
| | | if (!res.status) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: res.message, |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } |
| | | |
| | | let typeOptions = res.char || [] |
| | | |
| | | if (typeOptions.length > 0) { |
| | | let charType = this.state.charType |
| | | let charName = this.state.charName |
| | | let charInt = this.state.charInt |
| | | |
| | | if (charType && typeOptions.filter(n => n.voucher_class === charType) > 0) { |
| | | typeOptions.forEach(n => { |
| | | if (n.voucher_class === charType) { |
| | | charName = n.voucher_char |
| | | charInt = n.voucher_char_int + 1 |
| | | } |
| | | }) |
| | | } else { |
| | | charType = typeOptions[0].voucher_class |
| | | charName = typeOptions[0].voucher_char |
| | | charInt = typeOptions[0].voucher_char_int + 1 |
| | | } |
| | | |
| | | this.setState({ |
| | | typeOptions: typeOptions, |
| | | charType: charType, |
| | | charName: charName, |
| | | charInt: charInt |
| | | }) |
| | | } |
| | | |
| | | let msg = window.GLOB.CacheVoucher.get(config.uuid) || {} |
| | | msg.currency = res.currency || [] |
| | | |
| | | window.GLOB.CacheVoucher.set(config.uuid, msg) |
| | | }) |
| | | } |
| | | |
| | | triggermore = () => { |
| | | |
| | | } |
| | |
| | | |
| | | } |
| | | |
| | | triggerAttach = () => { |
| | | |
| | | } |
| | | |
| | | render() { |
| | | const { type, status, loading, config, typeOptions, charType, charInt, data, vouDate, username, remark, remarkVisible, attachments, title } = this.state |
| | | const { type, status, loading, config, typeOptions, charType, charInt, data, vouDate, username, remark, attachments, title, attachlist } = this.state |
| | | |
| | | return ( |
| | | <div className="menu-voucher-wrap" style={config.style}> |
| | |
| | | <InputNumber precision={0} min={1} value={charInt} autoComplete="off" onChange={(val) => this.setState({charInt: val})}/> 号 |
| | | </div> |
| | | <div className="voucher-date"> |
| | | 日期:<DatePicker value={vouDate} onChange={(val) => this.setState({vouDate: val})}/> |
| | | 日期:<DatePicker value={vouDate} onChange={this.changeVouDate}/> |
| | | </div> |
| | | <div className="voucher-text"> |
| | | <Input value={title} placeholder="凭证文本" autoComplete="off" onChange={(e) => this.setState({title: e.target.value})}/> |
| | | </div> |
| | | <div className="voucher-affix"> |
| | | 附单据 <InputNumber precision={0} value={attachments || 0} autoComplete="off" onChange={this.changeAttach}/> 张 |
| | | <Button type="link" className="" onClick={this.triggerAttach}>附件</Button> |
| | | <Button type="link" className="" onClick={this.triggerprint}>备注</Button> |
| | | <ResetAttach attachlist={attachlist} onChange={(vals) => this.setState({attachlist: vals})}/> |
| | | <ResetRemark remark={remark} ID={config.uuid + 'remark'} onChange={(val) => this.setState({remark: val})}/> |
| | | </div> |
| | | </div> : null} |
| | | <VoucherTable config={config} loading={loading} data={data} onChange={this.dataChange}/> |
| | | </div> |
| | | <div className="user">制单人:{username}</div> |
| | | <Modal |
| | | title="备注" |
| | | visible={remarkVisible} |
| | | width={700} |
| | | maskClosable={false} |
| | | onOk={this.remarkSubmit} |
| | | onCancel={() => { this.setState({ remarkVisible: false })}} |
| | | destroyOnClose |
| | | > |
| | | <TextArea id={config.uuid + 'remark'} defaultValue={remark} rows={6}/> |
| | | </Modal> |
| | | </div> |
| | | ) |
| | | } |