From 9e716f3bd30820a08757845b592db73363faa48c Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期一, 25 四月 2022 14:53:37 +0800 Subject: [PATCH] 2022-04-25 --- src/tabviews/subtabtable/index.jsx | 675 +++++++++++++++++++++++++++++++++++++------------------ 1 files changed, 451 insertions(+), 224 deletions(-) diff --git a/src/tabviews/subtabtable/index.jsx b/src/tabviews/subtabtable/index.jsx index 55d904d..9343c02 100644 --- a/src/tabviews/subtabtable/index.jsx +++ b/src/tabviews/subtabtable/index.jsx @@ -2,14 +2,15 @@ import PropTypes from 'prop-types' import {connect} from 'react-redux' import { is, fromJS } from 'immutable' -import { notification, Spin, Col, Row, Icon, Tabs} from 'antd' +import { notification, Spin} from 'antd' import Api from '@/api' import zhCN from '@/locales/zh-CN/main.js' import enUS from '@/locales/en-US/main.js' import Utils from '@/utils/utils.js' +import options from '@/store/options.js' import UtilsDM from '@/utils/utils-datamanage.js' -import UtilsUpdate from '@/utils/utils-update.js' +import { updateSubTabTable } from '@/utils/utils-update.js' import asyncComponent from '@/utils/asyncComponent' import asyncSpinComponent from '@/utils/asyncSpinComponent' import NotFount from '@/components/404' @@ -17,24 +18,17 @@ import './index.scss' -const { TabPane } = Tabs const SubSearch = asyncComponent(() => import('@/tabviews/zshare/topSearch')) const SubAction = asyncComponent(() => import('@/tabviews/zshare/actionList')) const SubTable = asyncSpinComponent(() => import('@/tabviews/zshare/normalTable')) -const CardComponent = asyncSpinComponent(() => import('@/tabviews/zshare/cardcomponent')) -const ChartComponent = asyncSpinComponent(() => import('@/tabviews/zshare/chartcomponent')) class SubTabModalTable extends Component { static propTpyes = { - type: PropTypes.any, // 绫诲瀷锛宑alendar闇�鐗规畩澶勭悊 Tab: PropTypes.any, // 鏃ュ巻鏍囩淇℃伅鎴栨爣绛炬寜閽俊鎭� BID: PropTypes.string, // 涓婄骇鏁版嵁ID BData: PropTypes.any, // 涓婄骇鏁版嵁 MenuID: PropTypes.string, // 鑿滃崟Id - mainSearch: PropTypes.any, // 涓昏〃鎼滅储鏉′欢 SupMenuID: PropTypes.string, // 涓婄骇鑿滃崟Id - refreshSupView: PropTypes.any, // 鍒锋柊涓婄骇鑿滃崟 - closeModalView: PropTypes.any // 鍏抽棴妯℃�佹 } state = { @@ -48,7 +42,7 @@ columns: null, // 鏄剧ず鍒� arr_field: '', // 浣跨敤 sPC_Get_TableData 鏃剁殑鏌ヨ瀛楁闆� setting: null, // 椤甸潰鍏ㄥ眬璁剧疆锛氭暟鎹簮銆佹寜閽強鏄剧ず鍒楀浐瀹氥�佷富閿瓑 - data: null, // 鍒楄〃鏁版嵁闆� + data: [], // 鍒楄〃鏁版嵁闆� selectedData: [], // 宸查�夎〃鏍兼暟鎹� total: 0, // 鎬绘暟 loading: false, // 鍒楄〃鏁版嵁鍔犺浇涓� @@ -56,17 +50,18 @@ pageSize: 10, // 姣忛〉鏁版嵁鏉℃暟 orderBy: '', // 鎺掑簭 search: '', // 鎼滅储鏉′欢鏁扮粍锛屼娇鐢ㄦ椂闇�鍒嗗満鏅鐞� - chartId: '', // 灞曞紑鍥捐〃ID statFields: [], // 鍚堣瀛楁 statFValue: [], // 鍚堣鍊� absFields: [], // 缁濆鍊煎瓧娈� + loadCustomApi: true, // 鍔犺浇澶栭儴璧勬簮 + hasReqFields: false } /** * @description 鑾峰彇椤甸潰閰嶇疆淇℃伅 */ async loadconfig () { - const { permAction, type, Tab } = this.props + const { permAction, Tab } = this.props let param = { func: 'sPC_Get_LongParam', @@ -78,6 +73,8 @@ try { // 閰嶇疆淇℃伅瑙f瀽 config = JSON.parse(window.decodeURIComponent(window.atob(result.LongParam))) + config.setting.MenuName = Tab.label + config.setting.$name = Tab.label } catch (e) { console.warn('Parse Failure') config = '' @@ -110,28 +107,17 @@ let absFields = [] // 缁濆鍊煎瓧娈� // 鐗堟湰鍏煎 - config = UtilsUpdate.updateSubTable(config) + config = updateSubTabTable(config) - // 浠呮敮鎸乪xec銆乸rompt銆乸op 涓夌绫诲瀷鎸夐挳 + // 涓嶆敮鎸乫uncbutton銆乸opview 绫诲瀷鎸夐挳 let labels = [] - if (type === 'calendar') { - config.action = config.action.filter(item => { - if (['exec', 'prompt', 'pop', 'tab', 'excelIn', 'excelOut'].includes(item.OpenType)) return true + config.action = config.action.filter(item => { + if (['exec', 'prompt', 'pop', 'tab', 'excelIn', 'excelOut', 'innerpage'].includes(item.OpenType)) return true - labels.push(item.label) + labels.push(item.label) - return false - }) - - } else { - config.action = config.action.filter(item => { - if (['exec', 'prompt', 'pop'].includes(item.OpenType)) return true - - labels.push(item.label) - - return false - }) - } + return false + }) if (window.GLOB.systemType !== 'production' && labels.length > 0) { notification.warning({ @@ -146,17 +132,17 @@ config.action = config.action.filter(item => permAction[item.uuid]) } - let roleId = sessionStorage.getItem('role_id') || '' // 瑙掕壊ID - // 瀛楁鏉冮檺榛戝悕鍗� - config.search = config.search.filter(item => { - item.oriInitval = item.initval - if (!item.blacklist || item.blacklist.length === 0) return item - if (item.blacklist.filter(v => roleId.indexOf(v) > -1).length > 0) { - item.Hide = 'true' - } + config.search = Utils.initSearchVal(config.search) - return item + let hasReqFields = false + config.search.forEach(field => { + if (field.required) { + hasReqFields = true + } }) + + // 瀛楁鏉冮檺榛戝悕鍗� + let roleId = sessionStorage.getItem('role_id') || '' // 瑙掕壊ID config.columns = config.columns.map(col => { if (!col.blacklist || col.blacklist.length === 0) return col @@ -166,19 +152,6 @@ return col }) - - // 瑙嗗浘鏉冮檺 - config.charts = config.charts.filter(item => { - if (item.Hide === 'true') return false - if (!item.blacklist || item.blacklist.length === 0) return true - return item.blacklist.filter(v => roleId.indexOf(v) > -1).length === 0 - }) - - if (config.charts.length <= 1) { - config.expand = true - } - - let chartId = config.charts[0] ? config.charts[0].uuid : '' // 1銆佺瓫閫夊瓧娈甸泦锛�2銆佽繃婊ら殣钘忓垪鍙婂悎骞跺垪涓殑瀛楁uuid config.columns.forEach(col => { @@ -217,8 +190,10 @@ subcols.push(colMap.get(sub)) } }) - _col.subcols = subcols - _columns.push(_col) + if (subcols.length > 0) { + _col.subcols = subcols + _columns.push(_col) + } } else { _columns.push(col) } @@ -229,9 +204,7 @@ config.action.forEach(item => { item.logLabel = Tab.label + '-' + item.label // 鐢ㄤ簬sPC_TableData_InUpDe璁板綍鎿嶄綔鎸夐挳 - if (item.execMode) { - item.OpenType = 'funcbutton' - } + item.$menuId = this.props.MenuID if (item.position === 'toolbar') { _actions.push(item) @@ -245,20 +218,13 @@ _columns.push(config.gridBtn) } - let valid = true // 鎼滅储鏉′欢蹇呭~楠岃瘉 - config.search.forEach(field => { - if (field.required === 'true' && !field.initval) { - valid = false - } - }) - config.setting.tabType = 'subtab' // 鏁版嵁婧愪俊鎭澶勭悊 config.setting.laypage = config.setting.laypage !== 'false' // 鏄惁鍒嗛〉锛岃浆涓篵oolean 缁熶竴鏍煎紡 config.setting.execute = config.setting.default !== 'false' // 榛樿sql鏄惁鎵ц锛岃浆涓篵oolean 缁熶竴鏍煎紡 config.setting.customScript = '' // 鑷畾涔夎剼鏈� - if (config.setting.interType === 'system') { + if (config.setting.interType === 'system' || (config.setting.interType === 'custom' && config.setting.requestMode === 'system')) { if (config.setting.scripts && config.setting.scripts.length > 0) { let _customScript = '' config.setting.scripts.forEach(item => { @@ -288,11 +254,47 @@ config.setting.dataresource = config.setting.dataresource.replace(/@\$|\$@/ig, '') config.setting.customScript = config.setting.customScript.replace(/@\$|\$@/ig, '') } + + let userName = sessionStorage.getItem('User_Name') || '' + let fullName = sessionStorage.getItem('Full_Name') || '' + let city = sessionStorage.getItem('city') || '' + + if (sessionStorage.getItem('isEditState') === 'true') { + userName = sessionStorage.getItem('CloudUserName') || '' + fullName = sessionStorage.getItem('CloudFullName') || '' + } + + let regs = [ + { reg: /@userName@/ig, value: `'${userName}'` }, + { reg: /@fullName@/ig, value: `'${fullName}'` }, + { reg: /@login_city@/ig, value: `'${city}'` } + ] + + regs.forEach(cell => { + config.setting.dataresource = config.setting.dataresource.replace(cell.reg, cell.value) + config.setting.customScript = config.setting.customScript.replace(cell.reg, cell.value) + }) + } + + if (config.setting.selected !== 'init' && config.setting.selected !== 'always') { + config.setting.selected = 'false' + } else if (config.setting.selected === 'init' && config.setting.onload === 'false') { + config.setting.selected = 'false' + } else { + config.setting.orisel = true + } + + if (config.setting.controlField) { + if (config.setting.controlVal) { + config.setting.controlVal = config.setting.controlVal.split(',') + } else { + config.setting.controlVal = [''] + } } this.setState({ + pageSize: config.setting.pageSize || 10, loadingview: false, - chartId, config, absFields, statFields, @@ -301,11 +303,11 @@ actions: _actions, columns: _columns, arr_field: _arrField.join(','), - search: Utils.initMainSearch(config.search) // 鎼滅储鏉′欢鍒濆鍖栵紙鍚湁鏃堕棿鏍煎紡锛岄渶瑕佽浆鍖栵級 + search: Utils.initMainSearch(config.search), // 鎼滅储鏉′欢鍒濆鍖栵紙鍚湁鏃堕棿鏍煎紡锛岄渶瑕佽浆鍖栵級 + hasReqFields }, () => { - if (config.setting.onload !== 'false' && valid) { // 鍒濆鍖栧彲鍔犺浇 - this.loadmaindata() - this.getStatFieldsValue() + if (config.setting.onload !== 'false') { // 鍒濆鍖栧彲鍔犺浇 + this.loadData() } }) } else { @@ -321,46 +323,251 @@ } } - /** - * @description 瀛愯〃鏁版嵁鍔犺浇 - */ - async loadmaindata () { - const { mainSearch, BID } = this.props - const { setting, arr_field, search, orderBy, pageIndex, pageSize, absFields } = this.state + loadData = (id) => { + const { setting, search, hasReqFields, loadCustomApi } = this.state let searches = fromJS(search).toJS() - if (mainSearch && mainSearch.length > 0) { // 涓昏〃鎼滅储鏉′欢 - searches = [...mainSearch, ...searches] + + if (hasReqFields) { + let requireFields = searches.filter(item => item.required && item.value === '') + if (requireFields.length > 0) { + this.setState({ + loading: false + }) + return + } } - let requireFields = search.filter(item => item.required && (!item.value || item.value.length === 0)) - - if (requireFields.length > 0) { - let labels = requireFields.map(item => item.label) - labels = Array.from(new Set(labels)) - + if (window.GLOB.systemType === 'production' && setting.interType === 'custom' && !setting.proInterface) { notification.warning({ top: 92, - message: this.state.dict['form.required.input'] + labels.join('銆�') + ' !', + message: '鏈缃寮忕郴缁熷湴鍧�!', duration: 3 }) return } this.setState({ - selectedData: [], + selectedData: [] + }) + + if (setting.interType === 'custom' && loadCustomApi) { + if (setting.execTime === 'once') { + this.setState({loadCustomApi: false}) + } + + this.loadOutResource(searches) + if (setting.execType === 'async') { + this.loadmaindata(id) + } + } else { + this.loadmaindata(id) + } + } + + loadOutResource = (searches) => { + const { setting } = this.state + + let param = UtilsDM.getPrevQueryParams(setting, searches, this.props.BID, this.props.menuType) + + if (setting.execType === 'sync') { + this.setState({ + loading: true + }) + } + + Api.genericInterface(param).then(res => { + if (res.status) { + if (res.mk_ex_invoke === 'false' || res.mk_ex_invoke === false) { + this.loadmaindata() + } else { + this.customOuterRequest(res) + } + } else { + this.setState({ + loading: false + }) + notification.error({ + top: 92, + message: res.message, + duration: 10 + }) + } + }, () => { + this.setState({ + loading: false + }) + }) + } + + customOuterRequest = (result) => { + const { setting } = this.state + let url = '' + + if (window.GLOB.systemType === 'production') { + url = setting.proInterface + } else { + url = setting.interface + } + + let mkey = result.mk_api_key || '' + + delete result.mk_ex_invoke + delete result.status + delete result.message + delete result.ErrCode + delete result.ErrMesg + delete result.mk_api_key + + let param = {} + + Object.keys(result).forEach(key => { + key = key.replace(/^mk_/ig, '') + param[key] = result[key] + }) + + Api.directRequest(url, setting.method, param, setting.cross).then(res => { + if (typeof(res) !== 'object') { + let error = '鏈煡鐨勮繑鍥炵粨鏋滐紒' + + if (typeof(res) === 'string') { + error = res.replace(/'/ig, '"') + } + + let _result = { + mk_api_key: mkey, + $ErrCode: 'E', + $ErrMesg: error + } + + this.customCallbackRequest(_result) + } else { + if (Array.isArray(res)) { + res = { data: res } + } + res.mk_api_key = mkey + this.customCallbackRequest(res) + } + }, (e) => { + let _result = { + mk_api_key: mkey, + $ErrCode: 'E', + $ErrMesg: e && e.statusText ? e.statusText : '' + } + + this.customCallbackRequest(_result) + }) + } + + customCallbackRequest = (result) => { + const { setting } = this.state + let errSql = '' + if (result.$ErrCode === 'E') { + errSql = ` + set @ErrorCode='E' + set @retmsg='${result.$ErrMesg}' + ` + delete result.$ErrCode + delete result.$ErrMesg + } + + let lines = UtilsDM.getCallBackSql(setting, result) + let param = {} + + if (setting.callbackType === 'script') { // 浣跨敤鑷畾涔夎剼鏈� + let sql = lines.map(item => (` + ${item.insert} + ${item.selects.join(` union all + `)} + `)) + sql = sql.join('') + + param = UtilsDM.getCallBackQueryParams(setting, sql, errSql) + + if (this.props.BID) { + param.BID = this.props.BID + } + + if (this.props.menuType === 'HS') { // 鍑芥暟 sPC_TableData_InUpDe 浜戠楠岃瘉 + param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp) + } + } else { + let name = this.props.Tab ? (this.props.Tab.label || '') : '' + param.func = 's_ex_result_back' + param.s_ex_result = lines.map((item, index) => ({ + MenuID: this.props.MenuID, + MenuName: name, + TableName: item.table, + LongText: window.btoa(window.encodeURIComponent(`${item.insert} ${item.selects.join(` union all `)}`)), + Sort: index + 1 + })) + + if (window.GLOB.debugger === true || (window.debugger === true && options.sysType !== 'cloud')) { + let sql = lines.map(item => (` + ${item.insert} + ${item.selects.join(` union all + `)} + `)) + sql = sql.join('') + console.info(sql.replace(/\n\s{10}/ig, '\n')) + } + } + + Api.genericInterface(param).then(res => { + if (res.status) { + this.loadmaindata() + } else { + this.setState({ + loading: false + }) + notification.error({ + top: 92, + message: res.message, + duration: 10 + }) + } + }, () => { + this.setState({ + loading: false + }) + }) + } + + /** + * @description 瀛愯〃鏁版嵁鍔犺浇 + */ + async loadmaindata (id) { + const { BID } = this.props + const { setting, arr_field, search, orderBy, pageIndex, pageSize, absFields } = this.state + + let searches = fromJS(search).toJS() + + this.setState({ loading: true }) let _orderBy = orderBy || setting.order let param = UtilsDM.getQueryDataParams(setting, arr_field, searches, _orderBy, pageIndex, pageSize, BID, this.props.menuType) - if (param.func === 'sPC_Get_TableData') { - param.menuname = this.props.Tab.label || '' - } - let result = await Api.genericInterface(param) + + this.getStatFieldsValue(searches) + if (result.status) { + let start = 1 + if (setting.laypage) { + start = pageSize * (pageIndex - 1) + 1 + } + + if (setting.selected !== 'false' || (setting.orisel && id)) { + setTimeout(() => { + MKEmitter.emit('mkTableCheckTopLine', this.props.MenuID, id) + }, 200) + if (setting.selected === 'init') { + this.setState({setting: {...setting, selected: 'false'}}) + } + } + this.setState({ data: result.data.map((item, index) => { if (absFields.length) { @@ -372,6 +579,17 @@ }) } item.key = index + item.$$uuid = item[setting.primaryKey] || '' + item.$$key = '' + item.key + item.$$uuid + item.$$BID = BID || '' + item.$Index = start + index + '' + + if (setting.controlField) { + if (setting.controlVal.includes(item[setting.controlField])) { + item.$disabled = true + } + } + return item }), total: result.total, @@ -392,29 +610,15 @@ /** * @description 鑾峰彇鍚堣瀛楁鍊� */ - getStatFieldsValue = () => { - const { mainSearch, BID } = this.props - const { setting, search, orderBy, statFields } = this.state + getStatFieldsValue = (searches) => { + const { BID } = this.props + const { setting, orderBy, statFields } = this.state - let searches = fromJS(search).toJS() - if (mainSearch && mainSearch.length > 0) { // 涓昏〃鎼滅储鏉′欢 - searches = [...mainSearch, ...searches] - } - - if (statFields.length === 0 || setting.interType !== 'system' || !setting.dataresource) return - - let requireFields = search.filter(item => item.required && (!item.value || item.value.length === 0)) - if (requireFields.length > 0) { - return - } + if (statFields.length === 0 || !(setting.interType === 'system' || (setting.interType === 'custom' && setting.requestMode === 'system')) || !setting.dataresource) return let _orderBy = orderBy || setting.order let param = UtilsDM.getStatQueryDataParams(setting, statFields, searches, _orderBy, BID, this.props.menuType) - if (param.func === 'sPC_Get_TableData') { - param.menuname = this.props.Tab.label || '' - } - Api.genericInterface(param).then(res => { if (res.status) { let _data = res.data[0] @@ -449,17 +653,90 @@ } /** + * @description 鑾峰彇鍗曡鏁版嵁 + */ + async loadmainLinedata (id) { + const { BID } = this.props + const { setting, arr_field, search, orderBy, pageIndex, pageSize, absFields } = this.state + + let searches = fromJS(search).toJS() + + this.setState({ + loading: true + }) + + let _orderBy = orderBy || setting.order + let param = UtilsDM.getQueryDataParams(setting, arr_field, searches, _orderBy, pageIndex, pageSize, BID, this.props.menuType, id) + + let result = await Api.genericInterface(param) + 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] || {} + + if (absFields.length) { + absFields.forEach(field => { + if (!_data[field]) return + if (isNaN(Math.abs(_data[field]))) return + + _data[field] = Math.abs(_data[field]) + }) + } + + _data.$$uuid = _data[setting.primaryKey] || '' + _data.$$BID = BID || '' + + try { + data = data.map(item => { + if (item.$$uuid === _data.$$uuid) { + _data.key = item.key + _data.$$key = '' + item.key + item.$$uuid + _data.$Index = item.$Index + return _data + } else { + return item + } + }) + selectedData = selectedData.map(item => { + if (_data.$$uuid === item.$$uuid) { + return _data + } + return item + }) + } catch (e) { + console.warn('鏁版嵁鏌ヨ閿欒') + } + } + + this.setState({ + data, + selectedData, + loading: false + }) + } else { + this.setState({ + loading: false + }) + notification.error({ + top: 92, + message: result.message, + duration: 10 + }) + } + } + + /** * @description 鎼滅储鏉′欢鏀瑰彉鏃讹紝閲嶇疆琛ㄦ牸鏁版嵁 * 鍚湁鍒濆涓嶅姞杞界殑椤甸潰锛屼慨鏀硅缃� */ refreshbysearch = (searches) => { - MKEmitter.emit('resetTable', this.props.MenuID + this.props.Tab.uuid) // 鍒楄〃閲嶇疆 + MKEmitter.emit('resetTable', this.props.Tab.uuid) // 鍒楄〃閲嶇疆 this.setState({ pageIndex: 1, search: searches }, () => { - this.loadmaindata() - this.getStatFieldsValue() + this.loadData() }) } @@ -480,26 +757,24 @@ pageSize: pagination.pageSize, orderBy: (sorter.field && sorter.order) ? `${sorter.field} ${sorter.order}` : '' }, () => { - this.loadmaindata() + this.loadData() }) } /** * @description 琛ㄦ牸鍒锋柊 */ - reloadtable = (btn) => { + reloadtable = (btn, id) => { if (!btn || btn.resetPageIndex !== 'false') { - MKEmitter.emit('resetTable', this.props.MenuID + this.props.Tab.uuid) // 鍒楄〃閲嶇疆 + MKEmitter.emit('resetTable', this.props.Tab.uuid) // 鍒楄〃閲嶇疆 this.setState({ pageIndex: 1 }, () => { - this.loadmaindata() - this.getStatFieldsValue() + this.loadData(id) }) } else { - MKEmitter.emit('resetTable', this.props.MenuID + this.props.Tab.uuid, 'false') // 鍒楄〃閲嶇疆 - this.loadmaindata() - this.getStatFieldsValue() + MKEmitter.emit('resetTable', this.props.Tab.uuid, 'false') // 鍒楄〃閲嶇疆 + this.loadData(id) } } @@ -512,42 +787,39 @@ } /** - * @description 鎸夐挳鎿嶄綔瀹屾垚鍚庯紙鎴愬姛鎴栧け璐ワ級锛岄〉闈㈠埛鏂帮紝閲嶇疆椤电爜鍙婇�夋嫨椤� - */ - refreshbyaction = (position, btn) => { - if (position === 'grid' || position === 'view' || position === 'maingrid') { - this.reloadtable(btn) - this.props.refreshSupView() - } else if (position === 'trigger') { // 鏃ュ巻瀛愯〃瑙﹀彂鏍囩鐐瑰嚮浜嬩欢 - this.props.closeModalView && this.props.closeModalView() - } - } - - /** * @description 瀵煎嚭Excel鏃讹紝鑾峰彇椤甸潰鎼滅储鎺掑簭绛夊弬鏁� */ - getexceloutparam = () => { - const { Tab, mainSearch } = this.props + queryModuleParam = (menuId, btnId) => { + const { Tab, MenuID } = this.props const { arr_field, orderBy, search, setting} = this.state - let searches = search - if (mainSearch && mainSearch.length > 0) { // 涓昏〃鎼滅储鏉′欢 - searches = [...mainSearch, ...search] - } + if (MenuID !== menuId) return - return { + MKEmitter.emit('returnModuleParam', MenuID, btnId, { arr_field: arr_field, orderBy: orderBy || setting.order, - search: searches, + search: search, menuName: Tab.label - } + }) } /** - * @description 鍥捐〃瑙嗗浘鍒囨崲 + * @description 鎸夐挳鎵ц瀹屾垚鍚庨〉闈㈠埛鏂� + * @param {*} menuId // 鑿滃崟Id + * @param {*} position // 鍒锋柊浣嶇疆 + * @param {*} btn // 鎵ц鐨勬寜閽� */ - changeChart = (uuid) => { - this.setState({chartId: uuid}) + refreshByButtonResult = (menuId, position, btn, id = '', lines) => { + const { MenuID } = this.props + + if (MenuID !== menuId) return + + if (position === 'line' && lines && lines.length === 1) { + this.loadmainLinedata(lines[0].$$uuid) + } else { + this.reloadtable(btn, id) + } + MKEmitter.emit('refreshPopButton', this.props.Tab.uuid) } UNSAFE_componentWillMount () { @@ -559,6 +831,11 @@ return !is(fromJS(this.props), fromJS(nextProps)) || !is(fromJS(this.state), fromJS(nextState)) } + componentDidMount () { + MKEmitter.addListener('queryModuleParam', this.queryModuleParam) + MKEmitter.addListener('refreshByButtonResult', this.refreshByButtonResult) + } + /** * @description 缁勪欢閿�姣侊紝娓呴櫎state鏇存柊 */ @@ -566,96 +843,46 @@ this.setState = () => { return } + MKEmitter.removeListener('queryModuleParam', this.queryModuleParam) + MKEmitter.removeListener('refreshByButtonResult', this.refreshByButtonResult) } render() { - const { config, setting, searchlist, pageSize, actions, columns, loadingview, viewlost, chartId, selectedData } = this.state + const { config, setting, searchlist, pageSize, actions, columns, loadingview, viewlost, selectedData } = this.state return ( <div className="subtabtable" id={'subtabtable' + this.props.MenuID}> {loadingview && <Spin />} {searchlist && searchlist.length ? - <SubSearch BID={this.props.BID} searchlist={searchlist} menuType={this.props.menuType} refreshdata={this.refreshbysearch}/> : null + <SubSearch BID={this.props.BID} setting={setting} searchlist={searchlist} menuType={this.props.menuType} refreshdata={this.refreshbysearch}/> : null } - {config ? <Row className="chart-view" gutter={16}> - {/* 瑙嗗浘缁� */} - {!config.expand ? <Tabs activeKey={chartId} onChange={this.changeChart}> - {config.charts.map(item => ( - <TabPane tab={<Icon type={item.icon} />} key={item.uuid}></TabPane> - ))} - </Tabs> : null} - {config.charts.map(item => { - if (!config.expand && chartId !== item.uuid) return null - - if (item.chartType === 'table') { - return ( - <Col span={item.width || 24} key={item.uuid}> - {config.charts.length > 1 ? <p className="chart-table chart-title">{item.title}</p> : null} - <div style={{minHeight: '25px'}}> - <SubAction - setting={setting} - actions={actions} - columns={columns} - BID={this.props.BID} - dict={this.state.dict} - BData={this.props.BData} - selectedData={selectedData} - MenuID={this.props.SupMenuID} - refreshdata={this.refreshbyaction} - getexceloutparam={this.getexceloutparam} - /> - </div> - <SubTable - tableId={this.props.Tab.uuid} - setting={setting} - columns={columns} - pageSize={pageSize} - BID={this.props.BID} - data={this.state.data} - dict={this.state.dict} - BData={this.props.BData} - total={this.state.total} - MenuID={this.props.MenuID} - loading={this.state.loading} - refreshdata={this.refreshbytable} - statFValue={this.state.statFValue} - refreshbyaction={this.refreshbyaction} - chgSelectData={this.changeSelectedData} - handleTableId={() => {}} - /> - </Col> - ) - } else if (item.chartType === 'card') { - return ( - <Col className="card-view" span={item.width} key={item.uuid}> - <CardComponent - tableId="" - plot={item} - config={config} - columns={columns} - BID={this.props.BID} - data={this.state.data} - BData={this.props.BData} - loading={this.state.loading} - refreshdata={this.refreshbyaction} - handleTableId={() => {}} - /> - </Col> - ) - } else { - return ( - <Col span={item.width} key={item.uuid}> - <ChartComponent - plot={item} - config={config} - data={this.state.data} - loading={this.state.loading} - /> - </Col> - ) - } - })} - </Row> : null } + {config ? <div style={{minHeight: '25px'}}> + <SubAction + setting={setting} + actions={actions} + columns={columns} + BID={this.props.BID} + dict={this.state.dict} + BData={this.props.BData} + selectedData={selectedData} + MenuID={this.props.SupMenuID} + /> + </div> : null} + {config ? <SubTable + tableId={this.props.Tab.uuid} + setting={setting} + columns={columns} + pageSize={pageSize} + data={this.state.data} + dict={this.state.dict} + BData={this.props.BData} + total={this.state.total} + MenuID={this.props.MenuID} + loading={this.state.loading} + refreshdata={this.refreshbytable} + statFValue={this.state.statFValue} + chgSelectData={this.changeSelectedData} + /> : null} {viewlost ? <NotFount msg={this.state.lostmsg} /> : null} </div> ) -- Gitblit v1.8.0