From c547c75fce3c2d9badcb496da7d8e5443e22dbfc Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期六, 03 八月 2024 17:10:41 +0800 Subject: [PATCH] Merge branch 'develop' --- src/tabviews/custom/components/module/invoice/invoiceTable/index.jsx | 44 ++++++++++++++++++++++++++++++++++++-------- 1 files changed, 36 insertions(+), 8 deletions(-) diff --git a/src/tabviews/custom/components/module/invoice/invoiceTable/index.jsx b/src/tabviews/custom/components/module/invoice/invoiceTable/index.jsx index 154a722..f9cbe0c 100644 --- a/src/tabviews/custom/components/module/invoice/invoiceTable/index.jsx +++ b/src/tabviews/custom/components/module/invoice/invoiceTable/index.jsx @@ -27,7 +27,7 @@ }) } - onChange = (value, key) => { + onChange = (value, key, nextkey) => { let line = {...this.props.line} if (['bill_count', 'unitprice', 'amount_line'].includes(key)) { @@ -75,10 +75,32 @@ }) this.props.changeLine(line, key) + + if (nextkey) { + let node = document.getElementById(nextkey) + if (node) { + if (node.select) { + node.select() + } else if (node.focus) { + node.focus() + } + } + } + } + + onSkip = (key) => { + let node = document.getElementById(key) + if (node) { + if (node.select) { + node.select() + } else if (node.focus) { + node.focus() + } + } } render() { - const { line, delLine, trigger, field } = this.props + const { line, delLine, trigger, field, pid } = this.props const { bill_count, unitprice, amount_line } = this.state return <div className="mk-tr active"> @@ -86,19 +108,19 @@ <div className="mk-input">{line.productname || ''}<EllipsisOutlined onClick={trigger}/></div> </div> <div className="mk-td"> - <Input defaultValue={line.spec || ''} autoFocus={field === 'spec'} onChange={(e) => this.onChange(e.target.value, 'spec')}/> + <Input defaultValue={line.spec || ''} autoFocus={field === 'spec'} onChange={(e) => this.onChange(e.target.value, 'spec')} onPressEnter={() => this.onSkip(pid + 'mk-invoice-unit')}/> </div> <div className="mk-td"> - <Input defaultValue={line.unit || ''} autoFocus={field === 'unit'} onChange={(e) => this.onChange(e.target.value, 'unit')}/> + <Input id={pid + 'mk-invoice-unit'} defaultValue={line.unit || ''} autoFocus={field === 'unit'} onChange={(e) => this.onChange(e.target.value, 'unit')} onPressEnter={() => this.onSkip(pid + 'mk-invoice-billcount')}/> </div> <div className="mk-td"> - <InputNumber value={bill_count} autoFocus={field === 'bill_count'} formatter={value => `${value}`.replace(/\B(?=(\d{3})+(?!\d))/g, ',')} parser={value => value.replace(/,*/g, '')} onChange={(val) => this.setState({bill_count: val})} onBlur={() => this.onChange(bill_count, 'bill_count')}/> + <InputNumber id={pid + 'mk-invoice-billcount'} value={bill_count} autoFocus={field === 'bill_count'} formatter={value => `${value}`.replace(/\B(?=(\d{3})+(?!\d))/g, ',')} parser={value => value.replace(/,*/g, '')} onChange={(val) => this.setState({bill_count: val})} onPressEnter={() => this.onChange(bill_count, 'bill_count', pid + 'mk-invoice-unitprice')} onBlur={() => this.onChange(bill_count, 'bill_count')}/> </div> <div className="mk-td"> - <InputNumber value={unitprice} autoFocus={field === 'unitprice'} formatter={value => `${value}`.replace(/\B(?=(\d{3})+(?!\d))/g, ',')} parser={value => value.replace(/,*/g, '')} onChange={(val) => this.setState({unitprice: val})} onBlur={() => this.onChange(unitprice, 'unitprice')}/> + <InputNumber id={pid + 'mk-invoice-unitprice'} value={unitprice} autoFocus={field === 'unitprice'} formatter={value => `${value}`.replace(/\B(?=(\d{3})+(?!\d))/g, ',')} parser={value => value.replace(/,*/g, '')} onChange={(val) => this.setState({unitprice: val})} onPressEnter={() => this.onChange(unitprice, 'unitprice', pid + 'mk-invoice-amount')} onBlur={() => this.onChange(unitprice, 'unitprice')}/> </div> <div className="mk-td"> - <InputNumber value={amount_line} autoFocus={field === 'amount_line'} formatter={value => `${value}`.replace(/\B(?=(\d{3})+(?!\d))/g, ',')} parser={value => value.replace(/,*/g, '')} onChange={(val) => this.setState({amount_line: val})} onBlur={() => this.onChange(amount_line, 'amount_line')}/> + <InputNumber id={pid + 'mk-invoice-amount'} value={amount_line} autoFocus={field === 'amount_line'} formatter={value => `${value}`.replace(/\B(?=(\d{3})+(?!\d))/g, ',')} parser={value => value.replace(/,*/g, '')} onChange={(val) => this.setState({amount_line: val})} onPressEnter={() => this.onChange(amount_line, 'amount_line')} onBlur={() => this.onChange(amount_line, 'amount_line')}/> </div> <div className="mk-td mk-right">{line.tax_name}</div> <div className="mk-td mk-right">{line.tax_amount.toFixed(2).replace(/\B(?=(\d{3})+(?!\d))/g, ',')} <span className="del-line" onClick={(e) => delLine(line.uuid, e)}></span> </div> @@ -110,6 +132,7 @@ static propTpyes = { config: PropTypes.object, timestamp: PropTypes.string, + read_only: PropTypes.any, data: PropTypes.any, onChange: PropTypes.func } @@ -326,7 +349,12 @@ } checkLine = (uuid, key, e) => { + const { read_only } = this.props + e && e.stopPropagation() + + if (read_only) return + this.setState({editKey: uuid, key: key || ''}, () => { if (key === 'productname') { this.setState({visible: true}) @@ -399,7 +427,7 @@ </div> {data.map(item => { if (editKey === item.uuid) { - return <DetailLine key={item.uuid} line={item} field={key} changeLine={this.changeLine} delLine={this.delLine} trigger={() => this.setState({visible: true})}/> + return <DetailLine key={item.uuid} pid={config.uuid} line={item} field={key} changeLine={this.changeLine} delLine={this.delLine} trigger={() => this.setState({visible: true})}/> } return <div className="mk-tr" key={item.uuid} onClick={() => this.checkLine(item.uuid)}> -- Gitblit v1.8.0