| | |
| | | subAccounts.forEach(item => { |
| | | if (item.field === 'supplier') { |
| | | account[item.field] = {suppliercode: item.value, suppliername: item.name} |
| | | } else if (item.field === 'logistics') { |
| | | account[item.field] = {logistics_code: item.value, logistics_name: item.name} |
| | | } else if (item.field === 'lessor') { |
| | | account[item.field] = {lessor_code: item.value, lessor_name: item.name} |
| | | } else if (item.field === 'customer') { |
| | | account[item.field] = {customercode: item.value, customername: item.name} |
| | | } else if (item.field === 'department') { |
| | |
| | | let line = {...record} |
| | | line[col.field] = value |
| | | |
| | | if (col.field === 'subject_voucher_text') { |
| | | MKEmitter.emit('changeRecord', col.tableId, line) |
| | | |
| | | setTimeout(() => { |
| | | let cl = {subject_voucher_text: 'subject_code', subject_code: 'debit', debit: 'credit'} |
| | | MKEmitter.emit('tdFocus', cl[col.uuid] + record.uuid) |
| | | }, 50) |
| | | return |
| | | } |
| | | |
| | | if (col.field === 'debit') { |
| | | line.credit = '' |
| | | if (isNaN(line.debit)) { |
| | |
| | | |
| | | setTimeout(() => { |
| | | if (col.field === 'debit' && (line.debit || line.debit === 0)) { |
| | | MKEmitter.emit('nextLine', col, record) |
| | | MKEmitter.emit('nextVoucher', col, record) |
| | | } else if (col.field === 'credit') { |
| | | MKEmitter.emit('nextLine', col, record) |
| | | MKEmitter.emit('nextVoucher', col, record) |
| | | } else { |
| | | let cl = {subject_voucher_text: 'subject_code', subject_code: 'debit', debit: 'credit'} |
| | | MKEmitter.emit('tdFocus', cl[col.uuid] + record.uuid) |
| | |
| | | |
| | | if (value !== record[col.field]) { |
| | | let line = {...record, [col.field]: value} |
| | | |
| | | if (col.field === 'subject_voucher_text') { |
| | | MKEmitter.emit('changeRecord', col.tableId, line) |
| | | return |
| | | } |
| | | |
| | | if (col.field === 'debit') { |
| | | line.credit = '' |
| | |
| | | MKEmitter.emit('plusLine', col.tableId, record) |
| | | } |
| | | |
| | | delRecord = () => { |
| | | delVoucher = () => { |
| | | const { col, record } = this.props |
| | | |
| | | MKEmitter.emit('delRecord', col.tableId, record) |
| | | MKEmitter.emit('delVoucher', col.tableId, record) |
| | | } |
| | | |
| | | onSelectBlur = () => { |
| | |
| | | if (record.type === 'total') { |
| | | children = <div className="content-wrap" style={{lineHeight: '60px'}}>合计: {val}</div> |
| | | colSpan = 2 |
| | | } else { |
| | | } else if (record.$disabled) { |
| | | children = <div className="content-wrap">{val}</div> |
| | | } else { |
| | | extra = <PlusOutlined onClick={this.plusLine}/> |
| | | |
| | | if (editing) { |
| | | let options = localStorage.getItem(window.GLOB.host + '_voucher_extract') |
| | | let options = localStorage.getItem(window.GLOB.sysSign + '_voucher_extract') |
| | | options = options ? JSON.parse(options) : [] |
| | | |
| | | children = <AutoComplete |
| | |
| | | if (record.sup_accounting && record.supAccounts) { |
| | | record.supAccounts.forEach(item => { |
| | | if (item.sup_acc_type === 'supplier') { |
| | | val += item.suppliercode ? '_' + item.suppliercode : '' |
| | | val += item.suppliercode ? '_' + item.suppliercode + ' ' + item.suppliername : '' |
| | | } else if (item.sup_acc_type === 'logistics') { |
| | | val += item.logistics_code ? '_' + item.logistics_code + ' ' + item.logistics_name : '' |
| | | } else if (item.sup_acc_type === 'lessor') { |
| | | val += item.lessor_code ? '_' + item.lessor_code + ' ' + item.lessor_name : '' |
| | | } else if (item.sup_acc_type === 'customer') { |
| | | val += item.customercode ? '_' + item.customercode : '' |
| | | val += item.customercode ? '_' + item.customercode + ' ' + item.customername : '' |
| | | } else if (item.sup_acc_type === 'department') { |
| | | val += item.co_pro_code ? '_' + item.co_pro_code : '' |
| | | val += item.co_pro_code ? '_' + item.co_pro_code + ' ' + item.co_pro_name : '' |
| | | } else if (item.sup_acc_type === 'project') { |
| | | val += item.projectcode ? '_' + item.projectcode : '' |
| | | val += item.projectcode ? '_' + item.projectcode + ' ' + item.projectname : '' |
| | | } else if (item.sup_acc_type === 'inventory') { |
| | | val += item.productcode ? '_' + item.productcode : '' |
| | | val += item.productcode ? '_' + item.productcode + ' ' + item.productname : '' |
| | | } else if (item.sup_acc_type === 'employee') { |
| | | val += item.workercode ? '_' + item.workercode : '' |
| | | val += item.workercode ? '_' + item.workercode + ' ' + item.workername : '' |
| | | } else if (item.sup_acc_type === 'cash_flow') { |
| | | val += item.cash_flow_code ? '_' + item.cash_flow_code : '' |
| | | val += item.cash_flow_code ? '_' + item.cash_flow_code + ' ' + item.cash_flow_name : '' |
| | | } else if (item.sup_acc_code) { |
| | | val += '_' + item.sup_acc_code |
| | | val += '_' + item.sup_acc_code + ' ' + item.sup_acc_name |
| | | } |
| | | }) |
| | | } |
| | |
| | | <span onClick={(e) => e.stopPropagation()}> |
| | | <span>单价:</span> |
| | | <span><InputNumber precision={4} className="inner-input" id={col.uuid + record.uuid + 'price'} defaultValue={record.net_unitprice || 0} onChange={(val) => this.onChange(val)} onPressEnter={this.pricePress} onBlur={this.priceBlur}/></span> |
| | | </span> |
| | | </div> |
| | | } else if (record.$disabled) { |
| | | countNode = <div className="count-wrap"> |
| | | <span style={{marginRight: '5px'}}> |
| | | <span>数量:</span> |
| | | <span>{record.fcc_count || 0}</span> |
| | | </span> |
| | | <span> |
| | | <span>单价:</span> |
| | | <span>{record.net_unitprice || 0}</span> |
| | | </span> |
| | | </div> |
| | | } else { |
| | |
| | | <span><InputNumber precision={2} className="inner-input" id={col.uuid + record.uuid + 'origin'} defaultValue={record.foreign_amount || 0} onChange={(val) => this.onChange(val)} onPressEnter={this.originPress} onBlur={this.originBlur}/></span> |
| | | </span> |
| | | </div> |
| | | } else if (record.$disabled) { |
| | | currencyNode = <div className="count-wrap"> |
| | | <span style={{marginRight: '5px'}}> |
| | | <span>货币:</span> |
| | | <span>{record.exratename || ''}</span> |
| | | </span> |
| | | <span style={{marginRight: '5px'}}> |
| | | <span>汇率:</span> |
| | | <span>{record.unitratio || 1}</span> |
| | | </span> |
| | | <span> |
| | | <span>原币:</span> |
| | | <span>{record.foreign_amount || 0}</span> |
| | | </span> |
| | | </div> |
| | | } else { |
| | | currencyNode = <div className="count-wrap"> |
| | | <span style={{marginRight: '5px'}} onClick={this.editCurrency}> |
| | |
| | | } |
| | | } |
| | | |
| | | children = <div className="content-wrap" onClick={this.focus}> |
| | | {val} |
| | | {countNode} |
| | | {currencyNode} |
| | | </div> |
| | | if (record.$disabled) { |
| | | children = <div className="content-wrap"> |
| | | {val} |
| | | {countNode} |
| | | {currencyNode} |
| | | </div> |
| | | } else { |
| | | children = <div className="content-wrap" onClick={this.focus}> |
| | | {val} |
| | | {countNode} |
| | | {currencyNode} |
| | | </div> |
| | | } |
| | | } |
| | | } |
| | | } else if (col.field === 'debit') { |
| | |
| | | } |
| | | vals = (val * 100).toFixed(0).split('').reverse() |
| | | } |
| | | children = <div className={'money-uint' + (down ? ' down' : '')} onClick={this.focus}> |
| | | <span>{vals[10] || ''}</span> <span>{vals[9] || ''}</span> <span>{vals[8] || ''}</span> <span>{vals[7] || ''}</span> <span>{vals[6] || ''}</span> <span>{vals[5] || ''}</span> |
| | | <span>{vals[4] || ''}</span> <span>{vals[3] || ''}</span> <span>{vals[2] || ''}</span> <span>{vals[1] || ''}</span> <span className="last">{vals[0] || ''}</span> |
| | | </div> |
| | | |
| | | if (record.$disabled) { |
| | | children = <div className={'money-uint' + (down ? ' down' : '')}> |
| | | <span>{vals[10] || ''}</span> <span>{vals[9] || ''}</span> <span>{vals[8] || ''}</span> <span>{vals[7] || ''}</span> <span>{vals[6] || ''}</span> <span>{vals[5] || ''}</span> |
| | | <span>{vals[4] || ''}</span> <span>{vals[3] || ''}</span> <span>{vals[2] || ''}</span> <span>{vals[1] || ''}</span> <span className="last">{vals[0] || ''}</span> |
| | | </div> |
| | | } else { |
| | | children = <div className={'money-uint' + (down ? ' down' : '')} onClick={this.focus}> |
| | | <span>{vals[10] || ''}</span> <span>{vals[9] || ''}</span> <span>{vals[8] || ''}</span> <span>{vals[7] || ''}</span> <span>{vals[6] || ''}</span> <span>{vals[5] || ''}</span> |
| | | <span>{vals[4] || ''}</span> <span>{vals[3] || ''}</span> <span>{vals[2] || ''}</span> <span>{vals[1] || ''}</span> <span className="last">{vals[0] || ''}</span> |
| | | </div> |
| | | } |
| | | } |
| | | } else if (col.field === 'credit') { |
| | | extra = <CloseOutlined onClick={this.delRecord}/> |
| | | if (record.type !== 'total' && !record.$disabled) { |
| | | extra = <CloseOutlined onClick={this.delVoucher}/> |
| | | } |
| | | |
| | | if (editing) { |
| | | children = <InputNumber id={col.uuid + record.uuid} precision={2} defaultValue={record.credit} onChange={(val) => this.onChange(val)} onPressEnter={this.enterPress} onBlur={this.onBlur}/> |
| | |
| | | } |
| | | vals = (val * 100).toFixed(0).split('').reverse() |
| | | } |
| | | children = <div className={'money-uint' + (down ? ' down' : '')} onClick={this.focus}> |
| | | <span>{vals[10] || ''}</span> <span>{vals[9] || ''}</span> <span>{vals[8] || ''}</span> <span>{vals[7] || ''}</span> <span>{vals[6] || ''}</span> <span>{vals[5] || ''}</span> |
| | | <span>{vals[4] || ''}</span> <span>{vals[3] || ''}</span> <span>{vals[2] || ''}</span> <span>{vals[1] || ''}</span> <span className="last">{vals[0] || ''}</span> |
| | | </div> |
| | | |
| | | if (record.$disabled) { |
| | | children = <div className={'money-uint' + (down ? ' down' : '')}> |
| | | <span>{vals[10] || ''}</span> <span>{vals[9] || ''}</span> <span>{vals[8] || ''}</span> <span>{vals[7] || ''}</span> <span>{vals[6] || ''}</span> <span>{vals[5] || ''}</span> |
| | | <span>{vals[4] || ''}</span> <span>{vals[3] || ''}</span> <span>{vals[2] || ''}</span> <span>{vals[1] || ''}</span> <span className="last">{vals[0] || ''}</span> |
| | | </div> |
| | | } else { |
| | | children = <div className={'money-uint' + (down ? ' down' : '')} onClick={this.focus}> |
| | | <span>{vals[10] || ''}</span> <span>{vals[9] || ''}</span> <span>{vals[8] || ''}</span> <span>{vals[7] || ''}</span> <span>{vals[6] || ''}</span> <span>{vals[5] || ''}</span> |
| | | <span>{vals[4] || ''}</span> <span>{vals[3] || ''}</span> <span>{vals[2] || ''}</span> <span>{vals[1] || ''}</span> <span className="last">{vals[0] || ''}</span> |
| | | </div> |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | class VoucherTable extends Component { |
| | | static propTpyes = { |
| | | config: PropTypes.object, // 菜单Id |
| | | data: PropTypes.any, // 表格数据 |
| | | loading: PropTypes.bool, // 表格加载中 |
| | | onChange: PropTypes.func, // 表格变动 |
| | | config: PropTypes.object, |
| | | data: PropTypes.any, |
| | | loading: PropTypes.bool, |
| | | onChange: PropTypes.func |
| | | } |
| | | |
| | | state = { |
| | | data: [], |
| | | edData: [], |
| | | tableId: '', // 表格ID |
| | | columns: null, // 显示列 |
| | | tableId: '', |
| | | columns: null, |
| | | } |
| | | |
| | | UNSAFE_componentWillMount () { |
| | |
| | | } |
| | | |
| | | componentDidMount () { |
| | | MKEmitter.addListener('nextLine', this.nextLine) |
| | | MKEmitter.addListener('plusLine', this.plusLine) |
| | | MKEmitter.addListener('delRecord', this.delRecord) |
| | | MKEmitter.addListener('delVoucher', this.delVoucher) |
| | | MKEmitter.addListener('cleartable', this.cleartable) |
| | | MKEmitter.addListener('nextVoucher', this.nextVoucher) |
| | | MKEmitter.addListener('changeRecord', this.changeRecord) |
| | | } |
| | | |
| | |
| | | this.setState = () => { |
| | | return |
| | | } |
| | | MKEmitter.removeListener('nextLine', this.nextLine) |
| | | MKEmitter.removeListener('plusLine', this.plusLine) |
| | | MKEmitter.removeListener('delRecord', this.delRecord) |
| | | MKEmitter.removeListener('delVoucher', this.delVoucher) |
| | | MKEmitter.removeListener('cleartable', this.cleartable) |
| | | MKEmitter.removeListener('nextVoucher', this.nextVoucher) |
| | | MKEmitter.removeListener('changeRecord', this.changeRecord) |
| | | } |
| | | |
| | |
| | | return item |
| | | }) |
| | | |
| | | let disabled = _data[0] && _data[0].$disabled ? true : false |
| | | |
| | | if (_data.length < 4) { |
| | | for (let i = _data.length - 1; i < 4; i++) { |
| | | _data.push({uuid: Utils.getguid(), index: i + 1, subject_voucher_text: '', subject_code: '', subject_name: '', debit: '', credit: ''}) |
| | | _data.push({uuid: Utils.getguid(), $disabled: disabled, index: i + 1, subject_voucher_text: '', subject_code: '', subject_name: '', debit: '', credit: ''}) |
| | | } |
| | | } |
| | | return _data |
| | |
| | | } |
| | | }) |
| | | |
| | | let _total = debit |
| | | if (debit === 0) { |
| | | debit = '' |
| | | } |
| | | |
| | | if (_total === '' && credit !== '') { |
| | | _total = 0 |
| | | } |
| | | |
| | | if (credit === 0) { |
| | | credit = '' |
| | | } |
| | | |
| | | totalLine.debit = debit |
| | | totalLine.credit = credit |
| | | |
| | | totalLine.subject_voucher_text = this.changeMoneyToChinese(debit) |
| | | totalLine.subject_voucher_text = this.changeMoneyToChinese(_total) |
| | | |
| | | return totalLine |
| | | } |
| | |
| | | return ChineseStr |
| | | } |
| | | |
| | | nextLine = (col, record) => { |
| | | nextVoucher = (col, record) => { |
| | | const { edData, tableId } = this.state |
| | | |
| | | if (col.tableId !== tableId) return |
| | |
| | | this.props.onChange(_data) |
| | | } |
| | | |
| | | delRecord = (id, record) => { |
| | | delVoucher = (id, record) => { |
| | | const { tableId, edData } = this.state |
| | | |
| | | if (id !== tableId) return |