agilebuilder-ui 1.0.621 → 1.0.962

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.
Files changed (120) hide show
  1. package/lib/super-ui.css +1 -1
  2. package/lib/super-ui.js +115880 -110424
  3. package/lib/super-ui.umd.cjs +103 -95
  4. package/package.json +6 -3
  5. package/packages/department-tree/src/department-tree.vue +27 -10
  6. package/packages/department-tree-inline/src/department-tree-service.js +20 -41
  7. package/packages/department-tree-mobile/src/department-tree-app.vue +6 -6
  8. package/packages/department-tree-mobile/src/department-tree-inline-app.vue +15 -15
  9. package/packages/department-user-tree/src/department-user-tree.vue +17 -2
  10. package/packages/department-user-tree-inline/src/department-user-multiple-tree-inline.vue +61 -26
  11. package/packages/department-user-tree-inline/src/department-user-single-tree-inline.vue +64 -22
  12. package/packages/department-user-tree-inline/src/department-user-tree-single-service.js +0 -6
  13. package/packages/department-user-tree-inline/src/group-user/group-input.vue +162 -0
  14. package/packages/department-user-tree-inline/src/group-user/group-list.vue +99 -0
  15. package/packages/department-user-tree-inline/src/group-user/group-user.vue +42 -0
  16. package/packages/department-user-tree-inline/src/group-user-multiple-tree.vue +304 -0
  17. package/packages/department-user-tree-inline/src/group-user-single-tree.vue +155 -0
  18. package/packages/department-user-tree-inline/src/group-user-tree-service.js +74 -0
  19. package/packages/department-user-tree-inline/src/search-result.vue +34 -36
  20. package/packages/department-user-tree-mobile/src/department-user-tree-app.vue +6 -6
  21. package/packages/department-user-tree-mobile/src/department-user-tree-inline-app.vue +17 -19
  22. package/packages/department-user-tree-mobile/src/department-user-tree-service.ts +0 -11
  23. package/packages/dynamic-source-select/src/dynamic-source-select.vue +795 -799
  24. package/packages/dynamic-source-select/src/events.js +11 -16
  25. package/packages/fs-upload-list/src/fs-upload-list.vue +183 -122
  26. package/packages/fs-upload-new/src/file-upload-mobile/file-upload-app.vue +246 -0
  27. package/packages/fs-upload-new/src/file-upload-mobile/file-upload-browser.vue +480 -0
  28. package/packages/fs-upload-new/src/file-upload-mobile/file-upload-component.vue +127 -0
  29. package/packages/fs-upload-new/src/file-upload-mobile/file-upload-input.vue +246 -0
  30. package/packages/fs-upload-new/src/file-upload-mobile/file-upload.vue +255 -0
  31. package/packages/fs-upload-new/src/fs-button-upload.vue +10 -13
  32. package/packages/fs-upload-new/src/fs-drag-upload.vue +4 -8
  33. package/packages/fs-upload-new/src/fs-preview-new.vue +103 -36
  34. package/packages/fs-upload-new/src/fs-upload-new.vue +160 -13
  35. package/packages/index.js +11 -2
  36. package/packages/organization-input/src/organization-input.vue +493 -539
  37. package/packages/plugins/export-data-new.js +34 -1
  38. package/packages/rich-editor/index.vue +29 -0
  39. package/packages/row-form/index.js +7 -0
  40. package/packages/row-form/index.vue +211 -0
  41. package/packages/scan-code-input/src/scan-code-input.vue +136 -104
  42. package/packages/scan-code-input-browser/index.js +6 -0
  43. package/packages/{scan-code-input/src/scan-code-input-colse.vue → scan-code-input-browser/src/scan-code-input.vue} +1 -28
  44. package/packages/secret-info/index.vue +2 -2
  45. package/packages/super-grid/src/apis.js +158 -10
  46. package/packages/super-grid/src/components/grid-icon.vue +7 -14
  47. package/packages/super-grid/src/components/hyperlinks.vue +24 -8
  48. package/packages/super-grid/src/custom-formatter.js +312 -380
  49. package/packages/super-grid/src/dynamic-input.vue +346 -43
  50. package/packages/super-grid/src/formValidatorUtil.js +79 -15
  51. package/packages/super-grid/src/group-column.vue +5 -0
  52. package/packages/super-grid/src/normal-column-content.vue +1056 -0
  53. package/packages/super-grid/src/normal-column.vue +57 -740
  54. package/packages/super-grid/src/row-detail.vue +50 -0
  55. package/packages/super-grid/src/row-operation.vue +19 -10
  56. package/packages/super-grid/src/scan-util.ts +243 -0
  57. package/packages/super-grid/src/search-button.vue +18 -14
  58. package/packages/super-grid/src/search-form-advancedQuery.vue +9 -2
  59. package/packages/super-grid/src/search-form-item.vue +10 -3
  60. package/packages/super-grid/src/search-form-mobile.vue +250 -0
  61. package/packages/super-grid/src/search-form.vue +159 -82
  62. package/packages/super-grid/src/super-grid-service.js +51 -6
  63. package/packages/super-grid/src/super-grid.vue +657 -761
  64. package/packages/super-grid/src/utils.js +126 -170
  65. package/packages/super-nine-grid/src/super-nine-grid.vue +1032 -1141
  66. package/packages/workflow-button/src/workflow-button.vue +6 -1
  67. package/packages/workgroup-tree/src/workgroup-tree.vue +31 -0
  68. package/packages/workgroup-tree-inline/src/workgroup-tree-inline.vue +28 -0
  69. package/packages/workgroup-tree-inline/src/workgroup-tree-service.js +26 -0
  70. package/packages/workgroup-tree-mobile/index.js +6 -0
  71. package/packages/workgroup-tree-mobile/src/dept-result.vue +51 -0
  72. package/packages/workgroup-tree-mobile/src/workgroup-tree-app.vue +120 -0
  73. package/packages/workgroup-tree-mobile/src/workgroup-tree-inline-app.vue +375 -0
  74. package/packages/workgroup-tree-mobile/src/workgroup-tree-service.ts +62 -0
  75. package/packages/workgroup-user-tree/src/workgroup-user-tree.vue +15 -0
  76. package/packages/workgroup-user-tree-inline/src/workgroup-tree-inline-service.js +27 -0
  77. package/packages/workgroup-user-tree-inline/src/workgroup-user-tree-inline.vue +11 -0
  78. package/packages/workgroup-user-tree-mobile/index.js +6 -0
  79. package/packages/workgroup-user-tree-mobile/src/dept-path.vue +36 -0
  80. package/packages/workgroup-user-tree-mobile/src/dept-result.vue +58 -0
  81. package/packages/workgroup-user-tree-mobile/src/workgroup-user-tree-app.vue +119 -0
  82. package/packages/workgroup-user-tree-mobile/src/workgroup-user-tree-inline-app.vue +394 -0
  83. package/packages/workgroup-user-tree-mobile/src/workgroup-user-tree-service.ts +41 -0
  84. package/src/api/sso-service.js +44 -15
  85. package/src/directives/permission/permission.js +4 -3
  86. package/src/i18n/langs/cn.js +19 -3
  87. package/src/i18n/langs/en.js +18 -2
  88. package/src/permission.js +114 -122
  89. package/src/store/modules/user.js +32 -33
  90. package/src/styles/index.scss +1 -0
  91. package/src/styles/table.scss +12 -0
  92. package/src/styles/theme/dark-blue/button.scss +2 -2
  93. package/src/styles/theme/dark-blue/index.scss +1 -1
  94. package/src/styles/theme/dark-blue/sidebar.scss +10 -0
  95. package/src/styles/theme/dark-blue/table.scss +8 -52
  96. package/src/styles/theme/green/button.scss +2 -2
  97. package/src/styles/theme/green/green.scss +1 -1
  98. package/src/styles/theme/green/index.scss +1 -1
  99. package/src/styles/theme/green/sidebar.scss +20 -0
  100. package/src/styles/theme/green/table.scss +7 -51
  101. package/src/styles/theme/ocean-blue/button.scss +2 -2
  102. package/src/styles/theme/ocean-blue/index.scss +1 -1
  103. package/src/styles/theme/ocean-blue/ocean-blue.scss +1 -1
  104. package/src/styles/theme/ocean-blue/sidebar.scss +10 -0
  105. package/src/styles/theme/ocean-blue/table.scss +7 -52
  106. package/src/utils/auth.js +23 -3
  107. package/src/utils/calculator/calculator-factory.js +4 -4
  108. package/src/utils/calculator/calculator-util.js +14 -0
  109. package/src/utils/common-util.js +270 -124
  110. package/src/utils/i18n-util.js +145 -0
  111. package/src/utils/jump-page-utils.js +245 -314
  112. package/src/utils/permission.js +7 -1
  113. package/src/utils/permissionAuth.js +155 -37
  114. package/src/utils/request.js +10 -11
  115. package/src/utils/util.js +154 -205
  116. package/src/views/layout/EmptyLayout.vue +1 -1
  117. package/src/views/layout/components/Menubar/Item.vue +27 -4
  118. package/src/views/layout/components/Menubar/SidebarItem.vue +7 -3
  119. package/src/views/layout/components/Menubar/index.vue +14 -2
  120. package/src/views/layout/tab-content-index.vue +1 -1
