@zscreate/zhxy-app-component 1.0.116 → 1.0.117
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/components/evan-form-item/evan-form-item.vue +1 -1
- package/components/evan-form-item/mixins/valueChangeMixin.js +22 -14
- package/components/form-container/css/style_2.less +1 -1
- package/components/l-file/l-file.vue +4 -3
- package/components/uploadFile/uploadFile.vue +58 -19
- package/package.json +1 -1
|
@@ -264,7 +264,7 @@
|
|
|
264
264
|
{{ widget.name }}
|
|
265
265
|
</view>
|
|
266
266
|
<view class="evan-form-item-container__main" :style="mContentStyle">
|
|
267
|
-
<unploadFile :widget="widget" @
|
|
267
|
+
<unploadFile :widget="widget" :action="getUploadFileUrl(widget)" @filePost="filePost" @fileDelete="fileDelete" :defaultImg="dataModel"></unploadFile>
|
|
268
268
|
</view>
|
|
269
269
|
</view>
|
|
270
270
|
|
|
@@ -2,26 +2,34 @@ export const valueChangeMixin = {
|
|
|
2
2
|
methods: {
|
|
3
3
|
/**文件dataModal**/
|
|
4
4
|
filePost(val) {
|
|
5
|
+
if (!Array.isArray(this.dataModel)) this.dataModel = []
|
|
5
6
|
this.dataModel.push(val)
|
|
6
|
-
this.
|
|
7
|
+
if (this.widget.options.uploadEncrypt) {
|
|
8
|
+
this.updateStringModel('formFileIds', val.fileId , 'add')
|
|
9
|
+
}
|
|
7
10
|
},
|
|
8
11
|
//文件删除
|
|
9
12
|
fileDelete(idx) {
|
|
10
|
-
this.dataModel.splice(idx, 1)
|
|
11
|
-
this.updateEncryptFileIds()
|
|
12
|
-
},
|
|
13
|
-
updateEncryptFileIds() {
|
|
13
|
+
const data = this.dataModel.splice(idx, 1)
|
|
14
14
|
if (this.widget.options.uploadEncrypt) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
15
|
+
this.updateStringModel('formFileIds', data[0].fileId , 'del')
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
updateStringModel(key ,data ,tag = 'add') {
|
|
19
|
+
const modelData = String(this.models[key] || '').split(',')
|
|
20
|
+
if (modelData[0] === '') modelData.shift()
|
|
21
|
+
|
|
22
|
+
if (tag === 'add' && !modelData.includes(data)) {
|
|
23
|
+
modelData.push(data)
|
|
24
|
+
}
|
|
25
|
+
else if (tag === 'del' && modelData.includes(data)) {
|
|
26
|
+
modelData.splice(modelData.indexOf(data), 1)
|
|
24
27
|
}
|
|
28
|
+
// 需要异步调用, 不然会影响 updateModels
|
|
29
|
+
setTimeout(() => {
|
|
30
|
+
this.models[key] = modelData.join(',')
|
|
31
|
+
this.$emit('update:models', this.models)
|
|
32
|
+
},0)
|
|
25
33
|
},
|
|
26
34
|
/**imgdataModal**/
|
|
27
35
|
imgUrlPost(val) {
|
|
@@ -155,16 +155,17 @@
|
|
|
155
155
|
title: res.message || '文件上传失败',
|
|
156
156
|
icon: 'none'
|
|
157
157
|
})
|
|
158
|
-
|
|
158
|
+
let uid = String(Math.random()).substr(2) - 0
|
|
159
159
|
let imgObj = {
|
|
160
|
-
|
|
160
|
+
uid,
|
|
161
|
+
key: uid,
|
|
161
162
|
name: that.name,
|
|
162
163
|
status: "success",
|
|
163
164
|
url: res.message
|
|
164
165
|
}
|
|
165
166
|
if (that.widget.options.uploadEncrypt) {
|
|
166
167
|
imgObj['fileId'] = res.result.fileId
|
|
167
|
-
imgObj['name'] =
|
|
168
|
+
imgObj['name'] = imgObj['name'] || res.result.fileName
|
|
168
169
|
}
|
|
169
170
|
that.$emit('filePost', imgObj)
|
|
170
171
|
},
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
<u-upload ref="uUpload" :file-list="fileList" :action="action" :deletable="!disabled"
|
|
4
4
|
@afterRead="afterRead"
|
|
5
5
|
@delete="onRemove"
|
|
6
|
+
:header="header"
|
|
6
7
|
:upload-text="widget.options.placeholder"
|
|
7
8
|
width="150" height="150" :multiple="false" :max-count="maxCount" :disabled="disabled"
|
|
8
9
|
@on-remove="onRemove" @on-oversize="onOversize" @on-success="onSuccess"
|
|
@@ -35,12 +36,14 @@ export default {
|
|
|
35
36
|
default: () => {
|
|
36
37
|
return {}
|
|
37
38
|
}
|
|
38
|
-
}
|
|
39
|
+
},
|
|
40
|
+
action: {
|
|
41
|
+
type: String,
|
|
42
|
+
},
|
|
39
43
|
},
|
|
40
44
|
data() {
|
|
41
45
|
return {
|
|
42
|
-
|
|
43
|
-
action: '',
|
|
46
|
+
|
|
44
47
|
percent: 0,
|
|
45
48
|
upimg: '',
|
|
46
49
|
maxCount: 8,
|
|
@@ -49,7 +52,10 @@ export default {
|
|
|
49
52
|
fileList: [],
|
|
50
53
|
emitList: [],
|
|
51
54
|
uploadIng: false,
|
|
52
|
-
showProgress: true
|
|
55
|
+
showProgress: true,
|
|
56
|
+
header: {
|
|
57
|
+
'X-Access-Token': uni.getStorageSync('token') || this.$store.state.token || this.$store.getters.token
|
|
58
|
+
},
|
|
53
59
|
};
|
|
54
60
|
},
|
|
55
61
|
created() {
|
|
@@ -116,19 +122,34 @@ export default {
|
|
|
116
122
|
// })
|
|
117
123
|
// })
|
|
118
124
|
for (let i = 0; i < lists.length; i++) {
|
|
119
|
-
|
|
125
|
+
|
|
126
|
+
const { message, result = {}, success } = await this.uploadFilePromise(lists[i].url)
|
|
120
127
|
let id = new Date().getTime();
|
|
128
|
+
if (!success) {
|
|
129
|
+
return uni.showToast({
|
|
130
|
+
title: message || '文件上传失败',
|
|
131
|
+
icon: 'none'
|
|
132
|
+
})
|
|
133
|
+
}
|
|
121
134
|
const item = {
|
|
122
135
|
key: id,
|
|
123
136
|
uid: id,
|
|
124
|
-
url:
|
|
137
|
+
url: message,
|
|
125
138
|
status: "done",
|
|
126
|
-
name:
|
|
139
|
+
name: id
|
|
140
|
+
}
|
|
141
|
+
let previewUrl = this.uniEnv.imgUrl + item.url
|
|
142
|
+
|
|
143
|
+
if (this.widget.options.uploadEncrypt) {
|
|
144
|
+
item.fileId = result.fileId
|
|
145
|
+
item.name = result.fileName || item.id
|
|
146
|
+
previewUrl = (process.uniEnv.BASE_API || process.uniEnv.apiUrl) + '/sys/common/downloadZip?fileId=' + result.fileId
|
|
127
147
|
}
|
|
128
148
|
this.emitList.push(item)
|
|
129
|
-
|
|
149
|
+
|
|
150
|
+
this.fileList.push(Object.assign({}, item, { url: previewUrl }))
|
|
130
151
|
this.uploadIng = false
|
|
131
|
-
this.$emit('
|
|
152
|
+
this.$emit('filePost', item)
|
|
132
153
|
}
|
|
133
154
|
},
|
|
134
155
|
uploadFilePromise(url) {
|
|
@@ -137,9 +158,10 @@ export default {
|
|
|
137
158
|
url: this.action,
|
|
138
159
|
filePath: url,
|
|
139
160
|
name: 'file',
|
|
161
|
+
header: this.header,
|
|
140
162
|
success: (uploadFileRes) => {
|
|
141
163
|
const res = JSON.parse(uploadFileRes.data)
|
|
142
|
-
resolve(res
|
|
164
|
+
resolve(res)
|
|
143
165
|
},
|
|
144
166
|
complete: () => {
|
|
145
167
|
setTimeout(() => {
|
|
@@ -166,6 +188,9 @@ export default {
|
|
|
166
188
|
...item,
|
|
167
189
|
};
|
|
168
190
|
tempItem.url = this.uniEnv.imgUrl + tempItem.url;
|
|
191
|
+
if (tempItem.fileId) {
|
|
192
|
+
tempItem.url = (process.uniEnv.BASE_API || process.uniEnv.apiUrl) + '/sys/common/downloadZip?fileId=' + tempItem.fileId
|
|
193
|
+
}
|
|
169
194
|
return tempItem;
|
|
170
195
|
})
|
|
171
196
|
|
|
@@ -174,11 +199,11 @@ export default {
|
|
|
174
199
|
},
|
|
175
200
|
initWidget() {
|
|
176
201
|
//action url
|
|
177
|
-
if (String(this.widget.options.action).startsWith('http')) {
|
|
178
|
-
|
|
179
|
-
} else {
|
|
180
|
-
|
|
181
|
-
}
|
|
202
|
+
// if (String(this.widget.options.action).startsWith('http')) {
|
|
203
|
+
// this.action = this.widget.options.action;
|
|
204
|
+
// } else {
|
|
205
|
+
// this.action = this.actionUrl.includes('sys/common/upload') ? this.actionUrl : (this.actionUrl + '/sys/common/upload')
|
|
206
|
+
// }
|
|
182
207
|
//文件大小限制
|
|
183
208
|
this.maxSize = this.widget.options.fileSize ? this.widget.options.fileSize * 1024 : 300000;
|
|
184
209
|
|
|
@@ -203,23 +228,37 @@ export default {
|
|
|
203
228
|
|
|
204
229
|
// },
|
|
205
230
|
onSuccess(data, index, lists, name) {
|
|
231
|
+
|
|
232
|
+
if (!data.success) {
|
|
233
|
+
// this.fileList = []
|
|
234
|
+
lists[index].error = true
|
|
235
|
+
return uni.showToast({
|
|
236
|
+
title: data.message || '文件上传失败',
|
|
237
|
+
icon: 'none'
|
|
238
|
+
})
|
|
239
|
+
}
|
|
206
240
|
let id = new Date().getTime();
|
|
207
241
|
let imgArr = data.message.split('/');
|
|
208
242
|
let _name = imgArr[imgArr.length - 1]
|
|
209
|
-
|
|
243
|
+
const imgObj = {
|
|
210
244
|
key: id,
|
|
211
245
|
uid: id,
|
|
212
246
|
url: data.message,
|
|
213
247
|
status: "done",
|
|
214
248
|
name: _name
|
|
215
|
-
}
|
|
216
|
-
|
|
249
|
+
}
|
|
250
|
+
if (this.widget.options.uploadEncrypt) {
|
|
251
|
+
imgObj['fileId'] = data.result.fileId
|
|
252
|
+
imgObj['name'] = imgObj['name'] || data.result.fileName
|
|
253
|
+
}
|
|
254
|
+
this.emitList.push(imgObj)
|
|
255
|
+
this.$emit('filePost', imgObj)
|
|
217
256
|
},
|
|
218
257
|
onRemove(index, lists, name) {
|
|
219
258
|
if (typeof (index) === 'object') index = index.index
|
|
220
259
|
this.emitList.splice(index, 1);
|
|
221
260
|
this.fileList.splice(index, 1);
|
|
222
|
-
this.$emit('
|
|
261
|
+
this.$emit('fileDelete', index)
|
|
223
262
|
}
|
|
224
263
|
}
|
|
225
264
|
}
|