cloudcc-ccdk 0.9.33 → 0.9.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. package/README.md +795 -780
  2. package/lib/ccdk.js +2372 -2165
  3. package/lib/ccdk.min.js +1 -1
  4. package/package.json +35 -35
package/lib/ccdk.js CHANGED
@@ -7,71 +7,71 @@ import Jwt from 'jsonwebtoken';
7
7
  import { Message, MessageBox, Notification } from 'element-ui';
8
8
  import CryptoJS from 'crypto-js';
9
9
 
10
- /**
11
- * 数据库操作
12
- */
13
- const db = new Dexie("cloudcc-ltn-main-web");
14
-
15
- /**
16
- * 初始化表,默认使用id自增长
17
- * @param {string} tablename 表名
18
- * @param {number} version 版本号
19
- * @param {...any} fields 字段集合
20
- */
21
- function init$2(tablename, version = 1, ...fields) {
22
- return db.version(version).stores({
23
- [tablename]: `++id, ${fields}`,
24
- });
25
- }
26
-
27
- /**
28
- * 新建数据,如果设置了ID,那么是更新,否则新建
29
- * @param {string} tableName 表名
30
- * @param {array} data 存储的数据集合
31
- * @returns
32
- */
33
- async function create(tableName, data = []) {
34
- return await db[tableName].bulkPut(data);
35
- }
36
-
37
- /**
38
- * 根据ID删除数据
39
- * @param {string} tableName 表名
40
- * @param {array} ids 数据id集合
41
- * @returns 删除数据的id集合
42
- */
43
- async function deleteCC(tableName, ids = []) {
44
- return await db[tableName].bulkDelete(ids);
45
- }
46
-
47
-
48
- /**
49
- * 根据过滤条件查询数据集合
50
- * @param {string} tableName 表名
51
- * @param {object} condition 查询条件
52
- * @returns 集合
53
- */
54
- async function list(tableName, condition) {
55
- return await db[tableName].where(condition).toArray();
56
- }
57
-
58
- /**
59
- * 根据ID精确查找某条数据
60
- * @param {string} tableName 表名
61
- * @param {string} id
62
- * @returns 详情
63
- */
64
- async function detail(tableName, id) {
65
- return await db[tableName].get(id);
66
- }
67
- /**
68
- * 事务
69
- * @param {string} tableName 表名
70
- * @param {function} id 事务方法
71
- * @returns 详情
72
- */
73
- async function transaction(tableName, transaction) {
74
- await db.transaction('rw', [db[tableName]], transaction);
10
+ /**
11
+ * 数据库操作
12
+ */
13
+ const db = new Dexie("cloudcc-ltn-main-web");
14
+
15
+ /**
16
+ * 初始化表,默认使用id自增长
17
+ * @param {string} tablename 表名
18
+ * @param {number} version 版本号
19
+ * @param {...any} fields 字段集合
20
+ */
21
+ function init$2(tablename, version = 1, ...fields) {
22
+ return db.version(version).stores({
23
+ [tablename]: `++id, ${fields}`,
24
+ });
25
+ }
26
+
27
+ /**
28
+ * 新建数据,如果设置了ID,那么是更新,否则新建
29
+ * @param {string} tableName 表名
30
+ * @param {array} data 存储的数据集合
31
+ * @returns
32
+ */
33
+ async function create(tableName, data = []) {
34
+ return await db[tableName].bulkPut(data);
35
+ }
36
+
37
+ /**
38
+ * 根据ID删除数据
39
+ * @param {string} tableName 表名
40
+ * @param {array} ids 数据id集合
41
+ * @returns 删除数据的id集合
42
+ */
43
+ async function deleteCC(tableName, ids = []) {
44
+ return await db[tableName].bulkDelete(ids);
45
+ }
46
+
47
+
48
+ /**
49
+ * 根据过滤条件查询数据集合
50
+ * @param {string} tableName 表名
51
+ * @param {object} condition 查询条件
52
+ * @returns 集合
53
+ */
54
+ async function list(tableName, condition) {
55
+ return await db[tableName].where(condition).toArray();
56
+ }
57
+
58
+ /**
59
+ * 根据ID精确查找某条数据
60
+ * @param {string} tableName 表名
61
+ * @param {string} id
62
+ * @returns 详情
63
+ */
64
+ async function detail(tableName, id) {
65
+ return await db[tableName].get(id);
66
+ }
67
+ /**
68
+ * 事务
69
+ * @param {string} tableName 表名
70
+ * @param {function} id 事务方法
71
+ * @returns 详情
72
+ */
73
+ async function transaction(tableName, transaction) {
74
+ await db.transaction('rw', [db[tableName]], transaction);
75
75
  }
76
76
 
77
77
  var CCDB = /*#__PURE__*/Object.freeze({
@@ -85,31 +85,31 @@ var CCDB = /*#__PURE__*/Object.freeze({
85
85
  transaction: transaction
86
86
  });
87
87
 
88
- // 当前应用存储标识
89
- // const APPLICATION_DETAIL = 'applicaton_current'
90
-
91
- const APPLICATION_DETAIL = () => {
92
- return window.$CCDK.CCUser.getUserInfo().userId + "-currentApp"
93
- };
94
- /**
95
- * 获得当前访问的应用对象
96
- */
97
- function getApplicaton() {
98
- let detail = localStorage.getItem(APPLICATION_DETAIL());
99
- if (detail) {
100
- return JSON.parse(detail)
101
- }
102
- return ''
103
- }
104
-
105
- /**
106
- * 设置应用对象信息
107
- * @param {object} detail 应用对象
108
- */
109
- function setApplication(detail = '') {
110
- if (detail) {
111
- localStorage.setItem(APPLICATION_DETAIL(), JSON.stringify(detail));
112
- }
88
+ // 当前应用存储标识
89
+ // const APPLICATION_DETAIL = 'applicaton_current'
90
+
91
+ const APPLICATION_DETAIL = () => {
92
+ return window.$CCDK.CCUser.getUserInfo().userId + "-currentApp"
93
+ };
94
+ /**
95
+ * 获得当前访问的应用对象
96
+ */
97
+ function getApplicaton() {
98
+ let detail = localStorage.getItem(APPLICATION_DETAIL());
99
+ if (detail) {
100
+ return JSON.parse(detail)
101
+ }
102
+ return ''
103
+ }
104
+
105
+ /**
106
+ * 设置应用对象信息
107
+ * @param {object} detail 应用对象
108
+ */
109
+ function setApplication(detail = '') {
110
+ if (detail) {
111
+ localStorage.setItem(APPLICATION_DETAIL(), JSON.stringify(detail));
112
+ }
113
113
  }
114
114
 
115
115
  var CCApplication = /*#__PURE__*/Object.freeze({
@@ -118,126 +118,188 @@ var CCApplication = /*#__PURE__*/Object.freeze({
118
118
  setApplication: setApplication
119
119
  });
120
120
 
121
- /**
122
- * 获得一级域名
123
- * 比如:xx.com、xx.cn、xx.com.cn、xx.net.cn、xx.org.cn
124
- */
125
- function getDomain() {
126
- let domain = document.domain;
127
- if (isValidIP(domain)) {
128
- return domain
129
- } else {
130
- // 倒数第二位域名
131
- let lastTow = document.domain.split('.').slice(-2, -1)[0];
132
- // 如果倒数第二位是这些关键字,那么需要取倒数三位域名
133
- if (lastTow == 'com' || lastTow == 'org' || lastTow == 'net') {
134
- return "." + document.domain.split('.').slice(-3).join('.')
135
- } else if (document.domain.indexOf(".cloudapp.azure.com") != -1) {
136
- return "." + document.domain.split('.').slice(-4).join('.')
137
- } else {
138
- return "." + document.domain.split('.').slice(-2).join('.')
139
- }
140
- }
141
- }
142
- /**
143
- * 检测是否为有效IP
144
- * @param {string} ip ip地址
145
- * @returns 是否为ip地址
146
- */
147
- function isValidIP(ip) {
148
- var reg = /^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/;
149
- return reg.test(ip);
150
- }
151
- /**
152
- * 校验token是否有效
153
- * {
154
- "versionType": "Unlimited",
155
- "loginName": "admin@cloudcc.com",
156
- "binding": "1eaabe2e24844904b443308f48fb0dee",
157
- "userId": "0052017BE8702F1PIi4j",
158
- "orgId": "exorg20235419690prod"
159
- }
160
- * @param {string} token 认证信息
161
- */
162
- function verifyToken(token) {
163
- let j = Jwt.decode(token);
164
- return { result: j && j.versionType && j.loginName && j.binding && j.userId && j.orgId, jwt: j }
165
- }
166
-
167
- /**
168
- * 格式化时间:yyyy-MM-dd HH:mm:ss
169
- * @returns
170
- */
171
- function getNowFormatDate() {
172
- var myDate = new Date;
173
- var year = myDate.getFullYear(); //获取当前年
174
- var mon = myDate.getMonth() + 1; //获取当前月
175
- if (mon < 10) {
176
- mon = "0" + mon;
177
- }
178
- var date = myDate.getDate(); //获取当前日
179
- if (date < 10) {
180
- date = "0" + date;
181
- }
182
- var hours = myDate.getHours(); //获取当前小时
183
- if (hours < 10) {
184
- hours = "0" + hours;
185
- }
186
- var minutes = myDate.getMinutes(); //获取当前分钟
187
- if (minutes < 10) {
188
- minutes = "0" + minutes;
189
- }
190
- var seconds = myDate.getSeconds(); //获取当前秒
191
- if (seconds < 10) {
192
- seconds = "0" + seconds;
193
- }
194
- var now = year + "-" + mon + "-" + date + " " + hours + ":" + minutes + ":" + seconds;
195
- return now;
196
- }
197
-
198
- /**
199
- * 获得16位标识
200
- * @returns 16位标识
201
- */
202
- function getUuid() {
203
- return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
204
- var r = (Math.random() * 16) | 0,
205
- v = c == 'x' ? r : (r & 0x3) | 0x8;
206
- return v.toString(16);
207
- });
208
- }
209
-
210
- function getBinding() {
211
- let binding = window.$CCDK.CCToken.getToken();
212
- if (!binding) {
213
- window.open(window.Glod.LOGIN_URL, '_self');
214
- // this.reLogin();
215
- } else {
216
- // 刷新有效期,而且有的老功能,依赖这个binding了
217
- Cookies.set('binding', binding, { expires: 1 / 12, sameSite: 'Lax' });
218
- Cookies.set('JSESSIONID', binding, { expires: 1 / 12, sameSite: 'Lax' });
219
- }
220
- return binding
221
- }
222
- /**
223
- * 用于获取当前页位置,暂时仅支持视图和详情页说明
224
- * view:视图页
225
- * detail:详情页
226
- * @returns {string} 返回值:当前页位置
227
- */
228
- function getCurrentPageType() {
229
- let currentPage;
230
- let currentHref = window.location.hash || '';
231
- currentHref = currentHref.split('?')[0] || '';
232
- const lastHref = currentHref.split('/').pop();
233
- if (currentHref.includes('#/commonObjects/views/table')) {
234
- // 当前是视图页
235
- currentPage = 'view';
236
- } else if (lastHref === 'DETAIL') {
237
- // 当前是视图页
238
- currentPage = 'detail';
239
- }
240
- return currentPage
121
+ /**
122
+ * 获得一级域名
123
+ * 比如:xx.com、xx.cn、xx.com.cn、xx.net.cn、xx.org.cn
124
+ */
125
+ function getDomain() {
126
+ let domain = document.domain;
127
+ if (isValidIP(domain)) {
128
+ return domain
129
+ } else {
130
+ // 倒数第二位域名
131
+ let lastTow = document.domain.split('.').slice(-2, -1)[0];
132
+ // 如果倒数第二位是这些关键字,那么需要取倒数三位域名
133
+ if (lastTow == 'com' || lastTow == 'org' || lastTow == 'net') {
134
+ return "." + document.domain.split('.').slice(-3).join('.')
135
+ } else if (document.domain.indexOf(".cloudapp.azure.com") != -1) {
136
+ return "." + document.domain.split('.').slice(-4).join('.')
137
+ } else if (document.domain.indexOf(".azurewebsites.net") != -1) {
138
+ return "." + document.domain.split('.').slice(-3).join('.')
139
+ } else {
140
+ return "." + document.domain.split('.').slice(-2).join('.')
141
+ }
142
+ }
143
+ }
144
+ /**
145
+ * 检测是否为有效IP
146
+ * @param {string} ip ip地址
147
+ * @returns 是否为ip地址
148
+ */
149
+ function isValidIP(ip) {
150
+ var reg = /^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/;
151
+ return reg.test(ip);
152
+ }
153
+ /**
154
+ * 校验token是否有效
155
+ * {
156
+ "versionType": "Unlimited",
157
+ "loginName": "admin@cloudcc.com",
158
+ "binding": "1eaabe2e24844904b443308f48fb0dee",
159
+ "userId": "0052017BE8702F1PIi4j",
160
+ "orgId": "exorg20235419690prod"
161
+ }
162
+ * @param {string} token 认证信息
163
+ */
164
+ function verifyToken(token) {
165
+ let j = Jwt.decode(token);
166
+ return { result: j && j.versionType && j.loginName && j.binding && j.userId && j.orgId, jwt: j }
167
+ }
168
+
169
+ /**
170
+ * 格式化时间:yyyy-MM-dd HH:mm:ss
171
+ * @returns
172
+ */
173
+ function getNowFormatDate() {
174
+ var myDate = new Date;
175
+ var year = myDate.getFullYear(); //获取当前年
176
+ var mon = myDate.getMonth() + 1; //获取当前月
177
+ if (mon < 10) {
178
+ mon = "0" + mon;
179
+ }
180
+ var date = myDate.getDate(); //获取当前日
181
+ if (date < 10) {
182
+ date = "0" + date;
183
+ }
184
+ var hours = myDate.getHours(); //获取当前小时
185
+ if (hours < 10) {
186
+ hours = "0" + hours;
187
+ }
188
+ var minutes = myDate.getMinutes(); //获取当前分钟
189
+ if (minutes < 10) {
190
+ minutes = "0" + minutes;
191
+ }
192
+ var seconds = myDate.getSeconds(); //获取当前秒
193
+ if (seconds < 10) {
194
+ seconds = "0" + seconds;
195
+ }
196
+ var now = year + "-" + mon + "-" + date + " " + hours + ":" + minutes + ":" + seconds;
197
+ return now;
198
+ }
199
+
200
+ /**
201
+ * 获得16位标识
202
+ * @returns 16位标识
203
+ */
204
+ function getUuid() {
205
+ return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
206
+ var r = (Math.random() * 16) | 0,
207
+ v = c == 'x' ? r : (r & 0x3) | 0x8;
208
+ return v.toString(16);
209
+ });
210
+ }
211
+
212
+ function getBinding() {
213
+ let binding = window.$CCDK.CCToken.getToken();
214
+ if (!binding) {
215
+ window.open(window.Glod.LOGIN_URL, '_self');
216
+ // this.reLogin();
217
+ } else {
218
+ // 刷新有效期,而且有的老功能,依赖这个binding
219
+ Cookies.set('binding', binding, { expires: 1 / 12, sameSite: 'Lax' });
220
+ Cookies.set('JSESSIONID', binding, { expires: 1 / 12, sameSite: 'Lax' });
221
+ }
222
+ return binding
223
+ }
224
+ /**
225
+ * 用于获取当前页位置,暂时仅支持视图和详情页说明
226
+ * view:视图页
227
+ * detail:详情页
228
+ * @returns {string} 返回值:当前页位置
229
+ */
230
+ function getCurrentPageType() {
231
+ let currentPage;
232
+ let currentHref = window.location.hash || '';
233
+ currentHref = currentHref.split('?')[0] || '';
234
+ const lastHref = currentHref.split('/').pop();
235
+ if (currentHref.includes('#/commonObjects/views/table')) {
236
+ // 当前是视图页
237
+ currentPage = 'view';
238
+ } else if (lastHref === 'DETAIL') {
239
+ // 当前是视图页
240
+ currentPage = 'detail';
241
+ }
242
+ return currentPage
243
+ }
244
+
245
+
246
+ // 设置筛选条件value值,数组转为字符串逗号拼接,且数组项中若是包含逗号则首尾加中括号
247
+ function setValueTypeConversion(value) {
248
+ let newArr = [];
249
+ // 将数组中带有逗号的数据项根据逗号分隔成对应数组
250
+ value.forEach((childVal) => {
251
+ if (childVal.indexOf(",") !== -1) {
252
+ childVal = childVal.split();
253
+ }
254
+ newArr.push(childVal);
255
+ });
256
+ let newData = "";
257
+ // 判断数组中的数据项是否为数组,若是数组则首尾拼接上中括号
258
+ newArr.forEach((nVal) => {
259
+ if (Array.isArray(nVal)) {
260
+ newData += "[" + nVal + "],";
261
+ } else {
262
+ newData += nVal + ",";
263
+ }
264
+ });
265
+ return newData.slice(0, newData.length - 1);
266
+ }
267
+
268
+ // 回显筛选条件value值,将字符串转为数组,若是数组项中包含逗号则首尾会带有中括号,需去掉首尾的中括号
269
+ function echoValueTypeConversion(value) {
270
+ let newArr = [];
271
+ // 若是数据为空,则直接返回空数组即可
272
+ if (!value) {
273
+ return newArr;
274
+ }
275
+ // 若是数据项中均为不带逗号的数据,直接转为数组即可
276
+ if (!value.match(/\[(.+?)\]/g)) {
277
+ newArr = value.split(",");
278
+ return newArr;
279
+ }
280
+ // 匹配字符串中带有中括号的数据,去掉首尾中括号
281
+ value
282
+ .match(/\[(.+?)\]/g)
283
+ .map((item) => newArr.push(item.replace(/\[|]/g, "")));
284
+ // 将字符串中带有中括号的数据去除
285
+ let valueArr = value.replace(/\[.*?\]/g, "").replace(/^,*|,*$/g, "");
286
+ // 当剩下的不带逗号的数据不为空时,才需要将带有逗号的数组和不带逗号的数组进行拼接
287
+ if (valueArr) {
288
+ valueArr = valueArr.split(",");
289
+ newArr = newArr.concat(valueArr);
290
+ }
291
+ return newArr;
292
+ }
293
+
294
+ // 获取表单值,配合客户端脚本使用
295
+ function getFormFieldValue(option){
296
+ const nameBus = option.view || 'ccForm';
297
+ window.$CCDK.CCBus.$emit(nameBus,'get', option);
298
+ }
299
+ // 设置表单值,配合客户端脚本使用
300
+ function setFormFieldValue(option){
301
+ const nameBus = option.view || 'ccForm';
302
+ window.$CCDK.CCBus.$emit(nameBus,'set', option);
241
303
  }
242
304
 
243
305
  var CCUtils = /*#__PURE__*/Object.freeze({
@@ -247,458 +309,462 @@ var CCUtils = /*#__PURE__*/Object.freeze({
247
309
  getBinding: getBinding,
248
310
  getNowFormatDate: getNowFormatDate,
249
311
  verifyToken: verifyToken,
250
- getCurrentPageType: getCurrentPageType
312
+ getCurrentPageType: getCurrentPageType,
313
+ setValueTypeConversion: setValueTypeConversion,
314
+ echoValueTypeConversion: echoValueTypeConversion,
315
+ getFormFieldValue: getFormFieldValue,
316
+ setFormFieldValue: setFormFieldValue
251
317
  });
252
318
 
253
- const toStr = Object.prototype.toString;
254
-
255
- const TypeEnum = {
256
- 'FUNCTION': '[object Function]',
257
- 'ARRAY': '[object Array]',
258
- };
259
-
260
- // 是否是一个函数
261
- const isFn = (value) => toStr.call(value) === TypeEnum.FUNCTION;
262
-
263
- // 是否是生产环境
264
- const isProduction = () => true ;
265
-
266
- // 延时
267
- const delay = (waitTime = 1000) => new Promise(resolve => setTimeout(resolve, waitTime));
268
-
269
- // 是否是超时请求
270
- const isTimeout = (error = {
271
- code: '',
272
- message: ''
273
- }) => {
274
- return error.code === AxiosError.ECONNABORTED && error.message.includes('timeout')
275
- };
276
-
277
- // 格式换请求体
278
- const formateData = data => {
279
- return {
280
- head: {
281
- appType: "lightning-main",
282
- appVersion: "1.1.1",
283
- accessToken: getBinding(),
284
- source: "lightning-main"
285
- },
286
- body: {
287
- ...data
288
- }
289
- }
290
- };
291
- /**
292
- * 深度合并
293
- * @param {object} source 合并的基础对象
294
- * @param {object} target 新的数据
295
- */
296
- const deepMerge = (source, target) => {
297
- const res = cloneDeep(source);
298
- for (let key in target) {
299
- if (target.hasOwnProperty(key)) {
300
- res[key] = isObject(target[key])
301
- ? deepMerge(res[key], target[key])
302
- : target[key];
303
- }
304
- }
305
- return res
319
+ const toStr = Object.prototype.toString;
320
+
321
+ const TypeEnum = {
322
+ 'FUNCTION': '[object Function]',
323
+ 'ARRAY': '[object Array]',
324
+ };
325
+
326
+ // 是否是一个函数
327
+ const isFn = (value) => toStr.call(value) === TypeEnum.FUNCTION;
328
+
329
+ // 是否是生产环境
330
+ const isProduction = () => true ;
331
+
332
+ // 延时
333
+ const delay = (waitTime = 1000) => new Promise(resolve => setTimeout(resolve, waitTime));
334
+
335
+ // 是否是超时请求
336
+ const isTimeout = (error = {
337
+ code: '',
338
+ message: ''
339
+ }) => {
340
+ return error.code === AxiosError.ECONNABORTED && error.message.includes('timeout')
306
341
  };
307
342
 
308
- /**
309
- * LRU算法
310
- * @param {number} capacity 最大缓存容量
311
- */
312
- const LRUCache = function (capacity) {
313
- this.capacity = capacity;
314
- this.cache = new Map();
315
- };
316
-
317
- /**
318
- * 获取指定key的缓存
319
- * @param {string} key 缓存的key
320
- */
321
- LRUCache.prototype.get = function (key) {
322
- var cacheTemp = this.cache,
323
- curTemp = cacheTemp.get(key);
324
- if (curTemp || curTemp === 0) {
325
- cacheTemp.delete(key);
326
- cacheTemp.set(key, curTemp);
327
- return curTemp
328
- }
329
- return null
330
- };
331
-
332
- /**
333
- * 指定key添加缓存
334
- * @param {string} key 缓存的key
335
- * @param {object} value 缓存的值
336
- */
337
- LRUCache.prototype.put = function (key, value) {
338
- var cacheTemp = this.cache;
339
- if (cacheTemp.get(key)) {
340
- cacheTemp.delete(key);
341
- } else if (cacheTemp.size >= this.capacity) {
342
- cacheTemp.delete(cacheTemp.keys().next().value);
343
- }
344
- cacheTemp.set(key, value);
343
+ // 格式换请求体
344
+ const formateData = data => {
345
+ return {
346
+ head: {
347
+ appType: "lightning-main",
348
+ appVersion: "1.1.1",
349
+ accessToken: getBinding(),
350
+ source: "lightning-main"
351
+ },
352
+ body: {
353
+ ...data
354
+ }
355
+ }
356
+ };
357
+ /**
358
+ * 深度合并
359
+ * @param {object} source 合并的基础对象
360
+ * @param {object} target 新的数据
361
+ */
362
+ const deepMerge = (source, target) => {
363
+ const res = cloneDeep(source);
364
+ for (let key in target) {
365
+ if (target.hasOwnProperty(key)) {
366
+ res[key] = isObject(target[key])
367
+ ? deepMerge(res[key], target[key])
368
+ : target[key];
369
+ }
370
+ }
371
+ return res
372
+ };
373
+
374
+ /**
375
+ * LRU算法
376
+ * @param {number} capacity 最大缓存容量
377
+ */
378
+ const LRUCache = function (capacity) {
379
+ this.capacity = capacity;
380
+ this.cache = new Map();
381
+ };
382
+
383
+ /**
384
+ * 获取指定key的缓存
385
+ * @param {string} key 缓存的key
386
+ */
387
+ LRUCache.prototype.get = function (key) {
388
+ var cacheTemp = this.cache,
389
+ curTemp = cacheTemp.get(key);
390
+ if (curTemp || curTemp === 0) {
391
+ cacheTemp.delete(key);
392
+ cacheTemp.set(key, curTemp);
393
+ return curTemp
394
+ }
395
+ return null
396
+ };
397
+
398
+ /**
399
+ * 指定key添加缓存
400
+ * @param {string} key 缓存的key
401
+ * @param {object} value 缓存的值
402
+ */
403
+ LRUCache.prototype.put = function (key, value) {
404
+ var cacheTemp = this.cache;
405
+ if (cacheTemp.get(key)) {
406
+ cacheTemp.delete(key);
407
+ } else if (cacheTemp.size >= this.capacity) {
408
+ cacheTemp.delete(cacheTemp.keys().next().value);
409
+ }
410
+ cacheTemp.set(key, value);
411
+ };
412
+
413
+ class CCAxios {
414
+ constructor(opt) {
415
+ this.options = opt;
416
+ this.axiosInstance = axios.create(opt);
417
+ this.setupInterceptors();
418
+ this.cachePool = new LRUCache(20);
419
+ // FIXME:区分构造函数参数和接口级别的参数
420
+ }
421
+
422
+ //获取拦截器
423
+ getTransform() {
424
+ const { transform } = this.options;
425
+ return transform;
426
+ }
427
+
428
+ //准备拦截器
429
+ setupInterceptors() {
430
+ const transform = this.getTransform();
431
+ if (!transform) {
432
+ return;
433
+ }
434
+ const {
435
+ requestInterceptors,
436
+ requestInterceptorsCatch,
437
+ responseInterceptors,
438
+ responseInterceptorsCatch,
439
+ } = transform;
440
+ // 请求拦截器
441
+ this.axiosInstance.interceptors.request.use(requestInterceptors, undefined);
442
+ // 请求拦截器错误处理
443
+ requestInterceptorsCatch
444
+ && isFn(requestInterceptorsCatch)
445
+ && this.axiosInstance.interceptors.request.use(undefined, requestInterceptorsCatch);
446
+
447
+ // 响应拦截器
448
+ this.axiosInstance.interceptors.response.use(responseInterceptors, undefined);
449
+ // 响应拦截器错误处理
450
+ responseInterceptorsCatch
451
+ && isFn(responseInterceptorsCatch)
452
+ && this.axiosInstance.interceptors.response.use(undefined, (error) => {
453
+ return responseInterceptorsCatch(this.axiosInstance, error)
454
+ });
455
+ }
456
+ get(config, options = {}) {
457
+ return this.request({ ...config, method: 'GET', }, options)
458
+ }
459
+ post(config, options = {}) {
460
+ const { envType } = options;
461
+ // 公有云专用接口,在私有云不请求
462
+ if ("public" == envType && "private" == window.Glod["ENV_TYPE"]) {
463
+ return new Promise(() => { })
464
+ }
465
+ // 私有云专用接口,在公有云不请求
466
+ if ("private" == envType && "private" != window.Glod["ENV_TYPE"]) {
467
+ return new Promise(() => { })
468
+ }
469
+ return this.request({ ...config, method: 'POST', }, options)
470
+ }
471
+ postFormat(config, options = {}) {
472
+ return this.request({ ...config, method: 'POST', data: formateData(config.data) }, options)
473
+ }
474
+ postParams(config, options = {}) {
475
+ return this.request({ ...config, method: 'POST', params: config.data }, options)
476
+ }
477
+
478
+ // FIXME:如果初始化时配置了重试那么所有get接口都重试了
479
+ // options是接口级定义的参数
480
+ request(config, options) {
481
+ const transform = this.getTransform();
482
+ const conf = config,
483
+ { requestOptions } = this.options;
484
+ requestOptions.cache = false;
485
+ requestOptions.cacheKey = '';
486
+ requestOptions.retryRequest = {
487
+ isOpenRetry: false,
488
+ count: 5,
489
+ waitTime: 1000
490
+ };
491
+
492
+ const opt = Object.assign({}, requestOptions, options);
493
+ conf.requestOptions = opt;
494
+
495
+ const retPromise = new Promise((resolve, reject) => {
496
+ this.axiosInstance(conf)
497
+ .then(res => {
498
+ const { transformResponseHook } = transform;
499
+ if (transformResponseHook && isFn(transformResponseHook)) {
500
+ try {
501
+ const ret = transformResponseHook(res, opt, this.cachePool);
502
+ resolve(ret);
503
+ } catch (err) {
504
+ reject(err || new Error('request error!'));
505
+ }
506
+ return;
507
+ }
508
+ resolve(res);
509
+ })
510
+ .catch(err => {
511
+ reject(err);
512
+ });
513
+ });
514
+ // 缓存
515
+ retPromise.cache = (callback) => {
516
+ const { cache, cacheKey } = opt;
517
+ const cacheData = (cache && this.cachePool.get([cacheKey]));
518
+ callback(cacheData ? cacheData : null);
519
+ return retPromise
520
+ };
521
+ return retPromise
522
+ }
523
+ }
524
+
525
+ // 使用全局弹窗进行提示
526
+ const createErrorModal = (response, options) => {
527
+ const { message } = options;
528
+ let temp;
529
+ if (response.name === 'AxiosError') {
530
+ temp = response.response;
531
+ temp.data.returnInfo = response.returnInfo || message || temp.error || '';
532
+ temp.data.returnCode = response.code || temp.status;
533
+ temp.data.requestId = response.config.headers.requestId;
534
+ } else {
535
+ temp = response;
536
+ temp.data.requestId = response.config.headers.requestId;
537
+ }
538
+ // 存在全局错误弹窗时才调用
539
+ isFn(Vue.prototype.$ErrorDialog) && Vue.prototype.$ErrorDialog({
540
+ response: temp
541
+ });
345
542
  };
346
543
 
347
- class CCAxios {
348
- constructor(opt) {
349
- this.options = opt;
350
- this.axiosInstance = axios.create(opt);
351
- this.setupInterceptors();
352
- this.cachePool = new LRUCache(20);
353
- // FIXME:区分构造函数参数和接口级别的参数
354
- }
355
-
356
- //获取拦截器
357
- getTransform() {
358
- const { transform } = this.options;
359
- return transform;
360
- }
361
-
362
- //准备拦截器
363
- setupInterceptors() {
364
- const transform = this.getTransform();
365
- if (!transform) {
366
- return;
367
- }
368
- const {
369
- requestInterceptors,
370
- requestInterceptorsCatch,
371
- responseInterceptors,
372
- responseInterceptorsCatch,
373
- } = transform;
374
- // 请求拦截器
375
- this.axiosInstance.interceptors.request.use(requestInterceptors, undefined);
376
- // 请求拦截器错误处理
377
- requestInterceptorsCatch
378
- && isFn(requestInterceptorsCatch)
379
- && this.axiosInstance.interceptors.request.use(undefined, requestInterceptorsCatch);
380
-
381
- // 响应拦截器
382
- this.axiosInstance.interceptors.response.use(responseInterceptors, undefined);
383
- // 响应拦截器错误处理
384
- responseInterceptorsCatch
385
- && isFn(responseInterceptorsCatch)
386
- && this.axiosInstance.interceptors.response.use(undefined, (error) => {
387
- return responseInterceptorsCatch(this.axiosInstance, error)
388
- });
389
- }
390
- get(config, options = {}) {
391
- return this.request({ ...config, method: 'GET', }, options)
392
- }
393
- post(config, options = {}) {
394
- const { envType } = options;
395
- // 公有云专用接口,在私有云不请求
396
- if ("public" == envType && "private" == window.Glod["ENV_TYPE"]) {
397
- return new Promise(() => { })
398
- }
399
- // 私有云专用接口,在公有云不请求
400
- if ("private" == envType && "private" != window.Glod["ENV_TYPE"]) {
401
- return new Promise(() => { })
402
- }
403
- return this.request({ ...config, method: 'POST', }, options)
404
- }
405
- postFormat(config, options = {}) {
406
- return this.request({ ...config, method: 'POST', data: formateData(config.data) }, options)
407
- }
408
- postParams(config, options = {}) {
409
- return this.request({ ...config, method: 'POST', params: config.data }, options)
410
- }
411
-
412
- // FIXME:如果初始化时配置了重试那么所有get接口都重试了
413
- // options是接口级定义的参数
414
- request(config, options) {
415
- const transform = this.getTransform();
416
- const conf = config,
417
- { requestOptions } = this.options;
418
- requestOptions.cache = false;
419
- requestOptions.cacheKey = '';
420
- requestOptions.retryRequest = {
421
- isOpenRetry: false,
422
- count: 5,
423
- waitTime: 1000
424
- };
425
-
426
- const opt = Object.assign({}, requestOptions, options);
427
- conf.requestOptions = opt;
428
-
429
- const retPromise = new Promise((resolve, reject) => {
430
- this.axiosInstance(conf)
431
- .then(res => {
432
- const { transformResponseHook } = transform;
433
- if (transformResponseHook && isFn(transformResponseHook)) {
434
- try {
435
- const ret = transformResponseHook(res, opt, this.cachePool);
436
- resolve(ret);
437
- } catch (err) {
438
- reject(err || new Error('request error!'));
439
- }
440
- return;
441
- }
442
- resolve(res);
443
- })
444
- .catch(err => {
445
- reject(err);
446
- });
447
- });
448
- // 缓存
449
- retPromise.cache = (callback) => {
450
- const { cache, cacheKey } = opt;
451
- const cacheData = (cache && this.cachePool.get([cacheKey]));
452
- callback(cacheData ? cacheData : null);
453
- return retPromise
454
- };
455
- return retPromise
456
- }
457
- }
458
-
459
- // 使用全局弹窗进行提示
460
- const createErrorModal = (response, options) => {
461
- const { message } = options;
462
- let temp;
463
- if (response.name === 'AxiosError') {
464
- temp = response.response;
465
- temp.data.returnInfo = response.returnInfo || message || temp.error || '';
466
- temp.data.returnCode = response.code || temp.status;
467
- temp.data.requestId = response.config.headers.requestId;
468
- } else {
469
- temp = response;
470
- temp.data.requestId = response.config.headers.requestId;
471
- }
472
- // 存在全局错误弹窗时才调用
473
- isFn(Vue.prototype.$ErrorDialog) && Vue.prototype.$ErrorDialog({
474
- response: temp
475
- });
476
- };
477
-
478
544
  const createMessage = Message;
479
545
 
480
- // 需要上报的errorType
546
+ // 需要上报的errorType
481
547
  const needReportErrorType = ['901', '999'];
482
548
 
483
- function checkStatus(error, status, msg, errorMessageMode = 'modal') {
484
- // const errorMsg = errorMsgMap[status] || {
485
- // label: "message.error.object.contactadministrators"
486
- // }
487
- // let errMessage = '',
488
- // label = '';
489
-
490
- // label = errorMsg.label;
491
- // [400, 401].includes(status) && msg && (label = msg)
492
- let errMessage = "message.error.object.contactadministrators"; //系统异常,请联系系统管理员获取帮助。
493
-
494
- if (status === 401) {
495
- //重新登录相关逻辑
496
- window.open(window.Glod.LOGIN_URL, '_self');
497
- }
498
-
499
- {
500
- if (errorMessageMode === 'modal') {
501
- createErrorModal(error, { message: errMessage });
502
- } else if (errorMessageMode === 'message') {
503
- createMessage.error(errMessage);
504
- }
505
- }
506
- }
507
-
508
- /**
509
- * 接口请求重试
510
- * @param {object} AxiosInstance实例
511
- * @param {error} AxiosError对象
512
- */
513
- const retry = async (instance, error) => {
514
- const { config } = error,
515
- { waitTime, count = 5} = config.requestOptions || {};
516
- config.__retryCount = config.__retryCount || 0;
517
- if(count <= config.__retryCount ) {
518
- return Promise.reject(error)
519
- }
520
-
521
- config.__retryCount++;
522
-
523
- await delay(waitTime);
524
- //请求返回后config的header不正确造成重试请求失败,删除返回headers采用默认headers
525
- delete config.headers;
526
- return instance(config)
549
+ function checkStatus(error, status, msg, errorMessageMode = 'modal') {
550
+ // const errorMsg = errorMsgMap[status] || {
551
+ // label: "message.error.object.contactadministrators"
552
+ // }
553
+ // let errMessage = '',
554
+ // label = '';
555
+
556
+ // label = errorMsg.label;
557
+ // [400, 401].includes(status) && msg && (label = msg)
558
+ let errMessage = "message.error.object.contactadministrators"; //系统异常,请联系系统管理员获取帮助。
559
+
560
+ if (status === 401) {
561
+ //重新登录相关逻辑
562
+ window.open(window.Glod.LOGIN_URL, '_self');
563
+ }
564
+
565
+ {
566
+ if (errorMessageMode === 'modal') {
567
+ createErrorModal(error, { message: errMessage });
568
+ } else if (errorMessageMode === 'message') {
569
+ createMessage.error(errMessage);
570
+ }
571
+ }
572
+ }
573
+
574
+ /**
575
+ * 接口请求重试
576
+ * @param {object} AxiosInstance实例
577
+ * @param {error} AxiosError对象
578
+ */
579
+ const retry = async (instance, error) => {
580
+ const { config } = error,
581
+ { waitTime, count = 5} = config.requestOptions || {};
582
+ config.__retryCount = config.__retryCount || 0;
583
+ if(count <= config.__retryCount ) {
584
+ return Promise.reject(error)
585
+ }
586
+
587
+ config.__retryCount++;
588
+
589
+ await delay(waitTime);
590
+ //请求返回后config的header不正确造成重试请求失败,删除返回headers采用默认headers
591
+ delete config.headers;
592
+ return instance(config)
593
+ };
594
+
595
+ const transform = {
596
+ // 请求拦截器
597
+ requestInterceptors(config) {
598
+ // 设置日志请求头信息
599
+ config.headers.requestId = window.$CCDK.CCUtils.getUuid();
600
+ config.headers.requestIdProducer = "browser";
601
+ config.headers.accessToken = window.$CCDK.CCToken.getToken();
602
+ return config
603
+ },
604
+ // 响应拦截器
605
+ responseInterceptors(response) {
606
+ const { data, config } = response,
607
+ { errorType, result } = data;
608
+ //失败
609
+ if (!result) {
610
+ if (needReportErrorType.includes(errorType) && isProduction()) {
611
+ const { errorReporter } = config.requestOptions;
612
+ //如果存在错误上报对象,则上报错误
613
+ if (errorReporter && isFn(errorReporter)) {
614
+ errorReporter(response);
615
+ }
616
+ }
617
+ return response
618
+ }
619
+ // 成功
620
+ // 生产环境上报日志
621
+ const { infoReporter } = config.requestOptions;
622
+ //如果存在日志上报对象,则上报日志
623
+ if (infoReporter && isFn(infoReporter)) {
624
+ infoReporter(response);
625
+ }
626
+ // 返回数据 外面处理
627
+ return response
628
+ },
629
+ // 响应拦截器异常处理,处理的错误类型包括: 服务器直接跑出异常、超时、网络错误
630
+ async responseInterceptorsCatch(axiosInstance, error) {
631
+ const { response, config } = error || {};
632
+
633
+ let err = "",
634
+ msg = "",
635
+ mode = "modal";
636
+ try {
637
+ err = error.toString(),
638
+ msg = response.data.error,
639
+ mode = config.requestOptions.errorMessageMode;
640
+ } catch (e) { }
641
+
642
+ let errorMessageMode = ['message', 'modal'].includes(mode) && mode || 'modal',
643
+ errMessage = '';
644
+
645
+ // 是否是取消的请求
646
+ if (axios.isCancel(error)) {
647
+ return Promise.reject(error)
648
+ }
649
+
650
+ try {
651
+ //如果存在错误上报对象,则上报错误
652
+ if (isProduction()) {
653
+ // 接口级的错误上报方式会覆盖实例初始化时的错误上报
654
+ const { errorReporter } = config.requestOptions;
655
+ if (errorReporter && isFn(errorReporter)) {
656
+ errorReporter(error);
657
+ }
658
+ }
659
+ // 处理超时
660
+ if (isTimeout(error)) {
661
+ errMessage = 'c2487';
662
+ }
663
+ // 处理网络错误
664
+ if (err && err.includes('Network Error')) {
665
+ errMessage = 'c929';
666
+ }
667
+
668
+ if (errMessage) {
669
+ if (errorMessageMode === 'modal') {
670
+ createErrorModal({
671
+ ...error,
672
+ response: {
673
+ data: {
674
+ returnInfo: error.message,
675
+ returnCode: error.code,
676
+ requestId: error.config.headers.requestId
677
+ },
678
+ config: error.config
679
+ }
680
+ }, { message: errMessage });
681
+ } else if (errorMessageMode === 'message') {
682
+ createMessage.error(errMessage);
683
+ }
684
+ return Promise.reject(error)
685
+ }
686
+ } catch (error) {
687
+ throw new Error(error);
688
+ }
689
+ // 根据status处理其他类型错误
690
+ checkStatus(error, error && error.response.status, msg, errorMessageMode);
691
+
692
+ // 接口重试操作
693
+ const { isOpenRetry } = config;
694
+ isOpenRetry && config.method && config.method.toUpperCase() === "GET" && retry(axiosInstance, error);
695
+
696
+ return Promise.reject(error);
697
+ },
698
+ // 响应数据处理,包含解密和数据返回结构设置
699
+ transformResponseHook(response, options, cachePool) {
700
+ const { data } = response;
701
+ const { errorType, result } = data;
702
+ // 失败
703
+ // 501异常处理
704
+ const businessLogicError = (response) => {
705
+ const { errorMessageMode, silent } = response.config.requestOptions;
706
+ // 接口如果设置了出现异常不提醒,则不提醒
707
+ if (silent) return;
708
+ // 根据errorMessageMode来判断显示错误弹窗的ui
709
+ if (errorMessageMode === 'modal') {
710
+ // 业务出错
711
+ createErrorModal(response, { message: 'Business Error' });
712
+ } else if (errorMessageMode === 'message') {
713
+ createMessage.error(response && response.data && response.data.returnInfo || 'Business Error');
714
+ }
715
+ };
716
+ if (!result) {
717
+ switch (errorType) {
718
+ case '901':
719
+ // 系统错误
720
+ createErrorModal(response, { message: 'System Error' });
721
+ break;
722
+ case '999':
723
+ break;
724
+ case '501':
725
+ default:
726
+ businessLogicError(response);
727
+ break;
728
+ }
729
+ return Promise.reject(response)
730
+ }
731
+ // 成功
732
+ const { isReturnNativeResponse, cache, cacheKey } = options;
733
+ // 直接返回
734
+ if (isReturnNativeResponse) {
735
+ cache && cacheKey && (cachePool.put(cacheKey, response));
736
+ return response
737
+ }
738
+ cache && cacheKey && (cachePool.put(cacheKey, data));
739
+ return data
740
+ }
527
741
  };
528
742
 
529
- const transform = {
530
- // 请求拦截器
531
- requestInterceptors(config) {
532
- // 设置日志请求头信息
533
- config.headers.requestId = window.$CCDK.CCUtils.getUuid();
534
- config.headers.requestIdProducer = "browser";
535
- config.headers.accessToken = window.$CCDK.CCToken.getToken();
536
- return config
537
- },
538
- // 响应拦截器
539
- responseInterceptors(response) {
540
- const { data, config } = response,
541
- { errorType, result } = data;
542
- //失败
543
- if (!result) {
544
- if (needReportErrorType.includes(errorType) && isProduction()) {
545
- const { errorReporter } = config.requestOptions;
546
- //如果存在错误上报对象,则上报错误
547
- if (errorReporter && isFn(errorReporter)) {
548
- errorReporter(response);
549
- }
550
- }
551
- return response
552
- }
553
- // 成功
554
- // 生产环境上报日志
555
- const { infoReporter } = config.requestOptions;
556
- //如果存在日志上报对象,则上报日志
557
- if (infoReporter && isFn(infoReporter)) {
558
- infoReporter(response);
559
- }
560
- // 返回数据 外面处理
561
- return response
562
- },
563
- // 响应拦截器异常处理,处理的错误类型包括: 服务器直接跑出异常、超时、网络错误
564
- async responseInterceptorsCatch(axiosInstance, error) {
565
- const { response, config } = error || {};
566
-
567
- let err = "",
568
- msg = "",
569
- mode = "modal";
570
- try {
571
- err = error.toString(),
572
- msg = response.data.error,
573
- mode = config.requestOptions.errorMessageMode;
574
- } catch (e) { }
575
-
576
- let errorMessageMode = ['message', 'modal'].includes(mode) && mode || 'modal',
577
- errMessage = '';
578
-
579
- // 是否是取消的请求
580
- if (axios.isCancel(error)) {
581
- return Promise.reject(error)
582
- }
583
-
584
- try {
585
- //如果存在错误上报对象,则上报错误
586
- if (isProduction()) {
587
- // 接口级的错误上报方式会覆盖实例初始化时的错误上报
588
- const { errorReporter } = config.requestOptions;
589
- if (errorReporter && isFn(errorReporter)) {
590
- errorReporter(error);
591
- }
592
- }
593
- // 处理超时
594
- if (isTimeout(error)) {
595
- errMessage = 'c2487';
596
- }
597
- // 处理网络错误
598
- if (err && err.includes('Network Error')) {
599
- errMessage = 'c929';
600
- }
601
-
602
- if (errMessage) {
603
- if (errorMessageMode === 'modal') {
604
- createErrorModal({
605
- ...error,
606
- response: {
607
- data: {
608
- returnInfo: error.message,
609
- returnCode: error.code,
610
- requestId: error.config.headers.requestId
611
- },
612
- config: error.config
613
- }
614
- }, { message: errMessage });
615
- } else if (errorMessageMode === 'message') {
616
- createMessage.error(errMessage);
617
- }
618
- return Promise.reject(error)
619
- }
620
- } catch (error) {
621
- throw new Error(error);
622
- }
623
- // 根据status处理其他类型错误
624
- checkStatus(error, error && error.response.status, msg, errorMessageMode);
625
-
626
- // 接口重试操作
627
- const { isOpenRetry } = config;
628
- isOpenRetry && config.method && config.method.toUpperCase() === "GET" && retry(axiosInstance, error);
629
-
630
- return Promise.reject(error);
631
- },
632
- // 响应数据处理,包含解密和数据返回结构设置
633
- transformResponseHook(response, options, cachePool) {
634
- const { data } = response;
635
- const { errorType, result } = data;
636
- // 失败
637
- // 501异常处理
638
- const businessLogicError = (response) => {
639
- const { errorMessageMode, silent } = response.config.requestOptions;
640
- // 接口如果设置了出现异常不提醒,则不提醒
641
- if (silent) return;
642
- // 根据errorMessageMode来判断显示错误弹窗的ui
643
- if (errorMessageMode === 'modal') {
644
- // 业务出错
645
- createErrorModal(response, { message: 'Business Error' });
646
- } else if (errorMessageMode === 'message') {
647
- createMessage.error(response && response.data && response.data.returnInfo || 'Business Error');
648
- }
649
- };
650
- if (!result) {
651
- switch (errorType) {
652
- case '901':
653
- // 系统错误
654
- createErrorModal(response, { message: 'System Error' });
655
- break;
656
- case '999':
657
- break;
658
- case '501':
659
- default:
660
- businessLogicError(response);
661
- break;
662
- }
663
- return Promise.reject(response)
664
- }
665
- // 成功
666
- const { isReturnNativeResponse, cache, cacheKey } = options;
667
- // 直接返回
668
- if (isReturnNativeResponse) {
669
- cache && cacheKey && (cachePool.put(cacheKey, response));
670
- return response
671
- }
672
- cache && cacheKey && (cachePool.put(cacheKey, data));
673
- return data
674
- }
675
- };
676
-
677
-
678
- function createAxios(opt) {
679
- return new CCAxios(deepMerge({
680
- timeout: 60 * 1000,
681
- headers: {
682
- 'Content-Type': 'application/json;charset=UTF-8',
683
- },
684
- transform: cloneDeep(transform),
685
- requestOptions: {
686
- envType: '',
687
- errorMessageMode: 'modal',
688
- //是否静默错误提示
689
- silent: false,
690
- // 接口是否需要缓存
691
- cache: false,
692
- // 接口重试相关
693
- retryRequest: {
694
- isOpenRetry: false,
695
- count: 5,
696
- waitTime: 100,
697
- },
698
- // 是否返回原生响应头 比如:需要获取响应头时使用该属性
699
- isReturnNativeResponse: false,
700
- }
701
- }, opt || {}))
743
+
744
+ function createAxios(opt) {
745
+ return new CCAxios(deepMerge({
746
+ timeout: 60 * 1000,
747
+ headers: {
748
+ 'Content-Type': 'application/json;charset=UTF-8',
749
+ },
750
+ transform: cloneDeep(transform),
751
+ requestOptions: {
752
+ envType: '',
753
+ errorMessageMode: 'modal',
754
+ //是否静默错误提示
755
+ silent: false,
756
+ // 接口是否需要缓存
757
+ cache: false,
758
+ // 接口重试相关
759
+ retryRequest: {
760
+ isOpenRetry: false,
761
+ count: 5,
762
+ waitTime: 100,
763
+ },
764
+ // 是否返回原生响应头 比如:需要获取响应头时使用该属性
765
+ isReturnNativeResponse: false,
766
+ }
767
+ }, opt || {}))
702
768
  }
703
769
 
704
770
  var CCHttp$1 = /*#__PURE__*/Object.freeze({
@@ -706,31 +772,31 @@ var CCHttp$1 = /*#__PURE__*/Object.freeze({
706
772
  createAxios: createAxios
707
773
  });
708
774
 
709
- Vue.prototype.$Bus = new Vue;
710
- window.ccBus = Vue.prototype.$Bus;
711
- /**
712
- * 发布信息
713
- * @param {string} event 事件名称
714
- * @param {...any} args 参数列表
715
- */
716
- function $emit(...args) {
717
- window.ccBus.$emit(...args);
718
- }
719
- /**
720
- * 订阅消息
721
- * @param {string} event 事件名称
722
- * @param {function} callback 回调方法
723
- */
724
- function $on(...args) {
725
- window.ccBus.$on(...args);
726
- }
727
- /**
728
- * 取消订阅
729
- * @param {string} event 事件名称
730
- * @param { function | function[] | undefined } callbacks 需要解除监听的事件
731
- */
732
- function $off(...args) {
733
- window.ccBus.$off(...args);
775
+ Vue.prototype.$Bus = new Vue;
776
+ window.ccBus = Vue.prototype.$Bus;
777
+ /**
778
+ * 发布信息
779
+ * @param {string} event 事件名称
780
+ * @param {...any} args 参数列表
781
+ */
782
+ function $emit(...args) {
783
+ window.ccBus.$emit(...args);
784
+ }
785
+ /**
786
+ * 订阅消息
787
+ * @param {string} event 事件名称
788
+ * @param {function} callback 回调方法
789
+ */
790
+ function $on(...args) {
791
+ window.ccBus.$on(...args);
792
+ }
793
+ /**
794
+ * 取消订阅
795
+ * @param {string} event 事件名称
796
+ * @param { function | function[] | undefined } callbacks 需要解除监听的事件
797
+ */
798
+ function $off(...args) {
799
+ window.ccBus.$off(...args);
734
800
  }
735
801
 
736
802
  var CCBus = /*#__PURE__*/Object.freeze({
@@ -740,57 +806,57 @@ var CCBus = /*#__PURE__*/Object.freeze({
740
806
  $off: $off
741
807
  });
742
808
 
743
- // 电话对象
744
- let ccCall = new Map();
745
- // 电话服务商当前对象
746
- let currentCall;
747
- /**
748
- * 初始化电话条
749
- * @param {string} id 电话服务商唯一标识
750
- * @param {object} callClient 电话对象
751
- */
752
- function init$1(id, callClient) {
753
- if (id && callClient) {
754
- ccCall.set(id, callClient);
755
- currentCall = callClient;
756
- return currentCall
757
- }
758
- }
759
-
760
-
761
- /**
762
- * 拨打电话
763
- * @param {string} id 电话服务商唯一标识
764
- * @param {object} options 配置信息
765
- */
766
- function call(id, options) {
767
- let call;
768
- if (id) {
769
- call = ccCall.get(id);
770
- } else {
771
- call = currentCall;
772
- }
773
- if (call) {
774
- call.call(options);
775
- }
776
- return call
777
- }
778
- /**
779
- * 打开通话面板
780
- * @param {string} id 电话服务商唯一标识
781
- * @param {object} options 配置信息
782
- */
783
- function openCallPanel(id, options) {
784
- let call;
785
- if (id) {
786
- call = ccCall.get(id);
787
- } else {
788
- call = currentCall;
789
- }
790
- if (call) {
791
- call.openCallPanel(options);
792
- }
793
- return call
809
+ // 电话对象
810
+ let ccCall = new Map();
811
+ // 电话服务商当前对象
812
+ let currentCall;
813
+ /**
814
+ * 初始化电话条
815
+ * @param {string} id 电话服务商唯一标识
816
+ * @param {object} callClient 电话对象
817
+ */
818
+ function init$1(id, callClient) {
819
+ if (id && callClient) {
820
+ ccCall.set(id, callClient);
821
+ currentCall = callClient;
822
+ return currentCall
823
+ }
824
+ }
825
+
826
+
827
+ /**
828
+ * 拨打电话
829
+ * @param {string} id 电话服务商唯一标识
830
+ * @param {object} options 配置信息
831
+ */
832
+ function call(id, options) {
833
+ let call;
834
+ if (id) {
835
+ call = ccCall.get(id);
836
+ } else {
837
+ call = currentCall;
838
+ }
839
+ if (call) {
840
+ call.call(options);
841
+ }
842
+ return call
843
+ }
844
+ /**
845
+ * 打开通话面板
846
+ * @param {string} id 电话服务商唯一标识
847
+ * @param {object} options 配置信息
848
+ */
849
+ function openCallPanel(id, options) {
850
+ let call;
851
+ if (id) {
852
+ call = ccCall.get(id);
853
+ } else {
854
+ call = currentCall;
855
+ }
856
+ if (call) {
857
+ call.openCallPanel(options);
858
+ }
859
+ return call
794
860
  }
795
861
 
796
862
  var CCCall = /*#__PURE__*/Object.freeze({
@@ -800,96 +866,96 @@ var CCCall = /*#__PURE__*/Object.freeze({
800
866
  openCallPanel: openCallPanel
801
867
  });
802
868
 
803
- /**
804
- * 错误日志上报
805
- * @param {object} response 响应体
806
- */
807
- function reportError(response) {
808
- if ("1" === window.Glod['CC_LOG_LEVEL'] || "2" === window.Glod['CC_LOG_LEVEL']) {
809
- window.$CCDK.CCLog.reportLog(window.Glod['ccex-log'] + "/ccerrorlog", response, "error", { serviceName: "lightning-custom-page" });
810
- }
811
- }
812
- /**
813
- * 常规日志上报
814
- * @param {object} response 响应体
815
- */
816
- function reportInfo(response) {
817
- if ("2" === window.Glod['CC_LOG_LEVEL']) {
818
- window.$CCDK.CCLog.reportLog(window.Glod['ccex-log'] + "/systeminfolog", response, "info", {
819
- serviceName: "lightning-custom-page"
820
- });
821
- }
822
- }
823
-
824
- const service$1 = axios.create({
825
- timeout: 60 * 1000,
826
- headers: {
827
- 'Content-Type': 'application/json; charset=utf-8',
828
- },
829
- });
830
-
831
- service$1.interceptors.request.use(
832
- config => {
833
- config.headers.accessToken = window.$CCDK.CCToken.getToken();
834
- config.headers.requestId = window.$CCDK.CCUtils.getUuid();
835
- config.headers.requestIdProducer = "browser";
836
- return config
837
- },
838
- error => {
839
- Promise.reject(error);
840
- }
841
- );
842
-
843
-
844
- service$1.interceptors.response.use(
845
- response => {
846
- if (response.data.result) {
847
- // 上报日志
848
- reportInfo(response);
849
- return response.data
850
- } else {
851
- reportError(response);
852
- return Promise.reject(response)
853
- }
854
- },
855
- error => {
856
- // 上报错误日志
857
- if (error) {
858
- reportError(error.response);
859
- }
860
- return Promise.reject(error)
861
- }
862
- );
863
-
864
-
865
- var http = {
866
- get: (url, data = {}, responseType = '') => {
867
- return service$1({
868
- url: url,
869
- method: 'get',
870
- params: data,
871
- responseType: responseType
872
- })
873
- },
874
- post: (url, data = {}, responseType = '') => {
875
- return service$1({
876
- url: url,
877
- method: 'post',
878
- data: data,
879
- responseType: responseType
880
- })
881
- },
869
+ /**
870
+ * 错误日志上报
871
+ * @param {object} response 响应体
872
+ */
873
+ function reportError(response) {
874
+ if ("1" === window.Glod['CC_LOG_LEVEL'] || "2" === window.Glod['CC_LOG_LEVEL']) {
875
+ window.$CCDK.CCLog.reportLog(window.Glod['ccex-log'] + "/ccerrorlog", response, "error", { serviceName: "lightning-custom-page" });
876
+ }
877
+ }
878
+ /**
879
+ * 常规日志上报
880
+ * @param {object} response 响应体
881
+ */
882
+ function reportInfo(response) {
883
+ if ("2" === window.Glod['CC_LOG_LEVEL']) {
884
+ window.$CCDK.CCLog.reportLog(window.Glod['ccex-log'] + "/systeminfolog", response, "info", {
885
+ serviceName: "lightning-custom-page"
886
+ });
887
+ }
888
+ }
889
+
890
+ const service$1 = axios.create({
891
+ timeout: 60 * 1000,
892
+ headers: {
893
+ 'Content-Type': 'application/json; charset=utf-8',
894
+ },
895
+ });
896
+
897
+ service$1.interceptors.request.use(
898
+ config => {
899
+ config.headers.accessToken = window.$CCDK.CCToken.getToken();
900
+ config.headers.requestId = window.$CCDK.CCUtils.getUuid();
901
+ config.headers.requestIdProducer = "browser";
902
+ return config
903
+ },
904
+ error => {
905
+ Promise.reject(error);
906
+ }
907
+ );
908
+
909
+
910
+ service$1.interceptors.response.use(
911
+ response => {
912
+ if (response.data.result) {
913
+ // 上报日志
914
+ reportInfo(response);
915
+ return response.data
916
+ } else {
917
+ reportError(response);
918
+ return Promise.reject(response)
919
+ }
920
+ },
921
+ error => {
922
+ // 上报错误日志
923
+ if (error) {
924
+ reportError(error.response);
925
+ }
926
+ return Promise.reject(error)
927
+ }
928
+ );
929
+
930
+
931
+ var http = {
932
+ get: (url, data = {}, responseType = '') => {
933
+ return service$1({
934
+ url: url,
935
+ method: 'get',
936
+ params: data,
937
+ responseType: responseType
938
+ })
939
+ },
940
+ post: (url, data = {}, responseType = '') => {
941
+ return service$1({
942
+ url: url,
943
+ method: 'post',
944
+ data: data,
945
+ responseType: responseType
946
+ })
947
+ },
882
948
  };
883
949
 
884
- /**
885
- * 请求common接口
886
- * @param {string} className 类名
887
- * @param {string} methodName 方法名
888
- * @param {Array} params 参数集合
889
- * @returns {Promise}
890
- */
891
- function post$1(className, methodName, params) {
892
- return http.post(window.Glod['ccex-apitsf'] + '/api/openCall/common', { className, methodName, params });
950
+ /**
951
+ * 请求common接口
952
+ * @param {string} className 类名
953
+ * @param {string} methodName 方法名
954
+ * @param {Array} params 参数集合
955
+ * @returns {Promise}
956
+ */
957
+ function post$1(className, methodName, params) {
958
+ return http.post(window.Glod['ccex-apitsf'] + '/api/openCall/common', { className, methodName, params });
893
959
  }
894
960
 
895
961
  var CCCommon = /*#__PURE__*/Object.freeze({
@@ -897,33 +963,33 @@ var CCCommon = /*#__PURE__*/Object.freeze({
897
963
  post: post$1
898
964
  });
899
965
 
900
- /**
901
- * 获取基础url
902
- * @returns 基础地址
903
- */
904
- function getBaseUrl() {
905
- return window.gw.BASE_URL || window.Glod.BASE_URL || (window.location.origin + "/ccdomaingateway")
906
- }
907
- /**
908
- * 获取网关对象
909
- * @returns 网关对象
910
- */
911
- function getGw() {
912
- return window.gw || window.Glod;
913
- }
914
- /**
915
- * 获取服务对象
916
- * @returns 服务对象
917
- */
918
- function getSvc() {
919
- return window.Glod;
920
- }
921
- /**
922
- * 获取静态资源的访问地址
923
- * @returns 静态资源访问地址
924
- */
925
- function getCDNUrl() {
926
- return window.Glod.CDN_URL;
966
+ /**
967
+ * 获取基础url
968
+ * @returns 基础地址
969
+ */
970
+ function getBaseUrl() {
971
+ return window.gw.BASE_URL || window.Glod.BASE_URL || (window.location.origin + "/ccdomaingateway")
972
+ }
973
+ /**
974
+ * 获取网关对象
975
+ * @returns 网关对象
976
+ */
977
+ function getGw() {
978
+ return window.gw || window.Glod;
979
+ }
980
+ /**
981
+ * 获取服务对象
982
+ * @returns 服务对象
983
+ */
984
+ function getSvc() {
985
+ return window.Glod;
986
+ }
987
+ /**
988
+ * 获取静态资源的访问地址
989
+ * @returns 静态资源访问地址
990
+ */
991
+ function getCDNUrl() {
992
+ return window.Glod.CDN_URL;
927
993
  }
928
994
 
929
995
  var CCConfig = /*#__PURE__*/Object.freeze({
@@ -934,70 +1000,70 @@ var CCConfig = /*#__PURE__*/Object.freeze({
934
1000
  getCDNUrl: getCDNUrl
935
1001
  });
936
1002
 
937
- /**
938
- * 加密
939
- * @param {String} data 数据
940
- * @param {String} key 密钥
941
- * @param {String} iv 偏移量
942
- * @returns
943
- */
944
- function getAesString(data, key, iv) {
945
- key = CryptoJS.enc.Utf8.parse(key);
946
- iv = CryptoJS.enc.Utf8.parse(iv);
947
- let encrypted = CryptoJS.AES.encrypt(data, key, {
948
- iv: iv,
949
- padding: CryptoJS.pad.Pkcs7,
950
- });
951
- return encrypted.toString(); //返回的是base64格式的密文
952
- }
953
-
954
- /**
955
- * 解密
956
- * @param {String} encrypted 密文
957
- * @param {String} key 密钥
958
- * @param {String} iv 偏移量
959
- * @returns
960
- */
961
- function getDAesString(encrypted, key, iv) {
962
- key = CryptoJS.enc.Utf8.parse(key);
963
- iv = CryptoJS.enc.Utf8.parse(iv);
964
- let decrypted = CryptoJS.AES.decrypt(encrypted, key, {
965
- iv: iv,
966
- padding: CryptoJS.pad.Pkcs7,
967
- });
968
- return decrypted.toString(CryptoJS.enc.Utf8);
969
- }
970
-
971
- /**
972
- * CryptoJS加密
973
- * @param {String} data 数据
974
- * @param {String} key 密钥
975
- * @param {String} iv 偏移量
976
- * @returns 加密的数据
977
- */
978
- function encrypt(data, key = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", iv = 1) {
979
- data = JSON.stringify(data);
980
- var encrypted = getAesString(data, key, iv); //密文
981
- return encrypted;
982
- }
983
-
984
- /**
985
- * CryptoJS解密
986
- * @param {String} data 加密的数据
987
- * @param {String} key 密钥
988
- * @param {String} iv 偏移量
989
- * @returns 解密的数据
990
- */
991
- function decrypt(data, key = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", iv = 1) {
992
- try {
993
- var decryptedStr = getDAesString(data, key, iv);
994
- if (!decryptedStr) return null
995
- return JSON.parse(decryptedStr);
996
- } catch (error) {
997
- // 解密密码错误
998
- console.trace("Decryption password error", error);
999
- return null;
1000
- }
1003
+ /**
1004
+ * 加密
1005
+ * @param {String} data 数据
1006
+ * @param {String} key 密钥
1007
+ * @param {String} iv 偏移量
1008
+ * @returns
1009
+ */
1010
+ function getAesString(data, key, iv) {
1011
+ key = CryptoJS.enc.Utf8.parse(key);
1012
+ iv = CryptoJS.enc.Utf8.parse(iv);
1013
+ let encrypted = CryptoJS.AES.encrypt(data, key, {
1014
+ iv: iv,
1015
+ padding: CryptoJS.pad.Pkcs7,
1016
+ });
1017
+ return encrypted.toString(); //返回的是base64格式的密文
1018
+ }
1019
+
1020
+ /**
1021
+ * 解密
1022
+ * @param {String} encrypted 密文
1023
+ * @param {String} key 密钥
1024
+ * @param {String} iv 偏移量
1025
+ * @returns
1026
+ */
1027
+ function getDAesString(encrypted, key, iv) {
1028
+ key = CryptoJS.enc.Utf8.parse(key);
1029
+ iv = CryptoJS.enc.Utf8.parse(iv);
1030
+ let decrypted = CryptoJS.AES.decrypt(encrypted, key, {
1031
+ iv: iv,
1032
+ padding: CryptoJS.pad.Pkcs7,
1033
+ });
1034
+ return decrypted.toString(CryptoJS.enc.Utf8);
1035
+ }
1036
+
1037
+ /**
1038
+ * CryptoJS加密
1039
+ * @param {String} data 数据
1040
+ * @param {String} key 密钥
1041
+ * @param {String} iv 偏移量
1042
+ * @returns 加密的数据
1043
+ */
1044
+ function encrypt(data, key = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", iv = 1) {
1045
+ data = JSON.stringify(data);
1046
+ var encrypted = getAesString(data, key, iv); //密文
1047
+ return encrypted;
1048
+ }
1049
+
1050
+ /**
1051
+ * CryptoJS解密
1052
+ * @param {String} data 加密的数据
1053
+ * @param {String} key 密钥
1054
+ * @param {String} iv 偏移量
1055
+ * @returns 解密的数据
1056
+ */
1057
+ function decrypt(data, key = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", iv = 1) {
1058
+ try {
1059
+ var decryptedStr = getDAesString(data, key, iv);
1060
+ if (!decryptedStr) return null
1061
+ return JSON.parse(decryptedStr);
1062
+ } catch (error) {
1063
+ // 解密密码错误
1064
+ console.trace("Decryption password error", error);
1065
+ return null;
1066
+ }
1001
1067
  }
1002
1068
 
1003
1069
  var Crypto = /*#__PURE__*/Object.freeze({
@@ -1006,76 +1072,76 @@ var Crypto = /*#__PURE__*/Object.freeze({
1006
1072
  decrypt: decrypt
1007
1073
  });
1008
1074
 
1009
- const service = axios.create({
1010
- timeout: 60000,
1011
- headers: {
1012
- 'Content-Type': 'application/json; charset=utf-8',
1013
- },
1014
- });
1015
-
1016
- service.interceptors.request.use(
1017
- config => {
1018
- config.headers['accessToken'] = window.$CCDK.CCToken.getToken();
1019
- return config
1020
- },
1021
- error => {
1022
- Promise.reject(error);
1023
- }
1024
- );
1025
-
1026
- service.interceptors.response.use(
1027
- response => {
1028
- const code = response.data.code || 200;
1029
- if (code !== 200) {
1030
- return Promise.reject(null == response.data.msg ? "unknown anomaly" : response.data.msg)
1031
- } else {
1032
- return response.data
1033
- }
1034
- },
1035
- error => {
1036
- return Promise.reject(error)
1037
- }
1038
- );
1039
- function get(url, data = {}, responseType = '') {
1040
- return service({
1041
- url: url,
1042
- method: 'get',
1043
- params: data,
1044
- responseType: responseType
1045
- })
1046
- }
1047
-
1048
- function post(url, data = {}, responseType = '') {
1049
- return service({
1050
- url: url,
1051
- method: 'post',
1052
- data: data,
1053
- responseType: responseType
1054
- })
1055
- }
1056
-
1057
- function put(url, data = {}) {
1058
- return service({
1059
- url: url,
1060
- method: 'put',
1061
- data: data
1062
- })
1063
- }
1064
-
1065
- function postParams(url, data = {}) {
1066
- return service({
1067
- url: url,
1068
- method: 'post',
1069
- params: data
1070
- })
1071
- }
1072
-
1073
- function patch(url, data = {}) {
1074
- return service({
1075
- url: url,
1076
- method: 'patch',
1077
- data: data
1078
- })
1075
+ const service = axios.create({
1076
+ timeout: 60000,
1077
+ headers: {
1078
+ 'Content-Type': 'application/json; charset=utf-8',
1079
+ },
1080
+ });
1081
+
1082
+ service.interceptors.request.use(
1083
+ config => {
1084
+ config.headers['accessToken'] = window.$CCDK.CCToken.getToken();
1085
+ return config
1086
+ },
1087
+ error => {
1088
+ Promise.reject(error);
1089
+ }
1090
+ );
1091
+
1092
+ service.interceptors.response.use(
1093
+ response => {
1094
+ const code = response.data.code || 200;
1095
+ if (code !== 200) {
1096
+ return Promise.reject(null == response.data.msg ? "unknown anomaly" : response.data.msg)
1097
+ } else {
1098
+ return response.data
1099
+ }
1100
+ },
1101
+ error => {
1102
+ return Promise.reject(error)
1103
+ }
1104
+ );
1105
+ function get(url, data = {}, responseType = '') {
1106
+ return service({
1107
+ url: url,
1108
+ method: 'get',
1109
+ params: data,
1110
+ responseType: responseType
1111
+ })
1112
+ }
1113
+
1114
+ function post(url, data = {}, responseType = '') {
1115
+ return service({
1116
+ url: url,
1117
+ method: 'post',
1118
+ data: data,
1119
+ responseType: responseType
1120
+ })
1121
+ }
1122
+
1123
+ function put(url, data = {}) {
1124
+ return service({
1125
+ url: url,
1126
+ method: 'put',
1127
+ data: data
1128
+ })
1129
+ }
1130
+
1131
+ function postParams(url, data = {}) {
1132
+ return service({
1133
+ url: url,
1134
+ method: 'post',
1135
+ params: data
1136
+ })
1137
+ }
1138
+
1139
+ function patch(url, data = {}) {
1140
+ return service({
1141
+ url: url,
1142
+ method: 'patch',
1143
+ data: data
1144
+ })
1079
1145
  }
1080
1146
 
1081
1147
  var CCHttp = /*#__PURE__*/Object.freeze({
@@ -1087,64 +1153,64 @@ var CCHttp = /*#__PURE__*/Object.freeze({
1087
1153
  postParams: postParams
1088
1154
  });
1089
1155
 
1090
- /**
1091
- * 下载js,并挂载到document上
1092
- * @param {string} src js下载路径
1093
- * @param {object} scriptOption script配置参数
1094
- * @returns
1095
- */
1096
- function loadJs(src, scriptOption) {
1097
- return new Promise((resolve, reject) => {
1098
- let scriptTemp = document.createElement('script');
1099
- if (scriptOption) {
1100
- Object.assign(scriptTemp, scriptOption);
1101
- }
1102
- scriptTemp.type = "text/javascript";
1103
- scriptTemp.src = src;
1104
- document.body.appendChild(scriptTemp);
1105
-
1106
- scriptTemp.onload = () => {
1107
- resolve();
1108
- };
1109
- scriptTemp.onerror = () => {
1110
- reject();
1111
- };
1112
- })
1113
- }
1114
- /**
1115
- * 创建加载js组件
1116
- */
1117
- function createLoadJsComponent() {
1118
- Vue.component('cc-load-script', {
1119
- render: function (createElement) {
1120
- var self = this;
1121
- return createElement('script', {
1122
- attrs: {
1123
- type: 'text/javascript',
1124
- src: this.src
1125
- },
1126
- on: {
1127
- load: function (event) {
1128
- self.$emit('load', event);
1129
- },
1130
- error: function (event) {
1131
- self.$emit('error', event);
1132
- },
1133
- readystatechange: function (event) {
1134
- if (this.readyState == 'complete') {
1135
- self.$emit('load', event);
1136
- }
1137
- }
1138
- }
1139
- });
1140
- },
1141
- props: {
1142
- src: {
1143
- type: String,
1144
- required: true
1145
- }
1146
- }
1147
- });
1156
+ /**
1157
+ * 下载js,并挂载到document上
1158
+ * @param {string} src js下载路径
1159
+ * @param {object} scriptOption script配置参数
1160
+ * @returns
1161
+ */
1162
+ function loadJs(src, scriptOption) {
1163
+ return new Promise((resolve, reject) => {
1164
+ let scriptTemp = document.createElement('script');
1165
+ if (scriptOption) {
1166
+ Object.assign(scriptTemp, scriptOption);
1167
+ }
1168
+ scriptTemp.type = "text/javascript";
1169
+ scriptTemp.src = src;
1170
+ document.body.appendChild(scriptTemp);
1171
+
1172
+ scriptTemp.onload = () => {
1173
+ resolve();
1174
+ };
1175
+ scriptTemp.onerror = () => {
1176
+ reject();
1177
+ };
1178
+ })
1179
+ }
1180
+ /**
1181
+ * 创建加载js组件
1182
+ */
1183
+ function createLoadJsComponent() {
1184
+ Vue.component('cc-load-script', {
1185
+ render: function (createElement) {
1186
+ var self = this;
1187
+ return createElement('script', {
1188
+ attrs: {
1189
+ type: 'text/javascript',
1190
+ src: this.src
1191
+ },
1192
+ on: {
1193
+ load: function (event) {
1194
+ self.$emit('load', event);
1195
+ },
1196
+ error: function (event) {
1197
+ self.$emit('error', event);
1198
+ },
1199
+ readystatechange: function (event) {
1200
+ if (this.readyState == 'complete') {
1201
+ self.$emit('load', event);
1202
+ }
1203
+ }
1204
+ }
1205
+ });
1206
+ },
1207
+ props: {
1208
+ src: {
1209
+ type: String,
1210
+ required: true
1211
+ }
1212
+ }
1213
+ });
1148
1214
  }
1149
1215
 
1150
1216
  var CCLoad = /*#__PURE__*/Object.freeze({
@@ -1153,201 +1219,201 @@ var CCLoad = /*#__PURE__*/Object.freeze({
1153
1219
  createLoadJsComponent: createLoadJsComponent
1154
1220
  });
1155
1221
 
1156
- /**
1157
- * 获取日志基础信息
1158
- * @returns 日志基础信息
1159
- */
1160
- function getBaseInfo() {
1161
- let userInfo = window.$CCDK.CCUser.getUserInfo();
1162
- let old = {
1163
- // 用户名,使用登录账号
1164
- "userName": userInfo.loginName || "unknown user",
1165
- // 用户id
1166
- "userId": userInfo.userId,
1167
- // 组织id
1168
- "orgId": userInfo.orgId,
1169
- // 组织名称
1170
- "orgName": userInfo.orgName,
1171
- // 服务名称
1172
- "serviceName": "unknown application",
1173
- // 记录类型:platform平台日志,dev开发者日志
1174
- "recordType": "platform",
1175
- // 日志类型
1176
- "logType": "front",
1177
- // 发生时间
1178
- "operateTime": (new Date()).valueOf(),
1179
- // 发生时间的str格式:yyyy-MM-dd HH:mm:ss
1180
- "operateTimeStr": window.$CCDK.CCUtils.getNowFormatDate(),
1181
- // 日志标识码,没有这个标识码,不能上传
1182
- "cccode": "hidden",
1183
- // 日志显示级别默认2
1184
- "displayLevel": "2",
1185
- };
1186
- return old
1187
- }
1188
- /**
1189
- * 获取网络异常信息
1190
- * @param {object} response 网络请求响应体
1191
- * @returns 请求体信息
1192
- */
1193
- function getHttpErrorInfo(error = {}) {
1194
- let { config = {}, data = {} } = error;
1195
- if (config) {
1196
- return {
1197
- // 请求地址url
1198
- "requestUrl": config.baseURL + config.url,
1199
- // 请求id
1200
- "requestId": config.headers ? config.headers.requestId : window.$CCDK.CCUtils.getUuid(),
1201
- // 请求id类型
1202
- "requestIdProducer": config.headers ? config.headers.requestIdProducer : "",
1203
- // 请求体
1204
- "requestParameter": config.data,
1205
- // 错误描述
1206
- "errorMessage": error.message || data.returnInfo || "Unknown Error",
1207
- // 请求结果状态
1208
- "requestResult": "Fail",
1209
- // 日志级别
1210
- "errorLevel": "2",
1211
- // 堆栈信息
1212
- "printStackTraceInfo": (error.message || data.returnInfo || "Unknown Error") + "\n" + config.data,
1213
- }
1214
- } else {
1215
- return {}
1216
- }
1217
- }
1218
-
1219
-
1220
- /**
1221
- * 获取网络信息
1222
- * @param {object} response 网络请求响应体
1223
- * @returns 请求体信息
1224
- */
1225
- function getHttpInfo(response) {
1226
- if (response) {
1227
- if (window.performance) {
1228
- // 通过性能接口精确测量接口用时
1229
- let per = performance.getEntriesByName(response.request.responseURL, "resource");
1230
- if (per.length > 0) {
1231
- let index = per.length - 1;
1232
- response.spendTime = (per[index].fetchStart > 0) ? (per[index].responseEnd - per[index].fetchStart) : "0";
1233
- }
1234
- }
1235
- return {
1236
- // 接口用时
1237
- "spendTime": response.spendTime || "0",
1238
- // 请求地址url
1239
- "requestUrl": response.request ? response.request.responseURL : "",
1240
- // 请求id
1241
- "requestId": response.config.headers ? response.config.headers.requestId : window.$CCDK.CCUtils.getUuid(),
1242
- // 请求id类型
1243
- "requestIdProducer": response.config.headers ? response.config.headers.requestIdProducer : "",
1244
- // 请求体
1245
- "requestParameter": response.config.data,
1246
- // 错误描述
1247
- "infoMessage": response.request.responseURL + ". took:" + (response.spendTime || 0).toFixed(0) + "ms" + "\n" + (response.config.data || ''),
1248
- // 请求结果状态
1249
- "requestResult": response.data.result ? "Success" : "Fail",
1250
- // 日志类型:info,debug
1251
- "infoType": "info",
1252
- }
1253
- } else {
1254
- return {}
1255
- }
1256
- }
1257
-
1258
- /**
1259
- * 上报日志
1260
- * @param {string} url 请求地址
1261
- * @param {object} response 响应信息
1262
- * @param {string} type 日志类型,info,debug,error
1263
- * @param {object} logInfo 日志信息
1264
- */
1265
- function reportLog(url, response, type = "info", logInfo = {}) {
1266
- // 某些情况下获取不到用户信息,可能是刚登陆,获取用户信息接口还没返回
1267
- let userInfo = getBaseInfo();
1268
- if ("unknown user" != userInfo.userName && userInfo.userName) {
1269
- axios.post(url,
1270
- {
1271
- ...userInfo,
1272
- ...(type === "info" ? getHttpInfo(response) : getHttpErrorInfo(response)),
1273
- ...logInfo
1274
- });
1275
- }
1276
-
1277
- }
1278
-
1279
-
1280
- /**
1281
- * 批量上报日志
1282
- * @param {string} url 请求地址
1283
- * @param {object} response 响应信息
1284
- * @param {string} type 日志类型,info,debug,error
1285
- * @param {object} logInfo 日志信息
1286
- */
1287
- function batchReportLog(url, response, type = "info", logInfo = []) {
1288
- // 某些情况下获取不到用户信息,可能是刚登陆,获取用户信息接口还没返回
1289
- let userInfo = getBaseInfo();
1290
- if ("unknown user" != userInfo.userName && userInfo.userName && logInfo.length > 0) {
1291
- let datas = logInfo.map(info => {
1292
- return {
1293
- ...userInfo,
1294
- ...(type === "info" ? getHttpInfo(response) : getHttpErrorInfo(response)),
1295
- ...info
1296
- }
1297
- });
1298
- axios.post(url, datas);
1299
- }
1300
-
1301
- }
1302
-
1303
- /**
1304
- * 上报info日志
1305
- * @param {object} logInfo 日志信息
1306
- * @param {object} response axios响应信息
1307
- */
1308
- function reportInfoLog(logInfo, response) {
1309
- logInfo.recordType = "dev";
1310
- reportLog(window.Glod['ccex-log'] + "/systeminfolog", response, "info", logInfo);
1311
- }
1312
- /**
1313
- * 上报错误信息
1314
- * @param {object} logInfo 日志信息
1315
- * @param {object} response axios响应信息
1316
- */
1317
- function reportErrorLog(logInfo, response) {
1318
- logInfo.recordType = "dev";
1319
- reportLog(window.Glod['ccex-log'] + "/ccerrorlog", response, "error", logInfo);
1320
- }
1321
-
1322
-
1323
- /**
1324
- * CC错误日志上报:这个api目前没有使用的场景
1325
- * @param {object} error 响应体
1326
- * @param {object} options 配置信息
1327
- */
1328
- function reportCCError(error, options = { serviceName: "lightning-main" }) {
1329
- if (process.env.NODE_ENV == 'production' && "1" === window.Glod['CC_LOG_LEVEL'] || "2" === window.Glod['CC_LOG_LEVEL']) {
1330
- window.$CCDK.CCLog.reportLog(window.Glod['ccex-log'] + "/ccerrorlog", error, "error", options);
1331
- }
1332
- }
1333
- /**
1334
- * CC常规日志上报:这个api目前没有使用的场景
1335
- * @param {object} response 响应体
1336
- * @param {object} options 配置信息
1337
- */
1338
- function reportCCInfo(response, options = { serviceName: "lightning-main" }) {
1339
- if (process.env.NODE_ENV == 'production' && "2" === window.Glod['CC_LOG_LEVEL']) {
1340
- if (response.config.data) {
1341
- try {
1342
- let data = JSON.parse(response.config.data);
1343
- if (data.head && data.head.accessToken) {
1344
- data.head.accessToken = "******";
1345
- response.config.data = JSON.stringify(data);
1346
- }
1347
- } catch (e) { }
1348
- }
1349
- window.$CCDK.CCLog.reportLog(window.Glod['ccex-log'] + "/systeminfolog", response, "info", options);
1350
- }
1222
+ /**
1223
+ * 获取日志基础信息
1224
+ * @returns 日志基础信息
1225
+ */
1226
+ function getBaseInfo() {
1227
+ let userInfo = window.$CCDK.CCUser.getUserInfo();
1228
+ let old = {
1229
+ // 用户名,使用登录账号
1230
+ "userName": userInfo.loginName || "unknown user",
1231
+ // 用户id
1232
+ "userId": userInfo.userId,
1233
+ // 组织id
1234
+ "orgId": userInfo.orgId,
1235
+ // 组织名称
1236
+ "orgName": userInfo.orgName,
1237
+ // 服务名称
1238
+ "serviceName": "unknown application",
1239
+ // 记录类型:platform平台日志,dev开发者日志
1240
+ "recordType": "platform",
1241
+ // 日志类型
1242
+ "logType": "front",
1243
+ // 发生时间
1244
+ "operateTime": (new Date()).valueOf(),
1245
+ // 发生时间的str格式:yyyy-MM-dd HH:mm:ss
1246
+ "operateTimeStr": window.$CCDK.CCUtils.getNowFormatDate(),
1247
+ // 日志标识码,没有这个标识码,不能上传
1248
+ "cccode": "hidden",
1249
+ // 日志显示级别默认2
1250
+ "displayLevel": "2",
1251
+ };
1252
+ return old
1253
+ }
1254
+ /**
1255
+ * 获取网络异常信息
1256
+ * @param {object} response 网络请求响应体
1257
+ * @returns 请求体信息
1258
+ */
1259
+ function getHttpErrorInfo(error = {}) {
1260
+ let { config = {}, data = {} } = error;
1261
+ if (config) {
1262
+ return {
1263
+ // 请求地址url
1264
+ "requestUrl": config.baseURL + config.url,
1265
+ // 请求id
1266
+ "requestId": config.headers ? config.headers.requestId : window.$CCDK.CCUtils.getUuid(),
1267
+ // 请求id类型
1268
+ "requestIdProducer": config.headers ? config.headers.requestIdProducer : "",
1269
+ // 请求体
1270
+ "requestParameter": config.data,
1271
+ // 错误描述
1272
+ "errorMessage": error.message || data.returnInfo || "Unknown Error",
1273
+ // 请求结果状态
1274
+ "requestResult": "Fail",
1275
+ // 日志级别
1276
+ "errorLevel": "2",
1277
+ // 堆栈信息
1278
+ "printStackTraceInfo": (error.message || data.returnInfo || "Unknown Error") + "\n" + config.data,
1279
+ }
1280
+ } else {
1281
+ return {}
1282
+ }
1283
+ }
1284
+
1285
+
1286
+ /**
1287
+ * 获取网络信息
1288
+ * @param {object} response 网络请求响应体
1289
+ * @returns 请求体信息
1290
+ */
1291
+ function getHttpInfo(response) {
1292
+ if (response) {
1293
+ if (window.performance) {
1294
+ // 通过性能接口精确测量接口用时
1295
+ let per = performance.getEntriesByName(response.request.responseURL, "resource");
1296
+ if (per.length > 0) {
1297
+ let index = per.length - 1;
1298
+ response.spendTime = (per[index].fetchStart > 0) ? (per[index].responseEnd - per[index].fetchStart) : "0";
1299
+ }
1300
+ }
1301
+ return {
1302
+ // 接口用时
1303
+ "spendTime": response.spendTime || "0",
1304
+ // 请求地址url
1305
+ "requestUrl": response.request ? response.request.responseURL : "",
1306
+ // 请求id
1307
+ "requestId": response.config.headers ? response.config.headers.requestId : window.$CCDK.CCUtils.getUuid(),
1308
+ // 请求id类型
1309
+ "requestIdProducer": response.config.headers ? response.config.headers.requestIdProducer : "",
1310
+ // 请求体
1311
+ "requestParameter": response.config.data,
1312
+ // 错误描述
1313
+ "infoMessage": response.request.responseURL + ". took:" + (response.spendTime || 0).toFixed(0) + "ms" + "\n" + (response.config.data || ''),
1314
+ // 请求结果状态
1315
+ "requestResult": response.data.result ? "Success" : "Fail",
1316
+ // 日志类型:info,debug
1317
+ "infoType": "info",
1318
+ }
1319
+ } else {
1320
+ return {}
1321
+ }
1322
+ }
1323
+
1324
+ /**
1325
+ * 上报日志
1326
+ * @param {string} url 请求地址
1327
+ * @param {object} response 响应信息
1328
+ * @param {string} type 日志类型,info,debug,error
1329
+ * @param {object} logInfo 日志信息
1330
+ */
1331
+ function reportLog(url, response, type = "info", logInfo = {}) {
1332
+ // 某些情况下获取不到用户信息,可能是刚登陆,获取用户信息接口还没返回
1333
+ let userInfo = getBaseInfo();
1334
+ if ("unknown user" != userInfo.userName && userInfo.userName) {
1335
+ axios.post(url,
1336
+ {
1337
+ ...userInfo,
1338
+ ...(type === "info" ? getHttpInfo(response) : getHttpErrorInfo(response)),
1339
+ ...logInfo
1340
+ });
1341
+ }
1342
+
1343
+ }
1344
+
1345
+
1346
+ /**
1347
+ * 批量上报日志
1348
+ * @param {string} url 请求地址
1349
+ * @param {object} response 响应信息
1350
+ * @param {string} type 日志类型,info,debug,error
1351
+ * @param {object} logInfo 日志信息
1352
+ */
1353
+ function batchReportLog(url, response, type = "info", logInfo = []) {
1354
+ // 某些情况下获取不到用户信息,可能是刚登陆,获取用户信息接口还没返回
1355
+ let userInfo = getBaseInfo();
1356
+ if ("unknown user" != userInfo.userName && userInfo.userName && logInfo.length > 0) {
1357
+ let datas = logInfo.map(info => {
1358
+ return {
1359
+ ...userInfo,
1360
+ ...(type === "info" ? getHttpInfo(response) : getHttpErrorInfo(response)),
1361
+ ...info
1362
+ }
1363
+ });
1364
+ axios.post(url, datas);
1365
+ }
1366
+
1367
+ }
1368
+
1369
+ /**
1370
+ * 上报info日志
1371
+ * @param {object} logInfo 日志信息
1372
+ * @param {object} response axios响应信息
1373
+ */
1374
+ function reportInfoLog(logInfo, response) {
1375
+ logInfo.recordType = "dev";
1376
+ reportLog(window.Glod['ccex-log'] + "/systeminfolog", response, "info", logInfo);
1377
+ }
1378
+ /**
1379
+ * 上报错误信息
1380
+ * @param {object} logInfo 日志信息
1381
+ * @param {object} response axios响应信息
1382
+ */
1383
+ function reportErrorLog(logInfo, response) {
1384
+ logInfo.recordType = "dev";
1385
+ reportLog(window.Glod['ccex-log'] + "/ccerrorlog", response, "error", logInfo);
1386
+ }
1387
+
1388
+
1389
+ /**
1390
+ * CC错误日志上报:这个api目前没有使用的场景
1391
+ * @param {object} error 响应体
1392
+ * @param {object} options 配置信息
1393
+ */
1394
+ function reportCCError(error, options = { serviceName: "lightning-main" }) {
1395
+ if (process.env.NODE_ENV == 'production' && "1" === window.Glod['CC_LOG_LEVEL'] || "2" === window.Glod['CC_LOG_LEVEL']) {
1396
+ window.$CCDK.CCLog.reportLog(window.Glod['ccex-log'] + "/ccerrorlog", error, "error", options);
1397
+ }
1398
+ }
1399
+ /**
1400
+ * CC常规日志上报:这个api目前没有使用的场景
1401
+ * @param {object} response 响应体
1402
+ * @param {object} options 配置信息
1403
+ */
1404
+ function reportCCInfo(response, options = { serviceName: "lightning-main" }) {
1405
+ if (process.env.NODE_ENV == 'production' && "2" === window.Glod['CC_LOG_LEVEL']) {
1406
+ if (response.config.data) {
1407
+ try {
1408
+ let data = JSON.parse(response.config.data);
1409
+ if (data.head && data.head.accessToken) {
1410
+ data.head.accessToken = "******";
1411
+ response.config.data = JSON.stringify(data);
1412
+ }
1413
+ } catch (e) { }
1414
+ }
1415
+ window.$CCDK.CCLog.reportLog(window.Glod['ccex-log'] + "/systeminfolog", response, "info", options);
1416
+ }
1351
1417
  }
1352
1418
 
1353
1419
  var CCLog = /*#__PURE__*/Object.freeze({
@@ -1360,123 +1426,123 @@ var CCLog = /*#__PURE__*/Object.freeze({
1360
1426
  batchReportLog: batchReportLog
1361
1427
  });
1362
1428
 
1363
- // 存储所有菜单标识
1364
- const ALL_MENU_LIST = 'all_menu_list';
1365
- // 存储当前选中的菜单
1366
- const CURRENT_MENU = 'current_menu';
1367
-
1368
- /**
1369
- * 获取全部菜单
1370
- */
1371
- function getAllMenu() {
1372
- let data = localStorage.getItem(Crypto.encrypt(ALL_MENU_LIST));
1373
- if (data) {
1374
- return JSON.parse(data)
1375
- }
1376
- return []
1377
- }
1378
-
1379
- /**
1380
- * 设置全部菜单
1381
- * @param {object} data 菜单集合
1382
- */
1383
- function setAllMenu(data = []) {
1384
- if (data) {
1385
- localStorage.setItem(Crypto.encrypt(ALL_MENU_LIST), JSON.stringify(data));
1386
- }
1387
- }
1388
-
1389
- /**
1390
- * 缓存当前选中菜单对象
1391
- * @param {object} data 菜单对象
1392
- */
1393
- function setCurrentMenu(data = {}) {
1394
- if (data) {
1395
- localStorage.setItem(Crypto.encrypt(CURRENT_MENU), JSON.stringify(data));
1396
- }
1397
- }
1398
-
1399
- /**
1400
- * 获取当前选中菜单对象
1401
- * @param {object} data 菜单对象
1402
- */
1403
- function getCurrentMenu() {
1404
- let data = localStorage.getItem(Crypto.encrypt(CURRENT_MENU));
1405
- if (data) {
1406
- return JSON.parse(data)
1407
- }
1408
- return {}
1409
- }
1410
-
1411
- /**
1412
- * 添加一个一级菜单
1413
- * @param {object} options 菜单配置
1414
- */
1415
- function addMenu1(options) {
1416
- window.$CCDK.CCBus.$emit('addMenu1', options);
1417
- }
1418
- /**
1419
- * 添加一个二级菜单
1420
- * @param {object} options 菜单配置
1421
- */
1422
- function addMenu2(options) {
1423
- window.$CCDK.CCBus.$emit('addMenu2', options);
1424
- }
1425
- /**
1426
- * 删除一个一级菜单
1427
- * @param {object} options 菜单配置
1428
- */
1429
- function deleteMenu1(options) {
1430
- window.$CCDK.CCBus.$emit('deleteMenu1', options);
1431
- }
1432
- /**
1433
- * 删除一个二级菜单
1434
- * @param {object} options 菜单配置
1435
- */
1436
- function deleteMenu2(options) {
1437
- window.$CCDK.CCBus.$emit('deleteMenu2', options);
1438
- }
1439
- /**
1440
- * 刷新一个一级菜单
1441
- * @param {object} options 菜单配置
1442
- */
1443
- function refreshMenu1(options) {
1444
- window.$CCDK.CCBus.$emit('refreshMenu1', options);
1445
- }
1446
- /**
1447
- * 刷新一个二级菜单
1448
- * @param {object} options 菜单配置
1449
- */
1450
- function refreshMenu2(options) {
1451
- window.$CCDK.CCBus.$emit('refreshMenu2', options);
1452
- }
1453
- /**
1454
- * 替换一个一级菜单
1455
- * @param {object} options 菜单配置
1456
- */
1457
- function replaceMenu1(options) {
1458
- window.$CCDK.CCBus.$emit('replaceMenu1', options);
1459
- }
1460
- /**
1461
- * 替换一个二级菜单
1462
- * @param {object} options 菜单配置
1463
- */
1464
- function replaceMenu2(options) {
1465
- window.$CCDK.CCBus.$emit('replaceMenu2', options);
1466
- }
1467
- /**
1468
- * 定位到已经打开的一级菜单
1469
- * @param {object} options 菜单配置
1470
- */
1471
- function reOpenMenu1(options) {
1472
- window.$CCDK.CCBus.$emit('reOpenMenu1', options);
1473
- }
1474
- /**
1475
- * 定位到当前一级菜单下已经打开的二级菜单(前提是当前在二级菜单下)
1476
- * @param {object} options 菜单配置
1477
- */
1478
- function reOpenMenu2(options) {
1479
- window.$CCDK.CCBus.$emit('reOpenMenu2', options);
1429
+ // 存储所有菜单标识
1430
+ const ALL_MENU_LIST = 'all_menu_list';
1431
+ // 存储当前选中的菜单
1432
+ const CURRENT_MENU = 'current_menu';
1433
+
1434
+ /**
1435
+ * 获取全部菜单
1436
+ */
1437
+ function getAllMenu() {
1438
+ let data = localStorage.getItem(Crypto.encrypt(ALL_MENU_LIST));
1439
+ if (data) {
1440
+ return JSON.parse(data)
1441
+ }
1442
+ return []
1443
+ }
1444
+
1445
+ /**
1446
+ * 设置全部菜单
1447
+ * @param {object} data 菜单集合
1448
+ */
1449
+ function setAllMenu(data = []) {
1450
+ if (data) {
1451
+ localStorage.setItem(Crypto.encrypt(ALL_MENU_LIST), JSON.stringify(data));
1452
+ }
1453
+ }
1454
+
1455
+ /**
1456
+ * 缓存当前选中菜单对象
1457
+ * @param {object} data 菜单对象
1458
+ */
1459
+ function setCurrentMenu(data = {}) {
1460
+ if (data) {
1461
+ localStorage.setItem(Crypto.encrypt(CURRENT_MENU), JSON.stringify(data));
1462
+ }
1463
+ }
1464
+
1465
+ /**
1466
+ * 获取当前选中菜单对象
1467
+ * @param {object} data 菜单对象
1468
+ */
1469
+ function getCurrentMenu() {
1470
+ let data = localStorage.getItem(Crypto.encrypt(CURRENT_MENU));
1471
+ if (data) {
1472
+ return JSON.parse(data)
1473
+ }
1474
+ return {}
1475
+ }
1476
+
1477
+ /**
1478
+ * 添加一个一级菜单
1479
+ * @param {object} options 菜单配置
1480
+ */
1481
+ function addMenu1(options) {
1482
+ window.$CCDK.CCBus.$emit('addMenu1', options);
1483
+ }
1484
+ /**
1485
+ * 添加一个二级菜单
1486
+ * @param {object} options 菜单配置
1487
+ */
1488
+ function addMenu2(options) {
1489
+ window.$CCDK.CCBus.$emit('addMenu2', options);
1490
+ }
1491
+ /**
1492
+ * 删除一个一级菜单
1493
+ * @param {object} options 菜单配置
1494
+ */
1495
+ function deleteMenu1(options) {
1496
+ window.$CCDK.CCBus.$emit('deleteMenu1', options);
1497
+ }
1498
+ /**
1499
+ * 删除一个二级菜单
1500
+ * @param {object} options 菜单配置
1501
+ */
1502
+ function deleteMenu2(options) {
1503
+ window.$CCDK.CCBus.$emit('deleteMenu2', options);
1504
+ }
1505
+ /**
1506
+ * 刷新一个一级菜单
1507
+ * @param {object} options 菜单配置
1508
+ */
1509
+ function refreshMenu1(options) {
1510
+ window.$CCDK.CCBus.$emit('refreshMenu1', options);
1511
+ }
1512
+ /**
1513
+ * 刷新一个二级菜单
1514
+ * @param {object} options 菜单配置
1515
+ */
1516
+ function refreshMenu2(options) {
1517
+ window.$CCDK.CCBus.$emit('refreshMenu2', options);
1518
+ }
1519
+ /**
1520
+ * 替换一个一级菜单
1521
+ * @param {object} options 菜单配置
1522
+ */
1523
+ function replaceMenu1(options) {
1524
+ window.$CCDK.CCBus.$emit('replaceMenu1', options);
1525
+ }
1526
+ /**
1527
+ * 替换一个二级菜单
1528
+ * @param {object} options 菜单配置
1529
+ */
1530
+ function replaceMenu2(options) {
1531
+ window.$CCDK.CCBus.$emit('replaceMenu2', options);
1532
+ }
1533
+ /**
1534
+ * 定位到已经打开的一级菜单
1535
+ * @param {object} options 菜单配置
1536
+ */
1537
+ function reOpenMenu1(options) {
1538
+ window.$CCDK.CCBus.$emit('reOpenMenu1', options);
1539
+ }
1540
+ /**
1541
+ * 定位到当前一级菜单下已经打开的二级菜单(前提是当前在二级菜单下)
1542
+ * @param {object} options 菜单配置
1543
+ */
1544
+ function reOpenMenu2(options) {
1545
+ window.$CCDK.CCBus.$emit('reOpenMenu2', options);
1480
1546
  }
1481
1547
 
1482
1548
  var CCMenu = /*#__PURE__*/Object.freeze({
@@ -1497,43 +1563,43 @@ var CCMenu = /*#__PURE__*/Object.freeze({
1497
1563
  getCurrentMenu: getCurrentMenu
1498
1564
  });
1499
1565
 
1500
- /**
1501
- * 消息提示框
1502
- * @param {string} text 提示文字,支持vhtml渲染
1503
- * @param {string} type 消息类别
1504
- * @param {number} duration 持续时间
1505
- * @param {boolean} showClose 是否显示消息关闭按钮
1506
- * @param {boolean} center 文字是否剧中
1507
- */
1508
- function showMessage(text, type = 'info', duration = 3000, showClose = false, center = false) {
1509
- Message({
1510
- message: text,
1511
- type,
1512
- duration,
1513
- showClose,
1514
- center
1515
- });
1516
- }
1517
- /**
1518
- * 提示确认框
1519
- * @param {string} text 提示信息
1520
- * @param {string} title 标题
1521
- * @param {object} options 配置信息
1522
- */
1523
- function showConfirm(text, title, options = {}, confirm = () => { }, reject = () => { }) {
1524
- MessageBox.confirm(text, title, options).then(() => {
1525
- confirm();
1526
- }).catch(() => {
1527
- reject();
1528
- });
1529
- }
1530
-
1531
- /**
1532
- * 提示消息框
1533
- * @param {object} options 配置信息
1534
- */
1535
- function showNotification(options = {}) {
1536
- Notification(options);
1566
+ /**
1567
+ * 消息提示框
1568
+ * @param {string} text 提示文字,支持vhtml渲染
1569
+ * @param {string} type 消息类别
1570
+ * @param {number} duration 持续时间
1571
+ * @param {boolean} showClose 是否显示消息关闭按钮
1572
+ * @param {boolean} center 文字是否剧中
1573
+ */
1574
+ function showMessage(text, type = 'info', duration = 3000, showClose = false, center = false) {
1575
+ Message({
1576
+ message: text,
1577
+ type,
1578
+ duration,
1579
+ showClose,
1580
+ center
1581
+ });
1582
+ }
1583
+ /**
1584
+ * 提示确认框
1585
+ * @param {string} text 提示信息
1586
+ * @param {string} title 标题
1587
+ * @param {object} options 配置信息
1588
+ */
1589
+ function showConfirm(text, title, options = {}, confirm = () => { }, reject = () => { }) {
1590
+ MessageBox.confirm(text, title, options).then(() => {
1591
+ confirm();
1592
+ }).catch(() => {
1593
+ reject();
1594
+ });
1595
+ }
1596
+
1597
+ /**
1598
+ * 提示消息框
1599
+ * @param {object} options 配置信息
1600
+ */
1601
+ function showNotification(options = {}) {
1602
+ Notification(options);
1537
1603
  }
1538
1604
 
1539
1605
  var CCMessage = /*#__PURE__*/Object.freeze({
@@ -1543,243 +1609,243 @@ var CCMessage = /*#__PURE__*/Object.freeze({
1543
1609
  showNotification: showNotification
1544
1610
  });
1545
1611
 
1546
- // 对象详情id存储标识
1547
- const OBJECT_DETAIL_ID = 'cc_object_detail_id';
1548
- // 对象存储标识
1549
- const OBJECT = 'cc_object';
1550
- // 列表视图存储标识
1551
- const OBJECT_LIST = 'cc_object_list';
1552
- // 详情页数据标识
1553
- const detailRecord = "_detail";
1554
- // 本地存储当前大小
1555
- let sessionSize = null;
1556
- let localSize = null;
1557
-
1558
- /**
1559
- * localStorage、sessionStorage存储满时,删除无用记录
1560
- * 仅清理详情页详细信息、视图列表以及详情页相关列表选中数据
1561
- * @param {string} type:类型(local、session)
1562
- * @returns {number} 清理后的存储大小
1563
- */
1564
- function clearStorag (type = 'session'){
1565
- let obj = null;
1566
- let size = 0;
1567
- if(type === 'local'){
1568
- obj = window.localStorage;
1569
- }else {
1570
- obj = window.sessionStorage;
1571
- }
1572
- if(obj && typeof obj === 'object'){
1573
- // 固定key需要清空的
1574
- // 设置当前标准对象列表选中的信息
1575
- obj.removeItem(Crypto.encrypt(OBJECT_LIST));
1576
- for(let i in obj){
1577
- if(i && obj.hasOwnProperty(i)){
1578
- const keyVal = i.split('_').pop();
1579
- const keyList = ['detail','record'];
1580
- if(keyList.includes(keyVal)){
1581
-
1582
- // 清空详情页存储数据
1583
- obj.removeItem(i);
1584
- }else {
1585
- let item = obj.getItem(i);
1586
- if(item){
1587
- size += item.length;
1588
- }
1589
- }
1590
-
1591
- }
1592
-
1593
- }
1594
- }
1595
- return size/1024/1024
1596
- }
1597
- /**
1598
- * 统一使用CCSetStorag进行storag的存储,暂时只需要session就可以了
1599
- * @param {type} 参数
1600
- * @returns {type} 返回值
1601
- */
1602
- function CCSetStorag (storagInfo){
1603
- // type:类型(local、session)
1604
- const {type,storageKey,value} = storagInfo || {};
1605
- if(type && storageKey){
1606
- const storagObj = type === 'local'? window.localStorage:window.sessionStorage;
1607
-
1608
- if(storagObj && typeof storagObj === 'object'){
1609
- let globalSize = type === 'local'? localSize:sessionSize;
1610
- const valueSize = value?value.length/1024/1024:0;
1611
- if(globalSize === null){
1612
- globalSize = getStoragSize(type);
1613
- }
1614
- globalSize = globalSize + valueSize;
1615
- // 谷歌浏览器sesssionStorage和localStorage最大内存是5M
1616
- if(globalSize > 4){
1617
- let val = clearStorag(type);
1618
- globalSize = valueSize + val;
1619
- }
1620
- if(type === 'local'){
1621
- localSize = globalSize;
1622
- }else {
1623
- sessionSize = globalSize;
1624
- }
1625
- // 存储内容
1626
- storagObj.setItem(storageKey,value);
1627
- }
1628
- }
1629
- }
1630
- /**
1631
- * 获取localStorage、sessionStorage存储大小
1632
- * @param {string} type:类型(local、session)
1633
- * @returns {number} 当前存储大小
1634
- */
1635
- function getStoragSize (type = 'session'){
1636
- let obj = null;
1637
- let size = 0;
1638
- if(type === 'local'){
1639
- obj = window.localStorage;
1640
- }else {
1641
- obj = window.sessionStorage;
1642
- }
1643
- if(obj && typeof obj === 'object'){
1644
- for(let i in obj){
1645
- if(obj.hasOwnProperty(i)){
1646
- let item = obj.getItem(i);
1647
- if(item){
1648
- size += item.length;
1649
- }
1650
- }
1651
-
1652
- }
1653
- }
1654
- return size/1024/1024
1655
- }
1656
- /**
1657
- * 获得当前标准对象信息
1658
- */
1659
- function getObject() {
1660
- let detail = localStorage.getItem(Crypto.encrypt(OBJECT));
1661
- if (detail) {
1662
- return JSON.parse(detail)
1663
- }
1664
- return ''
1665
- }
1666
-
1667
- /**
1668
- * 设置当前标准对象信息
1669
- * @param {object} detail 对象数据
1670
- */
1671
- function setObject(detail = '') {
1672
- if (detail) {
1673
- localStorage.setItem(Crypto.encrypt(OBJECT), JSON.stringify(detail));
1674
- }
1675
- }
1676
-
1677
- /**
1678
- * 获得当前标准对象的详细信息
1679
- * @param {String} apiname: 查找字段的apiname
1680
- * @param {String} detailId: 详情页数据id
1681
- */
1682
- function getObjectDetail(apiname, detailId) {
1683
- let detail;
1684
- // 没有指定详情页id,获取最后一次的id
1685
- detailId = detailId || window.$CCDK.CCDetail.getDetailId();
1686
- detailId = detailId+detailRecord;
1687
- if(detailId){
1688
- // 通过详情页id获取对应的详情页数据
1689
- detail = sessionStorage.getItem(detailId);
1690
- }
1691
- if (detail) {
1692
- // 转为对象
1693
- detail = JSON.parse(detail);
1694
- if (apiname) {
1695
- let detailList = detail.detail || [];
1696
- let targetField = undefined;
1697
- targetField = detailList.find(item => item.apiname === apiname);
1698
- return targetField
1699
- } else {
1700
- return detail
1701
- }
1702
- } else {
1703
- return ''
1704
- }
1705
-
1706
- }
1707
-
1708
- /**
1709
- * 设置当前标准对象的详细信息,默认两个小时有效期
1710
- * @param {object} detail 对象详细数据
1711
- */
1712
- function setObjectDetail(detail = '') {
1713
- if (detail && detail.id) {
1714
- // 减少detail.detail层级
1715
- if (Array.isArray(detail.detail) && detail.detail.length > 0) {
1716
- let data = [];
1717
- detail.detail.forEach(item => {
1718
- if (item && Array.isArray(item.data)) {
1719
- item.data.forEach(itemData => {
1720
- if (itemData.left && !Array.isArray(itemData.left)) {
1721
- data.push(itemData.left);
1722
- }
1723
- if (itemData.right && !Array.isArray(itemData.right)) {
1724
- data.push(itemData.right);
1725
- }
1726
- });
1727
- }
1728
- });
1729
- if (data.length > 0) {
1730
- detail.detail = data;
1731
- }
1732
- }
1733
- // 根据详情页id,记录详情页信息
1734
- const detailKey = detail.id+detailRecord;
1735
- const info = {type:'session',storageKey:detailKey,value:JSON.stringify(detail)};
1736
- window.$CCDK.CCObject.CCSetStorag(info);
1737
- // sessionStorage.setItem(detailKey, JSON.stringify(detail))
1738
- }
1739
- }
1740
- /**
1741
- * 设置当前标准对象列表选中的信息
1742
- * @param {object} detail 选中数据
1743
- */
1744
- function setObjectList(detail = {}) {
1745
- if (detail) {
1746
- const info = {type:'session',storageKey:Crypto.encrypt(OBJECT_LIST),value:JSON.stringify(detail)};
1747
- window.$CCDK.CCObject.CCSetStorag(info);
1748
- // sessionStorage.setItem(Crypto.encrypt(OBJECT_LIST), JSON.stringify(detail))
1749
- }
1750
- }
1751
- /**
1752
- * 获得当前标准对象列表选中的信息
1753
- */
1754
- function getObjectList() {
1755
- let detail = sessionStorage.getItem(Crypto.encrypt(OBJECT_LIST));
1756
- if (detail) {
1757
- return JSON.parse(detail)
1758
- }
1759
- return { ids: [] }
1760
- }
1761
- /**
1762
- * 设置当前标准对象的详情页id
1763
- * @param {object} id 对象详情页id
1764
- */
1765
- function setObjectDetailId(id = '') {
1766
- if (id) {
1767
- // 兼容老版本,自定义页面使用
1768
- localStorage.setItem("detailRecordId", id);
1769
- // 调整为sessionStorage存储,和标签一一对应
1770
- sessionStorage.setItem(Crypto.encrypt(OBJECT_DETAIL_ID),id);
1771
- }
1772
- }
1773
- /**
1774
- * 获取最后访问标准对象的详情页id
1775
- */
1776
- function getObjectDetailId() {
1777
- let id = sessionStorage.getItem(Crypto.encrypt(OBJECT_DETAIL_ID));
1778
- if(!id){
1779
- // 兼容老版本,自定义页面使用
1780
- id = localStorage.getItem("detailRecordId");
1781
- }
1782
- return id
1612
+ // 对象详情id存储标识
1613
+ const OBJECT_DETAIL_ID = 'cc_object_detail_id';
1614
+ // 对象存储标识
1615
+ const OBJECT = 'cc_object';
1616
+ // 列表视图存储标识
1617
+ const OBJECT_LIST = 'cc_object_list';
1618
+ // 详情页数据标识
1619
+ const detailRecord = "_detail";
1620
+ // 本地存储当前大小
1621
+ let sessionSize = null;
1622
+ let localSize = null;
1623
+
1624
+ /**
1625
+ * localStorage、sessionStorage存储满时,删除无用记录
1626
+ * 仅清理详情页详细信息、视图列表以及详情页相关列表选中数据
1627
+ * @param {string} type:类型(local、session)
1628
+ * @returns {number} 清理后的存储大小
1629
+ */
1630
+ function clearStorag (type = 'session'){
1631
+ let obj = null;
1632
+ let size = 0;
1633
+ if(type === 'local'){
1634
+ obj = window.localStorage;
1635
+ }else {
1636
+ obj = window.sessionStorage;
1637
+ }
1638
+ if(obj && typeof obj === 'object'){
1639
+ // 固定key需要清空的
1640
+ // 设置当前标准对象列表选中的信息
1641
+ obj.removeItem(Crypto.encrypt(OBJECT_LIST));
1642
+ for(let i in obj){
1643
+ if(i && obj.hasOwnProperty(i)){
1644
+ const keyVal = i.split('_').pop();
1645
+ const keyList = ['detail','record'];
1646
+ if(keyList.includes(keyVal)){
1647
+
1648
+ // 清空详情页存储数据
1649
+ obj.removeItem(i);
1650
+ }else {
1651
+ let item = obj.getItem(i);
1652
+ if(item){
1653
+ size += item.length;
1654
+ }
1655
+ }
1656
+
1657
+ }
1658
+
1659
+ }
1660
+ }
1661
+ return size/1024/1024
1662
+ }
1663
+ /**
1664
+ * 统一使用CCSetStorag进行storag的存储,暂时只需要session就可以了
1665
+ * @param {type} 参数
1666
+ * @returns {type} 返回值
1667
+ */
1668
+ function CCSetStorag (storagInfo){
1669
+ // type:类型(local、session)
1670
+ const {type,storageKey,value} = storagInfo || {};
1671
+ if(type && storageKey){
1672
+ const storagObj = type === 'local'? window.localStorage:window.sessionStorage;
1673
+
1674
+ if(storagObj && typeof storagObj === 'object'){
1675
+ let globalSize = type === 'local'? localSize:sessionSize;
1676
+ const valueSize = value?value.length/1024/1024:0;
1677
+ if(globalSize === null){
1678
+ globalSize = getStoragSize(type);
1679
+ }
1680
+ globalSize = globalSize + valueSize;
1681
+ // 谷歌浏览器sesssionStorage和localStorage最大内存是5M
1682
+ if(globalSize > 4){
1683
+ let val = clearStorag(type);
1684
+ globalSize = valueSize + val;
1685
+ }
1686
+ if(type === 'local'){
1687
+ localSize = globalSize;
1688
+ }else {
1689
+ sessionSize = globalSize;
1690
+ }
1691
+ // 存储内容
1692
+ storagObj.setItem(storageKey,value);
1693
+ }
1694
+ }
1695
+ }
1696
+ /**
1697
+ * 获取localStorage、sessionStorage存储大小
1698
+ * @param {string} type:类型(local、session)
1699
+ * @returns {number} 当前存储大小
1700
+ */
1701
+ function getStoragSize (type = 'session'){
1702
+ let obj = null;
1703
+ let size = 0;
1704
+ if(type === 'local'){
1705
+ obj = window.localStorage;
1706
+ }else {
1707
+ obj = window.sessionStorage;
1708
+ }
1709
+ if(obj && typeof obj === 'object'){
1710
+ for(let i in obj){
1711
+ if(obj.hasOwnProperty(i)){
1712
+ let item = obj.getItem(i);
1713
+ if(item){
1714
+ size += item.length;
1715
+ }
1716
+ }
1717
+
1718
+ }
1719
+ }
1720
+ return size/1024/1024
1721
+ }
1722
+ /**
1723
+ * 获得当前标准对象信息
1724
+ */
1725
+ function getObject() {
1726
+ let detail = localStorage.getItem(Crypto.encrypt(OBJECT));
1727
+ if (detail) {
1728
+ return JSON.parse(detail)
1729
+ }
1730
+ return ''
1731
+ }
1732
+
1733
+ /**
1734
+ * 设置当前标准对象信息
1735
+ * @param {object} detail 对象数据
1736
+ */
1737
+ function setObject(detail = '') {
1738
+ if (detail) {
1739
+ localStorage.setItem(Crypto.encrypt(OBJECT), JSON.stringify(detail));
1740
+ }
1741
+ }
1742
+
1743
+ /**
1744
+ * 获得当前标准对象的详细信息
1745
+ * @param {String} apiname: 查找字段的apiname
1746
+ * @param {String} detailId: 详情页数据id
1747
+ */
1748
+ function getObjectDetail(apiname, detailId) {
1749
+ let detail;
1750
+ // 没有指定详情页id,获取最后一次的id
1751
+ detailId = detailId || window.$CCDK.CCDetail.getDetailId();
1752
+ detailId = detailId+detailRecord;
1753
+ if(detailId){
1754
+ // 通过详情页id获取对应的详情页数据
1755
+ detail = sessionStorage.getItem(detailId);
1756
+ }
1757
+ if (detail) {
1758
+ // 转为对象
1759
+ detail = JSON.parse(detail);
1760
+ if (apiname) {
1761
+ let detailList = detail.detail || [];
1762
+ let targetField = undefined;
1763
+ targetField = detailList.find(item => item.apiname === apiname);
1764
+ return targetField
1765
+ } else {
1766
+ return detail
1767
+ }
1768
+ } else {
1769
+ return ''
1770
+ }
1771
+
1772
+ }
1773
+
1774
+ /**
1775
+ * 设置当前标准对象的详细信息,默认两个小时有效期
1776
+ * @param {object} detail 对象详细数据
1777
+ */
1778
+ function setObjectDetail(detail = '') {
1779
+ if (detail && detail.id) {
1780
+ // 减少detail.detail层级
1781
+ if (Array.isArray(detail.detail) && detail.detail.length > 0) {
1782
+ let data = [];
1783
+ detail.detail.forEach(item => {
1784
+ if (item && Array.isArray(item.data)) {
1785
+ item.data.forEach(itemData => {
1786
+ if (itemData.left && !Array.isArray(itemData.left)) {
1787
+ data.push(itemData.left);
1788
+ }
1789
+ if (itemData.right && !Array.isArray(itemData.right)) {
1790
+ data.push(itemData.right);
1791
+ }
1792
+ });
1793
+ }
1794
+ });
1795
+ if (data.length > 0) {
1796
+ detail.detail = data;
1797
+ }
1798
+ }
1799
+ // 根据详情页id,记录详情页信息
1800
+ const detailKey = detail.id+detailRecord;
1801
+ const info = {type:'session',storageKey:detailKey,value:JSON.stringify(detail)};
1802
+ window.$CCDK.CCObject.CCSetStorag(info);
1803
+ // sessionStorage.setItem(detailKey, JSON.stringify(detail))
1804
+ }
1805
+ }
1806
+ /**
1807
+ * 设置当前标准对象列表选中的信息
1808
+ * @param {object} detail 选中数据
1809
+ */
1810
+ function setObjectList(detail = {}) {
1811
+ if (detail) {
1812
+ const info = {type:'session',storageKey:Crypto.encrypt(OBJECT_LIST),value:JSON.stringify(detail)};
1813
+ window.$CCDK.CCObject.CCSetStorag(info);
1814
+ // sessionStorage.setItem(Crypto.encrypt(OBJECT_LIST), JSON.stringify(detail))
1815
+ }
1816
+ }
1817
+ /**
1818
+ * 获得当前标准对象列表选中的信息
1819
+ */
1820
+ function getObjectList() {
1821
+ let detail = sessionStorage.getItem(Crypto.encrypt(OBJECT_LIST));
1822
+ if (detail) {
1823
+ return JSON.parse(detail)
1824
+ }
1825
+ return { ids: [] }
1826
+ }
1827
+ /**
1828
+ * 设置当前标准对象的详情页id
1829
+ * @param {object} id 对象详情页id
1830
+ */
1831
+ function setObjectDetailId(id = '') {
1832
+ if (id) {
1833
+ // 兼容老版本,自定义页面使用
1834
+ localStorage.setItem("detailRecordId", id);
1835
+ // 调整为sessionStorage存储,和标签一一对应
1836
+ sessionStorage.setItem(Crypto.encrypt(OBJECT_DETAIL_ID),id);
1837
+ }
1838
+ }
1839
+ /**
1840
+ * 获取最后访问标准对象的详情页id
1841
+ */
1842
+ function getObjectDetailId() {
1843
+ let id = sessionStorage.getItem(Crypto.encrypt(OBJECT_DETAIL_ID));
1844
+ if(!id){
1845
+ // 兼容老版本,自定义页面使用
1846
+ id = localStorage.getItem("detailRecordId");
1847
+ }
1848
+ return id
1783
1849
  }
1784
1850
 
1785
1851
  var CCObject = /*#__PURE__*/Object.freeze({
@@ -1795,116 +1861,116 @@ var CCObject = /*#__PURE__*/Object.freeze({
1795
1861
  CCSetStorag: CCSetStorag
1796
1862
  });
1797
1863
 
1798
- /**
1799
- * 详情页的一些操作
1800
- */
1801
- // 表名
1802
- const TABLE_NAME$1 = "ccdetail";
1803
- // 相关列表选中key值标识
1804
- const record = "_record";
1805
- /**
1806
- * 设置详情页相关列表选中数据
1807
- * @param {string} detailId 详情页id
1808
- * @param {string} recordId 相关列表id
1809
- * @param {Array} list 相关列表选中的数据
1810
- */
1811
- function setRelatedSelected(detailId,recordId,list){
1812
- if(detailId && recordId && list){
1813
- // 获取当前详情页选中数据
1814
- detailId = detailId+record;
1815
- let detail = sessionStorage.getItem(detailId);
1816
- if(detail){
1817
- detail = JSON.parse(detail);
1818
- detail[recordId] = list;
1819
- }else {
1820
- detail = {};
1821
- detail[recordId] = list;
1822
- }
1823
- // 存储到sessionStorage中
1824
- const info = {type:'session',storageKey:detailId,value:JSON.stringify(detail)};
1825
- window.$CCDK.CCObject.CCSetStorag(info);
1826
- // sessionStorage.setItem(detailId,JSON.stringify(detail))
1827
-
1828
- }
1829
- }
1830
- /**
1831
- * 获取相关列表选中数据
1832
- * @param {string} recordId 相关列表id
1833
- * @param {string} detailId 详情页id,不传默认获取当前详情页id
1834
- * @returns {Array,object} 详情页中相关列表选中的数据
1835
- */
1836
- function getRelatedSelected(recordId,detailId){
1837
- if(!detailId){
1838
- detailId = window.$CCDK.CCObject.getObjectDetailId();
1839
- if(!detailId) return ;
1840
- }
1841
- // 获取当前详情页选中数据
1842
- detailId = detailId+record;
1843
- let detail = sessionStorage.getItem(detailId);
1844
- if(detail){
1845
- detail = JSON.parse(detail);
1846
- // 指定记录类型recordId获取选中数据
1847
- if(recordId){
1848
- detail = detail[recordId];
1849
- }
1850
- }
1851
-
1852
- return detail
1853
-
1854
- }
1855
- /**
1856
- * 获得详情页数据
1857
- * @param {String} apiname: 查找字段的apiname
1858
- * @param {String} detailId: 详情页数据id
1859
- */
1860
- function getDetail(apiname, detailId) {
1861
- return window.$CCDK.CCObject.getObjectDetail(apiname, detailId)
1862
- }
1863
-
1864
- /**
1865
- * 设置当前标准对象的详细信息,默认两个小时有效期
1866
- * @param {object} detail 对象详细数据
1867
- */
1868
- function setDetail(detail = '') {
1869
- window.$CCDK.CCObject.setObjectDetail(detail);
1870
- }
1871
- /**
1872
- * 设置当前标准对象的详情页id
1873
- * @param {object} id 对象详情页id
1874
- */
1875
- function setDetailId(id = '') {
1876
- window.$CCDK.CCObject.setObjectDetailId(id);
1877
- }
1878
- /**
1879
- * 获取最后访问标准对象的详情页id
1880
- */
1881
- function getDetailId() {
1882
- return window.$CCDK.CCObject.getObjectDetailId()
1883
- }
1884
-
1885
- /**
1886
- * 刷新相关列表
1887
- * @param {string} ids 相关列表ID字符串,逗号分隔,如果为空那么刷新所有相关列表
1888
- */
1889
- function refreshRelatedList(ids) {
1890
- window.$CCDK.CCBus.$emit('refreshRelation', { relatedlistId: ids });
1891
- }
1892
-
1893
- /**
1894
- * 存储数据
1895
- * @param {object} object 数据对象
1896
- * @returns
1897
- */
1898
- async function setRelatedFieldWidth(object) {
1899
- return await window.$CCDK.CCDB.create(TABLE_NAME$1, [object]);
1900
- }
1901
- /**
1902
- * 获取数据
1903
- * @param {object} object 过滤条件
1904
- * @returns
1905
- */
1906
- async function getRelatedFieldWidth(object) {
1907
- return await window.$CCDK.CCDB.list(TABLE_NAME$1, object);
1864
+ /**
1865
+ * 详情页的一些操作
1866
+ */
1867
+ // 表名
1868
+ const TABLE_NAME$1 = "ccdetail";
1869
+ // 相关列表选中key值标识
1870
+ const record = "_record";
1871
+ /**
1872
+ * 设置详情页相关列表选中数据
1873
+ * @param {string} detailId 详情页id
1874
+ * @param {string} recordId 相关列表id
1875
+ * @param {Array} list 相关列表选中的数据
1876
+ */
1877
+ function setRelatedSelected(detailId,recordId,list){
1878
+ if(detailId && recordId && list){
1879
+ // 获取当前详情页选中数据
1880
+ detailId = detailId+record;
1881
+ let detail = sessionStorage.getItem(detailId);
1882
+ if(detail){
1883
+ detail = JSON.parse(detail);
1884
+ detail[recordId] = list;
1885
+ }else {
1886
+ detail = {};
1887
+ detail[recordId] = list;
1888
+ }
1889
+ // 存储到sessionStorage中
1890
+ const info = {type:'session',storageKey:detailId,value:JSON.stringify(detail)};
1891
+ window.$CCDK.CCObject.CCSetStorag(info);
1892
+ // sessionStorage.setItem(detailId,JSON.stringify(detail))
1893
+
1894
+ }
1895
+ }
1896
+ /**
1897
+ * 获取相关列表选中数据
1898
+ * @param {string} recordId 相关列表id
1899
+ * @param {string} detailId 详情页id,不传默认获取当前详情页id
1900
+ * @returns {Array,object} 详情页中相关列表选中的数据
1901
+ */
1902
+ function getRelatedSelected(recordId,detailId){
1903
+ if(!detailId){
1904
+ detailId = window.$CCDK.CCObject.getObjectDetailId();
1905
+ if(!detailId) return ;
1906
+ }
1907
+ // 获取当前详情页选中数据
1908
+ detailId = detailId+record;
1909
+ let detail = sessionStorage.getItem(detailId);
1910
+ if(detail){
1911
+ detail = JSON.parse(detail);
1912
+ // 指定记录类型recordId获取选中数据
1913
+ if(recordId){
1914
+ detail = detail[recordId];
1915
+ }
1916
+ }
1917
+
1918
+ return detail
1919
+
1920
+ }
1921
+ /**
1922
+ * 获得详情页数据
1923
+ * @param {String} apiname: 查找字段的apiname
1924
+ * @param {String} detailId: 详情页数据id
1925
+ */
1926
+ function getDetail(apiname, detailId) {
1927
+ return window.$CCDK.CCObject.getObjectDetail(apiname, detailId)
1928
+ }
1929
+
1930
+ /**
1931
+ * 设置当前标准对象的详细信息,默认两个小时有效期
1932
+ * @param {object} detail 对象详细数据
1933
+ */
1934
+ function setDetail(detail = '') {
1935
+ window.$CCDK.CCObject.setObjectDetail(detail);
1936
+ }
1937
+ /**
1938
+ * 设置当前标准对象的详情页id
1939
+ * @param {object} id 对象详情页id
1940
+ */
1941
+ function setDetailId(id = '') {
1942
+ window.$CCDK.CCObject.setObjectDetailId(id);
1943
+ }
1944
+ /**
1945
+ * 获取最后访问标准对象的详情页id
1946
+ */
1947
+ function getDetailId() {
1948
+ return window.$CCDK.CCObject.getObjectDetailId()
1949
+ }
1950
+
1951
+ /**
1952
+ * 刷新相关列表
1953
+ * @param {string} ids 相关列表ID字符串,逗号分隔,如果为空那么刷新所有相关列表
1954
+ */
1955
+ function refreshRelatedList(ids) {
1956
+ window.$CCDK.CCBus.$emit('refreshRelation', { relatedlistId: ids });
1957
+ }
1958
+
1959
+ /**
1960
+ * 存储数据
1961
+ * @param {object} object 数据对象
1962
+ * @returns
1963
+ */
1964
+ async function setRelatedFieldWidth(object) {
1965
+ return await window.$CCDK.CCDB.create(TABLE_NAME$1, [object]);
1966
+ }
1967
+ /**
1968
+ * 获取数据
1969
+ * @param {object} object 过滤条件
1970
+ * @returns
1971
+ */
1972
+ async function getRelatedFieldWidth(object) {
1973
+ return await window.$CCDK.CCDB.list(TABLE_NAME$1, object);
1908
1974
  }
1909
1975
 
1910
1976
  var CCDetail = /*#__PURE__*/Object.freeze({
@@ -1920,86 +1986,86 @@ var CCDetail = /*#__PURE__*/Object.freeze({
1920
1986
  getRelatedSelected: getRelatedSelected
1921
1987
  });
1922
1988
 
1923
- // 表名
1924
- const TABLE_NAME = "cclist";
1925
- /**
1926
- * 对象视图页一些操作
1927
- */
1928
- /**
1929
- * 设置当前标准对象列表选中的信息,仅更新ids
1930
- * @param {object} detail 选中数据
1931
- */
1932
- function setSelected(detail = {}) {
1933
- const ids = detail && detail.ids;
1934
- if(ids){
1935
- let info = window.$CCDK.CCObject.getObjectList() || {};
1936
- info.ids = ids;
1937
- window.$CCDK.CCObject.setObjectList(info);
1938
-
1939
- }
1940
-
1941
- }
1942
- /**
1943
- * 获得当前标准对象列表选中的信息
1944
- */
1945
- function getSelected() {
1946
- let {ids} = window.$CCDK.CCObject.getObjectList();
1947
- return { ids: ids }
1948
- }
1949
- /**
1950
- * 获得当前视图列表页选中的视图id
1951
- */
1952
- function getViewId() {
1953
- let {viewId} = window.$CCDK.CCObject.getObjectList();
1954
- return viewId || ''
1955
- }
1956
-
1957
- /**
1958
- * 设置过滤条件
1959
- * @param {object} object 过滤条件
1960
- * {
1961
- objprefix: "003",
1962
- viewid: "aec20238DB5F47AciNyO",
1963
- filtercondition: '{"data":[{"fieldId":"ffe100000001260MztUa","type":"S","val":"11222","objid":"account","op":"c"},{"fieldId":"ffe2017082200ad001fa","type":"AD","val":"中国","objid":"account","op":"c"}]}',
1964
- filterdetail:
1965
- }
1966
- */
1967
- async function setFilter(object) {
1968
- await window.$CCDK.CCDB.create(TABLE_NAME, [object]);
1969
- }
1970
- /**
1971
- * 获取过滤条件
1972
- * @param {object} object 过滤条件
1973
- * {
1974
- objprefix: "003",
1975
- viewid: "aec20238DB5F47AciNyO",
1976
- }
1977
- */
1978
- async function getFilter(object) {
1979
- return await window.$CCDK.CCDB.list(TABLE_NAME, object);
1980
- }
1981
- /**
1982
- * 删除某对象下某视图列表的筛选条件
1983
- * */
1984
- async function deleteFilter(id) {
1985
- return await window.$CCDK.CCDB.deleteCC(TABLE_NAME, id)
1986
- }
1987
-
1988
- /**
1989
- * 清空所有数据
1990
- */
1991
- async function clearFilterAll() {
1992
- await window.$CCDK.CCDB.db[TABLE_NAME].toCollection().modify(item => {
1993
- item.filtercondition = "";
1994
- item.filterdetail = "";
1995
- });
1996
- }
1997
- /**
1998
- * 获取当前对象视图页数据
1999
- * @return {object} 当前视图对象信息
2000
- */
2001
- function getViewInfo(){
2002
- return window.$CCDK.CCObject.getObjectList() || {}
1989
+ // 表名
1990
+ const TABLE_NAME = "cclist";
1991
+ /**
1992
+ * 对象视图页一些操作
1993
+ */
1994
+ /**
1995
+ * 设置当前标准对象列表选中的信息,仅更新ids
1996
+ * @param {object} detail 选中数据
1997
+ */
1998
+ function setSelected(detail = {}) {
1999
+ const ids = detail && detail.ids;
2000
+ if(ids){
2001
+ let info = window.$CCDK.CCObject.getObjectList() || {};
2002
+ info.ids = ids;
2003
+ window.$CCDK.CCObject.setObjectList(info);
2004
+
2005
+ }
2006
+
2007
+ }
2008
+ /**
2009
+ * 获得当前标准对象列表选中的信息
2010
+ */
2011
+ function getSelected() {
2012
+ let {ids} = window.$CCDK.CCObject.getObjectList();
2013
+ return { ids: ids }
2014
+ }
2015
+ /**
2016
+ * 获得当前视图列表页选中的视图id
2017
+ */
2018
+ function getViewId() {
2019
+ let {viewId} = window.$CCDK.CCObject.getObjectList();
2020
+ return viewId || ''
2021
+ }
2022
+
2023
+ /**
2024
+ * 设置过滤条件
2025
+ * @param {object} object 过滤条件
2026
+ * {
2027
+ objprefix: "003",
2028
+ viewid: "aec20238DB5F47AciNyO",
2029
+ filtercondition: '{"data":[{"fieldId":"ffe100000001260MztUa","type":"S","val":"11222","objid":"account","op":"c"},{"fieldId":"ffe2017082200ad001fa","type":"AD","val":"中国","objid":"account","op":"c"}]}',
2030
+ filterdetail:
2031
+ }
2032
+ */
2033
+ async function setFilter(object) {
2034
+ await window.$CCDK.CCDB.create(TABLE_NAME, [object]);
2035
+ }
2036
+ /**
2037
+ * 获取过滤条件
2038
+ * @param {object} object 过滤条件
2039
+ * {
2040
+ objprefix: "003",
2041
+ viewid: "aec20238DB5F47AciNyO",
2042
+ }
2043
+ */
2044
+ async function getFilter(object) {
2045
+ return await window.$CCDK.CCDB.list(TABLE_NAME, object);
2046
+ }
2047
+ /**
2048
+ * 删除某对象下某视图列表的筛选条件
2049
+ * */
2050
+ async function deleteFilter(id) {
2051
+ return await window.$CCDK.CCDB.deleteCC(TABLE_NAME, id)
2052
+ }
2053
+
2054
+ /**
2055
+ * 清空所有数据
2056
+ */
2057
+ async function clearFilterAll() {
2058
+ await window.$CCDK.CCDB.db[TABLE_NAME].toCollection().modify(item => {
2059
+ item.filtercondition = "";
2060
+ item.filterdetail = "";
2061
+ });
2062
+ }
2063
+ /**
2064
+ * 获取当前对象视图页数据
2065
+ * @return {object} 当前视图对象信息
2066
+ */
2067
+ function getViewInfo(){
2068
+ return window.$CCDK.CCObject.getObjectList() || {}
2003
2069
  }
2004
2070
 
2005
2071
  var CCList = /*#__PURE__*/Object.freeze({
@@ -2014,183 +2080,183 @@ var CCList = /*#__PURE__*/Object.freeze({
2014
2080
  getViewInfo: getViewInfo
2015
2081
  });
2016
2082
 
2017
- /**
2018
- * 用于保存打开的页面集合
2019
- */
2020
- let pageList = new Map();
2021
- /**
2022
- * 打开对象视图页面
2023
- * @param {object} obj 对象信息
2024
- * @param {object} options 配置信息
2025
- */
2026
- function openListPage(obj, options = {}) {
2027
- let pageId = options.pageId||Math.random().toString(16).slice(2);
2028
- window.$CCDK.CCBus.$emit('openListPage', pageId, obj, options);
2029
- return pageId;
2030
- }
2031
-
2032
- /**
2033
- * 打开数据详情页
2034
- * @param {object} obj 对象体
2035
- * @param {string} id 数据id
2036
- * @param {object} options 配置信息
2037
- */
2038
- function openDetailPage(obj, id, options = {}) {
2039
- let pageId = options.pageId||Math.random().toString(16).slice(2);
2040
- window.$CCDK.CCBus.$emit('openDetailPage', pageId, obj, id, options);
2041
- return pageId;
2042
- }
2043
-
2044
- /**
2045
- * 打开创建页面
2046
- * @param {object} obj 对象体
2047
- * @param {object} options 配置信息
2048
- */
2049
- function openCreatePage(obj, options = {}) {
2050
- let pageId = options.pageId||Math.random().toString(16).slice(2);
2051
- window.$CCDK.CCBus.$emit('openCreatePage', pageId, obj, options);
2052
- return pageId;
2053
- }
2054
-
2055
- /**
2056
- * 打开修改页面
2057
- * @param {object} obj 对象体
2058
- * @param {string} id 数据id
2059
- * @param {object} options 配置信息
2060
- */
2061
- function openEditPage(obj, id, options = {}) {
2062
- let pageId = options.pageId||Math.random().toString(16).slice(2);
2063
- window.$CCDK.CCBus.$emit('openEditPage', pageId, obj, id, options);
2064
- return pageId;
2065
- }
2066
- /**
2067
- * 打开自定义页面
2068
- * @param {object} obj 自定义页面参数
2069
- * @param {object} options 配置信息
2070
- */
2071
- function openCustomPage(obj, options = {}) {
2072
- let pageId = options.pageId||Math.random().toString(16).slice(2);
2073
- window.$CCDK.CCBus.$emit('openCustomPage', pageId, obj, options);
2074
- return pageId;
2075
- }
2076
-
2077
- /**
2078
- * 通过页面id,重新打开某个页面
2079
- * @param {string} pageId 页面id
2080
- * @param {object} options 配置信息
2081
- */
2082
- function reOpenPage(pageId, options) {
2083
- let page;
2084
- if (pageId) {
2085
- pageId = pageId + '';
2086
- page = pageList.get(pageId);
2087
- }
2088
- if (page) {
2089
- page.reOpenPage();
2090
- if (options.refresh) {
2091
- page.refresh();
2092
- }
2093
- }
2094
- }
2095
-
2096
- /**
2097
- * 将打开的页面添加到集合中
2098
- * @param {string} id 唯一ID
2099
- * @param {object} page 页面对象
2100
- */
2101
- function addPage(id, page) {
2102
- if (id && page) {
2103
- id = id + '';
2104
- pageList.set(id, page);
2105
- }
2106
- }
2107
-
2108
- /**
2109
- * 删除某个页面
2110
- * @param {string} pageId 唯一ID
2111
- */
2112
- function deletePage(pageId) {
2113
- if (pageId) {
2114
- pageId = pageId + '';
2115
- pageList.delete(pageId);
2116
- }
2117
- }
2118
- /**
2119
- * 更改页面数据
2120
- * @param {string} id 唯一ID
2121
- * @param {object} page 页面对象
2122
- */
2123
- function updatePage(id, page) {
2124
- if (id && page) {
2125
- id = id + '';
2126
- pageList.set(id, page);
2127
- }
2128
- }
2129
-
2130
- /**
2131
- * 通过页面id查询页面
2132
- * @param {string} pageId 唯一ID
2133
- */
2134
- function searchPage(pageId) {
2135
- pageId = pageId + '';
2136
- return pageList.get(pageId)
2137
- }
2138
- /**
2139
- * 关闭页面,如果pageId为null,那么关闭当前页面
2140
- * 如果pageId为all,关闭所有一级菜单
2141
- * @param {string} pageId 页面id
2142
- */
2143
- function close$1(pageId = '') {
2144
- let page;
2145
- if(pageId === 'all'){
2146
- page = [...pageList.values()];
2147
- page.forEach(item => {
2148
- if(item){
2149
- item.close();
2150
- }
2151
- });
2152
- }else if (pageId) {
2153
- pageId = pageId + '';
2154
- page = pageList.get(pageId);
2155
- } else {
2156
- // 不传pageId 默认关闭当前选中的
2157
- // 当前选中菜单的树形结构
2158
- let currentMenuTree = JSON.parse(localStorage.getItem('current_page'));
2159
- if (currentMenuTree) {
2160
- // 说明当前选中的是二级菜单
2161
- if (currentMenuTree.level2Id) {
2162
- page = pageList.get(currentMenuTree.level2Id);
2163
- } else {
2164
- // 说明当前选中的是一级菜单
2165
- page = pageList.get(currentMenuTree.id);
2166
- }
2167
- }
2168
- // if (pageList.size > 0) {
2169
- // page = [...pageList.values()][pageList.size - 1]
2170
- // }
2171
- }
2172
- if (page) {
2173
- page.close();
2174
- }
2175
- }
2176
- /**
2177
- * 刷新当前页面
2178
- */
2179
- function refresh() {
2180
- window.$CCDK.CCBus.$emit('refresh');
2181
- }
2182
- /**
2183
- * 获取当前一二级选中菜单的树形结构
2184
- * @param {object} obj 自定义页面参数
2185
- * @param {object} options 配置信息
2186
- */
2187
- function getCurrentPage() {
2188
- // 当前选中菜单的树形结构
2189
- let currentMenuTree = localStorage.getItem('current_page');
2190
- if (currentMenuTree) {
2191
- return JSON.parse(currentMenuTree)
2192
- }
2193
- return ''
2083
+ /**
2084
+ * 用于保存打开的页面集合
2085
+ */
2086
+ let pageList = new Map();
2087
+ /**
2088
+ * 打开对象视图页面
2089
+ * @param {object} obj 对象信息
2090
+ * @param {object} options 配置信息
2091
+ */
2092
+ function openListPage(obj, options = {}) {
2093
+ let pageId = options.pageId||Math.random().toString(16).slice(2);
2094
+ window.$CCDK.CCBus.$emit('openListPage', pageId, obj, options);
2095
+ return pageId;
2096
+ }
2097
+
2098
+ /**
2099
+ * 打开数据详情页
2100
+ * @param {object} obj 对象体
2101
+ * @param {string} id 数据id
2102
+ * @param {object} options 配置信息
2103
+ */
2104
+ function openDetailPage(obj, id, options = {}) {
2105
+ let pageId = options.pageId||Math.random().toString(16).slice(2);
2106
+ window.$CCDK.CCBus.$emit('openDetailPage', pageId, obj, id, options);
2107
+ return pageId;
2108
+ }
2109
+
2110
+ /**
2111
+ * 打开创建页面
2112
+ * @param {object} obj 对象体
2113
+ * @param {object} options 配置信息
2114
+ */
2115
+ function openCreatePage(obj, options = {}) {
2116
+ let pageId = options.pageId||Math.random().toString(16).slice(2);
2117
+ window.$CCDK.CCBus.$emit('openCreatePage', pageId, obj, options);
2118
+ return pageId;
2119
+ }
2120
+
2121
+ /**
2122
+ * 打开修改页面
2123
+ * @param {object} obj 对象体
2124
+ * @param {string} id 数据id
2125
+ * @param {object} options 配置信息
2126
+ */
2127
+ function openEditPage(obj, id, options = {}) {
2128
+ let pageId = options.pageId||Math.random().toString(16).slice(2);
2129
+ window.$CCDK.CCBus.$emit('openEditPage', pageId, obj, id, options);
2130
+ return pageId;
2131
+ }
2132
+ /**
2133
+ * 打开自定义页面
2134
+ * @param {object} obj 自定义页面参数
2135
+ * @param {object} options 配置信息
2136
+ */
2137
+ function openCustomPage(obj, options = {}) {
2138
+ let pageId = options.pageId||Math.random().toString(16).slice(2);
2139
+ window.$CCDK.CCBus.$emit('openCustomPage', pageId, obj, options);
2140
+ return pageId;
2141
+ }
2142
+
2143
+ /**
2144
+ * 通过页面id,重新打开某个页面
2145
+ * @param {string} pageId 页面id
2146
+ * @param {object} options 配置信息
2147
+ */
2148
+ function reOpenPage(pageId, options) {
2149
+ let page;
2150
+ if (pageId) {
2151
+ pageId = pageId + '';
2152
+ page = pageList.get(pageId);
2153
+ }
2154
+ if (page) {
2155
+ page.reOpenPage();
2156
+ if (options.refresh) {
2157
+ page.refresh();
2158
+ }
2159
+ }
2160
+ }
2161
+
2162
+ /**
2163
+ * 将打开的页面添加到集合中
2164
+ * @param {string} id 唯一ID
2165
+ * @param {object} page 页面对象
2166
+ */
2167
+ function addPage(id, page) {
2168
+ if (id && page) {
2169
+ id = id + '';
2170
+ pageList.set(id, page);
2171
+ }
2172
+ }
2173
+
2174
+ /**
2175
+ * 删除某个页面
2176
+ * @param {string} pageId 唯一ID
2177
+ */
2178
+ function deletePage(pageId) {
2179
+ if (pageId) {
2180
+ pageId = pageId + '';
2181
+ pageList.delete(pageId);
2182
+ }
2183
+ }
2184
+ /**
2185
+ * 更改页面数据
2186
+ * @param {string} id 唯一ID
2187
+ * @param {object} page 页面对象
2188
+ */
2189
+ function updatePage(id, page) {
2190
+ if (id && page) {
2191
+ id = id + '';
2192
+ pageList.set(id, page);
2193
+ }
2194
+ }
2195
+
2196
+ /**
2197
+ * 通过页面id查询页面
2198
+ * @param {string} pageId 唯一ID
2199
+ */
2200
+ function searchPage(pageId) {
2201
+ pageId = pageId + '';
2202
+ return pageList.get(pageId)
2203
+ }
2204
+ /**
2205
+ * 关闭页面,如果pageId为null,那么关闭当前页面
2206
+ * 如果pageId为all,关闭所有一级菜单
2207
+ * @param {string} pageId 页面id
2208
+ */
2209
+ function close$1(pageId = '') {
2210
+ let page;
2211
+ if(pageId === 'all'){
2212
+ page = [...pageList.values()];
2213
+ page.forEach(item => {
2214
+ if(item){
2215
+ item.close();
2216
+ }
2217
+ });
2218
+ }else if (pageId) {
2219
+ pageId = pageId + '';
2220
+ page = pageList.get(pageId);
2221
+ } else {
2222
+ // 不传pageId 默认关闭当前选中的
2223
+ // 当前选中菜单的树形结构
2224
+ let currentMenuTree = JSON.parse(localStorage.getItem('current_page'));
2225
+ if (currentMenuTree) {
2226
+ // 说明当前选中的是二级菜单
2227
+ if (currentMenuTree.level2Id) {
2228
+ page = pageList.get(currentMenuTree.level2Id);
2229
+ } else {
2230
+ // 说明当前选中的是一级菜单
2231
+ page = pageList.get(currentMenuTree.id);
2232
+ }
2233
+ }
2234
+ // if (pageList.size > 0) {
2235
+ // page = [...pageList.values()][pageList.size - 1]
2236
+ // }
2237
+ }
2238
+ if (page) {
2239
+ page.close();
2240
+ }
2241
+ }
2242
+ /**
2243
+ * 刷新当前页面
2244
+ */
2245
+ function refresh() {
2246
+ window.$CCDK.CCBus.$emit('refresh');
2247
+ }
2248
+ /**
2249
+ * 获取当前一二级选中菜单的树形结构
2250
+ * @param {object} obj 自定义页面参数
2251
+ * @param {object} options 配置信息
2252
+ */
2253
+ function getCurrentPage() {
2254
+ // 当前选中菜单的树形结构
2255
+ let currentMenuTree = localStorage.getItem('current_page');
2256
+ if (currentMenuTree) {
2257
+ return JSON.parse(currentMenuTree)
2258
+ }
2259
+ return ''
2194
2260
  }
2195
2261
 
2196
2262
  var CCPage = /*#__PURE__*/Object.freeze({
@@ -2210,62 +2276,62 @@ var CCPage = /*#__PURE__*/Object.freeze({
2210
2276
  getCurrentPage: getCurrentPage
2211
2277
  });
2212
2278
 
2213
- /**
2214
- * 设置用户信息
2215
- * @param {object} sentry
2216
- * @param {object} ccUser 用户信息
2217
- */
2218
- function initUserInfo(sentry, ccUser = window.$CCDK.CCUser.getUserInfo()) {
2219
- if (ccUser && ccUser != "") {
2220
- // 添加日志监控标签:组织id
2221
- sentry.setTag("orgId", ccUser.orgId);
2222
- // 添加日志监控标签:组织名称
2223
- sentry.setTag("orgName", ccUser.orgName);
2224
- // 添加日志监控标签:用户id和用户名称
2225
- sentry.setUser({
2226
- username: ccUser.userName,
2227
- id: ccUser.userId,
2228
- });
2229
- }
2230
- }
2231
- /**
2232
- * 内存上报
2233
- * @param {object} sentry
2234
- */
2235
- function reportMemory(sentry, ccUser) {
2236
- if (performance.memory) {
2237
- let memeryMsg =
2238
- "Memory monitoring:jsHeapSizeLimit=" +
2239
- (performance.memory.jsHeapSizeLimit / 1024 / 1024).toFixed(2) +
2240
- "mb、" +
2241
- "totalJSHeapSize=" +
2242
- (performance.memory.totalJSHeapSize / 1024 / 1024).toFixed(2) +
2243
- "mb、" +
2244
- "usedJSHeapSize=" +
2245
- (performance.memory.usedJSHeapSize / 1024 / 1024).toFixed(2) +
2246
- "mb";
2247
- initUserInfo(sentry, ccUser);
2248
- sentry.withScope(function (scope) {
2249
- // 使用内存
2250
- sentry.setTag("usedJSHeapSize", (performance.memory.usedJSHeapSize / 1024 / 1024).toFixed(2));
2251
- // 添加日志监控标签:组织id
2252
- scope.setFingerprint(["Memory Monitoring"]);
2253
- sentry.captureMessage(memeryMsg);
2254
- });
2255
- }
2256
- }
2257
-
2258
- /**
2259
- * 网络异常上报
2260
- * @param {object} sentry
2261
- * @param {error} error
2262
- */
2263
- function reportHttpException(sentry, error, ccUser) {
2264
- initUserInfo(sentry, ccUser);
2265
- sentry.withScope(function (scope) {
2266
- scope.setFingerprint(["Interface Uncaught Exceptions response"]);
2267
- sentry.captureException(error);
2268
- });
2279
+ /**
2280
+ * 设置用户信息
2281
+ * @param {object} sentry
2282
+ * @param {object} ccUser 用户信息
2283
+ */
2284
+ function initUserInfo(sentry, ccUser = window.$CCDK.CCUser.getUserInfo()) {
2285
+ if (ccUser && ccUser != "") {
2286
+ // 添加日志监控标签:组织id
2287
+ sentry.setTag("orgId", ccUser.orgId);
2288
+ // 添加日志监控标签:组织名称
2289
+ sentry.setTag("orgName", ccUser.orgName);
2290
+ // 添加日志监控标签:用户id和用户名称
2291
+ sentry.setUser({
2292
+ username: ccUser.userName,
2293
+ id: ccUser.userId,
2294
+ });
2295
+ }
2296
+ }
2297
+ /**
2298
+ * 内存上报
2299
+ * @param {object} sentry
2300
+ */
2301
+ function reportMemory(sentry, ccUser) {
2302
+ if (performance.memory) {
2303
+ let memeryMsg =
2304
+ "Memory monitoring:jsHeapSizeLimit=" +
2305
+ (performance.memory.jsHeapSizeLimit / 1024 / 1024).toFixed(2) +
2306
+ "mb、" +
2307
+ "totalJSHeapSize=" +
2308
+ (performance.memory.totalJSHeapSize / 1024 / 1024).toFixed(2) +
2309
+ "mb、" +
2310
+ "usedJSHeapSize=" +
2311
+ (performance.memory.usedJSHeapSize / 1024 / 1024).toFixed(2) +
2312
+ "mb";
2313
+ initUserInfo(sentry, ccUser);
2314
+ sentry.withScope(function (scope) {
2315
+ // 使用内存
2316
+ sentry.setTag("usedJSHeapSize", (performance.memory.usedJSHeapSize / 1024 / 1024).toFixed(2));
2317
+ // 添加日志监控标签:组织id
2318
+ scope.setFingerprint(["Memory Monitoring"]);
2319
+ sentry.captureMessage(memeryMsg);
2320
+ });
2321
+ }
2322
+ }
2323
+
2324
+ /**
2325
+ * 网络异常上报
2326
+ * @param {object} sentry
2327
+ * @param {error} error
2328
+ */
2329
+ function reportHttpException(sentry, error, ccUser) {
2330
+ initUserInfo(sentry, ccUser);
2331
+ sentry.withScope(function (scope) {
2332
+ scope.setFingerprint(["Interface Uncaught Exceptions response"]);
2333
+ sentry.captureException(error);
2334
+ });
2269
2335
  }
2270
2336
 
2271
2337
  var CCSentry = /*#__PURE__*/Object.freeze({
@@ -2275,24 +2341,24 @@ var CCSentry = /*#__PURE__*/Object.freeze({
2275
2341
  reportHttpException: reportHttpException
2276
2342
  });
2277
2343
 
2278
- /**
2279
- * 初始化侧边区域
2280
- * @param {object} options 自定义页面配置
2281
- */
2282
- function init(options) {
2283
- window.$CCDK.CCBus.$emit('initSide', options);
2284
- }
2285
- /**
2286
- * 打开侧边区域
2287
- */
2288
- function open() {
2289
- window.$CCDK.CCBus.$emit('openSide');
2290
- }
2291
- /**
2292
- * 关闭侧边区域
2293
- */
2294
- function close() {
2295
- window.$CCDK.CCBus.$emit('closeSide');
2344
+ /**
2345
+ * 初始化侧边区域
2346
+ * @param {object} options 自定义页面配置
2347
+ */
2348
+ function init(options) {
2349
+ window.$CCDK.CCBus.$emit('initSide', options);
2350
+ }
2351
+ /**
2352
+ * 打开侧边区域
2353
+ */
2354
+ function open() {
2355
+ window.$CCDK.CCBus.$emit('openSide');
2356
+ }
2357
+ /**
2358
+ * 关闭侧边区域
2359
+ */
2360
+ function close() {
2361
+ window.$CCDK.CCBus.$emit('closeSide');
2296
2362
  }
2297
2363
 
2298
2364
  var CCSide = /*#__PURE__*/Object.freeze({
@@ -2302,60 +2368,60 @@ var CCSide = /*#__PURE__*/Object.freeze({
2302
2368
  close: close
2303
2369
  });
2304
2370
 
2305
- // cookie存储标识
2306
- const TOKEN = "cc_token";
2307
- /**
2308
- * 获取URL中参数的数据
2309
- * @param {name} 参数名
2310
- */
2311
- function getUrlQuery(name) {
2312
- var reg = new RegExp(name + "=([^&]*)(&|$)");
2313
- var r = window.location.href.match(reg);
2314
- let res = null;
2315
- if (r != null) res = r[1].trim();
2316
- return res;
2317
- }
2318
- /**
2319
- * 获取token:优先级-url最高,cc_token-cookies第二,binding-cookies第三,local第四
2320
- * @param {String} urlName 获取token的url名称
2321
- * @param {String} cookieName 获取token的cookie名称
2322
- * @returns
2323
- */
2324
- function getToken(urlName = "binding", cookieName = TOKEN) {
2325
- let token = getUrlQuery(urlName) || Cookies.get(Crypto.encrypt(cookieName)) || Cookies.get(urlName || TOKEN);
2326
- if (token) {
2327
- token = setToken(token, cookieName);
2328
- }
2329
- return token
2330
- }
2331
- /**
2332
- * 存储token
2333
- * @param {String} token token
2334
- * @param {String} cookieName 获取token的cookie名称
2335
- * @param {String} domain 域名
2336
- */
2337
- function setToken(token, cookieName = TOKEN, domain = getDomain()) {
2338
- // let { result } = verifyToken(token);
2339
- // if (result) {
2340
- Cookies.set(Crypto.encrypt(cookieName), token, { domain: domain, expires: 1 / 12 , sameSite: 'Lax'});
2341
- Cookies.set("JSESSIONID", token, { expires: 1 / 12, sameSite: 'Lax' });
2342
- // localStorage.setItem(Crypto.encrypt(cookieName), token);
2343
- return token
2344
- // } else {
2345
- // return null
2346
- // }
2347
- }
2348
-
2349
- /**
2350
- * 清除Token数据
2351
- * @param {String} domain 域名
2352
- * @param {String} cookieName 获取token的cookie名称
2353
- */
2354
- function clearToken(cookieName = TOKEN, domain = getDomain()) {
2355
- Cookies.remove(Crypto.encrypt(cookieName), { domain: domain });
2356
- Cookies.remove(Crypto.encrypt(cookieName));
2357
- Cookies.remove("JSESSIONID");
2358
- localStorage.removeItem(Crypto.encrypt(cookieName));
2371
+ // cookie存储标识
2372
+ const TOKEN = "cc_token";
2373
+ /**
2374
+ * 获取URL中参数的数据
2375
+ * @param {name} 参数名
2376
+ */
2377
+ function getUrlQuery(name) {
2378
+ var reg = new RegExp(name + "=([^&]*)(&|$)");
2379
+ var r = window.location.href.match(reg);
2380
+ let res = null;
2381
+ if (r != null) res = r[1].trim();
2382
+ return res;
2383
+ }
2384
+ /**
2385
+ * 获取token:优先级-url最高,cc_token-cookies第二,binding-cookies第三,local第四
2386
+ * @param {String} urlName 获取token的url名称
2387
+ * @param {String} cookieName 获取token的cookie名称
2388
+ * @returns
2389
+ */
2390
+ function getToken(urlName = "binding", cookieName = TOKEN) {
2391
+ let token = getUrlQuery(urlName) || Cookies.get(Crypto.encrypt(cookieName)) || Cookies.get(urlName || TOKEN);
2392
+ if (token) {
2393
+ token = setToken(token, cookieName);
2394
+ }
2395
+ return token
2396
+ }
2397
+ /**
2398
+ * 存储token
2399
+ * @param {String} token token
2400
+ * @param {String} cookieName 获取token的cookie名称
2401
+ * @param {String} domain 域名
2402
+ */
2403
+ function setToken(token, cookieName = TOKEN, domain = getDomain()) {
2404
+ // let { result } = verifyToken(token);
2405
+ // if (result) {
2406
+ Cookies.set(Crypto.encrypt(cookieName), token, { domain: domain, expires: 1 / 12 , sameSite: 'Lax'});
2407
+ Cookies.set("JSESSIONID", token, { expires: 1 / 12, sameSite: 'Lax' });
2408
+ // localStorage.setItem(Crypto.encrypt(cookieName), token);
2409
+ return token
2410
+ // } else {
2411
+ // return null
2412
+ // }
2413
+ }
2414
+
2415
+ /**
2416
+ * 清除Token数据
2417
+ * @param {String} domain 域名
2418
+ * @param {String} cookieName 获取token的cookie名称
2419
+ */
2420
+ function clearToken(cookieName = TOKEN, domain = getDomain()) {
2421
+ Cookies.remove(Crypto.encrypt(cookieName), { domain: domain });
2422
+ Cookies.remove(Crypto.encrypt(cookieName));
2423
+ Cookies.remove("JSESSIONID");
2424
+ localStorage.removeItem(Crypto.encrypt(cookieName));
2359
2425
  }
2360
2426
 
2361
2427
  var CCToken = /*#__PURE__*/Object.freeze({
@@ -2366,55 +2432,55 @@ var CCToken = /*#__PURE__*/Object.freeze({
2366
2432
  getUrlQuery: getUrlQuery
2367
2433
  });
2368
2434
 
2369
- // 用户cookie存储标识
2370
- const USER_INFO = "cc_user_info";
2371
- // JWT的cookie存储标识
2372
- const USER_JWT_INFO = "cc_user_jwt_info";
2373
-
2374
- /**
2375
- * 存储用户信息
2376
- * @param {String} userInfo 用户信息
2377
- * @param {String} domain 域名
2378
- */
2379
- function setUserInfo(userInfo, domain = getDomain()) {
2380
- Cookies.set(Crypto.encrypt(USER_INFO), Crypto.encrypt(userInfo), { domain: domain, expires: 1 / 12 , sameSite: 'Lax'});
2381
- }
2382
-
2383
- /**
2384
- * 获取用户信息
2385
- * @returns {String} 用户信息
2386
- */
2387
- function getUserInfo() {
2388
- // 加密的用户信息
2389
- let encryptUserInfo = Cookies.get(Crypto.encrypt(USER_INFO));
2390
- if (encryptUserInfo) {
2391
- return Crypto.decrypt(encryptUserInfo)
2392
- } else {
2393
- return ""
2394
- }
2395
- }
2396
-
2397
- /**
2398
- * 存储用户jwt信息
2399
- * @param {String} jwtInfo 用户信息
2400
- * @param {String} domain 域名
2401
- */
2402
- function setUserJwtInfo(jwtInfo, domain = getDomain()) {
2403
- Cookies.set(Crypto.encrypt(USER_JWT_INFO), Crypto.encrypt(jwtInfo), { domain: domain, expires: 1 / 12 , sameSite: 'Lax'});
2404
- }
2405
-
2406
- /**
2407
- * 获取用户jwt信息
2408
- * @returns {Object} 用户信息
2409
- */
2410
- function getUserJwtInfo() {
2411
- // 加密的用户信息
2412
- let encryptUserInfo = Cookies.get(Crypto.encrypt(USER_JWT_INFO));
2413
- if (encryptUserInfo) {
2414
- return JSON.parse(Crypto.decrypt(encryptUserInfo))
2415
- } else {
2416
- return {}
2417
- }
2435
+ // 用户cookie存储标识
2436
+ const USER_INFO = "cc_user_info";
2437
+ // JWT的cookie存储标识
2438
+ const USER_JWT_INFO = "cc_user_jwt_info";
2439
+
2440
+ /**
2441
+ * 存储用户信息
2442
+ * @param {String} userInfo 用户信息
2443
+ * @param {String} domain 域名
2444
+ */
2445
+ function setUserInfo(userInfo, domain = getDomain()) {
2446
+ Cookies.set(Crypto.encrypt(USER_INFO), Crypto.encrypt(userInfo), { domain: domain, expires: 1 / 12 , sameSite: 'Lax'});
2447
+ }
2448
+
2449
+ /**
2450
+ * 获取用户信息
2451
+ * @returns {String} 用户信息
2452
+ */
2453
+ function getUserInfo() {
2454
+ // 加密的用户信息
2455
+ let encryptUserInfo = Cookies.get(Crypto.encrypt(USER_INFO));
2456
+ if (encryptUserInfo) {
2457
+ return Crypto.decrypt(encryptUserInfo)
2458
+ } else {
2459
+ return ""
2460
+ }
2461
+ }
2462
+
2463
+ /**
2464
+ * 存储用户jwt信息
2465
+ * @param {String} jwtInfo 用户信息
2466
+ * @param {String} domain 域名
2467
+ */
2468
+ function setUserJwtInfo(jwtInfo, domain = getDomain()) {
2469
+ Cookies.set(Crypto.encrypt(USER_JWT_INFO), Crypto.encrypt(jwtInfo), { domain: domain, expires: 1 / 12 , sameSite: 'Lax'});
2470
+ }
2471
+
2472
+ /**
2473
+ * 获取用户jwt信息
2474
+ * @returns {Object} 用户信息
2475
+ */
2476
+ function getUserJwtInfo() {
2477
+ // 加密的用户信息
2478
+ let encryptUserInfo = Cookies.get(Crypto.encrypt(USER_JWT_INFO));
2479
+ if (encryptUserInfo) {
2480
+ return JSON.parse(Crypto.decrypt(encryptUserInfo))
2481
+ } else {
2482
+ return {}
2483
+ }
2418
2484
  }
2419
2485
 
2420
2486
  var CCUser = /*#__PURE__*/Object.freeze({
@@ -2425,8 +2491,149 @@ var CCUser = /*#__PURE__*/Object.freeze({
2425
2491
  getUserJwtInfo: getUserJwtInfo
2426
2492
  });
2427
2493
 
2428
- let CCDK = { CCDB, CCApplication, CCAxios: CCHttp$1, CCUser, CCCrypto: Crypto, CCDetail, CCList, CCToken, CCConfig, CCLoad, CCLog, CCMenu, CCUtils, CCHttp, CCObject, CCPage, CCSentry, CCSide, CCBus, CCCall, CCCommon, CCMessage };
2429
- Vue.prototype.$CCDK = CCDK;
2494
+ /**
2495
+ * 判断 hash数组是否为空
2496
+ * @param arr
2497
+ * true 为空 false为非空
2498
+ */
2499
+ function emptyArray(arr) {
2500
+ if (!(arr instanceof Object)) {
2501
+ throw new Error('Illegal parameters')
2502
+ }
2503
+ for (let key in arr) {
2504
+ if (arr[key]) {
2505
+ return false
2506
+ }
2507
+ }
2508
+ return true
2509
+ }
2510
+
2511
+ var CCArray = /*#__PURE__*/Object.freeze({
2512
+ __proto__: null,
2513
+ emptyArray: emptyArray
2514
+ });
2515
+
2516
+ /**
2517
+ * 根据name获取cookie
2518
+ * @param {string} name cookies的name
2519
+ * @returns 获取的值
2520
+ */
2521
+ function getCookie(name) {
2522
+ let prefix = name + "=";
2523
+ let start = document.cookie.indexOf(prefix);
2524
+
2525
+ if (start == -1) {
2526
+ return null;
2527
+ }
2528
+
2529
+ let end = document.cookie.indexOf(";", start + prefix.length);
2530
+ if (end == -1) {
2531
+ end = document.cookie.length;
2532
+ }
2533
+
2534
+ let value = document.cookie.substring(start + prefix.length, end);
2535
+ return unescape(value);
2536
+ }
2537
+
2538
+ /**
2539
+ * 判断是否是IE浏览器,包括Edge浏览器
2540
+ * @returns
2541
+ */
2542
+ function IEVersion() {
2543
+ let userAgent = navigator.userAgent; // 取得浏览器的userAgent字符串
2544
+ let isOpera = userAgent.indexOf('Opera') > -1; // 判断是否Opera浏览器
2545
+ let isIE = userAgent.indexOf('compatible') > -1 && userAgent.indexOf('MSIE') > -1 && !isOpera; // 判断是否IE浏览器
2546
+ let isEdge = userAgent.indexOf('Edge') > -1 && !isIE; // 判断是否IE的Edge浏览器
2547
+ if (isIE) {
2548
+ let reIE = new RegExp('MSIE (\\d+\\.\\d+);');
2549
+ reIE.test(userAgent);
2550
+ let fIEVersion = parseFloat(RegExp['$1']);
2551
+ if (fIEVersion === 7) {
2552
+ return 'IE7'
2553
+ } else if (fIEVersion === 8) {
2554
+ return 'IE8'
2555
+ } else if (fIEVersion === 9) {
2556
+ return 'IE9'
2557
+ } else if (fIEVersion === 10) {
2558
+ return 'IE10'
2559
+ } else if (fIEVersion === 11) {
2560
+ return 'IE11'
2561
+ } else {
2562
+ return '0'
2563
+ }// IE版本过低
2564
+ } else if (isEdge) {
2565
+ return 'edge'
2566
+ } else {
2567
+ return '-1'// 非IE
2568
+ }
2569
+ }
2570
+ function getBrowserType() {
2571
+ let browserType = ''; //内置浏览器类型 飞书 企业微信 微信 钉钉
2572
+ let _userAgent = navigator.userAgent;
2573
+ if (_userAgent?.includes('Lark')) {
2574
+ browserType = 'feishu';
2575
+ } else if (_userAgent?.includes('MicroMessenger')) {
2576
+ browserType = 'qiyeweixin';
2577
+ } else if (_userAgent?.includes('micromessenger')) {
2578
+ browserType = 'weixin';
2579
+ } else if (_userAgent?.includes('DingTalk')) {
2580
+ browserType = 'dingding';
2581
+ }
2582
+ return browserType
2583
+
2584
+ }
2585
+ function getUrl(path) {
2586
+ let browserType = getBrowserType();
2587
+
2588
+ let url = ''; // 跳转链接
2589
+ let appid = 'cli_a3e37d398e7bd00c';
2590
+ if (browserType == 'feishu') {
2591
+ url = `https://applink.feishu.cn/client/web_app/open?appId=${appid}&mode=window&lk_target_url=${encodeURIComponent(location.origin + '/' + path)}`;
2592
+ } else {
2593
+ url = path;
2594
+ }
2595
+ return url
2596
+ }
2597
+
2598
+ var CCBrower = /*#__PURE__*/Object.freeze({
2599
+ __proto__: null,
2600
+ getCookie: getCookie,
2601
+ IEVersion: IEVersion,
2602
+ getBrowserType: getBrowserType,
2603
+ getUrl: getUrl
2604
+ });
2605
+
2606
+ /**
2607
+ * @Description: 按钮Prop实例化对象
2608
+ */
2609
+ class Button {
2610
+ constructor({ label, notShow = false, type, disabled, action, cssClass = 'small', danger, checkedLength, role, resourceCode, icon }) {
2611
+ this.label = label; // 显示文字
2612
+ this.notShow = notShow; // 是否显示
2613
+ this.type = type; // 显示类型
2614
+ this.disabled = disabled; // 是否禁用
2615
+ this.action = action; // 派发事件
2616
+ this.cssClass = cssClass; // 引用样式
2617
+ this.danger = danger;
2618
+ this.checkedLength = checkedLength;
2619
+ this.icon = icon;
2620
+ this.role = role;
2621
+ this.resourceCode = resourceCode;
2622
+ }
2623
+ }
2624
+
2625
+ // eslint-disable-next-line no-unused-vars
2626
+ function createButton({ label, type, disabled, action, cssClass, danger, checkedLength, resourceCode, role, icon }) {
2627
+ return new Button(...arguments)
2628
+ }
2629
+
2630
+ var CCButton = /*#__PURE__*/Object.freeze({
2631
+ __proto__: null,
2632
+ createButton: createButton
2633
+ });
2634
+
2635
+ let CCDK = { CCButton, CCBrower, CCArray, CCDB, CCApplication, CCAxios: CCHttp$1, CCUser, CCCrypto: Crypto, CCDetail, CCList, CCToken, CCConfig, CCLoad, CCLog, CCMenu, CCUtils, CCHttp, CCObject, CCPage, CCSentry, CCSide, CCBus, CCCall, CCCommon, CCMessage };
2636
+ Vue.prototype.$CCDK = CCDK;
2430
2637
  window.$CCDK = CCDK;
2431
2638
 
2432
2639
  export { CCDK as default };