| | |
| | | * @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))', [], () => { |
| | | |
| | | // }, () => { |
| | | // // 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 CACHES (menuid varchar(50), CreateDate varchar(50), LongParam text, CDefine1 varchar(50), CDefine2 varchar(50))', [], () => { |
| | | |
| | | // }, () => { |
| | | // // 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))', [], () => { |
| | | |
| | | // }, () => { |
| | | // // 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) |
| | | // } |
| | | // } |
| | | // } |
| | | |
| | | // /** |
| | | // * @description 清空函数 |
| | | // */ |
| | | // static clearFuncs () { |
| | | // if (window.GLOB.systemType !== '') return |
| | | |
| | | // 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() |
| | | |
| | | // window.GLOB.IndexDB.transaction(['version'], 'readwrite').objectStore('version').delete('funcs') |
| | | // } |
| | | // } |
| | | |
| | | // /** |
| | | // * @description 获取websql中保存信息版本 |
| | | // */ |
| | | // static getWebSqlVersion () { |
| | | // if (!window.GLOB.WebSql) { |
| | | // return Promise.reject() |
| | | // } |
| | | |
| | | // 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 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] |
| | | |
| | | // if (result.createDate && !/^\d{4}-\d{2}-\d{2}/.test(result.createDate)) { |
| | | // result.createDate = '' |
| | | // } |
| | | |
| | | // result.menuids = res[1].join(';') |
| | | |
| | | // resolve(result) |
| | | // }) |
| | | // }) |
| | | // } |
| | | |
| | | // /** |
| | | // * @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) |
| | | // }) |
| | | // }) |
| | | // } |
| | | // } |
| | | |
| | | // /** |
| | | // * @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 |
| | | |
| | | // 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) |
| | | // }) |
| | | // } |
| | | // }) |
| | | // } |
| | | |
| | | // /** |
| | | // * @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 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 将缓存数据写入websql |
| | | // */ |
| | | // 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中超过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 |
| | | */ |
| | |
| | | .get('mksoft') |
| | | |
| | | request.onerror = (event) => { |
| | | window.GLOB.IndexDB = null |
| | | console.warn(event) |
| | | resolve({version: '', createDate: ''}) |
| | | } |
| | |
| | | let menus = [] |
| | | |
| | | request.onerror = () => { |
| | | window.GLOB.IndexDB = null |
| | | resolve(menus) |
| | | } |
| | | |
| | |
| | | if (!window.GLOB.IndexDB || !version) return |
| | | |
| | | if (!version) { |
| | | let request = window.GLOB.IndexDB.transaction(['configs'], 'readwrite').objectStore('configs').delete('mksoft') |
| | | |
| | | request.onerror = () => { |
| | | window.GLOB.IndexDB = null |
| | | } |
| | | window.GLOB.IndexDB.transaction(['configs'], 'readwrite').objectStore('configs').delete('mksoft') |
| | | } else { |
| | | version.id = 'mksoft' |
| | | |
| | | let objectStore = window.GLOB.IndexDB.transaction(['version'], 'readwrite').objectStore('version') |
| | | let request = objectStore.get('mksoft') |
| | | |
| | | request.onerror = () => { |
| | | window.GLOB.IndexDB = null |
| | | } |
| | | |
| | | request.onsuccess = () => { |
| | | if (request.result) { |
| | | let put = objectStore.put(version) |
| | | |
| | | put.onerror = () => { |
| | | window.GLOB.IndexDB = null |
| | | } |
| | | objectStore.put(version) |
| | | } else { |
| | | let add = objectStore.add(version) |
| | | |
| | | add.onerror = () => { |
| | | window.GLOB.IndexDB = null |
| | | } |
| | | objectStore.add(version) |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * @description 删除IndexedDB中保存的配置信息 |
| | | */ |
| | | static delMenuIndexDBConfig (key) { |
| | | if (!window.GLOB.IndexDB || !key) return Promise.resolve() |
| | | |
| | | return new Promise(resolve => { |
| | | let request = window.GLOB.IndexDB.transaction(['configs'], 'readwrite') |
| | | .objectStore('configs') |
| | | .delete(key) |
| | | |
| | | request.onsuccess = () => { |
| | | resolve() |
| | | } |
| | | request.onerror = () => { |
| | | window.GLOB.IndexDB = null |
| | | resolve() |
| | | } |
| | | }) |
| | | } |
| | | |
| | | /** |
| | |
| | | if (!window.GLOB.IndexDB) return |
| | | |
| | | if (!menuids) { |
| | | let request = window.GLOB.IndexDB.transaction(['configs'], 'readwrite').objectStore('configs').clear() |
| | | |
| | | request.onerror = () => { |
| | | window.GLOB.IndexDB = null |
| | | } |
| | | window.GLOB.IndexDB.transaction(['configs'], 'readwrite').objectStore('configs').clear() |
| | | } else { |
| | | let request = window.GLOB.IndexDB.transaction(['configs'], 'readwrite').objectStore('configs').openCursor() |
| | | |
| | | request.onerror = () => { |
| | | window.GLOB.IndexDB = null |
| | | } |
| | | |
| | | request.onsuccess = (e) => { |
| | | let cursor = e.target.result |
| | |
| | | /** |
| | | * @description 获取IndexedDB中的配置信息 |
| | | */ |
| | | static getIndexDBMenuConfig (MenuID, userid) { |
| | | if (!window.GLOB.IndexDB || !MenuID || !userid) return Promise.reject() |
| | | let key = MenuID + userid |
| | | static getIndexDBMenuConfig (key) { |
| | | if (!window.GLOB.IndexDB || !key) return Promise.reject() |
| | | |
| | | return new Promise((resolve, reject) => { |
| | | let request = window.GLOB.IndexDB.transaction(['configs']).objectStore('configs').get(key) |
| | | |
| | | request.onerror = () => { |
| | | window.GLOB.IndexDB = null |
| | | reject() |
| | | } |
| | | |
| | |
| | | import CacheUtils from './cacheutils' |
| | | import options from '@/store/options.js' |
| | | |
| | | // window.GLOB.WebSql = null |
| | | window.GLOB.IndexDB = null |
| | | window.GLOB.OuterToken = {} |
| | | |
| | | 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.indexedDB) { |
| | | CacheUtils.openIndexDB(db) |
| | | } |
| | |
| | | |
| | | delCacheConfig (type = '') { |
| | | let date = moment().subtract(7, 'days').format('YYYY-MM-DD') |
| | | // CacheUtils.delWebSqlCacheConfig(date, type) |
| | | CacheUtils.delIndexDBCacheConfig(date, type) |
| | | } |
| | | |
| | |
| | | let date = moment().format('YYYY-MM-DD') |
| | | let _data = data ? JSON.stringify(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() |
| | | // } |
| | | // }) |
| | | // } |
| | | if (window.GLOB.IndexDB) { |
| | | CacheUtils.getIndexDBCacheConfig(menuid).then(res => { |
| | | if (res && res.LongParam) { |
| | |
| | | } |
| | | |
| | | /** |
| | | * @description 获取系统版本信息,启用或更新websql |
| | | * @description 获取系统版本信息 |
| | | */ |
| | | getAppVersion (reload) { |
| | | if (!window.GLOB.IndexDB) { |
| | |
| | | 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) => { |
| | | // CacheUtils.getWebSqlVersion().then(msg => { |
| | | // let param = { |
| | | // func: 's_get_app_version', |
| | | // modifydate: msg.createDate |
| | | // } |
| | | return new Promise((resolve, reject) => { |
| | | CacheUtils.getIndexDBVersion().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.updateIndexDBversion({version: '1.00', createDate: 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) |
| | | // } |
| | | |
| | | // localStorage.setItem(db, curTime.substr(0, 10)) |
| | | // } |
| | | |
| | | // this.getSystemConfig(param).then(res => { |
| | | // if (!res.status) { |
| | | // reject() |
| | | // return |
| | | // } |
| | | |
| | | // let list = res.menu_data || [] |
| | | |
| | | // if (res.menu_del) { |
| | | // list.push(...res.menu_del) |
| | | // } |
| | | |
| | | // list = list.map(mid => mid.menuid) |
| | | |
| | | // if (typeof(reload) === 'string' && !list.includes(reload)) { |
| | | // list.push(reload) |
| | | // } |
| | | |
| | | // if (list.length > 0) { |
| | | // let clear = false |
| | | // let _appkey = window.GLOB.appkey.substr(-10) |
| | | // let reg = new RegExp(_appkey + '$', 'ig') |
| | | |
| | | // list.forEach(mid => { |
| | | // if (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 { |
| | | return new Promise((resolve, reject) => { |
| | | CacheUtils.getIndexDBVersion().then(msg => { |
| | | let param = { |
| | | func: 's_get_app_version', |
| | | modifydate: msg.createDate |
| | | } |
| | | |
| | | param.TypeCharOne = '' |
| | | param.typename = '' |
| | | |
| | | if (!msg.createDate && !msg.menuids) { |
| | | CacheUtils.updateIndexDBversion({version: '1.00', createDate: curTime}) |
| | | resolve() |
| | | return |
| | | } else if (!msg.createDate || reload === true) { |
| | | param.modifydate = curTime |
| | | if (!d || curTime.indexOf(d) === -1) { |
| | | 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) |
| | | } |
| | | |
| | | localStorage.setItem(db, curTime.substr(0, 10)) |
| | | } |
| | | |
| | | this.getSystemConfig(param).then(res => { |
| | | if (!res.status) { |
| | | reject() |
| | | return |
| | | } |
| | | |
| | | let list = res.menu_data || [] |
| | | localStorage.setItem(db, curTime.substr(0, 10)) |
| | | } |
| | | |
| | | if (res.menu_del) { |
| | | list.push(...res.menu_del) |
| | | } |
| | | this.getSystemConfig(param).then(res => { |
| | | if (!res.status) { |
| | | reject() |
| | | return |
| | | } |
| | | |
| | | list = list.map(mid => mid.menuid) |
| | | let list = res.menu_data || [] |
| | | |
| | | if (typeof(reload) === 'string' && !list.includes(reload)) { |
| | | list.push(reload) |
| | | } |
| | | if (res.menu_del) { |
| | | list.push(...res.menu_del) |
| | | } |
| | | |
| | | if (list.length > 0) { |
| | | let clear = false |
| | | let _appkey = window.GLOB.appkey.substr(-10) |
| | | let reg = new RegExp(_appkey + '$', 'ig') |
| | | list = list.map(mid => mid.menuid) |
| | | |
| | | list.forEach(mid => { |
| | | if (reg.test(mid)) { |
| | | clear = true |
| | | } |
| | | }) |
| | | if (clear) { |
| | | list = '' |
| | | if (typeof(reload) === 'string' && !list.includes(reload)) { |
| | | list.push(reload) |
| | | } |
| | | |
| | | if (list.length > 0) { |
| | | let clear = false |
| | | let _appkey = window.GLOB.appkey.substr(-10) |
| | | let reg = new RegExp(_appkey + '$', 'ig') |
| | | |
| | | list.forEach(mid => { |
| | | if (reg.test(mid)) { |
| | | clear = true |
| | | } |
| | | CacheUtils.delIndexDBConfig(list) |
| | | }) |
| | | if (clear) { |
| | | list = '' |
| | | } |
| | | CacheUtils.delIndexDBConfig(list) |
| | | } |
| | | |
| | | CacheUtils.updateIndexDBversion({version: res.app_version || '1.00', createDate: curTime}) |
| | | |
| | | resolve() |
| | | }) |
| | | }, () => { |
| | | reject() |
| | | CacheUtils.updateIndexDBversion({version: res.app_version || '1.00', createDate: curTime}) |
| | | |
| | | resolve() |
| | | }) |
| | | }, () => { |
| | | reject() |
| | | }) |
| | | // } |
| | | }) |
| | | } |
| | | |
| | | /** |
| | | * @description 更新系统版本信息,清空配置信息 |
| | | */ |
| | | updateAppVersion () { |
| | | // CacheUtils.delWebSqlConfig() |
| | | // CacheUtils.updateWebSqlversion() |
| | | CacheUtils.delIndexDBConfig() |
| | | CacheUtils.updateIndexDBversion() |
| | | // CacheUtils.clearFuncs() |
| | |
| | | * @description 删除某个菜单配置信息 |
| | | */ |
| | | deleteMenuStorage (menuId) { |
| | | if (window.GLOB.IndexDB) { |
| | | let key = menuId + (sessionStorage.getItem('UserID') || '') |
| | | return CacheUtils.delMenuIndexDBConfig(key) |
| | | // } else { |
| | | // return CacheUtils.delMenuWebSqlConfig(menuId) |
| | | } |
| | | CacheUtils.delIndexDBConfig(menuId) |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | |
| | | /** |
| | | * @description 获取系统配置,取值优先等级websql、缓存、服务器 |
| | | * @description 获取系统配置,取值优先等级IndexDB、缓存、服务器 |
| | | */ |
| | | getCacheConfig (param) { |
| | | param.userid = sessionStorage.getItem('UserID') || '' |
| | |
| | | } |
| | | } |
| | | |
| | | let _param = JSON.parse(JSON.stringify(param)) // 缓存校验,去除时间和加密字符 |
| | | delete _param.timestamp |
| | | delete _param.secretkey |
| | | delete _param.open_key |
| | | _param = JSON.stringify(_param) |
| | | _param = md5(_param) |
| | | let key = md5(param.MenuID + param.userid) |
| | | |
| | | // 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 => { |
| | | CacheUtils.getIndexDBMenuConfig(key).then(res => { |
| | | resolve(res) |
| | | }, () => { |
| | | param = this.encryptParam(param) |
| | |
| | | ...res, |
| | | userid: param.userid, |
| | | menuid: param.MenuID, |
| | | id: param.MenuID + param.userid |
| | | id: key |
| | | } |
| | | CacheUtils.writeInIndexDB(msg) |
| | | } else if (res.status) { |
| | | window.GLOB.CacheMap.set(_param, res) |
| | | window.GLOB.CacheMap.set(key, res) |
| | | } |
| | | resolve(res) |
| | | }) |
| | | }) |
| | | }) |
| | | } else if (window.GLOB.CacheMap.has(_param)) { |
| | | return Promise.resolve(window.GLOB.CacheMap.get(_param)) |
| | | } else if (window.GLOB.CacheMap.has(key)) { |
| | | return Promise.resolve(window.GLOB.CacheMap.get(key)) |
| | | } else { |
| | | param = this.encryptParam(param) |
| | | |
| | |
| | | data: param |
| | | }).then(res => { |
| | | if (res.status) { |
| | | window.GLOB.CacheMap.set(_param, res) |
| | | window.GLOB.CacheMap.set(key, res) |
| | | } |
| | | resolve(res) |
| | | }) |
| | |
| | | param.appkey = window.GLOB.appkey || '' |
| | | |
| | | 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 }) |
| | | // }) |
| | | // }) |
| | | // } |
| | | |
| | | if (window.GLOB.CacheMap.has(_param)) { |
| | | return Promise.resolve(window.GLOB.CacheMap.get(_param)) |
| | | } else { |
| | |
| | | } |
| | | |
| | | /** |
| | | * @description 导出Excel,后台生成文件 |
| | | */ |
| | | // getExcelOut (param, name) { |
| | | // param.userid = sessionStorage.getItem('UserID') |
| | | // param.lang = sessionStorage.getItem('lang') || '' |
| | | // param.SessionUid = localStorage.getItem('SessionUid') || '' |
| | | // param.LoginUID = sessionStorage.getItem('LoginUID') || '' |
| | | // param.appkey = window.GLOB.appkey || '' |
| | | |
| | | // return new Promise(resolve => { |
| | | // axios({ |
| | | // url: '/webapi/doexcel', |
| | | // responseType: 'blob', |
| | | // method: 'post', |
| | | // data: param |
| | | // }).then(res => { |
| | | // try { |
| | | // const blob = new Blob([res]) |
| | | |
| | | // if (res.type === 'application/json') { |
| | | // const reader = new FileReader() |
| | | // reader.onload = e => resolve(JSON.parse(e.target.result)) |
| | | // reader.readAsText(blob) |
| | | // } else { |
| | | // if ('download' in document.createElement('a')) { // 非IE下载 |
| | | // const elink = document.createElement('a') |
| | | // elink.download = name |
| | | // elink.style.display = 'none' |
| | | // elink.href = URL.createObjectURL(blob) |
| | | // document.body.appendChild(elink) |
| | | // elink.click() |
| | | // URL.revokeObjectURL(elink.href) // 释放URL 对象 |
| | | // document.body.removeChild(elink) |
| | | // } else { // IE10+下载 |
| | | // navigator.msSaveBlob(blob, name) |
| | | // } |
| | | // resolve() |
| | | // } |
| | | // } catch (e) { |
| | | // resolve({ |
| | | // ErrCode: 'E', |
| | | // ErrMesg: '文件解析错误', |
| | | // message: '', |
| | | // status: false |
| | | // }) |
| | | // } |
| | | // }) |
| | | // }) |
| | | // } |
| | | |
| | | /** |
| | | * @description 上传base64 |
| | | * @param {String} base64 base64图片编码 |
| | | */ |
| | |
| | | data: data |
| | | }) |
| | | } |
| | | |
| | | // /** |
| | | // * @description 文件上传 |
| | | // */ |
| | | // getFileUpload (param) { |
| | | // return axios({ |
| | | // url: '/zh-CN/Home/Upload', |
| | | // method: 'post', |
| | | // data: param |
| | | // }) |
| | | // } |
| | | } |
| | | |
| | | export default new Api() |
| | |
| | | _formfields = [..._formfields, ...group.sublist] |
| | | }) |
| | | |
| | | _inputfields = _formfields.filter(item => ['text', 'number', 'textarea', 'color'].includes(item.type) && card.field !== item.field) |
| | | _tabfields = _formfields.filter(item => card.field !== item.field && item.hidden !== 'true' && ['text', 'number', 'select', 'link'].includes(item.type)) |
| | | |
| | | if (card.linkSubField && card.linkSubField.length > 0) { |
| | | let fields = _inputfields.map(item => item.field) |
| | | card.linkSubField = card.linkSubField.filter(item => fields.includes(item)) |
| | | } |
| | | |
| | | let uniq = new Map() |
| | | uniq.set(card.field, true) |
| | | |
| | | _formfields.forEach(item => { |
| | | if (['text', 'number', 'textarea', 'color'].includes(item.type) && card.field !== item.field) { |
| | | _inputfields.push({ |
| | | field: item.field, |
| | | label: item.label |
| | | }) |
| | | } |
| | | if (card.field !== item.field && item.hidden !== 'true' && ['text', 'number', 'select', 'link'].includes(item.type)) { |
| | | _tabfields.push({ |
| | | field: item.field, |
| | | label: item.label |
| | | }) |
| | | } |
| | | |
| | | if (item.type !== 'select' && item.type !== 'link') return |
| | | if (item.field && !uniq.has(item.field)) { |
| | | uniq.set(item.field, true) |
| | |
| | | }) |
| | | } |
| | | }) |
| | | |
| | | if (card.linkSubField && card.linkSubField.length > 0) { |
| | | let fields = _inputfields.map(item => item.field) |
| | | card.linkSubField = card.linkSubField.filter(item => fields.includes(item)) |
| | | } |
| | | |
| | | if (menu.LongParam) { |
| | | menu.LongParam.columns.forEach(col => { |
| | |
| | | </div> |
| | | } style={{ width: '100%' }}> |
| | | <SettingOutlined onClick={this.changeSetting} /> |
| | | {/* <Tooltip placement="bottomLeft" overlayClassName="middle" title="在左侧工具栏《搜索》中,选择对应搜索框拖至此处添加;或点击按钮《添加搜索条件》批量添加,选择批量添加时,需提前选择使用表。"> |
| | | <QuestionCircleOutlined style={{position: 'relative', color: '#c49f47', left: '5px', top: '20px'}} /> |
| | | </Tooltip> */} |
| | | <Collapse |
| | | activeKey={config.groups.map(group => group.uuid)} |
| | | expandIconPosition={'right'} |
| | |
| | | ))} |
| | | </Collapse> |
| | | <div className="action-list"> |
| | | {/* <Tooltip placement="bottomLeft" overlayClassName="middle" title="在左侧工具栏《按钮》中,选择对应类型的按钮拖至此处添加,如选择按钮类型为表单、新标签页等含有配置页面的按钮,可在左侧工具栏-按钮-可配置按钮处,点击按钮完成相关配置。注:当设置按钮显示位置为表格时,显示列会增加操作列。"> |
| | | <QuestionCircleOutlined style={{position: 'absolute', color: '#c49f47', left: '5px', top: '5px'}} /> |
| | | </Tooltip> */} |
| | | <DragElement |
| | | type="action" |
| | | list={this.state.config.action} |
| | |
| | | >.ant-collapse { |
| | | border-radius: 0; |
| | | border: 0; |
| | | margin-top: 30px; |
| | | margin-top: 45px; |
| | | .ant-collapse-header { |
| | | cursor: default; |
| | | border-radius: 0; |
| | |
| | | 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 { |
| | | let objectStore = window.GLOB.IndexDB.transaction('funcs').objectStore('funcs') |
| | | let objectStore = window.GLOB.IndexDB.transaction('funcs').objectStore('funcs') |
| | | |
| | | objectStore.openCursor().onsuccess = (event) => { |
| | | let cursor = event.target.result |
| | | objectStore.openCursor().onsuccess = (event) => { |
| | | let cursor = event.target.result |
| | | |
| | | if (cursor) { |
| | | window.GLOB.funcs.push({ |
| | | func_code: cursor.value.func_code, |
| | | key_sql: window.decodeURIComponent(window.atob(cursor.value.key_sql)) |
| | | }) |
| | | cursor.continue() |
| | | } |
| | | if (cursor) { |
| | | window.GLOB.funcs.push({ |
| | | func_code: cursor.value.func_code, |
| | | key_sql: window.decodeURIComponent(window.atob(cursor.value.key_sql)) |
| | | }) |
| | | cursor.continue() |
| | | } |
| | | // } |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | 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 => { |
| | | // tx.executeSql('DELETE FROM FUNCS') |
| | | let objectStore = window.GLOB.IndexDB.transaction(['funcs'], 'readwrite').objectStore('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 { |
| | | let objectStore = window.GLOB.IndexDB.transaction(['funcs'], 'readwrite').objectStore('funcs') |
| | | objectStore.clear() |
| | | |
| | | objectStore.clear() |
| | | funcs.forEach(item => { |
| | | if (!item.key_sql) return |
| | | item.id = item.func_code |
| | | objectStore.add(item) |
| | | }) |
| | | |
| | | funcs.forEach(item => { |
| | | if (!item.key_sql) return |
| | | item.id = item.func_code |
| | | objectStore.add(item) |
| | | }) |
| | | |
| | | let funcStore = window.GLOB.IndexDB.transaction(['version'], 'readwrite').objectStore('version') |
| | | funcStore.put({id: 'funcs', version: '1.0', createDate: timestamp}) |
| | | // } |
| | | 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 { |
| | | let objectStore = window.GLOB.IndexDB.transaction(['version'], 'readwrite').objectStore('version') |
| | | let request = objectStore.get('funcs') |
| | | let objectStore = window.GLOB.IndexDB.transaction(['version'], 'readwrite').objectStore('version') |
| | | let request = objectStore.get('funcs') |
| | | |
| | | request.onerror = (event) => { |
| | | console.warn(event) |
| | | reject() |
| | | } |
| | | request.onerror = (event) => { |
| | | console.warn(event) |
| | | reject() |
| | | } |
| | | |
| | | request.onsuccess = () => { |
| | | if (request.result) { |
| | | resolve(request.result) |
| | | } else { |
| | | let add = objectStore.add({id: 'funcs', version: '1.0', createDate: '1970-01-01 14:59:09.000'}) |
| | | |
| | | add.onerror = () => { |
| | | reject() |
| | | } |
| | | add.onsuccess = () => { |
| | | resolve({id: 'funcs', version: '1.0', createDate: '1970-01-01 14:59:09.000'}) |
| | | } |
| | | request.onsuccess = () => { |
| | | if (request.result) { |
| | | resolve(request.result) |
| | | } else { |
| | | let add = objectStore.add({id: 'funcs', version: '1.0', createDate: '1970-01-01 14:59:09.000'}) |
| | | |
| | | add.onerror = () => { |
| | | reject() |
| | | } |
| | | add.onsuccess = () => { |
| | | resolve({id: 'funcs', version: '1.0', createDate: '1970-01-01 14:59:09.000'}) |
| | | } |
| | | } |
| | | // } |
| | | } |
| | | }) |
| | | } |
| | | |