ocpview-plus 1.0.19 → 1.1.2

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.
@@ -123,9 +123,9 @@ function getCommonUrlParam (_self, _param, _type) {
123
123
  let token = caseMethod.getToken();
124
124
  let end_id = caseMethod.getEnt_id();
125
125
  let para = _param;
126
- if (!para) {
126
+ if (!para) {
127
127
  para = {};
128
- }
128
+ }
129
129
  let portalkey = _self.OmdUrl.portalkey;
130
130
  if (!caseMethod.getUrlParam('portalkey')) {
131
131
  portalkey = caseMethod.getUrlParam('portalkey');
@@ -138,11 +138,11 @@ function getCommonUrlParam (_self, _param, _type) {
138
138
  if (token && token.trim() !== '') {
139
139
  url = url + '&ent_id=' + end_id + '&token=' + token + '&timestamp=' + new Date().getTime() + '&format=' + _self.OmdUrl.format + '&app_key=' + _self.OmdUrl.appKey + '&portalkey=' + portalkey + '&ver=' + _self.OmdUrl.ver;
140
140
  if (_self.OmdUrl.signMethod.trim().length !== 0 && _self.OmdUrl.secret.trim().length != 0) {
141
- url = url + '&sign_method=' + _self.OmdUrl.signMethod + '&sign=';
141
+ url = url + '&sign_method=' + _self.OmdUrl.signMethod + '&sign=';
142
142
  let secret = _self.OmdUrl.appKey+'='+_self.OmdUrl.secret+'&body='+JSON.stringify(para).toString()+'&token='+token;
143
143
  if (_self.OmdUrl.getMd5 !== undefined) {
144
144
  secret = _self.OmdUrl.getMd5(para, token);
145
- }
145
+ }
146
146
  url = url+ md5(secret);
147
147
  }
148
148
  } else {
@@ -164,7 +164,7 @@ function getCommonUrlParam (_self, _param, _type) {
164
164
  let secret = _self.OmdUrl.appKey+'='+_self.OmdUrl.secret+'&body='+JSON.stringify(para).toString()+'&token='+token;
165
165
  if (_self.OmdUrl.getMd5 !== undefined) {
166
166
  secret = _self.OmdUrl.getMd5(para, token);
167
- }
167
+ }
168
168
  temp.sign = md5(secret);
169
169
  } else {
170
170
  let _session = { 'ent_id': end_id, 'user_id': _self.OmdUrl.uid,'user_code': _self.OmdUrl.uid, 'user_name': _self.OmdUrl.uname };
@@ -195,31 +195,31 @@ function basePost (url, method, postdata, _self , _type) {
195
195
  axios.get(url, postdata, {
196
196
  params: temp
197
197
  })
198
- .then(response => {
199
- resolve(response.data);
200
- }, err => {
201
- reject(err);
202
- })
203
- .catch((error) => {
204
- reject(error);
205
- });
198
+ .then(response => {
199
+ resolve(response.data);
200
+ }, err => {
201
+ reject(err);
202
+ })
203
+ .catch((error) => {
204
+ reject(error);
205
+ });
206
206
  });
207
207
  } else {
208
208
  return new Promise((resolve, reject) => {
209
209
  axios.post(url, postdata, {
210
210
  params: temp
211
211
  })
212
- .then(response => {
213
- resolve(response.data);
214
- }, err => {
215
- reject(err);
216
- })
217
- .catch((error) => {
218
- reject(error);
219
- });
212
+ .then(response => {
213
+ resolve(response.data);
214
+ }, err => {
215
+ reject(err);
216
+ })
217
+ .catch((error) => {
218
+ reject(error);
219
+ });
220
220
  });
221
221
  }
222
-
222
+
223
223
  }
224
224
 
225
225
  function successRequest (data, _successFunc, _failFunc, _errorFunc, _self) {
@@ -394,13 +394,13 @@ caseMethod.synchroPost = function ( _baseUrl, _method, _param, _successFunc, _fa
394
394
  _self.alert(errorThrown, null, '2');
395
395
  }, 1000);
