| | |
| | | import React, {Component} from 'react' |
| | | import PropTypes from 'prop-types' |
| | | import { is, fromJS } from 'immutable' |
| | | import { Button, Select, Input, DatePicker, notification } from 'antd' |
| | | import { Button, Select, Input, Modal, DatePicker, notification, InputNumber, Dropdown } from 'antd' |
| | | import moment from 'moment' |
| | | |
| | | import Api from '@/api' |
| | | import asyncComponent from '@/utils/asyncComponent' |
| | | import Utils from '@/utils/utils.js' |
| | | import MKEmitter from '@/utils/events.js' |
| | | import VoucherTable from './voucherTable' |
| | | import SaveAsTemp from './saveAsTemp' |
| | | import ResetRemark from './resetRemark' |
| | | import ResetAttach from './resetAttach' |
| | | import LoadFromTemp from './loadFromTemp' |
| | | import './index.scss' |
| | | |
| | | const VoucherTable = asyncComponent(() => import('./voucherTable')) |
| | | const { confirm } = Modal |
| | | |
| | | class VoucherModule extends Component { |
| | | static propTpyes = { |
| | |
| | | |
| | | state = { |
| | | BID: '', |
| | | type: 'createVoucher', |
| | | config: null, |
| | | loading: false, |
| | | data: [], |
| | | disableAdd: false, |
| | | disableSave: false, |
| | | tbdata: [], |
| | | typeOptions: [], |
| | | charType: '', |
| | | charName: '', |
| | | charInt: '', |
| | | vouDate: null, |
| | | book: null, |
| | | username: sessionStorage.getItem('User_Name'), |
| | | change: false |
| | | remark: '', |
| | | attachments: 0, |
| | | vouAduited: false, |
| | | vouReadOnly: false, |
| | | attachlist: [], |
| | | oriAttachs: [], |
| | | tempTypes: [], |
| | | tempTypeClass: '', |
| | | tempTypeName: '', |
| | | title: '', |
| | | orgcode: '', |
| | | orgname: '', |
| | | status: '', // 新建时,empty、change、saved |
| | | saved: false, |
| | | voucherCode: '' |
| | | } |
| | | |
| | | UNSAFE_componentWillMount () { |
| | |
| | | |
| | | let BID = '' |
| | | let BData = '' |
| | | |
| | | |
| | | if (config.wrap.supModule) { |
| | | BData = window.GLOB.CacheData.get(config.wrap.supModule) |
| | | } else { |
| | |
| | | BID = BData.$BID || '' |
| | | } |
| | | |
| | | let book = null |
| | | let vouDate = null |
| | | if (config.wrap.supBook) { |
| | | book = window.GLOB.CacheData.get(config.wrap.supBook) || null |
| | | |
| | | if (book) { |
| | | let month = book.months |
| | | vouDate = moment() |
| | | |
| | | if (month && month < moment().format('YYYY-MM')) { |
| | | vouDate = moment(month, 'YYYY-MM').endOf('month') |
| | | } |
| | | } |
| | | } |
| | | |
| | | // config.wrap.type = 'checkVoucher' |
| | | // BID = '20230228173542370E2F4FC1773704C29A6A4' |
| | | |
| | | // config.wrap.type = 'checkTemp' |
| | | // BID = '20230214174458780MFR8IA576ON4VKNOLVH' |
| | | |
| | | window.GLOB.CacheVoucher.delete(config.uuid) |
| | | let type = config.wrap.type || 'createVoucher' |
| | | |
| | | if (type === 'createVoucher' || type === 'createTemp') { |
| | | BID = Utils.getguid() |
| | | } |
| | | |
| | | this.setState({ |
| | | book: book, |
| | | vouDate: vouDate, |
| | | config: fromJS(config).toJS(), |
| | | type: type, |
| | | BID: BID || '', |
| | | book: window.GLOB.CacheData.get(config.wrap.supBook) || null |
| | | status: 'empty' |
| | | }, () => { |
| | | this.loadData() |
| | | this.getVoucher() |
| | | }) |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | resetParentParam = (MenuID, id, data) => { |
| | | const { config } = this.state |
| | | const { config, type } = this.state |
| | | |
| | | if (config.wrap.supBook === MenuID) { |
| | | let month = data.months |
| | |
| | | |
| | | this.setState({ book: data, vouDate }, () => { |
| | | this.loadData() |
| | | this.getVoucher() |
| | | }) |
| | | return |
| | | } |
| | | |
| | | if (!config.wrap.supModule || config.wrap.supModule !== MenuID) return |
| | | if (!config.wrap.supModule || config.wrap.supModule !== MenuID || type === 'createVoucher' || type === 'createTemp') return |
| | | if (id !== this.state.BID || id !== '') { |
| | | this.setState({ BID: id, BData: data }, () => { |
| | | this.loadData() |
| | | this.setState({ BID: id }, () => { |
| | | this.getVoucher() |
| | | }) |
| | | } |
| | | } |
| | | |
| | | loadData = () => { |
| | | const { book, config } = this.state |
| | | const { book, config, type } = this.state |
| | | |
| | | 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') |
| | | // account_code: book.account_code || '', |
| | | fcc_date: book.months ? book.months + '-01' : moment().format('YYYY-MM-DD'), |
| | | account_year_code: book.account_year_code || '', |
| | | months: book.months ? book.months : moment().format('YYYY-MM'), |
| | | BID: book.id |
| | | } |
| | | |
| | | Api.genericInterface(param).then(res => { |
| | |
| | | } |
| | | |
| | | let typeOptions = res.char || [] |
| | | if (type === 'createVoucher') { |
| | | let charInt = typeOptions[0] ? typeOptions[0].voucher_char_int + 1 : 1 |
| | | |
| | | this.setState({ |
| | | typeOptions: typeOptions, |
| | | charType: typeOptions[0] ? typeOptions[0].voucher_class : '', |
| | | charInt: typeOptions[0] ? typeOptions[0].voucher_char_int : '', |
| | | }) |
| | | this.setState({ |
| | | typeOptions: typeOptions, |
| | | charType: typeOptions[0] ? typeOptions[0].voucher_class : '', |
| | | charName: typeOptions[0] ? typeOptions[0].voucher_char : '', |
| | | charInt: charInt, |
| | | orgcode: res.orgcode, |
| | | orgname: res.orgname, |
| | | tempTypes: res.temp_type || [] |
| | | }) |
| | | } else { |
| | | this.setState({ |
| | | typeOptions: typeOptions, |
| | | orgcode: res.orgcode, |
| | | orgname: res.orgname, |
| | | tempTypes: res.temp_type || [] |
| | | }) |
| | | } |
| | | |
| | | let names = {} |
| | | let supplier = [] |
| | |
| | | let inventory = [] |
| | | let employee = [] |
| | | let cash_flow = [] |
| | | let others = [] |
| | | let logistics = [] |
| | | let lessor = [] |
| | | |
| | | res.sup && res.sup.forEach(item => { |
| | | names[item.sup_type_code] = item.sup_type_name |
| | |
| | | |
| | | res.supplier && res.supplier.forEach(item => { |
| | | supplier.push({value: item.suppliercode, label: item.suppliername}) |
| | | }) |
| | | |
| | | res.logistics && res.logistics.forEach(item => { |
| | | logistics.push({value: item.logistics_code, label: item.logistics_name}) |
| | | }) |
| | | |
| | | res.lessor && res.lessor.forEach(item => { |
| | | lessor.push({value: item.lessor_code, label: item.lessor_name}) |
| | | }) |
| | | |
| | | res.customer && res.customer.forEach(item => { |
| | |
| | | cash_flow.push({value: item.cash_flow_code, label: item.cash_flow_name}) |
| | | }) |
| | | |
| | | res.others && res.others.forEach(item => { |
| | | others.push({value: item.sup_acc_code, label: item.sup_acc_name, parentId: item.sup_acc_type}) |
| | | }) |
| | | |
| | | let message = { |
| | | subjects: res.subjects || [], |
| | | names: names, |
| | | supplier: supplier, |
| | | logistics: logistics, |
| | | lessor: lessor, |
| | | customer: customer, |
| | | department: department, |
| | | project: project, |
| | | inventory: inventory, |
| | | currency: res.currency || [], |
| | | employee: employee, |
| | | cash_flow: cash_flow, |
| | | others: others, |
| | | account_code: res.account_code, |
| | | account_year_code: res.account_year_code |
| | | } |
| | | |
| | | window.GLOB.CacheVoucher.set(config.uuid, message) |
| | | |
| | | setTimeout(() => { |
| | | this.getVoucher() |
| | | }, 200) |
| | | }) |
| | | } |
| | | |
| | | |
| | | getVoucher = () => { |
| | | let data = [ |
| | | {remark: '提现', subjectscode: '1001', subjectsname: '库存现金', debtor: 124, creditor: ''}, |
| | | {remark: '购入固定资产', subjectscode: '1001', subjectsname: '库存现金', debtor: '', creditor: 124}, |
| | | {remark: '转结销售成本', subjectscode: '1001', subjectsname: '库存现金', debtor: -524, creditor: ''}, |
| | | {remark: '提现', subjectscode: '1001', subjectsname: '库存现金', debtor: 34, creditor: '', i: Math.random()}, |
| | | ] |
| | | const { book, BID, type } = this.state |
| | | |
| | | this.setState({ |
| | | data: data |
| | | if (!book || !BID || type === 'createVoucher' || type === 'createTemp') return |
| | | |
| | | let param = { |
| | | func: 's_get_fcc_voucher', |
| | | BID: book.id, |
| | | ID: BID |
| | | } |
| | | |
| | | if (type === 'checkTemp') { |
| | | param.func = 's_get_fcc_voucher_temp' |
| | | } |
| | | |
| | | Api.genericInterface(param).then(res => { |
| | | if (!res.status) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: res.message, |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } |
| | | |
| | | let data = [] |
| | | if (res.voucher) { |
| | | let disabled = res.voucher_status === 'true' |
| | | data = res.voucher.map(line => { |
| | | line.uuid = line.subject_id || '' |
| | | |
| | | if (line.direction_type === 'credit') { |
| | | line.credit = line.net_amount || 0 |
| | | line.debit = '' |
| | | } else { |
| | | line.debit = line.net_amount || 0 |
| | | line.credit = '' |
| | | } |
| | | |
| | | line.unitratio = line.foreign_unitratio || 0 |
| | | line.exratecode = line.foreign_exratecode || '' |
| | | line.exratename = line.foreign_exratename || '' |
| | | line.local_currency = line.local_exratecode || '' |
| | | line.foreign_currency_type = line.foreign_type || '' |
| | | line.$disabled = disabled |
| | | |
| | | if (line.sup) { |
| | | line.supAccounts = line.sup.map(cell => { |
| | | cell.uuid = cell.sup_id |
| | | return cell |
| | | }) |
| | | delete line.sup |
| | | } |
| | | |
| | | return line |
| | | }) |
| | | } |
| | | |
| | | if (type !== 'checkTemp') { |
| | | let files = [] |
| | | |
| | | res.fcc_files && res.fcc_files.forEach(file => { |
| | | file.attachments.forEach(item => { |
| | | item.id = item.attach_id |
| | | item.data_code = file.data_code |
| | | item.data_name = file.data_name |
| | | item.BID = file.id |
| | | |
| | | files.push(item) |
| | | }) |
| | | }) |
| | | |
| | | this.setState({ |
| | | data: data, |
| | | attachlist: files, |
| | | vouDate: res.fibvoucherdate ? moment(res.fibvoucherdate, 'YYYY-MM-DD') : null, |
| | | charType: res.voucher_class || 'keeping', |
| | | vouAduited: res.voucher_status === 'true' || res.read_only === 'true', |
| | | vouReadOnly: res.read_only === 'true', |
| | | charName: res.voucher_char, |
| | | charInt: res.voucher_char_int, |
| | | // orgcode: res.orgcode, |
| | | // orgname: res.orgname, |
| | | voucherCode: res.voucher_code || '', |
| | | tbdata: fromJS(data).toJS(), |
| | | oriAttachs: fromJS(files).toJS(), |
| | | attachments: res.attachments_int, |
| | | title: res.voucher_text || '', |
| | | remark: res.remark || '', |
| | | status: res.copy_type === 'true' ? 'copy' : 'saved' |
| | | }) |
| | | } else { |
| | | this.setState({ |
| | | data: data, |
| | | tbdata: fromJS(data).toJS(), |
| | | title: res.voucher_text || '', |
| | | tempTypeClass: res.typechartwo || '', |
| | | tempTypeName: res.typecharthree || '', |
| | | status: 'saved' |
| | | }) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | triggeradd = () => { |
| | | triggersave = (t) => { |
| | | const { tbdata } = this.state |
| | | |
| | | let err = '' |
| | | let tip = '' |
| | | let list = [] |
| | | |
| | | tbdata.forEach((line, index) => { |
| | | if (err) return |
| | | if (line.type === 'total') { |
| | | if (line.debit !== line.credit) { |
| | | err = '借贷不平衡!' |
| | | } |
| | | return |
| | | } |
| | | |
| | | let _index = index + 1 |
| | | |
| | | if (!line.subject_voucher_text && !line.subject_code && !line.debit && line.debit !== 0 && !line.credit && line.credit !== 0) { |
| | | if (_index === 1) { |
| | | err = '第1行不可为空。' |
| | | } |
| | | |
| | | return |
| | | } |
| | | |
| | | if (!line.subject_voucher_text) { |
| | | err = `第${_index}行,摘要不可为空。` |
| | | } else if (!line.subject_code) { |
| | | err = `第${_index}行,科目不可为空。` |
| | | } else if (!line.debit && line.debit !== 0 && !line.credit && line.credit !== 0) { |
| | | err = `第${_index}行,请输入金额。` |
| | | } else if (line.debit === 0 || line.credit === 0) { |
| | | err = `第${_index}行,金额不能为0。` |
| | | } else if (line.foreign_currency_type === 'Y' && !line.foreign_amount) { |
| | | err = `第${_index}行,原币不可为空或为0。` |
| | | } else if (line.sup_accounting && !line.supAccounts) { |
| | | err = `第${_index}行,请选择辅助核算。` |
| | | } else if (line.sup_accounting && line.supAccounts) { |
| | | line.supAccounts.forEach(item => { |
| | | if (item.sup_acc_type === 'supplier') { |
| | | if (!item.suppliercode || !item.suppliername) { |
| | | err = `第${_index}行,请选择辅助核算。` |
| | | } |
| | | } else if (item.sup_acc_type === 'logistics') { |
| | | if (!item.logistics_code || !item.logistics_name) { |
| | | err = `第${_index}行,请选择辅助核算。` |
| | | } |
| | | } else if (item.sup_acc_type === 'lessor') { |
| | | if (!item.lessor_code || !item.lessor_name) { |
| | | err = `第${_index}行,请选择辅助核算。` |
| | | } |
| | | } else if (item.sup_acc_type === 'customer') { |
| | | if (!item.customercode || !item.customername) { |
| | | err = `第${_index}行,请选择辅助核算。` |
| | | } |
| | | } else if (item.sup_acc_type === 'department') { |
| | | if (!item.co_pro_code || !item.co_pro_name) { |
| | | err = `第${_index}行,请选择辅助核算。` |
| | | } |
| | | } else if (item.sup_acc_type === 'project') { |
| | | if (!item.projectcode || !item.projectname) { |
| | | err = `第${_index}行,请选择辅助核算。` |
| | | } |
| | | } else if (item.sup_acc_type === 'inventory') { |
| | | if (!item.productcode || !item.productname) { |
| | | err = `第${_index}行,请选择辅助核算。` |
| | | } |
| | | } else if (item.sup_acc_type === 'employee') { |
| | | if (!item.workercode || !item.workername) { |
| | | err = `第${_index}行,请选择辅助核算。` |
| | | } |
| | | } else if (item.sup_acc_type === 'cash_flow') { |
| | | if (!item.cash_flow_code || !item.cash_flow_name) { |
| | | err = `第${_index}行,请选择辅助核算。` |
| | | } |
| | | } else if (!item.sup_acc_type || !item.sup_acc_code || !item.sup_acc_name) { |
| | | err = `第${_index}行,请选择辅助核算。` |
| | | } |
| | | }) |
| | | } |
| | | |
| | | if (line.count_type === 'Y' && !err) { |
| | | if (!line.fcc_count) { |
| | | tip += `第${_index}行,数量为空或为0!;` |
| | | } else if (line.net_unitprice) { |
| | | if (line.debit && line.debit !== line.fcc_count * line.net_unitprice) { |
| | | tip += `第${_index}行,数量和金额不匹配!;` |
| | | } else if (line.credit && line.credit !== line.fcc_count * line.net_unitprice) { |
| | | tip += `第${_index}行,数量和金额不匹配!;` |
| | | } |
| | | } |
| | | } |
| | | |
| | | list.push(line) |
| | | }) |
| | | |
| | | if (!err && list.length === 0) { |
| | | err = '第1行不可为空。' |
| | | } |
| | | |
| | | if (err) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: err, |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } |
| | | |
| | | if (tip) { |
| | | const that = this |
| | | confirm({ |
| | | content: tip + '确认要保存吗?', |
| | | onOk() { |
| | | that.voucherSave(list, t) |
| | | }, |
| | | onCancel() {} |
| | | }) |
| | | } else { |
| | | this.voucherSave(list, t) |
| | | } |
| | | } |
| | | |
| | | voucherSave = (list, t) => { |
| | | const { type, BID, data, config, voucherCode, charInt, charType, vouDate, book, remark, charName, attachments, title, orgcode, orgname, attachlist, oriAttachs } = this.state |
| | | |
| | | let err = '' |
| | | if (!book) { |
| | | err = '请选择账套!' |
| | | } else if (!vouDate) { |
| | | err = '请选择日期!' |
| | | } else if (!charName || !charInt) { |
| | | err = '请选择凭证号!' |
| | | } |
| | | |
| | | if (err) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: err, |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } |
| | | |
| | | let param = { |
| | | func: 's_fcc_voucher_addupt', |
| | | BID: book.id, |
| | | ID: BID, |
| | | voucher_code: voucherCode || '', |
| | | voucher_text: title, |
| | | remark: remark, |
| | | account_year_code: book.account_year_code || '', |
| | | voucher_type: config.wrap.voucherType || '', |
| | | voucher_type_text: config.wrap.voucherTypeText || '', |
| | | orgcode: orgcode || '', |
| | | orgname: orgname || '', |
| | | voucher_class: charType, |
| | | years: book.years, |
| | | months: moment(vouDate).format('YYYY-MM'), |
| | | business_type: config.wrap.businessType || '', |
| | | voucher_sign: config.wrap.voucherSign || '', |
| | | voucher_char: charName, |
| | | voucher_char_int: charInt, |
| | | account_code: book.account_code || '', |
| | | fibvoucherdate: moment(vouDate).format('YYYY-MM-DD'), |
| | | UserName: sessionStorage.getItem('User_Name') || '', |
| | | FullName: sessionStorage.getItem('Full_Name') || '', |
| | | attachments_int: attachments, |
| | | sup_data: '', |
| | | subject_data: '', |
| | | attachments_data: '' |
| | | } |
| | | |
| | | // id,deleted |
| | | // 附件列表 |
| | | |
| | | // 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 |
| | | |
| | | // sup_id,sup_voucher_code,sup_voucher_lp,voucher_sup_lp,sup_subject_code,sup_subject_name,sup_voucher_text,sup_direction_type,sup_net_amount,customercode,customername,suppliercode,suppliername,co_pro_code,co_pro_name,workercode,workername,project_code,project_name,productcode,productname,cash_flow_code,cash_flow_name,sup_acc_code,sup_acc_name,sup_acc_type,sup_bid,deleted |
| | | // 辅助科目行id,新增时空,凭证行号空,辅助科目行号空,科目编码,科目名称,辅助科目摘要空,方向'debit'、'credit',行金额,客户编码,客户名称,供应商编码,供应商名称,部门编码,部门名称,职员编码,职员名称,项目编码,项目名称,产品编码,产品名称,现金编码,现金名称,自定义科目编码,自定义科目名称,辅助科目类型,凭证行ID,删除标记 |
| | | |
| | | let sup_data = [] |
| | | let voucherMap = new Map() |
| | | let supMap = new Map() |
| | | let extract = localStorage.getItem(window.GLOB.sysSign + '_voucher_extract') |
| | | extract = extract ? JSON.parse(extract) : [] |
| | | |
| | | data.forEach(item => { |
| | | voucherMap.set(item.uuid, item) |
| | | |
| | | if (item.sup_accounting && item.supAccounts) { |
| | | item.supAccounts.forEach(cell => { |
| | | if (!cell.sup_acc_type) return |
| | | |
| | | let _cell = {...cell} |
| | | |
| | | _cell.sup_voucher_code = item.subject_voucher_code || '' |
| | | _cell.sup_voucher_lp = item.voucher_lp || '' |
| | | _cell.sup_subject_code = item.subject_code || '' |
| | | _cell.sup_subject_name = item.subject_name || '' |
| | | _cell.sup_bid = item.uuid || '' |
| | | _cell.sup_direct = item.debit ? 'debit' : 'credit' |
| | | _cell.sup_net_amount = item.debit || item.credit |
| | | |
| | | supMap.set(item.uuid + cell.sup_acc_type, _cell) |
| | | }) |
| | | } |
| | | }) |
| | | |
| | | let subject_data = list.map(item => { |
| | | let count = item.count_type === 'Y' |
| | | let curr = item.foreign_currency_type === 'Y' |
| | | let direct = item.debit ? 'debit' : 'credit' |
| | | |
| | | if (type === 'createVoucher' && item.subject_voucher_text && item.subject_voucher_text.length < 20) { |
| | | extract.unshift(item.subject_voucher_text) |
| | | } |
| | | |
| | | if (voucherMap.has(item.uuid)) { |
| | | voucherMap.delete(item.uuid) |
| | | } |
| | | if (item.sup_accounting && item.supAccounts) { |
| | | item.supAccounts.forEach(n => { |
| | | if (supMap.has(item.uuid + n.sup_acc_type)) { |
| | | supMap.delete(item.uuid + n.sup_acc_type) |
| | | } |
| | | |
| | | sup_data.push(`'${n.uuid}','${item.subject_voucher_code || ''}','${item.voucher_lp || ''}','${n.voucher_sup_lp || ''}','${item.subject_code}','${item.subject_name}','${n.sup_voucher_text || ''}','${direct}',${item.debit || item.credit},'${n.customercode || ''}','${n.customername || ''}','${n.suppliercode || ''}','${n.suppliername || ''}','${n.co_pro_code || ''}','${n.co_pro_name || ''}','${n.workercode || ''}','${n.workername || ''}','${n.project_code || ''}','${n.project_name || ''}','${n.productcode || ''}','${n.productname || ''}','${n.cash_flow_code || ''}','${n.cash_flow_name || ''}','${n.sup_acc_code || ''}','${n.sup_acc_name || ''}','${n.sup_acc_type || ''}','${item.uuid}',0,'${n.lessor_code || ''}','${n.lessor_name || ''}','${n.logistics_code || ''}','${n.logistics_name || ''}'`) |
| | | }) |
| | | } |
| | | return `'${item.uuid}','${item.subject_voucher_code || ''}','${item.voucher_lp || ''}','${item.subject_code}','${item.subject_name}','${item.subject_voucher_text || ''}',${count ? item.fcc_count || 0 : 0},${count ? item.net_unitprice || 0 : 0},'${item.unit}',${item.debit || item.credit},'${direct}','${curr ? item.exratecode : ''}','${curr ? item.exratename : ''}',${curr ? item.unitratio || 0 : 0},'${item.sup_accounting}',${item.debit ? 1 : -1},${curr ? item.foreign_amount || 0 : 0},0,'${item.local_currency || ''}','${count ? 'Y' : ''}','${curr ? 'Y' : ''}','${item.closing_foreign_exchange || ''}'` |
| | | }) |
| | | |
| | | if (type === 'createVoucher') { |
| | | extract = Array.from(new Set(extract)) |
| | | if (extract.length > 20) { |
| | | extract.length = 20 |
| | | } |
| | | localStorage.setItem(window.GLOB.sysSign + '_voucher_extract', JSON.stringify(extract)) |
| | | } |
| | | |
| | | voucherMap.forEach(item => { |
| | | let count = item.count_type === 'Y' |
| | | let curr = item.foreign_currency_type === 'Y' |
| | | let direct = item.debit ? 'debit' : 'credit' |
| | | |
| | | subject_data.push(`'${item.uuid}','${item.subject_voucher_code || ''}','${item.voucher_lp || ''}','${item.subject_code}','${item.subject_name}','${item.subject_voucher_text || ''}',${count ? item.fcc_count || 0 : 0},${count ? item.net_unitprice || 0 : 0},'${item.unit}',${item.debit || item.credit},'${direct}','${curr ? item.exratecode : ''}','${curr ? item.exratename : ''}',${curr ? item.unitratio || 0 : 0},'${item.sup_accounting}',${item.debit ? 1 : -1},${curr ? item.foreign_amount || 0 : 0},1,'${item.local_currency || ''}','${count ? 'Y' : ''}','${curr ? 'Y' : ''}','${item.closing_foreign_exchange || ''}'`) |
| | | }) |
| | | |
| | | supMap.forEach(n => { |
| | | sup_data.push(`'${n.uuid}','${n.sup_voucher_code}','${n.sup_voucher_lp}','${n.voucher_sup_lp || ''}','${n.sup_subject_code}','${n.sup_subject_name}','${n.sup_voucher_text || ''}','${n.sup_direct}',${n.sup_net_amount},'${n.customercode || ''}','${n.customername || ''}','${n.suppliercode || ''}','${n.suppliername || ''}','${n.co_pro_code || ''}','${n.co_pro_name || ''}','${n.workercode || ''}','${n.workername || ''}','${n.project_code || ''}','${n.project_name || ''}','${n.productcode || ''}','${n.productname || ''}','${n.cash_flow_code || ''}','${n.cash_flow_name || ''}','${n.sup_acc_code || ''}','${n.sup_acc_name || ''}','${n.sup_acc_type || ''}','${n.sup_bid}',1,'${n.lessor_code || ''}','${n.lessor_name || ''}','${n.logistics_code || ''}','${n.logistics_name || ''}'`) |
| | | }) |
| | | |
| | | let attachments_data = [] |
| | | let ids = [] |
| | | |
| | | attachlist.forEach(item => { |
| | | ids.push(item.id) |
| | | |
| | | attachments_data.push(`'${item.id}',0`) |
| | | }) |
| | | |
| | | if (oriAttachs.length > 0) { |
| | | oriAttachs.forEach(item => { |
| | | if (!ids.includes(item.id)) { |
| | | attachments_data.push(`'${item.id}',1`) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | param.subject_data = window.btoa(window.encodeURIComponent(subject_data.join(';un'))) |
| | | param.sup_data = window.btoa(window.encodeURIComponent(sup_data.join(';un'))) |
| | | param.attachments_data = window.btoa(window.encodeURIComponent(attachments_data.join(';un'))) |
| | | |
| | | Api.genericInterface(param).then(res => { |
| | | if (!res.status) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: res.message, |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } |
| | | |
| | | notification.success({ |
| | | top: 92, |
| | | message: '保存成功!' + (res.voucher_char_int !== charInt ? charInt + '号凭证号已经存在,已为您更新为' + res.voucher_char_int + '号凭证。' : ''), |
| | | duration: 5 |
| | | }) |
| | | |
| | | if (t === 'add') { |
| | | this.setState({ |
| | | status: 'empty', |
| | | remark: '', |
| | | tbdata: [], |
| | | oriAttachs: fromJS(attachlist).toJS(), |
| | | charInt: res.voucher_char_int + 1, |
| | | 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(), |
| | | oriAttachs: fromJS(attachlist).toJS(), |
| | | saved: true |
| | | }) |
| | | } |
| | | |
| | | let tabId = '' |
| | | if (config.wrap.linkmenu && config.wrap.linkmenu.length > 0) { |
| | | tabId = config.wrap.linkmenu[config.wrap.linkmenu.length - 1] |
| | | } |
| | | |
| | | if (tabId) { |
| | | MKEmitter.emit('reloadMenuView', tabId) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | triggersave = () => { |
| | | triggerTempsave = (name, typeChar, typeName) => { |
| | | const { tbdata } = this.state |
| | | |
| | | let err = '' |
| | | let list = [] |
| | | |
| | | tbdata.forEach((line, index) => { |
| | | if (err) return |
| | | |
| | | let _index = index + 1 |
| | | |
| | | if (!line.subject_voucher_text && !line.subject_code) { |
| | | if (_index === 1) { |
| | | err = '第1行不可为空。' |
| | | } |
| | | |
| | | return |
| | | } |
| | | |
| | | if (!line.subject_voucher_text) { |
| | | err = `第${_index}行,摘要不可为空。` |
| | | } else if (!line.subject_code) { |
| | | err = `第${_index}行,科目不可为空。` |
| | | } else if (line.sup_accounting && !line.supAccounts) { |
| | | err = `第${_index}行,请选择辅助核算。` |
| | | } else if (line.sup_accounting && line.supAccounts) { |
| | | line.supAccounts.forEach(item => { |
| | | if (item.sup_acc_type === 'supplier') { |
| | | if (!item.suppliercode || !item.suppliername) { |
| | | err = `第${_index}行,请选择辅助核算。` |
| | | } |
| | | } else if (item.sup_acc_type === 'logistics') { |
| | | if (!item.logistics_code || !item.logistics_name) { |
| | | err = `第${_index}行,请选择辅助核算。` |
| | | } |
| | | } else if (item.sup_acc_type === 'lessor') { |
| | | if (!item.lessor_code || !item.lessor_name) { |
| | | err = `第${_index}行,请选择辅助核算。` |
| | | } |
| | | } else if (item.sup_acc_type === 'customer') { |
| | | if (!item.customercode || !item.customername) { |
| | | err = `第${_index}行,请选择辅助核算。` |
| | | } |
| | | } else if (item.sup_acc_type === 'department') { |
| | | if (!item.co_pro_code || !item.co_pro_name) { |
| | | err = `第${_index}行,请选择辅助核算。` |
| | | } |
| | | } else if (item.sup_acc_type === 'project') { |
| | | if (!item.projectcode || !item.projectname) { |
| | | err = `第${_index}行,请选择辅助核算。` |
| | | } |
| | | } else if (item.sup_acc_type === 'inventory') { |
| | | if (!item.productcode || !item.productname) { |
| | | err = `第${_index}行,请选择辅助核算。` |
| | | } |
| | | } else if (item.sup_acc_type === 'employee') { |
| | | if (!item.workercode || !item.workername) { |
| | | err = `第${_index}行,请选择辅助核算。` |
| | | } |
| | | } else if (item.sup_acc_type === 'cash_flow') { |
| | | if (!item.cash_flow_code || !item.cash_flow_name) { |
| | | err = `第${_index}行,请选择辅助核算。` |
| | | } |
| | | } else if (!item.sup_acc_type || !item.sup_acc_code || !item.sup_acc_name) { |
| | | err = `第${_index}行,请选择辅助核算。` |
| | | } |
| | | }) |
| | | } |
| | | |
| | | list.push(line) |
| | | }) |
| | | |
| | | if (!err && list.length === 0) { |
| | | err = '第1行不可为空。' |
| | | } |
| | | |
| | | if (err) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: err, |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } |
| | | |
| | | this.voucherTempSave(list, name, typeChar, typeName) |
| | | } |
| | | |
| | | triggerprint = () => { |
| | | voucherTempSave = (list, name, typeChar, typeName) => { |
| | | const { type, config, BID, data, book, title, orgcode, orgname, tempTypeClass, tempTypeName } = this.state |
| | | |
| | | if (!book) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '请选择账套!', |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } else if (type !== 'createVoucher' && !title) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '请填写模板名称!', |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } else if (type !== 'createVoucher' && !tempTypeClass) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '请选择模板类型!', |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } |
| | | |
| | | let id = BID |
| | | let _name = title |
| | | let _typeChar = tempTypeClass |
| | | let _typeName = tempTypeName |
| | | |
| | | if (type === 'createVoucher') { |
| | | id = Utils.getguid() |
| | | _name = name |
| | | _typeChar = typeChar |
| | | _typeName = typeName |
| | | } |
| | | |
| | | let param = { |
| | | func: 's_fcc_voucher_addupt_temp', |
| | | BID: book.id, |
| | | ID: id, |
| | | voucher_code: '', |
| | | voucher_text: _name, |
| | | remark: '', |
| | | account_year_code: book.account_year_code || '', |
| | | voucher_type: 'fcc_temp', |
| | | voucher_type_text: '凭证模板', |
| | | orgcode: orgcode || '', |
| | | orgname: orgname || '', |
| | | voucher_class: 'temp', |
| | | years: book.years, |
| | | months: moment().format('YYYY-MM'), |
| | | business_type: '', |
| | | voucher_sign: 'temp', |
| | | voucher_char: '', |
| | | voucher_char_int: 0, |
| | | account_code: book.account_code || '', |
| | | fibvoucherdate: moment().format('YYYY-MM-DD'), |
| | | UserName: sessionStorage.getItem('User_Name') || '', |
| | | FullName: sessionStorage.getItem('Full_Name') || '', |
| | | attachments_int: 0, |
| | | typechartwo: _typeChar, |
| | | typecharthree: _typeName, |
| | | sup_data: '', |
| | | subject_data: '' |
| | | } |
| | | |
| | | let sup_data = [] |
| | | let voucherMap = new Map() |
| | | let supMap = new Map() |
| | | |
| | | if (type !== 'createVoucher') { |
| | | data.forEach(item => { |
| | | voucherMap.set(item.uuid, item) |
| | | |
| | | if (item.sup_accounting && item.supAccounts) { |
| | | item.supAccounts.forEach(cell => { |
| | | if (!cell.sup_acc_type) return |
| | | |
| | | let _cell = {...cell} |
| | | |
| | | _cell.sup_voucher_code = item.subject_voucher_code || '' |
| | | _cell.sup_voucher_lp = item.voucher_lp || '' |
| | | _cell.sup_subject_code = item.subject_code || '' |
| | | _cell.sup_subject_name = item.subject_name || '' |
| | | _cell.sup_bid = item.uuid || '' |
| | | _cell.sup_direct = !item.credit ? 'debit' : 'credit' |
| | | _cell.sup_net_amount = item.debit || item.credit || 0 |
| | | |
| | | supMap.set(item.uuid + cell.sup_acc_type, _cell) |
| | | }) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | let subject_data = list.map(item => { |
| | | let count = item.count_type === 'Y' |
| | | let curr = item.foreign_currency_type === 'Y' |
| | | let direct = !item.credit ? 'debit' : 'credit' |
| | | |
| | | if (voucherMap.has(item.uuid)) { |
| | | voucherMap.delete(item.uuid) |
| | | } |
| | | if (item.sup_accounting && item.supAccounts) { |
| | | item.supAccounts.forEach(n => { |
| | | if (supMap.has(item.uuid + n.sup_acc_type)) { |
| | | supMap.delete(item.uuid + n.sup_acc_type) |
| | | } |
| | | |
| | | sup_data.push(`'${n.uuid}','${item.subject_voucher_code || ''}','${item.voucher_lp || ''}','${n.voucher_sup_lp || ''}','${item.subject_code}','${item.subject_name}','${n.sup_voucher_text || ''}','${direct}',${item.debit || item.credit || 0},'${n.customercode || ''}','${n.customername || ''}','${n.suppliercode || ''}','${n.suppliername || ''}','${n.co_pro_code || ''}','${n.co_pro_name || ''}','${n.workercode || ''}','${n.workername || ''}','${n.project_code || ''}','${n.project_name || ''}','${n.productcode || ''}','${n.productname || ''}','${n.cash_flow_code || ''}','${n.cash_flow_name || ''}','${n.sup_acc_code || ''}','${n.sup_acc_name || ''}','${n.sup_acc_type || ''}','${item.uuid}',0,'${n.lessor_code || ''}','${n.lessor_name || ''}','${n.logistics_code || ''}','${n.logistics_name || ''}'`) |
| | | }) |
| | | } |
| | | return `'${item.uuid}','${item.subject_voucher_code || ''}','${item.voucher_lp || ''}','${item.subject_code}','${item.subject_name}','${item.subject_voucher_text || ''}',${count ? item.fcc_count || 0 : 0},${count ? item.net_unitprice || 0 : 0},'${item.unit}',${item.debit || item.credit || 0},'${direct}','${curr ? item.exratecode : ''}','${curr ? item.exratename : ''}',${curr ? item.unitratio || 0 : 0},'${item.sup_accounting}',${item.direct ? 1 : -1},${curr ? item.foreign_amount || 0 : 0},0,'${item.local_currency || ''}','${count ? 'Y' : ''}','${curr ? 'Y' : ''}','${item.closing_foreign_exchange || ''}'` |
| | | }) |
| | | |
| | | voucherMap.forEach(item => { |
| | | let count = item.count_type === 'Y' |
| | | let curr = item.foreign_currency_type === 'Y' |
| | | let direct = !item.credit ? 'debit' : 'credit' |
| | | |
| | | subject_data.push(`'${item.uuid}','${item.subject_voucher_code || ''}','${item.voucher_lp || ''}','${item.subject_code}','${item.subject_name}','${item.subject_voucher_text || ''}',${count ? item.fcc_count || 0 : 0},${count ? item.net_unitprice || 0 : 0},'${item.unit}',${item.debit || item.credit || 0},'${direct}','${curr ? item.exratecode : ''}','${curr ? item.exratename : ''}',${curr ? item.unitratio || 0 : 0},'${item.sup_accounting}',${item.direct ? 1 : -1},${curr ? item.foreign_amount || 0 : 0},1,'${item.local_currency || ''}','${count ? 'Y' : ''}','${curr ? 'Y' : ''}','${item.closing_foreign_exchange || ''}'`) |
| | | }) |
| | | |
| | | supMap.forEach(n => { |
| | | sup_data.push(`'${n.uuid}','${n.sup_voucher_code}','${n.sup_voucher_lp}','${n.voucher_sup_lp || ''}','${n.sup_subject_code}','${n.sup_subject_name}','${n.sup_voucher_text || ''}','${n.sup_direct}',${n.sup_net_amount},'${n.customercode || ''}','${n.customername || ''}','${n.suppliercode || ''}','${n.suppliername || ''}','${n.co_pro_code || ''}','${n.co_pro_name || ''}','${n.workercode || ''}','${n.workername || ''}','${n.project_code || ''}','${n.project_name || ''}','${n.productcode || ''}','${n.productname || ''}','${n.cash_flow_code || ''}','${n.cash_flow_name || ''}','${n.sup_acc_code || ''}','${n.sup_acc_name || ''}','${n.sup_acc_type || ''}','${n.sup_bid}',1,'${n.lessor_code || ''}','${n.lessor_name || ''}','${n.logistics_code || ''}','${n.logistics_name || ''}'`) |
| | | }) |
| | | |
| | | param.subject_data = window.btoa(window.encodeURIComponent(subject_data.join(';un'))) |
| | | param.sup_data = window.btoa(window.encodeURIComponent(sup_data.join(';un'))) |
| | | |
| | | Api.genericInterface(param).then(res => { |
| | | if (!res.status) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: res.message, |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } |
| | | |
| | | notification.success({ |
| | | top: 92, |
| | | message: '保存成功!', |
| | | duration: 5 |
| | | }) |
| | | |
| | | if (type !== 'createVoucher') { |
| | | this.setState({ |
| | | status: 'saved', |
| | | data: fromJS(list).toJS(), |
| | | }) |
| | | } |
| | | |
| | | let tabId = '' |
| | | if (config.wrap.linkmenu && config.wrap.linkmenu.length > 0) { |
| | | tabId = config.wrap.linkmenu[config.wrap.linkmenu.length - 1] |
| | | } |
| | | |
| | | if (tabId) { |
| | | MKEmitter.emit('reloadMenuView', tabId) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | dataChange = (data) => { |
| | | 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, status: 'change'}) |
| | | } |
| | | |
| | | changeVouDate = (val) => { |
| | | const { type, status, saved } = this.state |
| | | |
| | | this.setState({vouDate: val, status: 'change'}) |
| | | |
| | | 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) |
| | | }) |
| | | } |
| | | |
| | | resetAttachList = (vals) => { |
| | | const { attachlist } = this.state |
| | | let num = this.state.attachments |
| | | |
| | | if (num) { |
| | | num = num + (vals.length - attachlist.length) |
| | | } else { |
| | | num = vals.length |
| | | } |
| | | |
| | | if (num < 0) { |
| | | num = 0 |
| | | } |
| | | |
| | | this.setState({status: 'change', attachlist: vals, attachments: num}) |
| | | } |
| | | |
| | | triggerclose = () => { |
| | | const { config, status } = this.state |
| | | |
| | | if (status === 'change') { |
| | | confirm({ |
| | | content: '内容已变更,确定要关闭吗?', |
| | | onOk() { |
| | | MKEmitter.emit('closeTabView', config.$pageId) |
| | | }, |
| | | onCancel() {} |
| | | }) |
| | | } else { |
| | | MKEmitter.emit('closeTabView', config.$pageId) |
| | | } |
| | | } |
| | | |
| | | triggerTempLoad = (id) => { |
| | | const { book } = this.state |
| | | |
| | | if (!book) return |
| | | |
| | | let param = { |
| | | func: 's_get_fcc_voucher_temp', |
| | | BID: book.id, |
| | | ID: id |
| | | } |
| | | |
| | | Api.genericInterface(param).then(res => { |
| | | if (!res.status) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: res.message, |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } |
| | | |
| | | let data = [] |
| | | if (res.voucher) { |
| | | data = res.voucher.map(line => { |
| | | line.uuid = line.subject_id || '' |
| | | |
| | | if (line.direction_type === 'credit') { |
| | | line.credit = line.net_amount || 0 |
| | | line.debit = '' |
| | | } else { |
| | | line.debit = line.net_amount || 0 |
| | | line.credit = '' |
| | | } |
| | | |
| | | line.unitratio = line.foreign_unitratio || 0 |
| | | line.exratecode = line.foreign_exratecode || '' |
| | | line.exratename = line.foreign_exratename || '' |
| | | line.local_currency = line.local_exratecode || '' |
| | | line.foreign_currency_type = line.foreign_type || '' |
| | | |
| | | if (line.sup) { |
| | | line.supAccounts = line.sup.map(cell => { |
| | | cell.uuid = cell.sup_id |
| | | return cell |
| | | }) |
| | | delete line.sup |
| | | } |
| | | |
| | | return line |
| | | }) |
| | | } |
| | | |
| | | this.setState({ |
| | | data: data, |
| | | tbdata: fromJS(data).toJS(), |
| | | status: 'change' |
| | | }) |
| | | }) |
| | | } |
| | | |
| | | triggerPrint = () => { |
| | | const { config, BID } = this.state |
| | | |
| | | if (!config.wrap.printTemp) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '尚未设置打印模板!', |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } |
| | | |
| | | window.open('#/billprint/' + window.btoa(window.encodeURIComponent(JSON.stringify({ id: BID, tempId: config.wrap.printTemp, pageId: config.$pageId || '', dataM: sessionStorage.getItem('dataM') })))) |
| | | } |
| | | |
| | | triggerAduit = () => { |
| | | const { book, BID, voucherCode, username } = this.state |
| | | |
| | | if (!book) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '请选择账套!', |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } |
| | | |
| | | let param = { |
| | | func: 's_fcc_voucher_sub', |
| | | ID: BID, |
| | | status: 10, |
| | | statusname: '已审核', |
| | | voucher_code: voucherCode || '', |
| | | username: username, |
| | | fullname: sessionStorage.getItem('Full_Name') || '' |
| | | } |
| | | |
| | | const that = this |
| | | |
| | | confirm({ |
| | | content: '确定要审核吗?', |
| | | onOk() { |
| | | Api.genericInterface(param).then(res => { |
| | | if (!res.status) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: res.message, |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } |
| | | |
| | | notification.success({ |
| | | top: 92, |
| | | message: '已经通过审核', |
| | | duration: 2 |
| | | }) |
| | | |
| | | that.getVoucher() |
| | | }) |
| | | }, |
| | | onCancel() {} |
| | | }) |
| | | } |
| | | |
| | | triggerUnAduit = () => { |
| | | const { book, BID, voucherCode, username } = this.state |
| | | |
| | | if (!book) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '请选择账套!', |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } |
| | | |
| | | let param = { |
| | | func: 's_fcc_voucher_sub', |
| | | ID: BID, |
| | | status: 0, |
| | | statusname: '取消审核', |
| | | voucher_code: voucherCode || '', |
| | | username: username, |
| | | fullname: sessionStorage.getItem('Full_Name') || '' |
| | | } |
| | | |
| | | const that = this |
| | | |
| | | confirm({ |
| | | content: '确认要取消审核吗?', |
| | | onOk() { |
| | | Api.genericInterface(param).then(res => { |
| | | if (!res.status) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: res.message, |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } |
| | | |
| | | notification.success({ |
| | | top: 92, |
| | | message: '审核已取消', |
| | | duration: 2 |
| | | }) |
| | | |
| | | that.getVoucher() |
| | | }) |
| | | }, |
| | | onCancel() {} |
| | | }) |
| | | } |
| | | |
| | | render() { |
| | | const { config, disableSave, disableAdd, typeOptions, charType, charInt, data, vouDate, username } = this.state |
| | | const { type, status, loading, config, orgcode, typeOptions, tempTypes, charType, charInt, data, vouDate, username, remark, attachments, title, attachlist, tempTypeClass, vouAduited, vouReadOnly, voucherCode } = this.state |
| | | |
| | | return ( |
| | | <div className="menu-voucher-wrap" style={config.style}> |
| | | <div className="voucher-header"> |
| | | <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="out-background header-btn" disabled={disableSave} onClick={this.triggerprint}>导出</Button> |
| | | if (type === 'checkVoucher') { |
| | | return ( |
| | | <div className="menu-voucher-wrap" style={config.style}> |
| | | <div className="voucher-header" style={{padding: `10px ${config.wrap.space || 0}px`}}> |
| | | {!vouAduited ? <Button disabled={status === 'empty' || status === 'saved'} onClick={() => this.triggersave()}>保存</Button> : null} |
| | | {/* <PrintVoucher ID={config.uuid + 'print'} data={data} orgname={orgname} vouDate={vouDate} charName={charName} charInt={charInt} attachments={attachments} disabled={status !== 'saved'}/> */} |
| | | <Button disabled={status !== 'saved'} onClick={this.triggerPrint}>打印</Button> |
| | | {vouAduited && !vouReadOnly ? <Button onClick={this.triggerUnAduit}>取消审核</Button> : null} |
| | | {!vouAduited && !vouReadOnly ? <Button onClick={this.triggerAduit}>审核</Button> : null} |
| | | <Button onClick={this.triggerclose}>关闭</Button> |
| | | </div> |
| | | <div className="voucher-body" style={{padding: `0px ${config.wrap.space || 0}px`}}> |
| | | <div className="pre-wrap"> |
| | | <div className="voucher-number"> |
| | | 凭证号:{voucherCode} |
| | | </div> |
| | | <div className="voucher-code"> |
| | | <Select value={charType} disabled={vouAduited} dropdownClassName="mk-vcode-dropdown" onChange={(val, option) => this.setState({status: 'change', charType: val, charName: option.props.charname, charInt: option.props.charint})}> |
| | | {typeOptions.map(option => |
| | | <Select.Option key={option.id} value={option.voucher_class} charname={option.voucher_char} charint={option.voucher_char_int}>{option.voucher_char}</Select.Option> |
| | | )} |
| | | </Select> |
| | | <InputNumber precision={0} min={1} disabled={vouAduited} value={charInt} autoComplete="off" onChange={(val) => this.setState({status: 'change', charInt: val})}/> 号 |
| | | </div> |
| | | <div className="voucher-date"> |
| | | 日期:<DatePicker value={vouDate} disabled={vouAduited} onChange={this.changeVouDate}/> |
| | | </div> |
| | | <div className="voucher-text"> |
| | | <Input value={title} placeholder={vouAduited ? '' : '凭证文本'} disabled={vouAduited} autoComplete="off" onChange={(e) => this.setState({status: 'change', title: e.target.value})}/> |
| | | </div> |
| | | <div className="voucher-affix"> |
| | | 附单据 <InputNumber precision={0} disabled={vouAduited} value={attachments || 0} autoComplete="off" onChange={this.changeAttach}/> 张 |
| | | <ResetAttach config={config} disabled={vouAduited} orgcode={orgcode} voucherCode={this.state.voucherCode} attachlist={attachlist} onChange={this.resetAttachList}/> |
| | | <ResetRemark remark={remark} disabled={vouAduited} ID={config.uuid + 'remark'} onChange={(val) => this.setState({status: 'change', remark: val})}/> |
| | | </div> |
| | | </div> |
| | | <VoucherTable config={config} loading={loading} data={data} onChange={this.dataChange}/> |
| | | </div> |
| | | <div className="user" style={{paddingLeft: `${config.wrap.space || 0}px`}}>制单人:{username}</div> |
| | | </div> |
| | | {config.wrap.type === 'edit' ? <div className="voucher-body"> |
| | | <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})}> |
| | | {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> |
| | | <Input value={charInt} autoComplete="off" onChange={(e) => this.setState({charInt: e.target.value})}/> 号 |
| | | </div> |
| | | <div className="voucher-date"> |
| | | 日期:<DatePicker value={vouDate} onChange={(val) => this.setState({vouDate: val})}/> |
| | | </div> |
| | | <div className="voucher-affix"> |
| | | 附单据 <Input autoComplete="off" /> 张 |
| | | <Button type="link" className="" onClick={this.triggerprint}>附件</Button> |
| | | <Button type="link" className="" onClick={this.triggerprint}>备注</Button> |
| | | </div> |
| | | ) |
| | | } else if (type === 'createVoucher') { |
| | | return ( |
| | | <div className="menu-voucher-wrap" style={config.style}> |
| | | <div className="voucher-header" style={{padding: `10px ${config.wrap.space || 0}px`}}> |
| | | <Button disabled={status === 'empty'} onClick={() => this.triggersave('add')}>保存并新增</Button> |
| | | <Button disabled={status === 'empty' || status === 'saved'} onClick={() => this.triggersave()}>保存</Button> |
| | | <Button disabled={status !== 'saved'} onClick={this.triggerPrint}>打印</Button> |
| | | <Dropdown overlay={<div className="mk-voucher-dropdown-wrap"> |
| | | <SaveAsTemp tempTypes={tempTypes} onChange={this.triggerTempsave}/> |
| | | <div className="split"></div> |
| | | <LoadFromTemp tempTypes={tempTypes} onChange={this.triggerTempLoad}/> |
| | | </div>} trigger={['hover']} placement="bottomCenter"> |
| | | <Button>更多</Button> |
| | | </Dropdown> |
| | | </div> |
| | | <VoucherTable config={config} data={data}/> |
| | | </div> : null} |
| | | {config.wrap.type === 'check' ? <div className="voucher-body"> |
| | | <div className="pre-wrap"> |
| | | <div className="voucher-code"> |
| | | 记 1 号 |
| | | <div className="voucher-body" style={{padding: `0px ${config.wrap.space || 0}px`}}> |
| | | <div className="pre-wrap"> |
| | | <div className="voucher-code"> |
| | | <Select value={charType} dropdownClassName="mk-vcode-dropdown" onChange={(val, option) => this.setState({status: 'change', charType: val, charName: option.props.charname, charInt: option.props.charint})}> |
| | | {typeOptions.map(option => |
| | | <Select.Option key={option.id} value={option.voucher_class} charname={option.voucher_char} charint={option.voucher_char_int}>{option.voucher_char}</Select.Option> |
| | | )} |
| | | </Select> |
| | | <InputNumber precision={0} min={1} value={charInt} autoComplete="off" onChange={(val) => this.setState({status: 'change', charInt: val})}/> 号 |
| | | </div> |
| | | <div className="voucher-date"> |
| | | 日期:<DatePicker value={vouDate} onChange={this.changeVouDate}/> |
| | | </div> |
| | | <div className="voucher-text"> |
| | | <Input value={title} placeholder="凭证文本" autoComplete="off" onChange={(e) => this.setState({status: 'change', title: e.target.value})}/> |
| | | </div> |
| | | <div className="voucher-affix"> |
| | | 附单据 <InputNumber precision={0} value={attachments || 0} autoComplete="off" onChange={this.changeAttach}/> 张 |
| | | <ResetAttach config={config} orgcode={orgcode} voucherCode={this.state.voucherCode} attachlist={attachlist} onChange={this.resetAttachList}/> |
| | | <ResetRemark remark={remark} ID={config.uuid + 'remark'} onChange={(val) => this.setState({status: 'change', remark: val})}/> |
| | | </div> |
| | | </div> |
| | | <div className="voucher-date"> |
| | | 日期:2022-02-24 |
| | | </div> |
| | | <div className="voucher-affix"> |
| | | 附单据 2 张 |
| | | <Button type="link" className="" onClick={this.triggerprint}>附件</Button> |
| | | <Button type="link" className="" onClick={this.triggerprint}>备注</Button> |
| | | </div> |
| | | <VoucherTable config={config} loading={loading} data={data} onChange={this.dataChange}/> |
| | | </div> |
| | | <VoucherTable config={config} data={data}/> |
| | | </div> : null} |
| | | <div className="user">制单人:{username}</div> |
| | | </div> |
| | | ) |
| | | <div className="user" style={{paddingLeft: `${config.wrap.space || 0}px`}}>制单人:{username}</div> |
| | | </div> |
| | | ) |
| | | } else { |
| | | return ( |
| | | <div className="menu-voucher-wrap" style={config.style}> |
| | | <div className="voucher-body" style={{padding: `0px ${config.wrap.space || 0}px`}}> |
| | | <div className="pre-temp-wrap"> |
| | | <div className="temp-text"> |
| | | <span>模板名称:</span><Input value={title} placeholder="模板名称" autoComplete="off" onChange={(e) => this.setState({title: e.target.value})}/> |
| | | </div> |
| | | <div className="temp-text"> |
| | | <span>模板类型:</span> |
| | | <Select value={tempTypeClass} dropdownClassName="mk-vcode-dropdown" onChange={(val, option) => this.setState({tempTypeClass: val, tempTypeName: option.props.children})}> |
| | | {tempTypes.map(option => |
| | | <Select.Option key={option.data_code} value={option.data_code}>{option.data_name}</Select.Option> |
| | | )} |
| | | </Select> |
| | | </div> |
| | | <div className="temp-action"> |
| | | <Button onClick={() => this.triggerTempsave()}>保存</Button> |
| | | <Button onClick={this.triggerclose}>关闭</Button> |
| | | </div> |
| | | </div> |
| | | <VoucherTable config={config} loading={loading} data={data} onChange={this.dataChange}/> |
| | | </div> |
| | | </div> |
| | | ) |
| | | } |
| | | } |
| | | } |
| | | |