From 162440a345abe2432df48b933bb858e6f1b56449 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期四, 18 一月 2024 11:26:38 +0800 Subject: [PATCH] 2024-01-18 --- src/tabviews/custom/components/table/base-table/index.jsx | 95 +++++++++++++++++++++++++++++++---------------- 1 files changed, 62 insertions(+), 33 deletions(-) diff --git a/src/tabviews/custom/components/table/base-table/index.jsx b/src/tabviews/custom/components/table/base-table/index.jsx index c05ea6d..7c86fca 100644 --- a/src/tabviews/custom/components/table/base-table/index.jsx +++ b/src/tabviews/custom/components/table/base-table/index.jsx @@ -25,7 +25,6 @@ config: {}, // 椤甸潰閰嶇疆淇℃伅锛屽寘鎷寜閽�佹悳绱€�佹樉绀哄垪銆佹爣绛剧瓑 actions: null, // 鎸夐挳闆� columns: null, // 鏄剧ず鍒� - arr_field: '', // 鏌ヨ瀛楁闆� setting: null, // 椤甸潰鍏ㄥ眬璁剧疆锛氭暟鎹簮銆佹寜閽強鏄剧ず鍒楀浐瀹氥�佷富閿瓑 data: [], // 鍒楄〃鏁版嵁闆� selectedData: [], // 宸查�夎〃鏍兼暟鎹� @@ -82,7 +81,6 @@ setting: setting, actions: _config.action, columns: _config.cols, - arr_field: _config.columns.map(col => col.field).join(','), search: _config.$searches }, () => { if (_config.setting.onload === 'true') { @@ -100,7 +98,7 @@ * @param { String } repage 琛ㄦ牸鏄惁閲嶇疆椤电爜 */ async loadmaindata (reset, repage, id) { - 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) { // BID 涓嶅瓨鍦ㄦ椂锛屼笉鍋氭煡璇� this.setState({ @@ -137,9 +135,9 @@ }) 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) + let result = await Api.genericInterface(param, setting.js_script) if (result.status) { if (repage === 'false' && result.data && result.data.length === 0 && result.total > 0 && pageIndex > 1) { let _pageIndex = Math.ceil(result.total / pageSize) @@ -263,8 +261,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) { // 涓昏〃鎼滅储鏉′欢 @@ -282,10 +285,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() @@ -382,6 +390,8 @@ getStatFieldsValue = () => { const { setting, config, search, BID, orderBy } = this.state + if (!config.statFields) return + if (setting.supModule && !BID) { // BID 涓嶅瓨鍦ㄦ椂锛屼笉鍋氭煡璇� this.setState({ statFValue: [] @@ -513,7 +523,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 @@ -529,10 +539,8 @@ } callback({ - arr_field: arr_field, orderBy: orderBy || setting.order, - search: searches, - menuName: config.name + search: searches }) } @@ -544,7 +552,7 @@ if (!id) { this.reloadtable() } else { - this.loadmainLinedata(id) + this.loadLinedata(id) } } @@ -558,8 +566,10 @@ BID: id, BData: data }, () => { - this.loadmaindata(true, 'true') - this.getStatFieldsValue() + if (!setting.checkBid) { + this.loadmaindata(true, 'true') + this.getStatFieldsValue() + } }) } } @@ -575,9 +585,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) } @@ -598,6 +608,25 @@ }) } + autoExec = (times) => { + const { config } = this.state + + if (!config.wrap.autoExec) return + + let btn = document.getElementById('button' + config.wrap.autoExec) + + this.autoTimer && clearTimeout(this.autoTimer) + + if (btn) { + MKEmitter.emit('triggerBtnId', config.wrap.autoExec, []) + } else if (!times || times < 20) { + times = times ? times + 1 : 1 + this.autoTimer = setTimeout(() => { + this.autoExec(times) + }, 1000) + } + } + shouldComponentUpdate (nextProps, nextState) { return !is(fromJS(this.props), fromJS(nextProps)) || !is(fromJS(this.state), fromJS(nextState)) } @@ -613,6 +642,8 @@ if (config.setting.useMSearch) { MKEmitter.addListener('searchRefresh', this.searchRefresh) } + + this.autoExec() } /** @@ -645,22 +676,20 @@ columns={config.columns} selectedData={selectedData} /> : <div style={{height: '25px'}}></div>} - <div className="main-table-box"> - <MainTable - data={data} - setting={setting} - columns={columns} - MenuID={config.uuid} - fields={config.columns} - total={this.state.total} - autoMatic={config.autoMatic} - lineMarks={config.lineMarks} - loading={this.state.loading} - refreshdata={this.refreshbytable} - statFValue={this.state.statFValue} - chgSelectData={(selects) => this.setState({selectedData: selects})} - /> - </div> + <MainTable + data={data} + setting={setting} + columns={columns} + MenuID={config.uuid} + fields={config.columns} + total={this.state.total} + autoMatic={config.autoMatic} + lineMarks={config.lineMarks} + loading={this.state.loading} + refreshdata={this.refreshbytable} + statFValue={this.state.statFValue} + chgSelectData={(selects) => this.setState({selectedData: selects})} + /> </div> ) } -- Gitblit v1.8.0