From 3875da845b8fae679bd784d1246101a5fb1b61b5 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期三, 15 三月 2023 16:33:20 +0800 Subject: [PATCH] 2023-03-15 --- src/menu/components/card/balcony/index.jsx | 13 src/api/cacheutils.js | 476 ++++++++++---------- src/views/design/header/index.jsx | 60 +- src/tabviews/custom/components/card/balcony/index.scss | 1 src/components/header/index.jsx | 2 src/menu/components/card/cardcellcomponent/index.jsx | 1 src/tabviews/custom/components/card/double-data-card/index.jsx | 43 + src/views/interface/api/index.js | 116 ++--- src/templates/zshare/verifycard/index.jsx | 4 public/options.json | 10 src/templates/sharecomponent/fieldscomponent/index.jsx | 9 src/menu/components/card/balcony/index.scss | 1 src/api/index.js | 242 +++++----- src/views/interface/workspace/index.jsx | 18 src/views/interface/history/index.jsx | 251 +++++----- src/utils/utils.js | 32 16 files changed, 645 insertions(+), 634 deletions(-) diff --git a/public/options.json b/public/options.json index 4e405d0..bedcbee 100644 --- a/public/options.json +++ b/public/options.json @@ -1,12 +1,12 @@ { - "appId": "201912040924165801464FF1788654BC5AC73", - "appkey": "20191106103859640976D6E924E464D029CF0", + "appId": "202108312122504607B107A83F55B40C98CCF", + "appkey": "20210831212235413F287EC3BF489424496C8", "mainSystemApi": "http://sso.mk9h.cn/cloud/webapi/dostars", "systemType": "", "externalDatabase": "", "lineColor": "", "filter": "false", - "defaultApp": "mk", + "defaultApp": "mkindustry", "defaultLang": "zh-CN", "WXAppID": "", "WXminiAppID": "", @@ -17,6 +17,6 @@ "transfer": "false", "keepPassword": "true", "platforms": ["H5", "wechat", "android", "ios", "wxMiniProgram"], - "host": "http://qingqiumarket.cn", - "service": "MKWMS/" + "host": "http://demo.mk9h.cn", + "service": "erp_new/" } \ No newline at end of file diff --git a/src/api/cacheutils.js b/src/api/cacheutils.js index 1c174d9..244587a 100644 --- a/src/api/cacheutils.js +++ b/src/api/cacheutils.js @@ -2,274 +2,274 @@ * @description 缂撳瓨宸ュ叿绫� */ export default class CacheUtils { - /** - * @description 鎵撳紑websql - */ - static openWebSql (db) { - try { - window.GLOB.WebSql = openDatabase(db, '1', 'mk-pc-database', 50 * 1024 * 1024) - window.GLOB.WebSql.transaction(tx => { - tx.executeSql('CREATE TABLE IF NOT EXISTS VERSIONS (version varchar(50), createDate varchar(50), CDefine1 varchar(50), CDefine2 varchar(50), CDefine3 varchar(50))', [], () => { + // /** + // * @description 鎵撳紑websql + // */ + // static openWebSql (db) { + // try { + // window.GLOB.WebSql = openDatabase(db, '1', 'mk-pc-database', 50 * 1024 * 1024) + // window.GLOB.WebSql.transaction(tx => { + // tx.executeSql('CREATE TABLE IF NOT EXISTS VERSIONS (version varchar(50), createDate varchar(50), CDefine1 varchar(50), CDefine2 varchar(50), CDefine3 varchar(50))', [], () => { - }, () => { - // eslint-disable-next-line - throw 'CREATE TABLE ERROR' - }) - tx.executeSql('CREATE TABLE IF NOT EXISTS CONFIGS (menuid varchar(50), userid varchar(50), openEdition varchar(50), webEdition varchar(50), LongParam text, LongParamUser text, CDefine1 varchar(50), CDefine2 varchar(50), CDefine3 varchar(50), CDefine4 varchar(50), CDefine5 varchar(50))', [], () => { + // }, () => { + // // eslint-disable-next-line + // throw 'CREATE TABLE ERROR' + // }) + // tx.executeSql('CREATE TABLE IF NOT EXISTS CONFIGS (menuid varchar(50), userid varchar(50), openEdition varchar(50), webEdition varchar(50), LongParam text, LongParamUser text, CDefine1 varchar(50), CDefine2 varchar(50), CDefine3 varchar(50), CDefine4 varchar(50), CDefine5 varchar(50))', [], () => { - }, () => { - // eslint-disable-next-line - throw 'CREATE TABLE ERROR' - }) + // }, () => { + // // eslint-disable-next-line + // throw 'CREATE TABLE ERROR' + // }) - tx.executeSql('CREATE TABLE IF NOT EXISTS CACHES (menuid varchar(50), CreateDate varchar(50), LongParam text, CDefine1 varchar(50), CDefine2 varchar(50))', [], () => { + // tx.executeSql('CREATE TABLE IF NOT EXISTS CACHES (menuid varchar(50), CreateDate varchar(50), LongParam text, CDefine1 varchar(50), CDefine2 varchar(50))', [], () => { - }, () => { - // eslint-disable-next-line - throw 'CREATE TABLE ERROR' - }) + // }, () => { + // // eslint-disable-next-line + // throw 'CREATE TABLE ERROR' + // }) - if (window.GLOB.systemType === '') { - tx.executeSql('CREATE TABLE IF NOT EXISTS FUNCS (func_code varchar(50), key_sql text, CDefine1 varchar(50), CDefine2 varchar(50), CDefine3 varchar(50))', [], () => { + // if (window.GLOB.systemType === '') { + // tx.executeSql('CREATE TABLE IF NOT EXISTS FUNCS (func_code varchar(50), key_sql text, CDefine1 varchar(50), CDefine2 varchar(50), CDefine3 varchar(50))', [], () => { - }, () => { - // eslint-disable-next-line - throw 'CREATE TABLE ERROR' - }) - } - }) - // window.GLOB.WebSql.transaction(tx => { - // tx.executeSql('DROP TABLE VERSIONS') - // tx.executeSql('DROP TABLE CONFIGS') - // }) - } catch (e) { - console.warn('WebSql 鍒濆鍖栧け璐ワ紒') - window.GLOB.WebSql = null + // }, () => { + // // eslint-disable-next-line + // throw 'CREATE TABLE ERROR' + // }) + // } + // }) + // // window.GLOB.WebSql.transaction(tx => { + // // tx.executeSql('DROP TABLE VERSIONS') + // // tx.executeSql('DROP TABLE CONFIGS') + // // }) + // } catch (e) { + // console.warn('WebSql 鍒濆鍖栧け璐ワ紒') + // window.GLOB.WebSql = null - if (window.indexedDB) { - this.openIndexDB(db) - } - } - } + // if (window.indexedDB) { + // this.openIndexDB(db) + // } + // } + // } - /** - * @description 娓呯┖鍑芥暟 - */ - static clearFuncs () { - if (window.GLOB.systemType !== '') return + // /** + // * @description 娓呯┖鍑芥暟 + // */ + // static clearFuncs () { + // if (window.GLOB.systemType !== '') return - if (window.GLOB.WebSql) { - window.GLOB.WebSql.transaction(tx => { - tx.executeSql('DELETE FROM FUNCS') + // if (window.GLOB.WebSql) { + // window.GLOB.WebSql.transaction(tx => { + // tx.executeSql('DELETE FROM FUNCS') - tx.executeSql(`UPDATE VERSIONS SET createDate='1970-01-01 14:59:09.000' where CDefine1='funcs'`) - }) - } else if (window.GLOB.IndexDB) { - let objectStore = window.GLOB.IndexDB.transaction(['funcs'], 'readwrite').objectStore('funcs') - objectStore.clear() + // tx.executeSql(`UPDATE VERSIONS SET createDate='1970-01-01 14:59:09.000' where CDefine1='funcs'`) + // }) + // } else if (window.GLOB.IndexDB) { + // let objectStore = window.GLOB.IndexDB.transaction(['funcs'], 'readwrite').objectStore('funcs') + // objectStore.clear() - window.GLOB.IndexDB.transaction(['version'], 'readwrite').objectStore('version').delete('funcs') - } - } + // window.GLOB.IndexDB.transaction(['version'], 'readwrite').objectStore('version').delete('funcs') + // } + // } - /** - * @description 鑾峰彇websql涓繚瀛樹俊鎭増鏈� - */ - static getWebSqlVersion () { - if (!window.GLOB.WebSql) { - return Promise.reject() - } + // /** + // * @description 鑾峰彇websql涓繚瀛樹俊鎭増鏈� + // */ + // static getWebSqlVersion () { + // if (!window.GLOB.WebSql) { + // return Promise.reject() + // } - let deffers = [] + // let deffers = [] - deffers.push( - new Promise((resolve) => { - window.GLOB.WebSql.transaction(tx => { - tx.executeSql("SELECT * FROM VERSIONS where CDefine1='LongParam'", [], (tx, results) => { - if (results.rows[0]) { - resolve(results.rows[0]) - } else { - resolve({version: '', createDate: ''}) - } - }, (tx, results) => { - console.warn(results) - resolve({version: '', createDate: ''}) - }) - }) - }) - ) + // deffers.push( + // new Promise((resolve) => { + // window.GLOB.WebSql.transaction(tx => { + // tx.executeSql("SELECT * FROM VERSIONS where CDefine1='LongParam'", [], (tx, results) => { + // if (results.rows[0]) { + // resolve(results.rows[0]) + // } else { + // resolve({version: '', createDate: ''}) + // } + // }, (tx, results) => { + // console.warn(results) + // resolve({version: '', createDate: ''}) + // }) + // }) + // }) + // ) - deffers.push( - new Promise((resolve) => { - window.GLOB.WebSql.transaction(tx => { - tx.executeSql(`SELECT * FROM CONFIGS`, [], (tx, results) => { - let menus = [] - for (let i = 0; i < results.rows.length; i++) { - menus.push(`'${results.rows[i].menuid}','${results.rows[i].openEdition || 'mk'}'`) - } - resolve(menus) - }, (tx, results) => { - console.warn(results) - resolve([]) - }) - }) - }) - ) + // deffers.push( + // new Promise((resolve) => { + // window.GLOB.WebSql.transaction(tx => { + // tx.executeSql(`SELECT * FROM CONFIGS`, [], (tx, results) => { + // let menus = [] + // for (let i = 0; i < results.rows.length; i++) { + // menus.push(`'${results.rows[i].menuid}','${results.rows[i].openEdition || 'mk'}'`) + // } + // resolve(menus) + // }, (tx, results) => { + // console.warn(results) + // resolve([]) + // }) + // }) + // }) + // ) - return new Promise((resolve) => { - Promise.all(deffers).then(res => { - let result = res[0] + // return new Promise((resolve) => { + // Promise.all(deffers).then(res => { + // let result = res[0] - if (result.createDate && !/^\d{4}-\d{2}-\d{2}/.test(result.createDate)) { - result.createDate = '' - } + // if (result.createDate && !/^\d{4}-\d{2}-\d{2}/.test(result.createDate)) { + // result.createDate = '' + // } - result.menuids = res[1].join(';') + // result.menuids = res[1].join(';') - resolve(result) - }) - }) - } + // resolve(result) + // }) + // }) + // } - /** - * @description 鍒犻櫎websql涓繚瀛樼殑閰嶇疆淇℃伅 - */ - static delWebSqlConfig (keys) { - if (!window.GLOB.WebSql) return + // /** + // * @description 鍒犻櫎websql涓繚瀛樼殑閰嶇疆淇℃伅 + // */ + // static delWebSqlConfig (keys) { + // if (!window.GLOB.WebSql) return - if (!keys) { - window.GLOB.WebSql.transaction(tx => { - tx.executeSql(`DELETE FROM CONFIGS`, [], () => {}, (tx, results) => { - console.warn(results) - }) - }) - } else { - window.GLOB.WebSql.transaction(tx => { - tx.executeSql(`DELETE FROM CONFIGS where menuid in (${keys})`, [], () => {}, (tx, results) => { - console.warn(results) - }) - }) - } - } + // if (!keys) { + // window.GLOB.WebSql.transaction(tx => { + // tx.executeSql(`DELETE FROM CONFIGS`, [], () => {}, (tx, results) => { + // console.warn(results) + // }) + // }) + // } else { + // window.GLOB.WebSql.transaction(tx => { + // tx.executeSql(`DELETE FROM CONFIGS where menuid in (${keys})`, [], () => {}, (tx, results) => { + // console.warn(results) + // }) + // }) + // } + // } - /** - * @description 鍒犻櫎websql涓繚瀛樼殑閰嶇疆淇℃伅 - */ - static delMenuWebSqlConfig (menuId) { - if (!window.GLOB.WebSql || !menuId) return Promise.resolve() - return new Promise(resolve => { - window.GLOB.WebSql.transaction(tx => { - tx.executeSql(`DELETE FROM CONFIGS where menuid='${menuId}'`, [], () => { - resolve() - }, (tx, results) => { - console.warn(results) - resolve() - }) - }) - }) - } + // /** + // * @description 鍒犻櫎websql涓繚瀛樼殑閰嶇疆淇℃伅 + // */ + // static delMenuWebSqlConfig (menuId) { + // if (!window.GLOB.WebSql || !menuId) return Promise.resolve() + // return new Promise(resolve => { + // window.GLOB.WebSql.transaction(tx => { + // tx.executeSql(`DELETE FROM CONFIGS where menuid='${menuId}'`, [], () => { + // resolve() + // }, (tx, results) => { + // console.warn(results) + // resolve() + // }) + // }) + // }) + // } - /** - * @description 鏇存柊websql涓厤缃俊鎭殑鐗堟湰 - */ - static updateWebSqlversion (version, curTime) { - if (!window.GLOB.WebSql) return + // /** + // * @description 鏇存柊websql涓厤缃俊鎭殑鐗堟湰 + // */ + // static updateWebSqlversion (version, curTime) { + // if (!window.GLOB.WebSql) return - window.GLOB.WebSql.transaction(tx => { - tx.executeSql(`DELETE FROM VERSIONS where CDefine1='LongParam'`) + // window.GLOB.WebSql.transaction(tx => { + // tx.executeSql(`DELETE FROM VERSIONS where CDefine1='LongParam'`) - if (version) { - tx.executeSql('INSERT INTO VERSIONS (version, createDate, CDefine1) VALUES (?, ?, ?)', [version, curTime, 'LongParam'], () => {}, (tx, results) => { - console.warn(results) - }) - } - }) - } + // if (version) { + // tx.executeSql('INSERT INTO VERSIONS (version, createDate, CDefine1) VALUES (?, ?, ?)', [version, curTime, 'LongParam'], () => {}, (tx, results) => { + // console.warn(results) + // }) + // } + // }) + // } - /** - * @description 鑾峰彇websql涓殑閰嶇疆淇℃伅 - */ - static getWebSqlMenuConfig (MenuID, userid) { - if (!window.GLOB.WebSql || !MenuID || !userid) return Promise.reject() - return new Promise((resolve, reject) => { - window.GLOB.WebSql.transaction(tx => { - tx.executeSql(`SELECT * FROM CONFIGS WHERE menuid='${MenuID}' and userid='${userid}'`, [], (tx, results) => { - let paramItem = results.rows[0] - if (paramItem) { - resolve({ - ErrCode: 'S', - ErrMesg: '', - LongParam: paramItem.LongParam, - LongParamUser: paramItem.LongParamUser, - message: '', - open_edition: paramItem.openEdition, - status: true, - web_edition: paramItem.webEdition - }) - } else { - reject() - } - }, (tx, results) => { - console.warn(results) - reject() - }) - }) - }) - } + // /** + // * @description 鑾峰彇websql涓殑閰嶇疆淇℃伅 + // */ + // static getWebSqlMenuConfig (MenuID, userid) { + // if (!window.GLOB.WebSql || !MenuID || !userid) return Promise.reject() + // return new Promise((resolve, reject) => { + // window.GLOB.WebSql.transaction(tx => { + // tx.executeSql(`SELECT * FROM CONFIGS WHERE menuid='${MenuID}' and userid='${userid}'`, [], (tx, results) => { + // let paramItem = results.rows[0] + // if (paramItem) { + // resolve({ + // ErrCode: 'S', + // ErrMesg: '', + // LongParam: paramItem.LongParam, + // LongParamUser: paramItem.LongParamUser, + // message: '', + // open_edition: paramItem.openEdition, + // status: true, + // web_edition: paramItem.webEdition + // }) + // } else { + // reject() + // } + // }, (tx, results) => { + // console.warn(results) + // reject() + // }) + // }) + // }) + // } - /** - * @description 灏嗘暟鎹啓鍏ebsql - */ - static writeInWebSql (data) { - if (!window.GLOB.WebSql || !data) return - window.GLOB.WebSql.transaction(tx => { - tx.executeSql('INSERT INTO CONFIGS (menuid, userid, openEdition, webEdition, LongParam, LongParamUser) VALUES (?, ?, ?, ?, ?, ?)', data) - }) - } + // /** + // * @description 灏嗘暟鎹啓鍏ebsql + // */ + // static writeInWebSql (data) { + // if (!window.GLOB.WebSql || !data) return + // window.GLOB.WebSql.transaction(tx => { + // tx.executeSql('INSERT INTO CONFIGS (menuid, userid, openEdition, webEdition, LongParam, LongParamUser) VALUES (?, ?, ?, ?, ?, ?)', data) + // }) + // } - /** - * @description 灏嗙紦瀛樻暟鎹啓鍏ebsql - */ - static writeCacheInWebSql (data) { - if (!window.GLOB.WebSql) return - window.GLOB.WebSql.transaction(tx => { - tx.executeSql(`DELETE FROM CACHES where menuid='${data[0]}'`) - if (data[2]) { - tx.executeSql('INSERT INTO CACHES (menuid, CreateDate, LongParam) VALUES (?, ?, ?)', data) - } - }) - } + // /** + // * @description 灏嗙紦瀛樻暟鎹啓鍏ebsql + // */ + // static writeCacheInWebSql (data) { + // if (!window.GLOB.WebSql) return + // window.GLOB.WebSql.transaction(tx => { + // tx.executeSql(`DELETE FROM CACHES where menuid='${data[0]}'`) + // if (data[2]) { + // tx.executeSql('INSERT INTO CACHES (menuid, CreateDate, LongParam) VALUES (?, ?, ?)', data) + // } + // }) + // } - /** - * @description 鑾峰彇websql涓殑閰嶇疆淇℃伅 - */ - static getWebSqlCacheConfig (MenuID) { - if (!window.GLOB.WebSql) return Promise.resolve() - return new Promise((resolve, reject) => { - window.GLOB.WebSql.transaction(tx => { - tx.executeSql(`SELECT * FROM CACHES WHERE menuid='${MenuID}'`, [], (tx, results) => { - resolve(results.rows[0]) - }, (tx, results) => { - console.warn(results) - resolve() - }) - }) - }) - } + // /** + // * @description 鑾峰彇websql涓殑閰嶇疆淇℃伅 + // */ + // static getWebSqlCacheConfig (MenuID) { + // if (!window.GLOB.WebSql) return Promise.resolve() + // return new Promise((resolve, reject) => { + // window.GLOB.WebSql.transaction(tx => { + // tx.executeSql(`SELECT * FROM CACHES WHERE menuid='${MenuID}'`, [], (tx, results) => { + // resolve(results.rows[0]) + // }, (tx, results) => { + // console.warn(results) + // resolve() + // }) + // }) + // }) + // } - /** - * @description 鍒犻櫎websql涓秴杩�7澶╃殑缂撳瓨淇℃伅 - */ - static delWebSqlCacheConfig (date, type) { - if (!window.GLOB.WebSql) return - window.GLOB.WebSql.transaction(tx => { - if (type === 'all') { - tx.executeSql('DELETE FROM CACHES') - } else { - tx.executeSql(`DELETE FROM CACHES where CreateDate<'${date}'`) - } - }) - } + // /** + // * @description 鍒犻櫎websql涓秴杩�7澶╃殑缂撳瓨淇℃伅 + // */ + // static delWebSqlCacheConfig (date, type) { + // if (!window.GLOB.WebSql) return + // window.GLOB.WebSql.transaction(tx => { + // if (type === 'all') { + // tx.executeSql('DELETE FROM CACHES') + // } else { + // tx.executeSql(`DELETE FROM CACHES where CreateDate<'${date}'`) + // } + // }) + // } /** * @description 鎵撳紑IndexedDB diff --git a/src/api/index.js b/src/api/index.js index bb681d0..fc1f44b 100644 --- a/src/api/index.js +++ b/src/api/index.js @@ -9,7 +9,7 @@ import CacheUtils from './cacheutils' import options from '@/store/options.js' -window.GLOB.WebSql = null +// window.GLOB.WebSql = null window.GLOB.IndexDB = null window.GLOB.OuterToken = {} const systemMenuKeys = `1581067625930haged11ieaivpavv77k,1581734956310scks442ul2d955g9tu5,1583991994144ndddg0bhh0is6shi0v1,1583979633842550imkchl4qt4qppsiv, @@ -21,9 +21,10 @@ let service = window.GLOB.service ? '-' + window.GLOB.service.replace('/', '') : '' let db = `mkdb${service}` -if (window.openDatabase) { - CacheUtils.openWebSql(db) -} else if (window.indexedDB) { +// if (window.openDatabase) { +// CacheUtils.openWebSql(db) +// } else if (window.indexedDB) { +if (window.indexedDB) { CacheUtils.openIndexDB(db) } @@ -363,7 +364,7 @@ delCacheConfig (type = '') { let date = moment().subtract(7, 'days').format('YYYY-MM-DD') - CacheUtils.delWebSqlCacheConfig(date, type) + // CacheUtils.delWebSqlCacheConfig(date, type) CacheUtils.delIndexDBCacheConfig(date, type) } @@ -372,26 +373,27 @@ let date = moment().format('YYYY-MM-DD') let _data = data ? JSON.stringify(data) : '' - CacheUtils.writeCacheInWebSql([menuid, date, _data]) + // CacheUtils.writeCacheInWebSql([menuid, date, _data]) CacheUtils.writeCacheInIndexDB({menuid, CreateDate: date, LongParam: _data}) } getLCacheConfig (menuid) { return new Promise((resolve, reject) => { - if (window.GLOB.WebSql) { - CacheUtils.getWebSqlCacheConfig(menuid).then(res => { - if (res && res.LongParam) { - let _data = JSON.parse(res.LongParam) - if (_data.length === 0) { - resolve() - } else { - resolve(_data) - } - } else { - resolve() - } - }) - } else if (window.GLOB.IndexDB) { + // if (window.GLOB.WebSql) { + // CacheUtils.getWebSqlCacheConfig(menuid).then(res => { + // if (res && res.LongParam) { + // let _data = JSON.parse(res.LongParam) + // if (_data.length === 0) { + // resolve() + // } else { + // resolve(_data) + // } + // } else { + // resolve() + // } + // }) + // } + if (window.GLOB.IndexDB) { CacheUtils.getIndexDBCacheConfig(menuid).then(res => { if (res && res.LongParam) { let _data = JSON.parse(res.LongParam) @@ -414,7 +416,7 @@ * @description 鑾峰彇绯荤粺鐗堟湰淇℃伅锛屽惎鐢ㄦ垨鏇存柊websql */ getAppVersion (reload) { - if (!window.GLOB.WebSql && !window.GLOB.IndexDB) { + if (!window.GLOB.IndexDB) { return Promise.reject() } @@ -429,76 +431,79 @@ } } - if (window.GLOB.WebSql) { - return new Promise((resolve, reject) => { - CacheUtils.getWebSqlVersion().then(msg => { - let param = { - func: 's_get_app_version', - modifydate: msg.createDate - } + // if (window.GLOB.WebSql) { + // return new Promise((resolve, reject) => { + // CacheUtils.getWebSqlVersion().then(msg => { + // let param = { + // func: 's_get_app_version', + // modifydate: msg.createDate + // } - param.TypeCharOne = '' - param.typename = '' + // param.TypeCharOne = '' + // param.typename = '' - if (!msg.createDate && !msg.menuids) { - CacheUtils.updateWebSqlversion('1.00', curTime) - resolve() - return - } else if (!msg.createDate || reload === true) { - param.modifydate = curTime - param.menuids = window.btoa(msg.menuids) - } else if (msg.menuids) { - let d = localStorage.getItem(db) + // if (!msg.createDate && !msg.menuids) { + // CacheUtils.updateWebSqlversion('1.00', curTime) + // resolve() + // return + // } else if (!msg.createDate || reload === true) { + // param.modifydate = curTime + // param.menuids = window.btoa(msg.menuids) + // } else if (msg.menuids) { + // let d = localStorage.getItem(db) - if (!d || curTime.indexOf(d) === -1) { - param.menuids = window.btoa(msg.menuids) - } + // if (!d || curTime.indexOf(d) === -1) { + // param.menuids = window.btoa(msg.menuids) + // } - localStorage.setItem(db, curTime.substr(0, 10)) - } + // localStorage.setItem(db, curTime.substr(0, 10)) + // } - this.getSystemConfig(param).then(res => { - if (!res.status) { - reject() - return - } + // this.getSystemConfig(param).then(res => { + // if (!res.status) { + // reject() + // return + // } - let list = res.menu_data || [] + // let list = res.menu_data || [] - if (res.menu_del) { - list.push(...res.menu_del) - } + // if (res.menu_del) { + // list.push(...res.menu_del) + // } - list = list.map(mid => mid.menuid) + // list = list.map(mid => mid.menuid) - if (typeof(reload) === 'string' && !list.includes(reload)) { - list.push(reload) - } + // if (typeof(reload) === 'string' && !list.includes(reload)) { + // list.push(reload) + // } - if (list.length > 0) { - let clear = false - list.forEach(mid => { - if (systemMenuKeys.indexOf(mid) > -1) { - clear = true - } - }) - if (clear) { - list = '' - } else { - list = list.map(mid => `'${mid}'`).join(',') - } - CacheUtils.delWebSqlConfig(list) - } + // if (list.length > 0) { + // let clear = false + // let _appkey = window.GLOB.appkey.substr(-10) + // let reg = new RegExp(_appkey + '$', 'ig') - CacheUtils.updateWebSqlversion(res.app_version || '1.00', curTime) + // list.forEach(mid => { + // if (systemMenuKeys.indexOf(mid) > -1 || reg.test(mid)) { + // clear = true + // } + // }) + // if (clear) { + // list = '' + // } else { + // list = list.map(mid => `'${mid}'`).join(',') + // } + // CacheUtils.delWebSqlConfig(list) + // } + + // CacheUtils.updateWebSqlversion(res.app_version || '1.00', curTime) - resolve() - }) - }, () => { - reject() - }) - }) - } else { + // resolve() + // }) + // }, () => { + // reject() + // }) + // }) + // } else { return new Promise((resolve, reject) => { CacheUtils.getIndexDBVersion().then(msg => { let param = { @@ -546,8 +551,11 @@ if (list.length > 0) { let clear = false + let _appkey = window.GLOB.appkey.substr(-10) + let reg = new RegExp(_appkey + '$', 'ig') + list.forEach(mid => { - if (systemMenuKeys.indexOf(mid) > -1) { + if (systemMenuKeys.indexOf(mid) > -1 || reg.test(mid)) { clear = true } }) @@ -565,18 +573,18 @@ reject() }) }) - } + // } } /** * @description 鏇存柊绯荤粺鐗堟湰淇℃伅锛屾竻绌洪厤缃俊鎭� */ updateAppVersion () { - CacheUtils.delWebSqlConfig() - CacheUtils.updateWebSqlversion() + // CacheUtils.delWebSqlConfig() + // CacheUtils.updateWebSqlversion() CacheUtils.delIndexDBConfig() CacheUtils.updateIndexDBversion() - CacheUtils.clearFuncs() + // CacheUtils.clearFuncs() } /** @@ -586,8 +594,8 @@ if (window.GLOB.IndexDB) { let key = menuId + (sessionStorage.getItem('UserID') || '') return CacheUtils.delMenuIndexDBConfig(key) - } else { - return CacheUtils.delMenuWebSqlConfig(menuId) + // } else { + // return CacheUtils.delMenuWebSqlConfig(menuId) } } @@ -703,27 +711,28 @@ _param = JSON.stringify(_param) _param = md5(_param) - if (window.GLOB.WebSql) { - return new Promise(resolve => { - CacheUtils.getWebSqlMenuConfig(param.MenuID, param.userid).then(res => { - resolve(res) - }, () => { - param = this.encryptParam(param) - axios({ - url: `${url}${param.func ? '/' + param.func : ''}`, - method: 'post', - data: param - }).then(res => { - if (res.status && window.GLOB.WebSql) { - CacheUtils.writeInWebSql([param.MenuID, param.userid, res.open_edition, res.web_edition, res.LongParam, res.LongParamUser]) - } else if (res.status) { - window.GLOB.CacheMap.set(_param, res) - } - resolve(res) - }) - }) - }) - } else if (window.GLOB.IndexDB) { + // if (window.GLOB.WebSql) { + // return new Promise(resolve => { + // CacheUtils.getWebSqlMenuConfig(param.MenuID, param.userid).then(res => { + // resolve(res) + // }, () => { + // param = this.encryptParam(param) + // axios({ + // url: `${url}${param.func ? '/' + param.func : ''}`, + // method: 'post', + // data: param + // }).then(res => { + // if (res.status && window.GLOB.WebSql) { + // CacheUtils.writeInWebSql([param.MenuID, param.userid, res.open_edition, res.web_edition, res.LongParam, res.LongParamUser]) + // } else if (res.status) { + // window.GLOB.CacheMap.set(_param, res) + // } + // resolve(res) + // }) + // }) + // }) + // } + if (window.GLOB.IndexDB) { return new Promise(resolve => { CacheUtils.getIndexDBMenuConfig(param.MenuID, param.userid).then(res => { resolve(res) @@ -781,15 +790,16 @@ let _param = md5(JSON.stringify(param)) - if (window.GLOB.WebSql) { - return new Promise(resolve => { - CacheUtils.getWebSqlMenuConfig(param.MenuID, param.userid).then(res => { - resolve(res) - }, () => { - resolve({ ErrCode: 'S', ErrMesg: '', LongParam: '', message: '', status: false }) - }) - }) - } else if (window.GLOB.CacheMap.has(_param)) { + // if (window.GLOB.WebSql) { + // return new Promise(resolve => { + // CacheUtils.getWebSqlMenuConfig(param.MenuID, param.userid).then(res => { + // resolve(res) + // }, () => { + // resolve({ ErrCode: 'S', ErrMesg: '', LongParam: '', message: '', status: false }) + // }) + // }) + // } + if (window.GLOB.CacheMap.has(_param)) { return Promise.resolve(window.GLOB.CacheMap.get(_param)) } else { return Promise.resolve({ErrCode: 'S', ErrMesg: '', LongParam: '', message: '', status: false}) diff --git a/src/components/header/index.jsx b/src/components/header/index.jsx index cfbbe05..991636e 100644 --- a/src/components/header/index.jsx +++ b/src/components/header/index.jsx @@ -513,7 +513,7 @@ content: '閲嶆柊鍔犺浇搴旂敤淇℃伅', onOk() { return new Promise(resolve => { - if (!window.GLOB.WebSql && !window.GLOB.IndexDB) { + if (!window.GLOB.IndexDB) { notification.warning({ top: 92, message: '鏇存柊澶辫触锛岃鍒锋柊椤甸潰閲嶈瘯锛�', diff --git a/src/menu/components/card/balcony/index.jsx b/src/menu/components/card/balcony/index.jsx index d495918..7bd4ac0 100644 --- a/src/menu/components/card/balcony/index.jsx +++ b/src/menu/components/card/balcony/index.jsx @@ -275,6 +275,19 @@ } } + if (_card.wrap.position === 'fixed') { + if (_card.wrap.top && _card.wrap.bottom && _card.wrap.top.indexOf('vh') > -1 && _card.wrap.bottom.indexOf('vh') > -1) { + if (parseFloat(_card.wrap.top) + parseFloat(_card.wrap.bottom) >= 100) { + message.warning('鍏冪礌璺濅笂璺濅笅涔嬪拰瓒呭嚭100%锛屽彲鑳藉鑷村厓绱犳棤娉曟樉绀恒��') + } + } + if (_card.wrap.left && _card.wrap.right && _card.wrap.left.indexOf('vw') > -1 && _card.wrap.right.indexOf('vw') > -1) { + if (parseFloat(_card.wrap.left) + parseFloat(_card.wrap.right) >= 100) { + message.warning('鍏冪礌璺濆乏璺濆彸涔嬪拰瓒呭嚭100%锛屽彲鑳藉鑷村厓绱犳棤娉曟樉绀恒��') + } + } + } + this.updateComponent(_card) } diff --git a/src/menu/components/card/balcony/index.scss b/src/menu/components/card/balcony/index.scss index 3aaefbb..1108b2c 100644 --- a/src/menu/components/card/balcony/index.scss +++ b/src/menu/components/card/balcony/index.scss @@ -7,6 +7,7 @@ background-size: cover; min-height: 30px; display: flex; + overflow: hidden; .check-all { width: 70px; diff --git a/src/menu/components/card/cardcellcomponent/index.jsx b/src/menu/components/card/cardcellcomponent/index.jsx index 9459118..e35911f 100644 --- a/src/menu/components/card/cardcellcomponent/index.jsx +++ b/src/menu/components/card/cardcellcomponent/index.jsx @@ -706,6 +706,7 @@ return <VerifyCard card={card} config={cards} + side={side || ''} columns={side === 'sub' ? cards.subColumns : cards.columns} wrappedComponentRef={(inst) => this.verifyRef = inst} /> diff --git a/src/tabviews/custom/components/card/balcony/index.scss b/src/tabviews/custom/components/card/balcony/index.scss index 11921aa..d13e2fa 100644 --- a/src/tabviews/custom/components/card/balcony/index.scss +++ b/src/tabviews/custom/components/card/balcony/index.scss @@ -5,6 +5,7 @@ background-size: cover; position: relative; display: flex; + overflow: hidden; >.check-all { width: 70px; 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 3599a92..a752b91 100644 --- a/src/tabviews/custom/components/card/double-data-card/index.jsx +++ b/src/tabviews/custom/components/card/double-data-card/index.jsx @@ -183,22 +183,24 @@ Api.getLCacheConfig(config.uuid).then(res => { if (!res || this.loaded) return let _data = res.map((item, index) => { + item.children = [] + if (item[config.setting.subdata]) { let _children = item[config.setting.subdata] delete item[config.setting.subdata] - item.children = _children.map((cell, i) => { + _children.forEach((cell, i) => { cell.key = i cell.$$uuid = cell[config.setting.subKey] || '' cell.$$BID = item[config.setting.primaryKey] || '' cell.$$BData = {...item} cell.$Index = i + 1 + '' - return cell + if (cell.$$uuid) { + item.children.push(cell) + } }) - } else { - item.children = [] } item.key = index @@ -535,22 +537,24 @@ if (type === 'plus') { let _data = (this.state.data || []).concat(result.data || []) data = _data.map((item, index) => { + item.children = [] + if (item[config.setting.subdata]) { let _children = item[config.setting.subdata] delete item[config.setting.subdata] - - item.children = _children.map((cell, i) => { + + _children.forEach((cell, i) => { cell.key = i cell.$$uuid = cell[config.setting.subKey] || '' cell.$$BID = item[config.setting.primaryKey] || '' cell.$$BData = {...item} cell.$Index = i + 1 + '' - return cell + if (cell.$$uuid) { + item.children.push(cell) + } }) - } else { - item.children = [] } item.key = index @@ -569,24 +573,25 @@ }) } else { data = result.data.map((item, index) => { + item.children = [] + if (item[config.setting.subdata]) { let _children = item[config.setting.subdata] delete item[config.setting.subdata] - item.children = _children.map((cell, i) => { + _children.forEach((cell, i) => { cell.key = i cell.$$uuid = cell[config.setting.subKey] || '' cell.$$BID = item[config.setting.primaryKey] || '' cell.$$BData = {...item} cell.$Index = i + 1 + '' - return cell + if (cell.$$uuid) { + item.children.push(cell) + } }) - } else { - item.children = [] } - item.key = index item.$$uuid = item[config.setting.primaryKey] || '' item.$$BID = BID || '' @@ -669,22 +674,24 @@ try { data = data.map(item => { if (item[config.setting.primaryKey] === _data[config.setting.primaryKey]) { + _data.children = [] + if (_data[config.setting.subdata]) { let _children = _data[config.setting.subdata] delete _data[config.setting.subdata] - _data.children = _children.map((cell, i) => { + _children.forEach((cell, i) => { cell.key = i cell.$$uuid = cell[config.setting.subKey] || '' cell.$$BID = _data[config.setting.primaryKey] || '' cell.$$BData = {..._data} cell.$Index = i + 1 + '' - return cell + if (cell.$$uuid) { + _data.children.push(cell) + } }) - } else { - _data.children = [] } _data.key = item.key diff --git a/src/templates/sharecomponent/fieldscomponent/index.jsx b/src/templates/sharecomponent/fieldscomponent/index.jsx index 0aa6042..3066fac 100644 --- a/src/templates/sharecomponent/fieldscomponent/index.jsx +++ b/src/templates/sharecomponent/fieldscomponent/index.jsx @@ -263,9 +263,16 @@ const { type } = this.props const { fields } = this.state + let label = '鎵归噺娣诲姞' + if (type === 'search') { + label = '娣诲姞鎼滅储' + } else if (type === 'columns') { + label = '娣诲姞鏄剧ず鍒�' + } + return ( <div className="quickly-add"> - <Button type="primary" block onClick={this.queryField}>鎵归噺娣诲姞</Button> + <Button type="primary" block onClick={this.queryField}>{label}</Button> {/* 鏍规嵁瀛楁鍚嶆坊鍔犳樉绀哄垪鍙婃悳绱㈡潯浠� */} <Modal wrapClassName="model-table-fieldmanage-modal" diff --git a/src/templates/zshare/verifycard/index.jsx b/src/templates/zshare/verifycard/index.jsx index b2be305..0515210 100644 --- a/src/templates/zshare/verifycard/index.jsx +++ b/src/templates/zshare/verifycard/index.jsx @@ -789,6 +789,10 @@ let _updatesql = '' let _primaryKey = config.setting.primaryKey || 'id' + if (this.props.side === 'sub') { + _primaryKey = config.setting.subKey || 'id' + } + if (card.sqlType === 'insert' || card.sqlType === 'insertOrUpdate') { let keys = [] let values = [] diff --git a/src/utils/utils.js b/src/utils/utils.js index 4431f93..553ca2f 100644 --- a/src/utils/utils.js +++ b/src/utils/utils.js @@ -2253,24 +2253,24 @@ */ export function setGLOBFuncs () { window.GLOB.funcs = [] - if (!window.GLOB.WebSql && !window.GLOB.IndexDB) { + if (!window.GLOB.IndexDB) { return } - if (window.GLOB.WebSql) { - window.GLOB.WebSql.transaction(tx => { - tx.executeSql("SELECT * FROM FUNCS", [], (tx, results) => { - let rows = results.rows - if (!rows || rows.length === 0) return - for (let i = 0; i < rows.length; i++) { - window.GLOB.funcs.push({ - func_code: rows[i].func_code, - key_sql: window.decodeURIComponent(window.atob(rows[i].key_sql)) - }) - } - }) - }) - } else { + // if (window.GLOB.WebSql) { + // window.GLOB.WebSql.transaction(tx => { + // tx.executeSql("SELECT * FROM FUNCS", [], (tx, results) => { + // let rows = results.rows + // if (!rows || rows.length === 0) return + // for (let i = 0; i < rows.length; i++) { + // window.GLOB.funcs.push({ + // func_code: rows[i].func_code, + // key_sql: window.decodeURIComponent(window.atob(rows[i].key_sql)) + // }) + // } + // }) + // }) + // } else { let objectStore = window.GLOB.IndexDB.transaction('funcs').objectStore('funcs') objectStore.openCursor().onsuccess = (event) => { @@ -2284,7 +2284,7 @@ cursor.continue() } } - } + // } } /** diff --git a/src/views/design/header/index.jsx b/src/views/design/header/index.jsx index 39078cd..674453a 100644 --- a/src/views/design/header/index.jsx +++ b/src/views/design/header/index.jsx @@ -237,7 +237,7 @@ } setSystemFuncs = () => { - if (!window.GLOB.WebSql && !window.GLOB.IndexDB) { + if (!window.GLOB.IndexDB) { return } this.getfuncTime().then(res => { @@ -265,17 +265,17 @@ timestamp = moment(sys_datetime, 'YYYY-MM-DD HH:mm:ss').add(seconds, 'seconds').format('YYYY-MM-DD HH:mm:ss') } - if (window.GLOB.WebSql) { - window.GLOB.WebSql.transaction(tx => { - tx.executeSql('DELETE FROM FUNCS') + // if (window.GLOB.WebSql) { + // window.GLOB.WebSql.transaction(tx => { + // tx.executeSql('DELETE FROM FUNCS') - funcs.forEach(item => { - if (!item.key_sql) return - tx.executeSql('INSERT INTO FUNCS (func_code, key_sql) VALUES (?, ?)', [item.func_code, item.key_sql]) - }) - tx.executeSql(`UPDATE VERSIONS SET createDate='${timestamp}' where CDefine1='funcs'`) - }) - } else { + // funcs.forEach(item => { + // if (!item.key_sql) return + // tx.executeSql('INSERT INTO FUNCS (func_code, key_sql) VALUES (?, ?)', [item.func_code, item.key_sql]) + // }) + // tx.executeSql(`UPDATE VERSIONS SET createDate='${timestamp}' where CDefine1='funcs'`) + // }) + // } else { let objectStore = window.GLOB.IndexDB.transaction(['funcs'], 'readwrite').objectStore('funcs') objectStore.clear() @@ -288,28 +288,28 @@ let funcStore = window.GLOB.IndexDB.transaction(['version'], 'readwrite').objectStore('version') funcStore.put({id: 'funcs', version: '1.0', createDate: timestamp}) - } + // } } getfuncTime = () => { return new Promise((resolve, reject) => { - if (window.GLOB.WebSql) { - window.GLOB.WebSql.transaction(tx => { - tx.executeSql("SELECT * FROM VERSIONS where CDefine1='funcs'", [], (tx, results) => { - let rows = results.rows - if (rows.length === 0) { - tx.executeSql('DELETE FROM FUNCS') - tx.executeSql('INSERT INTO VERSIONS (version, createDate, CDefine1) VALUES (?, ?, ?)', ['1.0', '1970-01-01 14:59:09.000', 'funcs']) - resolve({createDate: '1970-01-01 14:59:09.000'}) - } else { - resolve(rows[0]) - } - }, (tx, results) => { - reject() - console.warn(results) - }) - }) - } else { + // if (window.GLOB.WebSql) { + // window.GLOB.WebSql.transaction(tx => { + // tx.executeSql("SELECT * FROM VERSIONS where CDefine1='funcs'", [], (tx, results) => { + // let rows = results.rows + // if (rows.length === 0) { + // tx.executeSql('DELETE FROM FUNCS') + // tx.executeSql('INSERT INTO VERSIONS (version, createDate, CDefine1) VALUES (?, ?, ?)', ['1.0', '1970-01-01 14:59:09.000', 'funcs']) + // resolve({createDate: '1970-01-01 14:59:09.000'}) + // } else { + // resolve(rows[0]) + // } + // }, (tx, results) => { + // reject() + // console.warn(results) + // }) + // }) + // } else { let objectStore = window.GLOB.IndexDB.transaction(['version'], 'readwrite').objectStore('version') let request = objectStore.get('funcs') @@ -332,7 +332,7 @@ } } } - } + // } }) } diff --git a/src/views/interface/api/index.js b/src/views/interface/api/index.js index 59f4941..37b374b 100644 --- a/src/views/interface/api/index.js +++ b/src/views/interface/api/index.js @@ -1,25 +1,30 @@ import axios from 'axios' import md5 from 'md5' import jsSHA from 'jssha' -import { notification } from 'antd' -window.GLOB.WebSql = null +window.GLOB.IndexDB = null -if (window.openDatabase) { - let service = window.GLOB.service ? '-' + window.GLOB.service.replace('/', '') : '' +let service = window.GLOB.service ? '-' + window.GLOB.service.replace('/', '') : '' +let db = `mk_inter${service}` + +if (window.indexedDB) { try { - window.GLOB.WebSql = openDatabase(`mkdb${service}`, '1', 'mk-pc-database', 50 * 1024 * 1024) - window.GLOB.WebSql.transaction(tx => { - tx.executeSql('CREATE TABLE IF NOT EXISTS INTERFACES (uuid varchar(50), createDate varchar(50), method varchar(50), interface text, params text, headers text, active varchar(50), raw text, formData text, CDefine1 varchar(50), CDefine2 varchar(50), CDefine3 varchar(50), CDefine4 varchar(50), CDefine5 text)', [], () => { - - }, () => { - // eslint-disable-next-line - throw 'CREATE TABLE ERROR' - }) - }) + let request = window.indexedDB.open(db, 1) + request.onerror = () => { + console.warn('IndexedDB 鍒濆鍖栧け璐ワ紒') + } + request.onsuccess = () => { + window.GLOB.IndexDB = request.result + } + request.onupgradeneeded = (event) => { + window.GLOB.IndexDB = event.target.result + if (!window.GLOB.IndexDB.objectStoreNames.contains('interfaces')) { + window.GLOB.IndexDB.createObjectStore('interfaces', { keyPath: 'id' }) + } + } } catch (e) { - console.warn('WebSql 鍒濆鍖栧け璐ワ紒') - window.GLOB.WebSql = null + console.warn('IndexedDB 鍒濆鍖栧け璐ワ紝鍘嗗彶璁板綍灏嗘棤娉曟煡璇㈡垨淇敼锛�') + window.GLOB.IndexDB = null } } @@ -102,73 +107,46 @@ return axios(config) } - writeInWebSql (data) { - if (!window.GLOB.WebSql) { - notification.warning({ top: 92, message: 'WebSql寮�鍚け璐ワ紒', duration: 5 }) - return - } - return new Promise((resolve, reject) => { - window.GLOB.WebSql.transaction(tx => { - tx.executeSql(`INSERT INTO INTERFACES (uuid, createDate, method, interface, params, headers, active, raw, formData) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`, data, (tx, results) => { - resolve(results) - }, () => { - resolve() - }) - }) - }) + writeInIndexDB (data) { + if (!window.GLOB.IndexDB) return + + window.GLOB.IndexDB.transaction(['interfaces'], 'readwrite').objectStore('interfaces').add(data) } getInterfaces () { - if (!window.GLOB.WebSql) { - notification.warning({ top: 92, message: 'WebSql寮�鍚け璐ワ紒', duration: 5 }) - return - } + if (!window.GLOB.IndexDB) return Promise.resolve() + return new Promise((resolve, reject) => { - window.GLOB.WebSql.transaction(tx => { - tx.executeSql(`SELECT * FROM INTERFACES`, [], (tx, results) => { - // let paramItem = results.rows[0] - resolve(results) - }, () => { - window.GLOB.WebSql = null - reject() - }) - }) + let request = window.GLOB.IndexDB.transaction(['interfaces']).objectStore('interfaces').openCursor() + let list = [] + + request.onsuccess = (e) => { + let cursor = e.target.result + if (cursor) { + if (cursor.value) { + list.push(cursor.value) + } + cursor.continue() + } else { + resolve(list) + } + } }) } - delInterface (uuid) { - if (!window.GLOB.WebSql) { - notification.warning({ top: 92, message: 'WebSql寮�鍚け璐ワ紒', duration: 5 }) - return - } - return new Promise((resolve, reject) => { - window.GLOB.WebSql.transaction(tx => { - tx.executeSql(`DELETE FROM INTERFACES where uuid = '${uuid}'`, [], (tx, results) => { - resolve(results) - }, () => { - resolve() - }) - }) - }) + delInterface (id) { + if (!window.GLOB.IndexDB) return + + window.GLOB.IndexDB.transaction(['interfaces'], 'readwrite').objectStore('interfaces').delete(id) } /** * @description 娓呯┖鎺ュ彛璋冪敤璁板綍 */ clearInterfaces () { - if (!window.GLOB.WebSql) { - notification.warning({ top: 92, message: 'WebSql寮�鍚け璐ワ紒', duration: 5 }) - return - } - return new Promise((resolve, reject) => { - window.GLOB.WebSql.transaction(tx => { - tx.executeSql(`DELETE FROM INTERFACES`, [], (tx, results) => { - resolve(results) - }, () => { - resolve() - }) - }) - }) + if (!window.GLOB.IndexDB) return + + window.GLOB.IndexDB.transaction(['interfaces'], 'readwrite').objectStore('interfaces').clear() } } diff --git a/src/views/interface/history/index.jsx b/src/views/interface/history/index.jsx index 0db24fe..c9c9143 100644 --- a/src/views/interface/history/index.jsx +++ b/src/views/interface/history/index.jsx @@ -22,69 +22,13 @@ componentDidMount() { MKEmitter.addListener('insertInterface', this.insertInterface) setTimeout(() => { - Api.getInterfaces().then(res => { - if (!res || !res.rows) return - - let rows = [...res.rows] - rows.sort((a,b) => { - return a.createDate < b.createDate ? 1 : -1 - }) - - let list = [] - let item = null - - rows.forEach(m => { - let date = m.createDate.substring(0, 10) - - if (m.params) { - try { - m.params = JSON.parse(m.params) - } catch (e) { - m.params = [] - } - } else { - m.params = [] - } - - if (m.headers) { - try { - m.headers = JSON.parse(m.headers) - } catch (e) { - m.headers = [] - } - } else { - m.headers = [] - } - - if (m.formData) { - try { - m.formData = JSON.parse(m.formData) - } catch (e) { - m.formData = [] - } - } else { - m.formData = [] - } - - if (item && item.date !== date) { - list.push(item) - item = null - } - - if (!item) { - item = {date, sublist: []} - item.sublist.push(m) - } else if (item && item.date === date) { - item.sublist.push(m) - } - }) - - if (item) { - list.push(item) - } - - this.setState({list, historys: fromJS(list).toJS()}) - }) + if (window.GLOB.IndexDB) { + this.getHistory() + } else { + setTimeout(() => { + this.getHistory() + }, 1000) + } }, 200) } @@ -103,91 +47,136 @@ confirm({ content: 'Are you sure you want to clear all your history requests?', onOk() { - Api.clearInterfaces().then(res => { - if (res && res.rows.length === 0) { - _this.setState({list: [], historys: []}) - Modal.success({ - title: '娓呴櫎鎴愬姛銆�' - }) - } else { - Modal.error({ - title: '娓呴櫎澶辫触锛佽鍒锋柊閲嶈瘯銆�' - }) - } - }) + Api.clearInterfaces() + + _this.setState({list: [], historys: []}) }, onCancel() {} }) } - delete = (m) => { - const { searchKey } = this.state - Api.delInterface(m.uuid).then(res => { - if (res) { - let list = this.state.list.filter(item => { - item.sublist = item.sublist.filter(cell => cell.uuid !== m.uuid) - - return item.sublist.length > 0 - }) + getHistory = () => { + Api.getInterfaces().then(res => { + if (!res) return - let historys = fromJS(list).toJS() - if (searchKey) { - historys = historys.filter(item => { - item.sublist = item.sublist.filter(cell => cell.interface.indexOf(searchKey) > -1) - - return item.sublist.length > 0 - }) + res.sort((a,b) => { + return a.createDate < b.createDate ? 1 : -1 + }) + + let list = [] + let item = null + + res.forEach(m => { + let date = m.createDate.substring(0, 10) + + if (m.params) { + try { + m.params = JSON.parse(m.params) + } catch (e) { + m.params = [] + } + } else { + m.params = [] } - this.setState({list, historys}) - } else { - Modal.error({ - title: '鍒犻櫎澶辫触锛佽鍒锋柊閲嶈瘯銆�' - }) + if (m.headers) { + try { + m.headers = JSON.parse(m.headers) + } catch (e) { + m.headers = [] + } + } else { + m.headers = [] + } + + if (m.formData) { + try { + m.formData = JSON.parse(m.formData) + } catch (e) { + m.formData = [] + } + } else { + m.formData = [] + } + + if (item && item.date !== date) { + list.push(item) + item = null + } + + if (!item) { + item = {date, sublist: []} + item.sublist.push(m) + } else if (item && item.date === date) { + item.sublist.push(m) + } + }) + + if (item) { + list.push(item) } + + this.setState({list, historys: fromJS(list).toJS()}) }) } + delete = (m) => { + const { searchKey } = this.state + + Api.delInterface(m.id) + + let list = this.state.list.filter(item => { + item.sublist = item.sublist.filter(cell => cell.id !== m.id) + + return item.sublist.length > 0 + }) + + let historys = fromJS(list).toJS() + if (searchKey) { + historys = historys.filter(item => { + item.sublist = item.sublist.filter(cell => cell.interface.indexOf(searchKey) > -1) + + return item.sublist.length > 0 + }) + } + + this.setState({list, historys}) + } + insertInterface = (item) => { - item.uuid = Utils.getuuid() + item.id = Utils.getuuid() item.createDate = moment().format('YYYY-MM-DD HH:mm:ss') - Api.writeInWebSql([item.uuid, item.createDate, item.method, item.interface, JSON.stringify(item.params), JSON.stringify(item.headers), item.active, item.raw, JSON.stringify(item.formData)]).then(res => { - if (res) { - let list = fromJS(this.state.list).toJS() + Api.writeInIndexDB(item) - if (list[0]) { - if (list[0].date === item.createDate.substring(0, 10)) { - list[0].sublist.unshift(item) - } else { - list.unshift({ - date: item.createDate.substring(0, 10), - sublist: [item] - }) - } - } else { - list.push({ - date: item.createDate.substring(0, 10), - sublist: [item] - }) - } + let list = fromJS(this.state.list).toJS() - let historys = fromJS(list).toJS() - if (this.state.searchKey) { - historys = historys.filter(item => { - item.sublist = item.sublist.filter(cell => cell.interface.indexOf(this.state.searchKey) > -1) - - return item.sublist.length > 0 - }) - } - - this.setState({ list, historys }) + if (list[0]) { + if (list[0].date === item.createDate.substring(0, 10)) { + list[0].sublist.unshift(item) } else { - Modal.error({ - title: '娣诲姞澶辫触锛佽鍒锋柊閲嶈瘯銆�' + list.unshift({ + date: item.createDate.substring(0, 10), + sublist: [item] }) } - }) + } else { + list.push({ + date: item.createDate.substring(0, 10), + sublist: [item] + }) + } + + let historys = fromJS(list).toJS() + if (this.state.searchKey) { + historys = historys.filter(item => { + item.sublist = item.sublist.filter(cell => cell.interface.indexOf(this.state.searchKey) > -1) + + return item.sublist.length > 0 + }) + } + + this.setState({ list, historys }) } use = (m) => { @@ -204,7 +193,7 @@ method: 'POST', params: [], raw: "{\n \"UserName\":\"******\",\n \"Password\":\"******\",\n \"systemType\":\"local\",\n \"Type\":\"鍏挜\",\n \"privatekey\":\"绉侀挜\",\n \"timestamp\":\"" + moment().format('YYYY-MM-DD HH:mm:ss') + "\",\n \"appkey\":\"" + window.GLOB.appkey + "\"\n}", - uuid: 'dologon' + id: 'dologon' } if (window.GLOB.mainSystemApi) { @@ -223,7 +212,7 @@ method: 'POST', params: [], raw: "{\n \"func\":\"******\",\n \"LoginUID\":\"" + (sessionStorage.getItem('LoginUID') || "******") + "\",\n \"UserID\":\"" + (sessionStorage.getItem('UserID') || "******") + "\",\n \"nonc\":\"" + Utils.getguid() + "\",\n \"t\":" + parseInt(new Date().getTime() / 1000) + "\n}", - uuid: 'dologon' + id: 'dologon' } MKEmitter.emit('useInterface', m) } @@ -258,7 +247,7 @@ <div className="list-line" key={index}> <div className="line-title">{item.date}</div> {item.sublist.map(m => ( - <div className="line-item" key={m.uuid}> + <div className="line-item" key={m.id}> <div className="method">POST</div> <div className="inter">{m.interface}</div> <div className="action"> diff --git a/src/views/interface/workspace/index.jsx b/src/views/interface/workspace/index.jsx index 58c0b71..a750938 100644 --- a/src/views/interface/workspace/index.jsx +++ b/src/views/interface/workspace/index.jsx @@ -12,7 +12,7 @@ class WorkSpace extends Component { state = { tabviews: [{ - uuid: Utils.getuuid(), + id: Utils.getuuid(), createDate: '', method: 'POST', interface: '', @@ -39,24 +39,24 @@ } useInterface = (item) => { - item.uuid = Utils.getuuid() + item.id = Utils.getuuid() this.setState({tabviews: [...this.state.tabviews, item]}, () => { - let div = document.getElementById(item.uuid) + let div = document.getElementById(item.id) div && div.click && div.click() }) } handleTabview = (view) => { let tabviews = fromJS(this.state.tabviews).toJS() - tabviews = tabviews.filter(item => item.uuid !== view.uuid) + tabviews = tabviews.filter(item => item.id !== view.id) this.setState({tabviews}, () => { if (tabviews.length > 0) return setTimeout(() => { this.setState({tabviews: [{ - uuid: Utils.getuuid(), + id: Utils.getuuid(), createDate: '', method: 'POST', interface: '', @@ -72,7 +72,7 @@ handleAdd = () => { let item = { - uuid: Utils.getuuid(), + id: Utils.getuuid(), createDate: '', method: 'POST', interface: '', @@ -83,7 +83,7 @@ formData: [] } this.setState({tabviews: [...this.state.tabviews, item]}, () => { - let div = document.getElementById(item.uuid) + let div = document.getElementById(item.id) div && div.click && div.click() }) } @@ -99,7 +99,7 @@ return ( <Tabs.TabPane tab={ - <span className="control" id={view.uuid || ''}> + <span className="control" id={view.id || ''}> <span className="method"> {view.method || 'POST'} </span> @@ -109,7 +109,7 @@ <CloseOutlined onClick={() => this.handleTabview(view)}/> </span> } - key={view.uuid} + key={view.id} > <Request config={view} /> </Tabs.TabPane> -- Gitblit v1.8.0