From 6f817bf3ae4e6f51f982c07b0713adb3caf9fac2 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期四, 02 二月 2023 17:14:16 +0800 Subject: [PATCH] 2023-02-02 --- src/tabviews/custom/components/module/voucher/index.jsx | 178 ++++++++++++++++++++++++++++++++++++++++------------------ 1 files changed, 122 insertions(+), 56 deletions(-) diff --git a/src/tabviews/custom/components/module/voucher/index.jsx b/src/tabviews/custom/components/module/voucher/index.jsx index aeafbc9..af58823 100644 --- a/src/tabviews/custom/components/module/voucher/index.jsx +++ b/src/tabviews/custom/components/module/voucher/index.jsx @@ -1,10 +1,11 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' import { is, fromJS } from 'immutable' -import { Button, Select, Input, Modal, DatePicker, notification } from 'antd' +import { Button, Select, Input, Modal, DatePicker, notification, InputNumber } from 'antd' import moment from 'moment' import Api from '@/api' +import Utils from '@/utils/utils.js' import asyncComponent from '@/utils/asyncComponent' import MKEmitter from '@/utils/events.js' import './index.scss' @@ -27,12 +28,16 @@ tbdata: [], typeOptions: [], charType: '', + charName: '', charInt: '', vouDate: null, book: null, username: sessionStorage.getItem('User_Name'), remark: '', remarkVisible: false, + attachments: 0, + title: '', + delItems: [], status: '' // 鏂板缓鏃讹紝empty銆乧hange銆乻aved } @@ -116,8 +121,9 @@ 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') + // account_code: book.account_code || '', + fcc_date: book.months ? book.months + '-01' : moment().format('YYYY-MM-DD'), + BID: book.id } Api.genericInterface(param).then(res => { @@ -135,6 +141,7 @@ this.setState({ typeOptions: typeOptions, charType: typeOptions[0] ? typeOptions[0].voucher_class : '', + charName: typeOptions[0] ? typeOptions[0].voucher_char : '', charInt: typeOptions[0] ? typeOptions[0].voucher_char_int : '', }) @@ -187,8 +194,13 @@ department: department, project: project, inventory: inventory, + currency: res.currency || [], employee: employee, cash_flow: cash_flow, + orgcode: res.orgcode, + orgname: res.orgname, + account_code: res.account_code, + account_year_code: res.account_year_code } window.GLOB.CacheVoucher.set(config.uuid, message) @@ -230,11 +242,12 @@ } triggersave = (t) => { - const { tbdata } = this.state + const { tbdata, delItems } = this.state let err = '' let tip = '' let list = [] + let _Items = [...delItems] tbdata.forEach((line, index) => { if (err) return @@ -250,7 +263,10 @@ if (!line.remark && !line.subjectscode && !line.debtor && line.debtor !== 0 && !line.creditor && line.creditor !== 0) { if (_index === 1) { err = '绗�1琛屼笉鍙负绌恒��' + } else if (line.$origin) { + _Items.push(line) } + return } @@ -262,6 +278,8 @@ err = `绗�${_index}琛岋紝璇疯緭鍏ラ噾棰濄�俙 } else if (line.debtor === 0 || line.creditor === 0) { err = `绗�${_index}琛岋紝閲戦涓嶈兘涓�0銆俙 + } else if (line.foreign_currency_type === 'Y' && !line.origin) { + err = `绗�${_index}琛岋紝鍘熷竵涓嶅彲涓虹┖鎴栦负0銆俙 } else if (line.sup_accounting) { line.sup_accounting.split(',').forEach(item => { if (!line[item]) { @@ -303,17 +321,17 @@ confirm({ content: tip + '纭瑕佷繚瀛樺悧锛�', onOk() { - _this.voucherSave(list, t) + _this.voucherSave(list, _Items, t) }, onCancel() {} }) } else { - this.voucherSave(list, t) + this.voucherSave(list, _Items, t) } } - voucherSave = (list, t) => { - const { BID, config, charInt, charType, vouDate, book, remark } = this.state + voucherSave = (list, items, t) => { + const { config, charInt, charType, vouDate, book, remark, charName, attachments, title } = this.state if (!book) { notification.warning({ @@ -324,59 +342,84 @@ return } + let message = window.GLOB.CacheVoucher.get(config.uuid) || {} + let param = { func: 's_fcc_voucher_addupt', - BID: BID, + BID: book.id, + ID: Utils.getguid(), voucher_code: '', - voucher_text: '', + voucher_text: title, remark: remark, - account_year_code: '', - voucher_type: '', - voucher_type_text: '', - orgcode: '', - orgname: '', - voucher_class: '', + account_year_code: book.account_year_code || '', + voucher_type: config.wrap.voucherType || '', + voucher_type_text: config.wrap.voucherTypeText || '', + orgcode: message.orgcode || '', + orgname: message.orgname || '', + voucher_class: charType, years: book.years, - business_type: '', - voucher_sign: '', - voucher_char: charType, + business_type: config.wrap.businessType || '', + voucher_sign: config.wrap.voucherSign || '', + voucher_char: charName, voucher_char_int: charInt, account_code: book.account_code || '', - fibvoucherdate: vouDate, + fibvoucherdate: moment(vouDate).format('YYYY-MM-DD'), UserName: sessionStorage.getItem('User_Name') || '', FullName: sessionStorage.getItem('Full_Name') || '', + attachments_int: attachments, sup_data: '', subject_data: '' } - console.log(list) - console.log(param) - console.log(config) + // subject_id,subject_voucher_code,voucher_lp,subject_code,subject_name + // ,subject_voucher_text,fcc_count,net_unitprice,unit,net_amount,direction_type + // ,exratecode,exratename,unitratio,sup_accounting ,direction_type_count,src_amount,deleted,local_exratecode + + let subject_data = list.map(item => { + let count = item.count_type === 'Y' + let curr = item.foreign_currency_type === 'Y' + return `${item.uuid},'','','${item.subjectscode}','${item.subjectsname}','${item.remark}',${count ? item.count || 0 : 0},${count ? item.price || 0 : 0},'${item.unit}',${item.debtor || item.creditor},'${item.debtor ? 'debit' : 'credit'}','${curr ? item.exratecode : '01010001'}','${curr ? item.exratename : 'CNY'}',${curr ? item.unitratio || 0 : 0},'${item.sup_accounting}',${item.debtor ? 1 : -1},${curr ? item.origin || 0 : 0},0,'${item.local_currency || ''}'` + }) - // Api.genericInterface(param).then(res => { - // if (!res.status) { - // notification.warning({ - // top: 92, - // message: res.message, - // duration: 5 - // }) - // return - // } + items.forEach(item => { + let count = item.count_type === 'Y' + let curr = item.foreign_currency_type === 'Y' + subject_data.push(`${item.uuid},'','','${item.subjectscode}','${item.subjectsname}','${item.remark}',${count ? item.count || 0 : 0},${count ? item.price || 0 : 0},'${item.unit}',${item.debtor || item.creditor},'${item.debtor ? 'debit' : 'credit'}','${curr ? item.exratecode : '01010001'}','${curr ? item.exratename : 'CNY'}',${curr ? item.unitratio || 0 : 0},'${item.sup_accounting}',${item.debtor ? 1 : -1},${curr ? item.origin || 0 : 0},1,'${item.local_currency || ''}'`) + }) - // if (t === 'add') { - // this.setState({ - // status: 'empty', - // remark: '', - // tbdata: [], - // charInt: charInt + 1 - // }) - // MKEmitter.emit('cleartable', config.uuid) - // } else { - // this.setState({ - // status: 'saved' - // }) - // } - // }) + param.subject_data = window.btoa(window.encodeURIComponent(subject_data.join(';un'))) + + if (param) { + console.log(param) + return + } + + Api.genericInterface(param).then(res => { + if (!res.status) { + notification.warning({ + top: 92, + message: res.message, + duration: 5 + }) + return + } + + if (t === 'add') { + this.setState({ + status: 'empty', + remark: '', + tbdata: [], + delItems: [], + charInt: charInt + 1 + }) + MKEmitter.emit('cleartable', config.uuid) + } else { + this.setState({ + status: 'saved', + delItems: [], + }) + } + }) } triggerprint = () => { @@ -399,15 +442,35 @@ this.setState({remark: val, remarkVisible: false}) } - dataChange = (data) => { - this.setState({ - status: 'change', - tbdata: data - }) + dataChange = (data, item) => { + if (item) { + this.setState({ + status: 'change', + tbdata: data, + delItems: [...this.state.delItems, item] + }) + } else { + this.setState({ + status: 'change', + tbdata: data + }) + } + } + + changeAttach = (val) => { + let _val = val + + if (isNaN(val) || val < 0) { + _val = 0 + } else { + _val = parseInt(val) + } + + this.setState({attachments: _val}) } render() { - const { type, status, loading, config, typeOptions, charType, charInt, data, vouDate, username, remark, remarkVisible } = this.state + const { type, status, loading, config, typeOptions, charType, charInt, data, vouDate, username, remark, remarkVisible, attachments, title } = this.state return ( <div className="menu-voucher-wrap" style={config.style}> @@ -420,18 +483,21 @@ <div className="voucher-body"> {type === 'createVoucher' ? <div className="pre-wrap"> <div className="voucher-code"> - <Select value={charType} dropdownClassName="mk-vcode-dropdown" onChange={(val, option) => this.setState({charType: val, charInt: option.props.charint})}> + <Select value={charType} dropdownClassName="mk-vcode-dropdown" onChange={(val, option) => this.setState({charType: val, charName: option.props.charName, charInt: option.props.charint})}> {typeOptions.map(option => - <Select.Option key={option.voucher_char_int} value={option.voucher_class} charint={option.voucher_char_int}>{option.voucher_char}</Select.Option> + <Select.Option key={option.voucher_char_int} value={option.voucher_class} charName={option.voucher_char} charint={option.voucher_char_int}>{option.voucher_char}</Select.Option> )} </Select> - <Input value={charInt} autoComplete="off" onChange={(e) => this.setState({charInt: e.target.value})}/> 鍙� + <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})}/> </div> + <div className="voucher-text"> + <Input value={title} placeholder="鍑瘉鏂囨湰" autoComplete="off" onChange={(e) => this.setState({title: e.target.value})}/> + </div> <div className="voucher-affix"> - 闄勫崟鎹� <Input autoComplete="off" /> 寮� + 闄勫崟鎹� <InputNumber precision={0} value={attachments || 0} autoComplete="off" onChange={this.changeAttach}/> 寮� <Button type="link" className="" onClick={this.triggerprint}>闄勪欢</Button> <Button type="link" className="" onClick={this.triggerprint}>澶囨敞</Button> </div> -- Gitblit v1.8.0