From c98e45bfac25e9110ad0383faac54a54d98ea9d5 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期四, 18 十一月 2021 20:47:04 +0800 Subject: [PATCH] 2021-11-18 --- src/tabviews/scriptmanage/index.jsx | 133 +++++++++++++++++++------------------------- 1 files changed, 58 insertions(+), 75 deletions(-) diff --git a/src/tabviews/scriptmanage/index.jsx b/src/tabviews/scriptmanage/index.jsx index 22912bf..06d760a 100644 --- a/src/tabviews/scriptmanage/index.jsx +++ b/src/tabviews/scriptmanage/index.jsx @@ -10,11 +10,15 @@ import Utils from '@/utils/utils.js' import options from '@/store/options.js' import { scriptMainTable, buttonConfig } from './config' +import MKEmitter from '@/utils/events.js' -import MainTable from '@/tabviews/zshare/normalTable' -import TopSearch from './topSearch' +import asyncComponent from '@/utils/asyncComponent' +import asyncSpinComponent from '@/utils/asyncSpinComponent' import MainAction from './actionList' import './index.scss' + +const MainSearch = asyncComponent(() => import('@/tabviews/zshare/topSearch')) +const MainTable = asyncSpinComponent(() => import('@/tabviews/zshare/normalTable')) class ScriptTable extends Component { static propTpyes = { @@ -31,9 +35,9 @@ actions: [], // 鎸夐挳闆� columns: [], // 鏄剧ず鍒� arr_field: '', // 浣跨敤 sPC_Get_TableData 鏃剁殑鏌ヨ瀛楁闆� - logcolumns: null, // 鏃ュ織涓樉绀虹殑鍒椾俊鎭� (澧炲姞鑷冲叏閮ㄥ垪锛岄櫎鍘诲悎骞跺垪) setting: {}, // 椤甸潰鍏ㄥ眬璁剧疆锛氭暟鎹簮銆佹寜閽強鏄剧ず鍒楀浐瀹氥�佷富閿瓑 data: [], // 鍒楄〃鏁版嵁闆� + selectedData: [], // 宸查�夎〃鏍兼暟鎹� total: 0, // 鎬绘暟 loading: false, // 鍒楄〃鏁版嵁鍔犺浇涓� pageIndex: 1, // 椤电爜 @@ -52,7 +56,6 @@ let _arrField = [] // 瀛楁闆� let _columns = [] // 鏄剧ず鍒� - let _logcolumns = [] // 鏃ュ織鏄剧ず鍒� let _hideCol = [] // 闅愯棌鍙婂悎骞跺垪涓瓧娈电殑uuid闆� let colMap = new Map() // 鐢ㄤ簬瀛楁杩囨护 @@ -60,13 +63,9 @@ config.columns.forEach(col => { if (col.field) { _arrField.push(col.field) - - _logcolumns.push(col) } if (col.type === 'colspan' && col.sublist) { // 绛涢�夐殣钘忓垪 _hideCol = _hideCol.concat(col.sublist) - } else if (col.Hide === 'true') { - _hideCol.push(col.uuid) } colMap.set(col.uuid, col) }) @@ -75,16 +74,22 @@ config.columns.forEach(col => { if (_hideCol.includes(col.uuid)) return - if (col.type === 'colspan' && col.sublist) { - let _col = JSON.parse(JSON.stringify(col)) - let subColumn = [] - _col.sublist.forEach(sub => { + if (col.type === 'colspan') { + if (col.unfold !== 'true') { // 涓嶅睍寮�涓烘棫鐗堝悎骞跺垪 + col.type = 'old_colspan' + } + + let _col = fromJS(col).toJS() + let subcols = [] + _col.sublist && _col.sublist.forEach(sub => { if (colMap.has(sub)) { - subColumn.push(colMap.get(sub)) + subcols.push(colMap.get(sub)) } }) - _col.subColumn = subColumn - _columns.push(_col) + if (subcols.length > 0) { + _col.subcols = subcols + _columns.push(_col) + } } else { _columns.push(col) } @@ -101,7 +106,6 @@ return item }), columns: _columns, - logcolumns: _logcolumns, arr_field: _arrField.join(','), search: Utils.initMainSearch(config.search) }, () => { @@ -116,6 +120,7 @@ * @description 涓昏〃鏁版嵁鍔犺浇 */ async loadmaindata () { + const { setting } = this.state let param = this.getDefaultParam() this.setState({ @@ -130,8 +135,8 @@ if (result.status) { this.setState({ data: result.data.map((item, index) => { - item.LongParam = Utils.formatOptions(item.LongParam, true) item.key = index + item.$$uuid = item[setting.primaryKey] || '' return item }), total: result.total, @@ -162,7 +167,8 @@ let param = { func: 'sPC_Get_TableData', obj_name: 'data', - arr_field: arr_field + arr_field: arr_field, + menuname: this.props.MenuName || '' } let _orderBy = orderBy || setting.order @@ -176,9 +182,11 @@ let DateCount = `select count(1) as total from ${_dataresource} ${_search}` param.LText = Utils.formatOptions(LText) - param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' + param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') param.secretkey = Utils.encrypt(param.LText, param.timestamp) param.DateCount = Utils.formatOptions(DateCount) + + param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp) // 浜戠鏁版嵁楠岃瘉 return param } @@ -188,11 +196,11 @@ * 鍚湁鍒濆涓嶅姞杞界殑椤甸潰锛屼慨鏀硅缃� */ refreshbysearch = (searches) => { - this.refs.mainTable.resetTable() - + MKEmitter.emit('resetTable', this.props.MenuID) // 鍒楄〃閲嶇疆 this.setState({ loading: true, pageIndex: 1, + selectedData: [], search: searches }, () => { this.loadmaindata() @@ -213,6 +221,7 @@ this.setState({ loading: true, + selectedData: [], pageIndex: pagination.current, pageSize: pagination.pageSize, orderBy: (sorter.field && sorter.order) ? `${sorter.field} ${sorter.order}` : '' @@ -225,10 +234,11 @@ * @description 琛ㄦ牸鍒锋柊 */ reloadtable = () => { - this.refs.mainTable.resetTable() + MKEmitter.emit('resetTable', this.props.MenuID) // 鍒楄〃閲嶇疆 this.setState({ loading: true, - pageIndex: 1 + pageIndex: 1, + selectedData: [] }, () => { this.loadmaindata() }) @@ -238,50 +248,18 @@ * @description 椤甸潰鍒锋柊锛岄噸鏂拌幏鍙栭厤缃� */ reloadview = () => { - this.setState({ - config: {}, - searchlist: [], - actions: [], - columns: [], - arr_field: '', - setting: {}, - data: [], - total: 0, - loading: false, - pageIndex: 1, - pageSize: 10, - orderBy: '', - search: '', - pickup: false + this.setState({ config: {}, searchlist: [], actions: [], columns: [], arr_field: '', setting: {}, data: [], total: 0, + loading: false, pageIndex: 1, pageSize: 10, orderBy: '', search: '', pickup: false, selectedData: [] }, () => { this.loadconfig() }) } /** - * @description 鎸夐挳鎿嶄綔瀹屾垚鍚庯紙鎴愬姛鎴栧け璐ワ級锛岄〉闈㈠埛鏂帮紝閲嶇疆椤电爜鍙婇�夋嫨椤� + * @description 琛ㄦ牸閫夋嫨椤瑰垏鎹� */ - refreshbyaction = (btn, type) => { - if (btn.execSuccess === 'grid' && type === 'success') { - this.reloadtable() - } else if (btn.execError === 'grid' && type === 'error') { - this.reloadtable() - } else if (btn.execSuccess === 'view' && type === 'success') { - this.reloadview() - } else if (btn.execError === 'view' && type === 'error') { - this.reloadview() - } - } - - /** - * @description 鑾峰彇琛ㄦ牸閫夋嫨椤� - */ - gettableselected = () => { - let data = [] - this.refs.mainTable.state.selectedRowKeys.forEach(item => { - data.push(this.refs.mainTable.props.data[item]) - }) - return data + changeSelectedData = (selectedData) => { + this.setState({selectedData}) } /** @@ -294,9 +272,21 @@ }) } + reloadMenuView = (menuId) => { + const { MenuID } = this.props + + if (MenuID !== menuId) return + + this.reloadview() + } + UNSAFE_componentWillMount () { // 缁勪欢鍔犺浇鏃讹紝鑾峰彇鑿滃崟鏁版嵁 this.loadconfig() + } + + componentDidMount () { + MKEmitter.addListener('reloadMenuView', this.reloadMenuView) } shouldComponentUpdate (nextProps, nextState) { @@ -310,18 +300,15 @@ this.setState = () => { return } + MKEmitter.removeListener('reloadMenuView', this.reloadMenuView) } render() { - const { dict, searchlist, config, setting, actions, columns, pickup } = this.state + const { searchlist, setting, actions, columns, pickup, selectedData } = this.state return ( - <div className="veruptable pick-control" id={this.state.ContainerId}> - <TopSearch - dict={dict} - searchlist={searchlist} - refreshdata={this.refreshbysearch} - /> + <div className="script-manage-table" id={this.state.ContainerId}> + <MainSearch searchlist={searchlist} menuType="HS" refreshdata={this.refreshbysearch}/> <MainAction BID="" type="main" @@ -329,10 +316,9 @@ actions={actions} dict={this.state.dict} MenuID={this.props.MenuID} - logcolumns={this.state.logcolumns} + selectedData={selectedData} ContainerId={this.state.ContainerId} - refreshdata={this.refreshbyaction} - gettableselected={this.gettableselected} + refreshdata={this.reloadtable} /> <div className="main-table-box"> {this.state.data && this.state.data.length > 0 ? @@ -341,11 +327,8 @@ </div> : null } <MainTable - ref="mainTable" - menuType="HS" - tableId="mainTable" + tableId={this.props.MenuID} pickup={pickup} - config={config} setting={setting} columns={columns} dict={this.state.dict} @@ -355,7 +338,7 @@ loading={this.state.loading} refreshdata={this.refreshbytable} buttonTrigger={() => {}} - handleTableId={() => {}} + chgSelectData={this.changeSelectedData} /> </div> </div> -- Gitblit v1.8.0