doway-coms 2.11.11 → 2.11.13

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