From cadfd4ed559fb170bb81d5bafbb6ae9775ba1ddc Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期四, 03 三月 2022 18:18:39 +0800 Subject: [PATCH] 2022-03-03 --- src/tabviews/custom/components/table/edit-table/normalTable/index.scss | 53 +++++ src/tabviews/custom/components/table/edit-table/index.jsx | 78 ++------ src/menu/components/table/edit-table/options.jsx | 113 +++++++----- src/menu/components/share/actioncomponent/formconfig.jsx | 22 +- src/menu/datasource/verifycard/settingform/index.jsx | 2 src/utils/utils.js | 21 -- src/tabviews/custom/components/table/edit-table/normalTable/index.jsx | 207 ++++++++++++++-------- 7 files changed, 281 insertions(+), 215 deletions(-) diff --git a/src/menu/components/share/actioncomponent/formconfig.jsx b/src/menu/components/share/actioncomponent/formconfig.jsx index c6f833e..369f300 100644 --- a/src/menu/components/share/actioncomponent/formconfig.jsx +++ b/src/menu/components/share/actioncomponent/formconfig.jsx @@ -63,17 +63,17 @@ }) } - if (type === 'editable') { - opentypes = [ - { - value: 'excelIn', - text: Formdict['model.form.excelIn'] - }, { - value: 'excelOut', - text: Formdict['model.form.excelOut'] - } - ] - } + // if (type === 'editable') { + // opentypes = [ + // { + // value: 'excelIn', + // text: Formdict['model.form.excelIn'] + // }, { + // value: 'excelOut', + // text: Formdict['model.form.excelOut'] + // } + // ] + // } let tabs = getTabs(JSON.parse(JSON.stringify(modules))) diff --git a/src/menu/components/table/edit-table/options.jsx b/src/menu/components/table/edit-table/options.jsx index 307b6ca..cd7c543 100644 --- a/src/menu/components/table/edit-table/options.jsx +++ b/src/menu/components/table/edit-table/options.jsx @@ -55,6 +55,74 @@ }, { type: 'radio', + field: 'editable', + label: '鍒濆鍖�', + initval: wrap.editable || 'false', + required: false, + options: [ + {value: 'true', label: '鍙紪杈�'}, + {value: 'false', label: '涓嶅彲缂栬緫'}, + ] + }, + { + type: 'radio', + field: 'commit', + label: '鏁版嵁鎻愪氦', + initval: wrap.commit || 'all', + required: false, + options: [ + {value: 'all', label: '鍏ㄩ儴'}, + {value: 'change', label: '淇敼椤�'}, + ] + }, + { + type: 'radio', + field: 'addable', + label: '鍙柊澧�', + initval: wrap.addable || 'false', + required: false, + options: [ + {value: 'true', label: '鏄�'}, + {value: 'false', label: '鍚�'}, + ] + }, + { + type: 'radio', + field: 'delable', + label: '鍙垹闄�', + initval: wrap.delable || 'true', + required: false, + options: [ + {value: 'true', label: '鏄�'}, + {value: 'false', label: '鍚�'}, + ] + }, + { + type: 'radio', + field: 'operType', + label: '缂栬緫鎸夐挳', + initval: wrap.operType || 'btnMode', + tooltip: '缂栬緫鏃剁殑娣诲姞銆佸垹闄ゆ寜閽樉绀轰綅缃紝娉細浣跨敤娴爣鏃惰〃鏍兼í鍚戞粴鍔ㄥけ鏁堬紝琛ㄦ牸璁剧疆楂樺害鏃舵诞鏍囨棤鏁堛��', + required: false, + options: [ + {value: 'btnMode', label: '鎸夐挳寮�'}, + {value: 'buoyMode', label: '娴爣寮�'}, + ] + }, + { + type: 'radio', + field: 'cache', + label: '缂撳瓨', + initval: wrap.cache || 'true', + tooltip: '瀵逛簬浣跨敤鏁版嵁婧愮殑涓嬫媺鑿滃崟锛屼笅鎷夐�夐」鏄惁缂撳瓨鍒版湰鍦般��', + required: false, + options: [ + {value: 'true', label: '浣跨敤'}, + {value: 'false', label: '涓嶄娇鐢�'}, + ] + }, + { + type: 'radio', field: 'bordered', label: '杈规', initval: wrap.bordered || 'true', @@ -110,51 +178,6 @@ options: [ {value: 'true', label: '鏄剧ず'}, {value: 'false', label: '闅愯棌'}, - ] - }, - { - type: 'radio', - field: 'addable', - label: '鍙柊澧�', - initval: wrap.addable || 'false', - required: false, - options: [ - {value: 'true', label: '鏄�'}, - {value: 'false', label: '鍚�'}, - ] - }, - { - type: 'radio', - field: 'delable', - label: '鍙垹闄�', - initval: wrap.delable || 'true', - required: false, - options: [ - {value: 'true', label: '鏄�'}, - {value: 'false', label: '鍚�'}, - ] - }, - { - type: 'radio', - field: 'editable', - label: '鍒濆鍖�', - initval: wrap.editable || 'false', - required: false, - options: [ - {value: 'true', label: '鍙紪杈�'}, - {value: 'false', label: '涓嶅彲缂栬緫'}, - ] - }, - { - type: 'radio', - field: 'cache', - label: '缂撳瓨', - initval: wrap.cache || 'true', - tooltip: '瀵逛簬浣跨敤鏁版嵁婧愮殑涓嬫媺鑿滃崟锛屼笅鎷夐�夐」鏄惁缂撳瓨鍒版湰鍦般��', - required: false, - options: [ - {value: 'true', label: '浣跨敤'}, - {value: 'false', label: '涓嶄娇鐢�'}, ] }, { diff --git a/src/menu/datasource/verifycard/settingform/index.jsx b/src/menu/datasource/verifycard/settingform/index.jsx index 72fc91f..9f89d35 100644 --- a/src/menu/datasource/verifycard/settingform/index.jsx +++ b/src/menu/datasource/verifycard/settingform/index.jsx @@ -406,7 +406,7 @@ </Form.Item> </Col> : null} {/* 1銆佷笉鍒嗛〉涓斾笉瀛樺湪涓婄骇妯″潡 */} - {!['navbar'].includes(config.type) && (!config.pageable || (config.pageable && laypage === 'false')) && (!supModule || supModule.length === 0 || supModule[0] === 'empty') ? <Col span={8}> + {!['navbar'].includes(config.type) && !['editable'].includes(config.subtype) && (!config.pageable || (config.pageable && laypage === 'false')) && (!supModule || supModule.length === 0 || supModule[0] === 'empty') ? <Col span={8}> <Form.Item label={ <Tooltip placement="topLeft" title={'鍒濆鍖栧姞杞芥椂锛屾槸鍚︿笌鍏朵粬缁勪欢涓�鍚屽姞杞芥暟鎹紝娉細浠呭湪浣跨敤绯荤粺鍑芥暟锛屼笖鍒濆鍖栧姞杞芥暟鎹椂鏈夋晥锛屽垎椤佃姹傛椂鏃犳晥銆�'}> <QuestionCircleOutlined className="mk-form-tip" /> diff --git a/src/tabviews/custom/components/table/edit-table/index.jsx b/src/tabviews/custom/components/table/edit-table/index.jsx index 0018d0c..e612d75 100644 --- a/src/tabviews/custom/components/table/edit-table/index.jsx +++ b/src/tabviews/custom/components/table/edit-table/index.jsx @@ -50,31 +50,14 @@ * 1銆� initdata 涓烘墦鍗版椂浣跨敤鐨勬暟鎹泦 */ UNSAFE_componentWillMount () { - const { data, initdata, BID, BData } = this.props + const { BID, BData } = this.props let _config = fromJS(this.props.config).toJS() let _cols = new Map() - let _data = null - let _sync = _config.setting.sync === 'true' let setting = {..._config.setting, ..._config.wrap, style: {}} setting.tableId = Utils.getuuid() - if (_config.setting.sync === 'true' && data) { - _data = data[_config.dataName] || [] - _sync = false - } else if (_config.setting.sync === 'true' && initdata) { - _data = initdata || [] - _sync = false - } - - if (_data) { - _data = _data.map((item, index) => { - item.key = index - item.$$uuid = item[_config.setting.primaryKey] || '' - item.$$BID = BID || '' - item.$$BData = BData || '' - item.$Index = index + 1 + '' - return item - }) + if (setting.height) { + setting.operType = 'btnMode' } _config.columns.forEach(item => { @@ -83,7 +66,7 @@ }) let _columns = [] - // let signAdd = false + let signAdd = false _config.cols.forEach(column => { if (column.Hide === 'true') return if (column.type === 'index') { @@ -91,10 +74,10 @@ column.type = 'text' } - // if (setting.addable === 'true' && column.type !== 'action' && !signAdd) { - // column.addable = true - // signAdd = true - // } + if (setting.addable === 'true' && setting.operType === 'buoyMode' && column.type !== 'action' && !signAdd) { + column.addable = true + signAdd = true + } if (column.marks && column.marks.length === 0) { column.marks = '' @@ -126,13 +109,13 @@ _columns.push(column) }) - // if (setting.delable !== 'false') { - // if (_columns[_columns.length - 1] && _columns[_columns.length - 1].type !== 'action') { - // _columns[_columns.length - 1].delable = true - // } else if (_columns[_columns.length - 2] && _columns[_columns.length - 2].type !== 'action') { - // _columns[_columns.length - 2].delable = true - // } - // } + if (setting.delable !== 'false' && setting.operType === 'buoyMode') { + if (_columns[_columns.length - 1] && _columns[_columns.length - 1].type !== 'action') { + _columns[_columns.length - 1].delable = true + } else if (_columns[_columns.length - 2] && _columns[_columns.length - 2].type !== 'action') { + _columns[_columns.length - 2].delable = true + } + } if (setting.color) { setting.style.color = setting.color @@ -150,8 +133,6 @@ BID: BID || '', BData: BData || '', title: _config.wrap.title, - sync: _sync, - data: _data, config: _config, setting: setting, searchlist: _config.search, @@ -160,13 +141,11 @@ arr_field: _config.columns.map(col => col.field).join(','), search: Utils.initMainSearch(_config.search) // 鎼滅储鏉′欢鍒濆鍖栵紙鍚湁鏃堕棿鏍煎紡锛岄渶瑕佽浆鍖栵級 }, () => { - if (_config.setting.sync !== 'true' && _config.setting.onload === 'true') { + if (_config.setting.onload === 'true') { setTimeout(() => { this.loadmaindata() this.getStatFieldsValue() }, _config.setting.delay || 0) - } else if (_config.setting.onload === 'true') { - this.getStatFieldsValue() } }) } @@ -227,6 +206,8 @@ item.$$BID = BID || '' item.$$BData = BData || '' item.$Index = start + index + '' + item.$type = 'upt' + item.$origin = true return item }), total: result.total, @@ -452,24 +433,9 @@ } UNSAFE_componentWillReceiveProps(nextProps) { - const { sync, config, BID, BData } = this.state + const { config } = this.state - if (sync && !is(fromJS(this.props.data), fromJS(nextProps.data))) { - let _data = [] - if (nextProps.data && nextProps.data[config.dataName]) { - _data = nextProps.data[config.dataName] || [] - _data = _data.map((item, index) => { - item.key = index - item.$$uuid = item[config.setting.primaryKey] || '' - item.$$BID = BID || '' - item.$$BData = BData || '' - item.$Index = index + 1 + '' - return item - }) - } - - this.setState({sync: false, data: _data}) - } else if (config.setting.syncRefresh && nextProps.mainSearch && !is(fromJS(this.props.mainSearch), fromJS(nextProps.mainSearch))) { + if (config.setting.syncRefresh && nextProps.mainSearch && !is(fromJS(this.props.mainSearch), fromJS(nextProps.mainSearch))) { this.setState({pageIndex: 1}, () => { this.reloadtable() }) @@ -501,7 +467,7 @@ } render() { - const { BID, setting, searchlist, actions, config, columns, BData } = this.state + const { BID, setting, searchlist, actions, config, columns, BData, data } = this.state return ( <div className="custom-edit-table" style={config.style}> @@ -520,10 +486,10 @@ <div className={'main-table-box ' + (!actions || actions.length === 0 ? 'no-action' : '')}> <MainTable BID={BID} + data={data} setting={setting} columns={columns} MenuID={config.uuid} - data={this.state.data} submit={config.submit} fields={config.columns} total={this.state.total} 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 59d6bd5..987b60d 100644 --- a/src/tabviews/custom/components/table/edit-table/normalTable/index.jsx +++ b/src/tabviews/custom/components/table/edit-table/normalTable/index.jsx @@ -2,7 +2,7 @@ import PropTypes from 'prop-types' import { is, fromJS } from 'immutable' import { Table, Typography, Switch, Modal, Input, InputNumber, Tooltip, Button, notification, message, Select } from 'antd' -import { ExclamationCircleOutlined, EditOutlined, PlusOutlined } from '@ant-design/icons' +import { ExclamationCircleOutlined, EditOutlined, PlusOutlined, PlusCircleOutlined, DeleteOutlined } from '@ant-design/icons' import moment from 'moment' import Api from '@/api' @@ -126,7 +126,7 @@ tdFocus = (id) => { const { col, record } = this.props - if (id !== col.uuid + record.$Index) return + if (id !== col.uuid + record.$$uuid) return this.focus() } @@ -137,9 +137,9 @@ this.setState({editing: false}) setTimeout(() => { if (col.enter === '$next') { - MKEmitter.emit('nextLine', col, record.$Index) + MKEmitter.emit('nextLine', col, record.$$uuid) } else { - MKEmitter.emit('tdFocus', col.enter + record.$Index) + MKEmitter.emit('tdFocus', col.enter + record.$$uuid) } }, 50) @@ -153,7 +153,7 @@ if (col.editType === 'switch' || col.editType === 'select') { this.setState({editing: true}, () => { - let node = document.getElementById(col.uuid + record.$Index) + let node = document.getElementById(col.uuid + record.$$uuid) node && node.click() }) } else { @@ -175,7 +175,7 @@ } this.setState({editing: true, value: val, err}, () => { - let node = document.getElementById(col.uuid + record.$Index) + let node = document.getElementById(col.uuid + record.$$uuid) node && node.select() }) } @@ -220,9 +220,9 @@ setTimeout(() => { if (col.enter === '$next') { - MKEmitter.emit('nextLine', col, record.$Index) + MKEmitter.emit('nextLine', col, record.$$uuid) } else { - MKEmitter.emit('tdFocus', col.enter + record.$Index) + MKEmitter.emit('tdFocus', col.enter + record.$$uuid) } }, 50) @@ -254,9 +254,9 @@ setTimeout(() => { if (col.enter === '$next') { - MKEmitter.emit('nextLine', col, record.$Index) + MKEmitter.emit('nextLine', col, record.$$uuid) } else { - MKEmitter.emit('tdFocus', col.enter + record.$Index) + MKEmitter.emit('tdFocus', col.enter + record.$$uuid) } }, 50) @@ -308,7 +308,7 @@ if (editing) { if (!col.editType || col.editType === 'text') { return (<td className="editing_table_cell"> - <Input id={col.uuid + record.$Index} defaultValue={value} onChange={(e) => this.onChange(e.target.value)} onPressEnter={this.enterPress} onBlur={this.onBlur}/> + <Input id={col.uuid + record.$$uuid} defaultValue={value} onChange={(e) => this.onChange(e.target.value)} onPressEnter={this.enterPress} onBlur={this.onBlur}/> {err ? <Tooltip title={err}><ExclamationCircleOutlined /></Tooltip> : null} </td>) } else if (col.editType === 'switch') { @@ -322,7 +322,7 @@ <Select showSearch defaultValue={_value} - id={col.uuid + record.$Index} + id={col.uuid + record.$$uuid} onBlur={() => this.setState({editing: false})} filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0} onSelect={this.onSelectChange} @@ -383,7 +383,7 @@ if (col.editable === 'true') { if (editing) { return (<td className="editing_table_cell"> - <InputNumber id={col.uuid + record.$Index} defaultValue={value} onChange={(val) => this.onChange(val)} onPressEnter={this.enterPress} onBlur={this.onBlur}/> + <InputNumber id={col.uuid + record.$$uuid} defaultValue={value} onChange={(val) => this.onChange(val)} onPressEnter={this.enterPress} onBlur={this.onBlur}/> {err ? <Tooltip title={err}><ExclamationCircleOutlined /></Tooltip> : null} </td>) } else { @@ -470,8 +470,8 @@ ) } - // return (<td className={className} style={style}>{col.addable ? <PlusCircleOutlined className="mk-editable mk-plus"/> : null}{children}{col.delable ? <DeleteOutlined className="mk-editable mk-del"/> : null}</td>) - return (<td className={className} style={style}>{children}</td>) + return (<td className={className} style={style}>{col.addable ? <PlusCircleOutlined onClick={() => MKEmitter.emit('addRecord', col.tableId, {...record})} className="mk-editable mk-plus"/> : null}{children}{col.delable ? <DeleteOutlined onClick={() => MKEmitter.emit('delRecord', col.tableId, {...record})} className="mk-editable mk-del"/> : null}</td>) + // return (<td className={className} style={style}>{children}</td>) } } @@ -558,19 +558,19 @@ _columns.push(_item) }) - // if (setting.delable !== 'false') { - // edColumns.push({ - // align: 'center', - // dataIndex: 'mkoperation', - // title: '鎿嶄綔', - // sorter: false, - // width: 100, - // onCell: record => ({ - // record, - // col: {type: 'operation', tableId: setting.tableId}, - // }) - // }) - // } + if (setting.delable !== 'false' && setting.operType !== 'buoyMode') { + edColumns.push({ + align: 'center', + dataIndex: 'mkoperation', + title: '鎿嶄綔', + sorter: false, + width: 100, + onCell: record => ({ + record, + col: {type: 'operation', tableId: setting.tableId}, + }) + }) + } if (setting.borderColor) { // 杈规棰滆壊 let style = `#${setting.tableId} table, #${setting.tableId} tr, #${setting.tableId} th, #${setting.tableId} td {border-color: ${setting.borderColor}}` @@ -623,6 +623,7 @@ } MKEmitter.addListener('nextLine', this.nextLine) + MKEmitter.addListener('addRecord', this.addLine) MKEmitter.addListener('delRecord', this.delRecord) MKEmitter.addListener('resetTable', this.resetTable) MKEmitter.addListener('changeRecord', this.changeRecord) @@ -636,6 +637,7 @@ return } MKEmitter.removeListener('nextLine', this.nextLine) + MKEmitter.removeListener('addRecord', this.addLine) MKEmitter.removeListener('delRecord', this.delRecord) MKEmitter.removeListener('resetTable', this.resetTable) MKEmitter.removeListener('changeRecord', this.changeRecord) @@ -644,7 +646,7 @@ UNSAFE_componentWillReceiveProps(nextProps) { if (!is(fromJS(this.props.data), fromJS(nextProps.data))) { this.setState({data: nextProps.data || []}) - if (this.state.editable === 'true') { + if (this.state.editable === 'true' && !this.state.pickup) { setTimeout(() => { this.pickupChange() }, 200) @@ -820,7 +822,7 @@ MKEmitter.emit('tdFocus', initEditLine.uuid + (index + 1)) } else if (col.footEnter === 'add' && setting.addable === 'true') { setTimeout(() => { - this.plusLine(initEditLine) + this.plusLine() }, 10) } else if (col.footEnter === 'sub') { setTimeout(() => { @@ -829,14 +831,14 @@ } } - plusLine = (initEditLine) => { - const { edData, fields } = this.state + plusLine = () => { + const { edData, fields, initEditLine } = this.state let item = {...edData[edData.length - 1]} - item.key = item.key + 1 - item.$$uuid = '$new' - item.$Index = item.key + 1 + '' + item.$$uuid = Utils.getguid() + item.$type = 'add' + item.$Index = '' fields.forEach(col => { if (col.initval !== '$copy') { @@ -854,7 +856,7 @@ }) this.setState({edData: [...edData, item]}, () => { - MKEmitter.emit('tdFocus', initEditLine.uuid + item.$Index) + MKEmitter.emit('tdFocus', initEditLine.uuid + item.$$uuid) }) } @@ -865,17 +867,14 @@ let _data = [] - if (record.$$uuid === '$new') { - _data = edData.filter(item => item.$Index !== record.$Index) - _data = _data.map((item, index) => { - item.key = index - item.$Index = 1 + index + '' - return item - }) + if (record.$type === 'add') { + _data = edData.filter(item => item.$$uuid !== record.$$uuid) } else { _data = edData.map(item => { - if (item.$Index === record.$Index) { + if (item.$$uuid === record.$$uuid) { record.$deleted = true + record.$origin = false + record.$type = 'del' return record } else { return item @@ -892,7 +891,8 @@ if (id !== tableId) return let _data = this.state.edData.map(item => { - if (item.$Index === record.$Index) { + if (item.$$uuid === record.$$uuid) { + record.$origin = false return record } else { return item @@ -902,40 +902,73 @@ this.setState({edData: _data}) } - addLine = () => { + addLine = (id, record) => { const { BID } = this.props - const { edData, fields } = this.state + const { edData, fields, tableId } = this.state - let item = {} - if (edData.length > 0) { - item = {...edData[edData.length - 1]} - item.key = item.key + 1 - item.$$uuid = '$new' - item.$Index = item.key + 1 + '' - } else { - item.key = 0 - item.$$uuid = '$new' - item.$Index = item.key + 1 + '' + if (id) { + if (id !== tableId) return + let _edData = fromJS(edData).toJS() + let index = _edData.findIndex(item => record.$$uuid === item.$$uuid) + + let item = {} + + item.$$uuid = Utils.getguid() + item.$type = 'add' + item.$Index = '' item.$$BID = BID || '' - } - - fields.forEach(col => { - if (col.initval !== '$copy') { - item[col.field] = col.initval - } - if (col.type === 'number') { - item[col.field] = +item[col.field] - if (isNaN(item[col.field])) { - item[col.field] = 0 + + fields.forEach(col => { + if (col.initval !== '$copy') { + item[col.field] = col.initval } - } + if (col.type === 'number') { + item[col.field] = +item[col.field] + if (isNaN(item[col.field])) { + item[col.field] = 0 + } + } + + if (item[col.field] === undefined) { + item[col.field] = '' + } + }) - if (item[col.field] === undefined) { - item[col.field] = '' - } - }) + _edData.splice(index, 0, item) - this.setState({edData: [...edData, item]}) + this.setState({edData: _edData}) + } else { + let item = {} + if (edData.length > 0) { + item = {...edData[edData.length - 1]} + item.$$uuid = Utils.getguid() + item.$type = 'add' + item.$Index = '' + } else { + item.$$uuid = Utils.getguid() + item.$type = 'add' + item.$Index = '' + item.$$BID = BID || '' + } + + fields.forEach(col => { + if (col.initval !== '$copy') { + item[col.field] = col.initval + } + if (col.type === 'number') { + item[col.field] = +item[col.field] + if (isNaN(item[col.field])) { + item[col.field] = 0 + } + } + + if (item[col.field] === undefined) { + item[col.field] = '' + } + }) + + this.setState({edData: [...edData, item]}) + } } checkData = () => { @@ -950,6 +983,7 @@ return } let err = '' + let Index = 1 let data = fromJS(edData).toJS().map(item => { let line = [] fields.forEach(col => { @@ -995,7 +1029,10 @@ }) if (line.length > 0) { - err += `绗�${item.$Index}琛岋細` + line.join('锛�') + '锛�' + err += `绗�${Index}琛岋細` + line.join('锛�') + '锛�' + } + if (!item.$deleted) { + Index++ } return item @@ -1013,8 +1050,21 @@ } submit = (data) => { - const { submit, BID } = this.props + const { submit, BID, setting } = this.props const { fields } = this.state + + if (setting.commit === 'change') { + data = data.filter(item => !item.$origin) + } + + if (data.length === 0) { + notification.warning({ + top: 92, + message: '鏁版嵁鏈慨鏀癸紝涓嶅彲鎻愪氦锛�', + duration: 5 + }) + return + } let result = getEditTableSql(submit, data, fields) @@ -1271,10 +1321,11 @@ let height = setting.height || false return ( - <div className={`edit-custom-table ${pickup ? 'editable' : ''} ${setting.tableHeader || ''} ${height ? 'fixed-height' : ''} ${setting.mode || ''}`} id={tableId}> - <Switch title="缂栬緫" className="main-pickup" checkedChildren="寮�" unCheckedChildren="鍏�" checked={pickup} onChange={this.pickupChange} /> + <div className={`edit-custom-table ${pickup ? 'editable' : ''} ${setting.tableHeader || ''} ${setting.operType || ''} ${height ? 'fixed-height' : ''} ${setting.mode || ''}`} id={tableId}> + <Switch title="缂栬緫" className="main-pickup" checkedChildren="寮�" unCheckedChildren="鍏�" disabled={loading || this.props.loading} checked={pickup} onChange={this.pickupChange} /> {pickup ? <Button style={submit.style} onClick={() => setTimeout(() => {this.checkData()}, 10)} loading={loading} className="submit-table" type="link">鎻愪氦</Button> : null} <Table + rowKey="$$uuid" components={components} style={setting.style} size={setting.size || 'middle'} @@ -1293,7 +1344,7 @@ pagination={_pagination} /> {_footer ? <div className={'normal-table-footer ' + (_pagination ? 'pagination' : '')}>{_footer}</div> : null} - {pickup && setting.addable === 'true' ? <Button onClick={this.addLine} style={{display: 'block', width: '100%', color: '#26C281', border: '1px solid #dddddd', borderRadius: 0}} type="link"><PlusOutlined /></Button> : null} + {pickup && setting.addable === 'true' ? <Button className="mk-add-line" onClick={() => this.addLine()} disabled={this.props.loading} type="link"><PlusOutlined /></Button> : null} </div> ) } diff --git a/src/tabviews/custom/components/table/edit-table/normalTable/index.scss b/src/tabviews/custom/components/table/edit-table/normalTable/index.scss index b0dfbaa..92c6847 100644 --- a/src/tabviews/custom/components/table/edit-table/normalTable/index.scss +++ b/src/tabviews/custom/components/table/edit-table/normalTable/index.scss @@ -213,13 +213,58 @@ } } .mk-editable { + position: absolute; display: inline-block; + top: calc(50% - 13px); + cursor: pointer; + padding: 10px 5px; + opacity: 0; + // transition: opacity 0.3s 0.1s, left 0.1s; + } + tr:hover { + .mk-editable { + opacity: 1; + } + .mk-plus { + left: -25px; + } + .mk-del { + right: -25px; + } } .mk-plus { - position: absolute; - top: 45%; - left: -20px; - color: #1890ff; + left: 0px; + // left: -25px; + color: rgb(38, 194, 129); + padding-right: 10px; + } + .mk-del { + right: 0px; + // right: -25px; + color: rgb(255, 77, 79); + padding-left: 10px; + } + .mk-add-line { + display: block; + width: 100%; + color: #26C281; + border: 1px solid #dddddd; + border-radius: 0; + font-size: 25px; + height: 40px; + } + .mk-add-line:disabled { + border-color: #fafafa!important; + } +} +.edit-custom-table.buoyMode { + .ant-table-scroll { + overflow: unset; + overflow-x: unset; + + .ant-table-body { + overflow-x: unset!important; + } } } .edit-custom-table.editable { diff --git a/src/utils/utils.js b/src/utils/utils.js index 5cfdffc..460b65f 100644 --- a/src/utils/utils.js +++ b/src/utils/utils.js @@ -1114,19 +1114,6 @@ database = database ? (database[0] || '') : '' - let getuuid = () => { - let uuid = [] - let timestamp = new Date().getTime() - let _options = '0123456789abcdefghigklmnopqrstuv' - for (let i = 0; i < 19; i++) { - uuid.push(_options.substr(Math.floor(Math.random() * 0x20), 1)) - } - uuid = timestamp + uuid.join('') - return uuid - } - - // let upId = getuuid() - let _initCustomScript = '' // 鍒濆鍖栬剼鏈� let _prevCustomScript = '' // 榛樿sql鍓嶆墽琛岃剼鏈� let _backCustomScript = '' // 榛樿sql鍚庢墽琛岃剼鏈� @@ -1168,13 +1155,7 @@ }) let key = item.$$uuid - let type = 'upt' - if (key === '$new') { - key = getuuid() - type = 'add' - } else if (item.$deleted) { - type = 'del' - } + let type = item.$type || 'upt' vals.push(`'${key}'`) vals.push(`'${type}'`) -- Gitblit v1.8.0