From 06a670976e2145a10ea05207041d3cf3164cd380 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期六, 03 二月 2024 18:13:25 +0800 Subject: [PATCH] Merge branch 'positec' into dms --- src/components/normalform/modalform/mkTable/index.jsx | 44 ++++++++++++++++++++++++++++++-------------- 1 files changed, 30 insertions(+), 14 deletions(-) diff --git a/src/components/normalform/modalform/mkTable/index.jsx b/src/components/normalform/modalform/mkTable/index.jsx index 3fdd300..341e32a 100644 --- a/src/components/normalform/modalform/mkTable/index.jsx +++ b/src/components/normalform/modalform/mkTable/index.jsx @@ -153,8 +153,9 @@ class EditTable extends Component { static propTpyes = { - columns: PropTypes.array, // 鏄剧ず鍒� - onChange: PropTypes.func // 鏁版嵁鍙樺寲 + actions: PropTypes.array, + columns: PropTypes.array, + onChange: PropTypes.func } state = { @@ -166,7 +167,7 @@ } UNSAFE_componentWillMount () { - let actions = this.props.actions || [] + const { actions } = this.props let columns = fromJS(this.props.columns).toJS() let operation = { @@ -189,16 +190,16 @@ </div> ) : ( <div className={'edit-operation-btn' + (editingKey !== '' ? ' disabled' : '')} style={{minWidth: '110px', whiteSpace: 'nowrap'}}> - <span className="primary" onClick={() => {editingKey === '' && this.edit(record)}}><EditOutlined /></span> - {editingKey === '' ? <Popconfirm + {actions.includes('edit') ? <span className="primary" onClick={() => {editingKey === '' && this.edit(record)}}><EditOutlined /></span> : null} + {actions.includes('del') && editingKey === '' ? <Popconfirm overlayClassName="popover-confirm" title="纭畾鍒犻櫎鍚�?" onConfirm={() => this.handleDelete(record.uuid) }> <span className="danger"><DeleteOutlined /></span> </Popconfirm> : null} - {editingKey !== '' ? <span className="danger"><DeleteOutlined /></span> : null} - {actions.includes('view') ? <span className="copy" onClick={() => {editingKey === '' && this.changeMenu(record.menu)}}><ArrowRightOutlined /></span> : null} + {actions.includes('del') && editingKey !== '' ? <span className="danger"><DeleteOutlined /></span> : null} + {actions.includes('view') ? <span className="copy" onClick={() => {editingKey === '' && this.changeMenu(record)}}><ArrowRightOutlined /></span> : null} </div> ) } @@ -217,7 +218,8 @@ // return !is(fromJS(this.state), fromJS(nextState)) // } - changeMenu = (MenuId) => { + changeMenu = (record) => { + let MenuId = record.menu if (MenuId === 'IM') { if (!sessionStorage.getItem('instantMessage')) return @@ -231,7 +233,7 @@ MKEmitter.emit('changeEditMenu', {routerUrl: '/imdesign/' + param}) } else { - MKEmitter.emit('changeEditMenu', {MenuID: MenuId}) + MKEmitter.emit('changeEditMenu', { ...record, MenuID: MenuId}) } } @@ -274,7 +276,18 @@ columns.forEach(col => { if (col.unique !== true || !unique) return - let _index = newData.findIndex(item => record.uuid !== item.uuid && record[col.dataIndex] === item[col.dataIndex]) + let _index = newData.findIndex(item => { + if (record.uuid === item.uuid) return false + + if (col.inputType === 'cascader') { + if (!Array.isArray(record[col.dataIndex]) || !Array.isArray(item[col.dataIndex])) { + return false + } + return record[col.dataIndex].toString() === item[col.dataIndex].toString() + } + + return record[col.dataIndex] === item[col.dataIndex] + }) if (_index > -1) { notification.warning({ @@ -392,7 +405,7 @@ } render() { - const { fixed } = this.props + const { actions } = this.props let components = { body: { cell: EditableCell @@ -401,8 +414,11 @@ let moveprops = {} components.body.row = DragableBodyRow - moveprops.moveAble = !this.state.editingKey - moveprops.moveRow = this.moveRow + + if (actions.includes('move')) { + moveprops.moveAble = !this.state.editingKey + moveprops.moveRow = this.moveRow + } let columns = this.state.columns.map(col => { if (col.copy) { @@ -437,7 +453,7 @@ return ( <EditableContext.Provider value={this.props.form}> <div className="modal-editable-table"> - {!fixed ? <Button disabled={!!this.state.editingKey} type="link" onClick={this.addline}><PlusOutlined style={{}}/></Button> : null} + {actions.includes('add') ? <Button disabled={!!this.state.editingKey} type="link" onClick={this.addline}><PlusOutlined style={{}}/></Button> : null} <DndProvider> <Table bordered -- Gitblit v1.8.0