cloudcc-ccdk 0.9.33 → 0.9.34

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