396
396
  }
397
-
397
+
398
398
  return false;// 系统异常
399
399
  }
400
400
  };
401
- if (!_param) {
401
+ if (!_param) {
402
402
  _param = {};
403
- }
403
+ }
404
404
  if (tempType === 'POST') {
405
405
  post.data = JSON.stringify(_param);
406
406
  } else {
@@ -425,7 +425,7 @@ caseMethod.getOmdUrlConfig = function (_self) {
425
425
  } else {
426
426
  obj[pro] = pageData[pro];
427
427
  }
428
- }
428
+ }
429
429
  }
430
430
  _self.config.globalProperties.OmdUrl = Object.assign({}, _self.config.globalProperties.OmdUrl, obj);
431
431
  }
@@ -439,13 +439,13 @@ caseMethod.getPortalConfig = function (_self) {
439
439
  dataType: 'json',
440
440
  success: function(res) {
441
441
  if (res.returncode == 0) {
442
- if (res.data) {
443
- if (res.data.OmdUrl) {
444
- let OmdUrl = JSON.parse(res.data.OmdUrl);
445
- _self.config.globalProperties.OmdUrl = Object.assign({}, _self.config.globalProperties.OmdUrl, OmdUrl);
446
- }
447
- _self.config.globalProperties.portalConfig = res.data;
448
- }
442
+ if (res.data) {
443
+ if (res.data.OmdUrl) {
444
+ let OmdUrl = JSON.parse(res.data.OmdUrl);
445
+ _self.config.globalProperties.OmdUrl = Object.assign({}, _self.config.globalProperties.OmdUrl, OmdUrl);
446
+ }
447
+ _self.config.globalProperties.portalConfig = res.data;
448
+ }
449
449
  }
450
450
  }
451
451
  });
@@ -461,7 +461,7 @@ function getCongouCookie(value) {
461
461
  return v.split(':')[1];
462
462
  } else {
463
463
  return value;
464
- }
464
+ }
465
465
  } catch (e) {
466
466
  return value;
467
467
  }
@@ -514,8 +514,8 @@ caseMethod.getUserName = function (v) {
514
514
  if (Cookies.get('user_code')) {
515
515
  username = '[' + Cookies.get('user_code') + ']' +Cookies.get('user_name');
516
516
  }
517
- }
518
- }
517
+ }
518
+ }
519
519
  return username;
520
520
  };
521
521
 
@@ -523,43 +523,43 @@ caseMethod.getPortalMkt =function() {
523
523
  let obj = {};
524
524
  obj.shopId = Cookies.get('shopId');
525
525
  obj.shopCode = Cookies.get('shopCode');
526
- obj.shopName = Cookies.get('shopName');
526
+ obj.shopName = Cookies.get('shopName');
527
527
  return obj;
528
528
  },
529
- caseMethod.getSession = function() {
530
- let obj = {};
531
- let user_name = caseMethod.getUserName();
532
- let user_code = caseMethod.getUserCode();
533
- let user_id = Cookies.get('user_id');
534
- let ent_id = caseMethod.getEnt_id();
535
- let token = caseMethod.getToken();
536
- if (user_name) {
537
- obj['user_name'] = user_name;
538
- } else {
539
- obj['user_name'] = '';
540
- }
541
- if (user_code) {
542
- obj['user_code'] = user_code;
543
- } else {
544
- obj['user_code'] = '';
545
- }
546
- if (user_id) {
547
- obj['user_id'] = user_id;
548
- } else {
549
- obj['user_id'] = '';
550
- }
551
- if (ent_id) {
552
- obj['ent_id'] = ent_id;
553
- } else {
554
- obj['ent_id'] = '';
555
- }
556
- if (token) {
557
- obj['token'] = token;
558
- } else {
559
- obj['token'] = '';
560
- }
561
- return JSON.stringify(obj);
562
- };
529
+ caseMethod.getSession = function() {
530
+ let obj = {};
531
+ let user_name = caseMethod.getUserName();
532
+ let user_code = caseMethod.getUserCode();
533
+ let user_id = Cookies.get('user_id');
534
+ let ent_id = caseMethod.getEnt_id();
535
+ let token = caseMethod.getToken();
536
+ if (user_name) {
537
+ obj['user_name'] = user_name;
538
+ } else {
539
+ obj['user_name'] = '';
540
+ }
541
+ if (user_code) {
542
+ obj['user_code'] = user_code;
543
+ } else {
544
+ obj['user_code'] = '';
545
+ }
546
+ if (user_id) {
547
+ obj['user_id'] = user_id;
548
+ } else {
549
+ obj['user_id'] = '';
550
+ }
551
+ if (ent_id) {
552
+ obj['ent_id'] = ent_id;
553
+ } else {
554
+ obj['ent_id'] = '';
555
+ }
556
+ if (token) {
557
+ obj['token'] = token;
558
+ } else {
559
+ obj['token'] = '';
560
+ }
561
+ return JSON.stringify(obj);
562
+ };
563
563
 
