From 7046b2568593b72f3640df6796a2b81980134030 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期日, 18 九月 2022 23:45:57 +0800 Subject: [PATCH] 2022-09-18 --- src/tabviews/custom/components/chart/antv-scatter/index.jsx | 82 ---- src/tabviews/custom/components/chart/antv-bar-line/index.jsx | 82 ---- src/menu/components/card/cardcellcomponent/dragaction/index.scss | 2 src/tabviews/custom/components/chart/antv-dashboard/index.jsx | 82 ---- src/menu/components/timeline/normal-timeline/index.jsx | 2 src/menu/components/card/table-card/index.jsx | 2 src/tabviews/custom/components/tree/antd-tree/index.jsx | 86 ---- src/tabviews/custom/components/share/normalTable/index.scss | 3 src/tabviews/custom/components/carousel/data-card/index.jsx | 23 + src/api/index.js | 22 public/README.txt | 2 src/menu/components/carousel/data-card/index.jsx | 2 src/tabviews/custom/components/chart/custom-chart/index.jsx | 83 ---- src/tabviews/custom/components/card/data-card/index.jsx | 25 + src/tabviews/custom/components/card/table-card/index.jsx | 25 + src/tabviews/custom/components/card/prop-card/index.jsx | 87 ---- src/tabviews/custom/components/table/normal-table/index.jsx | 28 + src/menu/components/carousel/prop-card/index.jsx | 2 src/tabviews/custom/components/chart/antv-pie/index.jsx | 82 ---- src/tabviews/custom/components/timeline/normal-timeline/index.jsx | 23 + src/utils/timer-task.js | 71 ++++ src/menu/components/card/data-card/index.jsx | 2 src/tabviews/custom/components/table/edit-table/normalTable/index.scss | 3 src/tabviews/custom/components/carousel/prop-card/index.jsx | 23 + src/menu/components/share/clockcomponent/settingform/index.jsx | 2 src/tabviews/custom/components/card/balcony/index.jsx | 85 ---- src/menu/components/share/clockcomponent/index.jsx | 5 src/tabviews/custom/components/card/cardcellList/index.scss | 2 src/menu/components/table/normal-table/index.jsx | 2 src/tabviews/zshare/normalTable/index.scss | 3 30 files changed, 335 insertions(+), 608 deletions(-) diff --git a/public/README.txt b/public/README.txt index b01eb22..14e4f03 100644 --- a/public/README.txt +++ b/public/README.txt @@ -14,6 +14,6 @@ debugger -- 鍊间负 true 鏃跺紑鍚皟璇曟ā寮忥紝寮�鍚悗绉诲姩绔瓙搴旂敤涓細鏈夋帶鍒跺彴 licenseKey -- 璁稿彲瀵嗛挜锛屽湪鍐呴儴缃戠粶涓娇鐢ㄧ郴缁熸椂锛屼細璺宠繃epc楠岃瘉 probation -- 璇曠敤鏈燂紙YYYY-MM-DD锛夛紝鍦ㄦ寮忕郴缁熶腑锛岃瘯鐢ㄦ湡鍐呰皟鐢ㄧ郴缁熸帴鍙g殑鑴氭湰浼氳褰曚笅鏉� -transfer -- 鏄惁浣跨敤杞帴鍙o紝浣跨敤杞帴鍙f椂璇疯缃负 true +transfer -- 鏄惁浣跨敤杞帴鍙o紝浣跨敤杞帴鍙f椂璇疯缃负 true, 浣跨敤杞帴鍙f椂锛屽閮ㄦ帴鍙h皟鐢ㄥ墠涓嶄細鍋氱櫥褰曢獙璇� keepPassword -- 璁颁綇瀵嗙爜锛岄粯璁ゅ紑鍚紝褰撳�间负 false 鏃剁鐢� platforms -- 绉诲姩绔彲浣跨敤鐨勫钩鍙扮被鍨嬶紝榛樿涓� ["H5", "wechat", "android", "ios", "wxMiniProgram"] 鍒嗗埆浠h〃H5椤甸潰銆佸井淇″叕浼楀彿銆佸畨鍗揂PP銆佽嫻鏋淎PP銆佸井淇″皬绋嬪簭 \ No newline at end of file diff --git a/src/api/index.js b/src/api/index.js index 02782e6..17a85f5 100644 --- a/src/api/index.js +++ b/src/api/index.js @@ -216,16 +216,6 @@ TypeCharOne: 'pc', kei_id: window.btoa(window.encodeURIComponent(window.GLOB.host)) } - - param.LText = md5(window.btoa(_SessionUid + param.timestamp)) - - // param.secretkey = md5(param.LText + 'mingke' + param.timestamp) // v_type 涓虹┖鏃� - let solt = md5((window.GLOB.appkey + window.btoa(window.GLOB.appkey + 'mingke') + 'mingke').toLowerCase()).slice(-6).toUpperCase() - - param.v_type = 'Y' - param.secretkey = md5(param.LText + solt + param.timestamp) - - param.appkey = window.GLOB.appkey || '' let url = '/webapi/dologon/s_visitor_login' if (window.GLOB.mainSystemApi) { @@ -246,7 +236,19 @@ if (!param.rduri) { param.rduri = window.GLOB.baseurl + 'webapi/dologon/s_visitor_login' } + + param.linkurl = appid.replace(/\/webapi(.*)/, '/index.html') } + + param.LText = md5(window.btoa(_SessionUid + param.timestamp + (param.linkurl || ''))) + + // param.secretkey = md5(param.LText + 'mingke' + param.timestamp) // v_type 涓虹┖鏃� + let solt = md5((window.GLOB.appkey + window.btoa(window.GLOB.appkey + 'mingke') + 'mingke').toLowerCase()).slice(-6).toUpperCase() + + param.v_type = param.v_type || 'Y' + param.secretkey = md5(param.LText + solt + param.timestamp) + + param.appkey = window.GLOB.appkey || '' return axios({ url: url, diff --git a/src/menu/components/card/cardcellcomponent/dragaction/index.scss b/src/menu/components/card/cardcellcomponent/dragaction/index.scss index d3ea903..ea8410f 100644 --- a/src/menu/components/card/cardcellcomponent/dragaction/index.scss +++ b/src/menu/components/card/cardcellcomponent/dragaction/index.scss @@ -114,7 +114,7 @@ background-size: cover; background-position: center center; background-repeat: no-repeat; - background-color: #e9e9e9; + background-color: #f5f5f5; } .ant-mk-icon { vertical-align: top; diff --git a/src/menu/components/card/data-card/index.jsx b/src/menu/components/card/data-card/index.jsx index b44b03d..09d308d 100644 --- a/src/menu/components/card/data-card/index.jsx +++ b/src/menu/components/card/data-card/index.jsx @@ -21,6 +21,7 @@ const UserComponent = asyncIconComponent(() => import('@/menu/components/share/usercomponent')) const PasteComponent = asyncIconComponent(() => import('@/components/paste')) const NormalHeader = asyncComponent(() => import('@/menu/components/share/normalheader')) +const ClockComponent = asyncIconComponent(() => import('@/menu/components/share/clockcomponent')) const ActionComponent = asyncComponent(() => import('@/menu/components/share/actioncomponent')) const { confirm } = Modal @@ -779,6 +780,7 @@ <PasteComponent options={['action', 'search', 'form', 'cardcell']} updateConfig={this.pasteComponent} /> <FontColorsOutlined className="style" title="璋冩暣鏍峰紡" onClick={this.changeStyle}/> {/* <LogComponent btnlog={card.btnlog || []} handlelog={this.handleLog} /> */} + <ClockComponent config={card} updateConfig={this.updateComponent}/> <UserComponent config={card}/> <DeleteOutlined className="close" title="鍒犻櫎缁勪欢" onClick={() => this.props.deletecomponent(card.uuid)} /> <SettingComponent config={card} updateConfig={this.updateComponent} /> diff --git a/src/menu/components/card/table-card/index.jsx b/src/menu/components/card/table-card/index.jsx index db3f76b..689e208 100644 --- a/src/menu/components/card/table-card/index.jsx +++ b/src/menu/components/card/table-card/index.jsx @@ -21,6 +21,7 @@ // const LogComponent = asyncIconComponent(() => import('@/menu/components/share/logcomponent')) const UserComponent = asyncIconComponent(() => import('@/menu/components/share/usercomponent')) const NormalHeader = asyncComponent(() => import('@/menu/components/share/normalheader')) +const ClockComponent = asyncIconComponent(() => import('@/menu/components/share/clockcomponent')) const ActionComponent = asyncComponent(() => import('@/menu/components/share/actioncomponent')) const { confirm } = Modal @@ -589,6 +590,7 @@ <PasteComponent options={['cardcell', 'search', 'form']} updateConfig={this.pasteComponent} /> <FontColorsOutlined className="style" title="璋冩暣鏍峰紡" onClick={this.changeStyle}/> {/* <LogComponent btnlog={card.btnlog || []} handlelog={this.handleLog} /> */} + <ClockComponent config={card} updateConfig={this.updateComponent}/> <UserComponent config={card}/> <DeleteOutlined className="close" title="鍒犻櫎缁勪欢" onClick={() => this.props.deletecomponent(card.uuid)} /> {card.wrap.datatype !== 'static' ? <SettingComponent config={card} updateConfig={this.updateComponent} /> : null} diff --git a/src/menu/components/carousel/data-card/index.jsx b/src/menu/components/carousel/data-card/index.jsx index 4440080..0a4ad64 100644 --- a/src/menu/components/carousel/data-card/index.jsx +++ b/src/menu/components/carousel/data-card/index.jsx @@ -17,6 +17,7 @@ const CardSimpleComponent = asyncComponent(() => import('@/menu/components/card/cardsimplecomponent')) // const LogComponent = asyncIconComponent(() => import('@/menu/components/share/logcomponent')) const CopyComponent = asyncIconComponent(() => import('@/menu/components/share/copycomponent')) +const ClockComponent = asyncIconComponent(() => import('@/menu/components/share/clockcomponent')) const UserComponent = asyncIconComponent(() => import('@/menu/components/share/usercomponent')) const { confirm } = Modal @@ -311,6 +312,7 @@ <CopyComponent type="datacard" card={card}/> <FontColorsOutlined className="style" title="璋冩暣鏍峰紡" onClick={this.changeStyle}/> {/* <LogComponent btnlog={card.btnlog || []} handlelog={this.handleLog}/> */} + <ClockComponent config={card} updateConfig={this.updateComponent}/> <UserComponent config={card}/> <DeleteOutlined className="close" title="鍒犻櫎缁勪欢" onClick={() => this.props.deletecomponent(card.uuid)}/> <SettingComponent config={card} updateConfig={this.updateComponent}/> diff --git a/src/menu/components/carousel/prop-card/index.jsx b/src/menu/components/carousel/prop-card/index.jsx index 641330c..685c304 100644 --- a/src/menu/components/carousel/prop-card/index.jsx +++ b/src/menu/components/carousel/prop-card/index.jsx @@ -18,6 +18,7 @@ const CopyComponent = asyncIconComponent(() => import('@/menu/components/share/copycomponent')) const PasteComponent = asyncIconComponent(() => import('@/menu/components/share/pastecomponent')) // const LogComponent = asyncIconComponent(() => import('@/menu/components/share/logcomponent')) +const ClockComponent = asyncIconComponent(() => import('@/menu/components/share/clockcomponent')) const UserComponent = asyncIconComponent(() => import('@/menu/components/share/usercomponent')) const { confirm } = Modal @@ -419,6 +420,7 @@ <PasteComponent config={card} options={['cardcell']} updateConfig={this.updateComponent} /> <FontColorsOutlined className="style" title="璋冩暣鏍峰紡" onClick={this.changeStyle}/> {/* <LogComponent btnlog={card.btnlog || []} handlelog={this.handleLog} /> */} + <ClockComponent config={card} updateConfig={this.updateComponent}/> <UserComponent config={card}/> <DeleteOutlined className="close" title="鍒犻櫎缁勪欢" onClick={() => this.props.deletecomponent(card.uuid)} /> {card.wrap.datatype !== 'static' ? <SettingComponent config={card} updateConfig={this.updateComponent} /> : null} diff --git a/src/menu/components/share/clockcomponent/index.jsx b/src/menu/components/share/clockcomponent/index.jsx index 9fb414d..24de95e 100644 --- a/src/menu/components/share/clockcomponent/index.jsx +++ b/src/menu/components/share/clockcomponent/index.jsx @@ -1,6 +1,5 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' -import { is, fromJS } from 'immutable' import { Modal } from 'antd' import { ClockCircleOutlined } from '@ant-design/icons' @@ -14,10 +13,6 @@ state = { visible: false - } - - shouldComponentUpdate (nextProps, nextState) { - return !is(fromJS(this.state), fromJS(nextState)) } trigger = () => { diff --git a/src/menu/components/share/clockcomponent/settingform/index.jsx b/src/menu/components/share/clockcomponent/settingform/index.jsx index 67b168c..0978f22 100644 --- a/src/menu/components/share/clockcomponent/settingform/index.jsx +++ b/src/menu/components/share/clockcomponent/settingform/index.jsx @@ -100,7 +100,7 @@ })(<InputNumber min={0} max={500} precision={0} />)} </Form.Item> </Col> : null} - {(config.subtype === 'balcony' || config.subtype === 'propcard') && timer && timer !== '2s' ? <Col span={22}> + {config.type === 'card' && (config.subtype === 'balcony' || config.subtype === 'propcard') && timer && timer !== '2s' ? <Col span={22}> <Form.Item label={ <Tooltip placement="topLeft" title="鍙互鎸囧畾瀛楁鐢ㄤ簬鎺у埗瀹氭椂鍣ㄧ殑鍏抽棴銆�"> <QuestionCircleOutlined className="mk-form-tip" /> diff --git a/src/menu/components/table/normal-table/index.jsx b/src/menu/components/table/normal-table/index.jsx index 480a7db..a2448ee 100644 --- a/src/menu/components/table/normal-table/index.jsx +++ b/src/menu/components/table/normal-table/index.jsx @@ -21,6 +21,7 @@ const CopyComponent = asyncIconComponent(() => import('@/menu/components/share/copycomponent')) const UserComponent = asyncIconComponent(() => import('@/menu/components/share/usercomponent')) const PasteComponent = asyncIconComponent(() => import('@/menu/components/share/pastecomponent')) +const ClockComponent = asyncIconComponent(() => import('@/menu/components/share/clockcomponent')) // const LogComponent = asyncIconComponent(() => import('@/menu/components/share/logcomponent')) const ColumnComponent = asyncComponent(() => import('./columns')) @@ -522,6 +523,7 @@ <PasteComponent config={card} options={options} updateConfig={this.updateComponent} /> <FontColorsOutlined className="style" title="璋冩暣鏍峰紡" onClick={this.changeStyle}/> {/* <LogComponent btnlog={card.btnlog || []} handlelog={this.handleLog} /> */} + <ClockComponent config={card} updateConfig={this.updateComponent}/> <UserComponent config={card}/> <DeleteOutlined className="close" title="鍒犻櫎缁勪欢" onClick={() => this.props.deletecomponent(card.uuid)} /> <SettingComponent config={card} updateConfig={this.updateComponent} /> diff --git a/src/menu/components/timeline/normal-timeline/index.jsx b/src/menu/components/timeline/normal-timeline/index.jsx index 87c2fe4..54da944 100644 --- a/src/menu/components/timeline/normal-timeline/index.jsx +++ b/src/menu/components/timeline/normal-timeline/index.jsx @@ -16,6 +16,7 @@ const NormalForm = asyncIconComponent(() => import('@/components/normalform')) const CardSimpleComponent = asyncComponent(() => import('@/menu/components/card/cardsimplecomponent')) const CopyComponent = asyncIconComponent(() => import('@/menu/components/share/copycomponent')) +const ClockComponent = asyncIconComponent(() => import('@/menu/components/share/clockcomponent')) const UserComponent = asyncIconComponent(() => import('@/menu/components/share/usercomponent')) const NormalHeader = asyncComponent(() => import('@/menu/components/share/normalheader')) @@ -217,6 +218,7 @@ </NormalForm> <CopyComponent type="timeline" card={card}/> <FontColorsOutlined className="style" title="璋冩暣鏍峰紡" onClick={this.changeStyle}/> + <ClockComponent config={card} updateConfig={this.updateComponent}/> <UserComponent config={card}/> <DeleteOutlined className="close" title="鍒犻櫎缁勪欢" onClick={() => this.props.deletecomponent(card.uuid)} /> <SettingComponent config={card} updateConfig={this.updateComponent} /> diff --git a/src/tabviews/custom/components/card/balcony/index.jsx b/src/tabviews/custom/components/card/balcony/index.jsx index 8429861..c00e0fa 100644 --- a/src/tabviews/custom/components/card/balcony/index.jsx +++ b/src/tabviews/custom/components/card/balcony/index.jsx @@ -2,13 +2,12 @@ import PropTypes from 'prop-types' import { is, fromJS } from 'immutable' import { Spin, notification, Checkbox } from 'antd' -import moment from 'moment' import Api from '@/api' -import Utils from '@/utils/utils.js' import UtilsDM from '@/utils/utils-datamanage.js' import asyncComponent from '@/utils/asyncComponent' import MKEmitter from '@/utils/events.js' +import TimerTask from '@/utils/timer-task.js' import './index.scss' const CardCellComponent = asyncComponent(() => import('../cardcellList')) @@ -123,12 +122,18 @@ } componentDidMount () { + const { config } = this.state + MKEmitter.addListener('reloadData', this.reloadData) MKEmitter.addListener('syncBalconyData', this.syncBalconyData) MKEmitter.addListener('resetSelectLine', this.resetParentParam) MKEmitter.addListener('queryModuleParam', this.queryModuleParam) MKEmitter.addListener('refreshByButtonResult', this.refreshByButtonResult) - this.handleTimer() + + if (config.timer) { + this.timer = new TimerTask() + this.timer.init(config.uuid, config.timer, config.timerRepeats, () => {this.loadData(true)}) + } } shouldComponentUpdate (nextProps, nextState) { @@ -136,7 +141,6 @@ } componentWillUnmount () { - clearTimeout(this.timer) this.setState = () => { return } @@ -145,6 +149,8 @@ MKEmitter.removeListener('resetSelectLine', this.resetParentParam) MKEmitter.removeListener('queryModuleParam', this.queryModuleParam) MKEmitter.removeListener('refreshByButtonResult', this.refreshByButtonResult) + + this.timer && this.timer.stop() } /** @@ -168,72 +174,6 @@ this.setState({sync: false, data: _data}) } - } - - handleTimer = () => { - const { config } = this.state - - if (!config.timer) return - - const _change = { '2s': 2000, '5s': 5000, '15s': 15000, '30s': 30000, '1min': 60000, '5min': 300000, '10min': 600000, '15min': 900000, '30min': 1800000, '1hour': 3600000 } - - let timer = _change[config.timer] - let repeats = config.timerRepeats || 0 - - if (!timer) return - - if (repeats > 0 && repeats <=3) { - this.setState({timer, repeats}) - this.timer = setTimeout(() => { - this.timerTask(repeats) - }, timer) - return - } - - let _param = { - func: 's_get_timers_role', - LText: `select '${window.GLOB.appkey || ''}','${config.uuid}'`, - timer_type: config.timer, - component_id: config.uuid - } - - _param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') // 鏃堕棿鎴� - _param.LText = Utils.formatOptions(_param.LText) // 鍏抽敭瀛楃鏇挎崲锛宐ase64鍔犲瘑 - _param.secretkey = Utils.encrypt(_param.LText, _param.timestamp) // md5瀵嗛挜 - - Api.getSystemConfig(_param).then(result => { - if (!result.status) { - notification.warning({ - top: 92, - message: result.message, - duration: 5 - }) - return - } else if (result.run_type) { - this.setState({timer, repeats}) - this.timer = setTimeout(() => { - this.timerTask(repeats) - }, timer) - } - }) - } - - timerTask = (times) => { - const { timer, repeats } = this.state - if (!timer) return - - this.loadData(true) - - if (repeats) { - times = times - 1 - if (times <= 0) { - clearTimeout(this.timer) - return - } - } - this.timer = setTimeout(() => { - this.timerTask(times) - }, timer) } /** @@ -370,13 +310,14 @@ if (config.timer && config.clearField) { let vals = (config.clearValue || '').split(',') if (vals.includes(_data[config.clearField])) { - clearTimeout(this.timer) + this.timer && this.timer.stop() } } } else { this.setState({ - loading: false, + loading: false }) + this.timer && this.timer.stop() notification.error({ top: 92, message: result.message, diff --git a/src/tabviews/custom/components/card/cardcellList/index.scss b/src/tabviews/custom/components/card/cardcellList/index.scss index 11dec19..2030460 100644 --- a/src/tabviews/custom/components/card/cardcellList/index.scss +++ b/src/tabviews/custom/components/card/cardcellList/index.scss @@ -155,7 +155,7 @@ background-size: cover; background-position: center center; background-repeat: no-repeat; - background-color: #e9e9e9; + background-color: #f5f5f5; } .ant-mk-picture.scale { cursor: zoom-in; diff --git a/src/tabviews/custom/components/card/data-card/index.jsx b/src/tabviews/custom/components/card/data-card/index.jsx index 0d24ab6..557efcd 100644 --- a/src/tabviews/custom/components/card/data-card/index.jsx +++ b/src/tabviews/custom/components/card/data-card/index.jsx @@ -10,6 +10,7 @@ import preImg from '@/assets/img/prev.png' import nextImg from '@/assets/img/next.png' import MKEmitter from '@/utils/events.js' +import TimerTask from '@/utils/timer-task.js' import asyncComponent from '@/utils/asyncComponent' import './index.scss' @@ -195,11 +196,24 @@ } componentDidMount () { + const { config } = this.state + MKEmitter.addListener('reloadData', this.reloadData) MKEmitter.addListener('mkCheckAll', this.mkCheckAll) MKEmitter.addListener('resetSelectLine', this.resetParentParam) MKEmitter.addListener('queryModuleParam', this.queryModuleParam) MKEmitter.addListener('refreshByButtonResult', this.refreshByButtonResult) + + if (config.timer) { + this.timer = new TimerTask() + this.timer.init(config.uuid, config.timer, config.timerRepeats, () => { + this.setState({ + pageIndex: 1 + }, () => { + this.loadData('', 'timer') + }) + }) + } } shouldComponentUpdate (nextProps, nextState) { @@ -256,6 +270,8 @@ MKEmitter.removeListener('resetSelectLine', this.resetParentParam) MKEmitter.removeListener('queryModuleParam', this.queryModuleParam) MKEmitter.removeListener('refreshByButtonResult', this.refreshByButtonResult) + + this.timer && this.timer.stop() } /** @@ -510,9 +526,11 @@ return } - this.setState({ - loading: true - }) + if (type !== 'timer') { + this.setState({ + loading: true + }) + } let _orderBy = config.setting.order || '' let param = UtilsDM.getQueryDataParams(config.setting, arr_field, searches, _orderBy, pageIndex, config.setting.pageSize, BID) @@ -585,6 +603,7 @@ this.setState({ loading: false }) + this.timer && this.timer.stop() notification.error({ top: 92, message: result.message, diff --git a/src/tabviews/custom/components/card/prop-card/index.jsx b/src/tabviews/custom/components/card/prop-card/index.jsx index f07fb25..71a8068 100644 --- a/src/tabviews/custom/components/card/prop-card/index.jsx +++ b/src/tabviews/custom/components/card/prop-card/index.jsx @@ -2,13 +2,12 @@ import PropTypes from 'prop-types' import { is, fromJS } from 'immutable' import { Spin, notification, Col, Row } from 'antd' -import moment from 'moment' import Api from '@/api' -import Utils from '@/utils/utils.js' import UtilsDM from '@/utils/utils-datamanage.js' import asyncComponent from '@/utils/asyncComponent' import MKEmitter from '@/utils/events.js' +import TimerTask from '@/utils/timer-task.js' import './index.scss' const CardItem = asyncComponent(() => import('../cardItem')) @@ -28,7 +27,6 @@ activeKey: '', // 閫変腑鏁版嵁 sync: false, // 鏄惁缁熶竴璇锋眰鏁版嵁 data: {}, // 鏁版嵁 - timer: null, // 瀹氭椂鍣ㄦ椂闂撮棿闅� BData: '', selected: 'false', } @@ -137,11 +135,17 @@ } componentDidMount () { + const { config } = this.state + MKEmitter.addListener('reloadData', this.reloadData) MKEmitter.addListener('resetSelectLine', this.resetParentParam) MKEmitter.addListener('queryModuleParam', this.queryModuleParam) MKEmitter.addListener('refreshByButtonResult', this.refreshByButtonResult) - this.handleTimer() + + if (config.timer) { + this.timer = new TimerTask() + this.timer.init(config.uuid, config.timer, config.timerRepeats, () => {this.loadData(true)}) + } } shouldComponentUpdate (nextProps, nextState) { @@ -149,7 +153,6 @@ } componentWillUnmount () { - clearTimeout(this.timer) this.setState = () => { return } @@ -157,6 +160,8 @@ MKEmitter.removeListener('resetSelectLine', this.resetParentParam) MKEmitter.removeListener('queryModuleParam', this.queryModuleParam) MKEmitter.removeListener('refreshByButtonResult', this.refreshByButtonResult) + + this.timer && this.timer.stop() } /** @@ -208,72 +213,6 @@ } MKEmitter.emit('resetSelectLine', config.uuid, primaryId, data) - } - - handleTimer = () => { - const { config } = this.state - - if (!config.timer) return - - const _change = { '2s': 2000, '5s': 5000, '15s': 15000, '30s': 30000, '1min': 60000, '5min': 300000, '10min': 600000, '15min': 900000, '30min': 1800000, '1hour': 3600000 } - - let timer = _change[config.timer] - let repeats = config.timerRepeats || 0 - - if (!timer) return - - if (repeats > 0 && repeats <=3) { - this.setState({timer, repeats}) - this.timer = setTimeout(() => { - this.timerTask(repeats) - }, timer) - return - } - - let _param = { - func: 's_get_timers_role', - LText: `select '${window.GLOB.appkey || ''}','${config.uuid}'`, - timer_type: config.timer, - component_id: config.uuid - } - - _param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') // 鏃堕棿鎴� - _param.LText = Utils.formatOptions(_param.LText) // 鍏抽敭瀛楃鏇挎崲锛宐ase64鍔犲瘑 - _param.secretkey = Utils.encrypt(_param.LText, _param.timestamp) // md5瀵嗛挜 - - Api.getSystemConfig(_param).then(result => { - if (!result.status) { - notification.warning({ - top: 92, - message: result.message, - duration: 5 - }) - return - } else if (result.run_type) { - this.setState({timer, repeats}) - this.timer = setTimeout(() => { - this.timerTask(repeats) - }, timer) - } - }) - } - - timerTask = (times) => { - const { timer, repeats } = this.state - if (!timer) return - - this.loadData(true) - - if (repeats) { - times = times - 1 - if (times <= 0) { - clearTimeout(this.timer) - return - } - } - this.timer = setTimeout(() => { - this.timerTask(times) - }, timer) } /** @@ -395,14 +334,14 @@ if (config.timer && config.clearField) { let vals = (config.clearValue || '').split(',') if (vals.includes(_data[config.clearField])) { - clearTimeout(this.timer) + this.timer && this.timer.stop() } } } else { this.setState({ - loading: false, - timer: null + loading: false }) + this.timer && this.timer.stop() notification.error({ top: 92, message: result.message, diff --git a/src/tabviews/custom/components/card/table-card/index.jsx b/src/tabviews/custom/components/card/table-card/index.jsx index c0e6424..40dce07 100644 --- a/src/tabviews/custom/components/card/table-card/index.jsx +++ b/src/tabviews/custom/components/card/table-card/index.jsx @@ -10,6 +10,7 @@ import asyncComponent from '@/utils/asyncComponent' import UtilsDM from '@/utils/utils-datamanage.js' import MKEmitter from '@/utils/events.js' +import TimerTask from '@/utils/timer-task.js' import './index.scss' const CardCellComponent = asyncComponent(() => import('../cardcellList')) @@ -122,10 +123,23 @@ } componentDidMount () { + const { config } = this.state + MKEmitter.addListener('reloadData', this.reloadData) MKEmitter.addListener('resetSelectLine', this.resetParentParam) MKEmitter.addListener('queryModuleParam', this.queryModuleParam) MKEmitter.addListener('refreshByButtonResult', this.refreshByButtonResult) + + if (config.timer) { + this.timer = new TimerTask() + this.timer.init(config.uuid, config.timer, config.timerRepeats, () => { + this.setState({ + pageIndex: 1 + }, () => { + this.loadData('timer') + }) + }) + } } shouldComponentUpdate (nextProps, nextState) { @@ -140,6 +154,8 @@ MKEmitter.removeListener('resetSelectLine', this.resetParentParam) MKEmitter.removeListener('queryModuleParam', this.queryModuleParam) MKEmitter.removeListener('refreshByButtonResult', this.refreshByButtonResult) + + this.timer && this.timer.stop() } /** @@ -266,9 +282,11 @@ return } - this.setState({ - loading: true - }) + if (type !== 'timer') { + this.setState({ + loading: true + }) + } let _orderBy = config.setting.order || '' let param = UtilsDM.getQueryDataParams(config.setting, arr_field, searches, _orderBy, pageIndex, config.setting.pageSize, BID) @@ -312,6 +330,7 @@ this.setState({ loading: false }) + this.timer && this.timer.stop() notification.error({ top: 92, message: result.message, diff --git a/src/tabviews/custom/components/carousel/data-card/index.jsx b/src/tabviews/custom/components/carousel/data-card/index.jsx index 5c3334b..788da3d 100644 --- a/src/tabviews/custom/components/carousel/data-card/index.jsx +++ b/src/tabviews/custom/components/carousel/data-card/index.jsx @@ -7,6 +7,7 @@ import UtilsDM from '@/utils/utils-datamanage.js' import MKEmitter from '@/utils/events.js' import asyncComponent from '@/utils/asyncComponent' +import TimerTask from '@/utils/timer-task.js' import './index.scss' const CardItem = asyncComponent(() => import('../cardItem')) @@ -106,9 +107,18 @@ } componentDidMount () { + const { config } = this.state + MKEmitter.addListener('resetSelectLine', this.resetParentParam) MKEmitter.addListener('queryModuleParam', this.queryModuleParam) MKEmitter.addListener('refreshByButtonResult', this.refreshByButtonResult) + + if (config.timer) { + this.timer = new TimerTask() + this.timer.init(config.uuid, config.timer, config.timerRepeats, () => { + this.loadData('timer') + }) + } } shouldComponentUpdate (nextProps, nextState) { @@ -148,6 +158,8 @@ MKEmitter.removeListener('resetSelectLine', this.resetParentParam) MKEmitter.removeListener('queryModuleParam', this.queryModuleParam) MKEmitter.removeListener('refreshByButtonResult', this.refreshByButtonResult) + + this.timer && this.timer.stop() } /** @@ -202,7 +214,7 @@ }) } - async loadData () { + async loadData (type) { const { mainSearch } = this.props const { config, arr_field, BID, BData } = this.state @@ -220,9 +232,11 @@ return } - this.setState({ - loading: true - }) + if (type !== 'timer') { + this.setState({ + loading: true + }) + } let _orderBy = config.setting.order || '' let param = UtilsDM.getQueryDataParams(config.setting, arr_field, searches, _orderBy, '', '', BID) @@ -244,6 +258,7 @@ this.setState({ loading: false }) + this.timer && this.timer.stop() notification.error({ top: 92, message: result.message, diff --git a/src/tabviews/custom/components/carousel/prop-card/index.jsx b/src/tabviews/custom/components/carousel/prop-card/index.jsx index 2b3d4fe..fc913f1 100644 --- a/src/tabviews/custom/components/carousel/prop-card/index.jsx +++ b/src/tabviews/custom/components/carousel/prop-card/index.jsx @@ -7,6 +7,7 @@ import Api from '@/api' import UtilsDM from '@/utils/utils-datamanage.js' import MKEmitter from '@/utils/events.js' +import TimerTask from '@/utils/timer-task.js' import './index.scss' const CardItem = asyncComponent(() => import('../cardItem')) @@ -105,10 +106,19 @@ } componentDidMount () { + const { config } = this.state + MKEmitter.addListener('reloadData', this.reloadData) MKEmitter.addListener('resetSelectLine', this.resetParentParam) MKEmitter.addListener('queryModuleParam', this.queryModuleParam) MKEmitter.addListener('refreshByButtonResult', this.refreshByButtonResult) + + if (config.timer) { + this.timer = new TimerTask() + this.timer.init(config.uuid, config.timer, config.timerRepeats, () => { + this.loadData('timer') + }) + } } shouldComponentUpdate (nextProps, nextState) { @@ -123,6 +133,8 @@ MKEmitter.removeListener('resetSelectLine', this.resetParentParam) MKEmitter.removeListener('queryModuleParam', this.queryModuleParam) MKEmitter.removeListener('refreshByButtonResult', this.refreshByButtonResult) + + this.timer && this.timer.stop() } /** @@ -211,7 +223,7 @@ this.loadData() } - async loadData () { + async loadData (type) { const { mainSearch } = this.props const { config, arr_field, BID, BData } = this.state @@ -234,9 +246,11 @@ return } - this.setState({ - loading: true - }) + if (type !== 'timer') { + this.setState({ + loading: true + }) + } let _orderBy = config.setting.order || '' let param = UtilsDM.getQueryDataParams(config.setting, arr_field, searches, _orderBy, 1, 1, BID) @@ -262,6 +276,7 @@ this.setState({ loading: false }) + this.timer && this.timer.stop() notification.error({ top: 92, message: result.message, diff --git a/src/tabviews/custom/components/chart/antv-bar-line/index.jsx b/src/tabviews/custom/components/chart/antv-bar-line/index.jsx index b90d017..4cb466d 100644 --- a/src/tabviews/custom/components/chart/antv-bar-line/index.jsx +++ b/src/tabviews/custom/components/chart/antv-bar-line/index.jsx @@ -13,6 +13,7 @@ import Utils from '@/utils/utils.js' import UtilsDM from '@/utils/utils-datamanage.js' import MKEmitter from '@/utils/events.js' +import TimerTask from '@/utils/timer-task.js' import NormalHeader from '@/tabviews/custom/components/share/normalheader' import './index.scss' @@ -375,18 +376,25 @@ } componentDidMount () { + const { config } = this.state + MKEmitter.addListener('reloadData', this.reloadData) MKEmitter.addListener('resetSelectLine', this.resetParentParam) MKEmitter.addListener('queryModuleParam', this.queryModuleParam) MKEmitter.addListener('refreshByButtonResult', this.refreshByButtonResult) - this.handleTimer() + + if (config.timer) { + this.timer = new TimerTask() + this.timer.init(config.uuid, config.timer, config.timerRepeats, () => { + this.loadData(true) + }) + } } /** * @description 缁勪欢閿�姣侊紝娓呴櫎state鏇存柊锛屾竻闄ゅ揩鎹烽敭璁剧疆 */ componentWillUnmount () { - clearTimeout(this.timer) this.setState = () => { return } @@ -394,72 +402,8 @@ MKEmitter.removeListener('resetSelectLine', this.resetParentParam) MKEmitter.removeListener('queryModuleParam', this.queryModuleParam) MKEmitter.removeListener('refreshByButtonResult', this.refreshByButtonResult) - } - handleTimer = () => { - const { config } = this.state - - if (!config.timer) return - - const _change = { '2s': 2000, '5s': 5000, '15s': 15000, '30s': 30000, '1min': 60000, '5min': 300000, '10min': 600000, '15min': 900000, '30min': 1800000, '1hour': 3600000 } - - let timer = _change[config.timer] - let repeats = config.timerRepeats || 0 - - if (!timer) return - - if (repeats > 0 && repeats <=3) { - this.setState({timer, repeats}) - this.timer = setTimeout(() => { - this.timerTask(repeats) - }, timer) - return - } - - let _param = { - func: 's_get_timers_role', - LText: `select '${window.GLOB.appkey || ''}','${config.uuid}'`, - timer_type: config.timer, - component_id: config.uuid - } - - _param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') // 鏃堕棿鎴� - _param.LText = Utils.formatOptions(_param.LText) // 鍏抽敭瀛楃鏇挎崲锛宐ase64鍔犲瘑 - _param.secretkey = Utils.encrypt(_param.LText, _param.timestamp) // md5瀵嗛挜 - - Api.getSystemConfig(_param).then(result => { - if (!result.status) { - notification.warning({ - top: 92, - message: result.message, - duration: 5 - }) - return - } else if (result.run_type) { - this.setState({timer, repeats}) - this.timer = setTimeout(() => { - this.timerTask(repeats) - }, timer) - } - }) - } - - timerTask = (times) => { - const { timer, repeats } = this.state - if (!timer) return - - this.loadData(true) - - if (repeats) { - times = times - 1 - if (times <= 0) { - clearTimeout(this.timer) - return - } - } - this.timer = setTimeout(() => { - this.timerTask(times) - }, timer) + this.timer && this.timer.stop() } /** @@ -587,9 +531,9 @@ }) } else { this.setState({ - loading: false, - timer: null + loading: false }) + this.timer && this.timer.stop() notification.error({ top: 92, message: result.message, diff --git a/src/tabviews/custom/components/chart/antv-dashboard/index.jsx b/src/tabviews/custom/components/chart/antv-dashboard/index.jsx index 9d8dbf7..bbda7f1 100644 --- a/src/tabviews/custom/components/chart/antv-dashboard/index.jsx +++ b/src/tabviews/custom/components/chart/antv-dashboard/index.jsx @@ -10,6 +10,7 @@ import Utils from '@/utils/utils.js' import UtilsDM from '@/utils/utils-datamanage.js' import MKEmitter from '@/utils/events.js' +import TimerTask from '@/utils/timer-task.js' import NormalHeader from '@/tabviews/custom/components/share/normalheader' import './index.scss' @@ -166,87 +167,30 @@ } componentDidMount () { + const { config } = this.state + MKEmitter.addListener('reloadData', this.reloadData) MKEmitter.addListener('resetSelectLine', this.resetParentParam) - this.handleTimer() + + if (config.timer) { + this.timer = new TimerTask() + this.timer.init(config.uuid, config.timer, config.timerRepeats, () => { + this.loadData(true) + }) + } } /** * @description 缁勪欢閿�姣侊紝娓呴櫎state鏇存柊锛屾竻闄ゅ揩鎹烽敭璁剧疆 */ componentWillUnmount () { - clearTimeout(this.timer) this.setState = () => { return } MKEmitter.removeListener('reloadData', this.reloadData) MKEmitter.removeListener('resetSelectLine', this.resetParentParam) - } - handleTimer = () => { - const { config } = this.state - - if (!config.timer) return - - const _change = { '2s': 2000, '5s': 5000, '15s': 15000, '30s': 30000, '1min': 60000, '5min': 300000, '10min': 600000, '15min': 900000, '30min': 1800000, '1hour': 3600000 } - - let timer = _change[config.timer] - let repeats = config.timerRepeats || 0 - - if (!timer) return - - if (repeats > 0 && repeats <=3) { - this.setState({timer, repeats}) - this.timer = setTimeout(() => { - this.timerTask(repeats) - }, timer) - return - } - - let _param = { - func: 's_get_timers_role', - LText: `select '${window.GLOB.appkey || ''}','${config.uuid}'`, - timer_type: config.timer, - component_id: config.uuid - } - - _param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') // 鏃堕棿鎴� - _param.LText = Utils.formatOptions(_param.LText) // 鍏抽敭瀛楃鏇挎崲锛宐ase64鍔犲瘑 - _param.secretkey = Utils.encrypt(_param.LText, _param.timestamp) // md5瀵嗛挜 - - Api.getSystemConfig(_param).then(result => { - if (!result.status) { - notification.warning({ - top: 92, - message: result.message, - duration: 5 - }) - return - } else if (result.run_type) { - this.setState({timer, repeats}) - this.timer = setTimeout(() => { - this.timerTask(repeats) - }, timer) - } - }) - } - - timerTask = (times) => { - const { timer, repeats } = this.state - if (!timer) return - - this.loadData(true) - - if (repeats) { - times = times - 1 - if (times <= 0) { - clearTimeout(this.timer) - return - } - } - this.timer = setTimeout(() => { - this.timerTask(times) - }, timer) + this.timer && this.timer.stop() } reloadData = (menuId) => { @@ -331,9 +275,9 @@ }) } else { this.setState({ - loading: false, - timer: null + loading: false }) + this.timer && this.timer.stop() notification.error({ top: 92, message: result.message, diff --git a/src/tabviews/custom/components/chart/antv-pie/index.jsx b/src/tabviews/custom/components/chart/antv-pie/index.jsx index f7fde28..06c4b42 100644 --- a/src/tabviews/custom/components/chart/antv-pie/index.jsx +++ b/src/tabviews/custom/components/chart/antv-pie/index.jsx @@ -13,6 +13,7 @@ import { chartColors } from '@/utils/option.js' import UtilsDM from '@/utils/utils-datamanage.js' import MKEmitter from '@/utils/events.js' +import TimerTask from '@/utils/timer-task.js' import NormalHeader from '@/tabviews/custom/components/share/normalheader' import './index.scss' @@ -122,87 +123,30 @@ } componentDidMount () { + const { config } = this.state + MKEmitter.addListener('reloadData', this.reloadData) MKEmitter.addListener('resetSelectLine', this.resetParentParam) - this.handleTimer() + + if (config.timer) { + this.timer = new TimerTask() + this.timer.init(config.uuid, config.timer, config.timerRepeats, () => { + this.loadData(true) + }) + } } /** * @description 缁勪欢閿�姣侊紝娓呴櫎state鏇存柊锛屾竻闄ゅ揩鎹烽敭璁剧疆 */ componentWillUnmount () { - clearTimeout(this.timer) this.setState = () => { return } MKEmitter.removeListener('reloadData', this.reloadData) MKEmitter.removeListener('resetSelectLine', this.resetParentParam) - } - handleTimer = () => { - const { config } = this.state - - if (!config.timer) return - - const _change = { '2s': 2000, '5s': 5000, '15s': 15000, '30s': 30000, '1min': 60000, '5min': 300000, '10min': 600000, '15min': 900000, '30min': 1800000, '1hour': 3600000 } - - let timer = _change[config.timer] - let repeats = config.timerRepeats || 0 - - if (!timer) return - - if (repeats > 0 && repeats <=3) { - this.setState({timer, repeats}) - this.timer = setTimeout(() => { - this.timerTask(repeats) - }, timer) - return - } - - let _param = { - func: 's_get_timers_role', - LText: `select '${window.GLOB.appkey || ''}','${config.uuid}'`, - timer_type: config.timer, - component_id: config.uuid - } - - _param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') // 鏃堕棿鎴� - _param.LText = Utils.formatOptions(_param.LText) // 鍏抽敭瀛楃鏇挎崲锛宐ase64鍔犲瘑 - _param.secretkey = Utils.encrypt(_param.LText, _param.timestamp) // md5瀵嗛挜 - - Api.getSystemConfig(_param).then(result => { - if (!result.status) { - notification.warning({ - top: 92, - message: result.message, - duration: 5 - }) - return - } else if (result.run_type) { - this.setState({timer, repeats}) - this.timer = setTimeout(() => { - this.timerTask(repeats) - }, timer) - } - }) - } - - timerTask = (times) => { - const { timer, repeats } = this.state - if (!timer) return - - this.loadData(true) - - if (repeats) { - times = times - 1 - if (times <= 0) { - clearTimeout(this.timer) - return - } - } - this.timer = setTimeout(() => { - this.timerTask(times) - }, timer) + this.timer && this.timer.stop() } reloadData = (menuId) => { @@ -293,9 +237,9 @@ }) } else { this.setState({ - loading: false, - timer: null + loading: false }) + this.timer && this.timer.stop() notification.error({ top: 92, message: result.message, diff --git a/src/tabviews/custom/components/chart/antv-scatter/index.jsx b/src/tabviews/custom/components/chart/antv-scatter/index.jsx index f5b5693..bffcc3b 100644 --- a/src/tabviews/custom/components/chart/antv-scatter/index.jsx +++ b/src/tabviews/custom/components/chart/antv-scatter/index.jsx @@ -11,6 +11,7 @@ import asyncBtnComponent from './asyncButtonComponent' import UtilsDM from '@/utils/utils-datamanage.js' import MKEmitter from '@/utils/events.js' +import TimerTask from '@/utils/timer-task.js' import NormalHeader from '@/tabviews/custom/components/share/normalheader' import './index.scss' @@ -112,18 +113,25 @@ } componentDidMount () { + const { config } = this.state + MKEmitter.addListener('reloadData', this.reloadData) MKEmitter.addListener('resetSelectLine', this.resetParentParam) MKEmitter.addListener('queryModuleParam', this.queryModuleParam) MKEmitter.addListener('refreshByButtonResult', this.refreshByButtonResult) - this.handleTimer() + + if (config.timer) { + this.timer = new TimerTask() + this.timer.init(config.uuid, config.timer, config.timerRepeats, () => { + this.loadData(true) + }) + } } /** * @description 缁勪欢閿�姣侊紝娓呴櫎state鏇存柊锛屾竻闄ゅ揩鎹烽敭璁剧疆 */ componentWillUnmount () { - clearTimeout(this.timer) this.setState = () => { return } @@ -131,72 +139,8 @@ MKEmitter.removeListener('resetSelectLine', this.resetParentParam) MKEmitter.removeListener('queryModuleParam', this.queryModuleParam) MKEmitter.removeListener('refreshByButtonResult', this.refreshByButtonResult) - } - handleTimer = () => { - const { config } = this.state - - if (!config.timer) return - - const _change = { '2s': 2000, '5s': 5000, '15s': 15000, '30s': 30000, '1min': 60000, '5min': 300000, '10min': 600000, '15min': 900000, '30min': 1800000, '1hour': 3600000 } - - let timer = _change[config.timer] - let repeats = config.timerRepeats || 0 - - if (!timer) return - - if (repeats > 0 && repeats <=3) { - this.setState({timer, repeats}) - this.timer = setTimeout(() => { - this.timerTask(repeats) - }, timer) - return - } - - let _param = { - func: 's_get_timers_role', - LText: `select '${window.GLOB.appkey || ''}','${config.uuid}'`, - timer_type: config.timer, - component_id: config.uuid - } - - _param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') // 鏃堕棿鎴� - _param.LText = Utils.formatOptions(_param.LText) // 鍏抽敭瀛楃鏇挎崲锛宐ase64鍔犲瘑 - _param.secretkey = Utils.encrypt(_param.LText, _param.timestamp) // md5瀵嗛挜 - - Api.getSystemConfig(_param).then(result => { - if (!result.status) { - notification.warning({ - top: 92, - message: result.message, - duration: 5 - }) - return - } else if (result.run_type) { - this.setState({timer, repeats}) - this.timer = setTimeout(() => { - this.timerTask(repeats) - }, timer) - } - }) - } - - timerTask = (times) => { - const { timer, repeats } = this.state - if (!timer) return - - this.loadData(true) - - if (repeats) { - times = times - 1 - if (times <= 0) { - clearTimeout(this.timer) - return - } - } - this.timer = setTimeout(() => { - this.timerTask(times) - }, timer) + this.timer && this.timer.stop() } /** @@ -326,9 +270,9 @@ }) } else { this.setState({ - loading: false, - timer: null + loading: false }) + this.timer && this.timer.stop() notification.error({ top: 92, message: result.message, diff --git a/src/tabviews/custom/components/chart/custom-chart/index.jsx b/src/tabviews/custom/components/chart/custom-chart/index.jsx index 3223266..2680e59 100644 --- a/src/tabviews/custom/components/chart/custom-chart/index.jsx +++ b/src/tabviews/custom/components/chart/custom-chart/index.jsx @@ -5,12 +5,12 @@ import DataSet from '@antv/data-set' import * as echarts from 'echarts' import { Spin, Empty, notification } from 'antd' -import moment from 'moment' import Api from '@/api' import Utils from '@/utils/utils.js' import UtilsDM from '@/utils/utils-datamanage.js' import MKEmitter from '@/utils/events.js' +import TimerTask from '@/utils/timer-task.js' import NormalHeader from '@/tabviews/custom/components/share/normalheader' import './index.scss' @@ -107,18 +107,25 @@ } componentDidMount () { + const { config } = this.state + MKEmitter.addListener('reloadData', this.reloadData) MKEmitter.addListener('resetSelectLine', this.resetParentParam) MKEmitter.addListener('queryModuleParam', this.queryModuleParam) MKEmitter.addListener('refreshByButtonResult', this.refreshByButtonResult) - this.handleTimer() + + if (config.timer) { + this.timer = new TimerTask() + this.timer.init(config.uuid, config.timer, config.timerRepeats, () => { + this.loadData(true) + }) + } } /** * @description 缁勪欢閿�姣侊紝娓呴櫎state鏇存柊锛屾竻闄ゅ揩鎹烽敭璁剧疆 */ componentWillUnmount () { - clearTimeout(this.timer) this.setState = () => { return } @@ -126,72 +133,8 @@ MKEmitter.removeListener('resetSelectLine', this.resetParentParam) MKEmitter.removeListener('queryModuleParam', this.queryModuleParam) MKEmitter.removeListener('refreshByButtonResult', this.refreshByButtonResult) - } - handleTimer = () => { - const { config } = this.state - - if (!config.timer) return - - const _change = { '2s': 2000, '5s': 5000, '15s': 15000, '30s': 30000, '1min': 60000, '5min': 300000, '10min': 600000, '15min': 900000, '30min': 1800000, '1hour': 3600000 } - - let timer = _change[config.timer] - let repeats = config.timerRepeats || 0 - - if (!timer) return - - if (repeats > 0 && repeats <=3) { - this.setState({timer, repeats}) - this.timer = setTimeout(() => { - this.timerTask(repeats) - }, timer) - return - } - - let _param = { - func: 's_get_timers_role', - LText: `select '${window.GLOB.appkey || ''}','${config.uuid}'`, - timer_type: config.timer, - component_id: config.uuid - } - - _param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') // 鏃堕棿鎴� - _param.LText = Utils.formatOptions(_param.LText) // 鍏抽敭瀛楃鏇挎崲锛宐ase64鍔犲瘑 - _param.secretkey = Utils.encrypt(_param.LText, _param.timestamp) // md5瀵嗛挜 - - Api.getSystemConfig(_param).then(result => { - if (!result.status) { - notification.warning({ - top: 92, - message: result.message, - duration: 5 - }) - return - } else if (result.run_type) { - this.setState({timer, repeats}) - this.timer = setTimeout(() => { - this.timerTask(repeats) - }, timer) - } - }) - } - - timerTask = (times) => { - const { timer, repeats } = this.state - if (!timer) return - - this.loadData(true) - - if (repeats) { - times = times - 1 - if (times <= 0) { - clearTimeout(this.timer) - return - } - } - this.timer = setTimeout(() => { - this.timerTask(times) - }, timer) + this.timer && this.timer.stop() } /** @@ -320,9 +263,9 @@ }) } else { this.setState({ - loading: false, - timer: null + loading: false }) + this.timer && this.timer.stop() notification.error({ top: 92, message: result.message, diff --git a/src/tabviews/custom/components/share/normalTable/index.scss b/src/tabviews/custom/components/share/normalTable/index.scss index d9c7c76..ebaa748 100644 --- a/src/tabviews/custom/components/share/normalTable/index.scss +++ b/src/tabviews/custom/components/share/normalTable/index.scss @@ -100,7 +100,8 @@ position: relative; background-position: center center; background-size: cover; - background-color: #e9e9e9; + background-repeat: no-repeat; + background-color: #f5f5f5; margin: 2px; } .ant-mk-picture.scale { diff --git a/src/tabviews/custom/components/table/edit-table/normalTable/index.scss b/src/tabviews/custom/components/table/edit-table/normalTable/index.scss index 519c26e..4e5b652 100644 --- a/src/tabviews/custom/components/table/edit-table/normalTable/index.scss +++ b/src/tabviews/custom/components/table/edit-table/normalTable/index.scss @@ -78,7 +78,8 @@ position: relative; background-position: center center; background-size: cover; - background-color: #e9e9e9; + background-repeat: no-repeat; + background-color: #f5f5f5; margin: 2px; } .ant-mk-picture.scale { diff --git a/src/tabviews/custom/components/table/normal-table/index.jsx b/src/tabviews/custom/components/table/normal-table/index.jsx index d7b7184..8f7ea2a 100644 --- a/src/tabviews/custom/components/table/normal-table/index.jsx +++ b/src/tabviews/custom/components/table/normal-table/index.jsx @@ -8,6 +8,7 @@ import UtilsDM from '@/utils/utils-datamanage.js' import asyncComponent from '@/utils/asyncComponent' import MKEmitter from '@/utils/events.js' +import TimerTask from '@/utils/timer-task.js' import './index.scss' // 閫氱敤缁勪欢 @@ -180,7 +181,7 @@ * @param { Boolean } reset 琛ㄦ牸鏄惁閲嶇疆 * @param { String } repage 琛ㄦ牸鏄惁閲嶇疆椤电爜 */ - async loadmaindata (reset, repage, id) { + async loadmaindata (reset, repage, id, type) { const { mainSearch } = this.props const { setting, config, arr_field, search, orderBy, BID, pageIndex, pageSize, BData } = this.state @@ -214,9 +215,11 @@ return } - this.setState({ - loading: true - }) + if (type !== 'timer') { + this.setState({ + loading: true + }) + } let _orderBy = orderBy || setting.order let param = UtilsDM.getQueryDataParams(setting, arr_field, searches, _orderBy, pageIndex, pageSize, BID) @@ -269,6 +272,7 @@ this.setState({ loading: false }) + this.timer && this.timer.stop() notification.error({ top: 92, message: result.message, @@ -612,10 +616,24 @@ } componentDidMount () { + const { config } = this.state + MKEmitter.addListener('reloadData', this.reloadData) MKEmitter.addListener('resetSelectLine', this.resetParentParam) MKEmitter.addListener('queryModuleParam', this.queryModuleParam) MKEmitter.addListener('refreshByButtonResult', this.refreshByButtonResult) + + if (config.timer) { + this.timer = new TimerTask() + this.timer.init(config.uuid, config.timer, config.timerRepeats, () => { + this.setState({ + pageIndex: 1 + }, () => { + this.loadmaindata(true, 'true', '', 'timer') + this.getStatFieldsValue() + }) + }) + } } /** @@ -629,6 +647,8 @@ MKEmitter.removeListener('resetSelectLine', this.resetParentParam) MKEmitter.removeListener('queryModuleParam', this.queryModuleParam) MKEmitter.removeListener('refreshByButtonResult', this.refreshByButtonResult) + + this.timer && this.timer.stop() } render() { diff --git a/src/tabviews/custom/components/timeline/normal-timeline/index.jsx b/src/tabviews/custom/components/timeline/normal-timeline/index.jsx index 1dbcafe..99f4cda 100644 --- a/src/tabviews/custom/components/timeline/normal-timeline/index.jsx +++ b/src/tabviews/custom/components/timeline/normal-timeline/index.jsx @@ -8,6 +8,7 @@ import asyncComponent from '@/utils/asyncComponent' import UtilsDM from '@/utils/utils-datamanage.js' import MKEmitter from '@/utils/events.js' +import TimerTask from '@/utils/timer-task.js' import './index.scss' const CardCellComponent = asyncComponent(() => import('@/tabviews/custom/components/card/cardcellList')) @@ -109,10 +110,19 @@ } componentDidMount () { + const { config } = this.state + MKEmitter.addListener('reloadData', this.reloadData) MKEmitter.addListener('resetSelectLine', this.resetParentParam) MKEmitter.addListener('queryModuleParam', this.queryModuleParam) MKEmitter.addListener('refreshByButtonResult', this.refreshByButtonResult) + + if (config.timer) { + this.timer = new TimerTask() + this.timer.init(config.uuid, config.timer, config.timerRepeats, () => { + this.loadData(true) + }) + } } shouldComponentUpdate (nextProps, nextState) { @@ -127,6 +137,8 @@ MKEmitter.removeListener('resetSelectLine', this.resetParentParam) MKEmitter.removeListener('queryModuleParam', this.queryModuleParam) MKEmitter.removeListener('refreshByButtonResult', this.refreshByButtonResult) + + this.timer && this.timer.stop() } /** @@ -226,7 +238,7 @@ }) } - async loadData () { + async loadData (hastimer) { const { mainSearch } = this.props const { config, arr_field, BID, BData } = this.state @@ -257,9 +269,11 @@ return } - this.setState({ - loading: true - }) + if (!hastimer) { + this.setState({ + loading: true + }) + } let _orderBy = config.setting.order || '' let param = UtilsDM.getQueryDataParams(config.setting, arr_field, searches, _orderBy, 1, config.setting.pageSize, BID) @@ -281,6 +295,7 @@ this.setState({ loading: false }) + this.timer && this.timer.stop() notification.error({ top: 92, message: result.message, diff --git a/src/tabviews/custom/components/tree/antd-tree/index.jsx b/src/tabviews/custom/components/tree/antd-tree/index.jsx index 3d8f850..41794b6 100644 --- a/src/tabviews/custom/components/tree/antd-tree/index.jsx +++ b/src/tabviews/custom/components/tree/antd-tree/index.jsx @@ -3,12 +3,11 @@ import { is, fromJS } from 'immutable' import { Spin, Empty, notification, Input, Tree } from 'antd' import { FolderOpenOutlined, FolderOutlined, FileOutlined } from '@ant-design/icons' -import moment from 'moment' import Api from '@/api' -import Utils from '@/utils/utils.js' import UtilsDM from '@/utils/utils-datamanage.js' import MKEmitter from '@/utils/events.js' +import TimerTask from '@/utils/timer-task.js' import './index.scss' const { TreeNode } = Tree @@ -73,7 +72,7 @@ }, () => { if (config.setting.sync !== 'true' && config.setting.onload === 'true') { setTimeout(() => { - this.loadData(null) + this.loadData() }, config.setting.delay || 0) } else if (config.setting.sync === 'true' && _data) { this.handleData() @@ -108,87 +107,30 @@ } componentDidMount () { + const { config } = this.state + MKEmitter.addListener('reloadData', this.reloadData) MKEmitter.addListener('resetSelectLine', this.resetParentParam) - this.handleTimer() + + if (config.timer) { + this.timer = new TimerTask() + this.timer.init(config.uuid, config.timer, config.timerRepeats, () => { + this.loadData(true) + }) + } } /** * @description 缁勪欢閿�姣侊紝娓呴櫎state鏇存柊锛屾竻闄ゅ揩鎹烽敭璁剧疆 */ componentWillUnmount () { - clearTimeout(this.timer) this.setState = () => { return } MKEmitter.removeListener('reloadData', this.reloadData) MKEmitter.removeListener('resetSelectLine', this.resetParentParam) - } - handleTimer = () => { - const { config } = this.state - - if (!config.timer) return - - const _change = { '2s': 2000, '5s': 5000, '15s': 15000, '30s': 30000, '1min': 60000, '5min': 300000, '10min': 600000, '15min': 900000, '30min': 1800000, '1hour': 3600000 } - - let timer = _change[config.timer] - let repeats = config.timerRepeats || 0 - - if (!timer) return - - if (repeats > 0 && repeats <=3) { - this.setState({timer, repeats}) - this.timer = setTimeout(() => { - this.timerTask(repeats) - }, timer) - return - } - - let _param = { - func: 's_get_timers_role', - LText: `select '${window.GLOB.appkey || ''}','${config.uuid}'`, - timer_type: config.timer, - component_id: config.uuid - } - - _param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') // 鏃堕棿鎴� - _param.LText = Utils.formatOptions(_param.LText) // 鍏抽敭瀛楃鏇挎崲锛宐ase64鍔犲瘑 - _param.secretkey = Utils.encrypt(_param.LText, _param.timestamp) // md5瀵嗛挜 - - Api.getSystemConfig(_param).then(result => { - if (!result.status) { - notification.warning({ - top: 92, - message: result.message, - duration: 5 - }) - return - } else if (result.run_type) { - this.setState({timer, repeats}) - this.timer = setTimeout(() => { - this.timerTask(repeats) - }, timer) - } - }) - } - - timerTask = (times) => { - const { timer, repeats } = this.state - if (!timer) return - - this.loadData(true) - - if (repeats) { - times = times - 1 - if (times <= 0) { - clearTimeout(this.timer) - return - } - } - this.timer = setTimeout(() => { - this.timerTask(times) - }, timer) + this.timer && this.timer.stop() } reloadData = (menuId) => { @@ -252,9 +194,9 @@ }) } else { this.setState({ - loading: false, - timer: null + loading: false }) + this.timer && this.timer.stop() notification.error({ top: 92, message: result.message, diff --git a/src/tabviews/zshare/normalTable/index.scss b/src/tabviews/zshare/normalTable/index.scss index 484fe09..0011eac 100644 --- a/src/tabviews/zshare/normalTable/index.scss +++ b/src/tabviews/zshare/normalTable/index.scss @@ -175,9 +175,10 @@ padding: 5px; } .mk-picture { - background-color: #e9e9e9; + background-color: #f5f5f5; background-position: center center; background-size: cover; + background-repeat: no-repeat; } .image-scale { cursor: zoom-in; diff --git a/src/utils/timer-task.js b/src/utils/timer-task.js new file mode 100644 index 0000000..d9e54bc --- /dev/null +++ b/src/utils/timer-task.js @@ -0,0 +1,71 @@ +import { notification } from 'antd' +import moment from 'moment' + +import Api from '@/api' +import Utils from '@/utils/utils.js' + +export default class timerTask { + constructor() { + this.timer = null + this.interval = null + this.repeats = 0 + } + + init(uuid, interval, repeats, callback) { + const _change = { '2s': 2000, '5s': 5000, '15s': 15000, '30s': 30000, '1min': 60000, '5min': 300000, '10min': 600000, '15min': 900000, '30min': 1800000, '1hour': 3600000 } + + this.interval = _change[interval] + this.repeats = repeats || 0 + + if (!this.interval) return + + if (this.repeats > 0 && this.repeats <=3) { + this.timer = setTimeout(() => { + this.timerTask(this.repeats, callback) + }, this.interval) + } else { + let _param = { + func: 's_get_timers_role', + LText: `select '${window.GLOB.appkey || ''}','${uuid}'`, + timer_type: interval, + component_id: uuid + } + + _param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') // 鏃堕棿鎴� + _param.LText = Utils.formatOptions(_param.LText) // 鍏抽敭瀛楃鏇挎崲锛宐ase64鍔犲瘑 + _param.secretkey = Utils.encrypt(_param.LText, _param.timestamp) // md5瀵嗛挜 + + Api.getSystemConfig(_param).then(result => { + if (!result.status) { + notification.warning({ + top: 92, + message: result.message, + duration: 5 + }) + } else if (result.run_type) { + this.timer = setTimeout(() => { + this.timerTask(this.repeats, callback) + }, this.interval) + } + }) + } + } + + timerTask(times, callback) { + callback() + if (this.repeats) { + times = times - 1 + if (times <= 0) { + clearTimeout(this.timer) + return + } + } + this.timer = setTimeout(() => { + this.timerTask(times, callback) + }, this.interval) + } + + stop() { + clearTimeout(this.timer) + } +} \ No newline at end of file -- Gitblit v1.8.0