cnhis-design-vue 2.1.16 → 2.1.19

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