doway-coms 1.5.7 → 1.5.9

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 (74) hide show
  1. package/.browserslistrc +2 -2
  2. package/README.md +28 -28
  3. package/dist/css/chunk-vendors.7f83d8f9.css +8 -0
  4. package/dist/css/index.7946d50b.css +1 -0
  5. package/dist/favicon.ico +0 -0
  6. package/dist/js/chunk-vendors.28fda91d.js +340 -0
  7. package/dist/js/index.49bc6add.js +2 -0
  8. package/lib/doway-coms.common.js +120397 -0
  9. package/lib/doway-coms.css +1 -0
  10. package/lib/doway-coms.umd.js +120407 -0
  11. package/lib/doway-coms.umd.min.js +328 -0
  12. package/package.json +52 -52
  13. package/packages/BaseButton/index.js +7 -7
  14. package/packages/BaseButton/src/index.vue +241 -241
  15. package/packages/BaseCheckbox/index.js +7 -7
  16. package/packages/BaseCheckbox/src/index.vue +134 -134
  17. package/packages/BaseDate/index.js +7 -7
  18. package/packages/BaseDate/src/index.vue +197 -197
  19. package/packages/BaseDateWeek/index.js +7 -7
  20. package/packages/BaseDateWeek/src/index.vue +163 -163
  21. package/packages/BaseDatetime/index.js +7 -7
  22. package/packages/BaseDatetime/src/index.vue +196 -196
  23. package/packages/BaseForm/index.js +7 -7
  24. package/packages/BaseForm/src/index.vue +664 -664
  25. package/packages/BaseGantt/index.js +9 -9
  26. package/packages/BaseGantt/src/index.vue +604 -604
  27. package/packages/BaseGrid/index.js +9 -9
  28. package/packages/BaseGrid/src/index.vue +2700 -2690
  29. package/packages/BaseGridAdjust/index.js +9 -9
  30. package/packages/BaseGridAdjust/src/index.vue +455 -455
  31. package/packages/BaseInput/index.js +7 -7
  32. package/packages/BaseInput/src/index.vue +164 -164
  33. package/packages/BaseIntervalInput/index.js +7 -7
  34. package/packages/BaseIntervalInput/src/index.vue +310 -310
  35. package/packages/BaseKanbanEmpty/index.js +7 -7
  36. package/packages/BaseKanbanEmpty/src/index.vue +176 -176
  37. package/packages/BaseNumberInput/index.js +7 -7
  38. package/packages/BaseNumberInput/src/index.vue +229 -229
  39. package/packages/BasePagination/index.js +7 -7
  40. package/packages/BasePagination/src/index.vue +91 -91
  41. package/packages/BasePictureCard/index.js +7 -7
  42. package/packages/BasePictureCard/src/index.vue +561 -561
  43. package/packages/BasePrintPreview/index.js +7 -7
  44. package/packages/BasePrintPreview/src/index.vue +117 -117
  45. package/packages/BasePulldown/index.js +7 -7
  46. package/packages/BasePulldown/src/index.vue +867 -867
  47. package/packages/BaseSearch/index.js +7 -7
  48. package/packages/BaseSearch/src/index.vue +935 -935
  49. package/packages/BaseSelect/index.js +7 -7
  50. package/packages/BaseSelect/src/index.vue +153 -153
  51. package/packages/BaseSelectMulti/index.js +7 -7
  52. package/packages/BaseSelectMulti/src/index.vue +148 -148
  53. package/packages/BaseTextArea/index.js +7 -7
  54. package/packages/BaseTextArea/src/index.vue +178 -178
  55. package/packages/BaseTime/index.js +7 -7
  56. package/packages/BaseTime/src/index.vue +166 -166
  57. package/packages/BaseTool/index.js +7 -7
  58. package/packages/BaseTool/src/index.vue +349 -349
  59. package/packages/BaseToolStatus/index.js +7 -7
  60. package/packages/BaseToolStatus/src/index.vue +383 -383
  61. package/packages/index.js +165 -165
  62. package/packages/styles/default.less +80 -80
  63. package/packages/utils/api.js +45 -45
  64. package/packages/utils/auth.js +38 -38
  65. package/packages/utils/common.js +583 -583
  66. package/packages/utils/dom.js +181 -181
  67. package/packages/utils/enum.js +83 -83
  68. package/packages/utils/filters.js +458 -458
  69. package/packages/utils/gridFormat.js +52 -52
  70. package/packages/utils/msg.js +16 -16
  71. package/packages/utils/patchFiles.js +44 -44
  72. package/packages/utils/request.js +169 -169
  73. package/packages/utils/store.js +254 -257
  74. package/vue.config.js +59 -59