@@ -0,0 +1,480 @@
1
+ <template>
2
+ <div>
3
+ <FileUploadComponent
4
+ ref="fileUploadRef"
5
+ :disabled="disabled"
6
+ :systemCode="systemCode"
7
+ :accept="accept"
8
+ :multiple="multiple"
9
+ :limitFileSize="limitFileSize"
10
+ :fileList="fileListResult"
11
+ :beforeRemove="beforeRemove"
12
+ :onRemove="onRemove"
13
+ :beforeDownload="beforeDownload"
14
+ :baseURL="baseURLVal"
15
+ @chooseFile="pickBrowserFiles"
16
+ @remove="removeFile"
17
+ />
18
+ <template v-if="openCameraOrChoosePhoto && openCameraOrChoosePhoto === 'openCamera'">
19
+ <!-- 由于直接打开capture相机属性的设置为空或者不是user/environment其中的任意一项时会打开的本地捕获音频 麦克风-->
20
+ <!-- 所有使用 template 可查看 https://w3c.github.io/html-media-capture/#introduction -->
21
+ <input
22
+ v-if="multiple && !disabled"
23
+ ref="fileRef"
24
+ type="file"
25
+ multiple="multiple"
26
+ :capture="'environment'"
27
+ name="file"
28
+ :accept="myAccept"
29
+ style="display: none"
30
+ @change="uploadFiles"
31
+ />
32
+ <input
33
+ v-else-if="!disabled"
34
+ ref="fileRef"
35
+ type="file"
36
+ :capture="'environment'"
37
+ name="file"
38
+ style="display: none"
39
+ :accept="myAccept"
40
+ @change="uploadFiles"
41
+ />
42
+ </template>
43
+ <template v-else>
44
+ <input
45
+ v-if="multiple && !disabled"
46
+ ref="fileRef"
47
+ type="file"
48
+ multiple="multiple"
49
+ name="file"
50
+ :accept="myAccept"
51
+ style="display: none"
52
+ @change="uploadFiles"
53
+ />
54
+ <input
55
+ v-else-if="!disabled"
56
+ ref="fileRef"
57
+ type="file"
58
+ name="file"
59
+ style="display: none"
60
+ :accept="myAccept"
61
+ @change="uploadFiles"
62
+ />
63
+ </template>
64
+ <el-drawer v-model="fileTypeFlag" direction="btt" @close="fileTypeFlag = false">
65
+ <div><el-button
66
+ link
67
+ @click="confirmFileType('image')"
68
+ >
69
+ {{ $t('fsUpload.image') }}
70
+ </el-button></div>
71
+ <div>
72
+ <el-button
73
+ link
74
+ @click="confirmFileType('video')"
75
+ >
76
+ {{ $t('fsUpload.video') }}
77
+ </el-button></div>
78
+ </el-drawer>
79
+ </div>
80
+ </template>
81
+
82
+ <script lang="ts" setup>
83
+ import { ref, defineEmits } from 'vue'
84
+ import { getSystemFrontendUrl, getReplaceUrlDomain, formatFileName } from '../../../../src/utils/common-util'
85
+ import { getToken, getCookieCache } from '../../../../src/utils/auth.js' // 获得token
86
+ import Compressor from 'compressorjs'
87
+ import { ElMessage } from 'element-plus'
88
+ import { useI18n } from 'vue-i18n'
89
+ import FileUploadComponent from './file-upload-component.vue'
90
+
91
+ const props = defineProps({
92
+ openFsUpload: {
93
+ type: Object,
94
+ default: true
95
+ },
96
+ entity: {
97
+ type: Object,
98
+ default: () => {
99
+ return null
100
+ }
101
+ },
102
+ fileInfo: {
103
+ type: Object,
104
+ default: () => ({})
105
+ },
106
+ systemCode: {
107
+ type: String,
108
+ default: ''
109
+ },
110
+ displayType: {
111
+ type: String,
112
+ default: 'input'
113
+ },
114
+ // 是否禁止编辑,为true只能下载,不能删除和上传
115
+ disabled: {
116
+ type: Boolean,
117
+ default: false
118
+ },
119
+ accept: {
120
+ type: String,
121
+ default: ''
122
+ },
123
+ multiple: {
124
+ type: Boolean,
125
+ default: false
126
+ },
127
+ limit: {
128
+ type: Number,
129
+ default: 1
130
+ },
131
+ // 文件大小限制,单位是M,默认是30M
132
+ limitFileSize: {
133
+ type: Number,
134
+ default: 30
135
+ },
136
+ placeholder: {
137
+ type: String,
138
+ default: '拖拽文件 或 点击上传'
139
+ },
140
+ action: {
141
+ type: String,
142
+ default: ''
143
+ },
144
+ headers: {
145
+ type: Object,
146
+ default: () => ({ Authorization: null })
147
+ },
148
+ // 已上传文件列表
149
+ fileList: {
150
+ type: Array,
151
+ default: () => []
152
+ },
153
+ onSuccess: {
154
+ type: Function,
155
+ default: () => {}
156
+ },
157
+ beforeRemove: {
158
+ type: Function,
159
+ default: () => {}
160
+ },
161
+ onRemove: {
162
+ type: Function,
163
+ default: () => {}
164
+ },
165
+ beforeDownload: {
166
+ type: Function,
167
+ default: () => {}
168
+ },
169
+ pageContext: {
170
+ type: Object,
171
+ default: () => ({})
172
+ },
173
+ configure: {
174
+ type: Object,
175
+ default: () => ({})
176
+ },
177
+ // 组件id,在表单或列表中应该唯一,一般传字段名即可
178
+ componentId: {
179
+ type: String,
180
+ default: function () {
181
+ return 'file-upload'
182
+ }
183
+ },
184
+ // 组件名称,一般是字段label
185
+ componentName: {
186
+ type: String,
187
+ default: function () {
188
+ return 'file-upload'
189
+ }
190
+ },
191
+ // 列表编码
192
+ listCode: {
193
+ type: String,
194
+ default: null
195
+ },
196
+ // 打开相机和相册选项,默认是都可以打开
197
+ openCameraOrChoosePhoto: {
198
+ type: String,
199
+ default: 'openCameraAndChoosePhoto'
200
+ },
201
+ beforeUpload: {
202
+ type: Function,
203
+ default: () => {}
204
+ }
205
+ })
206
+
207
+ const fileListResult = ref(props.fileList)
208
+
209
+ let baseURL = window.$vueApp.config.globalProperties.baseURL
210
+ if (props.pageContext && props.pageContext.backendUrl) {
211
+ baseURL = props.pageContext.backendUrl
212
+ }
213
+ if (!baseURL) {
214
+ baseURL = window.$vueApp.config.globalProperties.baseURL
215
+ }
216
+ const baseURLVal = ref(baseURL)
217
+
218
+ const baseAPI = window.$vueApp.config.globalProperties.baseAPI
219
+ const defaultAction = ref<string>('')
220
+
221
+ if (props.action) {
222
+ defaultAction.value = props.action
223
+ } else {
224
+ let tempAction = baseAPI + '/component/super-form/uploads'
225
+ if (props.multiple) {
226
+ tempAction = baseAPI + '/component/super-form/batch-uploads'
227
+ }
228
+ defaultAction.value = tempAction
229
+ }
230
+
231
+ defaultAction.value = getReplaceUrlDomain(defaultAction.value)
232
+
233
+ let myAccept = ref(props.accept ? props.accept : '')
234
+ let tempFileList = ref([])
235
+ let isUploading = ref(false)
236
+ let isFile = ref(false)
237
+ const fileRef = ref(null)
238
+ const fileTypeFlag = ref(false)
239
+ const emits = defineEmits(['remove', 'uploadend'])
240
+ const { t } = useI18n()
241
+ const fileUploadRef = ref(null)
242
+
243
+ function isImg(file) {
244
+ const fileName = file.name
245
+ if (fileName) {
246
+ return (
247
+ fileName.indexOf('jpg') !== -1 ||
248
+ fileName.indexOf('JPG') !== -1 ||
249
+ fileName.indexOf('png') !== -1 ||
250
+ fileName.indexOf('PNG') !== -1
251
+ )
252
+ }
253
+ return false
254
+ }
255
+
256
+ function removeFile(param) {
257
+ console.log('removeFile----param=', param)
258
+ const file = param.file
259
+ if(file){
260
+ emits('remove', { rmFiles: [file], serverFiles: fileListResult.value, index: param.index })
261
+ }
262
+ }
263
+ function pickBrowserFiles() {
264
+ if (props.openCameraOrChoosePhoto && props.openCameraOrChoosePhoto === 'openCamera') {
265
+ // 只打开相机
266
+ myAccept.value = 'image/*'
267
+ setTimeout(() => {
268
+ fileRef.value.click()
269
+ })
270
+ } else {
271
+ // 相机和文件都可以选
272
+ myAccept.value = '*'
273
+ fileTypeFlag.value = true
274
+ }
275
+ }
276
+
277
+ function confirmFileType(fileType: string) {
278
+ myAccept.value = ''
279
+ if (fileType && fileType === 'image') {
280
+ myAccept.value = 'image/*'
281
+ } else if (fileType && fileType === 'video') {
282
+ myAccept.value = 'video/*'
283
+ }
284
+ setTimeout(() => {
285
+ fileTypeFlag.value = false
286
+ fileRef.value.click()
287
+ })
288
+
289
+ console.log('Action chosen:', fileType)
290
+ }
291
+
292
+ async function uploadBrowserFile() {
293
+ const param = new FormData()
294
+ const fileNames = []
295
+ const selectFiles = []
296
+ let limitFileSize = props.limitFileSize
297
+ if (limitFileSize === undefined) {
298
+ // 默认是30M
299
+ limitFileSize = 30
300
+ }
301
+ let isCanUpload = false
302
+ const files = fileRef.value.files
303
+ for (let i = 0; i < files.length; i++) {
304
+ const newFile = files[i]
305
+ isCanUpload = validateCanUploadFile(newFile, limitFileSize)
306
+ if (isCanUpload) {
307
+ fileNames.push(newFile.name)
308
+ } else {
309
+ break
310
+ }
311
+ }
312
+ console.error('isCanUpload=', isCanUpload)
313
+ if (isCanUpload) {
314
+ for (let i = 0; i < files.length; i++) {
315
+ const fileObj = files[i]
316
+ console.error('fileObj.name=', fileObj.name, 'fileNames=', fileNames)
317
+ if (fileNames.indexOf(fileObj.name) >= 0) {
318
+ selectFiles.push(fileObj)
319
+ }
320
+ if (props.beforeUpload && typeof props.beforeUpload === 'function') {
321
+ const isMobile = true
322
+ // eslint-disable-next-line no-useless-call
323
+ isCanUpload = props.beforeUpload({fileObj, files:selectFiles, isMobile, pageContext: props.pageContext, configureObj: props.configure})
324
+ }
325
+ }
326
+ }
327
+ if (isCanUpload !== undefined && !isCanUpload) {
328
+ // 不能提交文件
329
+ return
330
+ }
331
+ if (!selectFiles || selectFiles.length === 0) {
332
+ console.error('未选择任何文件')
333
+ return
334
+ }
335
+ let uploadFiles = []
336
+ try {
337
+ uploadFiles = await compressionImg(selectFiles)
338
+ } catch (error) {
339
+ console.error('压缩图片失败', error)
340
+ uploadFiles = selectFiles
341
+ }
342
+ if (props.multiple) {
343
+ for (let i = 0; i < uploadFiles.length; i++) {
344
+ // param.append('files['+i+']', uploadFiles[i])
345
+ param.append('files', uploadFiles[i])
346
+ // param.append('files[]', uploadFiles[i])
347
+ }
348
+ // param.append('files', uploadFiles)
349
+ // 批量上传接口有这个参数,单文件上传没有该参数
350
+ param.append('limitFileSize', limitFileSize)
351
+ } else {
352
+ param.append('file', uploadFiles[0])
353
+ }
354
+ param.append('systemCode', props.systemCode)
355
+
356
+ console.log('上传文件111-----defaultAction.value=',defaultAction.value, 'param=', param, 'uploadFiles=', uploadFiles)
357
+ window.$vueApp.config.globalProperties.$http
358
+ .post(defaultAction.value, param, { headers: { 'Content-Type': 'multipart/form-data', Authorization: getToken() } })
359
+ .then((result) => {
360
+ // result:批量上传时返回的是集合,单选上传时返回的是对象
361
+ console.log('上传后返回值==result=', result)
362
+ if (result) {
363
+ if (props.multiple) {
364
+ if (result.length > 0) {
365
+ // this.tempFileList.push(...result)
366
+ uploadComplete(result)
367
+ } else {
368
+ console.error('多选时上传后返回值异常')
369
+ }
370
+ } else {
371
+ // this.tempFileList.push(result)
372
+ uploadComplete(result)
373
+ }
374
+ } else {
375
+ console.error('上传后返回值异常')
376
+ }
377
+ })
378
+ .catch(() => {
379
+ isUploading.value = false
380
+ })
381
+ }
382
+ function validateCanUploadFile(file, limitFileSize) {
383
+ let isCanUpload = true
384
+ console.log('上传文件--验证文件大小--file.size=', file.size, '文件线状大小,单位是M,limitFileSize=', limitFileSize)
385
+ if (file.size > limitFileSize * 1024 * 1024) {
386
+ // 超过最大限制
387
+ ElMessage({
388
+ showClose: true,
389
+ type: 'warning',
390
+ message: t('fileUpload.exceedFileSize', { fileName: file.name, fileSize: limitFileSize })
391
+ })
392
+ // 返回false停止上传
393
+ isCanUpload = false
394
+ }
395
+ return isCanUpload
396
+ }
397
+ // 所有文件上传完毕后
398
+ function uploadComplete(result) {
399
+ console.log('uploadComplete=开始')
400
+ if(!fileListResult.value){
401
+ fileListResult.value = []
402
+ }
403
+ if (props.multiple) {
404
+ console.log(
405
+ 'uploadComplete====fileListResult.value111=',
406
+ JSON.stringify(fileListResult.value),
407
+ 'result=',
408
+ result
409
+ )
410
+ fileListResult.value = fileListResult.value.concat(result)
411
+ console.log('uploadComplete====fileListResult.value222=', fileListResult.value)
412
+ } else {
413
+ // 单选时将已选文件移除,然后再替换为新上传的文件
414
+ console.log('uploadComplete====fileListResult.value333=', JSON.stringify(fileListResult.value))
415
+ const rmFiles = JSON.parse(JSON.stringify(fileListResult.value))
416
+ fileListResult.value.push(result)
417
+ emits('remove', { rmFiles, serverFiles: fileListResult.value, index: 0 })
418
+ console.log('uploadComplete====fileListResult.value444=', fileListResult.value)
419
+ }
420
+ console.log('uploadComplete====fileListResult.value555=', fileListResult.value)
421
+
422
+ fileRef.value.value = null
423
+ isUploading.value = false
424
+ fileUploadRef.value.changeFileList(fileListResult.value)
425
+ // 表示上传完成
426
+ emits('uploadend', fileListResult.value)
427
+ console.log('uploadComplete====上传完成=')
428
+ }
429
+ function uploadFiles() {
430
+ uploadBrowserFiles()
431
+ }
432
+ function uploadBrowserFiles() {
433
+ console.log('uploadBrowserFiles=====上传开始=')
434
+ const files = fileRef.value.files
435
+ if (files && files.length > 0) {
436
+ isUploading.value = true
437
+ uploadBrowserFile()
438
+ } else {
439
+ uploadNoNewFiles()
440
+ }
441
+ }
442
+
443
+ // 文件上传时,无需要走后台上传时的处理
444
+ function uploadNoNewFiles() {
445
+ fileRef.value.value = null
446
+
447
+ // 表示上传完成
448
+ emits('uploadend', fileListResult.value)
449
+ }
450
+
451
+ function compressionImg(selectFiles) {
452
+ const uploadFilesPromises = []
453
+ for (let i = 0; i < selectFiles.length; i++) {
454
+ uploadFilesPromises.push(
455
+ new Promise((resolve, reject) => {
456
+ console.log(`压缩前 size ${selectFiles[i].size / 1024 / 1024} MB`)
457
+ // eslint-disable-next-line no-new
458
+ new Compressor(selectFiles[i], {
459
+ quality: 0.7,
460
+ success(result) {
461
+ console.log(`压缩后 size ${result.size / 1024 / 1024} MB`)
462
+ resolve(
463
+ new File([result], selectFiles[i].name, {
464
+ type: result.type,
465
+ lastModified: Date.now()
466
+ })
467
+ )
468
+ },
469
+ error(err) {
470
+ reject(err)
471
+ }
472
+ })
473
+ })
474
+ )
475
+ }
476
+ return Promise.all(uploadFilesPromises)
477
+ }
478
+ </script>
479
+
480
+ <style lang="scss" scoped></style>
@@ -0,0 +1,127 @@
1
+ <template>
2
+ <el-upload action="#" list-type="picture-card" :file-list="fileListResult" :auto-upload="false" :disabled="true">
3
+ <template v-if="!disabled" #tip>
4
+ <el-text size="small" style="padding: 10px;font-weight: 600"> {{ accept }} {{limitFileSize?$t('imatrixUIMessage.uploadFileTip',{fileSize: limitFileSize}): ''}}</el-text>
5
+ </template>
6
+ <template v-if="!disabled" #trigger>
7
+ <el-icon @click="chooseFile"><Plus /></el-icon>
8
+ </template>
9
+
10
+ <template #file="{ file }">
11
+ <div style="width: 100%;" >
12
+ <div v-if="!isImg(file)" class="el-upload-list__item-thumbnail" >
13
+ <div class="file-name-container" >
14
+ {{file.name}}
15
+ </div></div>
16
+ <img v-else class="el-upload-list__item-thumbnail" :src="getPreviewSrc(file.name, file.serverPath)" alt="" />
17
+ <fs-preview-new :disabled="disabled" :file-list="fileListResult" :file="file" :system-code="systemCode" :before-remove="beforeRemove" :on-remove="onRemove" :before-download="beforeDownload" @remove="removeFile"/>
18
+
19
+ </div>
20
+ </template>
21
+ </el-upload>
22
+ </template>
23
+
24
+ <script lang="ts" setup>
25
+ import { ref,defineEmits } from 'vue'
26
+ import { Plus } from '@element-plus/icons-vue'
27
+ import fsPreviewNew from '../fs-preview-new.vue'
28
+
29
+ import { isImage } from '../../../../src/utils/util'
30
+ import { getToken } from '../../../../src/utils/auth'
31
+ import { getReplaceUrlDomain, isPlateSys } from '../../../../src/utils/common-util'
32
+
33
+ const props = defineProps({
34
+ systemCode: {
35
+ type: String,
36
+ default: ''
37
+ },
38
+ disabled: {
39
+ type: Boolean,
40
+ default: false
41
+ },
42
+ fileList: {
43
+ type: Array<{ showName: string; serverPath: string }>,
44
+ default: () => []
45
+ },
46
+ beforeRemove: {
47
+ type: Function,
48
+ default: () => {}
49
+ },
50
+ onRemove: {
51
+ type: Function,
52
+ default: () => {}
53
+ },
54
+ beforeDownload: {
55
+ type: Function,
56
+ default: () => {}
57
+ },
58
+ accept: {
59
+ type: String,
60
+ default: ''
61
+ },
62
+ limitFileSize: {
63
+ type: Number,
64
+ default: 30
65
+ },
66
+ baseURL: {
67
+ type: String,
68
+ default: ''
69
+ }
70
+ })
71
+
72
+ //拖动定义的方法
73
+ const emits = defineEmits(['chooseFile', 'remove']);
74
+
75
+ const dialogImageUrl = ref('')
76
+ const dialogVisible = ref(false)
77
+ const disabled = ref(false)
78
+
79
+ let baseURL = props.baseURL
80
+
81
+ const baseAPI = window.$vueApp.config.globalProperties.baseAPI
82
+
83
+ const fileListResult = ref(props.fileList)
84
+ console.log('file-upload-component---fileListResult=', fileListResult.value)
85
+ function changeFileList(fileList: any) {
86
+ fileListResult.value = fileList
87
+ }
88
+ const chooseFile = ()=>{
89
+ console.log('点击选择文件按钮---')
90
+ emits('chooseFile')
91
+ }
92
+ const isImg = (file: Object) =>{
93
+ return isImage(file.name)
94
+ }
95
+
96
+ function getPreviewSrc(showName: string, serverPath: string) {
97
+ showName = formatName(showName)
98
+ const token = getToken()
99
+ let url = baseURL + '/common/super-form/downloads?jwt=' + token
100
+ if (isPlateSys(props.systemCode)) {
101
+ url = baseAPI + '/component/super-form/downloads?jwt=' + token
102
+ }
103
+ url = getReplaceUrlDomain(url)
104
+ return url + '&showName=' + encodeURI(showName) + '&serverPath=' + serverPath
105
+ }
106
+ const formatName = (showName: string) => {
107
+ if (showName) {
108
+ showName = showName.replace('#', '~~').replace('?', '~$').replace('&', '$')
109
+ }
110
+ return showName
111
+ }
112
+
113
+ function removeFile(param){
114
+ emits('remove', param)
115
+ }
116
+
117
+ defineExpose({changeFileList})
118
+
119
+ </script>
120
+ <style scoped>
121
+ .file-name-container {
122
+ display: flex;
123
+ align-items: center; /* 垂直居中 */
124
+ justify-content: center; /* 水平居中,如需要 */
125
+ height: 100px; /* 容器高度 */
126
+ }
127
+ </style>