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