From d5edf87014863eceaa44f28809ae4b54a39b9a8e Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期五, 23 五月 2025 10:54:05 +0800 Subject: [PATCH] Merge branch 'develop' --- src/tabviews/custom/components/table/normal-table/index.jsx | 110 ++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 104 insertions(+), 6 deletions(-) diff --git a/src/tabviews/custom/components/table/normal-table/index.jsx b/src/tabviews/custom/components/table/normal-table/index.jsx index ae15927..42ec308 100644 --- a/src/tabviews/custom/components/table/normal-table/index.jsx +++ b/src/tabviews/custom/components/table/normal-table/index.jsx @@ -77,7 +77,7 @@ let setting = {..._config.setting, ..._config.wrap} - if (setting.selected !== 'always' && setting.selected !== 'init' && setting.selected !== 'sign') { + if (!['always', 'init', 'sign', 'local'].includes(setting.selected)) { setting.selected = 'false' } @@ -131,6 +131,8 @@ window.GLOB.SyncData.delete(_config.dataName) } + } else if (_config.setting.supModule && !BID && _config.wrap.supKey !== 'false') { + _config.setting.onload = 'false' } if (_config.wrap.collapse === 'true') { @@ -149,6 +151,10 @@ } } else { _config.colsCtrls = null + } + + if (setting.$tree && _config.cols[0]) { + _config.cols[0].$tree = true } let columns = _config.cols @@ -571,7 +577,7 @@ Api.writeCacheConfig(config.uuid, result.data || [], BID) } - if (repage === 'false' && result.data.length === 0 && pageIndex > 1) { + if (result.data.length === 0 && pageIndex > 1) { this.reloadIndex() return } @@ -608,6 +614,10 @@ return item }) + if (setting.$tree && data.length) { + data = this.getTree(data) + } + let total = result.total || 0 if (config.setting.custompage && data.length) { total = data[data.length - 1].mk_total || 0 @@ -620,8 +630,12 @@ } if (data.length && (id || setting.selected !== 'false')) { + let keys = null + if (setting.selected === 'local') { + keys = this.state.selectedData.map(cell => cell.$$uuid) + } setTimeout(() => { - MKEmitter.emit('mkCheckTopLine', config.uuid, id, setting.selected) + MKEmitter.emit('mkCheckTopLine', config.uuid, id, setting.selected, keys) }, 200) } else { MKEmitter.emit('resetSelectLine', config.uuid, '', '') // 骞挎挱鏁版嵁鍒囨崲 @@ -663,6 +677,90 @@ UtilsDM.queryFail(result) } + } + + getTree = (data) => { + const { setting } = this.state + + let options = [] + let pnodes = [] + let _data = [] + + data.forEach(item => { + let pval = item[setting.parentField] + '' + let val = item[setting.valueField] + '' + + if (pval === setting.mark) { + pnodes.push({ + ...item, + $mk_floor: 1, + $key: val, + $pid: '' + }) + } else if (pval) { + options.push({ + ...item, + $mk_floor: 0, + $key: val, + $pid: pval + }) + } + }) + + let get_tree = (parents) => { + parents.forEach(parent => { + parent.children = [] + + options = options.filter(option => { + if (option.$pid === parent.$key) { + option.$mk_floor = parent.$mk_floor + 1 + option.$pkeys = parent.$pkeys ? [...parent.$pkeys, parent.$key] : [parent.$key] + + parent.children.push(option) + return false + } + return true + }) + + if (parent.children.length === 0) { + parent.children = null + } else { + parent.$open = true + parent.children = get_tree(parent.children) + } + }) + return parents + } + + let tree = get_tree(pnodes) + + let get_data = (parents) => { + parents.forEach(parent => { + let children = parent.children + + delete parent.children + + _data.push(parent) + + if (children) { + get_data(children) + } + }) + } + + get_data(tree) + + if (options.length) { + _data.push(...options) + } + + _data = _data.map((item, index) => { + item.key = index + + return item + }) + + return _data } /** @@ -803,7 +901,7 @@ if (setting.supModule && !BID && setting.supKey !== 'false') { notification.warning({ top: 92, - message: window.GLOB.dict['sup_key_req'] || '闇�瑕佷笂绾т富閿�硷紒', + message: setting.supModTip || window.GLOB.dict['sup_key_req'] || '闇�瑕佷笂绾т富閿�硷紒', duration: 5 }) this.setState({ @@ -823,7 +921,7 @@ /** * @description 琛ㄦ牸鏉′欢鏀瑰彉鏃堕噸缃暟鎹紙鍒嗛〉鎴栨帓搴忥級 */ - refreshbytable = (pagination, filters, sorter) => { + refreshbytable = (pagination, sorter) => { if (sorter.order) { let _chg = { ascend: 'asc', @@ -835,7 +933,7 @@ this.setState({ pageIndex: pagination.current, pageSize: pagination.pageSize, - orderBy: (sorter.field && sorter.order) ? `${sorter.field} ${sorter.order}` : '' + orderBy: (sorter.field && sorter.order) ? `${sorter.field} ${sorter.order}` : (pagination.fixed ? this.state.orderBy : '') }, () => { this.loadData() }) -- Gitblit v1.8.0