From afb39f8ab004b2607bb718edab02e99c7a010114 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期三, 22 三月 2023 14:36:44 +0800 Subject: [PATCH] 2023-03-22 --- src/api/cacheutils.js | 330 ----------------------- src/views/design/header/index.jsx | 84 +---- src/api/index.js | 326 ++++------------------ src/templates/formtabconfig/index.jsx | 32 +- src/templates/formtabconfig/index.scss | 2 src/utils/utils.js | 35 - 6 files changed, 126 insertions(+), 683 deletions(-) diff --git a/src/api/cacheutils.js b/src/api/cacheutils.js index 244587a..f175333 100644 --- a/src/api/cacheutils.js +++ b/src/api/cacheutils.js @@ -2,275 +2,6 @@ * @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 灏嗘暟鎹啓鍏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 鑾峰彇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 */ @@ -323,7 +54,6 @@ .get('mksoft') request.onerror = (event) => { - window.GLOB.IndexDB = null console.warn(event) resolve({version: '', createDate: ''}) } @@ -344,7 +74,6 @@ let menus = [] request.onerror = () => { - window.GLOB.IndexDB = null resolve(menus) } @@ -382,58 +111,21 @@ 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() - } - }) } /** @@ -443,17 +135,9 @@ 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 @@ -470,15 +154,13 @@ /** * @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() } diff --git a/src/api/index.js b/src/api/index.js index 7d9a350..a4dd5b9 100644 --- a/src/api/index.js +++ b/src/api/index.js @@ -9,16 +9,12 @@ 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) } @@ -353,7 +349,6 @@ delCacheConfig (type = '') { let date = moment().subtract(7, 'days').format('YYYY-MM-DD') - // CacheUtils.delWebSqlCacheConfig(date, type) CacheUtils.delIndexDBCacheConfig(date, type) } @@ -362,26 +357,11 @@ 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) { @@ -402,7 +382,7 @@ } /** - * @description 鑾峰彇绯荤粺鐗堟湰淇℃伅锛屽惎鐢ㄦ垨鏇存柊websql + * @description 鑾峰彇绯荤粺鐗堟湰淇℃伅 */ getAppVersion (reload) { if (!window.GLOB.IndexDB) { @@ -412,157 +392,81 @@ 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() @@ -572,12 +476,7 @@ * @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) } /** @@ -661,7 +560,7 @@ } /** - * @description 鑾峰彇绯荤粺閰嶇疆锛屽彇鍊间紭鍏堢瓑绾ebsql銆佺紦瀛樸�佹湇鍔″櫒 + * @description 鑾峰彇绯荤粺閰嶇疆锛屽彇鍊间紭鍏堢瓑绾ndexDB銆佺紦瀛樸�佹湇鍔″櫒 */ getCacheConfig (param) { param.userid = sessionStorage.getItem('UserID') || '' @@ -685,37 +584,11 @@ } } - 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) @@ -729,18 +602,18 @@ ...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) @@ -751,7 +624,7 @@ data: param }).then(res => { if (res.status) { - window.GLOB.CacheMap.set(_param, res) + window.GLOB.CacheMap.set(key, res) } resolve(res) }) @@ -770,16 +643,7 @@ 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 { @@ -1069,57 +933,6 @@ } /** - * @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')) { // 闈濱E涓嬭浇 - // 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: '鏂囦欢瑙f瀽閿欒', - // message: '', - // status: false - // }) - // } - // }) - // }) - // } - - /** * @description 涓婁紶base64 * @param {String} base64 base64鍥剧墖缂栫爜 */ @@ -1231,17 +1044,6 @@ data: data }) } - - // /** - // * @description 鏂囦欢涓婁紶 - // */ - // getFileUpload (param) { - // return axios({ - // url: '/zh-CN/Home/Upload', - // method: 'post', - // data: param - // }) - // } } export default new Api() \ No newline at end of file diff --git a/src/templates/formtabconfig/index.jsx b/src/templates/formtabconfig/index.jsx index a3e43f0..d9b92c4 100644 --- a/src/templates/formtabconfig/index.jsx +++ b/src/templates/formtabconfig/index.jsx @@ -362,18 +362,23 @@ _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) @@ -388,6 +393,11 @@ }) } }) + + 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 => { @@ -1564,9 +1574,6 @@ </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'} @@ -1597,9 +1604,6 @@ ))} </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} diff --git a/src/templates/formtabconfig/index.scss b/src/templates/formtabconfig/index.scss index d555524..cb73f81 100644 --- a/src/templates/formtabconfig/index.scss +++ b/src/templates/formtabconfig/index.scss @@ -124,7 +124,7 @@ >.ant-collapse { border-radius: 0; border: 0; - margin-top: 30px; + margin-top: 45px; .ant-collapse-header { cursor: default; border-radius: 0; diff --git a/src/utils/utils.js b/src/utils/utils.js index 553ca2f..1a78fdb 100644 --- a/src/utils/utils.js +++ b/src/utils/utils.js @@ -2257,34 +2257,19 @@ 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() } - // } + } } /** diff --git a/src/views/design/header/index.jsx b/src/views/design/header/index.jsx index 8c60992..2155478 100644 --- a/src/views/design/header/index.jsx +++ b/src/views/design/header/index.jsx @@ -259,74 +259,44 @@ 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'}) } } - // } + } }) } -- Gitblit v1.8.0