From b26252d4e842e2561b5295b0d07ae98a4eaa3fe6 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期四, 16 三月 2023 14:17:57 +0800 Subject: [PATCH] 2023-03-16 --- src/views/sso/index.jsx | 6 + src/tabviews/custom/components/card/cardcellList/index.jsx | 3 src/views/design/header/index.jsx | 10 -- src/menu/components/group/paste/index.jsx | 2 src/tabviews/custom/components/card/double-data-card/index.jsx | 78 ++++++++----------- src/utils/utils-custom.js | 12 ++ src/menu/components/card/double-data-card/index.jsx | 2 src/menu/pastecontroller/index.jsx | 12 +- src/menu/components/card/data-card/index.jsx | 2 src/api/index.js | 22 +---- src/mob/components/formdragelement/index.scss | 11 ++ src/menu/components/tabs/paste/index.jsx | 10 +- src/tabviews/custom/components/card/data-card/index.jsx | 51 +++++++++--- src/views/login/index.jsx | 6 + 14 files changed, 120 insertions(+), 107 deletions(-) diff --git a/src/api/index.js b/src/api/index.js index fc1f44b..2f88dfc 100644 --- a/src/api/index.js +++ b/src/api/index.js @@ -305,6 +305,7 @@ * @description 鐧诲綍绯荤粺, 鑾峰彇鐢ㄦ埛淇℃伅 */ getusermsg (username, password, isCloud = false) { + let shim = +sessionStorage.getItem('sys_time_shim') let param = { // func: 'webapi_login', UserName: username, @@ -314,15 +315,8 @@ login_id_address: sessionStorage.getItem('ipAddress') || '', kei_id: window.btoa(window.encodeURIComponent(window.GLOB.host)), device_id: localStorage.getItem('SessionUid'), - timestamp: moment().format('YYYY-MM-DD HH:mm:ss'), + timestamp: moment().add(shim, 'seconds').format('YYYY-MM-DD HH:mm:ss'), appkey: window.GLOB.appkey || '' - } - - let sys_datetime = sessionStorage.getItem('sys_datetime') - let app_datetime = sessionStorage.getItem('app_datetime') - if (sys_datetime && app_datetime) { - let seconds = Math.floor((new Date().getTime() - app_datetime) / 1000) - param.timestamp = moment(sys_datetime, 'YYYY-MM-DD HH:mm:ss').add(seconds, 'seconds').format('YYYY-MM-DD HH:mm:ss') } // Type: 'S' 鏃� @@ -420,16 +414,8 @@ return Promise.reject() } - let curTime = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' - let sys_datetime = sessionStorage.getItem('sys_datetime') - let app_datetime = sessionStorage.getItem('app_datetime') - if (sys_datetime && app_datetime) { - let seconds = Math.floor((new Date().getTime() - app_datetime) / 1000) - let _curTime = moment(sys_datetime, 'YYYY-MM-DD HH:mm:ss').add(seconds, 'seconds').format('YYYY-MM-DD HH:mm:ss') + '.000' - if (/^\d{4}-\d{2}-\d{2}/.test(_curTime)) { - curTime = _curTime - } - } + let shim = +sessionStorage.getItem('sys_time_shim') + let curTime = moment().add(shim, 'seconds').format('YYYY-MM-DD HH:mm:ss') + '.000' // if (window.GLOB.WebSql) { // return new Promise((resolve, reject) => { diff --git a/src/menu/components/card/data-card/index.jsx b/src/menu/components/card/data-card/index.jsx index 6d59bf0..bc06811 100644 --- a/src/menu/components/card/data-card/index.jsx +++ b/src/menu/components/card/data-card/index.jsx @@ -617,7 +617,7 @@ {card.subcards.map((subcard, index) => (<CardComponent key={subcard.uuid} cards={card} card={subcard} move={this.move} updateElement={this.updateCard} deleteElement={this.deleteCard}/>))} </div> <div style={{clear: 'both'}}></div> - {card.wrap.pagestyle === 'page' && card.setting.laypage === 'true' && appType !== 'mob' ? <Pagination total={85} size="small" showTotal={total => `鍏� ${total} 鏉} pageSize={20} defaultCurrent={1}/> : null} + {card.wrap.pagestyle === 'page' && card.setting.laypage === 'true' && appType !== 'mob' ? <Pagination total={45} size="small" showTotal={total => `1-10 鍏� ${total} 鏉} showSizeChanger={true} pageSize={10} defaultCurrent={1}/> : null} {card.wrap.pagestyle === 'page' && card.setting.laypage === 'true' && appType === 'mob' ? <MobPagination /> : null} {card.wrap.pagestyle === 'more' && card.setting.laypage === 'true' ? <div className="mk-more">鏌ョ湅鏇村<DownOutlined/></div> : null} <div className="component-name"> diff --git a/src/menu/components/card/double-data-card/index.jsx b/src/menu/components/card/double-data-card/index.jsx index 13ea638..10e0a47 100644 --- a/src/menu/components/card/double-data-card/index.jsx +++ b/src/menu/components/card/double-data-card/index.jsx @@ -612,7 +612,7 @@ })} </div> <div style={{clear: 'both'}}></div> - {card.wrap.pagestyle === 'page' && card.setting.laypage === 'true' && appType !== 'mob' ? <Pagination total={85} size="small" showTotal={total => `鍏� ${total} 鏉} pageSize={20} defaultCurrent={1}/> : null} + {card.wrap.pagestyle === 'page' && card.setting.laypage === 'true' && appType !== 'mob' ? <Pagination total={45} size="small" showTotal={total => `1-10 鍏� ${total} 鏉} showSizeChanger={true} pageSize={10} defaultCurrent={1}/> : null} {card.wrap.pagestyle === 'page' && card.setting.laypage === 'true' && appType === 'mob' ? <MobPagination /> : null} {card.wrap.pagestyle === 'more' && card.setting.laypage === 'true' ? <div className="mk-more">鏌ョ湅鏇村<DownOutlined/></div> : null} <div className="component-name"> diff --git a/src/menu/components/group/paste/index.jsx b/src/menu/components/group/paste/index.jsx index 77f15d1..608cf32 100644 --- a/src/menu/components/group/paste/index.jsx +++ b/src/menu/components/group/paste/index.jsx @@ -53,7 +53,7 @@ return } - res = MenuUtils.resetComponentConfig(res) + res = MenuUtils.resetComponentConfig(res, appType) delete res.copyType diff --git a/src/menu/components/tabs/paste/index.jsx b/src/menu/components/tabs/paste/index.jsx index 346f029..31151b9 100644 --- a/src/menu/components/tabs/paste/index.jsx +++ b/src/menu/components/tabs/paste/index.jsx @@ -19,7 +19,7 @@ visible: false } - resetconfig = (item) => { + resetconfig = (item, appType) => { if (item.type === 'tabs') { item.uuid = MenuUtils.getuuid() item.setting.name = item.setting.name + MenuUtils.getSignName() @@ -29,7 +29,7 @@ tab.uuid = MenuUtils.getuuid() tab.components = tab.components.map(cell => { - cell = this.resetconfig(cell) + cell = this.resetconfig(cell, appType) return cell }) }) @@ -39,12 +39,12 @@ item.name = item.setting.name item.components = item.components.map(cell => { - cell = MenuUtils.resetComponentConfig(cell) + cell = MenuUtils.resetComponentConfig(cell, appType) return cell }) } else { - item = MenuUtils.resetComponentConfig(item) + item = MenuUtils.resetComponentConfig(item, appType) } return item @@ -83,7 +83,7 @@ return } - res = this.resetconfig(res) + res = this.resetconfig(res, appType) delete res.copyType diff --git a/src/menu/pastecontroller/index.jsx b/src/menu/pastecontroller/index.jsx index d816e9d..408e162 100644 --- a/src/menu/pastecontroller/index.jsx +++ b/src/menu/pastecontroller/index.jsx @@ -18,9 +18,7 @@ visible: false } - resetconfig = (item) => { - let appType = sessionStorage.getItem('appType') - + resetconfig = (item, appType) => { if (item.type === 'tabs') { item.uuid = MenuUtils.getuuid() item.setting.name = item.setting.name + MenuUtils.getSignName() @@ -34,7 +32,7 @@ } tab.components = tab.components.map(cell => { - cell = this.resetconfig(cell) + cell = this.resetconfig(cell, appType) return cell }) }) @@ -44,11 +42,11 @@ item.name = item.setting.name item.components = item.components.map(cell => { - cell = MenuUtils.resetComponentConfig(cell) + cell = MenuUtils.resetComponentConfig(cell, appType) return cell }) } else { - item = MenuUtils.resetComponentConfig(item) + item = MenuUtils.resetComponentConfig(item, appType) } return item @@ -78,7 +76,7 @@ return } - res = this.resetconfig(res) + res = this.resetconfig(res, appType) // delete res.copyType diff --git a/src/mob/components/formdragelement/index.scss b/src/mob/components/formdragelement/index.scss index 23151e5..3772a7b 100644 --- a/src/mob/components/formdragelement/index.scss +++ b/src/mob/components/formdragelement/index.scss @@ -307,6 +307,17 @@ content: '*'; } } + .ant-form-item:not(.required) { + .am-input-label::before { + display: inline-block; + margin-right: 4px; + color: transparent; + font-size: 14px; + font-family: SimSun, sans-serif; + line-height: 1; + content: '*'; + } + } .ant-form-item.no-boder { .am-list-line { border-bottom: none; diff --git a/src/tabviews/custom/components/card/cardcellList/index.jsx b/src/tabviews/custom/components/card/cardcellList/index.jsx index 5171fb0..12491ba 100644 --- a/src/tabviews/custom/components/card/cardcellList/index.jsx +++ b/src/tabviews/custom/components/card/cardcellList/index.jsx @@ -409,7 +409,8 @@ return null } - if (typeof(val) === 'number') { + if (!isNaN(val) && val !== '') { + val = +val if (card.round) { val = Math.round(val * card.round) / card.round } diff --git a/src/tabviews/custom/components/card/data-card/index.jsx b/src/tabviews/custom/components/card/data-card/index.jsx index 95fde61..4976ada 100644 --- a/src/tabviews/custom/components/card/data-card/index.jsx +++ b/src/tabviews/custom/components/card/data-card/index.jsx @@ -31,6 +31,8 @@ config: null, // 鍥捐〃閰嶇疆淇℃伅 search: null, // 鎼滅储鏉′欢 pageIndex: 1, // 椤电爜 + pageSize: 10, + pageOptions: [], activeKey: '', // 閫変腑鍗� selectKeys: [], // 澶氶�夋椂閫変腑鍗$墖 selectedData: [], // 閫変腑鏁版嵁锛岀敤浜庡伐鍏锋爮鎸夐挳 @@ -157,7 +159,19 @@ this.loaded = _data !== null + let pageOptions = ['10', '25', '50', '100', '500', '1000'] + + if (_config.wrap.pagestyle === 'page') { + let size = (_config.setting.pageSize || 10) + '' + if (!pageOptions.includes(size)) { + pageOptions.push(size) + pageOptions = pageOptions.sort((a, b) => a - b) + } + } + this.setState({ + pageSize: _config.setting.pageSize || 10, + pageOptions, supComs, selected, precards, @@ -588,7 +602,7 @@ async loadData (id, type) { const { mainSearch } = this.props - const { config, arr_field, pageIndex, search, BID, BData, selected } = this.state + const { config, arr_field, pageIndex, pageSize, search, BID, BData, selected } = this.state if (config.setting.supModule && !BID && config.wrap.supKey !== 'false') { // BID 涓嶅瓨鍦ㄦ椂锛屼笉鍋氭煡璇� this.loaded = true @@ -641,13 +655,13 @@ } let _orderBy = config.setting.order || '' - let param = UtilsDM.getQueryDataParams(config.setting, arr_field, searches, _orderBy, pageIndex, config.setting.pageSize, BID) + let param = UtilsDM.getQueryDataParams(config.setting, arr_field, searches, _orderBy, pageIndex, pageSize, BID) let result = await Api.genericInterface(param) if (result.status) { let start = 1 if (config.setting.laypage) { - start = config.setting.pageSize * (pageIndex - 1) + 1 + start = pageSize * (pageIndex - 1) + 1 } this.loaded = true @@ -736,7 +750,7 @@ */ async loadLinedata (id) { const { mainSearch } = this.props - const { config, arr_field, pageIndex, search, BID, BData } = this.state + const { config, arr_field, pageIndex, pageSize, search, BID, BData } = this.state let searches = fromJS(search).toJS() if (config.setting.useMSearch && mainSearch && mainSearch.length > 0) { // 涓昏〃鎼滅储鏉′欢 @@ -753,7 +767,7 @@ }) let _orderBy = config.setting.order || '' - let param = UtilsDM.getQueryDataParams(config.setting, arr_field, searches, _orderBy, pageIndex, config.setting.pageSize, BID, id) + let param = UtilsDM.getQueryDataParams(config.setting, arr_field, searches, _orderBy, pageIndex, pageSize, BID, id) let result = await Api.genericInterface(param) if (result.status) { @@ -798,9 +812,9 @@ } loadMore = () => { - const { total, pageIndex, loading, config } = this.state + const { total, pageIndex, pageSize, loading } = this.state - if (loading || config.setting.pageSize * pageIndex >= total) { + if (loading || pageSize * pageIndex >= total) { return } @@ -824,8 +838,8 @@ } nextPage = () => { - const { config, pageIndex, total } = this.state - let _total = config.setting.pageSize * pageIndex + const { pageIndex, pageSize, total } = this.state + let _total = pageSize * pageIndex if (_total >= total) return @@ -848,6 +862,15 @@ this.setState({ search: list, pageIndex: 1 + }, () => { + this.loadData() + }) + } + + pageSizeChange = (current, size) => { + this.setState({ + pageIndex: current, + pageSize: size }, () => { this.loadData() }) @@ -899,14 +922,14 @@ } render() { - const { config, precards, nextcards, loading, data, pageIndex, total, card, activeKey, BID, BData, selectedData, selectKeys } = this.state + const { config, precards, nextcards, loading, data, pageIndex, pageSize, total, card, activeKey, BID, BData, selectedData, selectKeys } = this.state if (config.wrap.empty === 'hidden' && (!data || data.length === 0)) return null let _total = 0 let switchable = false - if (config.wrap.pagestyle === 'switch' && config.pageable && config.setting.laypage && total > config.setting.pageSize && data) { - _total = config.setting.pageSize * pageIndex + if (config.wrap.pagestyle === 'switch' && config.pageable && config.setting.laypage && total > pageSize && data) { + _total = pageSize * pageIndex switchable = true } @@ -986,8 +1009,8 @@ {switchable ? <div className={'prev-page ' + (total <= _total ? 'disabled' : '')} onClick={this.nextPage}><div><div><img src={nextImg} alt=""/></div></div></div> : null} {precards.length === 0 && nextcards.length === 0 && (!data || data.length === 0) ? <Empty description={false}/> : null} </div> - {config.wrap.pagestyle === 'page' && config.setting.laypage && data ? <Pagination size="small" total={total} showTotal={t => `鍏� ${t} 鏉} pageSize={config.setting.pageSize} onChange={this.changePageIndex} current={pageIndex}/> : null} - {config.wrap.pagestyle === 'more' && config.setting.laypage && data && data.length > 0 ? <div className={'mk-more' + (config.setting.pageSize * pageIndex >= total ? ' disabled' : '')} onClick={this.loadMore}>鏌ョ湅鏇村<DownOutlined/></div> : null} + {config.wrap.pagestyle === 'page' && config.setting.laypage && data ? <Pagination size="small" total={total} showTotal={(t, range) => `${range[0]}-${range[1]} 鍏� ${total} 鏉} pageSize={pageSize} showSizeChanger={true} pageSizeOptions={this.state.pageOptions} onChange={this.changePageIndex} onShowSizeChange={this.pageSizeChange} current={pageIndex}/> : null} + {config.wrap.pagestyle === 'more' && config.setting.laypage && data && data.length > 0 ? <div className={'mk-more' + (pageSize * pageIndex >= total ? ' disabled' : '')} onClick={this.loadMore}>鏌ョ湅鏇村<DownOutlined/></div> : null} </div> ) } diff --git a/src/tabviews/custom/components/card/double-data-card/index.jsx b/src/tabviews/custom/components/card/double-data-card/index.jsx index fc363c8..c866b32 100644 --- a/src/tabviews/custom/components/card/double-data-card/index.jsx +++ b/src/tabviews/custom/components/card/double-data-card/index.jsx @@ -7,8 +7,6 @@ import Api from '@/api' import Utils from '@/utils/utils.js' import UtilsDM from '@/utils/utils-datamanage.js' -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' @@ -30,6 +28,8 @@ config: null, // 鍥捐〃閰嶇疆淇℃伅 search: null, // 鎼滅储鏉′欢 pageIndex: 1, // 椤电爜 + pageSize: 10, + pageOptions: [], activeKey: '', // 閫変腑鍗� selectKeys: [], // 澶氶�夋椂閫変腑鍗$墖 selectedData: [], // 閫変腑鏁版嵁锛岀敤浜庡伐鍏锋爮鎸夐挳 @@ -136,8 +136,19 @@ } _config.setting.sub_field = subconfig.columns.map(col => col.field).join(',') + let pageOptions = ['10', '25', '50', '100', '500', '1000'] + + if (_config.wrap.pagestyle === 'page') { + let size = (_config.setting.pageSize || 10) + '' + if (!pageOptions.includes(size)) { + pageOptions.push(size) + pageOptions = pageOptions.sort((a, b) => a - b) + } + } this.setState({ + pageSize: _config.setting.pageSize || 10, + pageOptions, selected, precards, nextcards, @@ -457,7 +468,7 @@ async loadData (id, type) { const { mainSearch } = this.props - const { config, arr_field, pageIndex, search, BID, BData, selected, card } = this.state + const { config, arr_field, pageIndex, pageSize, search, BID, BData, selected, card } = this.state if (config.setting.supModule && !BID && config.wrap.supKey !== 'false') { // BID 涓嶅瓨鍦ㄦ椂锛屼笉鍋氭煡璇� this.loaded = true @@ -508,13 +519,13 @@ } let _orderBy = config.setting.order || '' - let param = UtilsDM.getQueryDataParams(config.setting, arr_field, searches, _orderBy, pageIndex, config.setting.pageSize, BID) + let param = UtilsDM.getQueryDataParams(config.setting, arr_field, searches, _orderBy, pageIndex, pageSize, BID) let result = await Api.genericInterface(param) if (result.status) { let start = 1 if (config.setting.laypage) { - start = config.setting.pageSize * (pageIndex - 1) + 1 + start = pageSize * (pageIndex - 1) + 1 } this.loaded = true @@ -653,7 +664,7 @@ */ async loadLinedata (id) { const { mainSearch } = this.props - const { config, arr_field, pageIndex, search, BID, BData } = this.state + const { config, arr_field, pageIndex, pageSize, search, BID, BData } = this.state let searches = fromJS(search).toJS() if (config.setting.useMSearch && mainSearch && mainSearch.length > 0) { // 涓昏〃鎼滅储鏉′欢 @@ -670,7 +681,7 @@ }) let _orderBy = config.setting.order || '' - let param = UtilsDM.getQueryDataParams(config.setting, arr_field, searches, _orderBy, pageIndex, config.setting.pageSize, BID, id) + let param = UtilsDM.getQueryDataParams(config.setting, arr_field, searches, _orderBy, pageIndex, pageSize, BID, id) let result = await Api.genericInterface(param) if (result.status) { @@ -737,9 +748,9 @@ } loadMore = () => { - const { total, pageIndex, loading, config } = this.state + const { total, pageIndex, pageSize, loading } = this.state - if (loading || config.setting.pageSize * pageIndex >= total) { + if (loading || pageSize * pageIndex >= total) { return } @@ -747,31 +758,6 @@ pageIndex: pageIndex + 1 }, () => { this.loadData('', 'plus') - }) - } - - prevPage = () => { - const { pageIndex } = this.state - - if (pageIndex === 1) return - - this.setState({ - pageIndex: pageIndex - 1 - }, () => { - this.loadData() - }) - } - - nextPage = () => { - const { config, pageIndex, total } = this.state - let _total = config.setting.pageSize * pageIndex - - if (_total >= total) return - - this.setState({ - pageIndex: pageIndex + 1 - }, () => { - this.loadData() }) } @@ -787,6 +773,15 @@ this.setState({ search: list, pageIndex: 1 + }, () => { + this.loadData() + }) + } + + pageSizeChange = (current, size) => { + this.setState({ + pageIndex: current, + pageSize: size }, () => { this.loadData() }) @@ -869,16 +864,9 @@ } render() { - const { config, precards, nextcards, loading, data, pageIndex, total, card, activeKey, BID, BData, selectedData, selectKeys, subcard, subconfig, wrapStyle, opens } = this.state + const { config, precards, nextcards, loading, data, pageIndex, pageSize, total, card, activeKey, BID, BData, selectedData, selectKeys, subcard, subconfig, wrapStyle, opens } = this.state if (config.wrap.empty === 'hidden' && (!data || data.length === 0)) return null - - let _total = 0 - let switchable = false - if (config.wrap.pagestyle === 'switch' && config.pageable && config.setting.laypage && total > config.setting.pageSize && data) { - _total = config.setting.pageSize * pageIndex - switchable = true - } let extendData = {$$BID: BID, $$BData: BData, $$selectedData: selectedData, $$type: 'extendCard'} @@ -919,7 +907,6 @@ /> : null } <div className={`data-zoom ${config.wrap.wrapClass}`}> - {switchable ? <div className={'prev-page ' + (pageIndex === 1 ? 'disabled' : '')} onClick={this.prevPage}><div><div><img src={preImg} alt=""/></div></div></div> : null} <Row className={'card-row-list '}> {precards.map((item, index) => ( <Col key={'pre' + index} className="extend-card" span={item.setting.width || 6}> @@ -976,11 +963,10 @@ </Col> ))} </Row> - {switchable ? <div className={'prev-page ' + (total <= _total ? 'disabled' : '')} onClick={this.nextPage}><div><div><img src={nextImg} alt=""/></div></div></div> : null} {precards.length === 0 && nextcards.length === 0 && (!data || data.length === 0) ? <Empty description={false}/> : null} </div> - {config.wrap.pagestyle === 'page' && config.setting.laypage && data ? <Pagination size="small" total={total} showTotal={t => `鍏� ${t} 鏉} pageSize={config.setting.pageSize} onChange={this.changePageIndex} current={pageIndex}/> : null} - {config.wrap.pagestyle === 'more' && config.setting.laypage && data && data.length > 0 ? <div className={'mk-more' + (config.setting.pageSize * pageIndex >= total ? ' disabled' : '')} onClick={this.loadMore}>鏌ョ湅鏇村<DownOutlined/></div> : null} + {config.wrap.pagestyle === 'page' && config.setting.laypage && data ? <Pagination size="small" total={total} showTotal={(t, range) => `${range[0]}-${range[1]} 鍏� ${total} 鏉} pageSize={pageSize} showSizeChanger={true} pageSizeOptions={this.state.pageOptions} onChange={this.changePageIndex} onShowSizeChange={this.pageSizeChange} current={pageIndex}/> : null} + {config.wrap.pagestyle === 'more' && config.setting.laypage && data && data.length > 0 ? <div className={'mk-more' + (pageSize * pageIndex >= total ? ' disabled' : '')} onClick={this.loadMore}>鏌ョ湅鏇村<DownOutlined/></div> : null} </div> ) } diff --git a/src/utils/utils-custom.js b/src/utils/utils-custom.js index c07d64c..823cb11 100644 --- a/src/utils/utils-custom.js +++ b/src/utils/utils-custom.js @@ -709,7 +709,7 @@ * @description 閲嶇疆缁勪欢閰嶇疆 * @return {String} item 缁勪欢淇℃伅 */ - static resetComponentConfig = (item) => { + static resetComponentConfig = (item, appType) => { if (item.type === 'navbar') { return item } @@ -743,6 +743,16 @@ if (item.wrap.autoExec) { item.wrap.autoExec = md5(commonId + item.wrap.autoExec) } + + if (appType !== 'mob') { + if (item.wrap.pagestyle === 'slide') { + item.wrap.pagestyle = 'page' + } + } else { + if (item.wrap.pagestyle === 'switch') { + item.wrap.pagestyle = 'page' + } + } item.subcards.forEach(card => { card.uuid = this.getuuid() diff --git a/src/views/design/header/index.jsx b/src/views/design/header/index.jsx index 674453a..8c60992 100644 --- a/src/views/design/header/index.jsx +++ b/src/views/design/header/index.jsx @@ -256,14 +256,8 @@ } writeFuncs = (funcs) => { - let timestamp = moment().format('YYYY-MM-DD HH:mm:ss') - - let sys_datetime = sessionStorage.getItem('sys_datetime') - let app_datetime = sessionStorage.getItem('app_datetime') - if (sys_datetime && app_datetime) { - let seconds = Math.floor((new Date().getTime() - app_datetime) / 1000) - timestamp = moment(sys_datetime, 'YYYY-MM-DD HH:mm:ss').add(seconds, 'seconds').format('YYYY-MM-DD HH:mm:ss') - } + let shim = +sessionStorage.getItem('sys_time_shim') + let timestamp = moment().add(shim, 'seconds').format('YYYY-MM-DD HH:mm:ss') // if (window.GLOB.WebSql) { // window.GLOB.WebSql.transaction(tx => { diff --git a/src/views/login/index.jsx b/src/views/login/index.jsx index 0a64ba1..af5ae0b 100644 --- a/src/views/login/index.jsx +++ b/src/views/login/index.jsx @@ -631,10 +631,12 @@ } sessionStorage.setItem('home_background', res.index_background_color || '') + + let seconds = 0 if (res.sys_datetime) { - sessionStorage.setItem('sys_datetime', res.sys_datetime) - sessionStorage.setItem('app_datetime', new Date().getTime()) + seconds = Math.floor((new Date(res.sys_datetime).getTime() - new Date().getTime()) / 1000) } + sessionStorage.setItem('sys_time_shim', isNaN(seconds) ? 0 : seconds) // url鏍囬 document.title = systemMsg.platTitle diff --git a/src/views/sso/index.jsx b/src/views/sso/index.jsx index 24c8648..f889cad 100644 --- a/src/views/sso/index.jsx +++ b/src/views/sso/index.jsx @@ -108,10 +108,12 @@ } sessionStorage.setItem('home_background', res.index_background_color || '') + + let seconds = 0 if (res.sys_datetime) { - sessionStorage.setItem('sys_datetime', res.sys_datetime) - sessionStorage.setItem('app_datetime', new Date().getTime()) + seconds = Math.floor((new Date(res.sys_datetime).getTime() - new Date().getTime()) / 1000) } + sessionStorage.setItem('sys_time_shim', isNaN(seconds) ? 0 : seconds) // url鏍囬 document.title = systemMsg.platTitle -- Gitblit v1.8.0