From 253fbcbdd06f6354e857a8e1e47ddf116459df42 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期五, 10 二月 2023 17:43:58 +0800 Subject: [PATCH] 2023-02-10 --- src/tabviews/custom/components/module/voucher/index.jsx | 461 +++++++++++++++++++++++++++++++++++++++++++-------------- 1 files changed, 344 insertions(+), 117 deletions(-) diff --git a/src/tabviews/custom/components/module/voucher/index.jsx b/src/tabviews/custom/components/module/voucher/index.jsx index af58823..80c4e62 100644 --- a/src/tabviews/custom/components/module/voucher/index.jsx +++ b/src/tabviews/custom/components/module/voucher/index.jsx @@ -11,8 +11,9 @@ 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 = { @@ -34,11 +35,13 @@ book: null, username: sessionStorage.getItem('User_Name'), remark: '', - remarkVisible: false, attachments: 0, + attachlist: [], title: '', - delItems: [], - status: '' // 鏂板缓鏃讹紝empty銆乧hange銆乻aved + orgcode: '', + orgname: '', + status: '', // 鏂板缓鏃讹紝empty銆乧hange銆乻aved + saved: false } UNSAFE_componentWillMount () { @@ -56,16 +59,40 @@ 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') + } + } + } + window.GLOB.CacheVoucher.delete(config.uuid) let type = config.wrap.type || 'createVoucher' + // type = 'checkVoucher' + // BID = '202302081418373862P8Q29OUD19CT1AVMU6' + + if (type === 'createVoucher' || type === 'createTemp') { + BID = Utils.getguid() + } + this.setState({ + book: book, + vouDate: vouDate, config: fromJS(config).toJS(), type: type, BID: BID || '', - status: 'empty', - book: window.GLOB.CacheData.get(config.wrap.supBook) || null + status: 'empty' }, () => { + this.loadData() this.getVoucher() }) } @@ -90,7 +117,7 @@ } resetParentParam = (MenuID, id, data) => { - const { config } = this.state + const { config, type } = this.state if (config.wrap.supBook === MenuID) { let month = data.months @@ -102,20 +129,21 @@ 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.setState({ BID: id }, () => { this.getVoucher() }) } } loadData = () => { - const { book, config } = this.state + const { book, config, type } = this.state if (!book) return @@ -123,6 +151,8 @@ func: 's_get_fcc_account_data', // 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 } @@ -137,13 +167,22 @@ } 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 : '', - charName: typeOptions[0] ? typeOptions[0].voucher_char : '', - 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, + }) + } else { + this.setState({ + typeOptions: typeOptions + }) + } let names = {} let supplier = [] @@ -153,6 +192,7 @@ let inventory = [] let employee = [] let cash_flow = [] + let others = [] res.sup && res.sup.forEach(item => { names[item.sup_type_code] = item.sup_type_name @@ -186,6 +226,10 @@ 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, @@ -197,8 +241,7 @@ currency: res.currency || [], employee: employee, cash_flow: cash_flow, - orgcode: res.orgcode, - orgname: res.orgname, + others: others, account_code: res.account_code, account_year_code: res.account_year_code } @@ -208,21 +251,15 @@ } getVoucher = () => { - const { BID, type } = this.state + const { book, BID, type } = this.state - if (!BID || type === 'createVoucher' || type === 'createTemp') return + if (!book || !BID || type === 'createVoucher' || type === 'createTemp') return let param = { func: 's_get_fcc_voucher', - BID: BID + BID: book.id, + ID: BID } - - 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()}, - ] Api.genericInterface(param).then(res => { if (!res.status) { @@ -234,25 +271,62 @@ 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() + vouDate: res.fibvoucherdate ? moment(res.fibvoucherdate, 'YYYY-MM-DD') : null, + charType: res.voucher_class, + charName: res.voucher_char, + charInt: res.voucher_char_int, + orgcode: res.orgcode, + orgname: res.orgname, + tbdata: fromJS(data).toJS(), + status: 'saved' }) }) } triggersave = (t) => { - const { tbdata, delItems } = this.state + const { tbdata } = this.state let err = '' let tip = '' let list = [] - let _Items = [...delItems] tbdata.forEach((line, index) => { if (err) return if (line.type === 'total') { - if (line.debtor !== line.creditor) { + if (line.debit !== line.credit) { err = '鍊熻捶涓嶅钩琛★紒' } return @@ -260,41 +334,69 @@ let _index = index + 1 - if (!line.remark && !line.subjectscode && !line.debtor && line.debtor !== 0 && !line.creditor && line.creditor !== 0) { + if (!line.subject_voucher_text && !line.subject_code && !line.debit && line.debit !== 0 && !line.credit && line.credit !== 0) { if (_index === 1) { err = '绗�1琛屼笉鍙负绌恒��' - } else if (line.$origin) { - _Items.push(line) } return } - if (!line.remark) { + if (!line.subject_voucher_text) { err = `绗�${_index}琛岋紝鎽樿涓嶅彲涓虹┖銆俙 - } else if (!line.subjectscode) { + } else if (!line.subject_code) { err = `绗�${_index}琛岋紝绉戠洰涓嶅彲涓虹┖銆俙 - } else if (!line.debtor && line.debtor !== 0 && !line.creditor && line.creditor !== 0) { + } else if (!line.debit && line.debit !== 0 && !line.credit && line.credit !== 0) { err = `绗�${_index}琛岋紝璇疯緭鍏ラ噾棰濄�俙 - } else if (line.debtor === 0 || line.creditor === 0) { + } else if (line.debit === 0 || line.credit === 0) { err = `绗�${_index}琛岋紝閲戦涓嶈兘涓�0銆俙 - } else if (line.foreign_currency_type === 'Y' && !line.origin) { + } else if (line.foreign_currency_type === 'Y' && !line.foreign_amount) { err = `绗�${_index}琛岋紝鍘熷竵涓嶅彲涓虹┖鎴栦负0銆俙 - } else if (line.sup_accounting) { - line.sup_accounting.split(',').forEach(item => { - if (!line[item]) { + } 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 === '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.count) { + if (!line.fcc_count) { tip += `绗�${_index}琛岋紝鏁伴噺涓虹┖鎴栦负0锛侊紱` - } else if (line.price) { - if (line.debtor && line.debtor !== line.count * line.price) { + } else if (line.net_unitprice) { + if (line.debit && line.debit !== line.fcc_count * line.net_unitprice) { tip += `绗�${_index}琛岋紝鏁伴噺鍜岄噾棰濅笉鍖归厤锛侊紱` - } else if (line.creditor && line.creditor !== line.count * line.price) { + } else if (line.credit && line.credit !== line.fcc_count * line.net_unitprice) { tip += `绗�${_index}琛岋紝鏁伴噺鍜岄噾棰濅笉鍖归厤锛侊紱` } } @@ -321,28 +423,35 @@ confirm({ content: tip + '纭瑕佷繚瀛樺悧锛�', onOk() { - _this.voucherSave(list, _Items, t) + _this.voucherSave(list, t) }, onCancel() {} }) } else { - this.voucherSave(list, _Items, t) + this.voucherSave(list, t) } } - voucherSave = (list, items, t) => { - const { config, charInt, charType, vouDate, book, remark, charName, attachments, title } = this.state + 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 } - - let message = window.GLOB.CacheVoucher.get(config.uuid) || {} let param = { func: 's_fcc_voucher_addupt', @@ -354,10 +463,11 @@ account_year_code: book.account_year_code || '', voucher_type: config.wrap.voucherType || '', voucher_type_text: config.wrap.voucherTypeText || '', - orgcode: message.orgcode || '', - orgname: message.orgname || '', + 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, @@ -368,31 +478,93 @@ FullName: sessionStorage.getItem('Full_Name') || '', attachments_int: attachments, sup_data: '', - subject_data: '' + subject_data: '', + attachments_data: '' } - // subject_id,subject_voucher_code,voucher_lp,subject_code,subject_name - // ,subject_voucher_text,fcc_count,net_unitprice,unit,net_amount,direction_type + // 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 + // 杈呭姪绉戠洰琛宨d锛屾柊澧炴椂绌猴紝鍑瘉琛屽彿绌猴紝杈呭姪绉戠洰琛屽彿绌猴紝绉戠洰缂栫爜锛岀鐩悕绉帮紝杈呭姪绉戠洰鎽樿绌猴紝鏂瑰悜'debit'銆�'credit'锛岃閲戦锛屽鎴风紪鐮侊紝瀹㈡埛鍚嶇О锛屼緵搴斿晢缂栫爜锛屼緵搴斿晢鍚嶇О锛岄儴闂ㄧ紪鐮侊紝閮ㄩ棬鍚嶇О锛岃亴鍛樼紪鐮侊紝鑱屽憳鍚嶇О锛岄」鐩紪鐮侊紝椤圭洰鍚嶇О锛屼骇鍝佺紪鐮侊紝浜у搧鍚嶇О锛岀幇閲戠紪鐮侊紝鐜伴噾鍚嶇О锛岃嚜瀹氫箟绉戠洰缂栫爜锛岃嚜瀹氫箟绉戠洰鍚嶇О锛岃緟鍔╃鐩被鍨嬶紝鍑瘉琛孖D锛屽垹闄ゆ爣璁� + + let sup_data = [] + let voucherMap = new Map() + let supMap = new Map() + let extract = localStorage.getItem(window.GLOB.host + '_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' - 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 || ''}'` + 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`) + }) + } + 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 : '01010001'}','${curr ? item.exratename : 'CNY'}',${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' : ''}'` }) - items.forEach(item => { + if (type === 'createVoucher') { + extract = Array.from(new Set(extract)) + if (extract.length > 20) { + extract.length = 20 + } + localStorage.setItem(window.GLOB.host + '_voucher_extract', JSON.stringify(extract)) + } + + voucherMap.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 || ''}'`) + 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 : '01010001'}','${curr ? item.exratename : 'CNY'}',${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' : ''}'`) + }) + + 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`) }) param.subject_data = window.btoa(window.encodeURIComponent(subject_data.join(';un'))) - - if (param) { - console.log(param) - return - } + param.sup_data = window.btoa(window.encodeURIComponent(sup_data.join(';un'))) Api.genericInterface(param).then(res => { if (!res.status) { @@ -404,57 +576,42 @@ 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: [], - delItems: [], - charInt: charInt + 1 + charInt: res.voucher_char_int + 1, + BID: Utils.getguid(), + saved: false }) MKEmitter.emit('cleartable', config.uuid) } else { this.setState({ status: 'saved', - delItems: [], + charInt: res.voucher_char_int || charInt, + 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, item) => { - if (item) { - this.setState({ - status: 'change', - tbdata: data, - delItems: [...this.state.delItems, item] - }) - } else { - this.setState({ - status: 'change', - tbdata: data - }) - } + dataChange = (data) => { + this.setState({ + status: 'change', + tbdata: data + }) } changeAttach = (val) => { @@ -469,8 +626,84 @@ 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 = () => { + + } + + triggerclose = () => { + + } + 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}> @@ -478,10 +711,15 @@ <Button className="add-background header-btn" disabled={status === 'empty'} onClick={() => this.triggersave('add')}>淇濆瓨骞舵柊澧�</Button> <Button className="add-background header-btn" disabled={status === 'empty' || status === 'saved'} onClick={() => this.triggersave()}>淇濆瓨</Button> <Button className="print-background header-btn" disabled={status !== 'saved'} onClick={this.triggerprint}>鎵撳嵃</Button> - <Button className="out-background header-btn" onClick={this.triggerprint}>鏇村</Button> + <Button className="out-background header-btn" onClick={this.triggermore}>鏇村</Button> + </div> : null} + {type === 'checkVoucher' ? <div className="voucher-header"> + <Button className="add-background header-btn" disabled={status === 'empty' || status === 'saved'} onClick={() => this.triggersave()}>淇濆瓨</Button> + <Button className="print-background header-btn" disabled={status !== 'saved'} onClick={this.triggerprint}>鎵撳嵃</Button> + <Button className="out-background header-btn" onClick={this.triggerclose}>鍏抽棴</Button> </div> : null} <div className="voucher-body"> - {type === 'createVoucher' ? <div className="pre-wrap"> + {type === 'createVoucher' || type === 'checkVoucher' ? <div className="pre-wrap"> <div className="voucher-code"> <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 => @@ -491,31 +729,20 @@ <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.triggerprint}>闄勪欢</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> ) } -- Gitblit v1.8.0