564
564
  caseMethod.getUrlParam = function (name) {
565
565
  let reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)'); // 构造一个含有目标参数的正则表达式对象
@@ -572,7 +572,7 @@ caseMethod.getUrlParam = function (name) {
572
572
  if (!r) {
573
573
  if (list.length > 2) {
574
574
  r = list[2].match(reg); // 匹配目标参数
575
- }
575
+ }
576
576
  }
577
577
  if (r) return decodeURI(r[2]); return ''; // 返回参数值
578
578
  };
@@ -606,7 +606,7 @@ caseMethod.initGlobal = function (_self, _obj, isInitUser) {
606
606
 
607
607
  };
608
608
 
609
- caseMethod.getUserModuleMethod = function (curlmodulecode) {
609
+ caseMethod.getUserModuleMethod = function (curlmodulecode) {
610
610
  let reModuleMethod = null;
611
611
  let token = caseMethod.getToken();
612
612
  if (!token) {
@@ -628,7 +628,7 @@ caseMethod.getUserModuleMethod = function (curlmodulecode) {
628
628
  }
629
629
  let srvkey = caseMethod.getUrlParam('srvkey');
630
630
  if (srvkey === 'cloud') {
631
- portalUrl = this.OmdUrl.mdm;
631
+ portalUrl = this.OmdUrl.mdm;
632
632
  }
633
633
 
634
634
  let param = {};
@@ -638,7 +638,7 @@ caseMethod.getUserModuleMethod = function (curlmodulecode) {
638
638
  reModuleMethod = data;
639
639
  }, null);
640
640
  return reModuleMethod;
641
-
641
+
642
642
  };
643
643
  caseMethod.checkModuleByToken = function () {
644
644
  let powerflag = false;
@@ -655,15 +655,15 @@ caseMethod.checkModuleByToken = function () {
655
655
  }
656
656
  if(this.portalkey != 'congou') {
657
657
  return powerflag;
658
- }
659
-
658
+ }
659
+
660
660
  let portalUrl = '/mall-portal-rest/portalesb/ocmrest';
661
661
  if (this.OmdUrl.portal) {
662
662
  portalUrl = this.OmdUrl.portal;
663
663
  }
664
-
664
+
665
665
  let pathname = location.pathname;
666
-
666
+
667
667
  let searchParam = {
668
668
  'token': token,
669
669
  'modulecode': modulecode,
@@ -671,7 +671,7 @@ caseMethod.checkModuleByToken = function () {
671
671
  };
672
672
  let srvkey = caseMethod.getUrlParam('srvkey');
673
673
  if (srvkey === 'cloud') {
674
- portalUrl = this.OmdUrl.mdm;
674
+ portalUrl = this.OmdUrl.mdm;
675
675
  }
676
676
  let method = 'runtime.modulesrivce.checkmodulebytoken';
677
677
  this.synchroPost(portalUrl, method, searchParam, function(data) {
@@ -707,7 +707,7 @@ caseMethod.getDict = function(str, _fields) {
707
707
  let self = this;
708
708
  this.synchroPost(this.OmdUrl.omp, 'omp.work.dict.getbydictgroupcode', searchParam,function(data) {
709
709
  for (let pro of str2) {
710
- self.$Method.setLocalStorage('dictkey_' + pro , data[pro], self.OmdUrl.dictExpire);
710
+ self.$Method.setLocalStorage('dictkey_' + pro , data[pro], self.OmdUrl.dictExpire);
711
711
  _dicData[pro] = data[pro];
712
712
  }
713
713
  }, null);
@@ -779,7 +779,7 @@ caseMethod.getQueryConfig = function (selectkey) {
779
779
  return config;
780
780
  }
781
781
  }
782
-
782
+
783
783
  };
784
784
  caseMethod.getBillmoduleid = function(billtype) {
785
785
  let billmoduleid = '';
@@ -816,13 +816,13 @@ caseMethod.getHelpdocumenturl = function() {
816
816
  };
817
817
  caseMethod.getHelpId = function(helpType,helpIndex) {
818
818
  let helpId = '';
819
- let para = {};
820
- para.helpType = helpType;
821
- para.helpIndex = helpIndex;
819
+ let para = {};
820
+ para.helpType = helpType;
821
+ para.helpIndex = helpIndex;
822
822
  this.synchroPost(this.OmdUrl.amp, 'usercenter.helpconfig.getHelpId', para, function(data) {
823
823
  if(data && data.helpId){
824
- helpId = data.helpId
825
- }
824
+ helpId = data.helpId
825
+ }
826
826
  },function(data) {
827
827
  helpId= '';
828
828
  },function(data) {
@@ -843,7 +843,7 @@ caseMethod.getConditionValue = function (name, value, calculator, config) {
843
843
  temp['<'] = this.$Method.getNextMonthFirstDay(value);
844
844
  } else {
845
845
  temp['<'] = this.$Method.getTomorrow(value);
846
- }
846
+ }
847
847
  condition[name] = temp;
848
848
  } else {
849
849
  if (name === 'inputer' || name === 'auditor' || name === 'canceler') {
@@ -916,7 +916,7 @@ caseMethod.getEnt_id = function(_self) {
916
916
  ent_id = lock_entid;
917
917
  }
918
918
  }
919
-
919
+
920
920
  return ent_id;
921
921
  };
922
922
  caseMethod.getToken = function(_self) {
@@ -924,7 +924,7 @@ caseMethod.getToken = function(_self) {
924
924
  if (!_self) {
925
925
  if (this.token) {
926
926
  token = this.token;
927
- }
927
+ }
928
928
  } else {
929
929
  if (_self.token) {
930
930
  token = _self.token;
@@ -940,6 +940,9 @@ caseMethod.getToken = function(_self) {
940
940
  }
941
941
  return token;
942
942
  };
943
+
944
+
945
+
943
946
  caseMethod.getModulecode= function () {
944
947
  let modulecode = '';
945
948
  modulecode = caseMethod.getUrlParam('modulecode');
@@ -970,14 +973,14 @@ caseMethod.downloadFile = function(url, that) {
970
973
  let reader = new FileReader();
971
974
  let headerStr = decodeURI(this.getResponseHeader('content-disposition'));
972
975
  let filename = headerStr.replace('attachment;filename*=UTF-8\'\'','');
973
- filename = filename.replace('attachment;filename=','');
976
+ filename = filename.replace('attachment;filename=','');
974
977
  // let filename = this.getAllResponseHeaders().split(';')[2].split('\n')[0].split('filename=')[1];
975
978
  reader.readAsDataURL(blob); // 转换为base64,可以直接放入a表情href
976
979
  filename = decodeURIComponent(filename);
977
980
  //去除空格
978
- filename = filename.replace(/\ +/g,'');
981
+ filename = filename.replace(/\ +/g,'');
979
982
  //去除换行回车
980
- filename = filename.replace(/[\r\n]/g,'');
983
+ filename = filename.replace(/[\r\n]/g,'');
981
984
  reader.onload = function () {
982
985
 
983
986
  // 转换完成,创建一个a标签用于下载
@@ -1033,7 +1036,7 @@ caseMethod.doExportExcel = function(_baseUrl,_method,_param,exportType,that){
1033
1036
  _paramStr = _paramStr.replaceAll('+','%2B');
1034
1037
  //_paramStr = _paramStr.replaceAll(':','%3A');
1035
1038
  url = encodeURI(url + '&param=' + _paramStr);
1036
- let userid = Cookies.get('user_id');
1039
+ let userid = Cookies.get('user_id');
1037
1040
  let user_code = Cookies.get('user_code');
1038
1041
  if (userid) {
1039
1042
  url=url+encodeURI('&user_id='+userid);
@@ -1082,6 +1085,97 @@ caseMethod.doExportReport= function(_baseUrl,_method,_param,that){
1082
1085
  caseMethod.downloadFile(url, that);
1083
1086
  };
1084
1087
 
1088
+ caseMethod.doBillExport = function (baseUrl, method, param, ctx) {
1089
+ // 拼 URL
1090
+ const _param = Object.assign({}, param);
1091
+ const url = encodeURI(
1092
+ getresturl(baseUrl, method, _param, ctx) + '&param=' + JSON.stringify(_param)
1093
+ );
1094
+
1095
+ // 显示加载动画
1096
+ ctx.$Spin.show({
1097
+ render: h => h('div', '导出中...,请勿关闭!')
1098
+ });
1099
+
1100
+ caseMethod.downloadExcel(url, ctx, param);
1101
+ };
1102
+
1103
+
1104
+ caseMethod.downloadExcel = function (url, ctx, postObj = {}) {
1105
+ const xhr = new XMLHttpRequest();
1106
+ xhr.open('POST', url, true);
1107
+ xhr.responseType = 'blob';
1108
+ xhr.setRequestHeader('Content-Type', 'application/json');
1109
+
1110
+ xhr.onload = function () {
1111
+ ctx.$Spin.hide();
1112
+
1113
+ if (this.status !== 200) {
1114
+ ctx.alert?.(`导出失败:${this.status} ${this.statusText}`);
1115
+ return;
1116
+ }
1117
+
1118
+ const blob = this.response;
1119
+
1120
+ const reader = new FileReader();
1121
+ reader.onload = () => {
1122
+ let text = reader.result;
1123
+
1124
+ try {
1125
+ const json = JSON.parse(text);
1126
+ if (json.returncode && json.returncode !== '0') {
1127
+ ctx.alert?.(json.data || '导出失败');
1128
+ return;
1129
+ }
1130
+ } catch (e) {
1131
+ }
1132
+
1133
+ let filename = buildFilename(postObj, xhr);
1134
+ const a = document.createElement('a');
1135
+ a.href = URL.createObjectURL(blob);
1136
+ a.download = filename;
1137
+ document.body.appendChild(a);
1138
+ a.click();
1139
+ setTimeout(() => document.body.removeChild(a), 120);
1140
+ };
1141
+
1142
+ reader.readAsText(blob);
1143
+ };
1144
+
1145
+ xhr.onerror = () => {
1146
+ ctx.$Spin.hide();
1147
+ ctx.alert?.('网络错误,导出失败');
1148
+ };
1149
+
1150
+ xhr.send(JSON.stringify(postObj));
1151
+ };
1152
+
1153
+ function buildFilename(postObj, xhr) {
1154
+ // 优先使用后端返回的 Content-Disposition 文件名
1155
+ let cd = xhr.getResponseHeader('content-disposition');
1156
+ if (cd && cd.includes('filename=')) {
1157
+ let match = cd.match(/filename\*=UTF-8''(.+)/i);
1158
+ if (match && match[1]) return decodeURIComponent(match[1]);
1159
+
1160
+ let tmp = cd.split('filename=')[1];
1161
+ if (tmp) return tmp.replace(/["']/g, '');
1162
+ }
1163
+
1164
+ // 默认文件名
1165
+ const now = new Date();
1166
+ const t = [
1167
+ now.getFullYear(),
1168
+ String(now.getMonth() + 1).padStart(2, '0'),
1169
+ String(now.getDate()).padStart(2, '0'),
1170
+ String(now.getHours()).padStart(2, '0'),
1171
+ String(now.getMinutes()).padStart(2, '0'),
1172
+ String(now.getSeconds()).padStart(2, '0')
1173
+ ].join('');
1174
+
1175
+ const billmoduleid = postObj.billmoduleid || 'export';
1176
+ return `${t}${billmoduleid}.xls`;
1177
+ }
1178
+
1085
1179
  caseMethod.getFilesInfo = function(billno, billmoduleid,notdelfile,scenetype, callBackMethod) {
1086
1180
  let usercode = caseMethod.getUserCode();
1087
1181
  let username = caseMethod.getUserName();
@@ -1109,7 +1203,7 @@ caseMethod.getFilesInfo = function(billno, billmoduleid,notdelfile,scenetype, ca
1109
1203
  data.push(obj);
1110
1204
  });
1111
1205
  }
1112
- callBackMethod(data);
1206
+ callBackMethod(data);
1113
1207
  }, null, null, 'get');
1114
1208
  };
1115
1209
 
@@ -1135,7 +1229,7 @@ caseMethod.getFilesInfoByIdkey = function(idkey, callBackMethod) {
1135
1229
  data.push(obj);
1136
1230
  });
1137
1231
  }
1138
- callBackMethod(data);
1232
+ callBackMethod(data);
1139
1233
  }, null, null, 'get');
1140
1234
  };
1141
1235
  caseMethod.getFileInfo = function(filekey,callBackMethod) {
@@ -1160,7 +1254,7 @@ caseMethod.getFileInfo = function(filekey,callBackMethod) {
1160
1254
  data.push(obj);
1161
1255
  });
1162
1256
  }
1163
- callBackMethod(data);
1257
+ callBackMethod(data);
1164
1258
  }, null, null, 'get');
1165
1259
  };
