| | |
| | | state = { |
| | | editing: false, |
| | | visible: false, |
| | | counting: false, |
| | | priceing: false |
| | | } |
| | | |
| | | componentDidMount () { |
| | |
| | | setTimeout(() => { |
| | | this.setState({visible: true}) |
| | | }, 100) |
| | | } else if (line.count_type === 'Y') { |
| | | this.setState({counting: true, value: line.count || 0}, () => { |
| | | let node = document.getElementById(col.uuid + record.uuid + 'count') |
| | | node && node.select() |
| | | }) |
| | | } else { |
| | | this.setState({editing: false}) |
| | | this.setState({editing: false, visible: false, counting: false, priceing: false}) |
| | | setTimeout(() => { |
| | | MKEmitter.emit('tdFocus', 'debtor' + record.uuid) |
| | | }, 50) |
| | |
| | | MKEmitter.emit('changeRecord', col.tableId, fromJS(res).toJS()) |
| | | |
| | | this.setState({editing: false, visible: false}) |
| | | setTimeout(() => { |
| | | MKEmitter.emit('tdFocus', 'debtor' + res.uuid) |
| | | }, 50) |
| | | |
| | | if (res.count_type === 'Y') { |
| | | this.setState({counting: true, value: res.count || 0}, () => { |
| | | let node = document.getElementById(col.uuid + res.uuid + 'count') |
| | | node && node.select() |
| | | }) |
| | | } else { |
| | | setTimeout(() => { |
| | | MKEmitter.emit('tdFocus', 'debtor' + res.uuid) |
| | | }, 50) |
| | | } |
| | | } |
| | | |
| | | cancel = () => { |
| | |
| | | this.setState({editing: false, visible: false}) |
| | | } |
| | | |
| | | editCount = (e) => { |
| | | const { col, record } = this.props |
| | | e.stopPropagation() |
| | | |
| | | this.setState({counting: true, value: record.count || 0}, () => { |
| | | let node = document.getElementById(col.uuid + record.uuid + 'count') |
| | | node && node.select() |
| | | }) |
| | | } |
| | | |
| | | editPrice = (e) => { |
| | | const { col, record } = this.props |
| | | e.stopPropagation() |
| | | |
| | | this.setState({priceing: true, value: record.price || 0}, () => { |
| | | let node = document.getElementById(col.uuid + record.uuid + 'price') |
| | | node && node.select() |
| | | }) |
| | | } |
| | | |
| | | countPress = () => { |
| | | const { col, record } = this.props |
| | | const { value } = this.state |
| | | |
| | | let line = {...record} |
| | | line.count = value || 0 |
| | | |
| | | if (isNaN(line.count)) { |
| | | line.count = 0 |
| | | } |
| | | |
| | | MKEmitter.emit('changeRecord', col.tableId, line) |
| | | |
| | | this.setState({counting: false, priceing: true, value: line.price || 0}, () => { |
| | | let node = document.getElementById(col.uuid + record.uuid + 'price') |
| | | node && node.select() |
| | | }) |
| | | } |
| | | |
| | | countBlur = () => { |
| | | const { col, record } = this.props |
| | | const { value } = this.state |
| | | |
| | | this.setState({counting: false}) |
| | | |
| | | let line = {...record} |
| | | line.count = value || 0 |
| | | |
| | | if (isNaN(line.count)) { |
| | | line.count = 0 |
| | | } |
| | | |
| | | MKEmitter.emit('changeRecord', col.tableId, line) |
| | | } |
| | | |
| | | pricePress = () => { |
| | | const { col, record } = this.props |
| | | const { value } = this.state |
| | | |
| | | let line = {...record} |
| | | line.price = value || 0 |
| | | |
| | | if (isNaN(line.price)) { |
| | | line.price = 0 |
| | | } |
| | | |
| | | MKEmitter.emit('changeRecord', col.tableId, line) |
| | | |
| | | this.setState({priceing: false}) |
| | | setTimeout(() => { |
| | | MKEmitter.emit('tdFocus', 'debtor' + record.uuid) |
| | | }, 50) |
| | | } |
| | | |
| | | priceBlur = () => { |
| | | const { col, record } = this.props |
| | | const { value } = this.state |
| | | |
| | | this.setState({priceing: false}) |
| | | |
| | | let line = {...record} |
| | | line.price = value || 0 |
| | | |
| | | if (isNaN(line.price)) { |
| | | line.price = 0 |
| | | } |
| | | |
| | | MKEmitter.emit('changeRecord', col.tableId, line) |
| | | } |
| | | |
| | | render() { |
| | | let { col, record, className } = this.props |
| | | const { editing, visible } = this.state |
| | | const { editing, visible, counting, priceing } = this.state |
| | | |
| | | let children = null |
| | | let colSpan = 1 |
| | |
| | | } |
| | | }) |
| | | } |
| | | children = <div className="content-wrap" onClick={this.focus}>{val}</div> |
| | | |
| | | 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> |
| | | </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> |
| | | </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> |
| | | </div> |
| | | } |
| | | } else { |
| | | children = <div className="content-wrap" onClick={this.focus}>{val}</div> |
| | | } |
| | | } |
| | | } |
| | | } else if (col.field === 'debtor') { |
| | |
| | | data.push(this.getTotalLine(data)) |
| | | |
| | | this.setState({ |
| | | edData: data |
| | | edData: [] |
| | | }, () => { |
| | | this.setState({ |
| | | edData: data |
| | | }) |
| | | }) |
| | | } |
| | | |