meixioacomponent 0.2.43 → 0.2.46
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/lib/meixioacomponent.common.js +265 -107
- package/lib/meixioacomponent.umd.js +265 -107
- package/lib/meixioacomponent.umd.min.js +17 -17
- package/package.json +1 -1
- package/packages/components/base/baseUpload/baseUploadItem.vue +128 -13
- package/packages/components/proForm/proFormWrap/pro_form_wrap.vue +40 -3
package/package.json
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div
|
|
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
|
-
|
|
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,13 +59,14 @@
|
|
|
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 {};
|
|
45
68
|
},
|
|
69
|
+
created() {},
|
|
46
70
|
mixins: [baseUploadMixins],
|
|
47
71
|
components: {
|
|
48
72
|
baseImgVue,
|
|
@@ -84,14 +108,22 @@ export default {
|
|
|
84
108
|
get() {
|
|
85
109
|
return this.$props.value;
|
|
86
110
|
},
|
|
87
|
-
set(val) {
|
|
111
|
+
set(val) {
|
|
112
|
+
this.$emit("input", val);
|
|
113
|
+
},
|
|
88
114
|
},
|
|
115
|
+
|
|
89
116
|
imgSrc() {
|
|
90
|
-
if (
|
|
91
|
-
|
|
117
|
+
if (this.isGroup) {
|
|
118
|
+
if (!this.uploadItem?.url) {
|
|
119
|
+
return "";
|
|
120
|
+
}
|
|
121
|
+
return this.uploadItem.url;
|
|
122
|
+
} else {
|
|
123
|
+
return this.module[0]?.url;
|
|
92
124
|
}
|
|
93
|
-
return this.uploadItem.url;
|
|
94
125
|
},
|
|
126
|
+
|
|
95
127
|
accept() {
|
|
96
128
|
let accept = "";
|
|
97
129
|
let fileType = this.$props.fileType;
|
|
@@ -107,11 +139,25 @@ export default {
|
|
|
107
139
|
}
|
|
108
140
|
return accept;
|
|
109
141
|
},
|
|
142
|
+
|
|
143
|
+
isUploadProImg() {
|
|
144
|
+
let props = this.$props;
|
|
145
|
+
return (
|
|
146
|
+
props.shape == "pro" &&
|
|
147
|
+
props.fileType == "img" &&
|
|
148
|
+
props.uploadType == "single"
|
|
149
|
+
);
|
|
150
|
+
},
|
|
151
|
+
|
|
152
|
+
isGroup() {
|
|
153
|
+
return this.$parent.$options.name == "baseUpload";
|
|
154
|
+
},
|
|
110
155
|
},
|
|
111
156
|
methods: {
|
|
112
157
|
clickFile() {
|
|
113
158
|
this.$refs.inputFile.click();
|
|
114
159
|
},
|
|
160
|
+
|
|
115
161
|
async returnFiles(files) {
|
|
116
162
|
let list = [];
|
|
117
163
|
for (let i = 0; i < files.length; i++) {
|
|
@@ -124,18 +170,48 @@ export default {
|
|
|
124
170
|
}
|
|
125
171
|
return list;
|
|
126
172
|
},
|
|
173
|
+
|
|
127
174
|
async valueChange(e) {
|
|
128
175
|
let files = e.target.files;
|
|
129
176
|
let list = await this.returnFiles(files);
|
|
130
|
-
|
|
177
|
+
this.emitEvent(list);
|
|
178
|
+
this.$refs.inputFile.value = "";
|
|
179
|
+
},
|
|
180
|
+
|
|
181
|
+
emitEvent(list) {
|
|
182
|
+
if (this.isGroup) {
|
|
131
183
|
this.$emit("inputChange", list);
|
|
132
184
|
} else {
|
|
133
185
|
this.inputChange(list);
|
|
134
186
|
}
|
|
135
|
-
this.$refs.inputFile.value = "";
|
|
136
187
|
},
|
|
188
|
+
|
|
137
189
|
handleDeleteUploadItem() {
|
|
138
|
-
this
|
|
190
|
+
if (this.isGroup) {
|
|
191
|
+
this.$emit("handleDeleteUploadItem");
|
|
192
|
+
} else {
|
|
193
|
+
this.module = [];
|
|
194
|
+
}
|
|
195
|
+
},
|
|
196
|
+
|
|
197
|
+
async onPasteFile() {
|
|
198
|
+
const items = (event.clipboardData || window.clipboardData).items;
|
|
199
|
+
const rowList = [];
|
|
200
|
+
if (this.fileType == "img") {
|
|
201
|
+
for (var i = 0; i < items.length; i++) {
|
|
202
|
+
if (items[i].type.indexOf("image") !== -1) {
|
|
203
|
+
let file = items[i].getAsFile(); // getAsFile 如果拖拽项的对象是一个文件, 则返回 File 对象; 否则返回 null
|
|
204
|
+
rowList.push(file);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
} else {
|
|
208
|
+
for (var i = 0; i < items.length; i++) {
|
|
209
|
+
let file = items[i].getAsFile(); // getAsFile 如果拖拽项的对象是一个文件, 则返回 File 对象; 否则返回 null
|
|
210
|
+
rowList.push(file);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
let list = await this.returnFiles(rowList);
|
|
214
|
+
this.emitEvent(list);
|
|
139
215
|
},
|
|
140
216
|
},
|
|
141
217
|
};
|
|
@@ -143,8 +219,9 @@ export default {
|
|
|
143
219
|
|
|
144
220
|
<style lang="less" scoped>
|
|
145
221
|
.base-upload-item-wrap {
|
|
146
|
-
margin: var(--margin-4);
|
|
147
222
|
margin-left: 0px;
|
|
223
|
+
position: relative;
|
|
224
|
+
margin: var(--margin-4);
|
|
148
225
|
border-radius: calc(var(--radius) * 2);
|
|
149
226
|
border: 1px dashed var(--color-border-d);
|
|
150
227
|
.type-upload {
|
|
@@ -155,6 +232,34 @@ export default {
|
|
|
155
232
|
align-items: center;
|
|
156
233
|
flex-flow: row nowrap;
|
|
157
234
|
justify-content: center;
|
|
235
|
+
|
|
236
|
+
.is-upload-pro-img {
|
|
237
|
+
width: 100%;
|
|
238
|
+
height: 100%;
|
|
239
|
+
display: flex;
|
|
240
|
+
cursor: default;
|
|
241
|
+
align-items: center;
|
|
242
|
+
flex-flow: column nowrap;
|
|
243
|
+
justify-content: center;
|
|
244
|
+
|
|
245
|
+
.upload-notic-wrap {
|
|
246
|
+
text-align: center;
|
|
247
|
+
span {
|
|
248
|
+
display: block;
|
|
249
|
+
cursor: pointer;
|
|
250
|
+
color: var(--font-color-s);
|
|
251
|
+
font-size: var(--font-size-s);
|
|
252
|
+
line-height: 12px !important;
|
|
253
|
+
&:hover {
|
|
254
|
+
color: var(--color-primary);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
.primary-color {
|
|
258
|
+
margin-top: var(--margin-4);
|
|
259
|
+
color: var(--color-primary);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
}
|
|
158
263
|
.upload-icon {
|
|
159
264
|
width: 60px;
|
|
160
265
|
height: 60px;
|
|
@@ -164,9 +269,11 @@ export default {
|
|
|
164
269
|
}
|
|
165
270
|
}
|
|
166
271
|
.type-pre-views {
|
|
272
|
+
top: 0px;
|
|
273
|
+
left: 0px;
|
|
167
274
|
width: 100%;
|
|
168
275
|
height: 100%;
|
|
169
|
-
position:
|
|
276
|
+
position: absolute;
|
|
170
277
|
&:hover {
|
|
171
278
|
.handleUploadItem {
|
|
172
279
|
display: block;
|
|
@@ -202,4 +309,12 @@ export default {
|
|
|
202
309
|
width: 100px;
|
|
203
310
|
height: 100px;
|
|
204
311
|
}
|
|
312
|
+
.pro {
|
|
313
|
+
width: 100%;
|
|
314
|
+
height: 100%;
|
|
315
|
+
display: flex;
|
|
316
|
+
align-items: center;
|
|
317
|
+
flex-flow: row nowrap;
|
|
318
|
+
justify-content: center;
|
|
319
|
+
}
|
|
205
320
|
</style>
|
|
@@ -19,14 +19,22 @@
|
|
|
19
19
|
<pro_formVue
|
|
20
20
|
:size="size"
|
|
21
21
|
ref="proForm"
|
|
22
|
-
:form="
|
|
22
|
+
:form="form"
|
|
23
23
|
:rules="rules"
|
|
24
24
|
:footer="false"
|
|
25
|
-
|
|
25
|
+
v-model="formList"
|
|
26
26
|
:rowNumber="rowNumber"
|
|
27
27
|
:labelWidth="labelWidth"
|
|
28
28
|
@formItemConfirm="formItemConfirm"
|
|
29
|
-
></pro_formVue>
|
|
29
|
+
></pro_formVue>
|
|
30
|
+
<template v-for="slotItem in slotList">
|
|
31
|
+
<template :slot="`form-${slotItem}`">
|
|
32
|
+
<slot
|
|
33
|
+
:scope="slotItem.formList"
|
|
34
|
+
:name="`formslot-${slotItem}`"
|
|
35
|
+
></slot>
|
|
36
|
+
</template>
|
|
37
|
+
</template> </template
|
|
30
38
|
></baseSectionVue>
|
|
31
39
|
</div>
|
|
32
40
|
</template>
|
|
@@ -38,10 +46,18 @@ export default {
|
|
|
38
46
|
name: "baseFormWrap",
|
|
39
47
|
data() {
|
|
40
48
|
return {
|
|
49
|
+
slotList: [],
|
|
41
50
|
sectionOpen: true,
|
|
42
51
|
};
|
|
43
52
|
},
|
|
53
|
+
created() {
|
|
54
|
+
this.createSlots();
|
|
55
|
+
},
|
|
44
56
|
props: {
|
|
57
|
+
form: {
|
|
58
|
+
type: Boolean,
|
|
59
|
+
default: false,
|
|
60
|
+
},
|
|
45
61
|
formTitle: {
|
|
46
62
|
type: String,
|
|
47
63
|
require: true,
|
|
@@ -81,6 +97,27 @@ export default {
|
|
|
81
97
|
baseSectionVue,
|
|
82
98
|
},
|
|
83
99
|
methods: {
|
|
100
|
+
createSlots() {
|
|
101
|
+
let slotList = this.slotList;
|
|
102
|
+
let formList = this.$props.formList;
|
|
103
|
+
for (let i = 0; i < formList.length; i++) {
|
|
104
|
+
let citem = formList[i];
|
|
105
|
+
if (citem.type == "template") {
|
|
106
|
+
slotList.push(citem.key);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
|
|
111
|
+
async checkValidate() {
|
|
112
|
+
let refs = this.$refs.proForm;
|
|
113
|
+
let validateResult = true;
|
|
114
|
+
let validate = await refs[i].checkValidate();
|
|
115
|
+
validateResult = validate.result;
|
|
116
|
+
if (!validateResult) {
|
|
117
|
+
return validateResult;
|
|
118
|
+
}
|
|
119
|
+
return validateResult;
|
|
120
|
+
},
|
|
84
121
|
handleSection() {
|
|
85
122
|
this.sectionOpen = !this.sectionOpen;
|
|
86
123
|
},
|