cnhis-design-vue 2.1.23 → 2.1.25

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