ocpview-plus 1.3.14 → 1.3.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (213) hide show
  1. package/README.md +55 -43
  2. package/dist/ocpviewplus.min.esm.js +574 -482
  3. package/dist/ocpviewplus.min.js +9 -9
  4. package/dist/style.css +1 -1
  5. package/dist/styles/efviewplus.css +1 -1
  6. package/package.json +146 -146
  7. package/src/components/base/ContractPrintMixins.js +30 -30
  8. package/src/components/base/controlbase.vue +190 -190
  9. package/src/components/base/controlbox.vue +102 -102
  10. package/src/components/base/index.js +2 -2
  11. package/src/components/base/load.js +19 -19
  12. package/src/components/base/probase.js +220 -220
  13. package/src/components/base/size.js +78 -78
  14. package/src/components/billbox/billbox.vue +67 -67
  15. package/src/components/billbox/index.js +1 -1
  16. package/src/components/cascaderbox/cascaderbox.vue +184 -184
  17. package/src/components/cascaderbox/index.js +2 -2
  18. package/src/components/checkbox/checkbox.vue +75 -75
  19. package/src/components/checkbox/checkgroupbox.vue +103 -103
  20. package/src/components/checkbox/index.js +2 -2
  21. package/src/components/colorbox/colorbox.vue +43 -43
  22. package/src/components/colorbox/index.js +1 -1
  23. package/src/components/combobox/combobox.vue +219 -219
  24. package/src/components/combobox/index.js +1 -1
  25. package/src/components/conditionbox/conditionbase.vue +194 -194
  26. package/src/components/conditionbox/conditionbox.vue +62 -62
  27. package/src/components/conditionbox/conditionfilterbox.vue +479 -479
  28. package/src/components/conditionbox/conditionselectorbox.vue +237 -237
  29. package/src/components/conditionbox/index.js +4 -4
  30. package/src/components/conditionbox/queryconditionbox.vue +25 -25
  31. package/src/components/conditionbox/queryconditionboxbase.vue +123 -123
  32. package/src/components/conditionbox/searchconditionbox.vue +113 -113
  33. package/src/components/conditionbox/searchgrid.vue +391 -391
  34. package/src/components/datebox/DateBoxV1.vue +22 -22
  35. package/src/components/datebox/datebox.vue +129 -129
  36. package/src/components/datebox/daterangebox.vue +154 -154
  37. package/src/components/datebox/index.js +5 -5
  38. package/src/components/form/baseform.vue +676 -676
  39. package/src/components/form/detailsbox.vue +487 -487
  40. package/src/components/form/formbox.vue +28 -28
  41. package/src/components/form/formcardbox.vue +267 -267
  42. package/src/components/form/formcardbox2.vue +228 -228
  43. package/src/components/form/formcardgroupbox.vue +251 -251
  44. package/src/components/form/formcompro.js +18 -18
  45. package/src/components/form/formdetail.vue +128 -128
  46. package/src/components/form/formdetailtwo.vue +302 -302
  47. package/src/components/form/index.js +9 -9
  48. package/src/components/form/toolanchor.js +45 -45
  49. package/src/components/form/workform.vue +167 -167
  50. package/src/components/grid/basegrid.vue +1062 -1062
  51. package/src/components/grid/editgrid.vue +51 -51
  52. package/src/components/grid/editgridbase.vue +1062 -1062
  53. package/src/components/grid/editgridcard.vue +193 -193
  54. package/src/components/grid/expandrow.vue +137 -137
  55. package/src/components/grid/index.js +5 -5
  56. package/src/components/grid/viewgrid.vue +121 -121
  57. package/src/components/grid/viewgridbase.vue +1286 -1286
  58. package/src/components/icon/common-icon.vue +53 -53
  59. package/src/components/icon/eicon.vue +28 -28
  60. package/src/components/icon/icons.vue +42 -42
  61. package/src/components/icon/index.js +1 -1
  62. package/src/components/label/index.js +2 -2
  63. package/src/components/label/showtext.vue +94 -94
  64. package/src/components/load/loadcartoon.vue +227 -227
  65. package/src/components/map/index.js +1 -1
  66. package/src/components/map/mapbox.vue +348 -348
  67. package/src/components/masterplate/RewriteBillListDetails/BillInfoPanel.vue +184 -184
  68. package/src/components/masterplate/RewriteBillListDetails/BillInfoPanelEditTable.vue +838 -838
  69. package/src/components/masterplate/RewriteBillListDetails/BillInfoPanelEditTableControlbox.vue +126 -126
  70. package/src/components/masterplate/RewriteBillListDetails/BillInfoPanelEditTableControlboxNumberbox.vue +27 -27
  71. package/src/components/masterplate/RewriteBillListDetails/BillListPanel.vue +126 -126
  72. package/src/components/masterplate/RewriteBillListDetails/BillListPanelQueryBar.vue +280 -280
  73. package/src/components/masterplate/RewriteBillListDetails/BillListPanelTable.vue +346 -346
  74. package/src/components/masterplate/RewriteBillListDetails/index.vue +325 -325
  75. package/src/components/masterplate/RewriteBillListDetails/mixins/useVxeGridEditTypeKeydownEventHook.js +251 -251
  76. package/src/components/masterplate/RewriteListdetails/BillListPanelV2.vue +115 -115
  77. package/src/components/masterplate/RewriteListdetails/BillListPanelV2QueryBar.vue +24 -24
  78. package/src/components/masterplate/RewriteListdetails/BillListPanelV3.vue +121 -121
  79. package/src/components/masterplate/RewriteListdetails/BillListPanelV3QueryBar.vue +275 -275
  80. package/src/components/masterplate/RewriteListdetails/indexV2.vue +320 -320
  81. package/src/components/masterplate/RewriteListdetails/indexV3.vue +331 -331
  82. package/src/components/masterplate/appendix.vue +586 -586
  83. package/src/components/masterplate/approval.vue +863 -863
  84. package/src/components/masterplate/base.vue +1028 -1028
  85. package/src/components/masterplate/billasyncimport.vue +614 -614
  86. package/src/components/masterplate/billconditionbox.vue +223 -223
  87. package/src/components/masterplate/billconditionsbox.vue +427 -427
  88. package/src/components/masterplate/billdetailform.vue +1028 -1028
  89. package/src/components/masterplate/billimport.vue +301 -301
  90. package/src/components/masterplate/billquerygrid.vue +391 -391
  91. package/src/components/masterplate/billsinglegrid.vue +234 -234
  92. package/src/components/masterplate/birtreport.vue +185 -185
  93. package/src/components/masterplate/contractappendix.vue +688 -688
  94. package/src/components/masterplate/detailbtntoolbar.vue +311 -311
  95. package/src/components/masterplate/detailsbox.vue +386 -386
  96. package/src/components/masterplate/editgridcard.vue +292 -292
  97. package/src/components/masterplate/editgridcard2.vue +127 -127
  98. package/src/components/masterplate/formcard.vue +105 -105
  99. package/src/components/masterplate/formcardgroupbox.vue +167 -167
  100. package/src/components/masterplate/formdetailtwo.vue +366 -366
  101. package/src/components/masterplate/gridcolset.vue +226 -226
  102. package/src/components/masterplate/index.js +54 -54
  103. package/src/components/masterplate/layouttemplate.vue +51 -51
  104. package/src/components/masterplate/leftlistrightdetails.vue +581 -581
  105. package/src/components/masterplate/leftlistrightlist.vue +464 -464
  106. package/src/components/masterplate/lefttreerightdetails.vue +636 -636
  107. package/src/components/masterplate/levelreport.vue +510 -510
  108. package/src/components/masterplate/listbtntoolbar.vue +276 -276
  109. package/src/components/masterplate/listdetails.vue +768 -768
  110. package/src/components/masterplate/operlog.vue +272 -272
  111. package/src/components/masterplate/options.vue +110 -110
  112. package/src/components/masterplate/page.vue +102 -102
  113. package/src/components/masterplate/promptmessage.vue +73 -73
  114. package/src/components/masterplate/querybar.vue +490 -490
  115. package/src/components/masterplate/report.vue +357 -357
  116. package/src/components/masterplate/rowbtntoolbar.vue +126 -126
  117. package/src/components/masterplate/simpletree.vue +137 -137
  118. package/src/components/masterplate/simpleviewgrid.vue +144 -144
  119. package/src/components/mychart/bar/bar.vue +201 -201
  120. package/src/components/mychart/basechart.vue +190 -190
  121. package/src/components/mychart/complexmychart/barline.vue +153 -153
  122. package/src/components/mychart/gauge/gauge.vue +82 -82
  123. package/src/components/mychart/index.js +8 -8
  124. package/src/components/mychart/line/line.vue +201 -201
  125. package/src/components/mychart/liquidfill/liquidfill.vue +108 -108
  126. package/src/components/mychart/pie/pie.vue +95 -95
  127. package/src/components/mychart/radar/radar.vue +121 -121
  128. package/src/components/mychart/scatter/scatter.vue +75 -75
  129. package/src/components/numberbox/NumberBoxV1.vue +39 -39
  130. package/src/components/numberbox/append.js +11 -11
  131. package/src/components/numberbox/index.js +4 -4
  132. package/src/components/numberbox/numberbox.vue +302 -302
  133. package/src/components/numberbox/numberrangebox.vue +422 -422
  134. package/src/components/picturebox/filebox.vue +369 -369
  135. package/src/components/picturebox/index.js +2 -2
  136. package/src/components/picturebox/picturebox.vue +541 -541
  137. package/src/components/picturebox/uploadbox.vue +164 -164
  138. package/src/components/poptagbox/index.js +1 -1
  139. package/src/components/poptagbox/poptagbox.vue +388 -388
  140. package/src/components/poptextbox/index.js +1 -1
  141. package/src/components/poptextbox/poptextbox.vue +624 -624
  142. package/src/components/radiobox/index.js +1 -1
  143. package/src/components/radiobox/radiogroupbox.vue +75 -75
  144. package/src/components/richtextbox/editor.vue +150 -150
  145. package/src/components/richtextbox/index.js +1 -1
  146. package/src/components/richtextbox/richtextbox.vue +448 -448
  147. package/src/components/textbox/index.js +1 -1
  148. package/src/components/textbox/textbox.vue +97 -97
  149. package/src/components/timebox/index.js +1 -1
  150. package/src/components/timebox/timebox.vue +75 -75
  151. package/src/components/toolbar/ebutton.vue +169 -169
  152. package/src/components/toolbar/index.js +3 -3
  153. package/src/components/toolbar/toolbar.vue +445 -445
  154. package/src/components/tree/CompatTree.vue +297 -297
  155. package/src/components/tree/basetree.vue +1098 -1098
  156. package/src/components/tree/index.js +2 -2
  157. package/src/components/tree/treedata.vue +53 -53
  158. package/src/components/tree/treedatabase.vue +189 -189
  159. package/src/components/upload/billimport.vue +233 -233
  160. package/src/components/upload/index.js +1 -1
  161. package/src/components/videobox/index.js +1 -1
  162. package/src/components/videobox/uploadbox.vue +148 -148
  163. package/src/components/videobox/videobox.vue +503 -503
  164. package/src/components/wrichtextbox/editor.vue +219 -219
  165. package/src/components/wrichtextbox/index.js +1 -1
  166. package/src/components/wrichtextbox/wrichtextbox.vue +62 -62
  167. package/src/index.js +231 -231
  168. package/src/locale/format.js +51 -51
  169. package/src/locale/index.js +63 -63
  170. package/src/locale/lang/zh-CN.js +123 -123
  171. package/src/locale/lang/zh-TW.js +114 -114
  172. package/src/locale/lang/zh-UG.js +115 -115
  173. package/src/locale/lang.js +15 -15
  174. package/src/method/case/case.js +1274 -1274
  175. package/src/method/config/queryconfig.js +24 -24
  176. package/src/method/const/const.js +815 -815
  177. package/src/method/index.js +7 -7
  178. package/src/plugins/theme/theme-variable.css +114 -114
  179. package/src/plugins/vxeTable/index.js +241 -241
  180. package/src/plugins/vxeTable/renderer/components/TableFilterInput.vue +51 -51
  181. package/src/plugins/vxeTable/renderer/filter.js +32 -32
  182. package/src/static/excel/exportexcel.js +626 -626
  183. package/src/static/iview/coustom.js +462 -462
  184. package/src/store/index.js +18 -18
  185. package/src/store/modules/app.js +53 -53
  186. package/src/styles/README.md +3 -3
  187. package/src/styles/common.less +80 -80
  188. package/src/styles/components/anchor.less +74 -74
  189. package/src/styles/components/approval.less +135 -135
  190. package/src/styles/components/button.less +208 -208
  191. package/src/styles/components/card.less +51 -51
  192. package/src/styles/components/content.less +38 -38
  193. package/src/styles/components/font.less +313 -313
  194. package/src/styles/components/form.less +71 -71
  195. package/src/styles/components/iconfont/fonts/iconfont.less +1384 -1384
  196. package/src/styles/components/iconfont/fonts/iconfont.svg +703 -703
  197. package/src/styles/components/index.less +16 -16
  198. package/src/styles/components/input.less +290 -290
  199. package/src/styles/components/modal.less +203 -203
  200. package/src/styles/components/page.less +340 -340
  201. package/src/styles/components/select.less +361 -361
  202. package/src/styles/components/steps.less +367 -367
  203. package/src/styles/components/table.less +544 -544
  204. package/src/styles/components/tabs.less +249 -249
  205. package/src/styles/components/upload.less +82 -82
  206. package/src/styles/custom.less +67 -67
  207. package/src/styles/index.less +6 -6
  208. package/src/styles/pack.less +6 -6
  209. package/src/utils/EfuMessenger.js +155 -155
  210. package/src/utils/assist.js +353 -353
  211. package/src/utils/index.js +1 -1
  212. package/src/utils/random_str.js +10 -10
  213. package/src/components/masterplate/detailgridbox.vue +0 -386
