cnhis-design-vue 2.1.141 → 2.1.143

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 (53) hide show
  1. package/CHANGELOG.md +51 -34
  2. package/es/age/index.js +2 -2
  3. package/es/big-table/index.js +152 -112
  4. package/es/big-table/style.css +1 -1
  5. package/es/button/index.js +2395 -253
  6. package/es/button/style.css +1 -1
  7. package/es/captcha/index.js +3 -3
  8. package/es/card-reader-sdk/index.js +1 -1
  9. package/es/checkbox/index.js +1 -1
  10. package/es/color-picker/index.js +1 -1
  11. package/es/drag-layout/index.js +3 -3
  12. package/es/editor/index.js +1 -1
  13. package/es/ellipsis/index.js +1 -1
  14. package/es/fabric-chart/index.js +17 -16
  15. package/es/form-table/index.js +20 -20
  16. package/es/full-calendar/index.js +4 -4
  17. package/es/index/index.js +2509 -365
  18. package/es/index/style.css +1 -1
  19. package/es/input/index.js +1 -1
  20. package/es/map/index.js +1 -1
  21. package/es/multi-chat/index.js +25 -25
  22. package/es/multi-chat-client/index.js +19 -19
  23. package/es/multi-chat-history/index.js +4 -4
  24. package/es/multi-chat-record/index.js +4 -4
  25. package/es/multi-chat-setting/index.js +20 -20
  26. package/es/multi-chat-sip/index.js +1 -1
  27. package/es/radio/index.js +1 -1
  28. package/es/scale-container/index.js +1 -1
  29. package/es/scale-view/index.js +27 -27
  30. package/es/select/index.js +4 -4
  31. package/es/select-label/index.js +3 -3
  32. package/es/select-person/index.js +23 -20
  33. package/es/select-person/style.css +1 -1
  34. package/es/select-tag/index.js +4 -4
  35. package/es/shortcut-setter/index.js +2 -2
  36. package/es/slider-tree/index.js +1 -1
  37. package/es/table-filter/index.js +2225 -97
  38. package/es/table-filter/style.css +1 -1
  39. package/es/tag/index.js +1 -1
  40. package/es/verification-code/index.js +2 -2
  41. package/lib/cui.common.js +2753 -580
  42. package/lib/cui.umd.js +2753 -580
  43. package/lib/cui.umd.min.js +66 -66
  44. package/package.json +1 -1
  45. package/packages/big-table/src/BigTable.vue +5 -4
  46. package/packages/big-table/src/utils/headerFilter.js +54 -18
  47. package/packages/button/src/ButtonPrint/index.vue +27 -691
  48. package/packages/button/src/ButtonPrint/js/print.es.min.js +1 -1
  49. package/packages/button/src/ButtonPrint/js/print.es.min1.js +1 -1
  50. package/packages/button/src/ButtonPrint/new.vue +1438 -0
  51. package/packages/button/src/ButtonPrint/old.vue +809 -0
  52. package/packages/fabric-chart/src/fabric-chart/FabricTextGroup.vue +4 -3
  53. package/packages/select-person/select-person.vue +3 -0
