From 67a307d8f0fa25fbc56ee9f84c313d521280925f Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期五, 04 三月 2022 15:33:09 +0800 Subject: [PATCH] 2022-03-04 --- src/menu/components/table/normal-table/columns/editColumn/formconfig.jsx | 2 src/tabviews/zshare/actionList/popupbutton/index.jsx | 2 src/menu/components/share/actioncomponent/formconfig.jsx | 2 src/tabviews/custom/components/table/edit-table/normalTable/index.jsx | 257 ++++++++++++++++++++++++---- src/tabviews/custom/components/table/edit-table/normalTable/index.scss | 31 ++ src/menu/components/card/cardcellcomponent/formconfig.jsx | 2 src/tabviews/custom/components/table/edit-table/index.jsx | 95 ++++++---- src/menu/components/table/edit-table/options.jsx | 23 ++ src/tabviews/zshare/actionList/index.jsx | 11 + src/menu/components/table/edit-table/columns/editColumn/index.jsx | 8 src/tabviews/custom/components/table/edit-table/normalTable/cusSwitch/index.jsx | 3 src/menu/components/table/edit-table/columns/editColumn/formconfig.jsx | 58 ++++-- src/menu/components/table/edit-table/columns/index.jsx | 2 13 files changed, 372 insertions(+), 124 deletions(-) diff --git a/src/menu/components/card/cardcellcomponent/formconfig.jsx b/src/menu/components/card/cardcellcomponent/formconfig.jsx index ee0f0b8..2d675a2 100644 --- a/src/menu/components/card/cardcellcomponent/formconfig.jsx +++ b/src/menu/components/card/cardcellcomponent/formconfig.jsx @@ -516,7 +516,7 @@ key: 'formula', label: '鍏紡', initVal: card.formula || '', - tooltip: '鎵ц鏃朵細浣跨敤鏌ヨ鍒扮殑鏁版嵁鏇挎崲鐩稿簲鐨勫瓧娈碉紝灞曠ず鑾峰緱鐨勭粨鏋溿�傚彲浣跨敤JS鐨勪竴浜涜娉曪紝濡傦細涓夊厓琛ㄨ揪寮� @field1@ > @field2@ ? 0 : 1锛汳ath瀵硅薄锛屽彇缁濆鍊� Math.abs(@field@)銆佸洓鑸嶄簲鍏� Math.round(@field@)绛�', + tooltip: '鎵ц鏃朵細浣跨敤鏌ヨ鍒扮殑鏁版嵁鏇挎崲鐩稿簲鐨勫瓧娈碉紝灞曠ず鑾峰緱鐨勭粨鏋滐紝鍦ㄤ笉浣跨敤瑙f瀽鏃舵崲琛岀鎴栫┖鏍间細鏇挎崲涓洪〉闈㈠厓绱犮�傚彲浣跨敤JS鐨勪竴浜涜娉曪紝濡傦細涓夊厓琛ㄨ揪寮� @field1@ > @field2@ ? 0 : 1锛汳ath瀵硅薄锛屽彇缁濆鍊� Math.abs(@field@)銆佸洓鑸嶄簲鍏� Math.round(@field@)绛�', placeholder: '渚嬪锛欯price@ * @number@', required: true }, diff --git a/src/menu/components/share/actioncomponent/formconfig.jsx b/src/menu/components/share/actioncomponent/formconfig.jsx index 369f300..e40ee92 100644 --- a/src/menu/components/share/actioncomponent/formconfig.jsx +++ b/src/menu/components/share/actioncomponent/formconfig.jsx @@ -150,7 +150,7 @@ if (type === 'card') { opentypes.push({ value: 'form', - text: '琛ㄥ崟' + text: '琛ㄥ崟锛堝紑鍏虫垨鍕鹃�夋锛�' }) } diff --git a/src/menu/components/table/edit-table/columns/editColumn/formconfig.jsx b/src/menu/components/table/edit-table/columns/editColumn/formconfig.jsx index 2f81f13..4f7ffb1 100644 --- a/src/menu/components/table/edit-table/columns/editColumn/formconfig.jsx +++ b/src/menu/components/table/edit-table/columns/editColumn/formconfig.jsx @@ -48,8 +48,16 @@ let editCols = [ { + field: '$sub', + label: '鎻愪氦' + }, + { field: '$next', label: '涓嬩竴琛�' + }, + { + field: '$noAct', + label: '鏃犲姩浣�' } ] columns.forEach(col => { @@ -305,6 +313,20 @@ }, { type: 'radio', + key: 'dropdown', + label: '涓嬫媺瀹藉害', + initVal: card.dropdown || 'flex', + required: false, + options: [{ + value: 'flex', + text: '鑷�傚簲' + }, { + value: 'fixed', + text: '瀹氬' + }] + }, + { + type: 'radio', key: 'required', label: '蹇呭~', initVal: card.required || 'false', @@ -338,23 +360,23 @@ tooltip: '鍖呮嫭鏂囨湰鎴栨暟鍊煎洖杞︿簨浠躲�佷笅鎷夎彍鍗曢�変腑浜嬩欢銆佸紑鍏冲垏鎹簨浠躲��', options: editCols }, - { - type: 'radio', - key: 'footEnter', - label: '鏈鍥炶溅', - initVal: card.footEnter || 'false', - tooltip: '鏂板鍔熻兘浠呭湪琛ㄦ牸鍙柊澧炴椂鏈夋晥銆�', - options: [{ - value: 'sub', - text: '鎻愪氦' - }, { - value: 'add', - text: '鏂板' - }, { - value: 'false', - text: '鏃犲姩浣�' - }] - }, + // { + // type: 'radio', + // key: 'footEnter', + // label: '鏈鍥炶溅', + // initVal: card.footEnter || 'false', + // tooltip: '鏂板鍔熻兘浠呭湪琛ㄦ牸鍙柊澧炴椂鏈夋晥銆�', + // options: [{ + // value: 'sub', + // text: '鎻愪氦' + // }, { + // value: 'add', + // text: '鏂板' + // }, { + // value: 'false', + // text: '鏃犲姩浣�' + // }] + // }, { type: 'number', key: 'decimal', @@ -449,7 +471,7 @@ key: 'formula', label: '鍏紡', initVal: card.formula || '', - tooltip: '鎵ц鏃朵細浣跨敤鏌ヨ鍒扮殑鏁版嵁鏇挎崲鐩稿簲鐨勫瓧娈碉紝灞曠ず鑾峰緱鐨勭粨鏋溿�傚彲浣跨敤JS鐨勪竴浜涜娉曪紝濡傦細涓夊厓琛ㄨ揪寮� @field1@ > @field2@ ? 0 : 1锛汳ath瀵硅薄锛屽彇缁濆鍊� Math.abs(@field@)銆佸洓鑸嶄簲鍏� Math.round(@field@)绛�', + tooltip: '鎵ц鏃朵細浣跨敤鏌ヨ鍒扮殑鏁版嵁鏇挎崲鐩稿簲鐨勫瓧娈碉紝灞曠ず鑾峰緱鐨勭粨鏋滐紝鍦ㄤ笉浣跨敤瑙f瀽鏃舵崲琛岀鎴栫┖鏍间細鏇挎崲涓洪〉闈㈠厓绱犮�傚彲浣跨敤JS鐨勪竴浜涜娉曪紝濡傦細涓夊厓琛ㄨ揪寮� @field1@ > @field2@ ? 0 : 1锛汳ath瀵硅薄锛屽彇缁濆鍊� Math.abs(@field@)銆佸洓鑸嶄簲鍏� Math.round(@field@)绛�', placeholder: '渚嬪锛欯price@ * @number@', required: true }, diff --git a/src/menu/components/table/edit-table/columns/editColumn/index.jsx b/src/menu/components/table/edit-table/columns/editColumn/index.jsx index 1af68b0..ca299fb 100644 --- a/src/menu/components/table/edit-table/columns/editColumn/index.jsx +++ b/src/menu/components/table/edit-table/columns/editColumn/index.jsx @@ -64,9 +64,9 @@ _options.push('editType') if (this.column.editType === 'switch') { - _options.push('enter', 'footEnter', 'openVal', 'closeVal', 'openText', 'closeText') + _options.push('enter', 'openVal', 'closeVal', 'openText', 'closeText', 'editField') } else if (this.column.editType === 'select') { - _options.push('required', 'enter', 'footEnter', 'resourceType', 'linkSubField', 'editField') + _options.push('required', 'enter', 'resourceType', 'linkSubField', 'editField', 'dropdown') if (this.column.resourceType === '0') { _options.push('options') @@ -74,10 +74,10 @@ _options.push('dataSource', 'valueField', 'valueText', 'orderBy', 'orderType', 'disableField', 'database') } } else { - _options.push('required', 'enter', 'footEnter') + _options.push('required', 'enter') } } else if (this.column.type === 'number') { - _options.push('max', 'min', 'enter', 'footEnter') + _options.push('max', 'min', 'enter') } } diff --git a/src/menu/components/table/edit-table/columns/index.jsx b/src/menu/components/table/edit-table/columns/index.jsx index 4ed5e10..d2f4c71 100644 --- a/src/menu/components/table/edit-table/columns/index.jsx +++ b/src/menu/components/table/edit-table/columns/index.jsx @@ -514,7 +514,7 @@ const columns = this.state.columns.map((col, index) => { let title = col.label if (col.editable === 'true') { - title = <span>{col.label}<EditOutlined style={{position: 'absolute', bottom: 0, right: 0, color: '#1890ff'}}/></span> + title = <span>{col.label}<EditOutlined style={{position: 'absolute', bottom: 0, right: 0, color: '#1890ff', opacity: '0.7'}}/></span> } return { title: title, diff --git a/src/menu/components/table/edit-table/options.jsx b/src/menu/components/table/edit-table/options.jsx index b842966..a48dcdc 100644 --- a/src/menu/components/table/edit-table/options.jsx +++ b/src/menu/components/table/edit-table/options.jsx @@ -66,13 +66,13 @@ }, { type: 'radio', - field: 'commit', - label: '鏁版嵁鎻愪氦', - initval: wrap.commit || 'all', + field: 'submittal', + label: '鎻愪氦鍚�', + initval: wrap.submittal || 'false', required: false, options: [ - {value: 'all', label: '鍏ㄩ儴'}, - {value: 'change', label: '淇敼椤�'}, + {value: 'true', label: '鍙紪杈�'}, + {value: 'false', label: '涓嶅彲缂栬緫'}, ] }, { @@ -99,6 +99,19 @@ }, { type: 'radio', + field: 'commit', + label: '鏁版嵁鎻愪氦', + initval: wrap.commit || 'all', + tooltip: '鍗曢」鎻愪氦鎸囧湪琛ㄥ崟涓洖杞︽垨鍒犻櫎琛屾椂锛岃缃负鍗曢」鏃跺鐐瑰嚮鎻愪氦鎸夐挳锛屼細鎻愪氦淇敼椤广��', + required: false, + options: [ + {value: 'all', label: '鍏ㄩ儴'}, + {value: 'change', label: '淇敼椤�'}, + {value: 'simple', label: '鍗曢」'}, + ] + }, + { + type: 'radio', field: 'operType', label: '缂栬緫鎸夐挳', initval: wrap.operType || 'btnMode', diff --git a/src/menu/components/table/normal-table/columns/editColumn/formconfig.jsx b/src/menu/components/table/normal-table/columns/editColumn/formconfig.jsx index b861cf1..83d6271 100644 --- a/src/menu/components/table/normal-table/columns/editColumn/formconfig.jsx +++ b/src/menu/components/table/normal-table/columns/editColumn/formconfig.jsx @@ -405,7 +405,7 @@ key: 'formula', label: '鍏紡', initVal: card.formula || '', - tooltip: '鎵ц鏃朵細浣跨敤鏌ヨ鍒扮殑鏁版嵁鏇挎崲鐩稿簲鐨勫瓧娈碉紝灞曠ず鑾峰緱鐨勭粨鏋溿�傚彲浣跨敤JS鐨勪竴浜涜娉曪紝濡傦細涓夊厓琛ㄨ揪寮� @field1@ > @field2@ ? 0 : 1锛汳ath瀵硅薄锛屽彇缁濆鍊� Math.abs(@field@)銆佸洓鑸嶄簲鍏� Math.round(@field@)绛�', + tooltip: '鎵ц鏃朵細浣跨敤鏌ヨ鍒扮殑鏁版嵁鏇挎崲鐩稿簲鐨勫瓧娈碉紝灞曠ず鑾峰緱鐨勭粨鏋滐紝鍦ㄤ笉浣跨敤瑙f瀽鏃舵崲琛岀鎴栫┖鏍间細鏇挎崲涓洪〉闈㈠厓绱犮�傚彲浣跨敤JS鐨勪竴浜涜娉曪紝濡傦細涓夊厓琛ㄨ揪寮� @field1@ > @field2@ ? 0 : 1锛汳ath瀵硅薄锛屽彇缁濆鍊� Math.abs(@field@)銆佸洓鑸嶄簲鍏� Math.round(@field@)绛�', placeholder: '渚嬪锛欯price@ * @number@', required: true }, diff --git a/src/tabviews/custom/components/table/edit-table/index.jsx b/src/tabviews/custom/components/table/edit-table/index.jsx index 09e5078..9c8d79c 100644 --- a/src/tabviews/custom/components/table/edit-table/index.jsx +++ b/src/tabviews/custom/components/table/edit-table/index.jsx @@ -9,12 +9,13 @@ import UtilsDM from '@/utils/utils-datamanage.js' import asyncComponent from '@/utils/asyncComponent' import MKEmitter from '@/utils/events.js' +import MainTable from './normalTable' import './index.scss' // 閫氱敤缁勪欢 const MainSearch = asyncComponent(() => import('@/tabviews/zshare/topSearch')) const MainAction = asyncComponent(() => import('@/tabviews/zshare/actionList')) -const MainTable = asyncComponent(() => import('./normalTable')) +// const MainTable = asyncComponent(() => import('./normalTable')) const NormalHeader = asyncComponent(() => import('@/tabviews/custom/components/share/normalheader')) class EditableTable extends Component { @@ -43,7 +44,8 @@ pageSize: 10, // 姣忛〉鏁版嵁鏉℃暟 orderBy: '', // 鎺掑簭 search: '', // 鎼滅储鏉′欢鏁扮粍锛屼娇鐢ㄦ椂闇�鍒嗗満鏅鐞� - statFValue: [] // 鍚堣鍊� + statFValue: [], // 鍚堣鍊� + lock: false } /** @@ -200,22 +202,25 @@ if (setting.laypage) { start = pageSize * (pageIndex - 1) + 1 } + let data = result.data.map((item, index) => { + item.key = index + item.$$uuid = item[setting.primaryKey] || '' + item.$$BID = BID || '' + item.$$BData = BData || '' + item.$Index = start + index + '' + item.$type = 'upt' + item.$origin = true + return item + }) this.setState({ - data: result.data.map((item, index) => { - item.key = index - item.$$uuid = item[setting.primaryKey] || '' - item.$$BID = BID || '' - item.$$BData = BData || '' - item.$Index = start + index + '' - item.$type = 'upt' - item.$origin = true - return item - }), + data: data, selectedData: [], total: result.total, loading: false }) + + MKEmitter.emit('transferData', config.uuid, data) } else { this.setState({ loading: false @@ -231,7 +236,7 @@ /** * @description 鑾峰彇鍗曡鏁版嵁 */ - async loadmainLinedata (id) { + async loadmainLinedata (id, line) { const { mainSearch } = this.props const { setting, config, arr_field, search, orderBy, BID, pageIndex, pageSize, BData } = this.state @@ -256,34 +261,40 @@ if (result.status) { let data = fromJS(this.state.data).toJS() let selectedData = fromJS(this.state.selectedData).toJS() - if (result.data && result.data[0]) { - let _data = result.data[0] || {} - _data.$$uuid = _data[setting.primaryKey] || '' - _data.$$BID = BID || '' - _data.$$BData = BData || '' - _data.$type = 'upt' - _data.$origin = true - try { - data = data.map(item => { - if (item.$$uuid === _data.$$uuid) { - _data.key = item.key - _data.$Index = item.$Index - return _data - } else { - return item - } - }) - selectedData = selectedData.map(item => { - if (_data.$$uuid === item.$$uuid) { - return _data - } + let _data = result.data[0] || {} + _data.$$uuid = _data[setting.primaryKey] || '' + _data.$$BID = BID || '' + _data.$$BData = BData || '' + _data.$type = 'upt' + _data.$origin = true + + try { + data = data.map(item => { + if (item.$$uuid === _data.$$uuid) { + _data.key = item.key + _data.$Index = item.$Index + return _data + } else { return item - }) - } catch (e) { - console.warn('鏁版嵁鏌ヨ閿欒') - } + } + }) + selectedData = selectedData.map(item => { + if (_data.$$uuid === item.$$uuid) { + return _data + } + return item + }) + } catch (e) { + console.warn('鏁版嵁鏌ヨ閿欒') + } + if (line) { + if (line.$type === 'del' && !result.data[0]) { + data = data.filter(m => m.$$uuid === line.$$uuid) + } + MKEmitter.emit('transferData', config.uuid, _data, 'line') + } else { MKEmitter.emit('resetSelectLine', config.uuid, _data.$$uuid || '', _data) } @@ -462,7 +473,7 @@ }) } - reloadData = (menuId, id) => { + reloadData = (menuId, id, item) => { const { config } = this.state if (config.uuid !== menuId) return @@ -471,7 +482,7 @@ if (!id) { this.reloadtable() } else { - this.loadmainLinedata(id) + this.loadmainLinedata(id, item) } } @@ -555,7 +566,7 @@ } render() { - const { BID, setting, searchlist, actions, config, columns, BData, data, selectedData } = this.state + const { BID, setting, searchlist, actions, config, columns, BData, data, selectedData, lock } = this.state return ( <div className="custom-edit-table" style={config.style}> @@ -568,6 +579,7 @@ setting={setting} actions={actions} BData={BData} + lock={lock} columns={config.columns} selectedData={selectedData} /> @@ -585,6 +597,7 @@ loading={this.state.loading} refreshdata={this.refreshbytable} chgSelectData={(selects) => this.setState({selectedData: selects})} + changeLock={(lock) => this.setState({lock: lock})} statFValue={this.state.statFValue} /> </div> diff --git a/src/tabviews/custom/components/table/edit-table/normalTable/cusSwitch/index.jsx b/src/tabviews/custom/components/table/edit-table/normalTable/cusSwitch/index.jsx index 82fcb96..6b16aea 100644 --- a/src/tabviews/custom/components/table/edit-table/normalTable/cusSwitch/index.jsx +++ b/src/tabviews/custom/components/table/edit-table/normalTable/cusSwitch/index.jsx @@ -32,7 +32,8 @@ const { config } = this.props this.setState({ status: val }, () => { let _val = val ? config.openVal : config.closeVal - this.props.onChange(_val) + let _text = val ? config.openText : config.closeText + this.props.onChange(_val, _text) }) } 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 6ef85b0..558ea1f 100644 --- a/src/tabviews/custom/components/table/edit-table/normalTable/index.jsx +++ b/src/tabviews/custom/components/table/edit-table/normalTable/index.jsx @@ -138,7 +138,9 @@ setTimeout(() => { if (col.enter === '$next') { MKEmitter.emit('nextLine', col, record.$$uuid) - } else { + } else if (col.enter === '$sub') { + MKEmitter.emit('subLine', col, record) + } else if (col.enter !== '$noAct') { MKEmitter.emit('tdFocus', col.enter + record.$$uuid) } }, 50) @@ -213,7 +215,7 @@ this.setState({value: val, err}) } - onSwitchChange = (val) => { + onSwitchChange = (val, label) => { const { col, record } = this.props this.setState({editing: false}) @@ -221,12 +223,22 @@ setTimeout(() => { if (col.enter === '$next') { MKEmitter.emit('nextLine', col, record.$$uuid) - } else { + } else if (col.enter === '$sub') { + MKEmitter.emit('subLine', col, record) + } else if (col.enter !== '$noAct') { MKEmitter.emit('tdFocus', col.enter + record.$$uuid) } }, 50) - MKEmitter.emit('changeRecord', col.tableId, {...record, [col.field]: val}) + 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}) } onSelectChange = (val, option) => { @@ -255,7 +267,9 @@ setTimeout(() => { if (col.enter === '$next') { MKEmitter.emit('nextLine', col, record.$$uuid) - } else { + } else if (col.enter === '$sub') { + MKEmitter.emit('subLine', col, record) + } else if (col.enter !== '$noAct') { MKEmitter.emit('tdFocus', col.enter + record.$$uuid) } }, 50) @@ -314,16 +328,28 @@ {err ? <Tooltip title={err}><ExclamationCircleOutlined /></Tooltip> : null} </td>) } else if (col.editType === 'switch') { - let _value = record[col.field] !== undefined ? record[col.field] : '' + let _value = '' + if (col.editField) { + _value = record[col.editField] !== undefined ? record[col.editField] : '' + } else { + _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 = record[col.field] !== undefined ? record[col.field] : '' + let _value = '' + if (col.editField) { + _value = record[col.editField] !== undefined ? record[col.editField] : '' + } else { + _value = record[col.field] !== undefined ? record[col.field] : '' + } return (<td className="editing_table_cell"> <Select showSearch defaultValue={_value} + dropdownClassName="edit-table-dropdown" + dropdownMatchSelectWidth={col.dropdown === 'fixed'} id={col.uuid + record.$$uuid} onBlur={() => this.setState({editing: false})} filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0} @@ -522,7 +548,9 @@ setTimeout(() => { if (col.enter === '$next') { MKEmitter.emit('nextLine', col, record.$$uuid) - } else { + } else if (col.enter === '$sub') { + MKEmitter.emit('subLine', col, record) + } else if (col.enter !== '$noAct') { MKEmitter.emit('tdFocus', col.enter + record.$$uuid) } }, 50) @@ -581,18 +609,28 @@ MKEmitter.emit('changeRecord', col.tableId, {...record, [col.field]: val}) } - onSwitchChange = (val) => { + onSwitchChange = (val, label) => { const { col, record } = this.props setTimeout(() => { if (col.enter === '$next') { MKEmitter.emit('nextLine', col, record.$$uuid) - } else { + } else if (col.enter === '$sub') { + MKEmitter.emit('subLine', col, record) + } else if (col.enter !== '$noAct') { MKEmitter.emit('tdFocus', col.enter + record.$$uuid) } }, 50) - MKEmitter.emit('changeRecord', col.tableId, {...record, [col.field]: val}) + 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}) } onSelectChange = (val, option) => { @@ -619,7 +657,9 @@ setTimeout(() => { if (col.enter === '$next') { MKEmitter.emit('nextLine', col, record.$$uuid) - } else { + } else if (col.enter === '$sub') { + MKEmitter.emit('subLine', col, record) + } else if (col.enter !== '$noAct') { MKEmitter.emit('tdFocus', col.enter + record.$$uuid) } }, 50) @@ -634,7 +674,13 @@ let children = null if (col.type === 'text') { if (col.editable === 'true') { - let _value = record[col.field] !== undefined ? record[col.field] : '' + let _value = '' + if (col.editField) { + _value = record[col.editField] !== undefined ? record[col.editField] : '' + } else { + _value = record[col.field] !== undefined ? record[col.field] : '' + } + if (!col.editType || col.editType === 'text') { children = (<> <Input id={col.uuid + record.$$uuid} defaultValue={_value} onChange={(e) => this.onChange(e.target.value)} onPressEnter={this.enterPress} onBlur={this.onBlur}/> @@ -648,9 +694,10 @@ children = (<> <Select showSearch + dropdownClassName="edit-table-dropdown" + dropdownMatchSelectWidth={col.dropdown === 'fixed'} defaultValue={_value} id={col.uuid + record.$$uuid} - onBlur={() => this.setState({editing: false})} filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0} onSelect={this.onSelectChange} > @@ -830,6 +877,8 @@ total: PropTypes.any, // 鎬绘暟 loading: PropTypes.bool, // 琛ㄦ牸鍔犺浇涓� refreshdata: PropTypes.func, // 琛ㄦ牸涓帓搴忓垪銆侀〉鐮佺殑鍙樺寲鏃跺埛鏂� + changeLock: PropTypes.func, + chgSelectData: PropTypes.func, } state = { @@ -846,12 +895,12 @@ pickup: false, // 鏀惰捣鏈�夋嫨椤� orderfields: {}, // 鎺掑簭id涓巉ield杞崲 loading: false, - editable: 'false', + editable: false, pageOptions: [] } UNSAFE_componentWillMount () { - const { setting, fields, columns, data } = this.props + const { setting, fields, columns } = this.props let orderfields = {} let initEditLine = null let edColumns = [] @@ -933,13 +982,12 @@ this.setState({ pageSize: setting.pageSize || 10, pageOptions, - data, columns: _columns, edColumns, tableId: setting.tableId, orderfields, initEditLine, - editable: setting.editable + editable: setting.editable === 'true' }, () => { if (deForms.length > 0) { this.improveActionForm(deForms) @@ -953,23 +1001,17 @@ componentDidMount () { const { fields, setting } = this.props - const { data, editable } = this.state this.setState({ fields: fields.filter(item => item.field !== setting.primaryKey), }) - if (editable === 'true' && data && data.length > 0) { - this.setState({editable: 'false'}) - setTimeout(() => { - this.pickupChange() - }, 200) - } - + MKEmitter.addListener('subLine', this.subLine) MKEmitter.addListener('nextLine', this.nextLine) MKEmitter.addListener('addRecord', this.addLine) MKEmitter.addListener('delRecord', this.delRecord) MKEmitter.addListener('resetTable', this.resetTable) + MKEmitter.addListener('transferData', this.transferData) MKEmitter.addListener('changeRecord', this.changeRecord) } @@ -980,22 +1022,44 @@ this.setState = () => { return } + MKEmitter.removeListener('subLine', this.subLine) MKEmitter.removeListener('nextLine', this.nextLine) MKEmitter.removeListener('addRecord', this.addLine) MKEmitter.removeListener('delRecord', this.delRecord) MKEmitter.removeListener('resetTable', this.resetTable) + MKEmitter.removeListener('transferData', this.transferData) MKEmitter.removeListener('changeRecord', this.changeRecord) } - UNSAFE_componentWillReceiveProps(nextProps) { - if (!is(fromJS(this.props.data), fromJS(nextProps.data))) { - this.setState({data: nextProps.data || []}) - if (this.state.editable === 'true' && !this.state.pickup) { - this.setState({editable: 'false'}) + transferData = (menuid, data, type) => { + if (menuid !== this.props.MenuID) return + + if (type !== 'line') { + this.setState({data: data || []}) + + if (this.state.editable && !this.state.pickup) { + this.setState({editable: false}) setTimeout(() => { this.pickupChange() }, 200) } + } else if (type === 'line' && data.$$uuid) { + let _data = this.state.data.map(item => { + if (item.$$uuid === data.$$uuid) { + return data + } else { + return item + } + }) + let _edData = this.state.edData.map(item => { + if (item.$$uuid === data.$$uuid) { + return data + } else { + return item + } + }) + + this.setState({edData: _edData, data: _data}) } } @@ -1172,15 +1236,82 @@ if (next && initEditLine) { MKEmitter.emit('tdFocus', initEditLine.uuid + next.$$uuid) - } else if (col.footEnter === 'add' && setting.addable === 'true') { + } else if (setting.addable === 'true') { setTimeout(() => { this.plusLine() }, 10) - } else if (col.footEnter === 'sub') { - setTimeout(() => { - this.checkData() - }, 10) } + } + + subLine = (col, record) => { + const { tableId, fields, edData } = this.state + + if (col && col.tableId !== tableId) return + + if (edData.filter(item => !item.$origin).length > 1) { + setTimeout(() => { + this.submit(edData) + }, 10) + return + } + + setTimeout(() => { + let item = fromJS(record).toJS() + let line = [] + fields.forEach(col => { + if (col.editable !== 'true' || item.$deleted) { + if (col.type === 'number') { + item[col.field] = +item[col.field] + if (isNaN(item[col.field])) { + item[col.field] = 0 + } + } else { + item[col.field] = item[col.field] !== undefined ? (item[col.field] + '') : '' + } + return + } + if (col.type === 'text') { + let val = item[col.field] !== undefined ? (item[col.field] + '') : '' + if (col.required === 'true' && !val) { + line.push(`${col.label}涓嶅彲涓虹┖`) + } + item[col.field] = val + } else if (col.type === 'number') { + let val = item[col.field] + if (!val && val !== 0) { + line.push(`${col.label}涓嶅彲涓虹┖`) + return + } + val = +val + if (isNaN(val)) { + line.push(`${col.label}鏁版嵁鏍煎紡閿欒`) + return + } + + val = +val.toFixed(col.decimal || 0) + + if (typeof(col.max) === 'number' && val > col.max) { + line.push(`${col.label}涓嶅彲澶т簬${col.max}`) + } else if (typeof(col.min) === 'number' && val < col.min) { + line.push(`${col.label}涓嶅彲灏忎簬${col.min}`) + } + + item[col.field] = val + } + }) + + let err = line.join('锛�') + + if (err) { + notification.warning({ + top: 92, + message: err, + duration: 5 + }) + } else { + this.submit([item], 'simple') + } + }, 10) } plusLine = () => { @@ -1213,6 +1344,7 @@ } delRecord = (id, record) => { + const { setting } = this.props const { tableId, edData } = this.state if (id !== tableId) return @@ -1232,6 +1364,10 @@ return item } }) + + if (setting.commit === 'simple' && record.$deleted) { + this.subLine(null, record) + } } this.setState({edData: _data}) @@ -1401,11 +1537,11 @@ } } - submit = (data) => { + submit = (data, type) => { const { submit, BID, setting } = this.props const { fields } = this.state - if (setting.commit === 'change') { + if (type !== 'simple' && (setting.commit === 'change' || setting.commit === 'simple')) { data = data.filter(item => !item.$origin) } @@ -1457,7 +1593,12 @@ Api.genericInterface(param).then((res) => { if (res.status) { - this.execSuccess(res) + if (type === 'simple') { + this.updataLine(data[0]) + this.execSuccess(res, type) + } else { + this.execSuccess(res) + } } else { this.execError(res) } @@ -1469,7 +1610,12 @@ Api.genericInterface(param).then((res) => { if (res.status) { - this.execSuccess(res) + if (type === 'simple') { + this.updataLine(data[0]) + this.execSuccess(res, type) + } else { + this.execSuccess(res) + } } else { this.execError(res) } @@ -1479,7 +1625,26 @@ } } - execSuccess = (res) => { + updataLine = (item) => { + if (item.$type === 'del') { + let _data = this.state.edData.filter(m => m.$$uuid !== item.$$uuid) + + this.setState({edData: _data}) + } else { + let _data = this.state.edData.map(m => { + if (m.$$uuid === item.$$uuid) { + item.$origin = true + return item + } + return m + }) + + this.setState({edData: _data}) + } + MKEmitter.emit('reloadData', this.props.MenuID, item.$$uuid, item) + } + + execSuccess = (res, type) => { const { submit } = this.props if (res && res.ErrCode === 'S') { // 鎵ц鎴愬姛 @@ -1499,6 +1664,8 @@ this.setState({ loading: false }) + + if (type === 'simple') return if (submit.closetab === 'true') { MKEmitter.emit('popclose') @@ -1544,8 +1711,14 @@ } repick = () => { + const { setting } = this.props const { data } = this.state + if (setting.submittal === 'true') { + this.setState({editable: true}) + } + + this.props.changeLock(false) this.setState({ data: [], edData: [], @@ -1692,6 +1865,7 @@ }) } else { pickup && MKEmitter.emit('resetSelectLine', MenuID, '', '') + pickup && this.props.chgSelectData([]) this.setState({ data: [], edData: [], @@ -1705,6 +1879,7 @@ }) }) } + this.props.changeLock(pickup) } render() { 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 c66d3dc..9ab832e 100644 --- a/src/tabviews/custom/components/table/edit-table/normalTable/index.scss +++ b/src/tabviews/custom/components/table/edit-table/normalTable/index.scss @@ -201,11 +201,24 @@ } } .editing_all_table_cell { + .ant-input { + border-radius: 0; + } .ant-select { width: 100%; + .ant-select-selection { + border-radius: 0; + } } - .ant-input-number-handler-wrap { - display: none; + .ant-input-number { + border-radius: 0; + + .ant-input-number-handler-wrap { + display: none; + } + .ant-input-number-input { + border-radius: 0; + } } .anticon-exclamation-circle { color: #ff4d4f; @@ -259,15 +272,11 @@ } .mk-add-line { display: block; - width: 100%; + width: 100px; color: #26C281; - border: 1px solid #dddddd; border-radius: 0; font-size: 25px; - height: 40px; - } - .mk-add-line:disabled { - border-color: #fafafa!important; + height: 45px; } } .edit-custom-table.buoyMode { @@ -370,4 +379,10 @@ cursor: pointer; } } +} +.edit-table-dropdown { + .ant-select-dropdown-menu-item { + white-space: unset; + text-overflow: unset; + } } \ No newline at end of file diff --git a/src/tabviews/zshare/actionList/index.jsx b/src/tabviews/zshare/actionList/index.jsx index 068783c..be12727 100644 --- a/src/tabviews/zshare/actionList/index.jsx +++ b/src/tabviews/zshare/actionList/index.jsx @@ -18,6 +18,7 @@ class ActionList extends Component { static propTpyes = { BID: PropTypes.any, // 涓昏〃ID + lock: PropTypes.any, // 鍙紪杈戣〃涓寜閽攣瀹� BData: PropTypes.any, // 涓昏〃鏁版嵁 selectedData: PropTypes.any, // 瀛愯〃涓�夋嫨鏁版嵁 Tab: PropTypes.any, // 濡傛灉褰撳墠鍏冪礌涓烘爣绛炬椂锛宼ab涓烘爣绛句俊鎭� @@ -35,7 +36,7 @@ } getButtonList = (actions) => { - const { BID, BData, MenuID, Tab, columns, setting, ContainerId, selectedData } = this.props + const { BID, BData, MenuID, Tab, columns, setting, ContainerId, selectedData, lock } = this.props return actions.map(item => { if (['exec', 'prompt', 'pop'].includes(item.OpenType)) { @@ -43,6 +44,7 @@ <NormalButton key={item.uuid} show={item.show || 'actionList'} + disabled={lock || false} BID={BID} Tab={Tab} btn={item} @@ -58,6 +60,7 @@ <ExcelInButton key={item.uuid} show={item.show || 'actionList'} + disabled={lock || false} BID={BID} Tab={Tab} btn={item} @@ -71,6 +74,7 @@ <ExcelOutButton key={item.uuid} show={item.show || 'actionList'} + disabled={lock || false} BID={BID} Tab={Tab} btn={item} @@ -83,6 +87,7 @@ <PopupButton key={item.uuid} show={item.show || 'actionList'} + disabled={lock || false} BID={BID} Tab={Tab} btn={item} @@ -96,6 +101,7 @@ <TabButton key={item.uuid} show={item.show || 'actionList'} + disabled={lock || false} btn={item} BData={BData} MenuID={MenuID} @@ -108,6 +114,7 @@ <NewPageButton key={item.uuid} show="actionList" + disabled={lock || false} btn={item} BData={BData} setting={setting} @@ -120,6 +127,7 @@ <ChangeUserButton key={item.uuid} show={item.show || 'actionList'} + disabled={lock || false} BID={BID} btn={item} BData={BData} @@ -133,6 +141,7 @@ <PrintButton key={item.uuid} show={item.show || 'actionList'} + disabled={lock || false} BID={BID} Tab={Tab} btn={item} diff --git a/src/tabviews/zshare/actionList/popupbutton/index.jsx b/src/tabviews/zshare/actionList/popupbutton/index.jsx index f1b9b3b..cc5849f 100644 --- a/src/tabviews/zshare/actionList/popupbutton/index.jsx +++ b/src/tabviews/zshare/actionList/popupbutton/index.jsx @@ -184,7 +184,7 @@ // 闇�瑕侀�夋嫨鍗曡鏃讹紝鏍¢獙鏁版嵁 notification.warning({ top: 92, - message: this.state.dict['main.action.confirm.selectSingleLine'], + message: data.length === 0 ? '璇烽�夋嫨琛岋紒' : '璇烽�夋嫨鍗曡鏁版嵁锛�', duration: 5 }) return -- Gitblit v1.8.0