@vtj/materials 0.13.16 → 0.13.18
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/dist/assets/antdv/index.umd.js +2 -2
- package/dist/assets/charts/index.umd.js +2 -2
- package/dist/assets/element/index.umd.js +3 -3
- package/dist/assets/icons/index.umd.js +2 -2
- package/dist/assets/ui/index.umd.js +2 -2
- package/dist/assets/uni-h5/index.umd.js +2 -2
- package/dist/assets/uni-ui/index.umd.js +2 -2
- package/dist/assets/vant/index.umd.js +2 -2
- package/dist/deps/@vtj/charts/index.umd.js +2 -2
- package/dist/deps/@vtj/icons/index.umd.js +2 -2
- package/dist/deps/@vtj/ui/index.umd.js +4 -4
- package/dist/deps/@vtj/ui/style.css +1 -1
- package/dist/deps/@vtj/utils/index.umd.js +28 -33
- package/dist/deps/@vueuse/core/index.iife.min.js +1 -1
- package/dist/deps/element-plus/index.css +1 -1
- package/dist/deps/element-plus/index.full.min.js +14 -14
- package/dist/deps/element-plus/zh-cn.js +1 -1
- package/dist/deps/uni-app/index.umd.js +1 -1
- package/dist/deps/uni-h5/index.umd.js +8 -8
- package/dist/deps/uni-h5/style.css +1 -1
- package/dist/deps/uni-h5-vue/index.umd.js +1 -1
- package/dist/deps/uni-ui/index.umd.js +1 -1
- package/dist/deps/uni-ui/style.css +1 -1
- package/dist/deps/vue/vue.global.js +88 -53
- package/dist/deps/vue/vue.global.prod.js +9 -9
- package/package.json +12 -12
- package/src/antdv/image.ts +1 -1
- package/src/element/image.ts +1 -1
- package/src/element/virtualizedTable.ts +6 -6
- package/src/manifest.json +69 -0
- package/src/pages/index.vue +2 -0
- package/src/pages.json +19 -0
- package/src/uni-ui/index.ts +88 -58
- package/src/{uni-ui/lib/uni.scss → uni.scss} +4 -0
- package/src/version.ts +2 -2
- package/src/uni-ui/lib/uni-col/uni-col.vue +0 -324
- package/src/uni-ui/lib/uni-collapse/uni-collapse.vue +0 -153
- package/src/uni-ui/lib/uni-collapse-item/uni-collapse-item.vue +0 -425
- package/src/uni-ui/lib/uni-data-picker/keypress.js +0 -45
- package/src/uni-ui/lib/uni-data-picker/uni-data-picker.vue +0 -604
- package/src/uni-ui/lib/uni-data-pickerview/uni-data-picker.js +0 -622
- package/src/uni-ui/lib/uni-data-pickerview/uni-data-pickerview.css +0 -76
- package/src/uni-ui/lib/uni-data-pickerview/uni-data-pickerview.vue +0 -335
- package/src/uni-ui/lib/uni-data-select/uni-data-select.vue +0 -590
- package/src/uni-ui/lib/uni-datetime-picker/calendar-item.vue +0 -188
- package/src/uni-ui/lib/uni-datetime-picker/calendar.vue +0 -985
- package/src/uni-ui/lib/uni-datetime-picker/i18n/en.json +0 -22
- package/src/uni-ui/lib/uni-datetime-picker/i18n/index.js +0 -8
- package/src/uni-ui/lib/uni-datetime-picker/i18n/zh-Hans.json +0 -22
- package/src/uni-ui/lib/uni-datetime-picker/i18n/zh-Hant.json +0 -22
- package/src/uni-ui/lib/uni-datetime-picker/time-picker.vue +0 -1032
- package/src/uni-ui/lib/uni-datetime-picker/uni-datetime-picker.vue +0 -1230
- package/src/uni-ui/lib/uni-datetime-picker/util.js +0 -448
- package/src/uni-ui/lib/uni-easyinput/common.js +0 -54
- package/src/uni-ui/lib/uni-easyinput/uni-easyinput.vue +0 -790
- package/src/uni-ui/lib/uni-fav/i18n/en.json +0 -4
- package/src/uni-ui/lib/uni-fav/i18n/index.js +0 -8
- package/src/uni-ui/lib/uni-fav/i18n/zh-Hans.json +0 -4
- package/src/uni-ui/lib/uni-fav/i18n/zh-Hant.json +0 -4
- package/src/uni-ui/lib/uni-fav/uni-fav.vue +0 -170
- package/src/uni-ui/lib/uni-file-picker/choose-and-upload-file.js +0 -280
- package/src/uni-ui/lib/uni-file-picker/uni-file-picker.vue +0 -668
- package/src/uni-ui/lib/uni-file-picker/upload-file.vue +0 -325
- package/src/uni-ui/lib/uni-file-picker/upload-image.vue +0 -292
- package/src/uni-ui/lib/uni-file-picker/utils.js +0 -110
- package/src/uni-ui/lib/uni-forms/uni-forms.vue +0 -416
- package/src/uni-ui/lib/uni-forms/utils.js +0 -293
- package/src/uni-ui/lib/uni-forms/validate.js +0 -486
- package/src/uni-ui/lib/uni-forms-item/uni-forms-item.vue +0 -630
- package/src/uni-ui/lib/uni-goods-nav/i18n/en.json +0 -6
- package/src/uni-ui/lib/uni-goods-nav/i18n/index.js +0 -8
- package/src/uni-ui/lib/uni-goods-nav/i18n/zh-Hans.json +0 -6
- package/src/uni-ui/lib/uni-goods-nav/i18n/zh-Hant.json +0 -6
- package/src/uni-ui/lib/uni-goods-nav/uni-goods-nav.vue +0 -231
- package/src/uni-ui/lib/uni-grid/uni-grid.vue +0 -148
- package/src/uni-ui/lib/uni-icons/uni-icons.uvue +0 -91
- package/src/uni-ui/lib/uni-icons/uni-icons.vue +0 -114
- package/src/uni-ui/lib/uni-icons/uniicons.css +0 -664
- package/src/uni-ui/lib/uni-icons/uniicons.ttf +0 -0
- package/src/uni-ui/lib/uni-icons/uniicons_file.ts +0 -664
- package/src/uni-ui/lib/uni-icons/uniicons_file_vue.js +0 -649
- package/src/uni-ui/lib/uni-indexed-list/uni-indexed-list-item.vue +0 -168
- package/src/uni-ui/lib/uni-indexed-list/uni-indexed-list.vue +0 -404
- package/src/uni-ui/lib/uni-list/uni-list.vue +0 -123
- package/src/uni-ui/lib/uni-list/uni-refresh.vue +0 -65
- package/src/uni-ui/lib/uni-list/uni-refresh.wxs +0 -87
- package/src/uni-ui/lib/uni-load-more/i18n/en.json +0 -5
- package/src/uni-ui/lib/uni-load-more/i18n/index.js +0 -8
- package/src/uni-ui/lib/uni-load-more/i18n/zh-Hans.json +0 -5
- package/src/uni-ui/lib/uni-load-more/i18n/zh-Hant.json +0 -5
- package/src/uni-ui/lib/uni-load-more/uni-load-more.vue +0 -456
- package/src/uni-ui/lib/uni-notice-bar/uni-notice-bar.vue +0 -484
- package/src/uni-ui/lib/uni-popup/i18n/en.json +0 -7
- package/src/uni-ui/lib/uni-popup/i18n/index.js +0 -8
- package/src/uni-ui/lib/uni-popup/i18n/zh-Hans.json +0 -7
- package/src/uni-ui/lib/uni-popup/i18n/zh-Hant.json +0 -7
- package/src/uni-ui/lib/uni-popup/keypress.js +0 -45
- package/src/uni-ui/lib/uni-popup/popup.js +0 -26
- package/src/uni-ui/lib/uni-popup/uni-popup.uvue +0 -90
- package/src/uni-ui/lib/uni-popup/uni-popup.vue +0 -552
- package/src/uni-ui/lib/uni-popup-dialog/keypress.js +0 -45
- package/src/uni-ui/lib/uni-popup-dialog/uni-popup-dialog.vue +0 -324
- package/src/uni-ui/lib/uni-popup-message/uni-popup-message.vue +0 -149
- package/src/uni-ui/lib/uni-rate/uni-rate.vue +0 -380
- package/src/uni-ui/lib/uni-row/uni-row.vue +0 -193
- package/src/uni-ui/lib/uni-search-bar/i18n/en.json +0 -4
- package/src/uni-ui/lib/uni-search-bar/i18n/index.js +0 -8
- package/src/uni-ui/lib/uni-search-bar/i18n/zh-Hans.json +0 -4
- package/src/uni-ui/lib/uni-search-bar/i18n/zh-Hant.json +0 -4
- package/src/uni-ui/lib/uni-search-bar/uni-search-bar.vue +0 -339
- package/src/uni-ui/lib/uni-swipe-action-item/bindingx.js +0 -311
- package/src/uni-ui/lib/uni-swipe-action-item/isPC.js +0 -12
- package/src/uni-ui/lib/uni-swipe-action-item/mpalipay.js +0 -195
- package/src/uni-ui/lib/uni-swipe-action-item/mpother.js +0 -260
- package/src/uni-ui/lib/uni-swipe-action-item/mpwxs.js +0 -84
- package/src/uni-ui/lib/uni-swipe-action-item/render.js +0 -270
- package/src/uni-ui/lib/uni-swipe-action-item/uni-swipe-action-item.vue +0 -493
- package/src/uni-ui/lib/uni-swipe-action-item/wx.wxs +0 -341
- package/src/uni-ui/lib/uni-table/uni-table.vue +0 -496
- package/src/uni-ui/lib/uni-td/uni-td.vue +0 -99
- package/src/uni-ui/lib/uni-th/filter-dropdown.vue +0 -559
- package/src/uni-ui/lib/uni-th/uni-th.vue +0 -322
- package/src/uni-ui/lib/uni-tr/table-checkbox.vue +0 -181
- package/src/uni-ui/lib/uni-tr/uni-tr.vue +0 -208
- package/src/uni-ui/lib/uni-transition/createAnimation.js +0 -131
- package/src/uni-ui/lib/uni-transition/uni-transition.vue +0 -310
- package/src/uni-ui/polyfill.ts +0 -41
|
@@ -1,668 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<view class="uni-file-picker">
|
|
3
|
-
<view v-if="title" class="uni-file-picker__header">
|
|
4
|
-
<text class="file-title">{{ title }}</text>
|
|
5
|
-
<text class="file-count">{{ filesList.length }}/{{ limitLength }}</text>
|
|
6
|
-
</view>
|
|
7
|
-
<upload-image v-if="fileMediatype === 'image' && showType === 'grid'" :readonly="readonly"
|
|
8
|
-
:image-styles="imageStyles" :files-list="filesList" :limit="limitLength" :disablePreview="disablePreview"
|
|
9
|
-
:delIcon="delIcon" @uploadFiles="uploadFiles" @choose="choose" @delFile="delFile">
|
|
10
|
-
<slot>
|
|
11
|
-
<view class="is-add">
|
|
12
|
-
<view class="icon-add"></view>
|
|
13
|
-
<view class="icon-add rotate"></view>
|
|
14
|
-
</view>
|
|
15
|
-
</slot>
|
|
16
|
-
</upload-image>
|
|
17
|
-
<upload-file v-if="fileMediatype !== 'image' || showType !== 'grid'" :readonly="readonly"
|
|
18
|
-
:list-styles="listStyles" :files-list="filesList" :showType="showType" :delIcon="delIcon"
|
|
19
|
-
@uploadFiles="uploadFiles" @choose="choose" @delFile="delFile">
|
|
20
|
-
<slot><button type="primary" size="mini">选择文件</button></slot>
|
|
21
|
-
</upload-file>
|
|
22
|
-
</view>
|
|
23
|
-
</template>
|
|
24
|
-
|
|
25
|
-
<script>
|
|
26
|
-
import {
|
|
27
|
-
chooseAndUploadFile,
|
|
28
|
-
uploadCloudFiles
|
|
29
|
-
} from './choose-and-upload-file.js'
|
|
30
|
-
import {
|
|
31
|
-
get_file_ext,
|
|
32
|
-
get_extname,
|
|
33
|
-
get_files_and_is_max,
|
|
34
|
-
get_file_info,
|
|
35
|
-
get_file_data
|
|
36
|
-
} from './utils.js'
|
|
37
|
-
import uploadImage from './upload-image.vue'
|
|
38
|
-
import uploadFile from './upload-file.vue'
|
|
39
|
-
let fileInput = null
|
|
40
|
-
/**
|
|
41
|
-
* FilePicker 文件选择上传
|
|
42
|
-
* @description 文件选择上传组件,可以选择图片、视频等任意文件并上传到当前绑定的服务空间
|
|
43
|
-
* @tutorial https://ext.dcloud.net.cn/plugin?id=4079
|
|
44
|
-
* @property {Object|Array} value 组件数据,通常用来回显 ,类型由return-type属性决定
|
|
45
|
-
* @property {Boolean} disabled = [true|false] 组件禁用
|
|
46
|
-
* @value true 禁用
|
|
47
|
-
* @value false 取消禁用
|
|
48
|
-
* @property {Boolean} readonly = [true|false] 组件只读,不可选择,不显示进度,不显示删除按钮
|
|
49
|
-
* @value true 只读
|
|
50
|
-
* @value false 取消只读
|
|
51
|
-
* @property {String} return-type = [array|object] 限制 value 格式,当为 object 时 ,组件只能单选,且会覆盖
|
|
52
|
-
* @value array 规定 value 属性的类型为数组
|
|
53
|
-
* @value object 规定 value 属性的类型为对象
|
|
54
|
-
* @property {Boolean} disable-preview = [true|false] 禁用图片预览,仅 mode:grid 时生效
|
|
55
|
-
* @value true 禁用图片预览
|
|
56
|
-
* @value false 取消禁用图片预览
|
|
57
|
-
* @property {Boolean} del-icon = [true|false] 是否显示删除按钮
|
|
58
|
-
* @value true 显示删除按钮
|
|
59
|
-
* @value false 不显示删除按钮
|
|
60
|
-
* @property {Boolean} auto-upload = [true|false] 是否自动上传,值为true则只触发@select,可自行上传
|
|
61
|
-
* @value true 自动上传
|
|
62
|
-
* @value false 取消自动上传
|
|
63
|
-
* @property {Number|String} limit 最大选择个数 ,h5 会自动忽略多选的部分
|
|
64
|
-
* @property {String} title 组件标题,右侧显示上传计数
|
|
65
|
-
* @property {String} mode = [list|grid] 选择文件后的文件列表样式
|
|
66
|
-
* @value list 列表显示
|
|
67
|
-
* @value grid 宫格显示
|
|
68
|
-
* @property {String} file-mediatype = [image|video|all] 选择文件类型
|
|
69
|
-
* @value image 只选择图片
|
|
70
|
-
* @value video 只选择视频
|
|
71
|
-
* @value all 选择所有文件
|
|
72
|
-
* @property {Array} file-extname 选择文件后缀,根据 file-mediatype 属性而不同
|
|
73
|
-
* @property {Object} list-style mode:list 时的样式
|
|
74
|
-
* @property {Object} image-styles 选择文件后缀,根据 file-mediatype 属性而不同
|
|
75
|
-
* @event {Function} select 选择文件后触发
|
|
76
|
-
* @event {Function} progress 文件上传时触发
|
|
77
|
-
* @event {Function} success 上传成功触发
|
|
78
|
-
* @event {Function} fail 上传失败触发
|
|
79
|
-
* @event {Function} delete 文件从列表移除时触发
|
|
80
|
-
*/
|
|
81
|
-
export default {
|
|
82
|
-
name: 'uniFilePicker',
|
|
83
|
-
components: {
|
|
84
|
-
uploadImage,
|
|
85
|
-
uploadFile
|
|
86
|
-
},
|
|
87
|
-
options: {
|
|
88
|
-
virtualHost: true
|
|
89
|
-
},
|
|
90
|
-
emits: ['select', 'success', 'fail', 'progress', 'delete', 'update:modelValue', 'input'],
|
|
91
|
-
props: {
|
|
92
|
-
modelValue: {
|
|
93
|
-
type: [Array, Object],
|
|
94
|
-
default () {
|
|
95
|
-
return []
|
|
96
|
-
}
|
|
97
|
-
},
|
|
98
|
-
value: {
|
|
99
|
-
type: [Array, Object],
|
|
100
|
-
default () {
|
|
101
|
-
return []
|
|
102
|
-
}
|
|
103
|
-
},
|
|
104
|
-
disabled: {
|
|
105
|
-
type: Boolean,
|
|
106
|
-
default: false
|
|
107
|
-
},
|
|
108
|
-
disablePreview: {
|
|
109
|
-
type: Boolean,
|
|
110
|
-
default: false
|
|
111
|
-
},
|
|
112
|
-
delIcon: {
|
|
113
|
-
type: Boolean,
|
|
114
|
-
default: true
|
|
115
|
-
},
|
|
116
|
-
// 自动上传
|
|
117
|
-
autoUpload: {
|
|
118
|
-
type: Boolean,
|
|
119
|
-
default: true
|
|
120
|
-
},
|
|
121
|
-
// 最大选择个数 ,h5只能限制单选或是多选
|
|
122
|
-
limit: {
|
|
123
|
-
type: [Number, String],
|
|
124
|
-
default: 9
|
|
125
|
-
},
|
|
126
|
-
// 列表样式 grid | list | list-card
|
|
127
|
-
mode: {
|
|
128
|
-
type: String,
|
|
129
|
-
default: 'grid'
|
|
130
|
-
},
|
|
131
|
-
// 选择文件类型 image/video/all
|
|
132
|
-
fileMediatype: {
|
|
133
|
-
type: String,
|
|
134
|
-
default: 'image'
|
|
135
|
-
},
|
|
136
|
-
// 文件类型筛选
|
|
137
|
-
fileExtname: {
|
|
138
|
-
type: [Array, String],
|
|
139
|
-
default () {
|
|
140
|
-
return []
|
|
141
|
-
}
|
|
142
|
-
},
|
|
143
|
-
title: {
|
|
144
|
-
type: String,
|
|
145
|
-
default: ''
|
|
146
|
-
},
|
|
147
|
-
listStyles: {
|
|
148
|
-
type: Object,
|
|
149
|
-
default () {
|
|
150
|
-
return {
|
|
151
|
-
// 是否显示边框
|
|
152
|
-
border: true,
|
|
153
|
-
// 是否显示分隔线
|
|
154
|
-
dividline: true,
|
|
155
|
-
// 线条样式
|
|
156
|
-
borderStyle: {}
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
},
|
|
160
|
-
imageStyles: {
|
|
161
|
-
type: Object,
|
|
162
|
-
default () {
|
|
163
|
-
return {
|
|
164
|
-
width: 'auto',
|
|
165
|
-
height: 'auto'
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
},
|
|
169
|
-
readonly: {
|
|
170
|
-
type: Boolean,
|
|
171
|
-
default: false
|
|
172
|
-
},
|
|
173
|
-
returnType: {
|
|
174
|
-
type: String,
|
|
175
|
-
default: 'array'
|
|
176
|
-
},
|
|
177
|
-
sizeType: {
|
|
178
|
-
type: Array,
|
|
179
|
-
default () {
|
|
180
|
-
return ['original', 'compressed']
|
|
181
|
-
}
|
|
182
|
-
},
|
|
183
|
-
sourceType: {
|
|
184
|
-
type: Array,
|
|
185
|
-
default () {
|
|
186
|
-
return ['album', 'camera']
|
|
187
|
-
}
|
|
188
|
-
},
|
|
189
|
-
provider: {
|
|
190
|
-
type: String,
|
|
191
|
-
default: '' // 默认上传到 unicloud 内置存储 extStorage 扩展存储
|
|
192
|
-
}
|
|
193
|
-
},
|
|
194
|
-
data() {
|
|
195
|
-
return {
|
|
196
|
-
files: [],
|
|
197
|
-
localValue: []
|
|
198
|
-
}
|
|
199
|
-
},
|
|
200
|
-
watch: {
|
|
201
|
-
value: {
|
|
202
|
-
handler(newVal, oldVal) {
|
|
203
|
-
this.setValue(newVal, oldVal)
|
|
204
|
-
},
|
|
205
|
-
immediate: true
|
|
206
|
-
},
|
|
207
|
-
modelValue: {
|
|
208
|
-
handler(newVal, oldVal) {
|
|
209
|
-
this.setValue(newVal, oldVal)
|
|
210
|
-
},
|
|
211
|
-
immediate: true
|
|
212
|
-
},
|
|
213
|
-
},
|
|
214
|
-
computed: {
|
|
215
|
-
filesList() {
|
|
216
|
-
let files = []
|
|
217
|
-
this.files.forEach(v => {
|
|
218
|
-
files.push(v)
|
|
219
|
-
})
|
|
220
|
-
return files
|
|
221
|
-
},
|
|
222
|
-
showType() {
|
|
223
|
-
if (this.fileMediatype === 'image') {
|
|
224
|
-
return this.mode
|
|
225
|
-
}
|
|
226
|
-
return 'list'
|
|
227
|
-
},
|
|
228
|
-
limitLength() {
|
|
229
|
-
if (this.returnType === 'object') {
|
|
230
|
-
return 1
|
|
231
|
-
}
|
|
232
|
-
if (!this.limit) {
|
|
233
|
-
return 1
|
|
234
|
-
}
|
|
235
|
-
if (this.limit >= 9) {
|
|
236
|
-
return 9
|
|
237
|
-
}
|
|
238
|
-
return this.limit
|
|
239
|
-
}
|
|
240
|
-
},
|
|
241
|
-
created() {
|
|
242
|
-
// TODO 兼容不开通服务空间的情况
|
|
243
|
-
if (!(uniCloud.config && uniCloud.config.provider)) {
|
|
244
|
-
this.noSpace = true
|
|
245
|
-
uniCloud.chooseAndUploadFile = chooseAndUploadFile
|
|
246
|
-
}
|
|
247
|
-
this.form = this.getForm('uniForms')
|
|
248
|
-
this.formItem = this.getForm('uniFormsItem')
|
|
249
|
-
if (this.form && this.formItem) {
|
|
250
|
-
if (this.formItem.name) {
|
|
251
|
-
this.rename = this.formItem.name
|
|
252
|
-
this.form.inputChildrens.push(this)
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
},
|
|
256
|
-
methods: {
|
|
257
|
-
/**
|
|
258
|
-
* 公开用户使用,清空文件
|
|
259
|
-
* @param {Object} index
|
|
260
|
-
*/
|
|
261
|
-
clearFiles(index) {
|
|
262
|
-
if (index !== 0 && !index) {
|
|
263
|
-
this.files = []
|
|
264
|
-
this.$nextTick(() => {
|
|
265
|
-
this.setEmit()
|
|
266
|
-
})
|
|
267
|
-
} else {
|
|
268
|
-
this.files.splice(index, 1)
|
|
269
|
-
}
|
|
270
|
-
this.$nextTick(() => {
|
|
271
|
-
this.setEmit()
|
|
272
|
-
})
|
|
273
|
-
},
|
|
274
|
-
/**
|
|
275
|
-
* 公开用户使用,继续上传
|
|
276
|
-
*/
|
|
277
|
-
upload() {
|
|
278
|
-
let files = []
|
|
279
|
-
this.files.forEach((v, index) => {
|
|
280
|
-
if (v.status === 'ready' || v.status === 'error') {
|
|
281
|
-
files.push(Object.assign({}, v))
|
|
282
|
-
}
|
|
283
|
-
})
|
|
284
|
-
return this.uploadFiles(files)
|
|
285
|
-
},
|
|
286
|
-
async setValue(newVal, oldVal) {
|
|
287
|
-
const newData = async (v) => {
|
|
288
|
-
const reg = /cloud:\/\/([\w.]+\/?)\S*/
|
|
289
|
-
let url = ''
|
|
290
|
-
if(v.fileID){
|
|
291
|
-
url = v.fileID
|
|
292
|
-
}else{
|
|
293
|
-
url = v.url
|
|
294
|
-
}
|
|
295
|
-
if (reg.test(url)) {
|
|
296
|
-
v.fileID = url
|
|
297
|
-
v.url = await this.getTempFileURL(url)
|
|
298
|
-
}
|
|
299
|
-
if(v.url) v.path = v.url
|
|
300
|
-
return v
|
|
301
|
-
}
|
|
302
|
-
if (this.returnType === 'object') {
|
|
303
|
-
if (newVal) {
|
|
304
|
-
await newData(newVal)
|
|
305
|
-
} else {
|
|
306
|
-
newVal = {}
|
|
307
|
-
}
|
|
308
|
-
} else {
|
|
309
|
-
if (!newVal) newVal = []
|
|
310
|
-
for(let i =0 ;i < newVal.length ;i++){
|
|
311
|
-
let v = newVal[i]
|
|
312
|
-
await newData(v)
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
this.localValue = newVal
|
|
316
|
-
if (this.form && this.formItem &&!this.is_reset) {
|
|
317
|
-
this.is_reset = false
|
|
318
|
-
this.formItem.setValue(this.localValue)
|
|
319
|
-
}
|
|
320
|
-
let filesData = Object.keys(newVal).length > 0 ? newVal : [];
|
|
321
|
-
this.files = [].concat(filesData)
|
|
322
|
-
},
|
|
323
|
-
|
|
324
|
-
/**
|
|
325
|
-
* 选择文件
|
|
326
|
-
*/
|
|
327
|
-
choose() {
|
|
328
|
-
if (this.disabled) return
|
|
329
|
-
if (this.files.length >= Number(this.limitLength) && this.showType !== 'grid' && this.returnType ===
|
|
330
|
-
'array') {
|
|
331
|
-
uni.showToast({
|
|
332
|
-
title: `您最多选择 ${this.limitLength} 个文件`,
|
|
333
|
-
icon: 'none'
|
|
334
|
-
})
|
|
335
|
-
return
|
|
336
|
-
}
|
|
337
|
-
this.chooseFiles()
|
|
338
|
-
},
|
|
339
|
-
|
|
340
|
-
/**
|
|
341
|
-
* 选择文件并上传
|
|
342
|
-
*/
|
|
343
|
-
chooseFiles() {
|
|
344
|
-
const _extname = get_extname(this.fileExtname)
|
|
345
|
-
// 获取后缀
|
|
346
|
-
uniCloud
|
|
347
|
-
.chooseAndUploadFile({
|
|
348
|
-
type: this.fileMediatype,
|
|
349
|
-
compressed: false,
|
|
350
|
-
sizeType: this.sizeType,
|
|
351
|
-
sourceType: this.sourceType,
|
|
352
|
-
// TODO 如果为空,video 有问题
|
|
353
|
-
extension: _extname.length > 0 ? _extname : undefined,
|
|
354
|
-
count: this.limitLength - this.files.length, //默认9
|
|
355
|
-
onChooseFile: this.chooseFileCallback,
|
|
356
|
-
onUploadProgress: progressEvent => {
|
|
357
|
-
this.setProgress(progressEvent, progressEvent.index)
|
|
358
|
-
}
|
|
359
|
-
})
|
|
360
|
-
.then(result => {
|
|
361
|
-
this.setSuccessAndError(result.tempFiles)
|
|
362
|
-
})
|
|
363
|
-
.catch(err => {
|
|
364
|
-
console.log('选择失败', err)
|
|
365
|
-
})
|
|
366
|
-
},
|
|
367
|
-
|
|
368
|
-
/**
|
|
369
|
-
* 选择文件回调
|
|
370
|
-
* @param {Object} res
|
|
371
|
-
*/
|
|
372
|
-
async chooseFileCallback(res) {
|
|
373
|
-
const _extname = get_extname(this.fileExtname)
|
|
374
|
-
const is_one = (Number(this.limitLength) === 1 &&
|
|
375
|
-
this.disablePreview &&
|
|
376
|
-
!this.disabled) ||
|
|
377
|
-
this.returnType === 'object'
|
|
378
|
-
// 如果这有一个文件 ,需要清空本地缓存数据
|
|
379
|
-
if (is_one) {
|
|
380
|
-
this.files = []
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
let {
|
|
384
|
-
filePaths,
|
|
385
|
-
files
|
|
386
|
-
} = get_files_and_is_max(res, _extname)
|
|
387
|
-
if (!(_extname && _extname.length > 0)) {
|
|
388
|
-
filePaths = res.tempFilePaths
|
|
389
|
-
files = res.tempFiles
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
let currentData = []
|
|
393
|
-
for (let i = 0; i < files.length; i++) {
|
|
394
|
-
if (this.limitLength - this.files.length <= 0) break
|
|
395
|
-
files[i].uuid = Date.now()
|
|
396
|
-
let filedata = await get_file_data(files[i], this.fileMediatype)
|
|
397
|
-
filedata.progress = 0
|
|
398
|
-
filedata.status = 'ready'
|
|
399
|
-
this.files.push(filedata)
|
|
400
|
-
currentData.push({
|
|
401
|
-
...filedata,
|
|
402
|
-
file: files[i]
|
|
403
|
-
})
|
|
404
|
-
}
|
|
405
|
-
this.$emit('select', {
|
|
406
|
-
tempFiles: currentData,
|
|
407
|
-
tempFilePaths: filePaths
|
|
408
|
-
})
|
|
409
|
-
res.tempFiles = files
|
|
410
|
-
// 停止自动上传
|
|
411
|
-
if (!this.autoUpload || this.noSpace) {
|
|
412
|
-
res.tempFiles = []
|
|
413
|
-
}
|
|
414
|
-
res.tempFiles.forEach((fileItem, index) => {
|
|
415
|
-
this.provider && (fileItem.provider = this.provider);
|
|
416
|
-
const fileNameSplit = fileItem.name.split('.')
|
|
417
|
-
const ext = fileNameSplit.pop()
|
|
418
|
-
const fileName = fileNameSplit.join('.').replace(/[\s\/\?<>\\:\*\|":]/g, '_')
|
|
419
|
-
fileItem.cloudPath = fileName + '_' + Date.now() + '_' + index + '.' + ext
|
|
420
|
-
})
|
|
421
|
-
},
|
|
422
|
-
|
|
423
|
-
/**
|
|
424
|
-
* 批传
|
|
425
|
-
* @param {Object} e
|
|
426
|
-
*/
|
|
427
|
-
uploadFiles(files) {
|
|
428
|
-
files = [].concat(files)
|
|
429
|
-
return uploadCloudFiles.call(this, files, 5, res => {
|
|
430
|
-
this.setProgress(res, res.index, true)
|
|
431
|
-
})
|
|
432
|
-
.then(result => {
|
|
433
|
-
this.setSuccessAndError(result)
|
|
434
|
-
return result;
|
|
435
|
-
})
|
|
436
|
-
.catch(err => {
|
|
437
|
-
console.log(err)
|
|
438
|
-
})
|
|
439
|
-
},
|
|
440
|
-
|
|
441
|
-
/**
|
|
442
|
-
* 成功或失败
|
|
443
|
-
*/
|
|
444
|
-
async setSuccessAndError(res, fn) {
|
|
445
|
-
let successData = []
|
|
446
|
-
let errorData = []
|
|
447
|
-
let tempFilePath = []
|
|
448
|
-
let errorTempFilePath = []
|
|
449
|
-
for (let i = 0; i < res.length; i++) {
|
|
450
|
-
const item = res[i]
|
|
451
|
-
const index = item.uuid ? this.files.findIndex(p => p.uuid === item.uuid) : item.index
|
|
452
|
-
|
|
453
|
-
if (index === -1 || !this.files) break
|
|
454
|
-
if (item.errMsg === 'request:fail') {
|
|
455
|
-
this.files[index].url = item.path
|
|
456
|
-
this.files[index].status = 'error'
|
|
457
|
-
this.files[index].errMsg = item.errMsg
|
|
458
|
-
// this.files[index].progress = -1
|
|
459
|
-
errorData.push(this.files[index])
|
|
460
|
-
errorTempFilePath.push(this.files[index].url)
|
|
461
|
-
} else {
|
|
462
|
-
this.files[index].errMsg = ''
|
|
463
|
-
this.files[index].fileID = item.url
|
|
464
|
-
const reg = /cloud:\/\/([\w.]+\/?)\S*/
|
|
465
|
-
if (reg.test(item.url)) {
|
|
466
|
-
this.files[index].url = await this.getTempFileURL(item.url)
|
|
467
|
-
}else{
|
|
468
|
-
this.files[index].url = item.url
|
|
469
|
-
}
|
|
470
|
-
|
|
471
|
-
this.files[index].status = 'success'
|
|
472
|
-
this.files[index].progress += 1
|
|
473
|
-
successData.push(this.files[index])
|
|
474
|
-
tempFilePath.push(this.files[index].fileID)
|
|
475
|
-
}
|
|
476
|
-
}
|
|
477
|
-
|
|
478
|
-
if (successData.length > 0) {
|
|
479
|
-
this.setEmit()
|
|
480
|
-
// 状态改变返回
|
|
481
|
-
this.$emit('success', {
|
|
482
|
-
tempFiles: this.backObject(successData),
|
|
483
|
-
tempFilePaths: tempFilePath
|
|
484
|
-
})
|
|
485
|
-
}
|
|
486
|
-
|
|
487
|
-
if (errorData.length > 0) {
|
|
488
|
-
this.$emit('fail', {
|
|
489
|
-
tempFiles: this.backObject(errorData),
|
|
490
|
-
tempFilePaths: errorTempFilePath
|
|
491
|
-
})
|
|
492
|
-
}
|
|
493
|
-
},
|
|
494
|
-
|
|
495
|
-
/**
|
|
496
|
-
* 获取进度
|
|
497
|
-
* @param {Object} progressEvent
|
|
498
|
-
* @param {Object} index
|
|
499
|
-
* @param {Object} type
|
|
500
|
-
*/
|
|
501
|
-
setProgress(progressEvent, index, type) {
|
|
502
|
-
const fileLenth = this.files.length
|
|
503
|
-
const percentNum = (index / fileLenth) * 100
|
|
504
|
-
const percentCompleted = Math.round((progressEvent.loaded * 100) / progressEvent.total)
|
|
505
|
-
let idx = index
|
|
506
|
-
if (!type) {
|
|
507
|
-
idx = this.files.findIndex(p => p.uuid === progressEvent.tempFile.uuid)
|
|
508
|
-
}
|
|
509
|
-
if (idx === -1 || !this.files[idx]) return
|
|
510
|
-
// fix by mehaotian 100 就会消失,-1 是为了让进度条消失
|
|
511
|
-
this.files[idx].progress = percentCompleted - 1
|
|
512
|
-
// 上传中
|
|
513
|
-
this.$emit('progress', {
|
|
514
|
-
index: idx,
|
|
515
|
-
progress: parseInt(percentCompleted),
|
|
516
|
-
tempFile: this.files[idx]
|
|
517
|
-
})
|
|
518
|
-
},
|
|
519
|
-
|
|
520
|
-
/**
|
|
521
|
-
* 删除文件
|
|
522
|
-
* @param {Object} index
|
|
523
|
-
*/
|
|
524
|
-
delFile(index) {
|
|
525
|
-
this.$emit('delete', {
|
|
526
|
-
index,
|
|
527
|
-
tempFile: this.files[index],
|
|
528
|
-
tempFilePath: this.files[index].url
|
|
529
|
-
})
|
|
530
|
-
this.files.splice(index, 1)
|
|
531
|
-
this.$nextTick(() => {
|
|
532
|
-
this.setEmit()
|
|
533
|
-
})
|
|
534
|
-
},
|
|
535
|
-
|
|
536
|
-
/**
|
|
537
|
-
* 获取文件名和后缀
|
|
538
|
-
* @param {Object} name
|
|
539
|
-
*/
|
|
540
|
-
getFileExt(name) {
|
|
541
|
-
const last_len = name.lastIndexOf('.')
|
|
542
|
-
const len = name.length
|
|
543
|
-
return {
|
|
544
|
-
name: name.substring(0, last_len),
|
|
545
|
-
ext: name.substring(last_len + 1, len)
|
|
546
|
-
}
|
|
547
|
-
},
|
|
548
|
-
|
|
549
|
-
/**
|
|
550
|
-
* 处理返回事件
|
|
551
|
-
*/
|
|
552
|
-
setEmit() {
|
|
553
|
-
let data = []
|
|
554
|
-
if (this.returnType === 'object') {
|
|
555
|
-
data = this.backObject(this.files)[0]
|
|
556
|
-
this.localValue = data?data:null
|
|
557
|
-
} else {
|
|
558
|
-
data = this.backObject(this.files)
|
|
559
|
-
if (!this.localValue) {
|
|
560
|
-
this.localValue = []
|
|
561
|
-
}
|
|
562
|
-
this.localValue = [...data]
|
|
563
|
-
}
|
|
564
|
-
// #ifdef VUE3
|
|
565
|
-
this.$emit('update:modelValue', this.localValue)
|
|
566
|
-
// #endif
|
|
567
|
-
// #ifndef VUE3
|
|
568
|
-
this.$emit('input', this.localValue)
|
|
569
|
-
// #endif
|
|
570
|
-
},
|
|
571
|
-
|
|
572
|
-
/**
|
|
573
|
-
* 处理返回参数
|
|
574
|
-
* @param {Object} files
|
|
575
|
-
*/
|
|
576
|
-
backObject(files) {
|
|
577
|
-
let newFilesData = []
|
|
578
|
-
files.forEach(v => {
|
|
579
|
-
newFilesData.push({
|
|
580
|
-
extname: v.extname,
|
|
581
|
-
fileType: v.fileType,
|
|
582
|
-
image: v.image,
|
|
583
|
-
name: v.name,
|
|
584
|
-
path: v.path,
|
|
585
|
-
size: v.size,
|
|
586
|
-
fileID:v.fileID,
|
|
587
|
-
url: v.url,
|
|
588
|
-
// 修改删除一个文件后不能再上传的bug, #694
|
|
589
|
-
uuid: v.uuid,
|
|
590
|
-
status: v.status,
|
|
591
|
-
cloudPath: v.cloudPath
|
|
592
|
-
})
|
|
593
|
-
})
|
|
594
|
-
return newFilesData
|
|
595
|
-
},
|
|
596
|
-
async getTempFileURL(fileList) {
|
|
597
|
-
fileList = {
|
|
598
|
-
fileList: [].concat(fileList)
|
|
599
|
-
}
|
|
600
|
-
const urls = await uniCloud.getTempFileURL(fileList)
|
|
601
|
-
return urls.fileList[0].tempFileURL || ''
|
|
602
|
-
},
|
|
603
|
-
/**
|
|
604
|
-
* 获取父元素实例
|
|
605
|
-
*/
|
|
606
|
-
getForm(name = 'uniForms') {
|
|
607
|
-
let parent = this.$parent;
|
|
608
|
-
let parentName = parent.$options.name;
|
|
609
|
-
while (parentName !== name) {
|
|
610
|
-
parent = parent.$parent;
|
|
611
|
-
if (!parent) return false;
|
|
612
|
-
parentName = parent.$options.name;
|
|
613
|
-
}
|
|
614
|
-
return parent;
|
|
615
|
-
}
|
|
616
|
-
}
|
|
617
|
-
}
|
|
618
|
-
</script>
|
|
619
|
-
|
|
620
|
-
<style>
|
|
621
|
-
.uni-file-picker {
|
|
622
|
-
/* #ifndef APP-NVUE */
|
|
623
|
-
box-sizing: border-box;
|
|
624
|
-
overflow: hidden;
|
|
625
|
-
width: 100%;
|
|
626
|
-
/* #endif */
|
|
627
|
-
flex: 1;
|
|
628
|
-
}
|
|
629
|
-
|
|
630
|
-
.uni-file-picker__header {
|
|
631
|
-
padding-top: 5px;
|
|
632
|
-
padding-bottom: 10px;
|
|
633
|
-
/* #ifndef APP-NVUE */
|
|
634
|
-
display: flex;
|
|
635
|
-
/* #endif */
|
|
636
|
-
justify-content: space-between;
|
|
637
|
-
}
|
|
638
|
-
|
|
639
|
-
.file-title {
|
|
640
|
-
font-size: 14px;
|
|
641
|
-
color: #333;
|
|
642
|
-
}
|
|
643
|
-
|
|
644
|
-
.file-count {
|
|
645
|
-
font-size: 14px;
|
|
646
|
-
color: #999;
|
|
647
|
-
}
|
|
648
|
-
|
|
649
|
-
.is-add {
|
|
650
|
-
/* #ifndef APP-NVUE */
|
|
651
|
-
display: flex;
|
|
652
|
-
/* #endif */
|
|
653
|
-
align-items: center;
|
|
654
|
-
justify-content: center;
|
|
655
|
-
}
|
|
656
|
-
|
|
657
|
-
.icon-add {
|
|
658
|
-
width: 50px;
|
|
659
|
-
height: 5px;
|
|
660
|
-
background-color: #f1f1f1;
|
|
661
|
-
border-radius: 2px;
|
|
662
|
-
}
|
|
663
|
-
|
|
664
|
-
.rotate {
|
|
665
|
-
position: absolute;
|
|
666
|
-
transform: rotate(90deg);
|
|
667
|
-
}
|
|
668
|
-
</style>
|