From a5f41b5d98f23d618dc7519c605ce943b114dfd5 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期一, 13 十一月 2023 18:07:51 +0800 Subject: [PATCH] 2023-11-13 --- src/tabviews/custom/components/table/normal-table/index.jsx | 180 ++++++++++++++++++++++------------------------------------- 1 files changed, 67 insertions(+), 113 deletions(-) diff --git a/src/tabviews/custom/components/table/normal-table/index.jsx b/src/tabviews/custom/components/table/normal-table/index.jsx index 9b114c1..a1492a3 100644 --- a/src/tabviews/custom/components/table/normal-table/index.jsx +++ b/src/tabviews/custom/components/table/normal-table/index.jsx @@ -29,7 +29,6 @@ config: {}, // 椤甸潰閰嶇疆淇℃伅锛屽寘鎷寜閽�佹悳绱€�佹樉绀哄垪銆佹爣绛剧瓑 actions: null, // 鎸夐挳闆� columns: null, // 鏄剧ず鍒� - arr_field: '', // 鏌ヨ瀛楁闆� setting: null, // 椤甸潰鍏ㄥ眬璁剧疆锛氭暟鎹簮銆佹寜閽強鏄剧ず鍒楀浐瀹氥�佷富閿瓑 data: [], // 鍒楄〃鏁版嵁闆� selectedData: [], // 宸查�夎〃鏍兼暟鎹� @@ -39,7 +38,8 @@ pageSize: 10, // 姣忛〉鏁版嵁鏉℃暟 orderBy: '', // 鎺掑簭 search: '', // 鎼滅储鏉′欢鏁扮粍锛屼娇鐢ㄦ椂闇�鍒嗗満鏅鐞� - statFValue: [] // 鍚堣鍊� + statFValue: [], // 鍚堣鍊� + allSearch: null } loaded = false @@ -88,7 +88,7 @@ _data = window.GLOB.SyncData.get(_config.dataName) || [] if (_config.$cache) { - Api.writeCacheConfig(_config.uuid, fromJS(_data).toJS()) + Api.writeCacheConfig(_config.uuid, fromJS(_data).toJS(), BID) } _config.setting.sync = 'false' @@ -139,6 +139,18 @@ _config.style = _config.style || {} + let allSearch = null + if (_config.colsCtrls && _config.colsCtrls.length > 0) { + allSearch = [{key: 'BID', value: BID || ''}] + allSearch.push(..._config.$searches) + if (_config.setting.useMSearch) { + let mainSearch = window.GLOB.SearchBox.get(_config.$searchId) || [] + allSearch.push(...mainSearch) + } + } else { + _config.colsCtrls = null + } + this.setState({ pageSize: setting.pageSize || 10, BID: BID || '', @@ -149,8 +161,8 @@ setting: setting, actions: _config.action, columns: _config.cols, - arr_field: _config.columns.map(col => col.field).join(','), - search: _config.$searches + search: _config.$searches, + allSearch }) } @@ -182,7 +194,6 @@ pageIndex: 1 }, () => { this.loadmaindata(true, 'true', '', 'timer') - this.getStatFieldsValue() }) }) } @@ -209,12 +220,12 @@ } initExec = () => { - const { config, setting } = this.state + const { config, setting, BID } = this.state if (config.$cache) { if (config.$time && !setting.laypage) { if (!this.loaded) { - Api.getLCacheConfig(config.uuid, config.$time).then(res => { + Api.getLCacheConfig(config.uuid, config.$time, BID).then(res => { if (!res.valid && config.setting.onload === 'true') { setTimeout(() => { this.loadmaindata(false, 'true', '', 'init') @@ -249,7 +260,7 @@ } } else { if (!this.loaded) { - Api.getLCacheConfig(config.uuid, 0).then(res => { + Api.getLCacheConfig(config.uuid, 0, BID).then(res => { if (!res.data || this.loaded) return this.setState({data: res.data.map((item, index) => { @@ -280,14 +291,12 @@ if (config.setting.onload === 'true') { setTimeout(() => { this.loadmaindata(false, 'true', '', 'init') - this.getStatFieldsValue() }, config.setting.delay || 0) } } } else if (config.setting.onload === 'true') { setTimeout(() => { this.loadmaindata() - this.getStatFieldsValue() }, config.setting.delay || 0) } } @@ -302,7 +311,7 @@ let _data = window.GLOB.SyncData.get(config.dataName) || [] if (config.$cache) { - Api.writeCacheConfig(config.uuid, fromJS(_data).toJS()) + Api.writeCacheConfig(config.uuid, fromJS(_data).toJS(), BID) } _data = _data.map((item, index) => { @@ -354,7 +363,7 @@ * @param { String } repage 琛ㄦ牸鏄惁閲嶇疆椤电爜 */ async loadmaindata (reset, repage, id, type) { - const { setting, config, arr_field, search, orderBy, BID, pageIndex, pageSize, BData } = this.state + const { setting, config, search, orderBy, BID, pageIndex, pageSize, BData } = this.state if (setting.supModule && !BID && setting.supKey !== 'false') { // BID 涓嶅瓨鍦ㄦ椂锛屼笉鍋氭煡璇� this.setState({ @@ -395,13 +404,13 @@ } let _orderBy = orderBy || setting.order - let param = UtilsDM.getQueryDataParams(setting, arr_field, searches, _orderBy, pageIndex, pageSize, BID) + let param = UtilsDM.getQueryDataParams(setting, searches, _orderBy, pageIndex, pageSize, BID) let result = await Api.genericInterface(param) if (result.status) { this.loaded = true if (config.$cache && type === 'init') { - Api.writeCacheConfig(config.uuid, result.data || []) + Api.writeCacheConfig(config.uuid, result.data || [], BID) } if (repage === 'false' && result.data && result.data.length === 0 && result.total > 0 && pageIndex > 1) { @@ -472,9 +481,16 @@ total = data[data.length - 1].mk_total || 0 } + let allSearch = null + if (config.colsCtrls) { + allSearch = [{key: 'BID', value: BID || ''}] + allSearch.push(...searches) + } + this.setState({ data: data, selectedData: [], + allSearch: allSearch, total: total, loading: false }) @@ -523,8 +539,13 @@ /** * @description 鑾峰彇鍗曡鏁版嵁 */ - async loadmainLinedata (id) { - const { setting, config, arr_field, search, orderBy, BID, pageIndex, pageSize, BData } = this.state + async loadLinedata (id, position) { + const { setting, config, search, orderBy, BID, pageIndex, pageSize, BData } = this.state + + if (config.forbidLine) { + this.reloadtable() + return + } let searches = fromJS(search).toJS() if (config.setting.useMSearch) { // 涓昏〃鎼滅储鏉′欢 @@ -542,10 +563,15 @@ }) let _orderBy = orderBy || setting.order - let param = UtilsDM.getQueryDataParams(setting, arr_field, searches, _orderBy, pageIndex, pageSize, BID, id) + let param = UtilsDM.getQueryDataParams(setting, searches, _orderBy, pageIndex, pageSize, BID, id) let result = await Api.genericInterface(param) if (result.status) { + if (position === 'line_grid' && (!result.data || !result.data[0])) { + this.loadmaindata(true, 'false') + return + } + let data = fromJS(this.state.data).toJS() let selectedData = fromJS(this.state.selectedData).toJS() @@ -641,72 +667,6 @@ } /** - * @description 鑾峰彇鍚堣瀛楁鍊� - */ - getStatFieldsValue = () => { - const { setting, config, search, BID, orderBy } = this.state - - if (setting.supModule && !BID && setting.supKey !== 'false') { // BID 涓嶅瓨鍦ㄦ椂锛屼笉鍋氭煡璇� - this.setState({ - statFValue: [] - }) - return - } - - if (config.statFields.length === 0 || setting.interType !== 'system' || !setting.dataresource) return - - let searches = fromJS(search).toJS() - if (config.setting.useMSearch) { // 涓昏〃鎼滅储鏉′欢 - let mainSearch = window.GLOB.SearchBox.get(config.$searchId) || [] - let keys = config.$s_keys || [] - mainSearch.forEach(item => { - if (keys.includes(item.key.toLowerCase())) return - - searches.push(item) - }) - } - - if (config.$s_req && searches.filter(item => item.required && item.value === '').length > 0) { - return - } - - let _orderBy = orderBy || setting.order - let param = UtilsDM.getStatQueryDataParams(setting, config.statFields, searches, _orderBy, BID) - - Api.genericInterface(param).then(res => { - if (res.status) { - let _data = res.data[0] - let values = [] - - if (_data) { - config.statFields.forEach(item => { - if (_data[item.field] || _data[item.field] === 0) { - let val = +_data[item.field] - if (isNaN(val)) { - val = 0 - } - val = val.toFixed(item.decimal) - values.push({label: item.label, value: val}) - } - }) - } - this.setState({ - statFValue: values - }) - } else { - this.setState({ - statFValue: [] - }) - notification.error({ - top: 92, - message: res.message, - duration: 10 - }) - } - }) - } - - /** * @description 鎼滅储鏉′欢鏀瑰彉鏃讹紝閲嶇疆琛ㄦ牸鏁版嵁 * 鍚湁鍒濆涓嶅姞杞界殑椤甸潰锛屼慨鏀硅缃� */ @@ -716,7 +676,6 @@ search: searches }, () => { this.loadmaindata(true, 'true') - this.getStatFieldsValue() }) } @@ -750,11 +709,9 @@ pageIndex: 1 }, () => { this.loadmaindata(true, 'true', id) - this.getStatFieldsValue() }) } else { this.loadmaindata(true, 'false', id) - this.getStatFieldsValue() } } @@ -762,7 +719,7 @@ * @description 瀵煎嚭Excel鏃讹紝鑾峰彇椤甸潰鎼滅储鎺掑簭绛夊弬鏁� */ queryModuleParam = (menuId, callback) => { - const { arr_field, config, orderBy, search, setting} = this.state + const { config, orderBy, search, setting} = this.state if (config.uuid !== menuId) return @@ -778,10 +735,8 @@ } callback({ - arr_field: arr_field, orderBy: orderBy || setting.order, - search: searches, - menuName: config.name + search: searches }) } @@ -793,7 +748,7 @@ if (!id) { this.reloadtable() } else { - this.loadmainLinedata(id) + this.loadLinedata(id) } } @@ -809,7 +764,6 @@ BData: data }, () => { this.loadmaindata(true, 'true') - this.getStatFieldsValue() }) } } @@ -825,9 +779,9 @@ if (config.uuid !== menuId) return - if (position === 'line') { + if (position === 'line' || position === 'line_grid') { if (lines && lines.length === 1) { - this.loadmainLinedata(lines[0].$$uuid) + this.loadLinedata(lines[0].$$uuid, position) } else { this.reloadtable(btn, id) } @@ -873,7 +827,7 @@ } render() { - const { BID, setting, actions, config, columns, selectedData, BData, data } = this.state + const { BID, setting, actions, config, columns, selectedData, BData, data, allSearch } = this.state let style = {...config.style} if (config.wrap.empty === 'hidden' && (!data || data.length === 0)) { @@ -881,7 +835,7 @@ } let content = <> - {config.search && config.search.length ? + {config.search.length ? <MainSearch BID={BID} config={config} refreshdata={this.refreshbysearch}/> : null } {actions.length > 0 ? <MainAction @@ -891,22 +845,22 @@ BData={BData} columns={config.columns} selectedData={selectedData} - /> : <div className="mk-action-space" style={{height: '25px'}}></div>} - <div className={'main-table-box ' + (!actions || actions.length === 0 ? 'no-action' : '')}> - <MainTable - setting={setting} - columns={columns} - MenuID={config.uuid} - data={this.state.data} - fields={config.columns} - total={this.state.total} - lineMarks={config.lineMarks} - loading={this.state.loading} - refreshdata={this.refreshbytable} - statFValue={this.state.statFValue} - chgSelectData={(selects) => this.setState({selectedData: selects})} - /> - </div> + /> : (setting.tableType || config.search.length > 0 ? <div className="mk-action-space" style={{height: '25px'}}></div> : null)} + <MainTable + setting={setting} + columns={columns} + MenuID={config.uuid} + allSearch={allSearch} + data={this.state.data} + fields={config.columns} + total={this.state.total} + colsCtrls={config.colsCtrls} + lineMarks={config.lineMarks} + loading={this.state.loading} + refreshdata={this.refreshbytable} + statFValue={this.state.statFValue} + chgSelectData={(selects) => this.setState({selectedData: selects})} + /> </> return ( -- Gitblit v1.8.0