From 4e570c993e66a47ead0f83de76b63b0a2f8c5446 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期一, 05 六月 2023 17:28:16 +0800 Subject: [PATCH] 2023-06-05 --- src/tabviews/custom/components/table/edit-table/normalTable/index.jsx | 91 ++++++++++++++++----------------------------- 1 files changed, 32 insertions(+), 59 deletions(-) diff --git a/src/tabviews/custom/components/table/edit-table/normalTable/index.jsx b/src/tabviews/custom/components/table/edit-table/normalTable/index.jsx index 36e29df..47fb9f2 100644 --- a/src/tabviews/custom/components/table/edit-table/normalTable/index.jsx +++ b/src/tabviews/custom/components/table/edit-table/normalTable/index.jsx @@ -8,15 +8,13 @@ import Api from '@/api' import asyncComponent from '@/utils/asyncComponent' import Utils, { getEditTableSql, getMark } from '@/utils/utils.js' -import MkIcon from '@/components/mk-icon' import MKEmitter from '@/utils/events.js' -import zhCN from '@/locales/zh-CN/main.js' -import enUS from '@/locales/en-US/main.js' import CusSwitch from './cusSwitch' import Encrypts from '@/components/encrypts' import './index.scss' const { Paragraph } = Typography +const MkIcon = asyncComponent(() => import('@/components/mk-icon')) const CardCellComponent = asyncComponent(() => import('@/tabviews/custom/components/card/cardcellList')) class BodyRow extends React.Component { @@ -220,15 +218,7 @@ } }, 50) - let values = {} - // if (col.editField) { - // values[col.field] = label - // values[col.editField] = val - // } else { - values[col.field] = val - // } - - MKEmitter.emit('changeRecord', col.tableId, {...record, ...values}) + MKEmitter.emit('changeRecord', col.tableId, {...record, [col.field]: val}) } onSelectChange = (val, option) => { @@ -244,12 +234,7 @@ }) } - // if (col.editField) { - // values[col.field] = _option.label - // values[col.editField] = val - // } else { - values[col.field] = val - // } + values[col.field] = val } this.setState({editing: false}) @@ -333,22 +318,14 @@ <Input className={err ? 'has-error' : ''} title={err} id={col.uuid + record.$$uuid} defaultValue={value} onChange={(e) => this.onChange(e.target.value)} onPressEnter={this.enterPress} onBlur={this.onBlur}/> </td>) } else if (col.editType === 'switch') { - let _value = '' - // if (col.editField) { - // _value = record[col.editField] !== undefined ? record[col.editField] : '' - // } else { - _value = record[col.field] !== undefined ? record[col.field] : '' - // } + let _value = record[col.field] !== undefined ? record[col.field] : '' + return (<td className="editing_table_cell"> <CusSwitch config={col} defaultValue={_value} autoFocus={true} onChange={this.onSwitchChange} onBlur={this.switchBlur}/> </td>) } else { - let _value = '' - // if (col.editField) { - // _value = record[col.editField] !== undefined ? record[col.editField] : '' - // } else { - _value = record[col.field] !== undefined ? record[col.field] : '' - // } + let _value = record[col.field] !== undefined ? record[col.field] : '' + return (<td className="editing_table_cell"> <Select showSearch @@ -641,15 +618,7 @@ } }, 50) - let values = {} - // if (col.editField) { - // values[col.field] = label - // values[col.editField] = val - // } else { - values[col.field] = val - // } - - MKEmitter.emit('changeRecord', col.tableId, {...record, ...values}) + MKEmitter.emit('changeRecord', col.tableId, {...record, [col.field]: val}) } onSelectChange = (val, option) => { @@ -665,12 +634,7 @@ }) } - // if (col.editField) { - // values[col.field] = _option.label - // values[col.editField] = val - // } else { - values[col.field] = val - // } + values[col.field] = val } setTimeout(() => { @@ -707,12 +671,7 @@ let children = null if (col.type === 'text') { if (col.editable === 'true' && !disabled) { - let _value = '' - // if (col.editField) { - // _value = record[col.editField] !== undefined ? record[col.editField] : '' - // } else { - _value = record[col.field] !== undefined ? record[col.field] : '' - // } + let _value = record[col.field] !== undefined ? record[col.field] : '' if (!col.editType || col.editType === 'text') { children = (<> @@ -776,6 +735,11 @@ content = <span style={mark.innerStyle}>{content}</span> } } + + if (col.editable === 'true' && disabled) { + content = <span style={{display: 'inline-block', padding: '0 6px'}}>{content}</span> + } + children = content } } else if (col.type === 'number') { @@ -838,6 +802,11 @@ content = <span style={mark.innerStyle}>{content}</span> } } + + if (col.editable === 'true' && disabled) { + content = <span style={{display: 'inline-block', padding: '0 6px'}}>{content}</span> + } + children = content } } else if (col.type === 'textarea') { @@ -939,7 +908,6 @@ } state = { - dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, edData: [], selectedRowKeys: [], // 琛ㄦ牸涓�変腑琛� tableId: '', // 琛ㄦ牸ID @@ -1111,7 +1079,13 @@ if (menuid !== MenuID) return if (type !== 'line') { - this.setState({edData: data}) + if (setting.editType === 'multi' && data.length > 0) { + this.setState({edData: []}, () => { + this.setState({edData: data}) + }) + } else { + this.setState({edData: data}) + } if (setting.addable && data.length === 0) { setTimeout(() => { @@ -1709,7 +1683,7 @@ this.setState({edData: _data}) } - MKEmitter.emit('reloadData', this.props.MenuID, item.$$uuid, item) + MKEmitter.emit('reloadData', this.props.MenuID, item.$$uuid) } execSuccess = (res) => { @@ -1718,12 +1692,12 @@ if (res && res.ErrCode === 'S') { // 鎵ц鎴愬姛 notification.success({ top: 92, - message: res.ErrMesg || this.state.dict['main.action.confirm.success'], + message: res.ErrMesg || '鎵ц鎴愬姛', duration: submit.stime ? submit.stime : 2 }) } else if (res && res.ErrCode === 'Y') { // 鎵ц鎴愬姛 Modal.success({ - title: res.ErrMesg || this.state.dict['main.action.confirm.success'] + title: res.ErrMesg || '鎵ц鎴愬姛' }) } else if (res && res.ErrCode === '-1') { // 瀹屾垚鍚庝笉鎻愮ず @@ -1740,6 +1714,8 @@ if (submit.execSuccess !== 'never') { MKEmitter.emit('refreshByButtonResult', submit.$menuId, submit.execSuccess, submit) } + + submit.syncComponentId && MKEmitter.emit('reloadData', submit.syncComponentId) } execError = (res) => { @@ -1911,8 +1887,6 @@ } } - let _footer = '' - let height = setting.height || false if (height && height <= 100) { height = height + 'vh' @@ -1945,7 +1919,6 @@ onChange={this.changeTable} pagination={_pagination} /> - {_footer ? <div className={'normal-table-footer ' + (_pagination ? 'pagination' : '')}>{_footer}</div> : null} {_data.length > 10 ? <Button style={submit.style} onClick={() => setTimeout(() => {this.submit()}, 10)} loading={loading} className="submit-footer-table" type="link">鎻愪氦</Button> : null} </div> </> -- Gitblit v1.8.0