@@ -1,561 +1,561 @@
1
- <template>
2
- <div style="display: inline-block">
3
- <div class="file-card" :class="isStyle? 'currentHeight' : ''">
4
- <div
5
- class="attach-wrapper"
6
- v-for="internalRow in internalRows.filter(
7
- (x) => x.sysRowState != 'delete'
8
- )"
9
- :key="internalRow.attach.fileName"
10
- >
11
- <template v-if="internalRow.sysRowState !== sysRowState.delete">
12
- <slot name='header' :row="internalRow"></slot>
13
- <div class="attach" v-if="internalRow.attach.content === 'image'">
14
- <img
15
- @click="attachFileClick(internalRow.attach)"
16
- :style="{ height: height, lineHeight: height, width: width }"
17
- style="
18
- border: 1px solid #ccc;
19
- border-radius: 6px;
20
- overflow: hidden;
21
- margin: 0;
22
- padding: 0;
23
- "
24
- :src="`${internalServiceUrl}/GetAttachFile/${internalRow.attach.id}?accessToken=${$store.getters.token}`"
25
- />
26
- <a-icon
27
- class="attach-delete"
28
- type="close-circle"
29
- @click="removeAttach(internalRow.attach)"
30
- v-if="edit === true"
31
- />
32
- <a-icon
33
- class="attach-download"
34
- type="download"
35
- @click="downloadAttach(internalRow.attach)"
36
- />
37
- <a-icon
38
- class="attach-view"
39
- type="eye"
40
- @click="viewAttach(internalRow.attach)"
41
- />
42
- </div>
43
- <div class="attach" v-else>
44
- <img
45
- @click="attachFileClick(internalRow.attach)"
46
- :style="{ height: height, lineHeight: height, width: width }"
47
- :data-mimetype="internalRow.attach.contentType"
48
- />
49
- <a-icon
50
- class="attach-delete"
51
- type="close-circle"
52
- v-if="edit === true"
53
- @click="removeAttach(internalRow.attach)"
54
- />
55
- <a-icon
56
- class="attach-download"
57
- type="download"
58
- @click="downloadAttach(internalRow.attach)"
59
- />
60
- <a-icon
61
- class="attach-view"
62
- type="eye"
63
- @click="viewAttach(internalRow.attach)"
64
- />
65
- </div>
66
- <div
67
- :style="{ width: width }"
68
- :title="internalRow.attach.name"
69
- style="
70
- overflow: hidden;
71
- text-overflow: ellipsis;
72
- white-space: nowrap;
73
- "
74
- >
75
- {{ internalRow.attach.name }}
76
- </div>
77
- </template>
78
- </div>
79
- <a-upload
80
- class="avatar-uploader"
81
- :headers="uploadHeaders"
82
- :action="uploadData.picAction"
83
- :data="uploadData"
84
- v-if="edit === true"
85
- @change="handleAvatarSuccess"
86
- :showUploadList="false"
87
- :before-upload="beforeAvatarUpload"
88
- >
89
- <div
90
- style="border: 1px solid #d9d9d9; border-radius: 6px"
91
- :style="{ width: width, height: height, lineHeight: height }"
92
- >
93
- <a-icon
94
- type="plus"
95
- class="avatar-uploader-icon"
96
- style="text-align: center"
97
- :style="{ width: width, height: height, lineHeight: height }"
98
- />
99
- </div>
100
- </a-upload>
101
- <div v-if="edit !== true && showEmptyText && internalRows.length === 0">
102
- 没有附件信息哦,请编辑添加附件信息
103
- </div>
104
- </div>
105
- <VxeModal
106
- v-model="dialogVisible"
107
- show-zoom
108
- transfer
109
- resize
110
- :height="550"
111
- :width="800"
112
- destroy-on-close
113
- :fullscreen="dialogViewType == 'application/pdf'"
114
- :z-index="999"
115
- >
116
- <template #title>
117
- <span>{{ currentFileTitle }}</span>
118
- </template>
119
- <!-- pdf -->
120
- <embed
121
- v-if="dialogViewType == 'application/pdf'"
122
- :src="dialogImageUrl"
123
- :type="dialogViewType"
124
- width="100%"
125
- height="100%"
126
- />
127
- <!-- 普通图片 -->
128
- <img width="90%" height="auto" :src="dialogImageUrl" v-else />
129
- </VxeModal>
130
- </div>
131
- </template>
132
-
133
- <script>
134
- import { notification, Upload } from "ant-design-vue";
135
- import { sysRowState } from "../../utils/enum";
136
- import { Checkbox, Modal } from "vxe-table";
137
- import { attachGetAttachUrlApi, attachSearchApi } from "../../utils/api";
138
-
139
- export default {
140
- name: "BasePictureCard",
141
- components: {
142
- VxeCheckbox: Checkbox,
143
- "a-upload": Upload,
144
- VxeModal: Modal,
145
- },
146
- data() {
147
- return {
148
- demo1: "",
149
- demo2: "",
150
- internalServiceUrl: "",
151
- downFilePath: "",
152
- downFileName: "",
153
- isShowPdf: false,
154
- pdfData: null,
155
- internalUrls: [],
156
- internalRows: [],
157
- picName: [],
158
- dialogImageUrl: "",
159
- dialogViewType: "",
160
- sysRowState: sysRowState,
161
- dialogVisible: false,
162
- uploadData: {
163
- picType: "",
164
- picAction: "",
165
- resId: "",
166
- },
167
- uploadHeaders: {
168
- Authorization: null,
169
- },
170
- currentFileTitle: ''
171
- };
172
- },
173
- props: {
174
- isStyle: {
175
- type: Boolean,
176
- default: false,
177
- },
178
- showEmptyText: {
179
- type: Boolean,
180
- default: true,
181
- },
182
- picType: {
183
- type: String,
184
- default: "cust",
185
- },
186
- value: {
187
- type: String,
188
- },
189
- resId: {
190
- type: String,
191
- },
192
- dataName: {
193
- type: String,
194
- },
195
- edit: {
196
- // 列信息
197
- type: Boolean,
198
- },
199
- limitSize: {
200
- // 限制上传大小
201
- type: Number,
202
- default: 5,
203
- },
204
- limitType: {
205
- // 限制上传类型
206
- type: Array,
207
- default: () => {
208
- return [];
209
- },
210
- },
211
- formRow: {
212
- type: Object,
213
- default: () => {
214
- return {};
215
- },
216
- },
217
- width: {
218
- type: String,
219
- default: "100px",
220
- },
221
- height: {
222
- type: String,
223
- default: "100px",
224
- },
225
- rows: {
226
- // 表格数据
227
- type: Array,
228
- default: function () {
229
- return [];
230
- },
231
- },
232
- cols: {
233
- // 表格列信息
234
- type: Array,
235
- default: function () {
236
- return [];
237
- },
238
- },
239
- formState: {
240
- // 表格列信息
241
- type: String,
242
- default: "",
243
- },
244
- },
245
- watch: {
246
- rows: {
247
- handler: function (newVal) {
248
- this.getAttachInfo(newVal);
249
- },
250
- deep: true,
251
- },
252
- resId: {
253
- handler: function (newVal) {
254
- this.uploadData.resId = newVal;
255
- },
256
- },
257
- },
258
- created() {
259
- },
260
- mounted() {
261
- // 请求头加入token
262
- this.uploadHeaders.Authorization = `Bearer ${this.$store.getters.token}`;
263
-
264
- this.internalServiceUrl = attachGetAttachUrlApi();
265
- this.uploadData.picType = this.picType;
266
- this.uploadData.resId = this.resId;
267
- this.uploadData.picAction = this.internalServiceUrl + "/UploadAttach";
268
- this.getAttachInfo(this.rows);
269
- },
270
- methods: {
271
- getCurrentToken() {
272
- return this.$store.getters.token;
273
- },
274
- /**
275
- * 获取附件信息
276
- */
277
- getAttachInfo(newRows) {
278
- let attachIds = [];
279
- for (let i = 0; i < newRows.length; i++) {
280
- if (newRows[i].attach) {
281
- continue;
282
- }
283
- attachIds.push(newRows[i].attachId);
284
- newRows[i].attach = {
285
- fileName: "",
286
- contentType: "",
287
- content: "",
288
- name: "",
289
- id: newRows[i].attachId,
290
- };
291
- }
292
- if (attachIds.length == 0) {
293
- this.internalRows = newRows;
294
- return;
295
- }
296
- let postData = {
297
- fields: "id,fileName,contentType,name,content,isDefault",
298
- begin: 1,
299
- size: 0,
300
- exp: "id in (",
301
- };
302
- for (let i = 0; i < attachIds.length; i++) {
303
- postData.exp = postData.exp + attachIds[i] + ",";
304
- }
305
- let vm = this;
306
- postData.exp = postData.exp.substr(0, postData.exp.length - 1) + ")";
307
- attachSearchApi(postData)
308
- .then((responseData) => {
309
- for (let i = 0; i < responseData.content.length; i++) {
310
- for (let x = 0; x < newRows.length; x++) {
311
- if (responseData.content[i].id === newRows[x].attachId) {
312
- newRows[x].attach.fileName = responseData.content[i].fileName;
313
- newRows[x].attach.name = responseData.content[i].name;
314
- newRows[x].attach.content = responseData.content[i].content;
315
- newRows[x].attach.contentType =
316
- responseData.content[i].contentType;
317
- // newRows[x].attach.isDefault = false
318
- break;
319
- }
320
- }
321
- }
322
- vm.internalRows = newRows;
323
- })
324
- .catch(() => {});
325
- },
326
- attachFileClick(attachFile) {},
327
- handleAvatarSuccess(info) {
328
- if (info.file.status == "done") {
329
- let addRow = {
330
- attachId: info.file.response.content.id,
331
- sysRowState: sysRowState.add,
332
- attach: info.file.response.content,
333
- };
334
-
335
- this.internalRows.push(addRow);
336
- let tempField;
337
- for (let i = 0; i < this.cols.length; i++) {
338
- // 赋值关联字段数据
339
- let tempValue = addRow;
340
- tempField = this.cols[i].field;
341
- if (this.cols[i].isAuto) {
342
- tempValue[tempField] = this.$store.getters.newId() + "";
343
- continue;
344
- }
345
- if (
346
- this.cols[i].controlType === "text" &&
347
- this.cols[i].linkValueField !== null &&
348
- this.cols[i].linkValueField !== "" &&
349
- this.cols[i].linkValueField !== undefined
350
- ) {
351
- tempValue[tempField] = this.formRow[this.cols[i].linkValueField];
352
- }
353
- }
354
- this.$emit(
355
- "add",
356
- this.dataName,
357
- info.file.response.content
358
- );
359
- }
360
- },
361
- beforeAvatarUpload(file) {
362
- // const isPic = file.type === 'image/jpeg' || file.type === 'image/png'
363
- if (file.size / 1024 / 1024 > this.limitSize) {
364
- notification.error({
365
- message: "错误",
366
- description: "上传图片大小不能超过 " + this.limitSize + "MB!",
367
- });
368
- }
369
- if (this.limitType.length > 0 && !this.limitType[file.type]) {
370
- notification.error({
371
- message: "错误",
372
- description: "上传附件格式错误!",
373
- });
374
- }
375
- return true;
376
- },
377
- handleRemove(file, fileList) {
378
- // this.dialogVisible = !this.dialogVisible
379
- // alert(this.dialogVisible)
380
- this.internalUrls = fileList;
381
- this.$emit("remove", this.dataName, file.response.data);
382
- // this.$emit('remove', this.dataName, file.response.data)
383
- },
384
- circleAttach(attachFile, internalRow) {
385
- let vm = this;
386
- // if(internalRow.isDefault == true){
387
- this.internalRows.forEach((element) => {
388
- if (element.id !== internalRow.id) {
389
- element.isDefault = false;
390
- }
391
- });
392
- // }
393
- },
394
- removeAttach(attachFile) {
395
- for (let i = 0; i < this.internalRows.length; i++) {
396
- if (this.internalRows[i].attachId === attachFile.id) {
397
- if (this.internalRows[i].sysRowState === sysRowState.add) {
398
- this.internalRows.splice(i, 1);
399
- } else {
400
- this.$set(this.internalRows[i], "sysRowState", sysRowState.delete);
401
- }
402
- break;
403
- }
404
- }
405
- this.$emit("remove", attachFile.id);
406
- },
407
- downloadAttach(attachFile) {
408
- window.open(
409
- this.internalServiceUrl +
410
- "/DownAttachFile/" +
411
- attachFile.id +
412
- `?accessToken=${this.$store.getters.token}`
413
- );
414
- },
415
- /**
416
- * 查看附件
417
- */
418
- viewAttach(attachFile) {
419
- if (attachFile.contentType === "application/pdf") {
420
- this.dialogImageUrl = `${this.internalServiceUrl}/GetAttachFile/${attachFile.id}?accessToken=${this.$store.getters.token}`;
421
- this.dialogViewType = attachFile.contentType;
422
- this.dialogVisible = true;
423
- } else if (attachFile.content === "image") {
424
- this.dialogImageUrl = `${this.internalServiceUrl}/GetAttachFile/${attachFile.id}?accessToken=${this.$store.getters.token}`;
425
- this.dialogViewType = attachFile.contentType;
426
- this.dialogVisible = true;
427
- }
428
- this.currentFileTitle = attachFile.name
429
- },
430
- closePdf() {
431
- this.isShowPdf = false;
432
- },
433
- },
434
- };
435
- </script>
436
-
437
- <style lang="scss" scoped>
438
- .file-card {
439
- display: flex;
440
- flex-flow: row wrap;
441
- margin: 0 0 5px 5px;
442
-
443
- .attach-wrapper {
444
- .attach {
445
- position: relative;
446
- margin-right: 5px;
447
-
448
- .attach-delete {
449
- position: absolute;
450
- top: -2px;
451
- right: -4px;
452
- opacity: 0;
453
- font-size: 20px;
454
- background-color: red;
455
- }
456
-
457
- .attach-delete:hover {
458
- cursor: pointer;
459
- }
460
-
461
- .attach-download {
462
- position: absolute;
463
- bottom: 10px;
464
- left: 4px;
465
- opacity: 0;
466
- font-size: 18px;
467
- font-weight: bolder;
468
- border: 1px solid #ccc;
469
- border-radius: 50%;
470
- border-color: transparent;
471
- //background-color: rgb(255, 1, 1);
472
- color: #000;
473
- }
474
-
475
- .attach-download:hover {
476
- cursor: pointer;
477
- color: rgb(189, 8, 8);
478
- }
479
-
480
- .attach-view {
481
- position: absolute;
482
- bottom: 10px;
483
- right: 4px;
484
- opacity: 0;
485
- font-size: 18px;
486
- font-weight: bolder;
487
- border: 1px solid #ccc;
488
- border-radius: 50%;
489
- border-color: transparent;
490
- //background-color: #666;
491
- color: #000;
492
- }
493
-
494
- .attach-circle {
495
- position: absolute;
496
- // bottom: 10px;
497
- top: 2px;
498
- left: 4px;
499
- opacity: 0;
500
- }
501
-
502
- .attach-view:hover {
503
- cursor: pointer;
504
- color: rgb(189, 8, 8);
505
- }
506
- }
507
-
508
- .attach:hover > .attach-delete {
509
- opacity: 0.8;
510
- }
511
-
512
- .attach:hover > .attach-download {
513
- opacity: 0.7;
514
- }
515
-
516
- .attach:hover > .attach-view {
517
- opacity: 0.7;
518
- }
519
-
520
- .attach:hover > .attach-circle {
521
- opacity: 0.9;
522
- }
523
- }
524
- }
525
-
526
- .avatar-uploader .el-upload {
527
- border: 1px solid #d9d9d9;
528
-
529
- border-radius: 6px;
530
- cursor: pointer;
531
- position: relative;
532
- overflow: hidden;
533
- }
534
-
535
- .avatar-uploader .el-upload:hover {
536
- border-color: #409eff;
537
- }
538
-
539
- .avatar-uploader-icon {
540
- font-size: 28px;
541
- color: #8c939d;
542
- // width: 178px;
543
- // height: 178px;
544
- line-height: 178px;
545
- text-align: center;
546
- }
547
-
548
- .avatar {
549
- // width: 178px;
550
- // height: 178px;
551
- display: block;
552
- }
553
-
554
- .el-upload-list__item is-success {
555
- float: left;
556
- }
557
- .currentHeight {
558
- display: flex;
559
- align-items: center;
560
- }
561
- </style>
1
+ <template>
2
+ <div style="display: inline-block">
3
+ <div class="file-card" :class="isStyle? 'currentHeight' : ''">
4
+ <div
5
+ class="attach-wrapper"
6
+ v-for="internalRow in internalRows.filter(
7
+ (x) => x.sysRowState != 'delete'
8
+ )"
9
+ :key="internalRow.attach.fileName"
10
+ >
11
+ <template v-if="internalRow.sysRowState !== sysRowState.delete">
12
+ <slot name='header' :row="internalRow"></slot>
13
+ <div class="attach" v-if="internalRow.attach.content === 'image'">
14
+ <img
15
+ @click="attachFileClick(internalRow.attach)"
16
+ :style="{ height: height, lineHeight: height, width: width }"
17
+ style="
18
+ border: 1px solid #ccc;
19
+ border-radius: 6px;
20
+ overflow: hidden;
21
+ margin: 0;
22
+ padding: 0;
23
+ "
24
+ :src="`${internalServiceUrl}/GetAttachFile/${internalRow.attach.id}?accessToken=${$store.getters.token}`"
25
+ />
26
+ <a-icon
27
+ class="attach-delete"
28
+ type="close-circle"
29
+ @click="removeAttach(internalRow.attach)"
30
+ v-if="edit === true"
31
+ />
32
+ <a-icon
33
+ class="attach-download"
34
+ type="download"
35
+ @click="downloadAttach(internalRow.attach)"
36
+ />
37
+ <a-icon
38
+ class="attach-view"
39
+ type="eye"
40
+ @click="viewAttach(internalRow.attach)"
41
+ />
42
+ </div>
43
+ <div class="attach" v-else>
44
+ <img
45
+ @click="attachFileClick(internalRow.attach)"
46
+ :style="{ height: height, lineHeight: height, width: width }"
47
+ :data-mimetype="internalRow.attach.contentType"
48
+ />
49
+ <a-icon
50
+ class="attach-delete"
51
+ type="close-circle"
52
+ v-if="edit === true"
53
+ @click="removeAttach(internalRow.attach)"
54
+ />
55
+ <a-icon
56
+ class="attach-download"
57
+ type="download"
58
+ @click="downloadAttach(internalRow.attach)"
59
+ />
60
+ <a-icon
61
+ class="attach-view"
62
+ type="eye"
63
+ @click="viewAttach(internalRow.attach)"
64
+ />
65
+ </div>
66
+ <div
67
+ :style="{ width: width }"
68
+ :title="internalRow.attach.name"
69
+ style="
70
+ overflow: hidden;
71
+ text-overflow: ellipsis;
72
+ white-space: nowrap;
73
+ "
74
+ >
75
+ {{ internalRow.attach.name }}
76
+ </div>
77
+ </template>
78
+ </div>
79
+ <a-upload
80
+ class="avatar-uploader"
81
+ :headers="uploadHeaders"
82
+ :action="uploadData.picAction"
83
+ :data="uploadData"
84
+ v-if="edit === true"
85
+ @change="handleAvatarSuccess"
86
+ :showUploadList="false"
87
+ :before-upload="beforeAvatarUpload"
88
+ >
89
+ <div
90
+ style="border: 1px solid #d9d9d9; border-radius: 6px"
91
+ :style="{ width: width, height: height, lineHeight: height }"
92
+ >
93
+ <a-icon
94
+ type="plus"
95
+ class="avatar-uploader-icon"
96
+ style="text-align: center"
97
+ :style="{ width: width, height: height, lineHeight: height }"
98
+ />
99
+ </div>
100
+ </a-upload>
101
+ <div v-if="edit !== true && showEmptyText && internalRows.length === 0">
102
+ 没有附件信息哦,请编辑添加附件信息
103
+ </div>
104
+ </div>
105
+ <VxeModal
106
+ v-model="dialogVisible"
107
+ show-zoom
108
+ transfer
109
+ resize
110
+ :height="550"
111
+ :width="800"
112
+ destroy-on-close
113
+ :fullscreen="dialogViewType == 'application/pdf'"
114
+ :z-index="999"
115
+ >
116
+ <template #title>
117
+ <span>{{ currentFileTitle }}</span>
118
+ </template>
119
+ <!-- pdf -->
120
+ <embed
121
+ v-if="dialogViewType == 'application/pdf'"
122
+ :src="dialogImageUrl"
123
+ :type="dialogViewType"
124
+ width="100%"
125
+ height="100%"
126
+ />
127
+ <!-- 普通图片 -->
128
+ <img width="90%" height="auto" :src="dialogImageUrl" v-else />
129
+ </VxeModal>
130
+ </div>
131
+ </template>
132
+
133
+ <script>
134
+ import { notification, Upload } from "ant-design-vue";
135
+ import { sysRowState } from "../../utils/enum";
136
+ import { Checkbox, Modal } from "vxe-table";
137
+ import { attachGetAttachUrlApi, attachSearchApi } from "../../utils/api";
138
+
139
+ export default {
140
+ name: "BasePictureCard",
141
+ components: {
142
+ VxeCheckbox: Checkbox,
143
+ "a-upload": Upload,
144
+ VxeModal: Modal,
145
+ },
146
+ data() {
147
+ return {
148
+ demo1: "",
149
+ demo2: "",
150
+ internalServiceUrl: "",
151
+ downFilePath: "",
152
+ downFileName: "",
153
+ isShowPdf: false,
154
+ pdfData: null,
155
+ internalUrls: [],
156
+ internalRows: [],
157
+ picName: [],
158
+ dialogImageUrl: "",
159
+ dialogViewType: "",
160
+ sysRowState: sysRowState,
161
+ dialogVisible: false,
162
+ uploadData: {
163
+ picType: "",
164
+ picAction: "",
165
+ resId: "",
166
+ },
167
+ uploadHeaders: {
168
+ Authorization: null,
169
+ },
170
+ currentFileTitle: ''
171
+ };
172
+ },
173
+ props: {
174
+ isStyle: {
175
+ type: Boolean,
176
+ default: false,
177
+ },
178
+ showEmptyText: {
179
+ type: Boolean,
180
+ default: true,
181
+ },
182
+ picType: {
183
+ type: String,
184
+ default: "cust",
185
+ },
186
+ value: {
187
+ type: String,
188
+ },
189
+ resId: {
190
+ type: String,
191
+ },
192
+ dataName: {
193
+ type: String,
194
+ },
195
+ edit: {
196
+ // 列信息
197
+ type: Boolean,
198
+ },
199
+ limitSize: {
200
+ // 限制上传大小
201
+ type: Number,
202
+ default: 5,
203
+ },
204
+ limitType: {
205
+ // 限制上传类型
206
+ type: Array,
207
+ default: () => {
208
+ return [];
209
+ },
210
+ },
211
+ formRow: {
212
+ type: Object,
213
+ default: () => {
214
+ return {};
215
+ },
216
+ },
217
+ width: {
218
+ type: String,
219
+ default: "100px",
220
+ },
221
+ height: {
222
+ type: String,
223
+ default: "100px",
224
+ },
225
+ rows: {
226
+ // 表格数据
227
+ type: Array,
228
+ default: function () {
229
+ return [];
230
+ },
231
+ },
232
+ cols: {
233
+ // 表格列信息
234
+ type: Array,
235
+ default: function () {
236
+ return [];
237
+ },
238
+ },
239
+ formState: {
240
+ // 表格列信息
241
+ type: String,
242
+ default: "",
243
+ },
244
+ },
245
+ watch: {
246
+ rows: {
247
+ handler: function (newVal) {
248
+ this.getAttachInfo(newVal);
249
+ },
250
+ deep: true,
251
+ },
252
+ resId: {
253
+ handler: function (newVal) {
254
+ this.uploadData.resId = newVal;
255
+ },
256
+ },
257
+ },
258
+ created() {
259
+ },
260
+ mounted() {
261
+ // 请求头加入token
262
+ this.uploadHeaders.Authorization = `Bearer ${this.$store.getters.token}`;
263
+
264
+ this.internalServiceUrl = attachGetAttachUrlApi();
265
+ this.uploadData.picType = this.picType;
266
+ this.uploadData.resId = this.resId;
267
+ this.uploadData.picAction = this.internalServiceUrl + "/UploadAttach";
268
+ this.getAttachInfo(this.rows);
269
+ },
270
+ methods: {
271
+ getCurrentToken() {
272
+ return this.$store.getters.token;
273
+ },
274
+ /**
275
+ * 获取附件信息
276
+ */
277
+ getAttachInfo(newRows) {
278
+ let attachIds = [];
279
+ for (let i = 0; i < newRows.length; i++) {
280
+ if (newRows[i].attach) {
281
+ continue;
282
+ }
283
+ attachIds.push(newRows[i].attachId);
284
+ newRows[i].attach = {
285
+ fileName: "",
286
+ contentType: "",
287
+ content: "",
288
+ name: "",
289
+ id: newRows[i].attachId,
290
+ };
291
+ }
292
+ if (attachIds.length == 0) {
293
+ this.internalRows = newRows;
294
+ return;
295
+ }
296
+ let postData = {
297
+ fields: "id,fileName,contentType,name,content,isDefault",
298
+ begin: 1,
299
+ size: 0,
300
+ exp: "id in (",
301
+ };
302
+ for (let i = 0; i < attachIds.length; i++) {
303
+ postData.exp = postData.exp + attachIds[i] + ",";
304
+ }
305
+ let vm = this;
306
+ postData.exp = postData.exp.substr(0, postData.exp.length - 1) + ")";
307
+ attachSearchApi(postData)
308
+ .then((responseData) => {
309
+ for (let i = 0; i < responseData.content.length; i++) {
310
+ for (let x = 0; x < newRows.length; x++) {
311
+ if (responseData.content[i].id === newRows[x].attachId) {
312
+ newRows[x].attach.fileName = responseData.content[i].fileName;
313
+ newRows[x].attach.name = responseData.content[i].name;
314
+ newRows[x].attach.content = responseData.content[i].content;
315
+ newRows[x].attach.contentType =
316
+ responseData.content[i].contentType;
317
+ // newRows[x].attach.isDefault = false
318
+ break;
319
+ }
320
+ }
321
+ }
322
+ vm.internalRows = newRows;
323
+ })
324
+ .catch(() => {});
325
+ },
326
+ attachFileClick(attachFile) {},
327
+ handleAvatarSuccess(info) {
328
+ if (info.file.status == "done") {
329
+ let addRow = {
330
+ attachId: info.file.response.content.id,
331
+ sysRowState: sysRowState.add,
332
+ attach: info.file.response.content,
333
+ };
334
+
335
+ this.internalRows.push(addRow);
336
+ let tempField;
337
+ for (let i = 0; i < this.cols.length; i++) {
338
+ // 赋值关联字段数据
339
+ let tempValue = addRow;
340
+ tempField = this.cols[i].field;
341
+ if (this.cols[i].isAuto) {
342
+ tempValue[tempField] = this.$store.getters.newId() + "";
343
+ continue;
344
+ }
345
+ if (
346
+ this.cols[i].controlType === "text" &&
347
+ this.cols[i].linkValueField !== null &&
348
+ this.cols[i].linkValueField !== "" &&
349
+ this.cols[i].linkValueField !== undefined
350
+ ) {
351
+ tempValue[tempField] = this.formRow[this.cols[i].linkValueField];
352
+ }
353
+ }
354
+ this.$emit(
355
+ "add",
356
+ this.dataName,
357
+ info.file.response.content
358
+ );
359
+ }
360
+ },
361
+ beforeAvatarUpload(file) {
362
+ // const isPic = file.type === 'image/jpeg' || file.type === 'image/png'
363
+ if (file.size / 1024 / 1024 > this.limitSize) {
364
+ notification.error({
365
+ message: "错误",
366
+ description: "上传图片大小不能超过 " + this.limitSize + "MB!",
367
+ });
368
+ }
369
+ if (this.limitType.length > 0 && !this.limitType[file.type]) {
370
+ notification.error({
371
+ message: "错误",
372
+ description: "上传附件格式错误!",
373
+ });
374
+ }
375
+ return true;
376
+ },
377
+ handleRemove(file, fileList) {
378
+ // this.dialogVisible = !this.dialogVisible
379
+ // alert(this.dialogVisible)
380
+ this.internalUrls = fileList;
381
+ this.$emit("remove", this.dataName, file.response.data);
382
+ // this.$emit('remove', this.dataName, file.response.data)
383
+ },
384
+ circleAttach(attachFile, internalRow) {
385
+ let vm = this;
386
+ // if(internalRow.isDefault == true){
387
+ this.internalRows.forEach((element) => {
388
+ if (element.id !== internalRow.id) {
389
+ element.isDefault = false;
390
+ }
391
+ });
392
+ // }
393
+ },
394
+ removeAttach(attachFile) {
395
+ for (let i = 0; i < this.internalRows.length; i++) {
396
+ if (this.internalRows[i].attachId === attachFile.id) {
397
+ if (this.internalRows[i].sysRowState === sysRowState.add) {
398
+ this.internalRows.splice(i, 1);
399
+ } else {
400
+ this.$set(this.internalRows[i], "sysRowState", sysRowState.delete);
401
+ }
402
+ break;
403
+ }
404
+ }
405
+ this.$emit("remove", attachFile.id);
406
+ },
407
+ downloadAttach(attachFile) {
408
+ window.open(
409
+ this.internalServiceUrl +
410
+ "/DownAttachFile/" +
411
+ attachFile.id +
412
+ `?accessToken=${this.$store.getters.token}`
413
+ );
414
+ },
415
+ /**
416
+ * 查看附件
417
+ */
418
+ viewAttach(attachFile) {
419
+ if (attachFile.contentType === "application/pdf") {
420
+ this.dialogImageUrl = `${this.internalServiceUrl}/GetAttachFile/${attachFile.id}?accessToken=${this.$store.getters.token}`;
421
+ this.dialogViewType = attachFile.contentType;
422
+ this.dialogVisible = true;
423
+ } else if (attachFile.content === "image") {
424
+ this.dialogImageUrl = `${this.internalServiceUrl}/GetAttachFile/${attachFile.id}?accessToken=${this.$store.getters.token}`;
425
+ this.dialogViewType = attachFile.contentType;
426
+ this.dialogVisible = true;
427
+ }
428
+ this.currentFileTitle = attachFile.name
429
+ },
430
+ closePdf() {
431
+ this.isShowPdf = false;
432
+ },
433
+ },
434
+ };
435
+ </script>
436
+
437
+ <style lang="scss" scoped>
438
+ .file-card {
439
+ display: flex;
440
+ flex-flow: row wrap;
441
+ margin: 0 0 5px 5px;
442
+
443
+ .attach-wrapper {
444
+ .attach {
445
+ position: relative;
446
+ margin-right: 5px;
447
+
448
+ .attach-delete {
449
+ position: absolute;
450
+ top: -2px;
451
+ right: -4px;
452
+ opacity: 0;
453
+ font-size: 20px;
454
+ background-color: red;
455
+ }
456
+
457
+ .attach-delete:hover {
458
+ cursor: pointer;
459
+ }
460
+
461
+ .attach-download {
462
+ position: absolute;
463
+ bottom: 10px;
464
+ left: 4px;
465
+ opacity: 0;
466
+ font-size: 18px;
467
+ font-weight: bolder;
468
+ border: 1px solid #ccc;
469
+ border-radius: 50%;
470
+ border-color: transparent;
471
+ //background-color: rgb(255, 1, 1);
472
+ color: #000;
473
+ }
474
+
475
+ .attach-download:hover {
476
+ cursor: pointer;
477
+ color: rgb(189, 8, 8);
478
+ }
479
+
480
+ .attach-view {
481
+ position: absolute;
482
+ bottom: 10px;
483
+ right: 4px;
484
+ opacity: 0;
485
+ font-size: 18px;
486
+ font-weight: bolder;
487
+ border: 1px solid #ccc;
488
+ border-radius: 50%;
489
+ border-color: transparent;
490
+ //background-color: #666;
491
+ color: #000;
492
+ }
493
+
494
+ .attach-circle {
495
+ position: absolute;
496
+ // bottom: 10px;
497
+ top: 2px;
498
+ left: 4px;
499
+ opacity: 0;
500
+ }
501
+
502
+ .attach-view:hover {
503
+ cursor: pointer;
504
+ color: rgb(189, 8, 8);
505
+ }
506
+ }
507
+
508
+ .attach:hover > .attach-delete {
509
+ opacity: 0.8;
510
+ }
511
+
512
+ .attach:hover > .attach-download {
513
+ opacity: 0.7;
514
+ }
515
+
516
+ .attach:hover > .attach-view {
517
+ opacity: 0.7;
518
+ }
519
+
520
+ .attach:hover > .attach-circle {
521
+ opacity: 0.9;
522
+ }
523
+ }
524
+ }
525
+
526
+ .avatar-uploader .el-upload {
527
+ border: 1px solid #d9d9d9;
528
+
529
+ border-radius: 6px;
530
+ cursor: pointer;
531
+ position: relative;
532
+ overflow: hidden;
533
+ }
534
+
535
+ .avatar-uploader .el-upload:hover {
536
+ border-color: #409eff;
537
+ }
538
+
539
+ .avatar-uploader-icon {
540
+ font-size: 28px;
541
+ color: #8c939d;
542
+ // width: 178px;
543
+ // height: 178px;
544
+ line-height: 178px;
545
+ text-align: center;
546
+ }
547
+
548
+ .avatar {
549
+ // width: 178px;
550
+ // height: 178px;
551
+ display: block;
552
+ }
553
+
554
+ .el-upload-list__item is-success {
555
+ float: left;
556
+ }
557
+ .currentHeight {
558
+ display: flex;
559
+ align-items: center;
560
+ }
561
+ </style>