= {
- 1: { type: 'success', text: '本地存储' },
- 2: { type: 'info', text: 'MinIO存储' },
- 3: { type: 'warning', text: '阿里云OSS' },
- }
- const config = serviceMap[row.fileService] || { type: 'info', text: '未知' }
- return h(NTag, {
- type: config.type,
- size: 'small',
- }, { default: () => config.text })
- },
+ width: 140,
+ render: row => h(DictTag, { dictType: 'sys_file_service', value: row.fileService }),
},
{
title: '创建时间',
@@ -781,7 +787,8 @@ async function customUpload({ file, onProgress, onFinish, onError }: any) {
onProgress({ percent: 10 })
// 调用上传API,传递选择的存储类型
- const result = await uploadFile(fileObj, folderName, 2, '-1', uploadForm.value.fileService)
+ const storageType = mapServiceValueToType(uploadForm.value.fileService)
+ const result = await uploadFile(fileObj, folderName, 2, '-1', storageType)
// 检查业务逻辑是否成功
if (result.isSuccess === false) {
diff --git a/src/views/system/picture/index.vue b/src/views/system/picture/index.vue
index 88a76f6..eb9e995 100644
--- a/src/views/system/picture/index.vue
+++ b/src/views/system/picture/index.vue
@@ -72,7 +72,7 @@
v-model:value="searchForm.pictureService"
placeholder="请选择存储类型"
clearable
- :options="PICTURE_SERVICE_OPTIONS"
+ :options="getSelectOptions('sys_file_service')"
/>
@@ -258,7 +258,9 @@
新名称: {{ picture.newName }}
文件大小: {{ picture.pictureSize }}
文件后缀: {{ picture.pictureSuffix?.toUpperCase() }}
- 服务类型: {{ getPictureServiceText(picture.pictureService) }}
+
+ 服务类型:
+
创建时间: {{ picture.createTime ? new Date(picture.createTime).toLocaleString() : '--' }}
创建者: {{ picture.createBy || '--' }}
@@ -348,11 +350,7 @@
@@ -417,13 +415,13 @@ import CoiDialog from '@/components/common/CoiDialog.vue'
import CoiPagination from '@/components/common/CoiPagination.vue'
import CoiImageViewer from '@/components/common/CoiImageViewer.vue'
import { coiMsgBox, coiMsgError, coiMsgSuccess, coiMsgWarning } from '@/utils/coi'
-import { usePermission } from '@/hooks/usePermission'
+import DictTag from '@/components/common/DictTag.vue'
+import { useDict, usePermission } from '@/hooks'
import { PERMISSIONS } from '@/constants/permissions'
import {
batchDeleteSysPictures,
deleteSysPicture,
getSysPictureList,
- PICTURE_SERVICE_OPTIONS,
PICTURE_TYPE_OPTIONS,
uploadPicture,
} from '@/service/api/system/picture'
@@ -458,6 +456,35 @@ const uploadPictureTypeOptions = PICTURE_TYPE_OPTIONS.filter(option => option.va
// 权限验证
const { hasPermission } = usePermission()
+const { getSelectOptions } = useDict(['sys_file_service'])
+
+const storageValueToType: Record = {
+ 1: 'LOCAL',
+ 2: 'MINIO',
+ 3: 'OSS',
+}
+
+const storageTypeToValue: Record = {
+ LOCAL: '1',
+ MINIO: '2',
+ OSS: '3',
+}
+
+function mapServiceValueToType(value: string | null | undefined) {
+ const str = value != null ? String(value) : '1'
+ if (storageValueToType[str])
+ return storageValueToType[str]
+ const upper = str.toUpperCase()
+ return storageValueToType[storageTypeToValue[upper] ?? '1'] ?? 'LOCAL'
+}
+
+function mapStorageTypeToValue(type: string | null | undefined) {
+ const str = type != null ? String(type) : '1'
+ if (storageValueToType[str])
+ return str
+ const upper = str.toUpperCase()
+ return storageTypeToValue[upper] ?? '1'
+}
// 响应式数据
const searchFormRef = ref()
@@ -514,7 +541,7 @@ const isConfirmDisabled = computed(() => {
// 上传表单数据
const uploadForm = ref({
- pictureService: 'LOCAL',
+ pictureService: '1',
pictureType: '9', // 默认其他分类
picturePath: '',
})
@@ -622,20 +649,9 @@ const columns: DataTableColumns = [
{
title: '服务类型',
key: 'pictureService',
- width: 120,
+ width: 130,
align: 'center',
- render: (row) => {
- const serviceMap: Record = {
- 1: { type: 'success', text: '本地存储' },
- 2: { type: 'info', text: 'MinIO存储' },
- 3: { type: 'warning', text: '阿里云OSS' },
- }
- const config = serviceMap[row.pictureService] || { type: 'info', text: '未知' }
- return h(NTag, {
- type: config.type,
- size: 'small',
- }, { default: () => config.text })
- },
+ render: row => h(DictTag, { dictType: 'sys_file_service', value: mapStorageTypeToValue(row.pictureService) }),
},
{
title: '创建时间',
@@ -837,21 +853,12 @@ function handleDownload(row: SysPictureVo) {
}
// 获取图片服务类型文本
-function getPictureServiceText(serviceType: string): string {
- const serviceMap: Record = {
- 1: '本地存储',
- 2: 'MinIO存储',
- 3: '阿里云OSS',
- }
- return serviceMap[serviceType] || '未知'
-}
-
// 图片上传相关函数
// 打开上传弹框
function handleUpload() {
uploadForm.value = {
- pictureService: 'LOCAL',
+ pictureService: '1',
pictureType: selectedCategory.value === '0' ? '9' : selectedCategory.value, // 根据当前分类设置默认值
picturePath: '',
}
@@ -922,7 +929,8 @@ async function customUpload({ file, onProgress, onFinish, onError }: any) {
onProgress({ percent: 10 })
// 调用上传API - 使用选择的分类和存储类型
- const result = await uploadPicture(fileObj, uploadForm.value.pictureType, 2, uploadForm.value.pictureService)
+ const storageType = mapServiceValueToType(uploadForm.value.pictureService)
+ const result = await uploadPicture(fileObj, uploadForm.value.pictureType, 2, storageType)
// 检查业务逻辑是否成功
if (result.isSuccess === false) {