doway-coms 2.10.24 → 2.10.26

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "doway-coms",
3
- "version": "2.10.24",
3
+ "version": "2.10.26",
4
4
  "description": "doway组件库",
5
5
  "author": "dowaysoft",
6
6
  "main": "packages/index.js",
@@ -1,5 +1,7 @@
1
1
  <template>
2
- <div style="display: inline-block">
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> -->
3
5
  <div class="file-card" :class="isStyle? 'currentHeight' : ''">
4
6
  <div
5
7
  class="attach-wrapper"
@@ -12,8 +14,8 @@
12
14
  <slot name='header' :row="internalRow"></slot>
13
15
  <div class="attach" v-if="internalRow.attach.content === 'image'">
14
16
  <img
15
- @click="attachFileClick(internalRow.attach)"
16
- :style="{ height: height, lineHeight: height, width: width }"
17
+ @click="attachFileClick(internalRow)"
18
+ :style="{ height: height+'px', lineHeight: height+'px', width: width+'px' }"
17
19
  style="
18
20
  border: 1px solid #ccc;
19
21
  border-radius: 6px;
@@ -42,8 +44,8 @@
42
44
  </div>
43
45
  <div class="attach" v-else-if="internalRow.attach.contentType == 'application/pdf'">
44
46
  <img
45
- @click="attachFileClick(internalRow.attach)"
46
- :style="{ height: height, lineHeight: height, width: width }"
47
+ @click="attachFileClick(internalRow)"
48
+ :style="{ height: height+'px', lineHeight: height+'px', width: width+'px' }"
47
49
  src="../../styles/icon/pdf_file.svg"
48
50
  />
49
51
  <a-icon
@@ -65,8 +67,8 @@
65
67
  </div>
66
68
  <div class="attach" v-else>
67
69
  <img
68
- @click="attachFileClick(internalRow.attach)"
69
- :style="{ height: height, lineHeight: height, width: width }"
70
+ @click="attachFileClick(internalRow)"
71
+ :style="{ height: height+'px', lineHeight: height+'px', width: width +'px'}"
70
72
  src="../../styles/icon/uploaded_file.svg"
71
73
  :data-mimetype="internalRow.attach.contentType"
72
74
  />
@@ -95,31 +97,35 @@
95
97
  </div>
96
98
  </template>
97
99
  </div>
98
- <a-upload
100
+ <a-spin tip="上传中" :spinning="uploading">
101
+ <div v-show="edit===true" @click="selectClick"
102
+ style="border: 1px solid #d9d9d9; border-radius: 6px"
103
+ :style="{ width: width+'px', height: height+'px' }"
104
+ >
105
+
106
+ <!-- <span style="cursor: default;">&nbsp;</span> -->
107
+ <a-upload
99
108
  class="avatar-uploader"
100
109
  :headers="uploadHeaders"
101
110
  :action="uploadData.picAction"
102
111
  :data="uploadData"
103
- v-if="edit === true"
104
112
  @change="handleAvatarSuccess"
105
113
  :showUploadList="false"
106
114
  :fileList="uploadFileList"
107
115
  :before-upload="beforeAvatarUpload"
108
116
  >
109
- <div
110
- style="border: 1px solid #d9d9d9; border-radius: 6px"
111
- :style="{ width: width, height: height, lineHeight: height }"
112
- >
113
117
  <a-icon
114
118
  type="plus"
115
119
  class="avatar-uploader-icon"
116
- style="text-align: center"
117
- :style="{ width: width, height: height, lineHeight: height }"
120
+ :style="{ width: width+'px', height: height+'px', lineHeight: height+'px' }"
121
+ style="text-align: center;"
118
122
  />
119
-
120
- </div>
121
- </a-upload>
122
- <div ref="pasteFileView">黏贴</div>
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
+
123
129
  <div v-if="edit !== true && showEmptyText && internalRows.length === 0">
124
130
  没有附件信息哦,请编辑添加附件信息
125
131
  </div>
@@ -153,8 +159,9 @@
153
159
  </template>
154
160
 
155
161
  <script>
156
- import { notification, Upload } from "ant-design-vue";
162
+ import { notification, Upload,Spin } from "ant-design-vue";
157
163
  import { sysRowState } from "../../utils/enum";
164
+ import clickoutside from '../../directive/clickoutside'
158
165
  import { Checkbox, Modal } from "vxe-table";
159
166
  import { attachGetAttachUrlApi, attachSearchApi } from "../../utils/api";
160
167
  import request from '../../utils/request'
@@ -164,9 +171,15 @@ export default {
164
171
  VxeCheckbox: Checkbox,
165
172
  "a-upload": Upload,
166
173
  VxeModal: Modal,
174
+ 'a-spin':Spin
175
+ },
176
+ directives: {
177
+ clickoutside
167
178
  },
