@zscreate/zhxy-app-component 1.0.320-test.4 → 1.0.321
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/README.md
CHANGED
|
@@ -465,7 +465,7 @@
|
|
|
465
465
|
<view class="evan-form-item-container__main" :style="mContentStyle" @click="handleSeclet(widget.options.multiple)">
|
|
466
466
|
<view class="form-input" style="display: flex;align-items: center;">
|
|
467
467
|
<view class="option-font-size">{{ dataModelShow ? dataModelShow : widget.options.placeholder }}</view>
|
|
468
|
-
<uni-icons style="margin-left: auto; margin-right: 20rpx;margin-top: 8rpx;" @click.native.stop="handleClear" v-if="!widget.options.disabled && dataModelShow" type="clear" color="#e1e1e1" size="14"></uni-icons>
|
|
468
|
+
<uni-icons style="margin-left: auto; margin-right: 20rpx;margin-top: 8rpx;" @click.native.stop="handleClear(widget.options.multiple)" v-if="!widget.options.disabled && dataModelShow" type="clear" color="#e1e1e1" size="14"></uni-icons>
|
|
469
469
|
</view>
|
|
470
470
|
</view>
|
|
471
471
|
<!-- <icon type="clear" size="14" v-if="widget.options.canView" />-->
|
|
@@ -1018,8 +1018,8 @@ export default {
|
|
|
1018
1018
|
clearValidate() {
|
|
1019
1019
|
this.showFalse = false
|
|
1020
1020
|
},
|
|
1021
|
-
handleClear() {
|
|
1022
|
-
this.dataModel = []
|
|
1021
|
+
handleClear(isMultiple=true) {
|
|
1022
|
+
this.dataModel = isMultiple?[]:''
|
|
1023
1023
|
this.dataModelShow = ''
|
|
1024
1024
|
if(this.zjfmFormDesign && this.widget.model == 'thr') {
|
|
1025
1025
|
this.models.thxq = ''
|
|
@@ -55,7 +55,6 @@
|
|
|
55
55
|
@click="showTableRow(item.model, tableCIndex)">
|
|
56
56
|
</view>
|
|
57
57
|
</view>
|
|
58
|
-
{{tableRowsShow[item.model][tableCIndex]}}
|
|
59
58
|
<view class="view-port" v-show="tableRowsShow[item.model][tableCIndex]">
|
|
60
59
|
<view v-for="(tableItem, tableItemIndex) in table.columns" :key="tableItemIndex">
|
|
61
60
|
<evan-form-item v-show="tableItem.options.canView"
|
|
@@ -1,147 +1,155 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
2
|
+
<view style="width: 100%;">
|
|
3
|
+
<view class="file_conten" style="width: 100%;">
|
|
4
|
+
<view class="file_upload option-font-size" @click="chooseMessageFile" v-if="isShow">
|
|
5
|
+
{{ widget.options.placeholder || '点击上传' }}
|
|
6
|
+
</view>
|
|
7
|
+
<view style="width: 100%">
|
|
8
|
+
<view class="file_item" v-for="(item, idx) in defaultFile" :key="idx">
|
|
9
|
+
<view @click="downLoadFile(item.url, item.name, item)"
|
|
10
|
+
style="max-width: 580rpx;color: rgb(0, 122, 255); overflow: hidden"
|
|
11
|
+
:style="{ maxWidth: disabled ? '100%' : '580rpx' }">{{ item.name }}</view>
|
|
12
|
+
<view style="display: flex;align-items: center;">
|
|
13
|
+
<!-- #ifdef ZJAF_DESIGN -->
|
|
14
|
+
<!-- ZJAF_DESIGN浙江安防环境变量,有该变量才会有文件上传的预览功能 -->
|
|
15
|
+
<view v-if="['doc', 'docx', 'xls', 'xlsx', 'jpg', 'jpeg', 'png', 'gif', 'pdf'].includes(getFileExt(item.name))" @click="handlePreview(item)" style="color: rgb(0, 122, 255);margin-top: 0;margin-right: 20rpx;">预览
|
|
16
|
+
</view>
|
|
17
|
+
<!-- #endif -->
|
|
18
|
+
<icon type="clear" size="16" @click="handleDelete(idx)" v-if="!disabled" />
|
|
19
|
+
</view>
|
|
20
|
+
</view>
|
|
21
|
+
</view>
|
|
22
|
+
</view>
|
|
23
|
+
<!-- <view class="name" v-show="!show">{{name}}</view>
|
|
16
24
|
<view class="name SXcolor" v-if="fileName" @click="downLoadFile(defaultFile[0]['url'])">{{fileName}}</view>
|
|
17
25
|
</view>
|
|
18
26
|
<view v-if="fileName" class="tips option-font-size">更多文件详情请于电脑端查看</view> -->
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
27
|
+
<view v-if="!disabled && percent > 0">
|
|
28
|
+
<progress :percent="percent" stroke-width="5" activeColor="#007AFF" backgroundColor="#FFFFFF"
|
|
29
|
+
style="width: 200upx;" v-show="show"></progress>
|
|
30
|
+
</view>
|
|
31
|
+
</view>
|
|
24
32
|
</template>
|
|
25
33
|
|
|
26
34
|
<script>
|
|
27
|
-
import {downloadFile, getDictInfo, getOpenId, h5PreviewFile, toAwait} from "../../utils/util";
|
|
35
|
+
import { downloadFile, getDictInfo, getOpenId, h5PreviewFile, toAwait } from "../../utils/util";
|
|
28
36
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
37
|
+
export default {
|
|
38
|
+
props: {
|
|
39
|
+
widget: {
|
|
40
|
+
type: Object,
|
|
41
|
+
default: {}
|
|
42
|
+
},
|
|
43
|
+
url: {
|
|
44
|
+
type: String,
|
|
45
|
+
default: ''
|
|
46
|
+
},
|
|
47
|
+
disabled: {
|
|
48
|
+
type: Boolean,
|
|
49
|
+
default: false
|
|
50
|
+
},
|
|
51
|
+
defaultFile: {
|
|
52
|
+
type: Array,
|
|
53
|
+
default: () => []
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
data() {
|
|
57
|
+
return {
|
|
58
|
+
name: "",
|
|
59
|
+
percent: 0,
|
|
60
|
+
show: true,
|
|
61
|
+
uploadIng: false,
|
|
62
|
+
openId: undefined,
|
|
63
|
+
header: {
|
|
64
|
+
'X-Access-Token': uni.getStorageSync('token') || this.$store.state.token || this.$store.getters.token
|
|
65
|
+
},
|
|
66
|
+
isShow: true,//是否展示点击上传
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
watch: {
|
|
70
|
+
//当上传的数量超过了设置的数量 就不让上传
|
|
71
|
+
defaultFile(val) {
|
|
72
|
+
this.getShow(val)
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
async mounted() {
|
|
76
|
+
const { uploadEncrypt, downloadVerifyToken } = this.widget.options
|
|
77
|
+
if (uploadEncrypt && !downloadVerifyToken) {
|
|
78
|
+
this.openId = await getOpenId()
|
|
79
|
+
this.openId = this.openId.replaceAll("+", "%2B").replaceAll("=", "%3D")
|
|
80
|
+
}
|
|
81
|
+
if (this.disabled) {
|
|
82
|
+
this.isShow = !this.disabled
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
this.getShow(this.defaultFile)
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
methods: {
|
|
89
|
+
getShow(val) {
|
|
90
|
+
if (val && val.length >= this.widget.options.length) {
|
|
91
|
+
this.isShow = false
|
|
72
92
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
},
|
|
89
|
-
//删除文件
|
|
90
|
-
handleDelete(idx) {
|
|
91
|
-
this.$emit('fileDelete', idx)
|
|
92
|
-
},
|
|
93
|
-
async downLoadFile(path, name, item) {
|
|
94
|
-
let baseUrl = this.downLoadUrl
|
|
95
|
-
const { uploadEncrypt, downloadVerifyToken} = this.widget.options
|
|
96
|
-
if (uploadEncrypt) {
|
|
97
|
-
const [err, res = {} ] = await toAwait(this.$u.get('/sys/common/checkDownloadZip', {fileId: item.fileId}))
|
|
98
|
-
if (err || !res.success) {
|
|
99
|
-
return uni.showToast({title: res.message || '文件检查状态失败', icon: 'none'})
|
|
100
|
-
}
|
|
101
|
-
path = `/sys/common/downloadZip?fileId=${item.fileId}&openId=${this.openId}&token=${ this.header['X-Access-Token'] }`
|
|
102
|
-
baseUrl = this.uniEnv.BASE_API || this.uniEnv.apiUrl
|
|
103
|
-
}
|
|
104
|
-
// #ifdef H5
|
|
105
|
-
const { h5_preview, h5_preview_type } = this.widget.options
|
|
106
|
-
if (h5_preview) {
|
|
107
|
-
return h5PreviewFile(baseUrl + path, h5_preview_type)
|
|
93
|
+
else {
|
|
94
|
+
this.isShow = true
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
//删除文件
|
|
98
|
+
handleDelete(idx) {
|
|
99
|
+
this.$emit('fileDelete', idx)
|
|
100
|
+
},
|
|
101
|
+
async downLoadFile(path, name, item) {
|
|
102
|
+
let baseUrl = this.downLoadUrl
|
|
103
|
+
const { uploadEncrypt, downloadVerifyToken } = this.widget.options
|
|
104
|
+
if (uploadEncrypt) {
|
|
105
|
+
const [err, res = {}] = await toAwait(this.$u.get('/sys/common/checkDownloadZip', { fileId: item.fileId }))
|
|
106
|
+
if (err || !res.success) {
|
|
107
|
+
return uni.showToast({ title: res.message || '文件检查状态失败', icon: 'none' })
|
|
108
108
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
109
|
+
path = `/sys/common/downloadZip?fileId=${item.fileId}&openId=${this.openId}&token=${this.header['X-Access-Token']}`
|
|
110
|
+
baseUrl = this.uniEnv.BASE_API || this.uniEnv.apiUrl
|
|
111
|
+
}
|
|
112
|
+
// #ifdef H5
|
|
113
|
+
const { h5_preview, h5_preview_type } = this.widget.options
|
|
114
|
+
if (h5_preview) {
|
|
115
|
+
return h5PreviewFile(baseUrl + path, h5_preview_type)
|
|
116
|
+
}
|
|
117
|
+
// #endif
|
|
118
|
+
downloadFile(baseUrl, { path, name })
|
|
119
|
+
},
|
|
120
|
+
chooseMessageFile: function (e) {
|
|
121
|
+
console.log(this.widget,)
|
|
122
|
+
const { options } = this.widget
|
|
115
123
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
124
|
+
if (this.disabled || (this.defaultFile.length && this.defaultFile.length >= options.length)) {
|
|
125
|
+
this.uploadIng = false
|
|
126
|
+
return false;
|
|
127
|
+
}
|
|
120
128
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
129
|
+
if (this.uploadIng) {
|
|
130
|
+
uni.showToast({
|
|
131
|
+
title: `文件上传中`,
|
|
132
|
+
icon: 'none'
|
|
133
|
+
})
|
|
134
|
+
return
|
|
135
|
+
}
|
|
136
|
+
var that = this;
|
|
137
|
+
//#ifdef H5
|
|
138
|
+
uni.chooseFile
|
|
139
|
+
//#endif
|
|
140
|
+
// #ifdef MP-WEIXIN
|
|
141
|
+
wx.chooseMessageFile
|
|
134
142
|
// #endif
|
|
135
143
|
({
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
144
|
+
count: 1,
|
|
145
|
+
type: 'all',
|
|
146
|
+
success: (res) => {
|
|
139
147
|
this.uploadIng = true
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
const { ext = ''
|
|
143
|
-
const { fileSize
|
|
144
|
-
|
|
148
|
+
console.log(res.tempFiles)
|
|
149
|
+
const path = res.tempFiles
|
|
150
|
+
const { ext = '', options } = this.widget
|
|
151
|
+
const { fileSize } = options
|
|
152
|
+
that.name = res.tempFiles[0].name
|
|
145
153
|
|
|
146
154
|
console.log(ext, that.name.split('.').pop())
|
|
147
155
|
if (!ext.includes(that.name.split('.').pop())) {
|
|
@@ -160,16 +168,16 @@ import {downloadFile, getDictInfo, getOpenId, h5PreviewFile, toAwait} from "../.
|
|
|
160
168
|
}
|
|
161
169
|
|
|
162
170
|
this.uploadIng = true
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
171
|
+
const uploadTask = uni.uploadFile({
|
|
172
|
+
url: that.url,
|
|
173
|
+
filePath: path[0].path,
|
|
174
|
+
name: 'file',
|
|
167
175
|
formData: {
|
|
168
176
|
fileName: that.name,
|
|
169
177
|
},
|
|
170
178
|
// header['X-Access-Token'] = uni.getStorageSync('token') || vm.$store.state.token
|
|
171
179
|
header: this.header,
|
|
172
|
-
|
|
180
|
+
success: function (res) {
|
|
173
181
|
try {
|
|
174
182
|
res = JSON.parse(res.data)
|
|
175
183
|
if (!res.success) {
|
|
@@ -193,7 +201,7 @@ import {downloadFile, getDictInfo, getOpenId, h5PreviewFile, toAwait} from "../.
|
|
|
193
201
|
} catch (e) {
|
|
194
202
|
|
|
195
203
|
}
|
|
196
|
-
let uid =
|
|
204
|
+
let uid = String(Math.random()).substr(2) - 0
|
|
197
205
|
let imgObj = {
|
|
198
206
|
uid,
|
|
199
207
|
key: uid,
|
|
@@ -205,80 +213,117 @@ import {downloadFile, getDictInfo, getOpenId, h5PreviewFile, toAwait} from "../.
|
|
|
205
213
|
imgObj['fileId'] = res.result.fileId
|
|
206
214
|
imgObj['name'] = imgObj['name'] || res.result.fileName
|
|
207
215
|
}
|
|
208
|
-
|
|
209
|
-
|
|
216
|
+
that.$emit('filePost', imgObj)
|
|
217
|
+
},
|
|
210
218
|
fail() {
|
|
211
|
-
uni.showToast({title: '文件上传失败', icon: 'none'})
|
|
219
|
+
uni.showToast({ title: '文件上传失败', icon: 'none' })
|
|
212
220
|
},
|
|
213
221
|
complete() {
|
|
214
222
|
that.show = false
|
|
215
223
|
that.percent = 0
|
|
216
224
|
that.uploadIng = false
|
|
217
225
|
}
|
|
218
|
-
|
|
226
|
+
});
|
|
219
227
|
|
|
220
228
|
that.show = true
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
229
|
+
uploadTask.onProgressUpdate(function (res) {
|
|
230
|
+
that.percent = res.progress;
|
|
231
|
+
if (Number(res.progress) == 100) {
|
|
232
|
+
that.show = false
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
},
|
|
228
236
|
|
|
229
|
-
|
|
237
|
+
error: function (e) {
|
|
230
238
|
that.uploadIng = false
|
|
231
|
-
|
|
232
|
-
|
|
239
|
+
console.log(e);
|
|
240
|
+
},
|
|
233
241
|
|
|
234
242
|
complete: (res) => {
|
|
235
243
|
// if (res.errMsg.includes('cancel')) return that.uploadIng = false
|
|
236
244
|
}
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
245
|
+
});
|
|
246
|
+
},
|
|
247
|
+
handlePreview(file) {
|
|
248
|
+
debugger
|
|
249
|
+
let ext = this.getFileExt(file.name)
|
|
250
|
+
|
|
251
|
+
if(['doc', 'docx', 'xls', 'xlsx'].includes(ext)) {
|
|
252
|
+
let preViewPdf = file.url
|
|
253
|
+
this.$u.get('/sys/common/preViewPdf', {preViewPdf}).then((res) => {
|
|
254
|
+
if(res.success) {
|
|
255
|
+
debugger
|
|
256
|
+
window.open( process.uniEnv.imgUrl+ res.message + '?download=0')
|
|
257
|
+
} else {
|
|
258
|
+
uni.showToast({
|
|
259
|
+
title: '当前状态不支持文件预览',
|
|
260
|
+
icon: "none",
|
|
261
|
+
duration: 1500,
|
|
262
|
+
})
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
})
|
|
266
|
+
return
|
|
267
|
+
}
|
|
268
|
+
window.open(process.uniEnv.imgUrl + file.url + '?download=0')
|
|
269
|
+
},
|
|
270
|
+
getFileExt(filename) {
|
|
271
|
+
try {
|
|
272
|
+
filename = decodeURIComponent(filename)
|
|
273
|
+
} catch (e) {
|
|
274
|
+
|
|
275
|
+
}
|
|
276
|
+
if (!filename || typeof filename != 'string') {
|
|
277
|
+
return false
|
|
278
|
+
};
|
|
279
|
+
let a = filename.split('').reverse().join('');
|
|
280
|
+
let b = a.substring(0, a.search(/\./)).split('').reverse().join('');
|
|
281
|
+
return b
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
}
|
|
241
285
|
</script>
|
|
242
286
|
|
|
243
287
|
<style scoped lang="scss">
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
288
|
+
.file_conten {
|
|
289
|
+
// display: flex;
|
|
290
|
+
// flex-direction: row;
|
|
291
|
+
// align-items: center;
|
|
292
|
+
// justify-content: flex-start;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
.file_upload {
|
|
296
|
+
color: #666;
|
|
297
|
+
margin-right: 20rpx;
|
|
250
298
|
|
|
251
|
-
|
|
252
|
-
color: #666;
|
|
253
|
-
margin-right: 20rpx;
|
|
299
|
+
}
|
|
254
300
|
|
|
255
|
-
|
|
301
|
+
.option-font-size {
|
|
302
|
+
font-size: $uni-form-content-font-size;
|
|
303
|
+
}
|
|
256
304
|
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
305
|
+
.name {
|
|
306
|
+
padding-top: 4upx;
|
|
307
|
+
font-size: 22upx;
|
|
308
|
+
}
|
|
260
309
|
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
}
|
|
310
|
+
.SXcolor {
|
|
311
|
+
color: #539DFA;
|
|
312
|
+
}
|
|
265
313
|
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
314
|
+
.tips {
|
|
315
|
+
color: #999;
|
|
316
|
+
font-size: 22upx;
|
|
317
|
+
}
|
|
269
318
|
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
319
|
+
.file_item {
|
|
320
|
+
width: calc(100% - 10px);
|
|
321
|
+
display: flex;
|
|
322
|
+
justify-content: space-between;
|
|
323
|
+
align-items: center;
|
|
274
324
|
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
align-items: center;
|
|
280
|
-
view {
|
|
281
|
-
margin-top: 10upx;
|
|
282
|
-
}
|
|
283
|
-
}
|
|
325
|
+
view {
|
|
326
|
+
margin-top: 10upx;
|
|
327
|
+
}
|
|
328
|
+
}
|
|
284
329
|
</style>
|