1166
1260
  caseMethod.setUrlSuffix = function(url,self) {
@@ -1168,13 +1262,13 @@ caseMethod.setUrlSuffix = function(url,self) {
1168
1262
  let token = caseMethod.getUrlParam('token');
1169
1263
  let user_code = caseMethod.getUrlParam('usercode');
1170
1264
  let portalkey = caseMethod.getUrlParam('portalkey')
1171
- if (url) {
1172
- if (url.indexOf('?') != -1) {
1173
- return url +'&token='+token + '&srvkey=' + srvkey + '&app_key=' +self.OmdUrl.appKey + '&secret=' + self.OmdUrl.secret + '&portalkey=' + portalkey + '&usercode=' + user_code;
1174
- } else {
1175
- return url +'?token='+token + '&srvkey=' + srvkey + '&app_key=' +self.OmdUrl.appKey + '&secret=' + self.OmdUrl.secret + '&portalkey=' + portalkey + '&usercode=' + user_code;
1176
- }
1177
- }
1178
- return url;
1265
+ if (url) {
1266
+ if (url.indexOf('?') != -1) {
1267
+ return url +'&token='+token + '&srvkey=' + srvkey + '&app_key=' +self.OmdUrl.appKey + '&secret=' + self.OmdUrl.secret + '&portalkey=' + portalkey + '&usercode=' + user_code;
1268
+ } else {
1269
+ return url +'?token='+token + '&srvkey=' + srvkey + '&app_key=' +self.OmdUrl.appKey + '&secret=' + self.OmdUrl.secret + '&portalkey=' + portalkey + '&usercode=' + user_code;
1270
+ }
1271
+ }
1272
+ return url;
1179
1273
  }
1180
- export default caseMethod;
1274
+ export default caseMethod;