cnhis-design-vue 2.1.22 → 2.1.23

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 (122) hide show
  1. package/CHANGELOG.md +2280 -2270
  2. package/es/affix/index.js +8 -8
  3. package/es/age/index.js +10 -10
  4. package/es/alert/index.js +8 -8
  5. package/es/anchor/index.js +8 -8
  6. package/es/auto-complete/index.js +8 -8
  7. package/es/avatar/index.js +8 -8
  8. package/es/back-top/index.js +8 -8
  9. package/es/badge/index.js +8 -8
  10. package/es/base/index.js +8 -8
  11. package/es/big-table/index.js +164 -164
  12. package/es/breadcrumb/index.js +8 -8
  13. package/es/button/index.js +31 -31
  14. package/es/calendar/index.js +8 -8
  15. package/es/captcha/index.js +3 -3
  16. package/es/card/index.js +8 -8
  17. package/es/carousel/index.js +8 -8
  18. package/es/cascader/index.js +8 -8
  19. package/es/checkbox/index.js +9 -9
  20. package/es/col/index.js +8 -8
  21. package/es/collapse/index.js +8 -8
  22. package/es/color-picker/index.js +1 -1
  23. package/es/comment/index.js +8 -8
  24. package/es/config-provider/index.js +8 -8
  25. package/es/date-picker/index.js +8 -8
  26. package/es/descriptions/index.js +8 -8
  27. package/es/divider/index.js +8 -8
  28. package/es/drag-layout/index.js +3 -3
  29. package/es/drawer/index.js +8 -8
  30. package/es/dropdown/index.js +8 -8
  31. package/es/editor/index.js +1 -1
  32. package/es/empty/index.js +8 -8
  33. package/es/fabric-chart/index.js +39 -39
  34. package/es/form/index.js +8 -8
  35. package/es/form-model/index.js +8 -8
  36. package/es/form-table/index.js +62 -62
  37. package/es/index/index.js +708 -685
  38. package/es/index/style.css +1 -1
  39. package/es/input/index.js +9 -9
  40. package/es/input-number/index.js +8 -8
  41. package/es/layout/index.js +8 -8
  42. package/es/list/index.js +8 -8
  43. package/es/locale-provider/index.js +8 -8
  44. package/es/map/index.js +9 -9
  45. package/es/mentions/index.js +8 -8
  46. package/es/menu/index.js +8 -8
  47. package/es/message/index.js +8 -8
  48. package/es/multi-chat/index.js +92 -92
  49. package/es/multi-chat-client/index.js +86 -86
  50. package/es/multi-chat-history/index.js +4 -4
  51. package/es/multi-chat-record/index.js +14 -14
  52. package/es/multi-chat-setting/index.js +27 -27
  53. package/es/multi-chat-sip/index.js +1 -1
  54. package/es/notification/index.js +8 -8
  55. package/es/page-header/index.js +8 -8
  56. package/es/pagination/index.js +8 -8
  57. package/es/popconfirm/index.js +8 -8
  58. package/es/popover/index.js +8 -8
  59. package/es/progress/index.js +8 -8
  60. package/es/radio/index.js +9 -9
  61. package/es/rate/index.js +8 -8
  62. package/es/result/index.js +8 -8
  63. package/es/row/index.js +8 -8
  64. package/es/scale-view/index.js +33 -33
  65. package/es/select/index.js +11 -11
  66. package/es/select-label/index.js +11 -11
  67. package/es/select-person/index.js +81 -58
  68. package/es/select-person/style.css +1 -1
  69. package/es/skeleton/index.js +8 -8
  70. package/es/slider/index.js +8 -8
  71. package/es/space/index.js +8 -8
  72. package/es/spin/index.js +8 -8
  73. package/es/statistic/index.js +8 -8
  74. package/es/steps/index.js +8 -8
  75. package/es/switch/index.js +8 -8
  76. package/es/table-filter/index.js +142 -142
  77. package/es/tabs/index.js +8 -8
  78. package/es/tag/index.js +9 -9
  79. package/es/time-picker/index.js +8 -8
  80. package/es/timeline/index.js +8 -8
  81. package/es/tooltip/index.js +8 -8
  82. package/es/transfer/index.js +8 -8
  83. package/es/tree/index.js +8 -8
  84. package/es/tree-select/index.js +8 -8
  85. package/es/upload/index.js +8 -8
  86. package/es/verification-code/index.js +2 -2
  87. package/lib/cui.common.js +659 -636
  88. package/lib/cui.umd.js +659 -636
  89. package/lib/cui.umd.min.js +13 -13
  90. package/package.json +107 -107
  91. package/packages/big-table/src/BigTable.vue +3044 -3044
  92. package/packages/big-table/src/assets/style/table-base.less +370 -370
  93. package/packages/big-table/src/components/AutoLayoutButton.vue +270 -270
  94. package/packages/big-table/src/utils/batchEditing.js +610 -610
  95. package/packages/big-table/src/utils/bigTableProps.js +95 -95
  96. package/packages/button/src/ButtonPrint/components/IdentityVerification.vue +181 -181
  97. package/packages/button/src/ButtonPrint/index.vue +728 -728
  98. package/packages/fabric-chart/src/components/TimeScaleValue.vue +113 -113
  99. package/packages/fabric-chart/src/const/defaultVaule.js +59 -59
  100. package/packages/fabric-chart/src/fabric-chart/FabricPolylines.vue +1066 -1066
  101. package/packages/fabric-chart/src/fabric-chart/FabricScaleValue.vue +135 -135
  102. package/packages/fabric-chart/src/fabric-chart/FabricTextGroup.vue +558 -558
  103. package/packages/fabric-chart/src/fabric-chart2/FabricTop.vue +172 -172
  104. package/packages/multi-chat/chat/chatFooter.vue +1594 -1594
  105. package/packages/multi-chat/chat/chatMain.vue +1466 -1466
  106. package/packages/multi-chat/chat/quickReply.vue +439 -439
  107. package/packages/multi-chat/chat/scrollList.vue +1232 -1232
  108. package/packages/multi-chat/setting/baseInfo/index.vue +1316 -1316
  109. package/packages/multi-chat/store/actions.js +448 -448
  110. package/packages/multi-chat/store/state.js +112 -112
  111. package/packages/scale-view/formitem/r-choice.vue +714 -714
  112. package/packages/scale-view/scaleView.vue +2010 -2010
  113. package/packages/select-person/select-person.vue +1680 -1658
  114. package/packages/table-filter/src/base-search-com/BaseSearch.vue +2462 -2462
  115. package/packages/table-filter/src/components/c-tree-select/tree-select.vue +336 -336
  116. package/packages/table-filter/src/components/multi-select/multi-select.vue +219 -219
  117. package/packages/table-filter/src/components/out-quick-search/out-quick-search.vue +340 -340
  118. package/packages/table-filter/src/components/search-condition/SearchCondition.vue +1825 -1825
  119. package/packages/table-filter/src/const/dataOptions.js +43 -43
  120. package/packages/table-filter/src/mixins/mixins.js +695 -695
  121. package/packages/table-filter/src/quick-search/QuickSearch.vue +2109 -2109
  122. package/src/directive/preventReClick.js +12 -12
