This commit is contained in:
孟帅
2024-07-21 22:21:02 +08:00
parent 7d8330f72f
commit a37d088360
440 changed files with 6303 additions and 3339 deletions

View File

@@ -2,7 +2,7 @@
<n-grid :x-gap="5" :y-gap="5" :cols="pageGridCols" responsive="screen">
<n-gi :span="2">
<n-menu
:options="options.kind"
:options="generateKindOptions()"
style="width: 100%"
:default-value="defaultKindValue"
:on-update:value="handleUpdateKind"
@@ -60,8 +60,8 @@
</n-ellipsis>
</template>
<template #action style="padding: 5px">
<n-space justify="center">
<template #action>
<n-space justify="center" style="padding: 5px">
<n-button
strong
secondary
@@ -75,7 +75,6 @@
<DownloadOutlined v-else />
</n-icon>
</template>
{{ item.kind === 'image' ? '预览' : '下载' }}
</n-button>
<n-button
@@ -130,14 +129,15 @@
import { defRangeShortcuts } from '@/utils/dateUtil';
import { EyeOutlined, DeleteOutlined, DownloadOutlined, ClearOutlined } from '@vicons/antd';
import { useProjectSettingStore } from '@/store/modules/projectSetting';
import { ChooserOption, ClearKind, Delete, List } from '@/api/apply/attachment';
import { ClearKind, Delete, List } from '@/api/apply/attachment';
import { constantRouterIcon } from '@/router/router-icons';
import { errorImg } from '@/utils/hotgo';
import { getFileExt } from '@/utils/urlUtils';
import { renderIcon } from '@/utils';
import { Attachment, FileType, KindOption, KindRawOption } from './model';
import { Attachment, FileType, KindOption } from './model';
import Preview from './Preview.vue';
import { VNode } from '@vue/runtime-core';
import { VNode } from 'vue';
import { Option, useDictStore } from '@/store/modules/dict';
export interface Props {
fileList: string[] | null;
@@ -152,6 +152,7 @@
});
const emit = defineEmits(['saveChange']);
const dict = useDictStore();
const settingStore = useProjectSettingStore();
const message = useMessage();
const dialog = useDialog();
@@ -191,7 +192,7 @@
defaultValue: null,
componentProps: {
placeholder: '请选择上传驱动',
options: options.value.drive,
options: dict.getOption('config_upload_drive'),
onUpdateValue: (e: any) => {
console.log(e);
},
@@ -250,9 +251,6 @@
reloadTable();
});
},
onNegativeClick: () => {
// message.error('取消');
},
});
}
@@ -295,14 +293,14 @@
return selectList.value.some((selected) => selected === item.fileUrl);
}
function generateKindOptions(kinds: KindRawOption[]): any {
function generateKindOptions(): any {
const option: KindOption[] = [];
kinds.forEach((item: KindRawOption) => {
dict.getOptionUnRef('AttachmentKindOption').forEach((item: Option) => {
const data: KindOption = {
label: () => h(NEllipsis, null, { default: () => item.label }),
key: item.key,
key: item.key.toString(),
extra: () => (item.key !== '' ? createExtraContent(item) : null),
icon: constantRouterIcon[item.icon] || null,
icon: constantRouterIcon[item.extra] || null,
disabled: isDisabledKindOption(item),
};
option.push(data);
@@ -310,14 +308,14 @@
return option;
}
function isDisabledKindOption(item: KindRawOption): boolean {
function isDisabledKindOption(item: Option): boolean {
if (props.fileType === 'default') {
return false;
}
return item.key !== props.fileType;
}
function createExtraContent(item: KindRawOption): VNode {
function createExtraContent(item: Option): VNode {
return h(
NButton,
{
@@ -338,9 +336,6 @@
reloadTable();
});
},
onNegativeClick: () => {
// message.error('取消');
},
});
},
},
@@ -348,20 +343,6 @@
);
}
async function loadOptions() {
let tmpOptions = await ChooserOption();
options.value.drive = tmpOptions.drive;
options.value.kind = generateKindOptions(tmpOptions.kind);
for (const item of schemas.value) {
switch (item.field) {
case 'drive':
item.componentProps.options = options.value.drive;
break;
}
}
}
function loadList() {
loading.value = true;
List({ ...params.value, ...searchFormRef.value?.formModel }).then((res) => {
@@ -392,8 +373,12 @@
loadList();
}
function loadOptions() {
dict.loadOptions(['AttachmentKindOption', 'config_upload_drive']);
}
onMounted(async () => {
await loadOptions();
loadOptions();
loadList();
});

View File

@@ -21,12 +21,6 @@ export type Attachment = {
sizeFormat: string;
};
export interface KindRawOption {
key: string;
label: string;
icon: string;
}
export interface KindOption {
key: string;
label: any;