meixioacomponent 0.2.43 → 0.2.44

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": "meixioacomponent",
3
- "version": "0.2.43",
3
+ "version": "0.2.44",
4
4
  "private": false,
5
5
  "author": "YuRi",
6
6
  "main": "lib/meixioacomponent.umd.min.js",
@@ -1,5 +1,9 @@
1
1
  <template>
2
- <div class="base-upload-item-wrap" :class="[`${shape}`]">
2
+ <div
3
+ class="base-upload-item-wrap"
4
+ :class="[`${shape}`]"
5
+ v-on:paste="onPasteFile"
6
+ >
3
7
  <div class="type-upload" v-if="type == 'upload'">
4
8
  <input
5
9
  type="file"
@@ -14,12 +18,31 @@
14
18
  :color="`s`"
15
19
  :event="true"
16
20
  :size="`l`"
17
- :name="`meixicomponenticon-plus`"
18
21
  class="upload-icon"
22
+ v-if="!isUploadProImg"
19
23
  @iconClick="clickFile"
24
+ :name="`meixicomponenticon-plus`"
20
25
  ></base-icon>
26
+
27
+ <div class="is-upload-pro-img" v-if="isUploadProImg && !imgSrc">
28
+ <base-icon
29
+ class="upload-icon"
30
+ :iconClass="`element`"
31
+ :name="`el-icon-upload`"
32
+ ></base-icon>
33
+ <div class="upload-notic-wrap">
34
+ <span @click="clickFile">点击上传<br /></span
35
+ ><span class="primary-color"
36
+ >或点击该处后Ctrl+V 黏贴QQ或微信截图</span
37
+ >
38
+ </div>
39
+ </div>
21
40
  </div>
22
- <div v-else-if="type == 'img'" class="type-pre-views">
41
+
42
+ <div
43
+ v-if="(isUploadProImg || type == 'img') && imgSrc"
44
+ class="type-pre-views"
45
+ >
23
46
  <div class="handleUploadItem">
24
47
  <base-icon
25
48
  :size="`l`"
@@ -36,12 +59,15 @@
36
59
 
37
60
  <script>
38
61
  import baseImgVue from "../baseImg/baseImg.vue";
39
- //
62
+
40
63
  import { baseUploadMixins } from "./mixins";