@@ -1,728 +1,728 @@
1
- <template>
2
- <span v-clickoutside="handleClickOutside" @click="handleClickWrap">
3
- <a-dropdown :visible="visible" overlayClassName="rowFoldHideBtnList-dropdown">
4
- <a-menu slot="overlay">
5
- <a-sub-menu class="format-name" key="format" :title="formatTitle">
6
- <a-menu-item v-for="item in formatList" :key="item.id" :class="{ active: item.id === currentFormatId }" @click="handleClickFormat(item.id)">
7
- {{ item.name }}
8
- </a-menu-item>
9
- </a-sub-menu>
10
- <a-menu-divider />
11
- <a-menu-item @click="e => handleClickPrint(e)">
12
- {{ printText }}
13
- </a-menu-item>
14
- <a-menu-item @click="e => handleClickPreview(e)">
15
- {{ previewText }}
16
- </a-menu-item>
17
- <a-menu-item @click="e => handleClickEdit(e)">
18
- {{ formatEditText }}
19
- </a-menu-item>
20
- </a-menu>
21
- <slot name="button" :handleClickPrintBtn="handleClickBtn" :printSpinning="spinning" :printbtnText="btnText" :printVisible="visible">
22
- <a-button class="dropdown-button" style="margin: 0 8px 8px 0" @click.stop="handleClickBtn">
23
- <a-icon v-if="spinning" type="loading" style="line-height: 10px" />
24
- {{ btnText }}
25
- <a-icon type="down" />
26
- </a-button>
27
- </slot>
28
- </a-dropdown>
29
-
30
- <IdentityVerification
31
- :printConfig="printConfig"
32
- :baseUrl="baseUrl"
33
- :verifyUserUrl="verifyUserUrl"
34
- :visible.sync="identityVerification.visible"
35
- :identityVerificationTitle="identityVerificationTitle"
36
- :authorizationKey="authorizationKey"
37
- @success="verifiySuccess"
38
- ></IdentityVerification>
39
- </span>
40
- </template>
41
- <script>
42
- /**
43
- * @author ruanlin
44
- * @desc 全继承antd按钮组件,后期再扩展
45
- * @time 2021-06-08
46
- */
47
-
48
- let printInstance = null;
49
- let httpFn = null;
50
- import Print from './js/print.es.min';
51
- import IdentityVerification from './components/IdentityVerification';
52
- import Clickoutside from '@/utils/clickoutside';
53
- import Vue from 'vue';
54
- import { Button, Dropdown, Menu, Icon } from 'ant-design-vue';
55
- import create from '@/core/create';
56
- import axios from 'axios';
57
- import moment from 'moment';
58
- import vexutils from '@/utils/vexutils';
59
-
60
- export default create({
61
- name: 'button-print',
62
- components: {
63
- IdentityVerification
64
- },
65
- directives: { Clickoutside },
66
- props: {
67
- baseUrl: {
68
- type: String
69
- },
70
- /* */
71
- btnText: {
72
- type: String,
73
- default: '打印'
74
- },
75
- printText: {
76
- type: String,
77
- default: '直接打印'
78
- },
79
- previewText: {
80
- type: String,
81
- default: '打印预览'
82
- },
83
- formatEditText: {
84
- type: String,
85
- default: '格式编辑'
86
- },
87
- identityVerificationTitle: {
88
- type: String,
89
- default: '打印服务身份校验'
90
- },
91
- /* */
92
- authorizationKey: {
93
- type: String,
94
- require: true
95
- },
96
- templateNumber: {
97
- type: [Number, String],
98
- require: true
99
- },
100
- /* 格式化打印参数,需的原始数据 */
101
- params: {
102
- type: Array
103
- },
104
- hisParams: {
105
- type: Object
106
- },
107
- /* */
108
- prevFn: {
109
- type: Function,
110
- default() {
111
- return Promise.resolve();
112
- }
113
- },
114
- /** */
115
- verifyUserUrl: {
116
- type: String,
117
- default: '/verifyUser'
118
- },
119
- /** */
120
- getPrintFormatByNumberUrl: {
121
- type: String,
122
- default: '/getPrintFormatByNumber'
123
- },
124
- /** */
125
- getTemplateParamsUrl: {
126
- type: String,
127
- default: '/getTemplateParams'
128
- },
129
- /* 打印策略,默认多条打印 */
130
- strategy: {
131
- type: String,
132
- default: 'MULTI'
133
- },
134
- printConfig: {
135
- type: Object,
136
- default: () => ({})
137
- },
138
- // 1 为his老版,2 为新版 3为his更老版本
139
- versionType: { type: [Number, String], default: '2' }
140
- },
141
- computed: {
142
- currentFormatItem() {
143
- if (!this.currentFormatId) return {};
144
- let id = this.currentFormatId;
145
- return this.formatList.find(item => item.id === id);
146
- },
147
- formatTitle() {
148
- return this.currentFormatItem?.name || '格式选择';
149
- }
150
- },
151
- data() {
152
- return {
153
- spinning: false,
154
- visible: false,
155
- formatList: [],
156
- templateParams: {},
157
- printParams: [],
158
- currentFormatId: '',
159
- /* */
160
- identityVerification: {
161
- visible: false
162
- },
163
- isInited: false,
164
- watchPrintParamsReformatFn: null,
165
- spinTimer: null
166
- };
167
- },
168
- beforeCreate() {
169
- Vue.use(Button).use(Dropdown).use(Menu).use(Icon);
170
- },
171
- mounted() {
172
- this.isInited = false;
173
- },
174
- beforeDestroy() {
175
- // 创建Print实例的时候会在webview中注册一个事件, 需要调用printInstance.destroy()手动清除
176
- printInstance?.destroy?.()
177
- },
178
- watch: {
179
- // 监听变化, 重新格式化printParams
180
- params: {
181
- deep: true,
182
- handler(val) {
183
- if (!val?.length) return false;
184
- this.reformatPrintParams();
185
- }
186
- }
187
- },
188
- methods: {
189
- // getPopupContainer(triggerNode) {
190
- // return triggerNode.parentNode;
191
- // },
192
- handleClickOutside() {
193
- this.visible = false;
194
- },
195
- handleClickWrap() {
196
- setTimeout(() => {
197
- this.visible = true;
198
- }, 0);
199
- },
200
- /* */
201
- async handleClickBtn() {
202
- if (!this.visible) {
203
- let result = await this.init();
204
- if (!result) return false;
205
- }
206
-
207
- this.visible = !this.visible;
208
- },
209
- /* */
210
- async init() {
211
- if (this.isInited) return true;
212
- this.isInited = true;
213
-
214
- this.setTimeoutSpin();
215
-
216
- this.instantiatePrintSDK();
217
- let config = {
218
- withCredentials: false,
219
- timeout: 5000
220
- };
221
- let printUrlPrefix = this?.printConfig?.printUrlPrefix;
222
- let customCofing = this?.printConfig?.customCofing || {};
223
- let cCofing = this.getCustomCofing(customCofing);
224
- if (axios !== this.axios && printUrlPrefix) {
225
- config.baseURL = printUrlPrefix;
226
- }
227
- httpFn = axios.create({
228
- ...config,
229
- ...cCofing
230
- });
231
- const formatListResult = await this.queryFormatList();
232
- if (this.versionType == 1 || this.versionType == 3) {
233
- this.initHIS(formatListResult);
234
- } else {
235
- await this.initCRM(formatListResult);
236
- }
237
-
238
- this.setLoaded();
239
-
240
- return true;
241
- },
242
- initHIS(formatListResult) {
243
- this.formatList = formatListResult ? formatListResult.list.filter(item => item.printmark == 1) : [];
244
- this.currentFormatId = this.getDefaultFormatId(this.formatList, 'printmark');
245
- this.templateParams = this.formatList[0] || {};
246
- },
247
- async initCRM(formatListResult) {
248
- this.formatList = formatListResult ? this.formatFormatList(formatListResult.obj) : [];
249
- this.currentFormatId = this.getDefaultFormatId(this.formatList, 'defaultFlag');
250
-
251
- if (!this.currentFormatId) {
252
- this.$message.error('获取打印格式失败,请联系管理员!');
253
- return this.requestError();
254
- }
255
- if (!this.currentFormatId) {
256
- this.requestError();
257
- return;
258
- }
259
- let templateParamsResult = await this.queryTemplateParams();
260
-
261
- if (templateParamsResult) {
262
- this.templateParams = templateParamsResult;
263
- } else {
264
- return this.requestError();
265
- }
266
-
267
- this.printParams = this.formatParams(this.templateParams, this.params);
268
- },
269
- setTimeoutSpin() {
270
- this.spinTimer = setTimeout(() => {
271
- this.spinning = true;
272
- }, 1500);
273
- },
274
- setLoaded() {
275
- this.spinning = false;
276
- if (!this.spinTimer) return false;
277
- clearTimeout(this.spinTimer);
278
- this.spinTimer = null;
279
- },
280
- requestError() {
281
- this.isInited = false;
282
- this.setLoaded();
283
- setTimeout(() => {
284
- this.visible = false;
285
- }, 0);
286
-
287
- return false;
288
- },
289
- getDefaultFormatId(list, key) {
290
- if (!list?.length) return '';
291
- let findDefault = list.find(item => item[key] == 1);
292
- return findDefault?.id || list[0].id;
293
- },
294
- /* */
295
- instantiatePrintSDK() {
296
- if (printInstance) return false;
297
- printInstance = new Print();
298
- },
299
- /* */
300
- queryFormatList() {
301
- const { templateNumber, authorizationKey, baseUrl, getPrintFormatByNumberUrl, versionType } = this;
302
- const suffix = [1, 3].includes(versionType) ? `jsessionids=${vexutils.cookie.get('jsessionids') || '31e5fc0e-955f-4c89-9679-39c43d0171321636163291241'}` : `authorizationKey=${authorizationKey}`;
303
- const url = `${baseUrl}${getPrintFormatByNumberUrl}?number=${templateNumber}&${suffix}`;
304
- return httpFn
305
- .get(url)
306
- .then(async ({ data }) => {
307
- if (data.result !== 'SUCCESS') {
308
- this.$message.error(data.resultMsg || '参数异常,请联系管理员');
309
- return false;
310
- }
311
- return data;
312
- })
313
- .catch(e => {
314
- return false;
315
- });
316
- },
317
- formatFormatList(list) {
318
- let formatList = [];
319
-
320
- list.forEach(item => {
321
- if (!item.format) return false;
322
- formatList.push(...item.format);
323
- });
324
-
325
- return formatList;
326
- },
327
- /* */
328
- queryTemplateParams() {
329
- const { templateNumber, authorizationKey, baseUrl, getTemplateParamsUrl } = this;
330
- const { templateId } = this.formatList[0] || {};
331
- const url = `${baseUrl}${getTemplateParamsUrl}?number=${templateNumber}&templateId=${templateId}&authorizationKey=${authorizationKey}`;
332
-
333
- return httpFn
334
- .get(url)
335
- .then(async ({ data }) => {
336
- if (data.result !== 'SUCCESS') {
337
- this.$message.error(data.resultMsg || '参数异常,请联系管理员');
338
- return false;
339
- }
340
- return data?.obj || {};
341
- })
342
- .catch(e => {
343
- return false;
344
- });
345
- },
346
- formatDefaultVal(i, tableVal) {
347
- let val = i.defaultValue || '';
348
- let tVal = tableVal;
349
- if (i.type === 'NUMBER') {
350
- tVal = Number(tableVal) || 0;
351
- }
352
- if (i.type === 'DATE') {
353
- tVal = tableVal ? moment(tableVal).format('YYYY-MM-DD') : '';
354
- }
355
- if (i.type === 'DATETIME') {
356
- tVal = tableVal ? moment(tableVal).format('YYYY-MM-DD HH:mm:ss') : '';
357
- }
358
-
359
- return val ? val : tVal;
360
- },
361
- formatParams({ customizeDataset = [], param = [] }, params = []) {
362
- return params.map(paramObj => {
363
- let res = {};
364
-
365
- // 自定义结果集
366
- customizeDataset.forEach(dataSetItem => {
367
- const selectFieldList = dataSetItem.dataSetting[0].selectFieldList;
368
- res['datasetData'] = {
369
- [dataSetItem.name]: JSON.stringify(this.formatPrintParams(paramObj, selectFieldList, 'fieldName'))
370
- };
371
- });
372
-
373
- // 参数
374
- res = Object.assign({}, res, this.formatPrintParams(paramObj, param, 'key'));
375
- return res;
376
- });
377
- },
378
- reformatPrintParams() {
379
- this.watchPrintParamsReformatFn && this.watchPrintParamsReformatFn();
380
- /*
381
- 还没初始化完毕时(还没获取到模板格式配置等..)
382
- 触发再格式化逻辑,需等待初始化完毕,再重新执行格式化
383
- */
384
- if (!this.isInited) {
385
- this.watchPrintParamsReformatFn = this.$watch('isInited', val => {
386
- if (!val) return false;
387
- this.reformatPrintParams();
388
- });
389
- return;
390
- }
391
-
392
- this.printParams = this.formatParams(this.templateParams, this.params);
393
- },
394
- formatPrintParams(paramObj, fieldList, keyName) {
395
- const obj = {};
396
- fieldList.forEach(i => {
397
- let defaultVal = this.formatDefaultVal(i, paramObj[i[keyName]]);
398
- if (paramObj[i[keyName]] && defaultVal) {
399
- obj[i[keyName]] = defaultVal;
400
- }
401
- });
402
-
403
- return obj;
404
- },
405
- /* */
406
- handleClickFormat(id) {
407
- this.currentFormatId = id;
408
- },
409
- /* */
410
- getPrintParams(index = 0) {
411
- const params = this.printParams[index];
412
- return JSON.stringify(params);
413
- },
414
- getTemplateIdByFormatId(id) {
415
- let find = this.formatList.find(item => item.id === id);
416
- return find.templateId;
417
- },
418
- getOnceParams() {
419
- // 聚合一条
420
- let params = {};
421
- let obj = {};
422
- if (this.templateParams?.customizeDataset?.length) {
423
- // 有模板数据
424
- const key = Object.keys(this.printParams[0]?.datasetData || {})?.[0] || '';
425
- const datasetDataKeyVal = JSON.stringify(this.printParams.map(v => JSON.parse(v.datasetData[key])));
426
- obj = {
427
- datasetData: {}
428
- };
429
- obj.datasetData[key] = datasetDataKeyVal;
430
- } else {
431
- // 无模板数据
432
- Object.keys(this.printParams[0]).forEach(v => {
433
- obj[v] = [];
434
- this.printParams.forEach(k => {
435
- obj[v].push(k[v]);
436
- });
437
- obj[v] = obj[v].join(',');
438
- });
439
- }
440
- params = Object.assign({}, JSON.parse(this.getPrintParams(0)), obj);
441
- return JSON.stringify(params);
442
- },
443
- handleClickPrint(e) {
444
- e.domEvent.stopPropagation();
445
- let len = this.printParams.length;
446
- const callLocalServicesSuccessCb = async data => {
447
- try {
448
- if (--len <= 0) {
449
- this.callLocalServicesSuccessCb(data, 'print');
450
- }
451
- } catch (error) {
452
- console.log('error', error);
453
- }
454
- };
455
-
456
- this.prevFn()
457
- .catch(() => {
458
- this.prevFnError();
459
- return Promise.reject();
460
- })
461
- .then(() => {
462
- if (this.versionType == 1 || this.versionType == 3) {
463
- const printFn = this.versionType == 1 ? 'handleHisPrint' : 'handleOldHisPrint'
464
- if (this.strategy === 'MULTI') {
465
- for (let i = 0; i < this.params.length; i++) {
466
- const params = this.getHisParams(i);
467
- printInstance[printFn](7, params)
468
- .then(res => {
469
- console.log(res, '777777777777');
470
- })
471
- .catch(error => {
472
- console.log(error, 'error777');
473
- });
474
- }
475
- } else {
476
- const params = this.getOnceHisParams();
477
- printInstance[printFn](7, params)
478
- .then(res => {
479
- console.log(res, '777777777777');
480
- })
481
- .catch(error => {
482
- console.log(error, 'error777');
483
- });
484
- }
485
- } else {
486
- if (this.strategy === 'MULTI') {
487
- // 循环多条
488
- for (let i = 0; i < this.printParams.length; i++) {
489
- const queryParams = {
490
- formatId: this.currentFormatId,
491
- templateId: this.getTemplateIdByFormatId(this.currentFormatId),
492
- params: this.getPrintParams(i)
493
- };
494
- printInstance.printDirect(queryParams, callLocalServicesSuccessCb, this.callLocalServicesErrorCb);
495
- }
496
- } else {
497
- // 聚合一条
498
- const queryParams = {
499
- formatId: this.currentFormatId,
500
- templateId: this.getTemplateIdByFormatId(this.currentFormatId),
501
- params: this.getOnceParams()
502
- };
503
- printInstance.printDirect(
504
- queryParams,
505
- res => {
506
- this.callLocalServicesSuccessCb(res, 'print');
507
- },
508
- this.callLocalServicesErrorCb
509
- );
510
- }
511
- }
512
- })
513
- .finally(() => {
514
- this.visible = false;
515
- });
516
- },
517
- getHisParams(index = 0) {
518
- const { templateParams, hisParams, params } = this;
519
- const { reportid = '280' } = hisParams;
520
- const { id, name } = templateParams;
521
- return {
522
- reportid,
523
- formatid: this.currentFormatId || id,
524
- formatname: name,
525
- param: params[index]
526
- };
527
- },
528
- getOnceHisParams() {
529
- const { templateParams, hisParams, params } = this;
530
- const { reportid = '280' } = hisParams;
531
- const { id, name } = templateParams;
532
- const obj = {}
533
- Object.keys(params[0]).forEach(v => {
534
- obj[v] = [];
535
- params.forEach(k => {
536
- obj[v].push(k[v]);
537
- });
538
- obj[v] = obj[v].join(',');
539
- });
540
- return {
541
- reportid,
542
- formatid: this.currentFormatId || id,
543
- formatname: name,
544
- param: obj
545
- };
546
- },
547
- async handleClickPreview(e) {
548
- e.domEvent.stopPropagation();
549
-
550
- this.prevFn()
551
- .catch(() => {
552
- this.prevFnError();
553
- return Promise.reject();
554
- })
555
- .then(() => {
556
- if (this.versionType == 1 || this.versionType == 3) {
557
- const params = this.strategy === 'MULTI' ? this.getHisParams() : this.getOnceHisParams();
558
- const printFn = this.versionType == 1 ? 'handleHisPrint' : 'handleOldHisPrint'
559
- printInstance[printFn](8, params)
560
- .then(res => {
561
- console.log(res, 88888888);
562
- })
563
- .catch(error => {
564
- console.log(error, 'error888');
565
- });
566
- } else {
567
- const IS_MULTI = this.strategy === 'MULTI';
568
- if(IS_MULTI){
569
- // 循环多条
570
- for (let i = 0; i < this.printParams.length; i++) {
571
- const queryParams = {
572
- formatId: this.currentFormatId,
573
- templateId: this.getTemplateIdByFormatId(this.currentFormatId),
574
- params: this.getPrintParams(i)
575
- };
576
- printInstance.preview(
577
- queryParams,
578
- res => {
579
- this.callLocalServicesSuccessCb(res, 'preview');
580
- },
581
- this.callLocalServicesErrorCb
582
- );
583
- }
584
- } else {
585
- const queryParams = {
586
- formatId: this.currentFormatId,
587
- templateId: this.getTemplateIdByFormatId(this.currentFormatId),
588
- params: this.getOnceParams()
589
- };
590
- printInstance.preview(
591
- queryParams,
592
- res => {
593
- this.callLocalServicesSuccessCb(res, 'preview');
594
- },
595
- this.callLocalServicesErrorCb
596
- );
597
- }
598
- }
599
- })
600
- .finally(() => {
601
- this.visible = false;
602
- });
603
- },
604
- handleClickEdit(e) {
605
- e.domEvent.stopPropagation();
606
-
607
- this.prevFn()
608
- .catch(() => {
609
- this.prevFnError();
610
- return Promise.reject();
611
- })
612
- .then(() => {
613
- if (this.versionType == 1 || this.versionType == 3) {
614
- const params = this.strategy === 'MULTI' ? this.getHisParams() : this.getOnceHisParams();
615
- const printFn = this.versionType == 1 ? 'handleHisPrint' : 'handleOldHisPrint'
616
- printInstance[printFn](9, params)
617
- .then(res => {
618
- console.log(res, 999999);
619
- })
620
- .catch(error => {
621
- console.log(error, 'error999');
622
- });
623
- } else {
624
- this.identityVerification.visible = true;
625
- }
626
- })
627
- .finally(() => {
628
- this.visible = false;
629
- });
630
- },
631
- verifiySuccess(token) {
632
- this.identityVerification.visible = false;
633
-
634
- const queryParams = {
635
- formatId: this.currentFormatId,
636
- templateId: this.getTemplateIdByFormatId(this.currentFormatId),
637
- params: this.getPrintParams(),
638
- token
639
- };
640
- printInstance.editPrintFormat(
641
- queryParams,
642
- res => {
643
- this.callLocalServicesSuccessCb(res, 'edit');
644
- },
645
- this.callLocalServicesErrorCb
646
- );
647
- },
648
- /* */
649
- prevFnError() {
650
- // 前置条件执行错误这里不弹提示,“前置条件”事件内有弹提示了
651
- // let error = {
652
- // message: '前置条件执行错误'
653
- // };
654
- // this.$emit('error', error);
655
- },
656
- /* */
657
- callLocalServicesSuccessCb(res, type) {
658
- let info = {
659
- type,
660
- formatId: this.currentFormatId,
661
- templateId: this.getTemplateIdByFormatId(this.currentFormatId)
662
- };
663
- this.$emit('success', res, info);
664
- },
665
- callLocalServicesErrorCb(res) {
666
- this.$emit('error', res);
667
- },
668
-
669
- /**
670
- * 获取 axios 自定义配置
671
- */
672
- getCustomCofing(customCofing){
673
- let cCofing = {}
674
- let type = typeof customCofing;
675
- if(type === 'function'){
676
- cCofing = customCofing();
677
- } else if(type === 'object'){
678
- cCofing = customCofing;
679
- }
680
- return cCofing;
681
- }
682
- }
683
- });
684
- </script>
685
-
686
- <style lang="less" scoped>
687
- .dropdown-button {
688
- color: #212121;
689
- border-color: #d5d5d5 !important;
690
- margin-left: 8px;
691
- margin-bottom: 8px;
692
- /deep/ .svg-icon {
693
- margin-right: 4px;
694
- }
695
- &.ant-dropdown-trigger {
696
- i.anticon.anticon-down {
697
- color: #969696;
698
- font-size: 14px;
699
- }
700
- }
701
- }
702
- </style>
703
-
704
- <style lang="less">
705
- .rowFoldHideBtnList-dropdown {
706
- min-width: 150px !important;
707
- .ant-dropdown-menu {
708
- overflow-y: auto;
709
- max-height: 99vh;
710
- }
711
- .ant-dropdown-menu-item-group {
712
- .ant-dropdown-menu-item-group-title {
713
- display: none;
714
- }
715
- border-bottom: 1px solid #d5d5d5;
716
- &:last-child {
717
- border-color: transparent;
718
- }
719
- }
720
- .format-name .ant-dropdown-menu-submenu-title {
721
- font-weight: bold;
722
- color: #000;
723
- }
724
- .ant-dropdown-menu-item.active {
725
- color: #5585f5;
726
- }
727
- }
728
- </style>
1
+ <template>
2
+ <span v-clickoutside="handleClickOutside" @click="handleClickWrap">
3
+ <a-dropdown :visible="visible" overlayClassName="rowFoldHideBtnList-dropdown">
4
+ <a-menu slot="overlay">
5
+ <a-sub-menu class="format-name" key="format" :title="formatTitle">
6
+ <a-menu-item v-for="item in formatList" :key="item.id" :class="{ active: item.id === currentFormatId }" @click="handleClickFormat(item.id)">
7
+ {{ item.name }}
8
+ </a-menu-item>
9
+ </a-sub-menu>
10
+ <a-menu-divider />
11
+ <a-menu-item @click="e => handleClickPrint(e)">
12
+ {{ printText }}
13
+ </a-menu-item>
14
+ <a-menu-item @click="e => handleClickPreview(e)">
15
+ {{ previewText }}
16
+ </a-menu-item>
17
+ <a-menu-item @click="e => handleClickEdit(e)">
18
+ {{ formatEditText }}
19
+ </a-menu-item>
20
+ </a-menu>
21
+ <slot name="button" :handleClickPrintBtn="handleClickBtn" :printSpinning="spinning" :printbtnText="btnText" :printVisible="visible">
22
+ <a-button class="dropdown-button" style="margin: 0 8px 8px 0" @click.stop="handleClickBtn">
23
+ <a-icon v-if="spinning" type="loading" style="line-height: 10px" />
24
+ {{ btnText }}
25
+ <a-icon type="down" />
26
+ </a-button>
27
+ </slot>
28
+ </a-dropdown>
29
+
30
+ <IdentityVerification
31
+ :printConfig="printConfig"
32
+ :baseUrl="baseUrl"
33
+ :verifyUserUrl="verifyUserUrl"
34
+ :visible.sync="identityVerification.visible"
35
+ :identityVerificationTitle="identityVerificationTitle"
36
+ :authorizationKey="authorizationKey"
37
+ @success="verifiySuccess"
38
+ ></IdentityVerification>
39
+ </span>
40
+ </template>
41
+ <script>
42
+ /**
43
+ * @author ruanlin
44
+ * @desc 全继承antd按钮组件,后期再扩展
45
+ * @time 2021-06-08
46
+ */
47
+
48
+ let printInstance = null;
49
+ let httpFn = null;
50
+ import Print from './js/print.es.min';
51
+ import IdentityVerification from './components/IdentityVerification';
52
+ import Clickoutside from '@/utils/clickoutside';
53
+ import Vue from 'vue';
54
+ import { Button, Dropdown, Menu, Icon } from 'ant-design-vue';
55
+ import create from '@/core/create';
56
+ import axios from 'axios';
57
+ import moment from 'moment';
58
+ import vexutils from '@/utils/vexutils';
59
+
60
+ export default create({
61
+ name: 'button-print',
62
+ components: {
63
+ IdentityVerification
64
+ },
65
+ directives: { Clickoutside },
66
+ props: {
67
+ baseUrl: {
68
+ type: String
69
+ },
70
+ /* */
71
+ btnText: {
72
+ type: String,
73
+ default: '打印'
74
+ },
75
+ printText: {
76
+ type: String,
77
+ default: '直接打印'
78
+ },
79
+ previewText: {
80
+ type: String,
81
+ default: '打印预览'
82
+ },
83
+ formatEditText: {
84
+ type: String,
85
+ default: '格式编辑'
86
+ },
87
+ identityVerificationTitle: {
88
+ type: String,
89
+ default: '打印服务身份校验'
90
+ },
91
+ /* */
92
+ authorizationKey: {
93
+ type: String,
94
+ require: true
95
+ },
96
+ templateNumber: {
97
+ type: [Number, String],
98
+ require: true
99
+ },
100
+ /* 格式化打印参数,需的原始数据 */
101
+ params: {
102
+ type: Array
103
+ },
104
+ hisParams: {
105
+ type: Object
106
+ },
107
+ /* */
108
+ prevFn: {
109
+ type: Function,
110
+ default() {
111
+ return Promise.resolve();
112
+ }
113
+ },
114
+ /** */
115
+ verifyUserUrl: {
116
+ type: String,
117
+ default: '/verifyUser'
118
+ },
119
+ /** */
120
+ getPrintFormatByNumberUrl: {
121
+ type: String,
122
+ default: '/getPrintFormatByNumber'
123
+ },
124
+ /** */
125
+ getTemplateParamsUrl: {
126
+ type: String,
127
+ default: '/getTemplateParams'
128
+ },
129
+ /* 打印策略,默认多条打印 */
130
+ strategy: {
131
+ type: String,
132
+ default: 'MULTI'
133
+ },
134
+ printConfig: {
135
+ type: Object,
136
+ default: () => ({})
137
+ },
138
+ // 1 为his老版,2 为新版 3为his更老版本
139
+ versionType: { type: [Number, String], default: '2' }
140
+ },
141
+ computed: {
142
+ currentFormatItem() {
143
+ if (!this.currentFormatId) return {};
144
+ let id = this.currentFormatId;
145
+ return this.formatList.find(item => item.id === id);
146
+ },
147
+ formatTitle() {
148
+ return this.currentFormatItem?.name || '格式选择';
149
+ }
150
+ },
151
+ data() {
152
+ return {
153
+ spinning: false,
154
+ visible: false,
155
+ formatList: [],
156
+ templateParams: {},
157
+ printParams: [],
158
+ currentFormatId: '',
159
+ /* */
160
+ identityVerification: {
161
+ visible: false
162
+ },
163
+ isInited: false,
164
+ watchPrintParamsReformatFn: null,
165
+ spinTimer: null
166
+ };
167
+ },
168
+ beforeCreate() {
169
+ Vue.use(Button).use(Dropdown).use(Menu).use(Icon);
170
+ },
171
+ mounted() {
172
+ this.isInited = false;
173
+ },
174
+ beforeDestroy() {
175
+ // 创建Print实例的时候会在webview中注册一个事件, 需要调用printInstance.destroy()手动清除
176
+ printInstance?.destroy?.()
177
+ },
178
+ watch: {
179
+ // 监听变化, 重新格式化printParams
180
+ params: {
181
+ deep: true,
182
+ handler(val) {
183
+ if (!val?.length) return false;
184
+ this.reformatPrintParams();
185
+ }
186
+ }
187
+ },
188
+ methods: {
189
+ // getPopupContainer(triggerNode) {
190
+ // return triggerNode.parentNode;
191
+ // },
192
+ handleClickOutside() {
193
+ this.visible = false;
194
+ },
195
+ handleClickWrap() {
196
+ setTimeout(() => {
197
+ this.visible = true;
198
+ }, 0);
199
+ },
200
+ /* */
201
+ async handleClickBtn() {
202
+ if (!this.visible) {
203
+ let result = await this.init();
204
+ if (!result) return false;
205
+ }
206
+
207
+ this.visible = !this.visible;
208
+ },
209
+ /* */
210
+ async init() {
211
+ if (this.isInited) return true;
212
+ this.isInited = true;
213
+
214
+ this.setTimeoutSpin();
215
+
216
+ this.instantiatePrintSDK();
217
+ let config = {
218
+ withCredentials: false,
219
+ timeout: 5000
220
+ };
221
+ let printUrlPrefix = this?.printConfig?.printUrlPrefix;
222
+ let customCofing = this?.printConfig?.customCofing || {};
223
+ let cCofing = this.getCustomCofing(customCofing);
224
+ if (axios !== this.axios && printUrlPrefix) {
225
+ config.baseURL = printUrlPrefix;
226
+ }
227
+ httpFn = axios.create({
228
+ ...config,
229
+ ...cCofing
230
+ });
231
+ const formatListResult = await this.queryFormatList();
232
+ if (this.versionType == 1 || this.versionType == 3) {
233
+ this.initHIS(formatListResult);
234
+ } else {
235
+ await this.initCRM(formatListResult);
236
+ }
237
+
238
+ this.setLoaded();
239
+
240
+ return true;
241
+ },
242
+ initHIS(formatListResult) {
243
+ this.formatList = formatListResult ? formatListResult.list.filter(item => item.printmark == 1) : [];
244
+ this.currentFormatId = this.getDefaultFormatId(this.formatList, 'printmark');
245
+ this.templateParams = this.formatList[0] || {};
246
+ },
247
+ async initCRM(formatListResult) {
248
+ this.formatList = formatListResult ? this.formatFormatList(formatListResult.obj) : [];
249
+ this.currentFormatId = this.getDefaultFormatId(this.formatList, 'defaultFlag');
250
+
251
+ if (!this.currentFormatId) {
252
+ this.$message.error('获取打印格式失败,请联系管理员!');
253
+ return this.requestError();
254
+ }
255
+ if (!this.currentFormatId) {
256
+ this.requestError();
257
+ return;
258
+ }
259
+ let templateParamsResult = await this.queryTemplateParams();
260
+
261
+ if (templateParamsResult) {
262
+ this.templateParams = templateParamsResult;
263
+ } else {
264
+ return this.requestError();
265
+ }
266
+
267
+ this.printParams = this.formatParams(this.templateParams, this.params);
268
+ },
269
+ setTimeoutSpin() {
270
+ this.spinTimer = setTimeout(() => {
271
+ this.spinning = true;
272
+ }, 1500);
273
+ },
274
+ setLoaded() {
275
+ this.spinning = false;
276
+ if (!this.spinTimer) return false;
277
+ clearTimeout(this.spinTimer);
278
+ this.spinTimer = null;
279
+ },
280
+ requestError() {
281
+ this.isInited = false;
282
+ this.setLoaded();
283
+ setTimeout(() => {
284
+ this.visible = false;
285
+ }, 0);
286
+
287
+ return false;
288
+ },
289
+ getDefaultFormatId(list, key) {
290
+ if (!list?.length) return '';
291
+ let findDefault = list.find(item => item[key] == 1);
292
+ return findDefault?.id || list[0].id;
293
+ },
294
+ /* */
295
+ instantiatePrintSDK() {
296
+ if (printInstance) return false;
297
+ printInstance = new Print();
298
+ },
299
+ /* */
300
+ queryFormatList() {
301
+ const { templateNumber, authorizationKey, baseUrl, getPrintFormatByNumberUrl, versionType } = this;
302
+ const suffix = [1, 3].includes(versionType) ? `jsessionids=${vexutils.cookie.get('jsessionids') || '31e5fc0e-955f-4c89-9679-39c43d0171321636163291241'}` : `authorizationKey=${authorizationKey}`;
303
+ const url = `${baseUrl}${getPrintFormatByNumberUrl}?number=${templateNumber}&${suffix}`;
304
+ return httpFn
305
+ .get(url)
306
+ .then(async ({ data }) => {
307
+ if (data.result !== 'SUCCESS') {
308
+ this.$message.error(data.resultMsg || '参数异常,请联系管理员');
309
+ return false;
310
+ }
311
+ return data;
312
+ })
313
+ .catch(e => {
314
+ return false;
315
+ });
316
+ },
317
+ formatFormatList(list) {
318
+ let formatList = [];
319
+
320
+ list.forEach(item => {
321
+ if (!item.format) return false;
322
+ formatList.push(...item.format);
323
+ });
324
+
325
+ return formatList;
326
+ },
327
+ /* */
328
+ queryTemplateParams() {
329
+ const { templateNumber, authorizationKey, baseUrl, getTemplateParamsUrl } = this;
330
+ const { templateId } = this.formatList[0] || {};
331
+ const url = `${baseUrl}${getTemplateParamsUrl}?number=${templateNumber}&templateId=${templateId}&authorizationKey=${authorizationKey}`;
332
+
333
+ return httpFn
334
+ .get(url)
335
+ .then(async ({ data }) => {
336
+ if (data.result !== 'SUCCESS') {
337
+ this.$message.error(data.resultMsg || '参数异常,请联系管理员');
338
+ return false;
339
+ }
340
+ return data?.obj || {};
341
+ })
342
+ .catch(e => {
343
+ return false;
344
+ });
345
+ },
346
+ formatDefaultVal(i, tableVal) {
347
+ let val = i.defaultValue || '';
348
+ let tVal = tableVal;
349
+ if (i.type === 'NUMBER') {
350
+ tVal = Number(tableVal) || 0;
351
+ }
352
+ if (i.type === 'DATE') {
353
+ tVal = tableVal ? moment(tableVal).format('YYYY-MM-DD') : '';
354
+ }
355
+ if (i.type === 'DATETIME') {
356
+ tVal = tableVal ? moment(tableVal).format('YYYY-MM-DD HH:mm:ss') : '';
357
+ }
358
+
359
+ return val ? val : tVal;
360
+ },
361
+ formatParams({ customizeDataset = [], param = [] }, params = []) {
362
+ return params.map(paramObj => {
363
+ let res = {};
364
+
365
+ // 自定义结果集
366
+ customizeDataset.forEach(dataSetItem => {
367
+ const selectFieldList = dataSetItem.dataSetting[0].selectFieldList;
368
+ res['datasetData'] = {
369
+ [dataSetItem.name]: JSON.stringify(this.formatPrintParams(paramObj, selectFieldList, 'fieldName'))
370
+ };
371
+ });
372
+
373
+ // 参数
374
+ res = Object.assign({}, res, this.formatPrintParams(paramObj, param, 'key'));
375
+ return res;
376
+ });
377
+ },
378
+ reformatPrintParams() {
379
+ this.watchPrintParamsReformatFn && this.watchPrintParamsReformatFn();
380
+ /*
381
+ 还没初始化完毕时(还没获取到模板格式配置等..)
382
+ 触发再格式化逻辑,需等待初始化完毕,再重新执行格式化
383
+ */
384
+ if (!this.isInited) {
385
+ this.watchPrintParamsReformatFn = this.$watch('isInited', val => {
386
+ if (!val) return false;
387
+ this.reformatPrintParams();
388
+ });
389
+ return;
390
+ }
391
+
392
+ this.printParams = this.formatParams(this.templateParams, this.params);
393
+ },
394
+ formatPrintParams(paramObj, fieldList, keyName) {
395
+ const obj = {};
396
+ fieldList.forEach(i => {
397
+ let defaultVal = this.formatDefaultVal(i, paramObj[i[keyName]]);
398
+ if (paramObj[i[keyName]] && defaultVal) {
399
+ obj[i[keyName]] = defaultVal;
400
+ }
401
+ });
402
+
403
+ return obj;
404
+ },
405
+ /* */
406
+ handleClickFormat(id) {
407
+ this.currentFormatId = id;
408
+ },
409
+ /* */
410
+ getPrintParams(index = 0) {
411
+ const params = this.printParams[index];
412
+ return JSON.stringify(params);
413
+ },
414
+ getTemplateIdByFormatId(id) {
415
+ let find = this.formatList.find(item => item.id === id);
416
+ return find.templateId;
417
+ },
418
+ getOnceParams() {
419
+ // 聚合一条
420
+ let params = {};
421
+ let obj = {};
422
+ if (this.templateParams?.customizeDataset?.length) {
423
+ // 有模板数据
424
+ const key = Object.keys(this.printParams[0]?.datasetData || {})?.[0] || '';
425
+ const datasetDataKeyVal = JSON.stringify(this.printParams.map(v => JSON.parse(v.datasetData[key])));
426
+ obj = {
427
+ datasetData: {}
428
+ };
429
+ obj.datasetData[key] = datasetDataKeyVal;
430
+ } else {
431
+ // 无模板数据
432
+ Object.keys(this.printParams[0]).forEach(v => {
433
+ obj[v] = [];
434
+ this.printParams.forEach(k => {
435
+ obj[v].push(k[v]);
436
+ });
437
+ obj[v] = obj[v].join(',');
438
+ });
439
+ }
440
+ params = Object.assign({}, JSON.parse(this.getPrintParams(0)), obj);
441
+ return JSON.stringify(params);
442
+ },
443
+ handleClickPrint(e) {
444
+ e.domEvent.stopPropagation();
445
+ let len = this.printParams.length;
446
+ const callLocalServicesSuccessCb = async data => {
447
+ try {
448
+ if (--len <= 0) {
449
+ this.callLocalServicesSuccessCb(data, 'print');
450
+ }
451
+ } catch (error) {
452
+ console.log('error', error);
453
+ }
454
+ };
455
+
456
+ this.prevFn()
457
+ .catch(() => {
458
+ this.prevFnError();
459
+ return Promise.reject();
460
+ })
461
+ .then(() => {
462
+ if (this.versionType == 1 || this.versionType == 3) {
463
+ const printFn = this.versionType == 1 ? 'handleHisPrint' : 'handleOldHisPrint'
464
+ if (this.strategy === 'MULTI') {
465
+ for (let i = 0; i < this.params.length; i++) {
466
+ const params = this.getHisParams(i);
467
+ printInstance[printFn](7, params)
468
+ .then(res => {
469
+ console.log(res, '777777777777');
470
+ })
471
+ .catch(error => {
472
+ console.log(error, 'error777');
473
+ });
474
+ }
475
+ } else {
476
+ const params = this.getOnceHisParams();
477
+ printInstance[printFn](7, params)
478
+ .then(res => {
479
+ console.log(res, '777777777777');
480
+ })
481
+ .catch(error => {
482
+ console.log(error, 'error777');
483
+ });
484
+ }
485
+ } else {
486
+ if (this.strategy === 'MULTI') {
487
+ // 循环多条
488
+ for (let i = 0; i < this.printParams.length; i++) {
489
+ const queryParams = {
490
+ formatId: this.currentFormatId,
491
+ templateId: this.getTemplateIdByFormatId(this.currentFormatId),
492
+ params: this.getPrintParams(i)
493
+ };
494
+ printInstance.printDirect(queryParams, callLocalServicesSuccessCb, this.callLocalServicesErrorCb);
495
+ }
496
+ } else {
497
+ // 聚合一条
498
+ const queryParams = {
499
+ formatId: this.currentFormatId,
500
+ templateId: this.getTemplateIdByFormatId(this.currentFormatId),
501
+ params: this.getOnceParams()
502
+ };
503
+ printInstance.printDirect(
504
+ queryParams,
505
+ res => {
506
+ this.callLocalServicesSuccessCb(res, 'print');
507
+ },
508
+ this.callLocalServicesErrorCb
509
+ );
510
+ }
511
+ }
512
+ })
513
+ .finally(() => {
514
+ this.visible = false;
515
+ });
516
+ },
517
+ getHisParams(index = 0) {
518
+ const { templateParams, hisParams, params } = this;
519
+ const { reportid = '280' } = hisParams;
520
+ const { id, name } = templateParams;
521
+ return {
522
+ reportid,
523
+ formatid: this.currentFormatId || id,
524
+ formatname: name,
525
+ param: params[index]
526
+ };
527
+ },
528
+ getOnceHisParams() {
529
+ const { templateParams, hisParams, params } = this;
530
+ const { reportid = '280' } = hisParams;
531
+ const { id, name } = templateParams;
532
+ const obj = {}
533
+ Object.keys(params[0]).forEach(v => {
534
+ obj[v] = [];
535
+ params.forEach(k => {
536
+ obj[v].push(k[v]);
537
+ });
538
+ obj[v] = obj[v].join(',');
539
+ });
540
+ return {
541
+ reportid,
542
+ formatid: this.currentFormatId || id,
543
+ formatname: name,
544
+ param: obj
545
+ };
546
+ },
547
+ async handleClickPreview(e) {
548
+ e.domEvent.stopPropagation();
549
+
550
+ this.prevFn()
551
+ .catch(() => {
552
+ this.prevFnError();
553
+ return Promise.reject();
554
+ })
555
+ .then(() => {
556
+ if (this.versionType == 1 || this.versionType == 3) {
557
+ const params = this.strategy === 'MULTI' ? this.getHisParams() : this.getOnceHisParams();
558
+ const printFn = this.versionType == 1 ? 'handleHisPrint' : 'handleOldHisPrint'
559
+ printInstance[printFn](8, params)
560
+ .then(res => {
561
+ console.log(res, 88888888);
562
+ })
563
+ .catch(error => {
564
+ console.log(error, 'error888');
565
+ });
566
+ } else {
567
+ const IS_MULTI = this.strategy === 'MULTI';
568
+ if(IS_MULTI){
569
+ // 循环多条
570
+ for (let i = 0; i < this.printParams.length; i++) {
571
+ const queryParams = {
572
+ formatId: this.currentFormatId,
573
+ templateId: this.getTemplateIdByFormatId(this.currentFormatId),
574
+ params: this.getPrintParams(i)
575
+ };
576
+ printInstance.preview(
577
+ queryParams,
578
+ res => {
579
+ this.callLocalServicesSuccessCb(res, 'preview');
580
+ },
581
+ this.callLocalServicesErrorCb
582
+ );
583
+ }
584
+ } else {
585
+ const queryParams = {
586
+ formatId: this.currentFormatId,
587
+ templateId: this.getTemplateIdByFormatId(this.currentFormatId),
588
+ params: this.getOnceParams()
589
+ };
590
+ printInstance.preview(
591
+ queryParams,
592
+ res => {
593
+ this.callLocalServicesSuccessCb(res, 'preview');
594
+ },
595
+ this.callLocalServicesErrorCb
596
+ );
597
+ }
598
+ }
599
+ })
600
+ .finally(() => {
601
+ this.visible = false;
602
+ });
603
+ },
604
+ handleClickEdit(e) {
605
+ e.domEvent.stopPropagation();
606
+
607
+ this.prevFn()
608
+ .catch(() => {
609
+ this.prevFnError();
610
+ return Promise.reject();
611
+ })
612
+ .then(() => {
613
+ if (this.versionType == 1 || this.versionType == 3) {
614
+ const params = this.strategy === 'MULTI' ? this.getHisParams() : this.getOnceHisParams();
615
+ const printFn = this.versionType == 1 ? 'handleHisPrint' : 'handleOldHisPrint'
616
+ printInstance[printFn](9, params)
617
+ .then(res => {
618
+ console.log(res, 999999);
619
+ })
620
+ .catch(error => {
621
+ console.log(error, 'error999');
622
+ });
623
+ } else {
624
+ this.identityVerification.visible = true;
625
+ }
626
+ })
627
+ .finally(() => {
628
+ this.visible = false;
629
+ });
630
+ },
631
+ verifiySuccess(token) {
632
+ this.identityVerification.visible = false;
633
+
634
+ const queryParams = {
635
+ formatId: this.currentFormatId,
636
+ templateId: this.getTemplateIdByFormatId(this.currentFormatId),
637
+ params: this.getPrintParams(),
638
+ token
639
+ };
640
+ printInstance.editPrintFormat(
641
+ queryParams,
642
+ res => {
643
+ this.callLocalServicesSuccessCb(res, 'edit');
644
+ },
645
+ this.callLocalServicesErrorCb
646
+ );
647
+ },
648
+ /* */
649
+ prevFnError() {
650
+ // 前置条件执行错误这里不弹提示,“前置条件”事件内有弹提示了
651
+ // let error = {
652
+ // message: '前置条件执行错误'
653
+ // };
654
+ // this.$emit('error', error);
655
+ },
656
+ /* */
657
+ callLocalServicesSuccessCb(res, type) {
658
+ let info = {
659
+ type,
660
+ formatId: this.currentFormatId,
661
+ templateId: this.getTemplateIdByFormatId(this.currentFormatId)
662
+ };
663
+ this.$emit('success', res, info);
664
+ },
665
+ callLocalServicesErrorCb(res) {
666
+ this.$emit('error', res);
667
+ },
668
+
669
+ /**
670
+ * 获取 axios 自定义配置
671
+ */
672
+ getCustomCofing(customCofing){
673
+ let cCofing = {}
674
+ let type = typeof customCofing;
675
+ if(type === 'function'){
676
+ cCofing = customCofing();
677
+ } else if(type === 'object'){
678
+ cCofing = customCofing;
679
+ }
680
+ return cCofing;
681
+ }
682
+ }
683
+ });
684
+ </script>
685
+
686
+ <style lang="less" scoped>
687
+ .dropdown-button {
688
+ color: #212121;
689
+ border-color: #d5d5d5 !important;
690
+ margin-left: 8px;
691
+ margin-bottom: 8px;
692
+ /deep/ .svg-icon {
693
+ margin-right: 4px;
694
+ }
695
+ &.ant-dropdown-trigger {
696
+ i.anticon.anticon-down {
697
+ color: #969696;
698
+ font-size: 14px;
699
+ }
700
+ }
701
+ }
702
+ </style>
703
+
704
+ <style lang="less">
705
+ .rowFoldHideBtnList-dropdown {
706
+ min-width: 150px !important;
707
+ .ant-dropdown-menu {
708
+ overflow-y: auto;
709
+ max-height: 99vh;
710
+ }
711
+ .ant-dropdown-menu-item-group {
712
+ .ant-dropdown-menu-item-group-title {
713
+ display: none;
714
+ }
715
+ border-bottom: 1px solid #d5d5d5;
716
+ &:last-child {
717
+ border-color: transparent;
718
+ }
719
+ }
720
+ .format-name .ant-dropdown-menu-submenu-title {
721
+ font-weight: bold;
722
+ color: #000;
723
+ }
724
+ .ant-dropdown-menu-item.active {
725
+ color: #5585f5;
726
+ }
727
+ }
728
+ </style>