@@ -0,0 +1,1438 @@
1
+ <template>
2
+ <div class="newprint-all-buttons">
3
+ <div class="newprint-button-outer" id='newprint-button-outer' v-clickoutside="handleAllClickOutside">
4
+ <!-- 外部按钮集合 -->
5
+ <a-button-group>
6
+ <a-dropdown
7
+ v-for="outer in outerPrintItems"
8
+ :key="outer.key"
9
+ class="c-dropdown"
10
+ :trigger="dropOuter"
11
+ >
12
+ <a-button
13
+ :disabled="!printParams[outer.templateCode]"
14
+ :loading="outer.isLoading"
15
+ @click="handleOneTypePrint(outer.templateCode, outer.templateId, outer.key, true)"
16
+ >
17
+ {{ outer.label }}
18
+ <a-icon type="down" />
19
+ </a-button>
20
+ <template #overlay>
21
+ <a-menu>
22
+ <a-menu-item
23
+ v-for="operation in operations"
24
+ :key="operation.key"
25
+ @click="handleSelect(operation.key, outer)"
26
+ >
27
+ <span class="label" >{{ operation.label }}</span>
28
+ </a-menu-item>
29
+ </a-menu>
30
+ </template>
31
+ </a-dropdown>
32
+ </a-button-group>
33
+
34
+ <!-- 外显设置按钮 -->
35
+ <a-dropdown
36
+ v-if="outerPrintItems.length > 0 && outerPrintItems.length == options.length && isShowOutSettingBtn"
37
+ overlayClassName="newprint-button-menu"
38
+ :getPopupContainer="getPopupContainerNode"
39
+ id="dropdown-outer-setting-btn"
40
+ :visible="outSettingVisible"
41
+ :trigger="dropOperation"
42
+ >
43
+ <a-button @click="showSettingVisible('outSettingVisible')">
44
+ 外显设置
45
+ <a-icon type="setting" />
46
+ </a-button>
47
+ <a-menu slot="overlay">
48
+ <a-menu-item
49
+ v-for="sItem in options"
50
+ :key="sItem.key"
51
+ class="dropdown-between"
52
+ style="padding: 0 12px;"
53
+ >
54
+ <span class="label bold">{{ sItem.label }}</span>
55
+ <a-checkbox :checked="sItem.selected" @change="onSettingChange(sItem)">外显</a-checkbox>
56
+ </a-menu-item>
57
+ <a-menu-item class="print-divider"><a-divider /></a-menu-item>
58
+ <a-menu-item class="dropdown-between" style="padding: 0 12px;">
59
+ <a-button type="primary" size="small" @click="savePrintOutSetting('outSettingVisible')">保存</a-button>
60
+ <a-checkbox v-if="options && options.length > 1" :checked="isSelectedAll" @change="onSelectedAllChange">全选</a-checkbox>
61
+ </a-menu-item>
62
+ </a-menu>
63
+ </a-dropdown>
64
+
65
+ <!-- 打印全部按钮 -->
66
+ <a-button-group v-else>
67
+ <a-button :loading="this.spinning" @click.stop="printAllButtonClick">{{ isShowPrintAllBtn ? '打印全部' : btnText }}</a-button>
68
+ <a-dropdown :visible="visible" :getPopupContainer="getPopupContainerNode" overlayClassName="newprint-button-menu" :trigger="dropOperation">
69
+ <a-button
70
+ @click.stop="handleClickBtn"><a-icon type="down"/></a-button>
71
+ <a-menu slot="overlay">
72
+ <a-menu-item
73
+ class="dropdown-between"
74
+ v-for="option in innerPrintItems"
75
+ :key="option.key"
76
+ >
77
+ <span class="label bold" :class="!printParams[option.templateCode] ? 'isDisabled' : ''" @click="handleOneTypePrint(option.templateCode, option.templateId, option.key, true)"><a-icon type="loading" v-if="option.isLoading" style="margin-right: 6px;"/>{{ option.label }} </span>
78
+ <a-dropdown :trigger="dropOperation">
79
+ <a-button style="margin-left: 8px;" size="small"><a-icon type="right" /></a-button>
80
+ <a-menu slot="overlay">
81
+ <a-menu-item
82
+ v-for="operation in operations"
83
+ :key="operation.key"
84
+ @click="handleSelect(operation.key, option)"
85
+ >
86
+ <span class="label">{{ operation.label }}</span>
87
+ </a-menu-item>
88
+ </a-menu>
89
+ </a-dropdown>
90
+ </a-menu-item>
91
+ <!-- 分割线 -->
92
+ <a-menu-item v-if="isShowOutSettingBtn" class="print-divider"><a-divider /></a-menu-item>
93
+ <!-- 外显设置 -->
94
+ <a-menu-item v-if="isShowOutSettingBtn">
95
+ <a-dropdown :visible="innerSettingVisible" :trigger="dropOperation" :getPopupContainer="getPopupContainerNode" overlayClassName="newprint-button-menu">
96
+ <div style="width: 100%;display: flex;justify-content: space-between;align-items: center;" @click="showSettingVisible('innerSettingVisible')">
97
+ <span class="label bold">外显设置 </span>
98
+ <a-icon type="setting" />
99
+ </div>
100
+ <a-menu slot="overlay">
101
+ <a-menu-item
102
+ class="dropdown-between"
103
+ style="padding: 0 12px;"
104
+ v-for="sItem in options"
105
+ :key="sItem.key"
106
+ >
107
+ <span class="label bold"> {{ sItem.label }} </span>
108
+ <a-checkbox :checked="sItem.selected" @change="onSettingChange(sItem)">外显</a-checkbox>
109
+ </a-menu-item>
110
+ <!-- 分割线 -->
111
+ <a-menu-item class="print-divider"><a-divider /></a-menu-item>
112
+ <a-menu-item class="dropdown-between" style="padding: 0 12px;">
113
+ <a-button type="primary" @click="savePrintOutSetting('innerSettingVisible')">保存</a-button>
114
+ <a-checkbox v-if="options && options.length > 1" :checked="isSelectedAll" @change="onSelectedAllChange">全选</a-checkbox>
115
+ </a-menu-item>
116
+ </a-menu>
117
+ </a-dropdown>
118
+ </a-menu-item>
119
+ </a-menu>
120
+ </a-dropdown>
121
+ </a-button-group>
122
+
123
+
124
+ <IdentityVerification
125
+ :printConfig="printConfig"
126
+ :baseUrl="baseUrl"
127
+ :verifyUserUrl="verifyUserUrl"
128
+ :visible.sync="identityVerification.visible"
129
+ :identityVerificationTitle="identityVerificationTitle"
130
+ :authorizationKey="authorizationKey"
131
+ @success="verifiySuccess"
132
+ ></IdentityVerification>
133
+ </div>
134
+ </div>
135
+ </template>
136
+ <script>
137
+ /**
138
+ * @author ruanlin
139
+ * @desc 全继承antd按钮组件,后期再扩展
140
+ * @time 2021-06-08
141
+ */
142
+
143
+ let httpFn = null;
144
+ import Print from './js/print.es.min';
145
+ import IdentityVerification from './components/IdentityVerification';
146
+ import Clickoutside from '@/utils/clickoutside';
147
+ import Vue from 'vue';
148
+ import { Button, Dropdown, Menu, Icon, Divider, Checkbox, Popover } from 'ant-design-vue';
149
+ import create from '@/core/create';
150
+ import axios from 'axios';
151
+ import moment from 'moment';
152
+ import vexutils from '@/utils/vexutils';
153
+
154
+ export default create({
155
+ name: 'button-print',
156
+ components: {
157
+ IdentityVerification
158
+ },
159
+ directives: { Clickoutside },
160
+ props: {
161
+ baseUrl: {
162
+ type: String
163
+ },
164
+ /* */
165
+ btnText: {
166
+ type: String,
167
+ default: '打印'
168
+ },
169
+ printText: {
170
+ type: String,
171
+ default: '直接打印'
172
+ },
173
+ previewText: {
174
+ type: String,
175
+ default: '打印预览'
176
+ },
177
+ pdfLoadText: {
178
+ type: String,
179
+ default: '下载pdf'
180
+ },
181
+ formatEditText: {
182
+ type: String,
183
+ default: '格式编辑'
184
+ },
185
+ identityVerificationTitle: {
186
+ type: String,
187
+ default: '打印服务身份校验'
188
+ },
189
+ /* */
190
+ authorizationKey: {
191
+ type: String,
192
+ require: true
193
+ },
194
+ templateNumber: {
195
+ type: [Number, String],
196
+ require: true
197
+ },
198
+ /* 格式化打印参数,需的原始数据 */
199
+ params: {
200
+ type: Array
201
+ },
202
+ hisParams: {
203
+ type: Object
204
+ },
205
+ /* */
206
+ prevFn: {
207
+ type: Function,
208
+ default() {
209
+ return Promise.resolve();
210
+ }
211
+ },
212
+ /** */
213
+ verifyUserUrl: {
214
+ type: String,
215
+ default: '/verifyUser'
216
+ },
217
+ /** */
218
+ getPrintFormatByNumberUrl: {
219
+ type: String,
220
+ default: '/getPrintFormatByNumber'
221
+ },
222
+ /** */
223
+ getTemplateParamsUrl: {
224
+ type: String,
225
+ default: '/getTemplateParams'
226
+ },
227
+ /* 打印策略,默认多条打印 */
228
+ strategy: {
229
+ type: String,
230
+ default: 'MULTI'
231
+ },
232
+ printConfig: {
233
+ type: Object,
234
+ default: () => ({})
235
+ },
236
+ // 1 为his老版,2 为新版 3为his更老版本
237
+ versionType: { type: [Number, String], default: '2' },
238
+ // 用于获取用户信息的token
239
+ token: {
240
+ type: String,
241
+ default: ''
242
+ },
243
+ // 打印弹窗设置,1弹0不弹,默认不弹
244
+ printdlgshow: {
245
+ type: [String, Number],
246
+ default: '0'
247
+ },
248
+ // 没有模板提示
249
+ noformatTips: {
250
+ type: String,
251
+ default: ''
252
+ },
253
+
254
+ getOnceParamsAfter: {
255
+ type: Function
256
+ },
257
+
258
+ getPrintParamsAfter: {
259
+ type: Function
260
+ },
261
+ // 新版打印配置(新)
262
+ newPrintSetting: {
263
+ type: Object,
264
+ default: () => ({
265
+ // 是否显示打印全部
266
+ isShowPrintAll: true,
267
+ // 是否展示外显设置
268
+ isShowOutSetting: true,
269
+ // 打印自定义属性
270
+ customProps: {},
271
+ // 外显打印(formatId)值集合,用于初始化展示外显按钮
272
+ outerPrintKeys: [],
273
+ // 默认需要打印的格式(formatId)
274
+ defaultFormatId: ''
275
+ })
276
+ }
277
+ },
278
+ computed: {
279
+ currentFormatItem() {
280
+ if (!this.currentFormatId) return {};
281
+ let id = this.currentFormatId;
282
+ return this.formatList.find(item => item.id === id);
283
+ },
284
+ formatTitle() {
285
+ return this.currentFormatItem?.name || '格式选择';
286
+ },
287
+ printExtraParams() {
288
+ return this?.printConfig?.printExtraParams || {};
289
+ },
290
+ queryParams() {
291
+ return {
292
+ formatId: this.currentFormatId,
293
+ templateId: this.getTemplateIdByFormatId(this.currentFormatId)
294
+ };
295
+ },
296
+ // 是否展示全部打印按钮
297
+ isShowPrintAllBtn() {
298
+ return this.newPrintSetting?.isShowPrintAll;
299
+ },
300
+ // 是否展示外显设置
301
+ isShowOutSettingBtn() {
302
+ return this.newPrintSetting?.isShowOutSetting;
303
+ },
304
+ // 打印自定义属性
305
+ printCustomProps() {
306
+ return this.newPrintSetting?.customProps || {};
307
+ },
308
+ // 默认打印的formatId
309
+ defaultPrintFormatId() {
310
+ return this.newPrintSetting?.defaultFormatId || '';
311
+ },
312
+ isSelectedAll() {
313
+ return this.options.every(option => option.selected);
314
+ }
315
+ },
316
+ data() {
317
+ return {
318
+ spinning: false,
319
+ visible: false,
320
+ // 内部设置弹窗的展示状态
321
+ innerSettingVisible: false,
322
+ // 外部设置弹窗展示状态
323
+ outSettingVisible: false,
324
+ formatList: [],
325
+ templateParams: {},
326
+ // 打印参数汇总
327
+ printParams: [],
328
+ // 原始参数汇总
329
+ originParams: [],
330
+ currentFormatId: '',
331
+ /* */
332
+ identityVerification: {
333
+ visible: false
334
+ },
335
+ isInited: false,
336
+ watchPrintParamsReformatFn: null,
337
+ spinTimer: null,
338
+ printInstance: null,
339
+ dropOperation: ['click'],
340
+ dropOuter: ['hover'],
341
+ // 内显打印项
342
+ innerPrintItems: [],
343
+ // 外显打印项
344
+ outerPrintItems: [],
345
+ // 下拉数据
346
+ options: [],
347
+ // 操作按钮集合
348
+ operations: [
349
+ {
350
+ label: this.pdfLoadText, // 下载pdf
351
+ key: 'downloadPdf'
352
+ },
353
+ {
354
+ label: this.previewText, // 打印预览
355
+ key: 'previewText'
356
+ },
357
+ {
358
+ label: this.formatEditText, // 格式编辑
359
+ key: 'formatEditText'
360
+ },
361
+ {
362
+ label: '重置打印机', // 重置打印机
363
+ key: 'resetPrinter'
364
+ },
365
+ ],
366
+ // 当前打印参数列表
367
+ curPrintParamList: [],
368
+ // 当前是否为点击单个打印
369
+ isClickSinglePrint: false
370
+ }
371
+ },
372
+ beforeCreate() {
373
+ Vue.use(Button)
374
+ .use(Dropdown)
375
+ .use(Menu)
376
+ .use(Icon)
377
+ .use(Divider)
378
+ .use(Checkbox)
379
+ .use(Popover)
380
+ },
381
+ mounted() {
382
+ this.isInited = false;
383
+ },
384
+ beforeDestroy() {
385
+ // 创建Print实例的时候会在webview中注册一个事件, 需要调用printInstance.destroy()手动清除
386
+ this.printInstance?.destroy?.();
387
+ this.printInstance = null;
388
+ },
389
+ watch: {
390
+ // 监听变化, 重新格式化printParams
391
+ params: {
392
+ deep: true,
393
+ immediate: true,
394
+ handler(val) {
395
+ // if (!val?.length) return false;
396
+ const keys = Object.keys(this.templateParams);
397
+ if (keys?.length > 0) {
398
+ this.reformatPrintParams();
399
+ }
400
+ }
401
+ },
402
+ newPrintSetting: {
403
+ deep: true,
404
+ immediate: true,
405
+ async handler(val) {
406
+ const keys = val?.outerPrintKeys || [];
407
+ if (keys.length > 0) {
408
+ await this.handleClickBtn(false);
409
+ }
410
+ }
411
+ }
412
+ },
413
+ methods: {
414
+ getPopupContainerNode() {
415
+ const node = document.getElementById('newprint-button-outer');
416
+ return node;
417
+ },
418
+ // 重置所有的弹窗
419
+ handleAllClickOutside() {
420
+ this.outSettingVisible = this.innerSettingVisible = this.visible = false;
421
+ },
422
+ // 外显勾选
423
+ onSettingChange(sItem) {
424
+ sItem.selected = !sItem.selected;
425
+ },
426
+ // 勾选(取消勾选)全部
427
+ onSelectedAllChange(e) {
428
+ const isChecked = e.target.checked;
429
+ this.options.forEach(option => {
430
+ option.selected = isChecked;
431
+ })
432
+ },
433
+ async printAllButtonClick() {
434
+ // 如果显示打印全部按钮,直接打印全部;否则如果配置了默认格式,则打印默认格式,否则直接下拉
435
+ this.isShowPrintAllBtn ? await this.directPrint() : this.defaultPrintFormatId ? await this.directDefaultFormatPrint(this.defaultPrintFormatId) : await this.handleClickBtn();
436
+ },
437
+ // 打印全部
438
+ async directPrint() {
439
+ await this.handleClickBtn(false);
440
+ this.handleClickPrintAll();
441
+ },
442
+ // 打印全部
443
+ handleClickPrintAll() {
444
+ const templateNumbers = Object.keys(this.printParams);
445
+ this.isClickSinglePrint = false;
446
+ const originParamsClone = this.originParams;
447
+ for (let i = 0; i < templateNumbers.length; i++) {
448
+ const templateCode = templateNumbers[i];
449
+ const tmpParam = this.printParams[templateCode];
450
+ const printToParam = originParamsClone[templateCode] || [];
451
+ // 一个templateCode可能会对应多个类型
452
+ const formatTypeList = this.formatList.filter((format) => format.number == templateCode);
453
+ if (formatTypeList && formatTypeList.length > 0) {
454
+ formatTypeList.forEach(format => {
455
+ this.currentFormatId = format.id;
456
+ this.handleClickPrint(tmpParam, format.number, format.templateId, format.id, printToParam, true);
457
+ })
458
+ }
459
+ }
460
+ },
461
+ // 打印默认模板格式
462
+ async directDefaultFormatPrint(defaultFormatId) {
463
+ await this.handleClickBtn(false);
464
+ const curFormat = this.innerPrintItems.find(option => option.key == defaultFormatId);
465
+ if (curFormat) {
466
+ this.handleOneTypePrint(curFormat.templateCode, curFormat.templateId, curFormat.key, false);
467
+ }
468
+ },
469
+ // 点击某类型打印
470
+ handleOneTypePrint(templateCode, templateId, formatId, isSingleClick) {
471
+ const tmpParam = this.printParams[templateCode];
472
+ // 当前模板下没有传入打印的数据
473
+ if (!tmpParam) return;
474
+ this.isClickSinglePrint = isSingleClick;
475
+ this.currentFormatId = formatId;
476
+ const printToParam = this.originParams[templateCode] || [];
477
+ this.handleClickPrint(tmpParam, templateCode, templateId, formatId, printToParam);
478
+ },
479
+ showSettingVisible(key) {
480
+ this[key] = true;
481
+ },
482
+ // 修改设置
483
+ savePrintOutSetting(key) {
484
+ this.visible = false;
485
+ this[key] = false;
486
+ this.innerPrintItems = this.options.filter(option => !option.selected);
487
+ this.outerPrintItems = this.options.filter(option => option.selected);
488
+ this.$emit('saveOuterPrint', this.outerPrintItems);
489
+ },
490
+ handleSelect(type, { templateCode, templateId, key }) {
491
+ const tmpParam = this.printParams[templateCode];
492
+ // 当前模板下没有传入打印的数据
493
+ if (!tmpParam) return;
494
+ this.isClickSinglePrint = true;
495
+ this.currentFormatId = key;
496
+ switch (type) {
497
+ // 打印预览
498
+ case 'previewText':
499
+ this.handleClickPreview(tmpParam, templateCode, templateId, key);
500
+ break;
501
+ // 格式编辑
502
+ case 'formatEditText':
503
+ this.handleClickEdit(tmpParam, templateCode, templateId, key);
504
+ break;
505
+ // 下载pdf
506
+ case 'downloadPdf':
507
+ this.handleClickPdf(tmpParam, templateCode, templateId, key);
508
+ break;
509
+ // 重置打印机
510
+ case 'resetPrinter':
511
+ this.handleResetPrinter(tmpParam, templateCode, templateId, key);
512
+ break;
513
+ default:
514
+ break;
515
+ }
516
+ },
517
+ // 重置打印机
518
+ async handleResetPrinter(curPrintParamList=[], templateCode, templateId, formatId) {
519
+ if (this.getCurrentLoading()) return;
520
+ this.toggleExpandLoading(true, formatId);
521
+ const data = await this.printInstance.resetPrinter(formatId);
522
+ this.toggleExpandLoading(false);
523
+ if (data?.result == 'success') {
524
+ this.$message.success(data.message || '重置打印机成功');
525
+ return;
526
+ }
527
+ this.$message.warning('重置打印机失败');
528
+ },
529
+ /* */
530
+ async handleClickBtn(visible = true) {
531
+ if (!this.visible) {
532
+ let result = await this.init();
533
+ if (!result) return false;
534
+ }
535
+ if (visible) {
536
+ this.visible = !this.visible;
537
+ }
538
+ },
539
+ /* */
540
+ async init() {
541
+ if (this.isInited) return true;
542
+ this.isInited = true;
543
+
544
+ this.setTimeoutSpin();
545
+
546
+ this.instantiatePrintSDK();
547
+ let config = {
548
+ withCredentials: false,
549
+ timeout: 5000
550
+ };
551
+ let printUrlPrefix = this?.printConfig?.printUrlPrefix;
552
+ let customCofing = this?.printConfig?.customCofing || {};
553
+ let cCofing = this.getCustomCofing(customCofing);
554
+ if (axios !== this.axios && printUrlPrefix) {
555
+ config.baseURL = printUrlPrefix;
556
+ }
557
+ httpFn = axios.create({
558
+ ...config,
559
+ ...cCofing
560
+ });
561
+ const formatListResult = await this.queryFormatList();
562
+ // const formatListResult = {
563
+ // "result": "SUCCESS",
564
+ // "code": 0,
565
+ // "resultMsg": "",
566
+ // "obj": [
567
+ // {
568
+ // "number": "04-003-002.2.15",
569
+ // "authorizationKey": "-hQRma05xVDk8TgITIIlbZB0uQbdWbSnGaWZ0jquiPXro_TRORMrTnptz9_pcITa",
570
+ // "param": [
571
+ // {
572
+ // "type": "TEXT",
573
+ // "key": "vaf01",
574
+ // "required": false
575
+ // }
576
+ // ],
577
+ // "name": "检查申请单",
578
+ // "format": [
579
+ // {
580
+ // "number": "04-003-002.2.15",
581
+ // "defaultFlag": 0,
582
+ // "printType": 1,
583
+ // "rowNum": 10,
584
+ // "dataType": 2,
585
+ // "name": "检查申请单",
586
+ // "id": "1555397316323516416",
587
+ // "templateId": "1555397316298350592"
588
+ // }
589
+ // ],
590
+ // "id": "1555397316298350592",
591
+ // "datasetList": [
592
+ // {
593
+ // "name": "病人信息",
594
+ // "id": "1555397315836977152"
595
+ // },
596
+ // {
597
+ // "name": "病史信息",
598
+ // "id": "1555397316076052480"
599
+ // },
600
+ // {
601
+ // "name": "申请单信息",
602
+ // "id": "1610273175815266304"
603
+ // }
604
+ // ],
605
+ // "customizeDataset": [
606
+
607
+ // ]
608
+ // },
609
+ // // {
610
+ // // "number": "04-003-002.2.5",
611
+ // // "authorizationKey": "-hQRma05xVDk8TgITIIlbZB0uQbdWbSnGaWZ0jquiPXro_TRORMrTnptz9_pcITa",
612
+ // // "param": [
613
+ // // {
614
+ // // "type": "TEXT",
615
+ // // "key": "vaf01",
616
+ // // "required": true
617
+ // // },
618
+ // // {
619
+ // // "type": "TEXT",
620
+ // // "key": "vbi01",
621
+ // // "required": false
622
+ // // }
623
+ // // ],
624
+ // // "name": "注射单",
625
+ // // "format": [
626
+ // // {
627
+ // // "number": "04-003-002.2.5",
628
+ // // "defaultFlag": 1,
629
+ // // "printType": 1,
630
+ // // "rowNum": 2,
631
+ // // "dataType": 2,
632
+ // // "name": "注射单新",
633
+ // // "id": "1603271989354504192",
634
+ // // "templateId": "1549981374315700224"
635
+ // // },
636
+ // // {
637
+ // // "number": "04-003-002.2.5",
638
+ // // "defaultFlag": 0,
639
+ // // "printType": 1,
640
+ // // "rowNum": 10,
641
+ // // "dataType": 2,
642
+ // // "name": "注射单",
643
+ // // "id": "1555132544503980032",
644
+ // // "templateId": "1549981374315700224"
645
+ // // }
646
+ // // ],
647
+ // // "id": "1549981374315700224",
648
+ // // "datasetList": [
649
+ // // {
650
+ // // "name": "执行医嘱",
651
+ // // "id": "1610817743354798080"
652
+ // // }
653
+ // // ],
654
+ // // "customizeDataset": [
655
+
656
+ // // ]
657
+ // // }
658
+ // ],
659
+ // "total": 0,
660
+ // "recordsTotal": 0,
661
+ // "recordsFiltered": 0,
662
+ // "success": true
663
+ // };
664
+
665
+ // 获取模板参数接口
666
+ if (!formatListResult) {
667
+ this.isInited = false;
668
+ this.$message.error('获取模板参数失败,请联系管理员');
669
+ return false
670
+ }
671
+ if (this.versionType == 1 || this.versionType == 3) {
672
+ this.initHIS(formatListResult);
673
+ } else {
674
+ await this.initCRM(formatListResult);
675
+ }
676
+
677
+ this.setLoaded();
678
+
679
+ return true;
680
+ },
681
+ // 设置基础数据
682
+ setOptions() {
683
+ this.options = [];
684
+ const children = this.formatList.map(v => {
685
+ return {
686
+ templateCode: v.number,
687
+ templateId: v.templateId,
688
+ label: v.name,
689
+ key: v.id,
690
+ selected: false,
691
+ isLoading: false
692
+ };
693
+ });
694
+ this.options.unshift(...children);
695
+
696
+ // 自动设置外显的数据
697
+ if (this.newPrintSetting?.outerPrintKeys?.length > 0) {
698
+ this.options.forEach(option => {
699
+ if (this.newPrintSetting?.outerPrintKeys.includes(option.key)) {
700
+ option.selected = true;
701
+ }
702
+ })
703
+ this.outerPrintItems = this.options.filter(option => option.selected);
704
+ }
705
+
706
+ this.innerPrintItems = this.options.filter(option => !option.selected);
707
+ },
708
+ initHIS(formatListResult) {
709
+ this.formatList = formatListResult ? formatListResult.list.filter(item => item.printmark == 1) : [];
710
+ this.currentFormatId = this.getDefaultFormatId(this.formatList, 'printmark');
711
+ this.templateParams = this.formatList[0] || {};
712
+ },
713
+ async initCRM(formatListResult) {
714
+ this.formatList = formatListResult ? this.formatFormatList(formatListResult.obj) : [];
715
+ // this.currentFormatId = this.getDefaultFormatId(this.formatList, 'defaultFlag');
716
+
717
+ // if (!this.currentFormatId) {
718
+ // this.$message.error(this.noformatTips || '获取打印格式失败,请联系管理员!');
719
+ // return this.requestError();
720
+ // }
721
+ // if (!this.currentFormatId) {
722
+ // this.requestError();
723
+ // return;
724
+ // }
725
+ this.setOptions();
726
+
727
+ // this.templateParams = await this.queryTemplateParams();
728
+ this.templateParams = await this.mergeTemplateList(formatListResult.obj);
729
+
730
+ // if (templateParamsResult) {
731
+ // this.templateParams = templateParamsResult;
732
+ // } else {
733
+ // return this.requestError();
734
+ // }
735
+
736
+ // this.printParams = this.formatParams(this.templateParams, this.params);
737
+ this.printParams = this.formatSomeTypeParams(this.templateParams, this.params);
738
+ this.originParams = this.formatSomeOriginParams(this.templateParams, this.params);
739
+ },
740
+ formatSomeTypeParams(templateParams=[], params= []) {
741
+ let mergeParams = {};
742
+ params = params ? params : [];
743
+ params.forEach(paramObj => {
744
+ mergeParams = Object.assign({}, this.findTemplateAndInsertData(mergeParams, paramObj, templateParams));
745
+ });
746
+ return mergeParams;
747
+ },
748
+ // 格式化原始params映射值
749
+ formatSomeOriginParams(templateParams=[], params=[]) {
750
+ let mergeOriginParams = {};
751
+ params = params ? params : [];
752
+ params.forEach(paramObj => {
753
+ mergeOriginParams = Object.assign({}, this.findTemplateAndInsertParams(mergeOriginParams, paramObj, templateParams));
754
+ });
755
+ return mergeOriginParams;
756
+ },
757
+ // 查找模板并插入数据
758
+ findTemplateAndInsertData(mergeData, paramItem, templateParams) {
759
+ // 判断当前数据有没有指定模板
760
+ // 1. 有模板,则插入数据
761
+ if (paramItem.templateNumbers) {
762
+ for (let i = 0; i < paramItem.templateNumbers.length; i++) {
763
+ const tempNumber = paramItem.templateNumbers[i];
764
+ const templateObj = templateParams[tempNumber];
765
+ if (!templateObj) {
766
+ this.$message.error('当前勾选的数据没有匹配的模板');
767
+ return mergeData;
768
+ }
769
+ if (!mergeData[tempNumber]) {
770
+ mergeData[tempNumber] = [];
771
+ }
772
+ mergeData[tempNumber].push(this.formatItemParam(templateObj, paramItem));
773
+ }
774
+ return mergeData;
775
+ }
776
+ // 2. 将当前数据循环模板参数
777
+ const templateParamKeys = Object.keys(templateParams);
778
+ for (let i = 0; i < templateParamKeys.length; i++) {
779
+ const tempNumber = templateParamKeys[i];
780
+ const templateObj = templateParams[tempNumber];
781
+ if (!templateObj) {
782
+ this.$message.error('当前勾选的数据没有匹配的模板');
783
+ return mergeData;
784
+ }
785
+ if (!mergeData[tempNumber]) {
786
+ mergeData[tempNumber] = [];
787
+ }
788
+ mergeData[tempNumber].push(this.formatItemParam(templateObj, paramItem));
789
+ }
790
+ return mergeData;
791
+ },
792
+ // 查找模板并插入数据
793
+ findTemplateAndInsertParams(mergeData, paramItem, templateParams) {
794
+ // 判断当前数据有没有指定模板
795
+ // 1. 有模板,则插入数据
796
+ if (paramItem.templateNumbers) {
797
+ for (let i = 0; i < paramItem.templateNumbers.length; i++) {
798
+ const tempNumber = paramItem.templateNumbers[i];
799
+ const templateObj = templateParams[tempNumber];
800
+ if (!templateObj) {
801
+ this.$message.error('当前勾选的数据没有匹配的模板');
802
+ return mergeData;
803
+ }
804
+ if (!mergeData[tempNumber]) {
805
+ mergeData[tempNumber] = [];
806
+ }
807
+ mergeData[tempNumber].push(paramItem);
808
+ }
809
+ return mergeData;
810
+ }
811
+ // 2. 将当前数据循环模板参数
812
+ const templateParamKeys = Object.keys(templateParams);
813
+ for (let i = 0; i < templateParamKeys.length; i++) {
814
+ const tempNumber = templateParamKeys[i];
815
+ const templateObj = templateParams[tempNumber];
816
+ if (!templateObj) {
817
+ this.$message.error('当前勾选的数据没有匹配的模板');
818
+ return mergeData;
819
+ }
820
+ if (!mergeData[tempNumber]) {
821
+ mergeData[tempNumber] = [];
822
+ }
823
+ mergeData[tempNumber].push(paramItem);
824
+ }
825
+ return mergeData;
826
+ },
827
+ // 单条数据转换,通过getPrintFormatByNumber接口获取到的数据没有customizeDataset
828
+ formatItemParam(param = [], paramObj={}) {
829
+ let res = {};
830
+ // 自定义结果集
831
+ // customizeDataset.forEach((dataSetItem) => {
832
+ // const selectFieldList = dataSetItem.dataSetting[0].selectFieldList;
833
+ // if (!res['datasetData']) {
834
+ // res['datasetData'] = {};
835
+ // }
836
+ // res['datasetData'][dataSetItem.name] = JSON.stringify(this.formatPrintParams(paramObj, selectFieldList, 'fieldName'))
837
+ // });
838
+
839
+ // 参数
840
+ res = Object.assign({}, res, this.formatPrintParams(paramObj, param, 'key'));
841
+ return res;
842
+ },
843
+ // 合并所有的模板
844
+ mergeTemplateList(list) {
845
+ let templateObj = {};
846
+ list && list.forEach(item => {
847
+ if (!item.param) return false;
848
+ templateObj[item.number] = item.param;
849
+ });
850
+ return templateObj;
851
+ },
852
+
853
+ setTimeoutSpin() {
854
+ this.spinTimer = setTimeout(() => {
855
+ this.spinning = true;
856
+ }, 1500);
857
+ },
858
+ setLoaded() {
859
+ this.spinning = false;
860
+ if (!this.spinTimer) return false;
861
+ clearTimeout(this.spinTimer);
862
+ this.spinTimer = null;
863
+ },
864
+ // 展开模式下按钮loading状态
865
+ toggleExpandLoading(isLoading, formatId) {
866
+ // 点击单个打印
867
+ if (this.isClickSinglePrint) {
868
+ if (isLoading && formatId) {
869
+ const curOption = this.options.find(outer => outer.key == formatId);
870
+ if (curOption) curOption.isLoading = isLoading;
871
+ return;
872
+ }
873
+ // 让所有单个打印按钮都停止loading
874
+ this.options.forEach(outer => {
875
+ outer.isLoading = false;
876
+ })
877
+ } else {
878
+ // 全部按钮打印
879
+ this.spinning = isLoading;
880
+ }
881
+ },
882
+ getCurrentLoading() {
883
+ if (this.isClickSinglePrint) {
884
+ return this.options.some(outer => outer.isLoading);
885
+ }
886
+ return this.spinning;
887
+ },
888
+ requestError() {
889
+ this.isInited = false;
890
+ this.setLoaded();
891
+ setTimeout(() => {
892
+ this.visible = false;
893
+ }, 0);
894
+
895
+ return false;
896
+ },
897
+ getDefaultFormatId(list, key) {
898
+ if (!list?.length) return '';
899
+ let findDefault = list.find(item => item[key] == 1);
900
+ return findDefault?.id || list[0].id;
901
+ },
902
+ /* */
903
+ instantiatePrintSDK() {
904
+ if (this.printInstance) return false;
905
+ this.printInstance = new Print();
906
+ },
907
+ /* */
908
+ queryFormatList() {
909
+ const { templateNumber, authorizationKey, baseUrl, getPrintFormatByNumberUrl, versionType } = this;
910
+ const suffix = [1, 3].includes(versionType) ? `jsessionids=${vexutils.cookie.get('jsessionids') || '31e5fc0e-955f-4c89-9679-39c43d0171321636163291241'}` : `authorizationKey=${authorizationKey}`;
911
+ const url = `${baseUrl}${getPrintFormatByNumberUrl}?number=${templateNumber}&${suffix}`;
912
+ return httpFn
913
+ .get(url)
914
+ .then(async ({ data }) => {
915
+ if (data.result !== 'SUCCESS') {
916
+ this.$message.error(data.resultMsg || '参数异常,请联系管理员');
917
+ return false;
918
+ }
919
+ return data;
920
+ })
921
+ .catch(e => {
922
+ return false;
923
+ });
924
+ },
925
+ formatFormatList(list) {
926
+ let formatList = [];
927
+
928
+ list.forEach(item => {
929
+ if (!item.format) return false;
930
+ formatList.push(...item.format);
931
+ });
932
+
933
+ return formatList;
934
+ },
935
+ /* */
936
+ queryTemplateParams() {
937
+ const { templateNumber, authorizationKey, baseUrl, getTemplateParamsUrl } = this;
938
+ const { templateId } = this.formatList[0] || {};
939
+ const url = `${baseUrl}${getTemplateParamsUrl}?number=${templateNumber}&templateId=${templateId}&authorizationKey=${authorizationKey}`;
940
+
941
+ return httpFn
942
+ .get(url)
943
+ .then(async ({ data }) => {
944
+ if (data.result !== 'SUCCESS') {
945
+ this.$message.error(data.resultMsg || '参数异常,请联系管理员');
946
+ return false;
947
+ }
948
+ return data?.obj || {};
949
+ })
950
+ .catch(e => {
951
+ return false;
952
+ });
953
+ },
954
+ formatDefaultVal(i, tableVal) {
955
+ const formatMap = {
956
+ DATE: 'YYYY-MM-DD',
957
+ DATETIME: 'YYYY-MM-DD HH:mm:ss'
958
+ };
959
+ let tVal = tableVal;
960
+ if (Object.keys(formatMap).includes(i.type) && tableVal) {
961
+ tVal = moment(tableVal).format(formatMap[i.type]);
962
+ }
963
+ if (i.type === 'TEXT') {
964
+ tVal = String(tableVal) || '';
965
+ }
966
+
967
+ return i?.defaultValue || tVal || '';
968
+ },
969
+ // formatParams({ customizeDataset = [], param = [] }, params = []) {
970
+ // return params.map(paramObj => {
971
+ // let res = {};
972
+
973
+ // // 自定义结果集
974
+ // customizeDataset.forEach(dataSetItem => {
975
+ // const selectFieldList = dataSetItem.dataSetting[0].selectFieldList;
976
+ // res['datasetData'] = {
977
+ // [dataSetItem.name]: JSON.stringify(this.formatPrintParams(paramObj, selectFieldList, 'fieldName'))
978
+ // };
979
+ // });
980
+
981
+ // // 参数
982
+ // res = Object.assign({}, res, this.formatPrintParams(paramObj, param, 'key'));
983
+ // return res;
984
+ // });
985
+ // },
986
+ reformatPrintParams() {
987
+ this.watchPrintParamsReformatFn && this.watchPrintParamsReformatFn();
988
+ /*
989
+ 还没初始化完毕时(还没获取到模板格式配置等..)
990
+ 触发再格式化逻辑,需等待初始化完毕,再重新执行格式化
991
+ */
992
+ if (!this.isInited) {
993
+ this.watchPrintParamsReformatFn = this.$watch('isInited', val => {
994
+ if (!val) return false;
995
+ this.reformatPrintParams();
996
+ });
997
+ return;
998
+ }
999
+
1000
+ // this.printParams = this.formatParams(this.templateParams, this.params);
1001
+ this.printParams = this.formatSomeTypeParams(this.templateParams, this.params);
1002
+ this.originParams = this.formatSomeOriginParams(this.templateParams, this.params);
1003
+ },
1004
+ formatPrintParams(paramObj, fieldList, keyName) {
1005
+ const obj = {};
1006
+ fieldList.forEach(i => {
1007
+ let defaultVal = this.formatDefaultVal(i, paramObj[i[keyName]]);
1008
+ if (paramObj[i[keyName]] && defaultVal) {
1009
+ obj[i[keyName]] = defaultVal;
1010
+ }
1011
+ });
1012
+
1013
+ return obj;
1014
+ },
1015
+ /* */
1016
+ handleClickFormat(id) {
1017
+ this.currentFormatId = id;
1018
+ },
1019
+ /* */
1020
+ getPrintParams() {
1021
+ const extraParams = this?.printExtraParams || {};
1022
+ let res = {
1023
+ ...(this.token ? { token: this.token } : {}),
1024
+ ...extraParams
1025
+ };
1026
+ if (typeof this.getPrintParamsAfter === 'function') {
1027
+ let t = this.getPrintParamsAfter(res);
1028
+ return t || res;
1029
+ }
1030
+ return JSON.stringify(res);
1031
+ },
1032
+ getTemplateIdByFormatId(id) {
1033
+ let find = this.formatList.find(item => item.id === id);
1034
+ return find?.templateId || '';
1035
+ },
1036
+ getTemplateCodeByFormatId(id) {
1037
+ let find = this.formatList.find(item => item.id === id);
1038
+ return find?.number || '';
1039
+ },
1040
+ getOnceParams(curPrintParamList=[], templateCode) {
1041
+ // 聚合一条
1042
+ let params = {};
1043
+ let obj = {};
1044
+ // let cur = this.printParams?.[0] || {};
1045
+ if (this.templateParams[templateCode]?.customizeDataset?.length) {
1046
+ // 有模板数据
1047
+ const key = Object.keys(curPrintParamList[0]?.datasetData || {})?.[0] || '';
1048
+ const datasetDataKeyVal = JSON.stringify(curPrintParamList.map(v => JSON.parse(v.datasetData[key])));
1049
+ obj = {
1050
+ datasetData: {}
1051
+ };
1052
+ obj.datasetData[key] = datasetDataKeyVal;
1053
+ } else {
1054
+ // 无模板数据
1055
+ Object.keys(curPrintParamList[0]).forEach(v => {
1056
+ obj[v] = [];
1057
+ curPrintParamList.forEach(k => {
1058
+ if(!obj[v].includes(k[v])) {
1059
+ obj[v].push(k[v]);
1060
+ }
1061
+ });
1062
+ obj[v] = obj[v].join(',');
1063
+ });
1064
+ }
1065
+ params = Object.assign({}, JSON.parse(this.getPrintParams()), this.printCustomProps, obj);
1066
+ if (typeof this.getOnceParamsAfter === 'function') {
1067
+ let res = this.getOnceParamsAfter(params, obj);
1068
+ return res || params;
1069
+ }
1070
+ return JSON.stringify(params);
1071
+ },
1072
+ handleClickPrint(curPrintParamList, templateCode, templateId, formatId, printToParam=[], needContinuePrint) {
1073
+ let len = curPrintParamList.length;
1074
+ const callLocalServicesSuccessCb = async data => {
1075
+ try {
1076
+ if (--len <= 0) {
1077
+ this.callLocalServicesSuccessCb(data, 'print');
1078
+ }
1079
+ } catch (error) {
1080
+ console.log('error', error);
1081
+ }
1082
+ };
1083
+ if (this.getCurrentLoading() && !needContinuePrint) return;
1084
+ this.toggleExpandLoading(true, formatId);
1085
+ this.prevFn()
1086
+ .catch(() => {
1087
+ this.prevFnError();
1088
+ return Promise.reject();
1089
+ })
1090
+ .then(() => {
1091
+ if (this.versionType == 1 || this.versionType == 3) {
1092
+ const printFn = this.versionType == 1 ? 'handleHisPrint' : 'handleOldHisPrint';
1093
+ if (this.strategy === 'MULTI') {
1094
+ for (let i = 0; i < this.params.length; i++) {
1095
+ const params = this.getHisParams(i);
1096
+ this.printInstance[printFn](7, params)
1097
+ .then(res => {
1098
+ console.log(res, '777777777777');
1099
+ })
1100
+ .catch(error => {
1101
+ console.log(error, 'error777');
1102
+ });
1103
+ }
1104
+ } else {
1105
+ const params = this.getOnceHisParams();
1106
+ this.printInstance[printFn](7, params)
1107
+ .then(res => {
1108
+ console.log(res, '777777777777');
1109
+ })
1110
+ .catch(error => {
1111
+ console.log(error, 'error777');
1112
+ });
1113
+ }
1114
+ } else {
1115
+ this.curPrintParamList = curPrintParamList;
1116
+ const queryParams = {
1117
+ // ...this.queryParams,
1118
+ formatId,
1119
+ templateId,
1120
+ printdlgshow: this.printdlgshow
1121
+ };
1122
+ if (this.strategy === 'MULTI') {
1123
+ // 循环多条
1124
+ for (let i = 0; i < curPrintParamList.length; i++) {
1125
+ if (i > 0) queryParams.printdlgshow = '0';
1126
+ const params = JSON.stringify(Object.assign({}, JSON.parse(this.getPrintParams()), this.printCustomProps, curPrintParamList[i]));
1127
+ this.printInstance.printDirect(
1128
+ {
1129
+ ...queryParams,
1130
+ params
1131
+ },
1132
+ callLocalServicesSuccessCb,
1133
+ this.callLocalServicesErrorCb,
1134
+ this.callLocalServicesCancelCb
1135
+ );
1136
+ }
1137
+ } else {
1138
+ // 聚合一条
1139
+ this.printInstance.printDirect(
1140
+ {
1141
+ ...queryParams,
1142
+ params: this.getOnceParams(curPrintParamList, templateCode)
1143
+ },
1144
+ res => {
1145
+ res.params = printToParam;
1146
+ res.templateCode = templateCode;
1147
+ res.templateId = templateId;
1148
+ this.callLocalServicesSuccessCb(res, 'print');
1149
+ },
1150
+ this.callLocalServicesErrorCb,
1151
+ this.callLocalServicesCancelCb
1152
+ );
1153
+ }
1154
+ }
1155
+ })
1156
+ },
1157
+ getHisParams(index = 0) {
1158
+ const { templateParams, hisParams, params } = this;
1159
+ const { reportid = '280' } = hisParams;
1160
+ const { id, name } = templateParams;
1161
+ return {
1162
+ reportid,
1163
+ formatid: this.currentFormatId || id,
1164
+ formatname: name,
1165
+ param: params[index]
1166
+ };
1167
+ },
1168
+ getOnceHisParams() {
1169
+ const { templateParams, hisParams, params } = this;
1170
+ const { reportid = '280' } = hisParams;
1171
+ const { id, name } = templateParams;
1172
+ const obj = {};
1173
+ Object.keys(params[0]).forEach(v => {
1174
+ obj[v] = [];
1175
+ params.forEach(k => {
1176
+ obj[v].push(k[v]);
1177
+ });
1178
+ obj[v] = obj[v].join(',');
1179
+ });
1180
+ return {
1181
+ reportid,
1182
+ formatid: this.currentFormatId || id,
1183
+ formatname: name,
1184
+ param: obj
1185
+ };
1186
+ },
1187
+ async handleClickPreview(curPrintParamList=[], templateCode, templateId, formatId) {
1188
+ if (this.getCurrentLoading()) return;
1189
+ this.toggleExpandLoading(true, formatId);
1190
+ this.prevFn()
1191
+ .catch(() => {
1192
+ this.prevFnError();
1193
+ return Promise.reject();
1194
+ })
1195
+ .then(() => {
1196
+ if (this.versionType == 1 || this.versionType == 3) {
1197
+ const params = this.strategy === 'MULTI' ? this.getHisParams() : this.getOnceHisParams();
1198
+ const printFn = this.versionType == 1 ? 'handleHisPrint' : 'handleOldHisPrint';
1199
+ this.printInstance[printFn](8, params)
1200
+ .then(res => {
1201
+ console.log(res, 88888888);
1202
+ })
1203
+ .catch(error => {
1204
+ console.log(error, 'error888');
1205
+ });
1206
+ } else {
1207
+ this.curPrintParamList = curPrintParamList;
1208
+ const IS_MULTI = this.strategy === 'MULTI';
1209
+ const queryParams = {
1210
+ formatId,
1211
+ templateId
1212
+ };
1213
+ const paramsFirst = JSON.stringify(Object.assign({}, JSON.parse(this.getPrintParams()), this.printCustomProps.value, curPrintParamList[0]));
1214
+ this.printInstance.preview(
1215
+ {
1216
+ // ...this.queryParams,
1217
+ ...queryParams,
1218
+ params: IS_MULTI ? paramsFirst : this.getOnceParams(curPrintParamList, templateCode)
1219
+ },
1220
+ res => {
1221
+ this.callLocalServicesSuccessCb(res, 'preview');
1222
+ },
1223
+ this.callLocalServicesErrorCb
1224
+ );
1225
+ }
1226
+ })
1227
+ },
1228
+ // 下载pdf
1229
+ async handleClickPdf(curPrintParamList=[], templateCode, templateId, formatId) {
1230
+ if (this.getCurrentLoading()) return;
1231
+ this.toggleExpandLoading(true, formatId);
1232
+ this.prevFn()
1233
+ .catch(() => {
1234
+ this.prevFnError();
1235
+ return Promise.reject();
1236
+ })
1237
+ .then(() => {
1238
+ if (this.versionType == 1 || this.versionType == 3) {
1239
+ console.log('下载pdf>>>');
1240
+ } else {
1241
+ this.curPrintParamList = curPrintParamList;
1242
+ const IS_MULTI = this.strategy === 'MULTI';
1243
+ // const queryParams = {
1244
+ // ...this.queryParams,
1245
+ // print: { print: '1', type: '1', callback: '1' },
1246
+ // };
1247
+ const queryParams = {
1248
+ formatId,
1249
+ templateId,
1250
+ print: { print: '1', type: '1', callback: '1' },
1251
+ };
1252
+ const paramsFirst = JSON.stringify(Object.assign({}, JSON.parse(this.getPrintParams()), this.printCustomProps.value, curPrintParamList[0]));
1253
+ this.printInstance.downloadPDF(
1254
+ {
1255
+ ...queryParams,
1256
+ params: IS_MULTI ? paramsFirst : this.getOnceParams(curPrintParamList, templateCode)
1257
+ },
1258
+ res => {
1259
+ this.callLocalServicesSuccessCb(res, 'download');
1260
+ },
1261
+ this.callLocalServicesErrorCb
1262
+ );
1263
+ }
1264
+ })
1265
+ },
1266
+ handleClickEdit(curPrintParamList=[], templateCode, templateId, formatId) {
1267
+ if (this.getCurrentLoading()) return;
1268
+ this.toggleExpandLoading(true, formatId);
1269
+ this.prevFn()
1270
+ .catch(() => {
1271
+ this.prevFnError();
1272
+ return Promise.reject();
1273
+ })
1274
+ .then(() => {
1275
+ if (this.versionType == 1 || this.versionType == 3) {
1276
+ const params = this.strategy === 'MULTI' ? this.getHisParams() : this.getOnceHisParams();
1277
+ const printFn = this.versionType == 1 ? 'handleHisPrint' : 'handleOldHisPrint';
1278
+ this.printInstance[printFn](9, params)
1279
+ .then(res => {
1280
+ console.log(res, 999999);
1281
+ })
1282
+ .catch(error => {
1283
+ console.log(error, 'error999');
1284
+ });
1285
+ } else {
1286
+ this.toggleExpandLoading(false);
1287
+ this.curPrintParamList = curPrintParamList;
1288
+ this.currentFormatId = formatId;
1289
+ this.identityVerification.visible = true;
1290
+ }
1291
+ })
1292
+ },
1293
+ verifiySuccess(token) {
1294
+ this.identityVerification.visible = false;
1295
+ const paramsFirst = JSON.stringify(Object.assign({}, JSON.parse(this.getPrintParams()), this.printCustomProps.value, this.curPrintParamList[0]));
1296
+ const params = this.strategy === 'MULTI' ? paramsFirst : this.getOnceParams(this.curPrintParamList, this.getTemplateCodeByFormatId(this.currentFormatId));
1297
+ const queryParams = {
1298
+ // ...this.queryParams,
1299
+ formatId: this.currentFormatId,
1300
+ templateId: this.getTemplateIdByFormatId(this.currentFormatId),
1301
+ params,
1302
+ token
1303
+ };
1304
+ this.printInstance.editPrintFormat(
1305
+ queryParams,
1306
+ res => {
1307
+ this.callLocalServicesSuccessCb(res, 'edit');
1308
+ },
1309
+ this.callLocalServicesErrorCb
1310
+ );
1311
+ },
1312
+ /* */
1313
+ prevFnError() {
1314
+ // 前置条件执行错误这里不弹提示,“前置条件”事件内有弹提示了
1315
+ // let error = {
1316
+ // message: '前置条件执行错误'
1317
+ // };
1318
+ // this.$emit('error', error);
1319
+ this.toggleExpandLoading(false);
1320
+ this.visible = false;
1321
+ },
1322
+ /* */
1323
+ callLocalServicesSuccessCb(res, type) {
1324
+ this.toggleExpandLoading(false);
1325
+ let info = {
1326
+ type,
1327
+ formatId: this.currentFormatId,
1328
+ templateId: res?.templateId || this.getTemplateIdByFormatId(this.currentFormatId),
1329
+ templateCode: res?.templateCode || this.getTemplateCodeByFormatId(this.currentFormatId),
1330
+ };
1331
+ this.$emit('success', res, info);
1332
+ },
1333
+ callLocalServicesErrorCb(res) {
1334
+ this.toggleExpandLoading(false);
1335
+ this.$emit('error', res);
1336
+ },
1337
+ callLocalServicesCancelCb(res) {
1338
+ this.toggleExpandLoading(false);
1339
+ this.$emit('cancel', res);
1340
+ },
1341
+
1342
+ /**
1343
+ * 获取 axios 自定义配置
1344
+ */
1345
+ getCustomCofing(customCofing) {
1346
+ let cCofing = {};
1347
+ let type = typeof customCofing;
1348
+ if (type === 'function') {
1349
+ cCofing = customCofing();
1350
+ } else if (type === 'object') {
1351
+ cCofing = customCofing;
1352
+ }
1353
+ return cCofing;
1354
+ }
1355
+ }
1356
+ });
1357
+ </script>
1358
+
1359
+ <style lang="less" scoped>
1360
+ .dropdown-button {
1361
+ color: #212121;
1362
+ border-color: #d5d5d5 !important;
1363
+ margin-left: 8px;
1364
+ margin-bottom: 8px;
1365
+ /deep/ .svg-icon {
1366
+ margin-right: 4px;
1367
+ }
1368
+ &.ant-dropdown-trigger {
1369
+ i.anticon.anticon-down {
1370
+ color: #969696;
1371
+ font-size: 14px;
1372
+ }
1373
+ }
1374
+ }
1375
+ </style>
1376
+
1377
+ <style lang="less">
1378
+ .newprint-button-outer {
1379
+ display: flex;
1380
+ align-items: center;
1381
+ .ant-popover-inner-content{
1382
+ padding: 0;
1383
+ }
1384
+ }
1385
+
1386
+ .newprint-button-menu{
1387
+ .print-divider{
1388
+ .ant-divider{
1389
+ margin: 0;
1390
+ }
1391
+ }
1392
+ .isDisabled{
1393
+ color: #999;
1394
+ cursor: default;
1395
+ }
1396
+ .dropdown-between{
1397
+ display: flex;
1398
+ justify-content: space-between;
1399
+ align-items: center;
1400
+ padding: 0;
1401
+ .label{
1402
+ flex: 1;
1403
+ padding: 5px 12px;
1404
+ }
1405
+ .ant-btn{
1406
+ margin: 5px 12px 5px 0;
1407
+ }
1408
+ }
1409
+ }
1410
+
1411
+
1412
+
1413
+
1414
+
1415
+ .rowFoldHideBtnList-dropdown {
1416
+ min-width: 150px !important;
1417
+ .ant-dropdown-menu {
1418
+ overflow-y: auto;
1419
+ max-height: 99vh;
1420
+ }
1421
+ .ant-dropdown-menu-item-group {
1422
+ .ant-dropdown-menu-item-group-title {
1423
+ display: none;
1424
+ }
1425
+ border-bottom: 1px solid #d5d5d5;
1426
+ &:last-child {
1427
+ border-color: transparent;
1428
+ }
1429
+ }
1430
+ .format-name .ant-dropdown-menu-submenu-title {
1431
+ font-weight: bold;
1432
+ color: #000;
1433
+ }
1434
+ .ant-dropdown-menu-item.active {
1435
+ color: #5585f5;
1436
+ }
1437
+ }
1438
+ </style>