@netang/quasar 0.0.20
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/LICENSE +21 -0
- package/README.md +17 -0
- package/components/column-title/index.vue +32 -0
- package/components/dialog/components/index.js +6 -0
- package/components/dialog/components/move-to-tree/index.vue +150 -0
- package/components/dialog/index.vue +330 -0
- package/components/dialog-table/index.vue +92 -0
- package/components/dragger/index.vue +202 -0
- package/components/drawer/index.vue +262 -0
- package/components/field-date/index.vue +844 -0
- package/components/field-date/methods.js +100 -0
- package/components/field-table/index.vue +468 -0
- package/components/field-text/index.vue +167 -0
- package/components/field-tree/index.vue +435 -0
- package/components/input-number/index.vue +324 -0
- package/components/input-number/number.js +67 -0
- package/components/input-price-cent/index.vue +213 -0
- package/components/input-price-yuan/index.vue +179 -0
- package/components/layout/index.vue +119 -0
- package/components/list-menu/index.vue +137 -0
- package/components/list-menu-item/index.vue +79 -0
- package/components/power-data/index.vue +667 -0
- package/components/search/index.vue +176 -0
- package/components/search-item/index.vue +219 -0
- package/components/select/index.vue +71 -0
- package/components/select-filter/index.vue +75 -0
- package/components/table/index.vue +347 -0
- package/components/table-column-fixed/index.vue +68 -0
- package/components/table-pagination/index.vue +83 -0
- package/components/table-summary/index.vue +91 -0
- package/components/thumbnail/index.vue +87 -0
- package/components/toolbar/container.vue +31 -0
- package/components/toolbar/index.vue +405 -0
- package/components/uploader/index.vue +157 -0
- package/components/uploader-query/index.vue +731 -0
- package/package.json +21 -0
- package/sass/common.scss +165 -0
- package/sass/index.scss +14 -0
- package/sass/line.scss +39 -0
- package/sass/quasar/btn.scss +46 -0
- package/sass/quasar/common.scss +3 -0
- package/sass/quasar/dialog.scss +7 -0
- package/sass/quasar/drawer.scss +6 -0
- package/sass/quasar/field.scss +210 -0
- package/sass/quasar/loading.scss +6 -0
- package/sass/quasar/menu.scss +8 -0
- package/sass/quasar/table.scss +112 -0
- package/sass/quasar/toolbar.scss +22 -0
- package/store/index.js +32 -0
- package/utils/$area.js +387 -0
- package/utils/$auth.js +135 -0
- package/utils/$dialog.js +43 -0
- package/utils/$role.js +807 -0
- package/utils/$rule.js +17 -0
- package/utils/$search.js +336 -0
- package/utils/$table.js +802 -0
- package/utils/$tree.js +620 -0
- package/utils/$uploader.js +1029 -0
- package/utils/alert.js +10 -0
- package/utils/bus.js +6 -0
- package/utils/config.js +22 -0
- package/utils/confrim.js +11 -0
- package/utils/dict.js +44 -0
- package/utils/getData.js +61 -0
- package/utils/getFile.js +30 -0
- package/utils/getImage.js +136 -0
- package/utils/getTime.js +94 -0
- package/utils/http.js +251 -0
- package/utils/loading.js +13 -0
- package/utils/notify.js +13 -0
- package/utils/previewImage.js +8 -0
- package/utils/symbols.js +3 -0
- package/utils/timestamp.js +18 -0
- package/utils/toast.js +13 -0
- package/utils/uploader/aliyun.js +6 -0
- package/utils/uploader/local.js +8 -0
- package/utils/uploader/qiniu.js +311 -0
- package/utils/useAuth.js +26 -0
- package/utils/useRouter.js +36 -0
- package/utils/useUploader.js +58 -0
|
@@ -0,0 +1,405 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<container
|
|
3
|
+
:header="header"
|
|
4
|
+
>
|
|
5
|
+
<q-toolbar>
|
|
6
|
+
|
|
7
|
+
<!-- 左边按钮-->
|
|
8
|
+
<q-btn
|
|
9
|
+
:icon="leftIcon"
|
|
10
|
+
dense
|
|
11
|
+
round
|
|
12
|
+
flat
|
|
13
|
+
@click="layoutData.left.toggle"
|
|
14
|
+
v-if="hiddenLeft ? ! layoutData.left.show() : (layoutData.left.data !== null)"
|
|
15
|
+
/>
|
|
16
|
+
|
|
17
|
+
<!-- 左边插槽 -->
|
|
18
|
+
<slot name="left" />
|
|
19
|
+
|
|
20
|
+
<!-- 中间插槽 -->
|
|
21
|
+
<q-toolbar-title>
|
|
22
|
+
<q-scroll-area style="height:50px;" v-if="! inDialog">
|
|
23
|
+
<div class="n-toolbar__body">
|
|
24
|
+
|
|
25
|
+
<!-- 权限按钮 -->
|
|
26
|
+
<template v-for="item in currentRoleBtnLists">
|
|
27
|
+
<q-btn
|
|
28
|
+
class="n-button-icon"
|
|
29
|
+
:color="item.color"
|
|
30
|
+
:outline="item.color === 'default'"
|
|
31
|
+
:label="item.title"
|
|
32
|
+
:icon="item.icon"
|
|
33
|
+
v-if="! item.hidden"
|
|
34
|
+
v-show="item.show"
|
|
35
|
+
@click="onClick(item, tableSelected)"
|
|
36
|
+
unelevated
|
|
37
|
+
/>
|
|
38
|
+
</template>
|
|
39
|
+
|
|
40
|
+
<!-- 插槽 -->
|
|
41
|
+
<slot />
|
|
42
|
+
|
|
43
|
+
<!--</div>-->
|
|
44
|
+
</div>
|
|
45
|
+
</q-scroll-area>
|
|
46
|
+
</q-toolbar-title>
|
|
47
|
+
|
|
48
|
+
<!-- 右边插槽 -->
|
|
49
|
+
<slot name="right" />
|
|
50
|
+
|
|
51
|
+
<!-- 表格筛选列按钮-->
|
|
52
|
+
<q-btn
|
|
53
|
+
icon="checklist"
|
|
54
|
+
dense
|
|
55
|
+
round
|
|
56
|
+
flat
|
|
57
|
+
v-if="tableColumns"
|
|
58
|
+
>
|
|
59
|
+
<q-menu
|
|
60
|
+
self="top middle"
|
|
61
|
+
:offset="[0, 8]"
|
|
62
|
+
>
|
|
63
|
+
<q-list style="min-width: 250px" dense bordered>
|
|
64
|
+
|
|
65
|
+
<!-- 表格宫格 -->
|
|
66
|
+
<template v-if="tableGrid !== null">
|
|
67
|
+
<q-item
|
|
68
|
+
clickable
|
|
69
|
+
@click="onTableGrid"
|
|
70
|
+
>
|
|
71
|
+
<q-item-section>宫格模式</q-item-section>
|
|
72
|
+
<q-item-section side>
|
|
73
|
+
<q-icon
|
|
74
|
+
size="xs"
|
|
75
|
+
name="check"
|
|
76
|
+
v-show="tableGrid"
|
|
77
|
+
/>
|
|
78
|
+
</q-item-section>
|
|
79
|
+
</q-item>
|
|
80
|
+
<q-separator />
|
|
81
|
+
</template>
|
|
82
|
+
|
|
83
|
+
<!-- 筛选表格列 -->
|
|
84
|
+
<q-item
|
|
85
|
+
v-for="item in tableColumns"
|
|
86
|
+
clickable
|
|
87
|
+
@click="onTableVisible(item)"
|
|
88
|
+
>
|
|
89
|
+
<q-item-section>{{item.label}}</q-item-section>
|
|
90
|
+
<q-item-section side>
|
|
91
|
+
<q-icon
|
|
92
|
+
size="xs"
|
|
93
|
+
name="check"
|
|
94
|
+
v-show="utils.indexOf(tableVisibleColumns, item.name) > -1"
|
|
95
|
+
/>
|
|
96
|
+
</q-item-section>
|
|
97
|
+
</q-item>
|
|
98
|
+
</q-list>
|
|
99
|
+
</q-menu>
|
|
100
|
+
</q-btn>
|
|
101
|
+
|
|
102
|
+
<!-- 右边按钮-->
|
|
103
|
+
<q-btn
|
|
104
|
+
:icon="rightIcon"
|
|
105
|
+
dense
|
|
106
|
+
round
|
|
107
|
+
flat
|
|
108
|
+
@click="layoutData.right.toggle"
|
|
109
|
+
v-if="hiddenRight ? ! layoutData.right.show() : (layoutData.right.data !== null)"
|
|
110
|
+
/>
|
|
111
|
+
</q-toolbar>
|
|
112
|
+
</container>
|
|
113
|
+
</template>
|
|
114
|
+
|
|
115
|
+
<script>
|
|
116
|
+
import { inject, computed, ref } from 'vue'
|
|
117
|
+
import { useRoute } from 'vue-router'
|
|
118
|
+
import { useQuasar } from 'quasar'
|
|
119
|
+
|
|
120
|
+
import Container from './container'
|
|
121
|
+
import { NLayoutKey } from '../../utils/symbols'
|
|
122
|
+
|
|
123
|
+
export default {
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* 标识
|
|
127
|
+
*/
|
|
128
|
+
name: 'NToolbar',
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* 容器
|
|
132
|
+
*/
|
|
133
|
+
components: {
|
|
134
|
+
Container,
|
|
135
|
+
},
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* 声明属性
|
|
139
|
+
*/
|
|
140
|
+
props: {
|
|
141
|
+
// 值(权限按钮列表)
|
|
142
|
+
modelValue: Array,
|
|
143
|
+
// 表格宫格
|
|
144
|
+
tableGrid: {
|
|
145
|
+
type: Boolean,
|
|
146
|
+
default: null,
|
|
147
|
+
},
|
|
148
|
+
// 表格可见列
|
|
149
|
+
tableVisibleColumns: Array,
|
|
150
|
+
|
|
151
|
+
// 传参
|
|
152
|
+
query: Object,
|
|
153
|
+
// 表格列
|
|
154
|
+
tableColumns: Array,
|
|
155
|
+
// 表格选中数据
|
|
156
|
+
tableSelected: Array,
|
|
157
|
+
// 表格刷新
|
|
158
|
+
tableRefresh: Function,
|
|
159
|
+
// 表单节点
|
|
160
|
+
formRef: Function,
|
|
161
|
+
// 表单数据
|
|
162
|
+
formData: Object,
|
|
163
|
+
// 重置表单
|
|
164
|
+
resetForm: Function,
|
|
165
|
+
// 请求前执行
|
|
166
|
+
requestBefore: Function,
|
|
167
|
+
// 请求成功执行
|
|
168
|
+
requestSuccess: Function,
|
|
169
|
+
// 请求失败执行
|
|
170
|
+
requestFail: Function,
|
|
171
|
+
// 请求后执行
|
|
172
|
+
requestAfter: Function,
|
|
173
|
+
// 左边图标
|
|
174
|
+
leftIcon: {
|
|
175
|
+
type: String,
|
|
176
|
+
default: 'format_list_bulleted',
|
|
177
|
+
},
|
|
178
|
+
// 默认隐藏左边(宽屏不显示, 小屏自动显示)
|
|
179
|
+
hiddenLeft: Boolean,
|
|
180
|
+
// 左边图标
|
|
181
|
+
rightIcon: {
|
|
182
|
+
type: String,
|
|
183
|
+
default: 'search',
|
|
184
|
+
},
|
|
185
|
+
// 是否请求权限按钮数据
|
|
186
|
+
getRoleBtn: {
|
|
187
|
+
type: Boolean,
|
|
188
|
+
default: true,
|
|
189
|
+
},
|
|
190
|
+
// 是否隐藏右边(宽屏不显示, 小屏自动显示)
|
|
191
|
+
hiddenRight: Boolean,
|
|
192
|
+
// 是否头部
|
|
193
|
+
header: Boolean,
|
|
194
|
+
},
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* 声明事件
|
|
198
|
+
*/
|
|
199
|
+
emits: [
|
|
200
|
+
'update:modelValue',
|
|
201
|
+
'update:tableVisibleColumns',
|
|
202
|
+
],
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* 组合式
|
|
206
|
+
*/
|
|
207
|
+
setup(props, { emit }) {
|
|
208
|
+
|
|
209
|
+
// ==========【注入】============================================================================================
|
|
210
|
+
|
|
211
|
+
// 获取布局注入数据
|
|
212
|
+
const $nLayout = inject(NLayoutKey)
|
|
213
|
+
|
|
214
|
+
// 是否在对话框中
|
|
215
|
+
const inDialog = ref(!! utils.$dialog.inject())
|
|
216
|
+
|
|
217
|
+
// ==========【数据】============================================================================================
|
|
218
|
+
|
|
219
|
+
// quasar 对象
|
|
220
|
+
const $q = useQuasar()
|
|
221
|
+
|
|
222
|
+
// 当前路由地址
|
|
223
|
+
const $route = useRoute()
|
|
224
|
+
|
|
225
|
+
// ==========【计算属性】=========================================================================================
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* 当前权限按钮
|
|
229
|
+
*/
|
|
230
|
+
const currentRoleBtnLists = computed(function() {
|
|
231
|
+
|
|
232
|
+
if (utils.isValidArray(props.modelValue)) {
|
|
233
|
+
|
|
234
|
+
const lists = _.filter(utils.$role.formatRoleBtnLists(props.modelValue), e => e.type > 2)
|
|
235
|
+
|
|
236
|
+
// 格式化权限按钮列表
|
|
237
|
+
utils.forEach(lists, function(item) {
|
|
238
|
+
|
|
239
|
+
if (! item.hidden) {
|
|
240
|
+
|
|
241
|
+
// 如果是单条数据显示
|
|
242
|
+
const isSingle = item.show === 'single'
|
|
243
|
+
|
|
244
|
+
// 如果是单条 || 多条显示
|
|
245
|
+
if (isSingle || item.show === 'multi') {
|
|
246
|
+
|
|
247
|
+
// 初始为不显示
|
|
248
|
+
item.show = false
|
|
249
|
+
|
|
250
|
+
// 如果有数据
|
|
251
|
+
if (utils.isValidArray(props.tableSelected)) {
|
|
252
|
+
|
|
253
|
+
// 如果是单个显示
|
|
254
|
+
if (isSingle) {
|
|
255
|
+
item.show = props.tableSelected.length === 1
|
|
256
|
+
|
|
257
|
+
// 否则是多个显示
|
|
258
|
+
} else {
|
|
259
|
+
item.show = props.tableSelected.length >= 1
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
// 如果是手机模式
|
|
265
|
+
if ($q.platform.is.mobile) {
|
|
266
|
+
item.icon = undefined
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
})
|
|
270
|
+
|
|
271
|
+
return lists
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
return []
|
|
275
|
+
})
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* 权限传参
|
|
279
|
+
*/
|
|
280
|
+
const roleQuery = computed(function () {
|
|
281
|
+
|
|
282
|
+
const query = {}
|
|
283
|
+
|
|
284
|
+
// 合并路由传参
|
|
285
|
+
if (utils.isValidObject($route.query)) {
|
|
286
|
+
Object.assign(query, $route.query)
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
// 合并声明传参
|
|
290
|
+
if (utils.isValidObject(props.query)) {
|
|
291
|
+
Object.assign(query, props.query)
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
return utils.numberDeep(query)
|
|
295
|
+
})
|
|
296
|
+
|
|
297
|
+
// ==========【方法】=============================================================================================
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* 按钮点击
|
|
301
|
+
*/
|
|
302
|
+
async function onClick({ data }, tableSelected) {
|
|
303
|
+
|
|
304
|
+
// 角色请求
|
|
305
|
+
await utils.$role.request({
|
|
306
|
+
// 按钮数据
|
|
307
|
+
data,
|
|
308
|
+
// 传参
|
|
309
|
+
query: roleQuery.value,
|
|
310
|
+
// 表格选中数据
|
|
311
|
+
tableSelected,
|
|
312
|
+
// 表格刷新
|
|
313
|
+
tableRefresh: props.tableRefresh,
|
|
314
|
+
// 检查是否正在上传文件
|
|
315
|
+
checkUploading: $nLayout.checkUploading,
|
|
316
|
+
// 表单节点
|
|
317
|
+
formRef: props.formRef,
|
|
318
|
+
// 表单数据
|
|
319
|
+
formData: props.formData,
|
|
320
|
+
// 重置表单
|
|
321
|
+
resetForm: props.resetForm,
|
|
322
|
+
// 请求前执行
|
|
323
|
+
requestBefore: props.requestBefore,
|
|
324
|
+
// 请求数据执行
|
|
325
|
+
requestData: props.requestData,
|
|
326
|
+
// 请求成功执行
|
|
327
|
+
requestSuccess: props.requestSuccess,
|
|
328
|
+
// 请求后执行
|
|
329
|
+
requestAfter: props.requestAfter,
|
|
330
|
+
})
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
// 更新布局数据
|
|
334
|
+
$nLayout.update(function(data) {
|
|
335
|
+
Object.assign(data.role, {
|
|
336
|
+
click: onClick,
|
|
337
|
+
})
|
|
338
|
+
})
|
|
339
|
+
|
|
340
|
+
|
|
341
|
+
/**
|
|
342
|
+
* 表格宫格点击
|
|
343
|
+
*/
|
|
344
|
+
function onTableGrid() {
|
|
345
|
+
emit('update:tableGrid', ! props.tableGrid)
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
/**
|
|
349
|
+
* 表格可见列点击
|
|
350
|
+
*/
|
|
351
|
+
function onTableVisible(item) {
|
|
352
|
+
|
|
353
|
+
const columns = [...props.tableVisibleColumns]
|
|
354
|
+
|
|
355
|
+
const index = utils.indexOf(props.tableVisibleColumns, item.name)
|
|
356
|
+
if (index > -1) {
|
|
357
|
+
columns.splice(index, 1)
|
|
358
|
+
} else {
|
|
359
|
+
columns.push(item.name)
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
emit('update:tableVisibleColumns', columns)
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
// ==========【返回】=============================================================================================
|
|
366
|
+
|
|
367
|
+
return {
|
|
368
|
+
// 是否在对话框中
|
|
369
|
+
inDialog,
|
|
370
|
+
// 布局数据
|
|
371
|
+
layoutData: $nLayout.data,
|
|
372
|
+
// 当前权限按钮
|
|
373
|
+
currentRoleBtnLists,
|
|
374
|
+
|
|
375
|
+
// 按钮点击
|
|
376
|
+
onClick,
|
|
377
|
+
// 表格宫格点击
|
|
378
|
+
onTableGrid,
|
|
379
|
+
// 表格可见列点击
|
|
380
|
+
onTableVisible,
|
|
381
|
+
}
|
|
382
|
+
},
|
|
383
|
+
}
|
|
384
|
+
</script>
|
|
385
|
+
|
|
386
|
+
<style lang="scss">
|
|
387
|
+
@import "@/assets/sass/var.scss";
|
|
388
|
+
|
|
389
|
+
.n-toolbar {
|
|
390
|
+
&__body {
|
|
391
|
+
//height: 50px;
|
|
392
|
+
//display: flex;
|
|
393
|
+
//align-items: center;
|
|
394
|
+
|
|
395
|
+
.q-btn {
|
|
396
|
+
margin-top: 7px;
|
|
397
|
+
|
|
398
|
+
// 非第一个子节点
|
|
399
|
+
&:not(:first-child) {
|
|
400
|
+
margin-left: 7px;
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
</style>
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="n-uploader" v-if="pageStatus === true">
|
|
3
|
+
|
|
4
|
+
<!-- 隐藏上传文件输入框 -->
|
|
5
|
+
<input
|
|
6
|
+
ref="fileRef"
|
|
7
|
+
class="hidden"
|
|
8
|
+
type="file"
|
|
9
|
+
:multiple="count !== 1"
|
|
10
|
+
@change="uploader.fileChange"
|
|
11
|
+
>
|
|
12
|
+
|
|
13
|
+
<!-- 插槽 -->
|
|
14
|
+
<slot
|
|
15
|
+
:count="count"
|
|
16
|
+
:uploader="uploader"
|
|
17
|
+
:query="uploadFileLists"
|
|
18
|
+
/>
|
|
19
|
+
</div>
|
|
20
|
+
</template>
|
|
21
|
+
|
|
22
|
+
<script>
|
|
23
|
+
import {onMounted, ref, provide, inject} from 'vue'
|
|
24
|
+
import { NUploaderKey, NLayoutKey } from '../../utils/symbols'
|
|
25
|
+
|
|
26
|
+
export default {
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* 标识
|
|
30
|
+
*/
|
|
31
|
+
name: 'NUploader',
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* 声明属性
|
|
35
|
+
*/
|
|
36
|
+
props: {
|
|
37
|
+
// 值
|
|
38
|
+
modelValue: [String, Array],
|
|
39
|
+
// 上传文件类型, 可选值 file image video audio
|
|
40
|
+
type: {
|
|
41
|
+
type: String,
|
|
42
|
+
validator: v => [ 'file', 'image', 'video', 'audio'].includes(v),
|
|
43
|
+
default: 'image',
|
|
44
|
+
},
|
|
45
|
+
// 上传文件数量(0:不限)
|
|
46
|
+
count: {
|
|
47
|
+
type: Number,
|
|
48
|
+
default: 0,
|
|
49
|
+
},
|
|
50
|
+
// 单个文件的最大大小(单位: MB)
|
|
51
|
+
maxSize: Number,
|
|
52
|
+
// 单个文件的限制后缀
|
|
53
|
+
exts: Array,
|
|
54
|
+
// true: 值格式为数组, 如 ['xxxxxx', 'xxxxxx', 'xxxxxx']
|
|
55
|
+
// false: 值格式为字符串, 如 xxxxxx,xxxxxx,xxxxxx
|
|
56
|
+
valueArray: Boolean,
|
|
57
|
+
// 是否去重
|
|
58
|
+
unique: Boolean,
|
|
59
|
+
// 是否初始加载文件信息(仅图片有效, 其他类型自动会加载文件信息)
|
|
60
|
+
loadInfo: Boolean,
|
|
61
|
+
// 单文件上传提示(true: 提示上传替换, false: 不提示直接替换)
|
|
62
|
+
confirm: Boolean,
|
|
63
|
+
},
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* 声明事件
|
|
67
|
+
*/
|
|
68
|
+
emits: [
|
|
69
|
+
'update:modelValue',
|
|
70
|
+
'update',
|
|
71
|
+
],
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* 组合式
|
|
75
|
+
*/
|
|
76
|
+
setup(props, { emit }) {
|
|
77
|
+
|
|
78
|
+
// ==========【注入】============================================================================================
|
|
79
|
+
|
|
80
|
+
// 获取布局注入数据
|
|
81
|
+
const $nLayout = inject(NLayoutKey)
|
|
82
|
+
|
|
83
|
+
// ==========【数据】============================================================================================
|
|
84
|
+
|
|
85
|
+
// 页面状态
|
|
86
|
+
const pageStatus = ref(false)
|
|
87
|
+
|
|
88
|
+
// 上传文件输入框节点
|
|
89
|
+
const fileRef = ref(null)
|
|
90
|
+
|
|
91
|
+
// 上传文件列表
|
|
92
|
+
const uploadFileLists = ref([])
|
|
93
|
+
|
|
94
|
+
// 创建上传器
|
|
95
|
+
const uploader = utils.$uploader.create({
|
|
96
|
+
type: props.type,
|
|
97
|
+
// 声明属性
|
|
98
|
+
props,
|
|
99
|
+
// 上传文件输入框节点
|
|
100
|
+
fileRef,
|
|
101
|
+
// 上传文件列表
|
|
102
|
+
uploadFileLists,
|
|
103
|
+
// 更新值方法
|
|
104
|
+
onUpdateModelValue({ value }) {
|
|
105
|
+
emit('update:modelValue', value)
|
|
106
|
+
},
|
|
107
|
+
// 更新方法
|
|
108
|
+
onUpdate(res) {
|
|
109
|
+
emit('update', res)
|
|
110
|
+
},
|
|
111
|
+
})
|
|
112
|
+
|
|
113
|
+
// 更新布局数据
|
|
114
|
+
$nLayout.update(function(data) {
|
|
115
|
+
data.uploader.push(uploader)
|
|
116
|
+
})
|
|
117
|
+
|
|
118
|
+
// ==========【注入】=============================================================================================
|
|
119
|
+
|
|
120
|
+
provide(NUploaderKey, {
|
|
121
|
+
// 声明属性
|
|
122
|
+
props,
|
|
123
|
+
// 上传器
|
|
124
|
+
uploader,
|
|
125
|
+
// 文件队列
|
|
126
|
+
query: uploadFileLists,
|
|
127
|
+
})
|
|
128
|
+
|
|
129
|
+
// ==========【生命周期】=========================================================================================
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* 实例被挂载后调用
|
|
133
|
+
*/
|
|
134
|
+
onMounted( async function() {
|
|
135
|
+
|
|
136
|
+
// 初始化上传列表
|
|
137
|
+
await uploader.initUploadFileLists()
|
|
138
|
+
|
|
139
|
+
// 页面状态
|
|
140
|
+
pageStatus.value = true
|
|
141
|
+
})
|
|
142
|
+
|
|
143
|
+
// ==========【返回】=============================================================================================
|
|
144
|
+
|
|
145
|
+
return {
|
|
146
|
+
// 页面状态
|
|
147
|
+
pageStatus,
|
|
148
|
+
// 上传文件输入框节点
|
|
149
|
+
fileRef,
|
|
150
|
+
// 上传文件列表
|
|
151
|
+
uploadFileLists,
|
|
152
|
+
// 上传器
|
|
153
|
+
uploader,
|
|
154
|
+
}
|
|
155
|
+
},
|
|
156
|
+
}
|
|
157
|
+
</script>
|