41
64
  export default {
42
65
  name: "baseUploadItem",
43
66
  data() {
44
67
  return {};
68
+ },
69
+ created() {
70
+
45
71
  },
46
72
  mixins: [baseUploadMixins],
47
73
  components: {
@@ -80,18 +106,27 @@ export default {
80
106
  },
81
107
  },
82
108
  computed: {
109
+
83
110
  module: {
84
111
  get() {
85
112
  return this.$props.value;
86
113
  },
87
- set(val) {},
114
+ set(val) {
115
+ this.$emit("input", val);
116
+ },
88
117
  },
118
+
89
119
  imgSrc() {
90
- if (!this.uploadItem.url) {
91
- return "";
120
+ if (this.isGroup) {
121
+ if (!this.uploadItem?.url) {
122
+ return "";
123
+ }
124
+ return this.uploadItem.url;
125
+ } else {
126
+ return this.module[0]?.url;
92
127
  }
93
- return this.uploadItem.url;
94
128
  },
129
+
95
130
  accept() {
96
131
  let accept = "";
97
132
  let fileType = this.$props.fileType;
@@ -107,11 +142,25 @@ export default {
107
142
  }
108
143
  return accept;
109
144
  },
145
+
146
+ isUploadProImg() {
147
+ let props = this.$props;
148
+ return (
149
+ props.shape == "pro" &&
150
+ props.fileType == "img" &&
151
+ props.uploadType == "single"
152
+ );
153
+ },
154
+
155
+ isGroup() {
156
+ return this.$parent.$options.name == "baseUpload";
157
+ },
110
158
  },
111
159
  methods: {
112
160
  clickFile() {
113
161
  this.$refs.inputFile.click();
114
162
  },
163
+
115
164
  async returnFiles(files) {
116
165
  let list = [];
117
166
  for (let i = 0; i < files.length; i++) {
@@ -124,18 +173,48 @@ export default {
124
173
  }
125
174
  return list;
126
175
  },
176
+
127
177
  async valueChange(e) {
128
178
  let files = e.target.files;
129
179
  let list = await this.returnFiles(files);
130
- if (this.$parent.$options.name == "baseUpload") {
180
+ this.emitEvent(list);
181
+ this.$refs.inputFile.value = "";
182
+ },
183
+
184
+ emitEvent(list) {
185
+ if (this.isGroup) {
131
186
  this.$emit("inputChange", list);
132
187
  } else {
133
188
  this.inputChange(list);
134
189
  }
135
- this.$refs.inputFile.value = "";
136
190
  },
191
+
137
192
  handleDeleteUploadItem() {
138
- this.$emit("handleDeleteUploadItem");
193
+ if (this.isGroup) {
194
+ this.$emit("handleDeleteUploadItem");
195
+ } else {
196
+ this.module = [];
197
+ }
198
+ },
199
+
200
+ async onPasteFile() {
201
+ const items = (event.clipboardData || window.clipboardData).items;
202
+ const rowList = [];
203
+ if (this.fileType == "img") {
204
+ for (var i = 0; i < items.length; i++) {
205
+ if (items[i].type.indexOf("image") !== -1) {
206
+ let file = items[i].getAsFile(); // getAsFile 如果拖拽项的对象是一个文件, 则返回 File 对象; 否则返回 null
207
+ rowList.push(file);
208
+ }
209
+ }
210
+ } else {
211
+ for (var i = 0; i < items.length; i++) {
212
+ let file = items[i].getAsFile(); // getAsFile 如果拖拽项的对象是一个文件, 则返回 File 对象; 否则返回 null
213
+ rowList.push(file);
214
+ }
215
+ }
216
+ let list = await this.returnFiles(rowList);
217
+ this.emitEvent(list);
139
218
  },
140
219
  },
141
220
  };
@@ -143,8 +222,9 @@ export default {
143
222
 
144
223
  <style lang="less" scoped>
145
224
  .base-upload-item-wrap {
146
- margin: var(--margin-4);
147
225
  margin-left: 0px;
226
+ position: relative;
227
+ margin: var(--margin-4);
148
228
  border-radius: calc(var(--radius) * 2);
149
229
  border: 1px dashed var(--color-border-d);
150
230
  .type-upload {
@@ -155,6 +235,33 @@ export default {
155
235
  align-items: center;
156
236
  flex-flow: row nowrap;
157
237
  justify-content: center;
238
+
239
+ .is-upload-pro-img {
240
+ width: 100%;
241
+ height: 100%;
242
+ display: flex;
243
+ cursor: default;
244
+ align-items: center;
245
+ flex-flow: column nowrap;
246
+ justify-content: center;
247
+
248
+ .upload-notic-wrap {
249
+ text-align: center;
250
+ span {
251
+ display: block;
252
+ cursor: pointer;
253
+ color: var(--font-color-s);
254
+ font-size: var(--font-size-s);
255
+ &:hover {
256
+ color: var(--color-primary);
257
+ }
258
+ }
259
+ .primary-color {
260
+ margin-top: var(--margin-4);
261
+ color: var(--color-primary);
262
+ }
263
+ }
264
+ }
158
265
  .upload-icon {
159
266
  width: 60px;
160
267
  height: 60px;
@@ -164,9 +271,11 @@ export default {
164
271
  }
165
272
  }
166
273
  .type-pre-views {
274
+ top: 0px;
275
+ left: 0px;
167
276
  width: 100%;
168
277
  height: 100%;
169
- position: relative;
278
+ position: absolute;
170
279
  &:hover {
171
280
  .handleUploadItem {
172
281
  display: block;
@@ -202,4 +311,12 @@ export default {
202
311
  width: 100px;
203
312
  height: 100px;
204
313
  }
314
+ .pro {
315
+ width: 100%;
316
+ height: 100%;
317
+ display: flex;
318
+ align-items: center;
319
+ flex-flow: row nowrap;
320
+ justify-content: center;
321
+ }
205
322
  </style>