@jari-ace/element-plus-component 0.6.3 → 0.6.5

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/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.3",
4
+ "version": "0.6.5",
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.11"
30
+ "@jari-ace/app-bolts": "0.7.12"
31
31
  },
32
32
  "devDependencies": {
33
33
  "@types/lodash-es": "^4.17.12",
@@ -1,13 +1,13 @@
1
1
  <script setup lang="ts">
2
- import type {ValidationInstance} from '../../hooks/useBackendValidations'
3
- import {inject, ref, watch, computed} from "vue";
4
- import {getValue, setValue} from "../../utils/objectUtils";
2
+ import type { ValidationInstance } from '../../hooks/useBackendValidations'
3
+ import { inject, ref, watch, computed } from "vue";
4
+ import { getValue, setValue } from "../../utils/objectUtils";
5
5
  import Uploader from "./uploader.vue";
6
6
 
7
7
  export interface JaUploaderProps {
8
- /**
9
- * 应用名
10
- */
8
+ /**
9
+ * 应用名
10
+ */
11
11
  serviceName: string,
12
12
  /**
13
13
  * 附件配置key
@@ -36,15 +36,15 @@ export interface JaUploaderProps {
36
36
  /**
37
37
  * 是否允许下载,为空表示采用应用里的附件设置
38
38
  */
39
- allowDownload?: boolean,
39
+ allowDownload?: boolean | null,
40
40
  /**
41
41
  * 是否允许删除,为空表示采用应用里的附件设置
42
42
  */
43
- allowDelete?: boolean,
43
+ allowDelete?: boolean | null,
44
44
  /**
45
45
  * 是否允许预览,为空表示采用应用里的附件设置
46
46
  */
47
- allowPreview?: boolean,
47
+ allowPreview?: boolean | null,
48
48
  /**
49
49
  * 布局方式: list-列表布局(默认), inline-行内布局
50
50
  */
@@ -52,10 +52,17 @@ export interface JaUploaderProps {
52
52
  /**
53
53
  * 是否隐藏下载所有按钮
54
54
  */
55
- hideDownloadAll?: boolean
55
+ hideDownloadAll?: boolean | null
56
56
  }
57
57
 
58
- const props = defineProps<JaUploaderProps>();
58
+ const props = withDefaults(defineProps<JaUploaderProps>(), {
59
+ layout: 'list',
60
+ allowUpload: undefined,
61
+ allowDownload: undefined,
62
+ allowDelete: undefined,
63
+ allowPreview: undefined,
64
+ hideDownloadAll: false
65
+ });
59
66
  const input = ref<InstanceType<typeof Uploader>>()
60
67
  const model = inject('aceFormModel') as Record<string, any>
61
68
  const prop = inject('aceFormItemProp') as string
@@ -85,22 +92,10 @@ defineExpose({
85
92
  </script>
86
93
 
87
94
  <template>
88
- <uploader :service-name="serviceName"
89
- :max-height="maxHeight"
90
- :height="height"
91
- :config-key="configKey"
92
- :attach-token="attachToken"
93
- :classification-level="classificationLevel"
94
- :allow-delete="allowDelete"
95
- :allow-download="allowDownload"
96
- :allow-preview="allowPreview"
97
- :layout="layout"
98
- :hide-download-all="hideDownloadAll"
99
- :allow-upload="allowUpload"
100
- v-model="mv"
101
- @change="onChange"></uploader>
95
+ <uploader :service-name="serviceName" :max-height="maxHeight" :height="height" :config-key="configKey"
96
+ :attach-token="attachToken" :classification-level="classificationLevel" :allow-delete="allowDelete"
97
+ :allow-download="allowDownload" :allow-preview="allowPreview" :layout="layout"
98
+ :hide-download-all="hideDownloadAll" :allow-upload="allowUpload" v-model="mv" @change="onChange"></uploader>
102
99
  </template>
103
100
 
104
- <style scoped lang="scss">
105
-
106
- </style>
101
+ <style scoped lang="scss"></style>
@@ -76,19 +76,19 @@ const props = withDefaults(defineProps<{
76
76
  /**
77
77
  * 是否允许上传, 为空表示采用应用里的附件设置
78
78
  */
79
- allowUpload?: boolean,
79
+ allowUpload?: boolean | null,
80
80
  /**
81
81
  * 是否允许下载,为空表示采用应用里的附件设置
82
82
  */
83
- allowDownload?: boolean,
83
+ allowDownload?: boolean | null,
84
84
  /**
85
85
  * 是否允许删除,为空表示采用应用里的附件设置
86
86
  */
87
- allowDelete?: boolean,
87
+ allowDelete?: boolean | null,
88
88
  /**
89
89
  * 是否允许预览,为空表示采用应用里的附件设置
90
90
  */
91
- allowPreview?: boolean,
91
+ allowPreview?: boolean | null,
92
92
  /**
93
93
  * 布局方式: list-列表布局(默认), inline-行内布局
94
94
  */
@@ -96,7 +96,7 @@ const props = withDefaults(defineProps<{
96
96
  /**
97
97
  * 是否隐藏下载所有按钮
98
98
  */
99
- hideDownloadAll?: boolean
99
+ hideDownloadAll?: boolean | null
100
100
  }>(), {
101
101
  layout: 'list',
102
102
  allowUpload: undefined,
@@ -235,7 +235,7 @@ function createUppyInstance() {
235
235
  });
236
236
 
237
237
  let urlPrefix = getUrlPrefix();
238
- uppy.use(Tus, {
238
+ uppy.use(Tus, {
239
239
  endpoint: new URL(urlPrefix + "/uploads", location.origin).toString(),
240
240
  withCredentials: true,
241
241
  retryDelays: undefined,
@@ -420,21 +420,61 @@ async function initNew() {
420
420
  }
421
421
 
422
422
  async function delUploadedFile(file: FileInfo) {
423
- await api.deleteFile(file.token || file.id);
424
- files.value = files.value.filter(f => f.id !== file.id);
425
- emits('fileInfosChanged', files.value)
423
+ const cfg = uploadInitParams.value?.fileConfig;
424
+ if (cfg) {
425
+ let fileToken = file.token;
426
+ if (cfg.isPublic) {
427
+ const token = {
428
+ storageKey: file.storageKey,
429
+ directory: file.fileDir,
430
+ id: file.id
431
+ }
432
+ fileToken = btoa(JSON.stringify(token))
433
+ }
434
+ await api.deleteFile(fileToken);
435
+ files.value = files.value.filter(f => f.id !== file.id);
436
+ emits('fileInfosChanged', files.value);
437
+ } else {
438
+ ElMessageBox.alert("无法删除文件“" + file.fileName + "”", "错误");
439
+ }
426
440
  }
427
441
 
428
- function previewFile(fileToken: string) {
429
- pdfSrc.value = new URL(getUrlPrefix() + "/uploads/preview/" + fileToken, location.origin).toString()
430
- pdfViewerVisible.value = true;
442
+ function previewFile(file: FileInfo) {
443
+ const cfg = uploadInitParams.value?.fileConfig;
444
+ if (cfg) {
445
+ let fileToken = file.token;
446
+ if (cfg.isPublic) {
447
+ const token = {
448
+ storageKey: file.storageKey,
449
+ directory: file.fileDir,
450
+ id: file.id
451
+ }
452
+ fileToken = btoa(JSON.stringify(token))
453
+ }
454
+ pdfSrc.value = new URL(getUrlPrefix() + "/uploads/preview/" + fileToken, location.origin).toString()
455
+ pdfViewerVisible.value = true;
456
+ } else {
457
+ ElMessageBox.alert("无法预览文件”" + file.fileName + "”", "错误");
458
+ }
431
459
  }
432
460
 
433
- async function downloadFile(fileToken: string) {
434
- await api.downloadFile(fileToken);
435
- var file = files.value.filter(f => fileToken === f.token)
436
- if (file && file.length > 0)
437
- emits('downloaded', file[0]);
461
+ async function downloadFile(file: FileInfo) {
462
+ const cfg = uploadInitParams.value?.fileConfig;
463
+ if (cfg) {
464
+ let fileToken = file.token;
465
+ if (cfg.isPublic) {
466
+ const token = {
467
+ storageKey: file.storageKey,
468
+ directory: file.fileDir,
469
+ id: file.id
470
+ }
471
+ fileToken = btoa(JSON.stringify(token))
472
+ }
473
+ await api.downloadFile(fileToken);
474
+ emits('downloaded', file);
475
+ } else {
476
+ ElMessageBox.alert("无法下载文件“" + file.fileName + "”", "错误");
477
+ }
438
478
  }
439
479
 
440
480
  function viewUppyDashboard() {
@@ -455,7 +495,7 @@ async function downloadAll() {
455
495
  function checkAllowUpload() {
456
496
  console.log('ja-uploader 上传权限调试:')
457
497
  console.log('props.allowUpload = ', props.allowUpload)
458
- if (props.allowUpload === false) return false;
498
+ if (props.allowUpload === false || props.allowUpload === true) return props.allowUpload;
459
499
  const cfg = uploadInitParams.value?.fileConfig;
460
500
  if (cfg) {
461
501
  let hasRole = true;
@@ -478,7 +518,7 @@ function checkAllowUpload() {
478
518
  function checkAllowDownload() {
479
519
  console.log('ja-uploader 下载权限调试:')
480
520
  console.log('props.allowDownload = ', props.allowDownload)
481
- if (props.allowDownload === false) return false;
521
+ if (props.allowDownload === false || props.allowDownload === true) return props.allowDownload;
482
522
  const cfg = uploadInitParams.value?.fileConfig;
483
523
  if (cfg) {
484
524
  let hasRole = true;
@@ -500,7 +540,7 @@ function checkAllowDownload() {
500
540
  function checkAllowDelete() {
501
541
  console.log('ja-uploader 删除权限调试:')
502
542
  console.log('props.allowDelete = ', props.allowDelete)
503
- if (props.allowDelete === false) return false;
543
+ if (props.allowDelete === false || props.allowDelete === true) return props.allowDelete;
504
544
  const cfg = uploadInitParams.value?.fileConfig;
505
545
  if (cfg) {
506
546
  let hasRole = true;
@@ -522,7 +562,7 @@ function checkAllowDelete() {
522
562
  function checkAllowPreview(file: FileInfo) {
523
563
  console.log('ja-uploader 预览权限调试:')
524
564
  console.log('props.allowPreview = ', props.allowPreview)
525
- if (props.allowPreview === false) return false;
565
+ if (props.allowPreview === false || props.allowPreview === true) return props.allowPreview;
526
566
  const cfg = uploadInitParams.value?.fileConfig;
527
567
  if (cfg) {
528
568
  if (cfg.disablePreview) {
@@ -588,8 +628,8 @@ function getFileIcon(fileName: string) {
588
628
  :disabled="loading" size="small" v-if="allowedClassificationLevels.length <= 1 && checkAllowUpload()">
589
629
  上传{{ uploadInitParams?.fileConfig.enableClassifiedLevel ? "(非密)" : "" }}
590
630
  </el-button>
591
- <el-button plain :icon="Download" @click="downloadAll" v-if="checkAllowDownload() && !hideDownloadAll" :loading="loading"
592
- :disabled="loading || files?.length === 0" size="small">
631
+ <el-button plain :icon="Download" @click="downloadAll" v-if="checkAllowDownload() && !hideDownloadAll"
632
+ :loading="loading" :disabled="loading || files?.length === 0" size="small">
593
633
  全部下载
594
634
  </el-button>
595
635
  <el-dropdown v-if="allowedClassificationLevels.length > 1 && checkAllowUpload()"
@@ -643,10 +683,10 @@ function getFileIcon(fileName: string) {
643
683
  </span>
644
684
  </div>
645
685
  <div class="popover-actions">
646
- <el-button link type="primary" @click="previewFile(file.token)"
686
+ <el-button link type="primary" @click="previewFile(file)"
647
687
  v-if="checkAllowPreview(file)">预览
648
688
  </el-button>
649
- <el-button link type="primary" @click="downloadFile(file.token)"
689
+ <el-button link type="primary" @click="downloadFile(file)"
650
690
  v-if="checkAllowDownload()">下载
651
691
  </el-button>
652
692
  <el-button link type="danger" @click="delUploadedFile(file)"
@@ -683,10 +723,9 @@ function getFileIcon(fileName: string) {
683
723
  </el-tooltip>
684
724
  </div>
685
725
  <div class="file-actions">
686
- <el-button link type="primary" @click="previewFile(file.token)"
687
- v-if="checkAllowPreview(file)">预览
726
+ <el-button link type="primary" @click="previewFile(file)" v-if="checkAllowPreview(file)">预览
688
727
  </el-button>
689
- <el-button link type="primary" @click="downloadFile(file.token)" v-if="checkAllowDownload()">下载
728
+ <el-button link type="primary" @click="downloadFile(file)" v-if="checkAllowDownload()">下载
690
729
  </el-button>
691
730
  <el-button link type="danger" @click="delUploadedFile(file)" v-if="checkAllowDelete()">删除
692
731
  </el-button>
@@ -698,7 +737,15 @@ function getFileIcon(fileName: string) {
698
737
  <pdf-viewer-modal :src="pdfSrc" v-model="pdfViewerVisible"></pdf-viewer-modal>
699
738
  </template>
700
739
 
701
- <style lang="scss" scoped>
740
+ <style>
741
+ /**
742
+ * Uppy Dashboard 全局样式
743
+ *
744
+ * 必须使用非 scoped 样式,因为 Uppy Dashboard 通过 Portal 挂载到 document.body,
745
+ * 不在当前组件的 DOM 树中,scoped 样式无法作用于它。
746
+ *
747
+ * z-index 设置为 9999,确保显示在 Element Plus 的 el-dialog (默认 z-index: 2000+) 之上。
748
+ */
702
749
  .uppy-Dashboard--modal {
703
750
  z-index: 9999 !important;
704
751
  }
@@ -706,7 +753,9 @@ function getFileIcon(fileName: string) {
706
753
  .uppy-Root {
707
754
  z-index: 9999;
708
755
  }
756
+ </style>
709
757
 
758
+ <style lang="scss" scoped>
710
759
  .ja-uploader {
711
760
  width: 100%;
712
761
  display: flex;