| | |
| | | editing: false, |
| | | visible: false, |
| | | counting: false, |
| | | priceing: false |
| | | priceing: false, |
| | | curring: false, |
| | | ratioing: false, |
| | | origining: false, |
| | | } |
| | | |
| | | componentDidMount () { |
| | |
| | | } |
| | | } |
| | | |
| | | if (line.foreign_currency_type === 'Y' && line.origin) { |
| | | if (line.debtor) { |
| | | line.unitratio = Math.round(line.debtor / line.origin * 100000) / 100000 |
| | | } else if (line.creditor) { |
| | | line.unitratio = Math.round(line.creditor / line.origin * 100000) / 100000 |
| | | } |
| | | } |
| | | |
| | | MKEmitter.emit('changeRecord', col.tableId, line) |
| | | |
| | | setTimeout(() => { |
| | |
| | | |
| | | if (col.field === 'subjectscode') { |
| | | this.setState({editing: true}, () => { |
| | | try { |
| | | let node = document.getElementById(col.uuid + record.uuid) |
| | | node.click() |
| | | } catch(e) {} |
| | | let node = document.getElementById(col.uuid + record.uuid) |
| | | node && node.click() |
| | | }) |
| | | } else { |
| | | this.setState({editing: true, value: record[col.field]}, () => { |
| | |
| | | line.price = Math.round(line.debtor / line.count * 10000) / 10000 |
| | | } else if (line.creditor) { |
| | | line.price = Math.round(line.creditor / line.count * 10000) / 10000 |
| | | } |
| | | } |
| | | |
| | | if (line.foreign_currency_type === 'Y' && line.origin) { |
| | | if (line.debtor) { |
| | | line.unitratio = Math.round(line.debtor / line.origin * 100000) / 100000 |
| | | } else if (line.creditor) { |
| | | line.unitratio = Math.round(line.creditor / line.origin * 100000) / 100000 |
| | | } |
| | | } |
| | | |
| | |
| | | }) |
| | | } |
| | | |
| | | if (line.foreign_currency_type === 'Y' && line.foreign_currency) { |
| | | let msg = window.GLOB.CacheVoucher.get(col.tableId) |
| | | let cur = msg ? msg.currency.filter(n => n.exratename === line.foreign_currency)[0] : null |
| | | if (cur) { |
| | | line = {...line, ...cur} |
| | | } |
| | | |
| | | this.currencyChange(line) |
| | | } |
| | | |
| | | MKEmitter.emit('changeRecord', col.tableId, line) |
| | | |
| | | if (line.sup_accounting) { |
| | |
| | | this.setState({counting: true, value: line.count || 0}, () => { |
| | | let node = document.getElementById(col.uuid + record.uuid + 'count') |
| | | node && node.select() |
| | | }) |
| | | } else if (line.foreign_currency_type === 'Y') { |
| | | this.setState({curring: true}, () => { |
| | | let node = document.getElementById(col.uuid + record.uuid + 'currency') |
| | | node && node.click() |
| | | }) |
| | | } else { |
| | | this.setState({editing: false, visible: false, counting: false, priceing: false}) |
| | |
| | | line.count = 0 |
| | | } |
| | | |
| | | if (line.count && line.price) { |
| | | line.debtor = Math.round(line.count * line.price * 100) / 100 |
| | | } |
| | | this.countChange(line) |
| | | |
| | | MKEmitter.emit('changeRecord', col.tableId, line) |
| | | |
| | |
| | | line.count = 0 |
| | | } |
| | | |
| | | if (line.count && line.price) { |
| | | line.debtor = Math.round(line.count * line.price * 100) / 100 |
| | | } |
| | | this.countChange(line) |
| | | |
| | | MKEmitter.emit('changeRecord', col.tableId, line) |
| | | } |
| | |
| | | line.price = 0 |
| | | } |
| | | |
| | | if (line.count && line.price) { |
| | | line.debtor = Math.round(line.count * line.price * 100) / 100 |
| | | } |
| | | this.countChange(line) |
| | | |
| | | MKEmitter.emit('changeRecord', col.tableId, line) |
| | | |
| | |
| | | line.price = 0 |
| | | } |
| | | |
| | | if (line.count && line.price) { |
| | | line.debtor = Math.round(line.count * line.price * 100) / 100 |
| | | } |
| | | this.countChange(line) |
| | | |
| | | MKEmitter.emit('changeRecord', col.tableId, line) |
| | | } |
| | | |
| | | editCurrency = (e) => { |
| | | const { col, record } = this.props |
| | | e.stopPropagation() |
| | | |
| | | this.setState({curring: true}, () => { |
| | | let node = document.getElementById(col.uuid + record.uuid + 'currency') |
| | | node && node.click() |
| | | }) |
| | | } |
| | | |
| | | onCurrSelectChange = (val, option) => { |
| | | const { col, record } = this.props |
| | | |
| | | let line = {...record, ...option.props.extra} |
| | | |
| | | this.currencyChange(line) |
| | | |
| | | MKEmitter.emit('changeRecord', col.tableId, line) |
| | | |
| | | if (line.exratename === 'CNY') { |
| | | this.setState({curring: false, origining: true, value: line.origin || 0}, () => { |
| | | let node = document.getElementById(col.uuid + record.uuid + 'origin') |
| | | node && node.select() |
| | | }) |
| | | } else { |
| | | this.setState({curring: false, ratioing: true, value: line.unitratio || 1}, () => { |
| | | let node = document.getElementById(col.uuid + record.uuid + 'ratio') |
| | | node && node.select() |
| | | }) |
| | | } |
| | | } |
| | | |
| | | editRatio = (e) => { |
| | | const { col, record } = this.props |
| | | e.stopPropagation() |
| | | |
| | | this.setState({ratioing: true, value: record.unitratio || 1}, () => { |
| | | let node = document.getElementById(col.uuid + record.uuid + 'ratio') |
| | | node && node.select() |
| | | }) |
| | | } |
| | | |
| | | ratioPress = () => { |
| | | const { col, record } = this.props |
| | | const { value } = this.state |
| | | |
| | | let line = {...record} |
| | | line.unitratio = value || 1 |
| | | |
| | | if (isNaN(line.unitratio)) { |
| | | line.unitratio = 1 |
| | | } |
| | | |
| | | this.currencyChange(line) |
| | | |
| | | MKEmitter.emit('changeRecord', col.tableId, line) |
| | | |
| | | this.setState({ratioing: false, origining: true, value: line.origin || 0}, () => { |
| | | let node = document.getElementById(col.uuid + record.uuid + 'origin') |
| | | node && node.select() |
| | | }) |
| | | } |
| | | |
| | | ratioBlur = () => { |
| | | const { col, record } = this.props |
| | | const { value } = this.state |
| | | |
| | | this.setState({ratioing: false}) |
| | | |
| | | let line = {...record} |
| | | line.unitratio = value || 1 |
| | | |
| | | if (isNaN(line.unitratio)) { |
| | | line.unitratio = 1 |
| | | } |
| | | |
| | | this.currencyChange(line) |
| | | |
| | | MKEmitter.emit('changeRecord', col.tableId, line) |
| | | } |
| | | |
| | | editOrigin = (e) => { |
| | | const { col, record } = this.props |
| | | e.stopPropagation() |
| | | |
| | | this.setState({origining: true, value: record.origin || 1}, () => { |
| | | let node = document.getElementById(col.uuid + record.uuid + 'origin') |
| | | node && node.select() |
| | | }) |
| | | } |
| | | |
| | | originPress = () => { |
| | | const { col, record } = this.props |
| | | const { value } = this.state |
| | | |
| | | let line = {...record} |
| | | line.origin = value || 0 |
| | | |
| | | if (isNaN(line.origin)) { |
| | | line.origin = 0 |
| | | } |
| | | |
| | | this.currencyChange(line) |
| | | |
| | | MKEmitter.emit('changeRecord', col.tableId, line) |
| | | |
| | | this.setState({origining: false}) |
| | | |
| | | setTimeout(() => { |
| | | MKEmitter.emit('tdFocus', 'debtor' + record.uuid) |
| | | }, 50) |
| | | } |
| | | |
| | | originBlur = () => { |
| | | const { col, record } = this.props |
| | | const { value } = this.state |
| | | |
| | | this.setState({origining: false}) |
| | | |
| | | let line = {...record} |
| | | line.origin = value || 0 |
| | | |
| | | if (isNaN(line.origin)) { |
| | | line.origin = 0 |
| | | } |
| | | |
| | | this.currencyChange(line) |
| | | |
| | | MKEmitter.emit('changeRecord', col.tableId, line) |
| | | } |
| | | |
| | | countChange = (line) => { |
| | | if (line.count && line.price) { |
| | | if (line.creditor) { |
| | | line.creditor = Math.round(line.count * line.price * 100) / 100 |
| | | } else { |
| | | line.debtor = Math.round(line.count * line.price * 100) / 100 |
| | | } |
| | | |
| | | if (line.foreign_currency_type === 'Y' && line.origin) { |
| | | if (line.debtor) { |
| | | line.unitratio = Math.round(line.debtor / line.origin * 100000) / 100000 |
| | | } else if (line.creditor) { |
| | | line.unitratio = Math.round(line.creditor / line.origin * 100000) / 100000 |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | currencyChange = (line) => { |
| | | if (line.unitratio && line.origin) { |
| | | if (line.creditor) { |
| | | line.creditor = Math.round(line.unitratio * line.origin * 100) / 100 |
| | | } else { |
| | | line.debtor = Math.round(line.unitratio * line.origin * 100) / 100 |
| | | } |
| | | |
| | | if (line.count_type === 'Y' && line.count) { |
| | | if (line.debtor) { |
| | | line.price = Math.round(line.debtor / line.count * 10000) / 10000 |
| | | } else if (line.creditor) { |
| | | line.price = Math.round(line.creditor / line.count * 10000) / 10000 |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | render() { |
| | | let { col, record, className } = this.props |
| | | const { editing, visible, counting, priceing } = this.state |
| | | const { editing, visible, counting, priceing, curring, ratioing, origining } = this.state |
| | | |
| | | let children = null |
| | | let colSpan = 1 |
| | |
| | | > |
| | | {subjects.map((item, i) => (<Select.Option key={i} extra={item} value={item.subjectscode}>{item.subjectscode + ' ' + item.subjectsname}</Select.Option>))} |
| | | </Select> |
| | | <Popover overlayClassName="subject-pop-wrap" placement="bottom" title="辅助核算" visible={visible} content={<Accounting confirm={this.confirm} cancel={this.cancel} tableId={col.tableId} data={record}/>}> |
| | | <Popover overlayClassName="subject-pop-wrap" placement="bottom" title="" visible={visible} content={<Accounting confirm={this.confirm} cancel={this.cancel} tableId={col.tableId} data={record}/>}> |
| | | <span className="pop-anchor"></span> |
| | | </Popover> |
| | | </> |
| | |
| | | }) |
| | | } |
| | | |
| | | let countNode = null |
| | | let currencyNode = null |
| | | |
| | | if (record.count_type === 'Y') { |
| | | if (counting) { |
| | | children = <div className="content-wrap" onClick={this.focus}> |
| | | <div>{val}</div> |
| | | <div className="count-wrap"> |
| | | <span style={{marginRight: '5px'}}> |
| | | <span>数量:</span> |
| | | <span><InputNumber className="inner-input" id={col.uuid + record.uuid + 'count'} defaultValue={record.count || 0} onChange={(val) => this.onChange(val)} onPressEnter={this.countPress} onBlur={this.countBlur}/></span> |
| | | </span> |
| | | <span onClick={this.editPrice}> |
| | | <span>单价:</span> |
| | | <span>{record.price || 0}</span> |
| | | </span> |
| | | </div> |
| | | countNode = <div className="count-wrap"> |
| | | <span style={{marginRight: '5px'}} onClick={(e) => e.stopPropagation()}> |
| | | <span>数量:</span> |
| | | <span><InputNumber precision={4} className="inner-input" id={col.uuid + record.uuid + 'count'} defaultValue={record.count || 0} onChange={(val) => this.onChange(val)} onPressEnter={this.countPress} onBlur={this.countBlur}/></span> |
| | | </span> |
| | | <span onClick={this.editPrice}> |
| | | <span>单价:</span> |
| | | <span>{record.price || 0}</span> |
| | | </span> |
| | | </div> |
| | | } else if (priceing) { |
| | | children = <div className="content-wrap" onClick={this.focus}> |
| | | <div>{val}</div> |
| | | <div className="count-wrap"> |
| | | <span style={{marginRight: '5px'}} onClick={this.editCount}> |
| | | <span>数量:</span> |
| | | <span>{record.count || 0}</span> |
| | | </span> |
| | | <span> |
| | | <span>单价:</span> |
| | | <span><InputNumber className="inner-input" id={col.uuid + record.uuid + 'price'} defaultValue={record.price || 0} onChange={(val) => this.onChange(val)} onPressEnter={this.pricePress} onBlur={this.priceBlur}/></span> |
| | | </span> |
| | | </div> |
| | | countNode = <div className="count-wrap"> |
| | | <span style={{marginRight: '5px'}} onClick={this.editCount}> |
| | | <span>数量:</span> |
| | | <span>{record.count || 0}</span> |
| | | </span> |
| | | <span onClick={(e) => e.stopPropagation()}> |
| | | <span>单价:</span> |
| | | <span><InputNumber precision={4} className="inner-input" id={col.uuid + record.uuid + 'price'} defaultValue={record.price || 0} onChange={(val) => this.onChange(val)} onPressEnter={this.pricePress} onBlur={this.priceBlur}/></span> |
| | | </span> |
| | | </div> |
| | | } else { |
| | | children = <div className="content-wrap" onClick={this.focus}> |
| | | <div>{val}</div> |
| | | <div className="count-wrap"> |
| | | <span style={{marginRight: '5px'}} onClick={this.editCount}> |
| | | <span>数量:</span> |
| | | <span>{record.count || 0}</span> |
| | | </span> |
| | | <span onClick={this.editPrice}> |
| | | <span>单价:</span> |
| | | <span>{record.price || 0}</span> |
| | | </span> |
| | | </div> |
| | | countNode = <div className="count-wrap"> |
| | | <span style={{marginRight: '5px'}} onClick={this.editCount}> |
| | | <span>数量:</span> |
| | | <span>{record.count || 0}</span> |
| | | </span> |
| | | <span onClick={this.editPrice}> |
| | | <span>单价:</span> |
| | | <span>{record.price || 0}</span> |
| | | </span> |
| | | </div> |
| | | } |
| | | } else { |
| | | children = <div className="content-wrap" onClick={this.focus}>{val}</div> |
| | | } |
| | | |
| | | if (record.foreign_currency_type === 'Y') { |
| | | if (curring) { |
| | | let msg = window.GLOB.CacheVoucher.get(col.tableId) |
| | | let currency = msg ? msg.currency : [] |
| | | |
| | | currencyNode = <div className="count-wrap"> |
| | | <span style={{marginRight: '5px'}} onClick={(e) => e.stopPropagation()}> |
| | | <span>货币:</span> |
| | | <span> |
| | | <Select |
| | | className="currency-select" |
| | | defaultValue={record.exratename || ''} |
| | | dropdownClassName="edit-table-dropdown" |
| | | id={col.uuid + record.uuid + 'currency'} |
| | | onBlur={() => this.setState({curring: false})} |
| | | onSelect={this.onCurrSelectChange} |
| | | > |
| | | {currency.map((item, i) => (<Select.Option key={i} extra={item} value={item.exratename}>{item.exratename}</Select.Option>))} |
| | | </Select> |
| | | </span> |
| | | </span> |
| | | <span style={{marginRight: '5px'}} onClick={this.editRatio}> |
| | | <span>汇率:</span> |
| | | <span>{record.unitratio || 1}</span> |
| | | </span> |
| | | <span onClick={this.editOrigin}> |
| | | <span>原币:</span> |
| | | <span>{record.origin || 0}</span> |
| | | </span> |
| | | </div> |
| | | } else if (ratioing) { |
| | | currencyNode = <div className="count-wrap"> |
| | | <span style={{marginRight: '5px'}} onClick={this.editCurrency}> |
| | | <span>货币:</span> |
| | | <span>{record.exratename || ''}</span> |
| | | </span> |
| | | <span style={{marginRight: '5px'}} onClick={(e) => e.stopPropagation()}> |
| | | <span>汇率:</span> |
| | | <span><InputNumber precision={5} className="inner-input" id={col.uuid + record.uuid + 'ratio'} defaultValue={record.unitratio || 1} onChange={(val) => this.onChange(val)} onPressEnter={this.ratioPress} onBlur={this.ratioBlur}/></span> |
| | | </span> |
| | | <span onClick={this.editOrigin}> |
| | | <span>原币:</span> |
| | | <span>{record.origin || 0}</span> |
| | | </span> |
| | | </div> |
| | | } else if (origining) { |
| | | currencyNode = <div className="count-wrap"> |
| | | <span style={{marginRight: '5px'}} onClick={this.editCurrency}> |
| | | <span>货币:</span> |
| | | <span>{record.exratename || ''}</span> |
| | | </span> |
| | | <span style={{marginRight: '5px'}} onClick={this.editRatio}> |
| | | <span>汇率:</span> |
| | | <span>{record.unitratio || 1}</span> |
| | | </span> |
| | | <span onClick={(e) => e.stopPropagation()}> |
| | | <span>原币:</span> |
| | | <span><InputNumber precision={2} className="inner-input" id={col.uuid + record.uuid + 'origin'} defaultValue={record.origin || 0} onChange={(val) => this.onChange(val)} onPressEnter={this.originPress} onBlur={this.originBlur}/></span> |
| | | </span> |
| | | </div> |
| | | } else { |
| | | currencyNode = <div className="count-wrap"> |
| | | <span style={{marginRight: '5px'}} onClick={this.editCurrency}> |
| | | <span>货币:</span> |
| | | <span>{record.exratename || ''}</span> |
| | | </span> |
| | | <span style={{marginRight: '5px'}} onClick={this.editRatio}> |
| | | <span>汇率:</span> |
| | | <span>{record.unitratio || 1}</span> |
| | | </span> |
| | | <span onClick={this.editOrigin}> |
| | | <span>原币:</span> |
| | | <span>{record.origin || 0}</span> |
| | | </span> |
| | | </div> |
| | | } |
| | | } |
| | | |
| | | children = <div className="content-wrap" onClick={this.focus}> |
| | | {val} |
| | | {countNode} |
| | | {currencyNode} |
| | | </div> |
| | | } |
| | | } |
| | | } else if (col.field === 'debtor') { |
| | |
| | | |
| | | initData = (data) => { |
| | | let _data = data.map((item, i) => { |
| | | item.uuid = Utils.getuuid() |
| | | // item.uuid = Utils.getguid() |
| | | item.index = i |
| | | item.$origin = true |
| | | |
| | | return item |
| | | }) |
| | | |
| | | if (_data.length < 4) { |
| | | for (let i = _data.length - 1; i < 4; i++) { |
| | | _data.push({uuid: Utils.getuuid(), index: i + 1, remark: '', subjectscode: '', subjectsname: '', debtor: '', creditor: ''}) |
| | | _data.push({uuid: Utils.getguid(), index: i + 1, remark: '', subjectscode: '', subjectsname: '', debtor: '', creditor: ''}) |
| | | } |
| | | } |
| | | return _data |
| | | } |
| | | |
| | | getTotalLine = (data) => { |
| | | let totalLine = {uuid: Utils.getuuid(), type: 'total'} |
| | | let totalLine = {uuid: Utils.getguid(), type: 'total'} |
| | | let debtor = '' |
| | | let creditor = '' |
| | | |
| | |
| | | MKEmitter.emit('tdFocus', 'remark' + edData[record.index + 1].uuid) |
| | | } else { |
| | | let _data = fromJS(edData).toJS() |
| | | let line = {uuid: Utils.getuuid(), index: _data.length - 1, remark: record.remark || '', subjectscode: '', subjectsname: '', debtor: '', creditor: ''} |
| | | let line = {uuid: Utils.getguid(), index: _data.length - 1, remark: record.remark || '', subjectscode: '', subjectsname: '', debtor: '', creditor: ''} |
| | | |
| | | _data.splice(_data.length - 1, 0, line) |
| | | |
| | |
| | | if (tid !== tableId) return |
| | | |
| | | let _data = fromJS(edData).toJS() |
| | | let line = {uuid: Utils.getuuid(), index: 0, remark: '', subjectscode: '', subjectsname: '', debtor: '', creditor: ''} |
| | | let line = {uuid: Utils.getguid(), index: 0, remark: '', subjectscode: '', subjectsname: '', debtor: '', creditor: ''} |
| | | |
| | | _data.splice(record.index, 0, line) |
| | | _data = _data.map((item, index) => { |
| | |
| | | |
| | | if (_data.length < 4) { |
| | | for (let i = _data.length; i < 4; i++) { |
| | | _data.push({uuid: Utils.getuuid(), index: 0, remark: '', subjectscode: '', subjectsname: '', debtor: '', creditor: ''}) |
| | | _data.push({uuid: Utils.getguid(), index: 0, remark: '', subjectscode: '', subjectsname: '', debtor: '', creditor: ''}) |
| | | } |
| | | } |
| | | |
| | |
| | | _data.push(this.getTotalLine(_data)) |
| | | |
| | | this.setState({edData: _data}) |
| | | this.props.onChange(_data) |
| | | this.props.onChange(_data, record.$origin ? record : null) |
| | | } |
| | | |
| | | changeRecord = (tableId, record) => { |
| | |
| | | _data.pop() |
| | | |
| | | if (record.index === _data.length - 1) { |
| | | _data.push({uuid: Utils.getuuid(), index: record.index + 1, remark: '', subjectscode: '', subjectsname: '', debtor: '', creditor: ''}) |
| | | _data.push({uuid: Utils.getguid(), index: record.index + 1, remark: '', subjectscode: '', subjectsname: '', debtor: '', creditor: ''}) |
| | | } |
| | | |
| | | _data.push(this.getTotalLine(_data)) |