meixioacomponent 0.2.42 → 0.2.45

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.42",
3
+ "version": "0.2.45",
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,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 (!this.uploadItem.url) {
91
- return "";
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
- if (this.$parent.$options.name == "baseUpload") {
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.$emit("handleDeleteUploadItem");
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: relative;
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,19 @@
19
19
  <pro_formVue
20
20
  :size="size"
21
21
  ref="proForm"
22
- :form="false"
22
+ :form="form"
23
23
  :rules="rules"
24
24
  :footer="false"
25
- :formList="formList"
25
+ v-model="formList"
26
26
  :rowNumber="rowNumber"
27
27
  :labelWidth="labelWidth"
28
28
  @formItemConfirm="formItemConfirm"
29
- ></pro_formVue> </template
29
+ ></pro_formVue>
30
+ <template v-for="slotItem in slotList">
31
+ <template :slot="`form-${slotItem}`">
32
+ <slot :scope="item.formList" :name="`formslot-${slotItem}`"></slot>
33
+ </template>
34
+ </template> </template
30
35
  ></baseSectionVue>
31
36
  </div>
32
37
  </template>
@@ -38,10 +43,18 @@ export default {
38
43
  name: "baseFormWrap",
39
44
  data() {
40
45
  return {
46
+ slotList: [],
41
47
  sectionOpen: true,
42
48
  };
43
49
  },
50
+ created() {
51
+ this.createSlots();
52
+ },
44
53
  props: {
54
+ form: {
55
+ type: Boolean,
56
+ default: false,
57
+ },
45
58
  formTitle: {
46
59
  type: String,
47
60
  require: true,
@@ -81,6 +94,27 @@ export default {
81
94
  baseSectionVue,
82
95
  },
83
96
  methods: {
97
+ createSlots() {
98
+ let slotList = this.slotList;
99
+ let formList = this.$props.formList;
100
+ for (let i = 0; i < formList.length; i++) {
101
+ let citem = formList[i];
102
+ if (citem.type == "template") {
103
+ slotList.push(citem.key);
104
+ }
105
+ }
106
+ },
107
+
108
+ async checkValidate() {
109
+ let refs = this.$refs.proForm;
110
+ let validateResult = true;
111
+ let validate = await refs[i].checkValidate();
112
+ validateResult = validate.result;
113
+ if (!validateResult) {
114
+ return validateResult;
115
+ }
116
+ return validateResult;
117
+ },
84
118
  handleSection() {
85
119
  this.sectionOpen = !this.sectionOpen;
86
120
  },
@@ -5,6 +5,7 @@ const componentConfig = {
5
5
  store: null,
6
6
  router: null,
7
7
  dynamicId: 0,
8
+ uploadUrl: null,
8
9
  eventBus: new Vue(),
9
10
  selectStore: null,
10
11
 
@@ -12,6 +13,10 @@ const componentConfig = {
12
13
  componentConfig.dynamicId += 1;
13
14
  },
14
15
 
16
+ setUploadUrl: (url) => {
17
+ componentConfig.uploadUrl = url;
18
+ },
19
+
15
20
  initConfig: (_store, _router) => {
16
21
  // 注册element 组件
17
22
  useElementComponent();
@@ -1,11 +1,12 @@
1
1
  import axios from "axios";
2
2
  import { GetToken } from "../utils/utils.js";
3
+ import componentConfig from "./componentConfig.js";
3
4
 
4
5
  const ossInstance = (params, uploadProgressFn) => {
5
6
  // 创建 axios 实例
6
7
  const instance = axios.create({
7
8
  // API 请求的默认前缀
8
- baseURL: process.env.VUE_APP_UPLOAD_URL,
9
+ baseURL: componentConfig.uploadUrl,
9
10
  });
10
11
 
11
12
  // 异常拦截处理器