168
179
  data() {
169
180
  return {
181
+ uploading:false,
182
+ currentSelectId:null,
170
183
  uploadFileList:[],
171
184
  demo1: "",
172
185
  demo2: "",
@@ -239,12 +252,12 @@ export default {
239
252
  },
240
253
  },
241
254
  width: {
242
- type: String,
243
- default: "100px",
255
+ type: Number,
256
+ default: 100,
244
257
  },
245
258
  height: {
246
- type: String,
247
- default: "100px",
259
+ type: Number,
260
+ default: 100,
248
261
  },
249
262
  rows: {
250
263
  // 表格数据
@@ -291,7 +304,7 @@ export default {
291
304
  this.uploadData.picAction = this.internalServiceUrl + "/UploadAttach";
292
305
  this.getAttachInfo(this.rows);
293
306
 
294
- this.$refs.pasteFileView.addEventListener('paste', async (e) => {
307
+ this.$refs.updateLoadContentView.addEventListener('paste', async (e) => {
295
308
  e.preventDefault();
296
309
  await this.pasteFileClick(e)
297
310
  })
@@ -353,7 +366,9 @@ export default {
353
366
  })
354
367
  .catch(() => {});
355
368
  },
356
- attachFileClick(attachFile) {},
369
+ attachFileClick(attachFile) {
370
+ // console.debug('attachFileClick',attachFile)
371
+ },
357
372
  handleAvatarSuccess(info) {
358
373
  if (info.file.status == "done") {
359
374
  let addRow = {
@@ -465,17 +480,31 @@ export default {
465
480
  * 黏贴附件
466
481
  */
467
482
  async pasteFileClick(e){
468
- console.debug('e',e)
483
+ if(this.currentSelectId!=='empty'){
484
+ return
485
+ }
486
+ // console.debug('e',e)
469
487
  const items = e.clipboardData.files;
488
+ if(items.length===0){
489
+ return
490
+ }
470
491
  console.debug('items',items)
492
+ this.uploading = true
493
+ try
494
+ {
471
495
  for (const item of items) {
472
- if (item.type.startsWith('image/') || item.type.startsWith('application/')) {
496
+ // if (item.type.startsWith('image/') || item.type.startsWith('application/')) {
473
497
  // this.pasteFile = URL.createObjectURL(item)
474
498
  //'复制文件'+this.$store.getters.newId() +'.png'
475
- let type = item.type
476
- this.pasteFile = new File([item],`复制文件${this.$store.getters.newId()}.${type.split('/')[1]}` , { type });
477
- this.uploadPasteFile()
478
- return
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}})
479
508
  // console.debug('file',file)
480
509
  // this.uploadFileList = [file];
481
510
  // const reader = new FileReader();
@@ -484,20 +513,31 @@ export default {
484
513
  // // this.imageSrc = e.target.result;
485
514
  // };
486
515
  // reader.readAsDataURL(blob);
487
- }
516
+ // }
488
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()
489
538
  },
490
- uploadPasteFile(){
491
- const formData = new FormData();
492
- formData.append('file', this.pasteFile)
493
- formData.append('picType', this.uploadData.picType)
494
- formData.append('resId', this.uploadData.resId)
495
- request({url:this.uploadData.picAction,method:'post',data:formData,headers:{'Content-Type': 'multipart/form-data'}})
496
- .then(res=>{
497
- this.handleAvatarSuccess({file:{status:'done',response:res}})
498
- }).catch(err=>{
499
- console.debug(err)
500
- })
539
+ async uploadPasteFile(){
540
+
501
541
  }
502
542
  },
503
543
  };
@@ -0,0 +1,44 @@
1
+ const clickoutsideContext = '@@clickoutsideContext'
2
+
3
+ export default {
4
+ /*
5
+ @param el 指令所绑定的元素
6
+ @param binding {Object}
7
+ @param vnode vue编译生成的虚拟节点
8
+ */
9
+ bind(el, binding, vnode) {
10
+ const documentHandler = function(e) {
11
+ // console.log(el)
12
+ // console.log(e.target);
13
+ // console.log(vnode);
14
+ // console.log(binding);
15
+
16
+ if (!vnode.context || el.contains(e.target)) {
17
+ return false
18
+ }
19
+ if (binding.expression) {
20
+ vnode.context[el[clickoutsideContext].methodName](e)
21
+ } else {
22
+ el[clickoutsideContext].bindingFn(e)
23
+ }
24
+ }
25
+ el[clickoutsideContext] = {
26
+ documentHandler,
27
+ methodName: binding.expression,
28
+ bindingFn: binding.value
29
+ }
30
+ setTimeout(() => {
31
+ document.addEventListener('click', documentHandler)
32
+ }, 0)
33
+ },
34
+ update(el, binding) {
35
+ el[clickoutsideContext].methodName = binding.expression
36
+ el[clickoutsideContext].bindingFn = binding.value
37
+ },
38
+ unbind(el) {
39
+ document.removeEventListener(
40
+ 'click',
41
+ el[clickoutsideContext].documentHandler
42
+ )
43
+ }
44
+ }