@jari-ace/element-plus-component 0.6.0 → 0.6.2
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/components/switch/JaSwitch.vue.d.ts +229 -170
- package/dist/components/switch/JaSwitch.vue.d.ts.map +1 -1
- package/dist/components/switch/JaSwitch.vue.js +4 -13
- package/dist/components/switch/JaSwitch.vue.js.map +1 -1
- package/dist/components/upload/JaUploader.vue.d.ts +6 -0
- package/dist/components/upload/JaUploader.vue.d.ts.map +1 -1
- package/dist/components/upload/index.d.ts +8 -0
- package/dist/components/upload/index.d.ts.map +1 -1
- package/dist/components/upload/uploader.vue.d.ts +2 -0
- package/dist/components/upload/uploader.vue.d.ts.map +1 -1
- package/dist/components/upload/uploader.vue.js +28 -8
- package/dist/components/upload/uploader.vue.js.map +1 -1
- package/lib/index.css +1 -1
- package/lib/index.js +2803 -2816
- package/lib/index.umd.cjs +30 -30
- package/package.json +2 -2
- package/packages/components/switch/JaSwitch.vue +5 -16
- package/packages/components/upload/uploader.vue +35 -9
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jari-ace/element-plus-component",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.6.
|
|
4
|
+
"version": "0.6.2",
|
|
5
5
|
"main": "lib/index.umd.cjs",
|
|
6
6
|
"module": "lib/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"pretty-bytes": "^7.1.0",
|
|
28
28
|
"vue-pdf-embed": "^2.1.3",
|
|
29
29
|
"vue-router": "^5.0.1",
|
|
30
|
-
"@jari-ace/app-bolts": "0.7.
|
|
30
|
+
"@jari-ace/app-bolts": "0.7.10"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@types/lodash-es": "^4.17.12",
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import type {ValidationInstance} from '../../hooks/useBackendValidations'
|
|
3
|
-
import {inject, ref, watch
|
|
3
|
+
import {inject, ref, watch} from "vue";
|
|
4
4
|
import {ElSwitch} from "element-plus";
|
|
5
|
-
import type { SwitchProps } from 'element-plus'
|
|
6
5
|
import {getValue, setValue} from "../../utils/objectUtils";
|
|
7
6
|
import type {EpPropMergeType} from "element-plus/es/utils";
|
|
8
7
|
|
|
9
|
-
const input = ref<
|
|
8
|
+
const input = ref<typeof ElSwitch>()
|
|
10
9
|
const model = inject('aceFormModel') as Record<string, any>
|
|
11
10
|
const prop = inject('aceFormItemProp') as string
|
|
12
11
|
const validator = inject('aceFormValidator') as ValidationInstance
|
|
@@ -14,11 +13,6 @@ const emit = defineEmits<{
|
|
|
14
13
|
change: [value: boolean | string | number]
|
|
15
14
|
}>()
|
|
16
15
|
|
|
17
|
-
export interface JaSwitchProps extends Partial<SwitchProps> {
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const props = defineProps<JaSwitchProps>()
|
|
21
|
-
|
|
22
16
|
function onChange(value: boolean | string | number) {
|
|
23
17
|
validator.removeFieldError(prop)
|
|
24
18
|
setValue(model.formData, prop, mv.value);
|
|
@@ -36,14 +30,9 @@ watch(() => model.formData, () => {
|
|
|
36
30
|
deep: true
|
|
37
31
|
})
|
|
38
32
|
|
|
39
|
-
const elementProps = computed(() => {
|
|
40
|
-
const { modelValue, ...rest } = props
|
|
41
|
-
return rest
|
|
42
|
-
})
|
|
43
|
-
|
|
44
33
|
defineExpose({
|
|
45
|
-
focus: () =>
|
|
46
|
-
blur: () =>
|
|
34
|
+
focus: () => input.value?.focus(),
|
|
35
|
+
blur: () => input.value?.blur(),
|
|
47
36
|
elSwitch: input
|
|
48
37
|
})
|
|
49
38
|
</script>
|
|
@@ -53,7 +42,7 @@ defineExpose({
|
|
|
53
42
|
ref="input"
|
|
54
43
|
v-model="mv"
|
|
55
44
|
@change="onChange"
|
|
56
|
-
v-bind="
|
|
45
|
+
v-bind="$attrs">
|
|
57
46
|
<template v-for="(_, name) in $slots" v-slot:[name]>
|
|
58
47
|
<slot :name="name"></slot>
|
|
59
48
|
</template>
|
|
@@ -175,6 +175,10 @@ const emits = defineEmits<{
|
|
|
175
175
|
* 单个文件上传失败事件
|
|
176
176
|
*/
|
|
177
177
|
uploadError: [file: AceFile, error: Error]
|
|
178
|
+
/**
|
|
179
|
+
* 获取平台记录的文件信息,当文件列表加载、上传、删除时会触发此事件,向外传递文件信息
|
|
180
|
+
*/
|
|
181
|
+
fileInfosChanged: [files: FileInfo[]]
|
|
178
182
|
/**
|
|
179
183
|
* 下载完成事件
|
|
180
184
|
*/
|
|
@@ -211,8 +215,11 @@ async function updateAllowedClassificationLevels() {
|
|
|
211
215
|
async function loadFileInfos() {
|
|
212
216
|
if (!curAttachToken.value) {
|
|
213
217
|
files.value = [];
|
|
218
|
+
emits('fileInfosChanged', files.value)
|
|
219
|
+
return;
|
|
214
220
|
}
|
|
215
221
|
files.value = await api.getFileList(curAttachToken.value!);
|
|
222
|
+
emits('fileInfosChanged', files.value)
|
|
216
223
|
}
|
|
217
224
|
|
|
218
225
|
function createUppyInstance() {
|
|
@@ -224,13 +231,12 @@ function createUppyInstance() {
|
|
|
224
231
|
autoProceed: true,
|
|
225
232
|
locale: zhCN
|
|
226
233
|
}).on("progress", progress => {
|
|
227
|
-
if (progress == 100) {
|
|
228
|
-
loadFileInfos();
|
|
229
|
-
}
|
|
230
234
|
uploadingProgress.value = progress;
|
|
231
235
|
});
|
|
232
|
-
|
|
233
|
-
|
|
236
|
+
|
|
237
|
+
let urlPrefix = getUrlPrefix();
|
|
238
|
+
uppy.use(Tus, {
|
|
239
|
+
endpoint: new URL(urlPrefix + "/uploads", location.origin).toString(),
|
|
234
240
|
withCredentials: true,
|
|
235
241
|
retryDelays: undefined,
|
|
236
242
|
chunkSize: !uploadInitParams.value?.chunkSize || uploadInitParams.value?.chunkSize
|
|
@@ -238,7 +244,8 @@ function createUppyInstance() {
|
|
|
238
244
|
parallelUploads: 1,
|
|
239
245
|
headers: {
|
|
240
246
|
aceAttachId: attachId.value!,
|
|
241
|
-
aceNewForm: isNewForm.value ? "yes" : "no"
|
|
247
|
+
aceNewForm: isNewForm.value ? "yes" : "no",
|
|
248
|
+
'X-Forwarded-Prefix': urlPrefix
|
|
242
249
|
},
|
|
243
250
|
metadata: {
|
|
244
251
|
attachId: attachId.value!,
|
|
@@ -251,7 +258,7 @@ function createUppyInstance() {
|
|
|
251
258
|
configKey: props.configKey,
|
|
252
259
|
appServiceName: props.serviceName,
|
|
253
260
|
classifiedLevel: selectedFileClassificationLevel.value.toString()
|
|
254
|
-
}
|
|
261
|
+
},
|
|
255
262
|
});
|
|
256
263
|
if (cfg.enableWebcam) {
|
|
257
264
|
uppy.use(Webcam, {
|
|
@@ -317,6 +324,10 @@ function createUppyInstance() {
|
|
|
317
324
|
}).on('upload-success', file => {
|
|
318
325
|
emits('uploadSuccess', file)
|
|
319
326
|
}).on('complete', (result) => {
|
|
327
|
+
if (result.failed || result.failed.length == 0) {
|
|
328
|
+
uppy.clear()
|
|
329
|
+
}
|
|
330
|
+
loadFileInfos()
|
|
320
331
|
emits('complete', result.successful, result.failed)
|
|
321
332
|
}).on('error', (error) => {
|
|
322
333
|
emits('error', error)
|
|
@@ -325,6 +336,18 @@ function createUppyInstance() {
|
|
|
325
336
|
})
|
|
326
337
|
}
|
|
327
338
|
|
|
339
|
+
function getUrlPrefix() {
|
|
340
|
+
let isDev = window.appDescriptor?.env.isDevMode();
|
|
341
|
+
if (window.rawWindow) {
|
|
342
|
+
isDev = window.rawWindow.appDescriptor.env.isDevMode();
|
|
343
|
+
}
|
|
344
|
+
let urlPrefix = "/ace-file-service";
|
|
345
|
+
if (isDev) {
|
|
346
|
+
urlPrefix = "/ace/ace-file-service";
|
|
347
|
+
}
|
|
348
|
+
return urlPrefix;
|
|
349
|
+
}
|
|
350
|
+
|
|
328
351
|
async function onUploadBtnClick() {
|
|
329
352
|
console.log('upload btn clicked')
|
|
330
353
|
const cfg = uploadInitParams.value?.fileConfig;
|
|
@@ -376,6 +399,7 @@ function handleClassificationLevelSelCmd(level: number) {
|
|
|
376
399
|
async function initLoad() {
|
|
377
400
|
uploadInitParams.value = await api.initLoad(props.serviceName, props.configKey, props.attachToken!);
|
|
378
401
|
files.value = uploadInitParams.value.files;
|
|
402
|
+
emits('fileInfosChanged', files.value)
|
|
379
403
|
attachId.value = uploadInitParams.value?.attachId;
|
|
380
404
|
curAttachToken.value = uploadInitParams.value?.attachId;
|
|
381
405
|
isNewForm.value = false;
|
|
@@ -386,6 +410,7 @@ async function initLoad() {
|
|
|
386
410
|
async function initNew() {
|
|
387
411
|
uploadInitParams.value = await api.initNew(props.serviceName, props.configKey);
|
|
388
412
|
files.value = uploadInitParams.value.files;
|
|
413
|
+
emits('fileInfosChanged', files.value)
|
|
389
414
|
attachId.value = uploadInitParams.value?.attachId;
|
|
390
415
|
curAttachToken.value = uploadInitParams.value?.attachToken;
|
|
391
416
|
isNewForm.value = true;
|
|
@@ -397,10 +422,11 @@ async function initNew() {
|
|
|
397
422
|
async function delUploadedFile(file: FileInfo) {
|
|
398
423
|
await api.deleteFile(file.token || file.id);
|
|
399
424
|
files.value = files.value.filter(f => f.id !== file.id);
|
|
425
|
+
emits('fileInfosChanged', files.value)
|
|
400
426
|
}
|
|
401
427
|
|
|
402
428
|
function previewFile(fileToken: string) {
|
|
403
|
-
pdfSrc.value = new URL("uploads/preview/" + fileToken, location.origin).toString()
|
|
429
|
+
pdfSrc.value = new URL(getUrlPrefix() + "/uploads/preview/" + fileToken, location.origin).toString()
|
|
404
430
|
pdfViewerVisible.value = true;
|
|
405
431
|
}
|
|
406
432
|
|
|
@@ -634,7 +660,7 @@ function getFileIcon(fileName: string) {
|
|
|
634
660
|
</div>
|
|
635
661
|
<div v-if="layout === 'list'" class="file-list"
|
|
636
662
|
:style="{ height: typeof props.height === 'number' ? props.height + 'px' : props.height, maxHeight: typeof props.maxHeight === 'number' ? props.maxHeight + 'px' : props.maxHeight }">
|
|
637
|
-
<div v-if="files?.length
|
|
663
|
+
<div v-if="!files || files?.length == 0" class="empty-text">暂无文件</div>
|
|
638
664
|
<div v-for="file in files" :key="file.id" class="file-item">
|
|
639
665
|
<div class="file-main">
|
|
640
666
|
<el-icon class="file-icon">
|