@@ -1,1274 +1,1274 @@
1
- import axios from 'axios';
2
- import $ from 'jquery';
3
- import Cookies from 'js-cookie';
4
- import md5 from 'js-md5';
5
- import { Modal } from 'view-ui-plus'
6
-
7
- // async synchro
8
-
9
- let caseMethod = {};
10
-
11
- let OmdUrl = {};
12
- OmdUrl.eid = '0';
13
- OmdUrl.uid = '0';
14
- OmdUrl.uname = 'future';
15
- OmdUrl.format = 'json';
16
- OmdUrl.appKey = 'mall';
17
- OmdUrl.portalkey = 'congou';
18
- OmdUrl.checktoken = 'Y';
19
- OmdUrl.ver = '1.0';
20
- OmdUrl.signMethod = 'MD5';
21
- OmdUrl.secret = '';
22
- OmdUrl.omp = '/mall-work-webin/rest';
23
- OmdUrl.mall = '/mall-work-webin/rest';
24
- OmdUrl.mss = '/mall-work-webin/rest';
25
- OmdUrl.portal = '/mall-portal-rest/portalesb/ocmrest';
26
- OmdUrl.mdm = '/ocm-mdm-webin/rest';
27
- OmdUrl.omc = '/omc-tags-webin/rest';
28
- OmdUrl.member = '/omc-membership-webin/rest';
29
- OmdUrl.accnt = '/omc-accnt-webin/rest';
30
- OmdUrl.work = '/omc-work-webin/rest';
31
- OmdUrl.investment = '/mall-investment-webin/rest';
32
- OmdUrl.uploadfile ='/mss-sysconf-boot/upload';
33
- OmdUrl.delfile ='/mss-sysconf-boot/delete?filekey=';
34
- OmdUrl.downfile = '/mss-sysconf-boot/download?filekey=';
35
- OmdUrl.getfile = '/mss-sysconf-boot/filedata?';
36
- OmdUrl.amp = '/ampOpenapiService/';
37
- OmdUrl.uidespath = OmdUrl.amp;
38
- OmdUrl.helpUrl = 'docs.sjhgo.com';
39
- OmdUrl.mallmdm = '/mall-mdm-webin/rest';
40
- OmdUrl.mallmaster = '/mall-master-webin/rest';
41
- OmdUrl.portal = OmdUrl.mallmdm;
42
- OmdUrl.uiConfigExpire = 24;
43
- OmdUrl.fairyConfigExpire = 24;
44
- OmdUrl.dictExpire = 24;
45
- OmdUrl.operbilllog = '/mss-sysconf-query/rest';
46
- //测试
47
- //OmdUrl.startHelp = 'Y';
48
- //OmdUrl.helpType = '13';
49
- //OmdUrl.portal = '/mall-master-webin/rest';
50
- //OmdUrl.mdm = '/mall-master-webin/rest';
51
-
52
- OmdUrl.getCurHelpUrl = function (that) {
53
- var curHelpUrl = '';
54
- if (that.OmdUrl.startHelp === 'Y') {
55
- if (that.OmdUrl.helpType) {
56
- var modulecodeHelp = that.$Method.getUrlParam('helpindex');
57
- var modulecodeHelpUrl = that.$Method.getLocalStorage('modulecodeHelp_' + that.OmdUrl.helpType + '_' + modulecodeHelp);
58
- if (modulecodeHelpUrl) {
59
- return modulecodeHelpUrl;
60
- }
61
- if (modulecodeHelp) {
62
- var helpUrl = that.OmdUrl.helpUrl;
63
- if (!helpUrl) {
64
- if (that.getHelpdocumenturl) {
65
- helpUrl = that.getHelpdocumenturl();
66
- }
67
- }
68
- if (helpUrl) {
69
- let helpId = that.getHelpId(that.OmdUrl.helpType, modulecodeHelp);
70
- if (helpId) {
71
- curHelpUrl ='http://' + helpUrl + '/web/#/p/' + helpId;
72
- } else {
73
- curHelpUrl = 'http://' + helpUrl + '/web/#/' + that.OmdUrl.helpType + '?page_id=' + modulecodeHelp;
74
- }
75
- }
76
- that.$Method.setLocalStorage('modulecodeHelp_' +that.OmdUrl.helpType + '_' + modulecodeHelp,curHelpUrl,that.OmdUrl.uiConfigExpire)
77
- }
78
- }
79
- }
80
- return curHelpUrl;
81
- };
82
-
83
- caseMethod.OmdUrl = OmdUrl;
84
-
85
- caseMethod.alert = function (_strerr, _title, _flag) {
86
- if (!_flag) {
87
- _flag = '1';
88
- }
89
- if (_strerr && typeof _strerr === 'string') {
90
- _strerr = _strerr.replace(new RegExp('</xmp>', 'gi'), '</txmp>');
91
- _strerr = _strerr.replace(new RegExp('<xmp', 'gi'), '<txmp');
92
- _strerr = '<xmp style="margin: 0;white-space:break-spaces;">' +_strerr + '</xmp>';
93
- }
94
- _flag = _flag + '';
95
- if (_flag === '2') {
96
- Modal.error({
97
- title: '系统警告',
98
- content: '<div style="word-wrap:break-word">' + _strerr + '</div>'
99
- });
100
- } else if (_flag === '3') {
101
- if (!_title) {
102
- _title = '成功';
103
- }
104
- Modal.success({
105
- title:_title,
106
- content: '<div style="word-wrap:break-word">' + _strerr + '</div>'
107
- });
108
- } else {
109
- if (!_title) {
110
- _title = '提醒';
111
- }
112
- Modal.warning({
113
- title: _title,
114
- content: '<div style="word-wrap:break-word">' + _strerr + '</div>'
115
- });
116
- }
117
- };
118
-
119
-
120
-
121
-
122
- function getCommonUrlParam (_self, _param, _type) {
123
- let token = caseMethod.getToken();
124
- let end_id = caseMethod.getEnt_id();
125
- let para = _param;
126
- if (!para) {
127
- para = {};
128
- }
129
- let portalkey = _self.OmdUrl.portalkey;
130
- if (!caseMethod.getUrlParam('portalkey')) {
131
- portalkey = caseMethod.getUrlParam('portalkey');
132
- }
133
- if (caseMethod.getUrlParam('srvkey') === 'cloud') {
134
- portalkey = 'cloud';
135
- }
136
- if (_type === '1') {
137
- let url = '';
138
- if (token && token.trim() !== '') {
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
- if (_self.OmdUrl.signMethod.trim().length !== 0 && _self.OmdUrl.secret.trim().length != 0) {
141
- url = url + '&sign_method=' + _self.OmdUrl.signMethod + '&sign=';
142
- let secret = _self.OmdUrl.appKey+'='+_self.OmdUrl.secret+'&body='+JSON.stringify(para).toString()+'&token='+token;
143
- if (_self.OmdUrl.getMd5 !== undefined) {
144
- secret = _self.OmdUrl.getMd5(para, token);
145
- }
146
- url = url+ md5(secret);
147
- }
148
- } else {
149
- let _session = { 'ent_id': end_id, 'user_id': _self.OmdUrl.uid, 'user_code': _self.OmdUrl.uid, 'user_name': _self.OmdUrl.uname };
150
- url = url + '&session=' + JSON.stringify(_session);
151
- }
152
- return url;
153
- } else {
154
- let temp = {};
155
- if (token && token.trim() !== '') {
156
- temp.ent_id = end_id;
157
- temp.token = token;
158
- temp.timestamp = new Date().getTime();
159
- temp.format = _self.OmdUrl.format;
160
- temp.app_key = _self.OmdUrl.appKey;
161
- temp.ver = _self.OmdUrl.ver;
162
- temp.portalkey = portalkey;
163
- temp.sign_method = _self.OmdUrl.signMethod;
164
- let secret = _self.OmdUrl.appKey+'='+_self.OmdUrl.secret+'&body='+JSON.stringify(para).toString()+'&token='+token;
165
- if (_self.OmdUrl.getMd5 !== undefined) {
166
- secret = _self.OmdUrl.getMd5(para, token);
167
- }
168
- temp.sign = md5(secret);
169
- } else {
170
- let _session = { 'ent_id': end_id, 'user_id': _self.OmdUrl.uid,'user_code': _self.OmdUrl.uid, 'user_name': _self.OmdUrl.uname };
171
- temp.session = JSON.stringify(_session);
172
- }
173
- return temp;
174
- }
175
- }
176
- function basePost (url, method, postdata, _self , _type) {
177
- let temp = {};
178
- if (method) {
179
- temp.method = method;
180
- }
181
- let comtemp = getCommonUrlParam(_self, postdata, '2');
182
- for (let v in comtemp) {
183
- temp[v]=comtemp[v];
184
- }
185
- if (!postdata) {
186
- postdata = {};
187
- }
188
-
189
- let menuCode = caseMethod.getUrlParam('menuCode');
190
- if (menuCode) {
191
- temp.menuCode = menuCode;
192
- }
193
- if (_type === 'get') {
194
- return new Promise((resolve, reject) => {
195
- axios.get(url, postdata, {
196
- params: temp
197
- })
198
- .then(response => {
199
- resolve(response.data);
200
- }, err => {
201
- reject(err);
202
- })
203
- .catch((error) => {
204
- reject(error);
205
- });
206
- });
207
- } else {
208
- return new Promise((resolve, reject) => {
209
- axios.post(url, postdata, {
210
- params: temp
211
- })
212
- .then(response => {
213
- resolve(response.data);
214
- }, err => {
215
- reject(err);
216
- })
217
- .catch((error) => {
218
- reject(error);
219
- });
220
- });
221
- }
222
-
223
- }
224
-
225
- function successRequest (data, _successFunc, _failFunc, _errorFunc, _self) {
226
- let obj = null;
227
- try {
228
- if (typeof data === 'string') {
229
- obj = JSON.parse(data);
230
- } else {
231
- obj = data;
232
- }
233
- if (parseInt(obj.returncode) === 0) { // 请求处理成功
234
- try {
235
- if (_successFunc) {
236
- _successFunc(obj.data);
237
- }
238
- } catch (e) {
239
- if (_self.$Spin) {
240
- _self.$Spin.hide();
241
- }
242
- _self.$nextTick(() => {
243
- setTimeout(() => {
244
- _self.alert(e, null, 2);
245
- }, 1000);
246
- });
247
- }
248
- return;
249
- } else if (parseInt(obj.returncode) > 0) {
250
- if (_failFunc) {
251
- try {
252
- _failFunc(obj.data);
253
- } catch (e) {
254
- if (_self.$Spin) {
255
- _self.$Spin.hide();
256
- }
257
- _self.$nextTick(() => {
258
- setTimeout(() => {
259
- _self.alert(e, null, 2);
260
- }, 1000);
261
- });
262
- }
263
- return;
264
- } else {
265
- throw obj.data; // 业务处理错误
266
- }
267
- } else {
268
- if (_errorFunc) {
269
- try {
270
- _errorFunc(obj.data);
271
- } catch (e) {
272
- if (_self.$Spin) {
273
- _self.$Spin.hide();
274
- }
275
- _self.$nextTick(() => {
276
- setTimeout(() => {
277
- _self.alert(e, null, 2);
278
- }, 1000);
279
- });
280
- }
281
- return;
282
- } else {
283
- throw obj.data; // 系统异常
284
- }
285
- }
286
- } catch (e) {
287
- if (_self.$Spin) {
288
- _self.$Spin.hide();
289
- }
290
- _self.$nextTick(() => {
291
- setTimeout(() => {
292
- if (typeof data === 'string') {
293
- _self.alert(e + '<br/>' + data, null, 2);
294
- } else {
295
- _self.alert(e, null, 2);
296
- }
297
- }, 1000);
298
- });
299
- }
300
- }
301
- caseMethod.asyncPost = function (url, method, postdata, _successFunc, _failFunc, _errorFunc, _type) {
302
- let _self = this;
303
- if (!url.startsWith('/')) {
304
- url = '/' + url;
305
- }
306
- basePost(url, method, postdata, _self, _type).then(function (data) {
307
- return successRequest(data, _successFunc, _failFunc, null, _self);
308
- }, function (err) {
309
- if (_failFunc) {
310
- _failFunc(err);
311
- } else {
312
- if (_self.$Spin) {
313
- _self.$Spin.hide();
314
- }
315
- _self.$nextTick(() => {
316
- setTimeout(() => {
317
- _self.alert(err.message + '<br/>' + err.response.data, null, '2');
318
- }, 1000);
319
- });
320
- }
321
- }).catch((err) => {
322
- if (_errorFunc) {
323
- _errorFunc(err);
324
- } else {
325
- if (_self.$Spin) {
326
- _self.$Spin.hide();
327
- }
328
- let error = JSON.stringify(err);
329
- _self.$nextTick(() => {
330
- setTimeout(() => {
331
- _self.alert(error, null, '2');
332
- }, 1000);
333
- });
334
- return false;
335
- }
336
- });
337
- };
338
- // 判断是否为IE浏览器
339
- // function isIE () { return !!(window.ActiveXObject || 'ActiveXObject' in window); }
340
-
341
- function getresturl (_baseUrl, _method, _param, _self) {
342
- let url = '';
343
- if (_method) {
344
- url = 'method=' + _method;
345
- } else {
346
- url = 'method=';
347
- }
348
- let tempUrl = getCommonUrlParam(_self, _param, '1');
349
- url = url + tempUrl;
350
- if (_baseUrl && _baseUrl.indexOf('?') != -1) {
351
- url = _baseUrl + '&' + url;
352
- } else {
353
- url = _baseUrl + '?' + url;
354
- }
355
-
356
- let menuCode = caseMethod.getUrlParam('menuCode');
357
- if (menuCode) {
358
- url = url + '&menuCode=' + menuCode;
359
- }
360
-
361
- return encodeURI(url);
362
- }
363
-
364
- caseMethod.getResturl = getresturl;
365
- caseMethod.synchroPost = function ( _baseUrl, _method, _param, _successFunc, _failFunc, _errorFunc, _type) {
366
- let _self = this;
367
- let tempType = 'POST';
368
- if (_type) {
369
- tempType = _type;
370
- }
371
- let url = getresturl(_baseUrl, _method, _param, _self);
372
- if (!url.startsWith('/')) {
373
- url = '/' + url;
374
- }
375
- $.ajaxSetup({cache: false});
376
- let post = {
377
- type: tempType,
378
- contentType: 'text/plain; charset=UTF-8',
379
- async: false,
380
- dataType: 'JSON',
381
- processData: false,
382
- success: function (data) {
383
- return successRequest(data, _successFunc, _failFunc, _errorFunc, _self);
384
- },
385
- error: function (XMLHttpRequest, textStatus, errorThrown) {
386
- if (_self.$Spin) {
387
- _self.$Spin.hide();
388
- }
389
- try {
390
- let error = JSON.stringify(errorThrown);
391
- _self.alert(error, null, '2');
392
- } catch (e) {
393
- setTimeout(() => {
394
- _self.alert(errorThrown, null, '2');
395
- }, 1000);
396
- }
397
-
398
- return false;// 系统异常
399
- }
400
- };
401
- if (!_param) {
402
- _param = {};
403
- }
404
- if (tempType === 'POST') {
405
- post.data = JSON.stringify(_param);
406
- } else {
407
- delete post.data;
408
- }
409
- $.ajax(url, post);
410
- };
411
- caseMethod.getOmdUrlConfig = function (_self) {
412
- $.ajax({
413
- url: '/amp-glod/config.json',
414
- type: 'GET',
415
- dataType: 'json',
416
- success: function(data) {
417
- let pageData=data;
418
- let obj = {};
419
- if (pageData) {
420
- for (let pro in pageData) {
421
- if (pageData[pro] instanceof Array) {
422
- pageData[pro].forEach(el => {
423
- obj[el.name] = el.value;
424
- });
425
- } else {
426
- obj[pro] = pageData[pro];
427
- }
428
- }
429
- }
430
- _self.config.globalProperties.OmdUrl = Object.assign({}, _self.config.globalProperties.OmdUrl, obj);
431
- }
432
- });
433
- };
434
- caseMethod.getPortalConfig = function (_self) {
435
- $.ajax({
436
- url: '/ampOpenapiService?method=usercenter.portal.getConfig',
437
- type: 'POST',
438
- data: {},
439
- dataType: 'json',
440
- success: function(res) {
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
- }
449
- }
450
- }
451
- });
452
- }
453
-
454
- function getCongouCookie(value) {
455
- if (!value)
456
- return '';
457
- try {
458
- let v = JSON.parse(value);
459
- v = v.state;
460
- if (v) {
461
- return v.split(':')[1];
462
- } else {
463
- return value;
464
- }
465
- } catch (e) {
466
- return value;
467
- }
468
- }
469
-
470
- caseMethod.getUserCode = function (v) {
471
- let that = null;
472
- if (!v) {
473
- that = this;
474
- } else {
475
- that = v;
476
- }
477
- let token = caseMethod.getToken(v);
478
- let portalkey = '';
479
- let usercode = '';
480
- portalkey = that.portalkey;
481
- usercode = that.OmdUrl.uid;
482
- if (token) {
483
- if(portalkey == 'congou'){
484
- usercode = getCongouCookie(Cookies.get('user_code'));
485
- }
486
- else
487
- {
488
- if (Cookies.get('user_code')) {
489
- usercode = Cookies.get('user_code');
490
- }
491
- }
492
- }
493
- return usercode;
494
- };
495
-
496
- caseMethod.getUserName = function (v) {
497
- let that = null;
498
- if (!v) {
499
- that = this;
500
- } else {
501
- that = v;
502
- }
503
- let token = caseMethod.getToken(v);
504
- let portalkey = '';
505
- let username = '';
506
- portalkey = that.portalkey;
507
- username = '[' + that.OmdUrl.uid + ']' + that.OmdUrl.uname;
508
- if (token) {
509
- if(portalkey == 'congou'){
510
- username = '[' + getCongouCookie(Cookies.get('user_code')) + ']' + getCongouCookie(Cookies.get('user_name'));
511
- }
512
- else
513
- {
514
- if (Cookies.get('user_code')) {
515
- username = '[' + Cookies.get('user_code') + ']' +Cookies.get('user_name');
516
- }
517
- }
518
- }
519
- return username;
520
- };
521
-
522
- caseMethod.getPortalMkt =function() {
523
- let obj = {};
524
- obj.shopId = Cookies.get('shopId');
525
- obj.shopCode = Cookies.get('shopCode');
526
- obj.shopName = Cookies.get('shopName');
527
- return obj;
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
- };
563
-
564
- caseMethod.getUrlParam = function (name) {
565
- let reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)'); // 构造一个含有目标参数的正则表达式对象
566
-
567
- let list = window.location.href.split('?');
568
- let r = '';
569
- if (list.length > 1) {
570
- r = list[1].match(reg); // 匹配目标参数
571
- }
572
- if (!r) {
573
- if (list.length > 2) {
574
- r = list[2].match(reg); // 匹配目标参数
575
- }
576
- }
577
- if (r) return decodeURI(r[2]); return ''; // 返回参数值
578
- };
579
-
580
- caseMethod.initGlobal = function (_self, _obj, isInitUser) {
581
- let OmdUrl = {};
582
- if (!_self.config.globalProperties.OmdUrl) {
583
- _self.config.globalProperties.OmdUrl = {};
584
- }
585
- if (_obj) {
586
- OmdUrl = Object.assign({},_self.config.globalProperties.OmdUrl, _obj);
587
- }
588
- let portalkey = caseMethod.getUrlParam('portalkey');
589
- if (portalkey) {
590
- OmdUrl.portalkey = portalkey;
591
- }
592
- OmdUrl.eid = caseMethod.getEnt_id(_self.config.globalProperties);
593
-
594
- OmdUrl.modulecode = caseMethod.getUrlParam('modulecode');
595
- if (! OmdUrl.modulecode) {
596
- OmdUrl.modulecode = caseMethod.getUrlParam('billmoduleid');
597
- }
598
- OmdUrl.helpindex = caseMethod.getUrlParam('helpindex');
599
- OmdUrl.billmoduleid =_self.config.globalProperties.modulecode;
600
- OmdUrl.openbillno = caseMethod.getUrlParam('billno');
601
- OmdUrl.opentaskid = caseMethod.getUrlParam('taskid');
602
- OmdUrl.nocheck = caseMethod.getUrlParam('nocheck')?caseMethod.getUrlParam('nocheck'):'N';
603
- _self.config.globalProperties.OmdUrl = Object.assign({}, _self.config.globalProperties.OmdUrl, OmdUrl);
604
- // caseMethod.getOmdUrlConfig(_self);
605
- caseMethod.getPortalConfig(_self);
606
-
607
- };
608
-
609
- caseMethod.getUserModuleMethod = function (curlmodulecode) {
610
- let reModuleMethod = null;
611
- let token = caseMethod.getToken();
612
- if (!token) {
613
- return reModuleMethod;
614
- }
615
-
616
- let modulecode = '';
617
- if (curlmodulecode) {
618
- modulecode = curlmodulecode;
619
- } else {
620
- modulecode = caseMethod.getUrlParam('modulecode');
621
- if (!modulecode) {
622
- return reModuleMethod;
623
- }
624
- }
625
- let portalUrl = '/mall-portal-rest/portalesb/ocmrest';
626
- if (this.OmdUrl && this.OmdUrl.portal) {
627
- portalUrl = this.OmdUrl.portal;
628
- }
629
- let srvkey = caseMethod.getUrlParam('srvkey');
630
- if (srvkey === 'cloud') {
631
- portalUrl = this.OmdUrl.mdm;
632
- }
633
-
634
- let param = {};
635
- param.token = token;
636
- param.modulecode = modulecode;
637
- this.synchroPost(portalUrl, 'runtime.modulesrivce.getUserModuleMethod',param, function(data) {
638
- reModuleMethod = data;
639
- }, null);
640
- return reModuleMethod;
641
-
642
- };
643
- caseMethod.checkModuleByToken = function () {
644
- let powerflag = false;
645
- let token = caseMethod.getToken();
646
- if (!token) {
647
- return powerflag;
648
- }
649
- let modulecode = caseMethod.getUrlParam('modulecode');
650
- if (!modulecode) {
651
- return powerflag;
652
- }
653
- if (!location.pathname) {
654
- return powerflag;
655
- }
656
- if(this.portalkey != 'congou') {
657
- return powerflag;
658
- }
659
-
660
- let portalUrl = '/mall-portal-rest/portalesb/ocmrest';
661
- if (this.OmdUrl.portal) {
662
- portalUrl = this.OmdUrl.portal;
663
- }
664
-
665
- let pathname = location.pathname;
666
-
667
- let searchParam = {
668
- 'token': token,
669
- 'modulecode': modulecode,
670
- 'execmodule': pathname
671
- };
672
- let srvkey = caseMethod.getUrlParam('srvkey');
673
- if (srvkey === 'cloud') {
674
- portalUrl = this.OmdUrl.mdm;
675
- }
676
- let method = 'runtime.modulesrivce.checkmodulebytoken';
677
- this.synchroPost(portalUrl, method, searchParam, function(data) {
678
- if (data.flag === '-1') {
679
- powerflag = true;
680
- }
681
- }, null);
682
- return powerflag;
683
- };
684
-
685
- /*
686
- caseMethod.getDict = function(str, _fields) {
687
- let fields = 'code,name';
688
- if (_fields) {
689
- fields = _fields;
690
- }
691
- let dictkey = str.split(',');
692
- let _dicData = {};
693
- let str2 = [];
694
- for (let pro of dictkey) {
695
- let data = this.$Method.getLocalStorage('dictkey_' + pro);
696
- if (data) {
697
- _dicData[pro] = data;
698
- } else {
699
- str2.push(pro);
700
- }
701
- }
702
- if (str2.length > 0) {
703
- let searchParam = {
704
- fields: fields,
705
- dict_group_code: str2.join(',')
706
- };
707
- let self = this;
708
- this.synchroPost(this.OmdUrl.omp, 'omp.work.dict.getbydictgroupcode', searchParam,function(data) {
709
- for (let pro of str2) {
710
- self.$Method.setLocalStorage('dictkey_' + pro , data[pro], self.OmdUrl.dictExpire);
711
- _dicData[pro] = data[pro];
712
- }
713
- }, null);
714
- }
715
- return _dicData;
716
- };
717
- */
718
-
719
- caseMethod.getDict = function(str, _fields) {
720
- let fields = 'code,name';
721
- if (_fields) {
722
- fields = _fields;
723
- }
724
- let _dicData = {};
725
- let searchParam = {
726
- fields: fields,
727
- dict_group_code:str
728
- };
729
- this.synchroPost(this.OmdUrl.omp, 'omp.work.dict.getbydictgroupcode', searchParam,function(data) {
730
- _dicData = data;
731
- }, null);
732
- return _dicData;
733
- };
734
-
735
- caseMethod.setQueryConfig = function(obj) {
736
- Object.assign(this.query.Config, obj);
737
- };
738
- caseMethod.getQueryConfig = function (selectkey) {
739
- let config = null;
740
- if (this.query.Config[selectkey]) {
741
- config = JSON.parse(JSON.stringify(this.query.Config[selectkey]));
742
- } else {
743
- config = {};
744
- }
745
- if (config.width === undefined) {
746
- if (config.isTree) {
747
- config.width = 0.3;
748
- } else {
749
- config.width = 0.4;
750
- }
751
- }
752
- if (config.height === undefined) {
753
- config.height = 0.6;
754
- }
755
- if (config.responseId === undefined) {
756
- config.responseId = config.responseCode;
757
- }
758
- if (config.manualLoad === undefined) {
759
- config.manualLoad = true;
760
- }
761
- if (config.multiSelect === undefined) {
762
- config.multiSelect = false;
763
- }
764
-
765
- if (config.showCondition === undefined) {
766
- config.showCondition = true;
767
- }
768
- /*if (config.isTree) {
769
- config.popControl = 'SimpleTree';
770
- } else {
771
- config.popControl = 'SimpleViewGrid';
772
- }*/
773
- if (config.isConfig) {
774
- return config;
775
- } else {
776
- if (this.query.customQueryConfig) {
777
- return this.query.customQueryConfig(config);
778
- } else {
779
- return config;
780
- }
781
- }
782
-
783
- };
784
- caseMethod.getBillmoduleid = function(billtype) {
785
- let billmoduleid = '';
786
- let searchParam = {'billtype':billtype,'order_field' : 'modeid'};
787
- let method = 'mss.base.billmain.search';
788
- this.synchroPost(this.OmdUrl.mall, method,searchParam, function(data) {
789
- if(data && data.billmain && data.billmain.length >0){
790
- billmoduleid =data.billmain[0].modeid;
791
- }
792
- },null);
793
- return billmoduleid;
794
- };
795
- caseMethod.getBilltype = function(billmoduleid) {
796
- let billtype = '';
797
- let searchParam = {'modeid':billmoduleid};
798
- let method = 'mss.base.billmain.search';
799
- this.synchroPost(this.OmdUrl.mall, method,searchParam, function(data) {
800
- if(data && data.billmain && data.billmain.length >0){
801
- billtype =data.billmain[0].billtype;
802
- }
803
- },null);
804
- return billtype;
805
- };
806
- caseMethod.getHelpdocumenturl = function() {
807
- let url = '';
808
- let searchParam = {'queryid':'select_fgetmanapara','mpmkt':'00','mpcode':'HELPDOCUMENTURL'};
809
- let method = 'mss.work.report.query';
810
- this.synchroPost(this.OmdUrl.mall, method,searchParam, function(data) {
811
- if(data && data.report && data.report.length >0){
812
- url =data.report[0].mpvalue;
813
- }
814
- },null);
815
- return url;
816
- };
817
- caseMethod.getHelpId = function(helpType,helpIndex) {
818
- let helpId = '';
819
- let para = {};
820
- para.helpType = helpType;
821
- para.helpIndex = helpIndex;
822
- this.synchroPost(this.OmdUrl.amp, 'usercenter.helpconfig.getHelpId', para, function(data) {
823
- if(data && data.helpId){
824
- helpId = data.helpId
825
- }
826
- },function(data) {
827
- helpId= '';
828
- },function(data) {
829
- helpId= '';
830
- });
831
- return helpId;
832
- };
833
-
834
-
835
- caseMethod.getConditionValue = function (name, value, calculator, config) {
836
- let condition = {};
837
- if (calculator === '==') {
838
- if (config.type === 'DateBox') {
839
- condition[name] = {};
840
- let temp = {};
841
- temp['>='] = value;
842
- if (config.vtype === 'month') {
843
- temp['<'] = this.$Method.getNextMonthFirstDay(value);
844
- } else {
845
- temp['<'] = this.$Method.getTomorrow(value);
846
- }
847
- condition[name] = temp;
848
- } else {
849
- if (name === 'inputer' || name === 'auditor' || name === 'canceler') {
850
- let temp1 = {};
851
- temp1[name] = {'==':value};
852
- let temp2 = {};
853
- temp2[name+'_name'] = {'LIKE': '[%]' + value};
854
- condition['$or'] = [];
855
- condition['$or'].push(temp1);
856
- condition['$or'].push(temp2);
857
- } else {
858
- condition[name] = {};
859
- if (value.value !== undefined) {
860
- condition[name][calculator] = value.value;
861
- } else {
862
- condition[name][calculator] = value;
863
- }
864
- }
865
- }
866
- }
867
-
868
- if (calculator === 'LIKE') {
869
- condition[name] = {};
870
- condition[name][calculator] = '%' + value + '%';
871
- }
872
-
873
- if (calculator !== 'LIKE' && calculator !== '==') {
874
- condition[name] = {};
875
- condition[name][calculator] = value;
876
- }
877
- return condition;
878
- };
879
- caseMethod.getHelpUrl = function() {
880
- let url = '';
881
- if (this.helpindex) {
882
- let helpUrl = '';
883
- if (this.OmdUrl.helpUrl) {
884
- helpUrl = this.OmdUrl.helpUrl;
885
- } else {
886
- helpUrl = this.getHelpdocumenturl();
887
- }
888
- if (helpUrl) {
889
- url = 'http://'+helpUrl+'/web/#/'+this.OmdUrl.helpType+'?page_id='+ this.helpindex;
890
- }
891
- }
892
- return url;
893
-
894
- };
895
- caseMethod.getEnt_id = function(_self) {
896
- let ent_id = '';
897
- let portalkey = '';
898
- if (_self) {
899
- ent_id = _self.OmdUrl.eid;
900
- portalkey = _self.OmdUrl.portalkey;
901
- } else {
902
- ent_id = this.OmdUrl.eid;
903
- portalkey = this.OmdUrl.portalkey;
904
- }
905
- if (Cookies.get('ent_id') !== undefined && Cookies.get('ent_id') !== '') {
906
- ent_id = Cookies.get('ent_id');
907
- } else {
908
- let temp = caseMethod.getUrlParam('ent_id');
909
- if (temp !== undefined && temp !== '') {
910
- ent_id = temp;
911
- }
912
- }
913
- if (portalkey === 'cloud') {
914
- let lock_entid = caseMethod.getUrlParam('lock_entid');
915
- if (lock_entid !== undefined && lock_entid !== '') {
916
- ent_id = lock_entid;
917
- }
918
- }
919
-
920
- return ent_id;
921
- };
922
- caseMethod.getToken = function(_self) {
923
- let token = '';
924
- if (!_self) {
925
- if (this.token) {
926
- token = this.token;
927
- }
928
- } else {
929
- if (_self.token) {
930
- token = _self.token;
931
- }
932
- }
933
- if (Cookies.get('token')) {
934
- token = Cookies.get('token');
935
- } else {
936
- let temp = caseMethod.getUrlParam('token');
937
- if (temp) {
938
- token = temp;
939
- }
940
- }
941
- return token;
942
- };
943
-
944
-
945
-
946
- caseMethod.getModulecode= function () {
947
- let modulecode = '';
948
- modulecode = caseMethod.getUrlParam('modulecode');
949
- if (!modulecode) {
950
- modulecode = caseMethod.getUrlParam('billmoduleid');
951
- }
952
- return modulecode;
953
- };
954
- caseMethod.downloadFile = function(url, that) {
955
-
956
- if (!url) {
957
- return;
958
- }
959
-
960
- let xhr = new XMLHttpRequest();
961
-
962
- xhr.open('GET', url, true); // 也可以使用POST方式,根据接口
963
-
964
- xhr.responseType = 'blob'; // 返回类型blob
965
-
966
- // 定义请求完成的处理函数,请求前也可以增加加载框/禁用下载按钮逻辑
967
-
968
- xhr.onload = function () {
969
- // 请求完成
970
- if (this.status === 200) {
971
- // 返回200
972
- let blob = this.response;
973
- let reader = new FileReader();
974
- let headerStr = decodeURI(this.getResponseHeader('content-disposition'));
975
- let filename = headerStr.replace('attachment;filename*=UTF-8\'\'','');
976
- filename = filename.replace('attachment;filename=','');
977
- // let filename = this.getAllResponseHeaders().split(';')[2].split('\n')[0].split('filename=')[1];
978
- reader.readAsDataURL(blob); // 转换为base64,可以直接放入a表情href
979
- filename = decodeURIComponent(filename);
980
- //去除空格
981
- filename = filename.replace(/\ +/g,'');
982
- //去除换行回车
983
- filename = filename.replace(/[\r\n]/g,'');
984
- reader.onload = function () {
985
-
986
- // 转换完成,创建一个a标签用于下载
987
-
988
- let a = document.createElement('a');
989
-
990
- a.download = filename;
991
-
992
-
993
- //a.href = e.target.result;
994
- a.href = URL.createObjectURL(blob);
995
-
996
- $('body').append(a); // 修复firefox中无法触发click
997
- that.$Spin.hide();
998
- a.click();
999
-
1000
- $(a).remove();
1001
-
1002
- };
1003
-
1004
- } else {
1005
- that.$Spin.hide();
1006
- that.alert('导出失败');
1007
- }
1008
-
1009
- };
1010
-
1011
- // 发送ajax请求
1012
-
1013
- xhr.send(new Blob());
1014
-
1015
- };
1016
-
1017
- caseMethod.exportExcelback = function (that) {
1018
- if (that.child) {
1019
- setTimeout(that.exportExcelback(that),100);
1020
- } else {
1021
- that.$Spin.hide();
1022
- }
1023
- };
1024
-
1025
- caseMethod.doExportExcel = function(_baseUrl,_method,_param,exportType,that){
1026
- let url = _baseUrl;
1027
- //filetyep:1 导出文件XlS filetype:2 导出文件XLSX 默认为2
1028
- //_param.filetype = "1";
1029
- if (!_param) {
1030
- _param = {};
1031
- }
1032
- url = getresturl(url, _method, _param, that);
1033
- let _paramStr = JSON.stringify(_param);
1034
- _paramStr = _paramStr.replaceAll('#','%23');
1035
- _paramStr = _paramStr.replaceAll('&','%26');
1036
- _paramStr = _paramStr.replaceAll('+','%2B');
1037
- //_paramStr = _paramStr.replaceAll(':','%3A');
1038
- url = encodeURI(url + '&param=' + _paramStr);
1039
- let userid = Cookies.get('user_id');
1040
- let user_code = Cookies.get('user_code');
1041
- if (userid) {
1042
- url=url+encodeURI('&user_id='+userid);
1043
- }
1044
- if (user_code) {
1045
- url=url+encodeURI('&user_code='+user_code);
1046
- }
1047
- that.$Spin.show({
1048
- render: (h) => {
1049
- return h('div', '导出中...,请勿关闭!');
1050
- }
1051
- });
1052
- if (!exportType) {
1053
- exportType = '2';
1054
- }
1055
- if(exportType === '2'){
1056
- caseMethod.downloadFile(url, that);
1057
- } else {
1058
- const child = window.open(url,'_blank');
1059
- var loop = setInterval(function () {
1060
- if (child.closed) {
1061
- that.$Spin.hide();
1062
- clearInterval(loop);
1063
- }
1064
- }, 100);
1065
- // setTimeout(caseMethod.exportExcelback(that),100);
1066
- }
1067
- };
1068
-
1069
- caseMethod.doExportReport= function(_baseUrl,_method,_param,that){
1070
- let url = _baseUrl;
1071
- if (!_param) {
1072
- _param = {};
1073
- }
1074
- url = getresturl(url, _method, _param, that);
1075
- let _paramStr = JSON.stringify(_param);
1076
- _paramStr = _paramStr.replaceAll('#','%23');
1077
- _paramStr = _paramStr.replaceAll('&','%26');
1078
- _paramStr = _paramStr.replaceAll('+','%2B');
1079
- url = encodeURI(url + '&param=' + _paramStr);
1080
- that.$Spin.show({
1081
- render: (h) => {
1082
- return h('div', '导出中...,请勿关闭!');
1083
- }
1084
- });
1085
- caseMethod.downloadFile(url, that);
1086
- };
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
-
1179
- caseMethod.getFilesInfo = function(billno, billmoduleid,notdelfile,scenetype, callBackMethod) {
1180
- let usercode = caseMethod.getUserCode();
1181
- let username = caseMethod.getUserName();
1182
- let token = caseMethod.getToken();
1183
- let url = OmdUrl.getfile + 'billno=' + billno + '&billmoduleid=' + billmoduleid+'&scenetype=' + scenetype;
1184
- let userInfo = '&usercode=' + usercode + '&username=' + username+'&token=' + token;
1185
- if (notdelfile !== 'Y') {
1186
- userInfo = userInfo + '&notdelfile=N';
1187
- } else {
1188
- userInfo = userInfo + '&notdelfile=Y';
1189
- }
1190
- userInfo = encodeURI(userInfo);
1191
- caseMethod.synchroPost(url, '', {}, (result) => {
1192
- let data = [];
1193
- if (result && result.length > 0) {
1194
- result.forEach(el => {
1195
- let obj = Object.assign({},{},el);
1196
- obj.filename = el.filename;
1197
- obj.filekey = el.filekey;
1198
- obj.downUrl = OmdUrl.downfile + obj.filekey + userInfo;
1199
- obj.delUrl = OmdUrl.delfile + obj.filekey + userInfo;
1200
- obj.title = obj.filename;
1201
- obj.url = obj.downUrl;
1202
- obj.modflag = el.modflag;
1203
- data.push(obj);
1204
- });
1205
- }
1206
- callBackMethod(data);
1207
- }, null, null, 'get');
1208
- };
1209
-
1210
- caseMethod.getFilesInfoByIdkey = function(idkey, callBackMethod) {
1211
- let usercode = caseMethod.getUserCode();
1212
- let username = caseMethod.getUserName();
1213
- let token = caseMethod.getToken();
1214
- let url = OmdUrl.getfile + 'idkey=' + idkey;
1215
- let userInfo = '&usercode=' + usercode + '&username=' + username +'&token=' + token;
1216
- userInfo = encodeURI(userInfo);
1217
- caseMethod.synchroPost(url, '', {}, (result) => {
1218
- let data = [];
1219
- if (result && result.length > 0) {
1220
- result.forEach(el => {
1221
- let obj = Object.assign({},{},el);
1222
- obj.filename = el.filename;
1223
- obj.filekey = el.filekey;
1224
- obj.downUrl = OmdUrl.downfile + obj.filekey + userInfo;
1225
- obj.delUrl = OmdUrl.delfile + obj.filekey + userInfo;
1226
- obj.title = obj.filename;
1227
- obj.url = obj.downUrl;
1228
- obj.modflag = el.modflag;
1229
- data.push(obj);
1230
- });
1231
- }
1232
- callBackMethod(data);
1233
- }, null, null, 'get');
1234
- };
1235
- caseMethod.getFileInfo = function(filekey,callBackMethod) {
1236
- let usercode = caseMethod.getUserCode();
1237
- let username = caseMethod.getUserName();
1238
- let token = caseMethod.getToken();
1239
- let url = OmdUrl.getfile + 'filekey=' + filekey;
1240
- let userInfo = '&usercode=' + usercode + '&username=' + username +'&token=' + token;
1241
- userInfo = encodeURI(userInfo);
1242
- caseMethod.synchroPost(url, '', {}, (result) => {
1243
- let data = [];
1244
- if (result && result.length > 0) {
1245
- result.forEach(el => {
1246
- let obj = Object.assign({},{},el);
1247
- obj.filename = el.filename;
1248
- obj.filekey = el.filekey;
1249
- obj.downUrl = OmdUrl.downfile + obj.filekey + userInfo;
1250
- obj.delUrl = OmdUrl.delfile + obj.filekey + userInfo;
1251
- obj.title = obj.filename;
1252
- obj.url = obj.downUrl;
1253
- obj.modflag = el.modflag;
1254
- data.push(obj);
1255
- });
1256
- }
1257
- callBackMethod(data);
1258
- }, null, null, 'get');
1259
- };
1260
- caseMethod.setUrlSuffix = function(url,self) {
1261
- let srvkey = caseMethod.getUrlParam('srvkey');
1262
- let token = caseMethod.getUrlParam('token');
1263
- let user_code = caseMethod.getUrlParam('usercode');
1264
- let portalkey = caseMethod.getUrlParam('portalkey')
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;
1273
- }
1274
- export default caseMethod;
1
+ import axios from 'axios';
2
+ import $ from 'jquery';
3
+ import Cookies from 'js-cookie';
4
+ import md5 from 'js-md5';
5
+ import { Modal } from 'view-ui-plus'
6
+
7
+ // async synchro
8
+
9
+ let caseMethod = {};
10
+
11
+ let OmdUrl = {};
12
+ OmdUrl.eid = '0';
13
+ OmdUrl.uid = '0';
14
+ OmdUrl.uname = 'future';
15
+ OmdUrl.format = 'json';
16
+ OmdUrl.appKey = 'mall';
17
+ OmdUrl.portalkey = 'congou';
18
+ OmdUrl.checktoken = 'Y';
19
+ OmdUrl.ver = '1.0';
20
+ OmdUrl.signMethod = 'MD5';
21
+ OmdUrl.secret = '';
22
+ OmdUrl.omp = '/mall-work-webin/rest';
23
+ OmdUrl.mall = '/mall-work-webin/rest';
24
+ OmdUrl.mss = '/mall-work-webin/rest';
25
+ OmdUrl.portal = '/mall-portal-rest/portalesb/ocmrest';
26
+ OmdUrl.mdm = '/ocm-mdm-webin/rest';
27
+ OmdUrl.omc = '/omc-tags-webin/rest';
28
+ OmdUrl.member = '/omc-membership-webin/rest';
29
+ OmdUrl.accnt = '/omc-accnt-webin/rest';
30
+ OmdUrl.work = '/omc-work-webin/rest';
31
+ OmdUrl.investment = '/mall-investment-webin/rest';
32
+ OmdUrl.uploadfile ='/mss-sysconf-boot/upload';
33
+ OmdUrl.delfile ='/mss-sysconf-boot/delete?filekey=';
34
+ OmdUrl.downfile = '/mss-sysconf-boot/download?filekey=';
35
+ OmdUrl.getfile = '/mss-sysconf-boot/filedata?';
36
+ OmdUrl.amp = '/ampOpenapiService/';
37
+ OmdUrl.uidespath = OmdUrl.amp;
38
+ OmdUrl.helpUrl = 'docs.sjhgo.com';
39
+ OmdUrl.mallmdm = '/mall-mdm-webin/rest';
40
+ OmdUrl.mallmaster = '/mall-master-webin/rest';
41
+ OmdUrl.portal = OmdUrl.mallmdm;
42
+ OmdUrl.uiConfigExpire = 24;
43
+ OmdUrl.fairyConfigExpire = 24;
44
+ OmdUrl.dictExpire = 24;
45
+ OmdUrl.operbilllog = '/mss-sysconf-query/rest';
46
+ //测试
47
+ //OmdUrl.startHelp = 'Y';
48
+ //OmdUrl.helpType = '13';
49
+ //OmdUrl.portal = '/mall-master-webin/rest';
50
+ //OmdUrl.mdm = '/mall-master-webin/rest';
51
+
52
+ OmdUrl.getCurHelpUrl = function (that) {
53
+ var curHelpUrl = '';
54
+ if (that.OmdUrl.startHelp === 'Y') {
55
+ if (that.OmdUrl.helpType) {
56
+ var modulecodeHelp = that.$Method.getUrlParam('helpindex');
57
+ var modulecodeHelpUrl = that.$Method.getLocalStorage('modulecodeHelp_' + that.OmdUrl.helpType + '_' + modulecodeHelp);
58
+ if (modulecodeHelpUrl) {
59
+ return modulecodeHelpUrl;
60
+ }
61
+ if (modulecodeHelp) {
62
+ var helpUrl = that.OmdUrl.helpUrl;
63
+ if (!helpUrl) {
64
+ if (that.getHelpdocumenturl) {
65
+ helpUrl = that.getHelpdocumenturl();
66
+ }
67
+ }
68
+ if (helpUrl) {
69
+ let helpId = that.getHelpId(that.OmdUrl.helpType, modulecodeHelp);
70
+ if (helpId) {
71
+ curHelpUrl ='http://' + helpUrl + '/web/#/p/' + helpId;
72
+ } else {
73
+ curHelpUrl = 'http://' + helpUrl + '/web/#/' + that.OmdUrl.helpType + '?page_id=' + modulecodeHelp;
74
+ }
75
+ }
76
+ that.$Method.setLocalStorage('modulecodeHelp_' +that.OmdUrl.helpType + '_' + modulecodeHelp,curHelpUrl,that.OmdUrl.uiConfigExpire)
77
+ }
78
+ }
79
+ }
80
+ return curHelpUrl;
81
+ };
82
+
83
+ caseMethod.OmdUrl = OmdUrl;
84
+
85
+ caseMethod.alert = function (_strerr, _title, _flag) {
86
+ if (!_flag) {
87
+ _flag = '1';
88
+ }
89
+ if (_strerr && typeof _strerr === 'string') {
90
+ _strerr = _strerr.replace(new RegExp('</xmp>', 'gi'), '</txmp>');
91
+ _strerr = _strerr.replace(new RegExp('<xmp', 'gi'), '<txmp');
92
+ _strerr = '<xmp style="margin: 0;white-space:break-spaces;">' +_strerr + '</xmp>';
93
+ }
94
+ _flag = _flag + '';
95
+ if (_flag === '2') {
96
+ Modal.error({
97
+ title: '系统警告',
98
+ content: '<div style="word-wrap:break-word">' + _strerr + '</div>'
99
+ });
100
+ } else if (_flag === '3') {
101
+ if (!_title) {
102
+ _title = '成功';
103
+ }
104
+ Modal.success({
105
+ title:_title,
106
+ content: '<div style="word-wrap:break-word">' + _strerr + '</div>'
107
+ });
108
+ } else {
109
+ if (!_title) {
110
+ _title = '提醒';
111
+ }
112
+ Modal.warning({
113
+ title: _title,
114
+ content: '<div style="word-wrap:break-word">' + _strerr + '</div>'
115
+ });
116
+ }
117
+ };
118
+
119
+
120
+
121
+
122
+ function getCommonUrlParam (_self, _param, _type) {
123
+ let token = caseMethod.getToken();
124
+ let end_id = caseMethod.getEnt_id();
125
+ let para = _param;
126
+ if (!para) {
127
+ para = {};
128
+ }
129
+ let portalkey = _self.OmdUrl.portalkey;
130
+ if (!caseMethod.getUrlParam('portalkey')) {
131
+ portalkey = caseMethod.getUrlParam('portalkey');
132
+ }
133
+ if (caseMethod.getUrlParam('srvkey') === 'cloud') {
134
+ portalkey = 'cloud';
135
+ }
136
+ if (_type === '1') {
137
+ let url = '';
138
+ if (token && token.trim() !== '') {
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
+ if (_self.OmdUrl.signMethod.trim().length !== 0 && _self.OmdUrl.secret.trim().length != 0) {
141
+ url = url + '&sign_method=' + _self.OmdUrl.signMethod + '&sign=';
142
+ let secret = _self.OmdUrl.appKey+'='+_self.OmdUrl.secret+'&body='+JSON.stringify(para).toString()+'&token='+token;
143
+ if (_self.OmdUrl.getMd5 !== undefined) {
144
+ secret = _self.OmdUrl.getMd5(para, token);
145
+ }
146
+ url = url+ md5(secret);
147
+ }
148
+ } else {
149
+ let _session = { 'ent_id': end_id, 'user_id': _self.OmdUrl.uid, 'user_code': _self.OmdUrl.uid, 'user_name': _self.OmdUrl.uname };
150
+ url = url + '&session=' + JSON.stringify(_session);
151
+ }
152
+ return url;
153
+ } else {
154
+ let temp = {};
155
+ if (token && token.trim() !== '') {
156
+ temp.ent_id = end_id;
157
+ temp.token = token;
158
+ temp.timestamp = new Date().getTime();
159
+ temp.format = _self.OmdUrl.format;
160
+ temp.app_key = _self.OmdUrl.appKey;
161
+ temp.ver = _self.OmdUrl.ver;
162
+ temp.portalkey = portalkey;
163
+ temp.sign_method = _self.OmdUrl.signMethod;
164
+ let secret = _self.OmdUrl.appKey+'='+_self.OmdUrl.secret+'&body='+JSON.stringify(para).toString()+'&token='+token;
165
+ if (_self.OmdUrl.getMd5 !== undefined) {
166
+ secret = _self.OmdUrl.getMd5(para, token);
167
+ }
168
+ temp.sign = md5(secret);
169
+ } else {
170
+ let _session = { 'ent_id': end_id, 'user_id': _self.OmdUrl.uid,'user_code': _self.OmdUrl.uid, 'user_name': _self.OmdUrl.uname };
171
+ temp.session = JSON.stringify(_session);
172
+ }
173
+ return temp;
174
+ }
175
+ }
176
+ function basePost (url, method, postdata, _self , _type) {
177
+ let temp = {};
178
+ if (method) {
179
+ temp.method = method;
180
+ }
181
+ let comtemp = getCommonUrlParam(_self, postdata, '2');
182
+ for (let v in comtemp) {
183
+ temp[v]=comtemp[v];
184
+ }
185
+ if (!postdata) {
186
+ postdata = {};
187
+ }
188
+
189
+ let menuCode = caseMethod.getUrlParam('menuCode');
190
+ if (menuCode) {
191
+ temp.menuCode = menuCode;
192
+ }
193
+ if (_type === 'get') {
194
+ return new Promise((resolve, reject) => {
195
+ axios.get(url, postdata, {
196
+ params: temp
197
+ })
198
+ .then(response => {
199
+ resolve(response.data);
200
+ }, err => {
201
+ reject(err);
202
+ })
203
+ .catch((error) => {
204
+ reject(error);
205
+ });
206
+ });
207
+ } else {
208
+ return new Promise((resolve, reject) => {
209
+ axios.post(url, postdata, {
210
+ params: temp
211
+ })
212
+ .then(response => {
213
+ resolve(response.data);
214
+ }, err => {
215
+ reject(err);
216
+ })
217
+ .catch((error) => {
218
+ reject(error);
219
+ });
220
+ });
221
+ }
222
+
223
+ }
224
+
225
+ function successRequest (data, _successFunc, _failFunc, _errorFunc, _self) {
226
+ let obj = null;
227
+ try {
228
+ if (typeof data === 'string') {
229
+ obj = JSON.parse(data);
230
+ } else {
231
+ obj = data;
232
+ }
233
+ if (parseInt(obj.returncode) === 0) { // 请求处理成功
234
+ try {
235
+ if (_successFunc) {
236
+ _successFunc(obj.data);
237
+ }
238
+ } catch (e) {
239
+ if (_self.$Spin) {
240
+ _self.$Spin.hide();
241
+ }
242
+ _self.$nextTick(() => {
243
+ setTimeout(() => {
244
+ _self.alert(e, null, 2);
245
+ }, 1000);
246
+ });
247
+ }
248
+ return;
249
+ } else if (parseInt(obj.returncode) > 0) {
250
+ if (_failFunc) {
251
+ try {
252
+ _failFunc(obj.data);
253
+ } catch (e) {
254
+ if (_self.$Spin) {
255
+ _self.$Spin.hide();
256
+ }
257
+ _self.$nextTick(() => {
258
+ setTimeout(() => {
259
+ _self.alert(e, null, 2);
260
+ }, 1000);
261
+ });
262
+ }
263
+ return;
264
+ } else {
265
+ throw obj.data; // 业务处理错误
266
+ }
267
+ } else {
268
+ if (_errorFunc) {
269
+ try {
270
+ _errorFunc(obj.data);
271
+ } catch (e) {
272
+ if (_self.$Spin) {
273
+ _self.$Spin.hide();
274
+ }
275
+ _self.$nextTick(() => {
276
+ setTimeout(() => {
277
+ _self.alert(e, null, 2);
278
+ }, 1000);
279
+ });
280
+ }
281
+ return;
282
+ } else {
283
+ throw obj.data; // 系统异常
284
+ }
285
+ }
286
+ } catch (e) {
287
+ if (_self.$Spin) {
288
+ _self.$Spin.hide();
289
+ }
290
+ _self.$nextTick(() => {
291
+ setTimeout(() => {
292
+ if (typeof data === 'string') {
293
+ _self.alert(e + '<br/>' + data, null, 2);
294
+ } else {
295
+ _self.alert(e, null, 2);
296
+ }
297
+ }, 1000);
298
+ });
299
+ }
300
+ }
301
+ caseMethod.asyncPost = function (url, method, postdata, _successFunc, _failFunc, _errorFunc, _type) {
302
+ let _self = this;
303
+ if (!url.startsWith('/')) {
304
+ url = '/' + url;
305
+ }
306
+ basePost(url, method, postdata, _self, _type).then(function (data) {
307
+ return successRequest(data, _successFunc, _failFunc, null, _self);
308
+ }, function (err) {
309
+ if (_failFunc) {
310
+ _failFunc(err);
311
+ } else {
312
+ if (_self.$Spin) {
313
+ _self.$Spin.hide();
314
+ }
315
+ _self.$nextTick(() => {
316
+ setTimeout(() => {
317
+ _self.alert(err.message + '<br/>' + err.response.data, null, '2');
318
+ }, 1000);
319
+ });
320
+ }
321
+ }).catch((err) => {
322
+ if (_errorFunc) {
323
+ _errorFunc(err);
324
+ } else {
325
+ if (_self.$Spin) {
326
+ _self.$Spin.hide();
327
+ }
328
+ let error = JSON.stringify(err);
329
+ _self.$nextTick(() => {
330
+ setTimeout(() => {
331
+ _self.alert(error, null, '2');
332
+ }, 1000);
333
+ });
334
+ return false;
335
+ }
336
+ });
337
+ };
338
+ // 判断是否为IE浏览器
339
+ // function isIE () { return !!(window.ActiveXObject || 'ActiveXObject' in window); }
340
+
341
+ function getresturl (_baseUrl, _method, _param, _self) {
342
+ let url = '';
343
+ if (_method) {
344
+ url = 'method=' + _method;
345
+ } else {
346
+ url = 'method=';
347
+ }
348
+ let tempUrl = getCommonUrlParam(_self, _param, '1');
349
+ url = url + tempUrl;
350
+ if (_baseUrl && _baseUrl.indexOf('?') != -1) {
351
+ url = _baseUrl + '&' + url;
352
+ } else {
353
+ url = _baseUrl + '?' + url;
354
+ }
355
+
356
+ let menuCode = caseMethod.getUrlParam('menuCode');
357
+ if (menuCode) {
358
+ url = url + '&menuCode=' + menuCode;
359
+ }
360
+
361
+ return encodeURI(url);
362
+ }
363
+
364
+ caseMethod.getResturl = getresturl;
365
+ caseMethod.synchroPost = function ( _baseUrl, _method, _param, _successFunc, _failFunc, _errorFunc, _type) {
366
+ let _self = this;
367
+ let tempType = 'POST';
368
+ if (_type) {
369
+ tempType = _type;
370
+ }
371
+ let url = getresturl(_baseUrl, _method, _param, _self);
372
+ if (!url.startsWith('/')) {
373
+ url = '/' + url;
374
+ }
375
+ $.ajaxSetup({cache: false});
376
+ let post = {
377
+ type: tempType,
378
+ contentType: 'text/plain; charset=UTF-8',
379
+ async: false,
380
+ dataType: 'JSON',
381
+ processData: false,
382
+ success: function (data) {
383
+ return successRequest(data, _successFunc, _failFunc, _errorFunc, _self);
384
+ },
385
+ error: function (XMLHttpRequest, textStatus, errorThrown) {
386
+ if (_self.$Spin) {
387
+ _self.$Spin.hide();
388
+ }
389
+ try {
390
+ let error = JSON.stringify(errorThrown);
391
+ _self.alert(error, null, '2');
392
+ } catch (e) {
393
+ setTimeout(() => {
394
+ _self.alert(errorThrown, null, '2');
395
+ }, 1000);
396
+ }
397
+
398
+ return false;// 系统异常
399
+ }
400
+ };
401
+ if (!_param) {
402
+ _param = {};
403
+ }
404
+ if (tempType === 'POST') {
405
+ post.data = JSON.stringify(_param);
406
+ } else {
407
+ delete post.data;
408
+ }
409
+ $.ajax(url, post);
410
+ };
411
+ caseMethod.getOmdUrlConfig = function (_self) {
412
+ $.ajax({
413
+ url: '/amp-glod/config.json',
414
+ type: 'GET',
415
+ dataType: 'json',
416
+ success: function(data) {
417
+ let pageData=data;
418
+ let obj = {};
419
+ if (pageData) {
420
+ for (let pro in pageData) {
421
+ if (pageData[pro] instanceof Array) {
422
+ pageData[pro].forEach(el => {
423
+ obj[el.name] = el.value;
424
+ });
425
+ } else {
426
+ obj[pro] = pageData[pro];
427
+ }
428
+ }
429
+ }
430
+ _self.config.globalProperties.OmdUrl = Object.assign({}, _self.config.globalProperties.OmdUrl, obj);
431
+ }
432
+ });
433
+ };
434
+ caseMethod.getPortalConfig = function (_self) {
435
+ $.ajax({
436
+ url: '/ampOpenapiService?method=usercenter.portal.getConfig',
437
+ type: 'POST',
438
+ data: {},
439
+ dataType: 'json',
440
+ success: function(res) {
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
+ }
449
+ }
450
+ }
451
+ });
452
+ }
453
+
454
+ function getCongouCookie(value) {
455
+ if (!value)
456
+ return '';
457
+ try {
458
+ let v = JSON.parse(value);
459
+ v = v.state;
460
+ if (v) {
461
+ return v.split(':')[1];
462
+ } else {
463
+ return value;
464
+ }
465
+ } catch (e) {
466
+ return value;
467
+ }
468
+ }
469
+
470
+ caseMethod.getUserCode = function (v) {
471
+ let that = null;
472
+ if (!v) {
473
+ that = this;
474
+ } else {
475
+ that = v;
476
+ }
477
+ let token = caseMethod.getToken(v);
478
+ let portalkey = '';
479
+ let usercode = '';
480
+ portalkey = that.portalkey;
481
+ usercode = that.OmdUrl.uid;
482
+ if (token) {
483
+ if(portalkey == 'congou'){
484
+ usercode = getCongouCookie(Cookies.get('user_code'));
485
+ }
486
+ else
487
+ {
488
+ if (Cookies.get('user_code')) {
489
+ usercode = Cookies.get('user_code');
490
+ }
491
+ }
492
+ }
493
+ return usercode;
494
+ };
495
+
496
+ caseMethod.getUserName = function (v) {
497
+ let that = null;
498
+ if (!v) {
499
+ that = this;
500
+ } else {
501
+ that = v;
502
+ }
503
+ let token = caseMethod.getToken(v);
504
+ let portalkey = '';
505
+ let username = '';
506
+ portalkey = that.portalkey;
507
+ username = '[' + that.OmdUrl.uid + ']' + that.OmdUrl.uname;
508
+ if (token) {
509
+ if(portalkey == 'congou'){
510
+ username = '[' + getCongouCookie(Cookies.get('user_code')) + ']' + getCongouCookie(Cookies.get('user_name'));
511
+ }
512
+ else
513
+ {
514
+ if (Cookies.get('user_code')) {
515
+ username = '[' + Cookies.get('user_code') + ']' +Cookies.get('user_name');
516
+ }
517
+ }
518
+ }
519
+ return username;
520
+ };
521
+
522
+ caseMethod.getPortalMkt =function() {
523
+ let obj = {};
524
+ obj.shopId = Cookies.get('shopId');
525
+ obj.shopCode = Cookies.get('shopCode');
526
+ obj.shopName = Cookies.get('shopName');
527
+ return obj;
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
+ };
563
+
564
+ caseMethod.getUrlParam = function (name) {
565
+ let reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)'); // 构造一个含有目标参数的正则表达式对象
566
+
567
+ let list = window.location.href.split('?');
568
+ let r = '';
569
+ if (list.length > 1) {
570
+ r = list[1].match(reg); // 匹配目标参数
571
+ }
572
+ if (!r) {
573
+ if (list.length > 2) {
574
+ r = list[2].match(reg); // 匹配目标参数
575
+ }
576
+ }
577
+ if (r) return decodeURI(r[2]); return ''; // 返回参数值
578
+ };
579
+
580
+ caseMethod.initGlobal = function (_self, _obj, isInitUser) {
581
+ let OmdUrl = {};
582
+ if (!_self.config.globalProperties.OmdUrl) {
583
+ _self.config.globalProperties.OmdUrl = {};
584
+ }
585
+ if (_obj) {
586
+ OmdUrl = Object.assign({},_self.config.globalProperties.OmdUrl, _obj);
587
+ }
588
+ let portalkey = caseMethod.getUrlParam('portalkey');
589
+ if (portalkey) {
590
+ OmdUrl.portalkey = portalkey;
591
+ }
592
+ OmdUrl.eid = caseMethod.getEnt_id(_self.config.globalProperties);
593
+
594
+ OmdUrl.modulecode = caseMethod.getUrlParam('modulecode');
595
+ if (! OmdUrl.modulecode) {
596
+ OmdUrl.modulecode = caseMethod.getUrlParam('billmoduleid');
597
+ }
598
+ OmdUrl.helpindex = caseMethod.getUrlParam('helpindex');
599
+ OmdUrl.billmoduleid =_self.config.globalProperties.modulecode;
600
+ OmdUrl.openbillno = caseMethod.getUrlParam('billno');
601
+ OmdUrl.opentaskid = caseMethod.getUrlParam('taskid');
602
+ OmdUrl.nocheck = caseMethod.getUrlParam('nocheck')?caseMethod.getUrlParam('nocheck'):'N';
603
+ _self.config.globalProperties.OmdUrl = Object.assign({}, _self.config.globalProperties.OmdUrl, OmdUrl);
604
+ // caseMethod.getOmdUrlConfig(_self);
605
+ caseMethod.getPortalConfig(_self);
606
+
607
+ };
608
+
609
+ caseMethod.getUserModuleMethod = function (curlmodulecode) {
610
+ let reModuleMethod = null;
611
+ let token = caseMethod.getToken();
612
+ if (!token) {
613
+ return reModuleMethod;
614
+ }
615
+
616
+ let modulecode = '';
617
+ if (curlmodulecode) {
618
+ modulecode = curlmodulecode;
619
+ } else {
620
+ modulecode = caseMethod.getUrlParam('modulecode');
621
+ if (!modulecode) {
622
+ return reModuleMethod;
623
+ }
624
+ }
625
+ let portalUrl = '/mall-portal-rest/portalesb/ocmrest';
626
+ if (this.OmdUrl && this.OmdUrl.portal) {
627
+ portalUrl = this.OmdUrl.portal;
628
+ }
629
+ let srvkey = caseMethod.getUrlParam('srvkey');
630
+ if (srvkey === 'cloud') {
631
+ portalUrl = this.OmdUrl.mdm;
632
+ }
633
+
634
+ let param = {};
635
+ param.token = token;
636
+ param.modulecode = modulecode;
637
+ this.synchroPost(portalUrl, 'runtime.modulesrivce.getUserModuleMethod',param, function(data) {
638
+ reModuleMethod = data;
639
+ }, null);
640
+ return reModuleMethod;
641
+
642
+ };
643
+ caseMethod.checkModuleByToken = function () {
644
+ let powerflag = false;
645
+ let token = caseMethod.getToken();
646
+ if (!token) {
647
+ return powerflag;
648
+ }
649
+ let modulecode = caseMethod.getUrlParam('modulecode');
650
+ if (!modulecode) {
651
+ return powerflag;
652
+ }
653
+ if (!location.pathname) {
654
+ return powerflag;
655
+ }
656
+ if(this.portalkey != 'congou') {
657
+ return powerflag;
658
+ }
659
+
660
+ let portalUrl = '/mall-portal-rest/portalesb/ocmrest';
661
+ if (this.OmdUrl.portal) {
662
+ portalUrl = this.OmdUrl.portal;
663
+ }
664
+
665
+ let pathname = location.pathname;
666
+
667
+ let searchParam = {
668
+ 'token': token,
669
+ 'modulecode': modulecode,
670
+ 'execmodule': pathname
671
+ };
672
+ let srvkey = caseMethod.getUrlParam('srvkey');
673
+ if (srvkey === 'cloud') {
674
+ portalUrl = this.OmdUrl.mdm;
675
+ }
676
+ let method = 'runtime.modulesrivce.checkmodulebytoken';
677
+ this.synchroPost(portalUrl, method, searchParam, function(data) {
678
+ if (data.flag === '-1') {
679
+ powerflag = true;
680
+ }
681
+ }, null);
682
+ return powerflag;
683
+ };
684
+
685
+ /*
686
+ caseMethod.getDict = function(str, _fields) {
687
+ let fields = 'code,name';
688
+ if (_fields) {
689
+ fields = _fields;
690
+ }
691
+ let dictkey = str.split(',');
692
+ let _dicData = {};
693
+ let str2 = [];
694
+ for (let pro of dictkey) {
695
+ let data = this.$Method.getLocalStorage('dictkey_' + pro);
696
+ if (data) {
697
+ _dicData[pro] = data;
698
+ } else {
699
+ str2.push(pro);
700
+ }
701
+ }
702
+ if (str2.length > 0) {
703
+ let searchParam = {
704
+ fields: fields,
705
+ dict_group_code: str2.join(',')
706
+ };
707
+ let self = this;
708
+ this.synchroPost(this.OmdUrl.omp, 'omp.work.dict.getbydictgroupcode', searchParam,function(data) {
709
+ for (let pro of str2) {
710
+ self.$Method.setLocalStorage('dictkey_' + pro , data[pro], self.OmdUrl.dictExpire);
711
+ _dicData[pro] = data[pro];
712
+ }
713
+ }, null);
714
+ }
715
+ return _dicData;
716
+ };
717
+ */
718
+
719
+ caseMethod.getDict = function(str, _fields) {
720
+ let fields = 'code,name';
721
+ if (_fields) {
722
+ fields = _fields;
723
+ }
724
+ let _dicData = {};
725
+ let searchParam = {
726
+ fields: fields,
727
+ dict_group_code:str
728
+ };
729
+ this.synchroPost(this.OmdUrl.omp, 'omp.work.dict.getbydictgroupcode', searchParam,function(data) {
730
+ _dicData = data;
731
+ }, null);
732
+ return _dicData;
733
+ };
734
+
735
+ caseMethod.setQueryConfig = function(obj) {
736
+ Object.assign(this.query.Config, obj);
737
+ };
738
+ caseMethod.getQueryConfig = function (selectkey) {
739
+ let config = null;
740
+ if (this.query.Config[selectkey]) {
741
+ config = JSON.parse(JSON.stringify(this.query.Config[selectkey]));
742
+ } else {
743
+ config = {};
744
+ }
745
+ if (config.width === undefined) {
746
+ if (config.isTree) {
747
+ config.width = 0.3;
748
+ } else {
749
+ config.width = 0.4;
750
+ }
751
+ }
752
+ if (config.height === undefined) {
753
+ config.height = 0.6;
754
+ }
755
+ if (config.responseId === undefined) {
756
+ config.responseId = config.responseCode;
757
+ }
758
+ if (config.manualLoad === undefined) {
759
+ config.manualLoad = true;
760
+ }
761
+ if (config.multiSelect === undefined) {
762
+ config.multiSelect = false;
763
+ }
764
+
765
+ if (config.showCondition === undefined) {
766
+ config.showCondition = true;
767
+ }
768
+ /*if (config.isTree) {
769
+ config.popControl = 'SimpleTree';
770
+ } else {
771
+ config.popControl = 'SimpleViewGrid';
772
+ }*/
773
+ if (config.isConfig) {
774
+ return config;
775
+ } else {
776
+ if (this.query.customQueryConfig) {
777
+ return this.query.customQueryConfig(config);
778
+ } else {
779
+ return config;
780
+ }
781
+ }
782
+
783
+ };
784
+ caseMethod.getBillmoduleid = function(billtype) {
785
+ let billmoduleid = '';
786
+ let searchParam = {'billtype':billtype,'order_field' : 'modeid'};
787
+ let method = 'mss.base.billmain.search';
788
+ this.synchroPost(this.OmdUrl.mall, method,searchParam, function(data) {
789
+ if(data && data.billmain && data.billmain.length >0){
790
+ billmoduleid =data.billmain[0].modeid;
791
+ }
792
+ },null);
793
+ return billmoduleid;
794
+ };
795
+ caseMethod.getBilltype = function(billmoduleid) {
796
+ let billtype = '';
797
+ let searchParam = {'modeid':billmoduleid};
798
+ let method = 'mss.base.billmain.search';
799
+ this.synchroPost(this.OmdUrl.mall, method,searchParam, function(data) {
800
+ if(data && data.billmain && data.billmain.length >0){
801
+ billtype =data.billmain[0].billtype;
802
+ }
803
+ },null);
804
+ return billtype;
805
+ };
806
+ caseMethod.getHelpdocumenturl = function() {
807
+ let url = '';
808
+ let searchParam = {'queryid':'select_fgetmanapara','mpmkt':'00','mpcode':'HELPDOCUMENTURL'};
809
+ let method = 'mss.work.report.query';
810
+ this.synchroPost(this.OmdUrl.mall, method,searchParam, function(data) {
811
+ if(data && data.report && data.report.length >0){
812
+ url =data.report[0].mpvalue;
813
+ }
814
+ },null);
815
+ return url;
816
+ };
817
+ caseMethod.getHelpId = function(helpType,helpIndex) {
818
+ let helpId = '';
819
+ let para = {};
820
+ para.helpType = helpType;
821
+ para.helpIndex = helpIndex;
822
+ this.synchroPost(this.OmdUrl.amp, 'usercenter.helpconfig.getHelpId', para, function(data) {
823
+ if(data && data.helpId){
824
+ helpId = data.helpId
825
+ }
826
+ },function(data) {
827
+ helpId= '';
828
+ },function(data) {
829
+ helpId= '';
830
+ });
831
+ return helpId;
832
+ };
833
+
834
+
835
+ caseMethod.getConditionValue = function (name, value, calculator, config) {
836
+ let condition = {};
837
+ if (calculator === '==') {
838
+ if (config.type === 'DateBox') {
839
+ condition[name] = {};
840
+ let temp = {};
841
+ temp['>='] = value;
842
+ if (config.vtype === 'month') {
843
+ temp['<'] = this.$Method.getNextMonthFirstDay(value);
844
+ } else {
845
+ temp['<'] = this.$Method.getTomorrow(value);
846
+ }
847
+ condition[name] = temp;
848
+ } else {
849
+ if (name === 'inputer' || name === 'auditor' || name === 'canceler') {
850
+ let temp1 = {};
851
+ temp1[name] = {'==':value};
852
+ let temp2 = {};
853
+ temp2[name+'_name'] = {'LIKE': '[%]' + value};
854
+ condition['$or'] = [];
855
+ condition['$or'].push(temp1);
856
+ condition['$or'].push(temp2);
857
+ } else {
858
+ condition[name] = {};
859
+ if (value.value !== undefined) {
860
+ condition[name][calculator] = value.value;
861
+ } else {
862
+ condition[name][calculator] = value;
863
+ }
864
+ }
865
+ }
866
+ }
867
+
868
+ if (calculator === 'LIKE') {
869
+ condition[name] = {};
870
+ condition[name][calculator] = '%' + value + '%';
871
+ }
872
+
873
+ if (calculator !== 'LIKE' && calculator !== '==') {
874
+ condition[name] = {};
875
+ condition[name][calculator] = value;
876
+ }
877
+ return condition;
878
+ };
879
+ caseMethod.getHelpUrl = function() {
880
+ let url = '';
881
+ if (this.helpindex) {
882
+ let helpUrl = '';
883
+ if (this.OmdUrl.helpUrl) {
884
+ helpUrl = this.OmdUrl.helpUrl;
885
+ } else {
886
+ helpUrl = this.getHelpdocumenturl();
887
+ }
888
+ if (helpUrl) {
889
+ url = 'http://'+helpUrl+'/web/#/'+this.OmdUrl.helpType+'?page_id='+ this.helpindex;
890
+ }
891
+ }
892
+ return url;
893
+
894
+ };
895
+ caseMethod.getEnt_id = function(_self) {
896
+ let ent_id = '';
897
+ let portalkey = '';
898
+ if (_self) {
899
+ ent_id = _self.OmdUrl.eid;
900
+ portalkey = _self.OmdUrl.portalkey;
901
+ } else {
902
+ ent_id = this.OmdUrl.eid;
903
+ portalkey = this.OmdUrl.portalkey;
904
+ }
905
+ if (Cookies.get('ent_id') !== undefined && Cookies.get('ent_id') !== '') {
906
+ ent_id = Cookies.get('ent_id');
907
+ } else {
908
+ let temp = caseMethod.getUrlParam('ent_id');
909
+ if (temp !== undefined && temp !== '') {
910
+ ent_id = temp;
911
+ }
912
+ }
913
+ if (portalkey === 'cloud') {
914
+ let lock_entid = caseMethod.getUrlParam('lock_entid');
915
+ if (lock_entid !== undefined && lock_entid !== '') {
916
+ ent_id = lock_entid;
917
+ }
918
+ }
919
+
920
+ return ent_id;
921
+ };
922
+ caseMethod.getToken = function(_self) {
923
+ let token = '';
924
+ if (!_self) {
925
+ if (this.token) {
926
+ token = this.token;
927
+ }
928
+ } else {
929
+ if (_self.token) {
930
+ token = _self.token;
931
+ }
932
+ }
933
+ if (Cookies.get('token')) {
934
+ token = Cookies.get('token');
935
+ } else {
936
+ let temp = caseMethod.getUrlParam('token');
937
+ if (temp) {
938
+ token = temp;
939
+ }
940
+ }
941
+ return token;
942
+ };
943
+
944
+
945
+
946
+ caseMethod.getModulecode= function () {
947
+ let modulecode = '';
948
+ modulecode = caseMethod.getUrlParam('modulecode');
949
+ if (!modulecode) {
950
+ modulecode = caseMethod.getUrlParam('billmoduleid');
951
+ }
952
+ return modulecode;
953
+ };
954
+ caseMethod.downloadFile = function(url, that) {
955
+
956
+ if (!url) {
957
+ return;
958
+ }
959
+
960
+ let xhr = new XMLHttpRequest();
961
+
962
+ xhr.open('GET', url, true); // 也可以使用POST方式,根据接口
963
+
964
+ xhr.responseType = 'blob'; // 返回类型blob
965
+
966
+ // 定义请求完成的处理函数,请求前也可以增加加载框/禁用下载按钮逻辑
967
+
968
+ xhr.onload = function () {
969
+ // 请求完成
970
+ if (this.status === 200) {
971
+ // 返回200
972
+ let blob = this.response;
973
+ let reader = new FileReader();
974
+ let headerStr = decodeURI(this.getResponseHeader('content-disposition'));
975
+ let filename = headerStr.replace('attachment;filename*=UTF-8\'\'','');
976
+ filename = filename.replace('attachment;filename=','');
977
+ // let filename = this.getAllResponseHeaders().split(';')[2].split('\n')[0].split('filename=')[1];
978
+ reader.readAsDataURL(blob); // 转换为base64,可以直接放入a表情href
979
+ filename = decodeURIComponent(filename);
980
+ //去除空格
981
+ filename = filename.replace(/\ +/g,'');
982
+ //去除换行回车
983
+ filename = filename.replace(/[\r\n]/g,'');
984
+ reader.onload = function () {
985
+
986
+ // 转换完成,创建一个a标签用于下载
987
+
988
+ let a = document.createElement('a');
989
+
990
+ a.download = filename;
991
+
992
+
993
+ //a.href = e.target.result;
994
+ a.href = URL.createObjectURL(blob);
995
+
996
+ $('body').append(a); // 修复firefox中无法触发click
997
+ that.$Spin.hide();
998
+ a.click();
999
+
1000
+ $(a).remove();
1001
+
1002
+ };
1003
+
1004
+ } else {
1005
+ that.$Spin.hide();
1006
+ that.alert('导出失败');
1007
+ }
1008
+
1009
+ };
1010
+
1011
+ // 发送ajax请求
1012
+
1013
+ xhr.send(new Blob());
1014
+
1015
+ };
1016
+
1017
+ caseMethod.exportExcelback = function (that) {
1018
+ if (that.child) {
1019
+ setTimeout(that.exportExcelback(that),100);
1020
+ } else {
1021
+ that.$Spin.hide();
1022
+ }
1023
+ };
1024
+
1025
+ caseMethod.doExportExcel = function(_baseUrl,_method,_param,exportType,that){
1026
+ let url = _baseUrl;
1027
+ //filetyep:1 导出文件XlS filetype:2 导出文件XLSX 默认为2
1028
+ //_param.filetype = "1";
1029
+ if (!_param) {
1030
+ _param = {};
1031
+ }
1032
+ url = getresturl(url, _method, _param, that);
1033
+ let _paramStr = JSON.stringify(_param);
1034
+ _paramStr = _paramStr.replaceAll('#','%23');
1035
+ _paramStr = _paramStr.replaceAll('&','%26');
1036
+ _paramStr = _paramStr.replaceAll('+','%2B');
1037
+ //_paramStr = _paramStr.replaceAll(':','%3A');
1038
+ url = encodeURI(url + '&param=' + _paramStr);
1039
+ let userid = Cookies.get('user_id');
1040
+ let user_code = Cookies.get('user_code');
1041
+ if (userid) {
1042
+ url=url+encodeURI('&user_id='+userid);
1043
+ }
1044
+ if (user_code) {
1045
+ url=url+encodeURI('&user_code='+user_code);
1046
+ }
1047
+ that.$Spin.show({
1048
+ render: (h) => {
1049
+ return h('div', '导出中...,请勿关闭!');
1050
+ }
1051
+ });
1052
+ if (!exportType) {
1053
+ exportType = '2';
1054
+ }
1055
+ if(exportType === '2'){
1056
+ caseMethod.downloadFile(url, that);
1057
+ } else {
1058
+ const child = window.open(url,'_blank');
1059
+ var loop = setInterval(function () {
1060
+ if (child.closed) {
1061
+ that.$Spin.hide();
1062
+ clearInterval(loop);
1063
+ }
1064
+ }, 100);
1065
+ // setTimeout(caseMethod.exportExcelback(that),100);
1066
+ }
1067
+ };
1068
+
1069
+ caseMethod.doExportReport= function(_baseUrl,_method,_param,that){
1070
+ let url = _baseUrl;
1071
+ if (!_param) {
1072
+ _param = {};
1073
+ }
1074
+ url = getresturl(url, _method, _param, that);
1075
+ let _paramStr = JSON.stringify(_param);
1076
+ _paramStr = _paramStr.replaceAll('#','%23');
1077
+ _paramStr = _paramStr.replaceAll('&','%26');
1078
+ _paramStr = _paramStr.replaceAll('+','%2B');
1079
+ url = encodeURI(url + '&param=' + _paramStr);
1080
+ that.$Spin.show({
1081
+ render: (h) => {
1082
+ return h('div', '导出中...,请勿关闭!');
1083
+ }
1084
+ });
1085
+ caseMethod.downloadFile(url, that);
1086
+ };
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
+
1179
+ caseMethod.getFilesInfo = function(billno, billmoduleid,notdelfile,scenetype, callBackMethod) {
1180
+ let usercode = caseMethod.getUserCode();
1181
+ let username = caseMethod.getUserName();
1182
+ let token = caseMethod.getToken();
1183
+ let url = OmdUrl.getfile + 'billno=' + billno + '&billmoduleid=' + billmoduleid+'&scenetype=' + scenetype;
1184
+ let userInfo = '&usercode=' + usercode + '&username=' + username+'&token=' + token;
1185
+ if (notdelfile !== 'Y') {
1186
+ userInfo = userInfo + '&notdelfile=N';
1187
+ } else {
1188
+ userInfo = userInfo + '&notdelfile=Y';
1189
+ }
1190
+ userInfo = encodeURI(userInfo);
1191
+ caseMethod.synchroPost(url, '', {}, (result) => {
1192
+ let data = [];
1193
+ if (result && result.length > 0) {
1194
+ result.forEach(el => {
1195
+ let obj = Object.assign({},{},el);
1196
+ obj.filename = el.filename;
1197
+ obj.filekey = el.filekey;
1198
+ obj.downUrl = OmdUrl.downfile + obj.filekey + userInfo;
1199
+ obj.delUrl = OmdUrl.delfile + obj.filekey + userInfo;
1200
+ obj.title = obj.filename;
1201
+ obj.url = obj.downUrl;
1202
+ obj.modflag = el.modflag;
1203
+ data.push(obj);
1204
+ });
1205
+ }
1206
+ callBackMethod(data);
1207
+ }, null, null, 'get');
1208
+ };
1209
+
1210
+ caseMethod.getFilesInfoByIdkey = function(idkey, callBackMethod) {
1211
+ let usercode = caseMethod.getUserCode();
1212
+ let username = caseMethod.getUserName();
1213
+ let token = caseMethod.getToken();
1214
+ let url = OmdUrl.getfile + 'idkey=' + idkey;
1215
+ let userInfo = '&usercode=' + usercode + '&username=' + username +'&token=' + token;
1216
+ userInfo = encodeURI(userInfo);
1217
+ caseMethod.synchroPost(url, '', {}, (result) => {
1218
+ let data = [];
1219
+ if (result && result.length > 0) {
1220
+ result.forEach(el => {
1221
+ let obj = Object.assign({},{},el);
1222
+ obj.filename = el.filename;
1223
+ obj.filekey = el.filekey;
1224
+ obj.downUrl = OmdUrl.downfile + obj.filekey + userInfo;
1225
+ obj.delUrl = OmdUrl.delfile + obj.filekey + userInfo;
1226
+ obj.title = obj.filename;
1227
+ obj.url = obj.downUrl;
1228
+ obj.modflag = el.modflag;
1229
+ data.push(obj);
1230
+ });
1231
+ }
1232
+ callBackMethod(data);
1233
+ }, null, null, 'get');
1234
+ };
1235
+ caseMethod.getFileInfo = function(filekey,callBackMethod) {
1236
+ let usercode = caseMethod.getUserCode();
1237
+ let username = caseMethod.getUserName();
1238
+ let token = caseMethod.getToken();
1239
+ let url = OmdUrl.getfile + 'filekey=' + filekey;
1240
+ let userInfo = '&usercode=' + usercode + '&username=' + username +'&token=' + token;
1241
+ userInfo = encodeURI(userInfo);
1242
+ caseMethod.synchroPost(url, '', {}, (result) => {
1243
+ let data = [];
1244
+ if (result && result.length > 0) {
1245
+ result.forEach(el => {
1246
+ let obj = Object.assign({},{},el);
1247
+ obj.filename = el.filename;
1248
+ obj.filekey = el.filekey;
1249
+ obj.downUrl = OmdUrl.downfile + obj.filekey + userInfo;
1250
+ obj.delUrl = OmdUrl.delfile + obj.filekey + userInfo;
1251
+ obj.title = obj.filename;
1252
+ obj.url = obj.downUrl;
1253
+ obj.modflag = el.modflag;
1254
+ data.push(obj);
1255
+ });
1256
+ }
1257
+ callBackMethod(data);
1258
+ }, null, null, 'get');
1259
+ };
1260
+ caseMethod.setUrlSuffix = function(url,self) {
1261
+ let srvkey = caseMethod.getUrlParam('srvkey');
1262
+ let token = caseMethod.getUrlParam('token');
1263
+ let user_code = caseMethod.getUrlParam('usercode');
1264
+ let portalkey = caseMethod.getUrlParam('portalkey')
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;
1273
+ }
1274
+ export default caseMethod;