mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-23 23:59:19 +08:00
fix: 修复前端若干类型报错
This commit is contained in:
@@ -83,6 +83,8 @@ export namespace OrderDTO {
|
||||
minReceivedAmount?: number;
|
||||
/** 实收金额范围-最大值 */
|
||||
maxReceivedAmount?: number;
|
||||
/** 确认状态(0 未确认 / 1 已确认) */
|
||||
confirm?: number;
|
||||
/** 下单时间范围-开始时间 */
|
||||
startOrderTime?: string;
|
||||
/** 下单时间范围-结束时间 */
|
||||
|
||||
@@ -5,9 +5,7 @@ import { computed, onMounted, ref, watch } from 'vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
|
||||
import { AuthenticationLoginExpiredModal } from '@vben/common-ui';
|
||||
import { VBEN_DOC_URL, VBEN_GITHUB_URL } from '@vben/constants';
|
||||
import { useWatermark } from '@vben/hooks';
|
||||
import { MdiGithub } from '@vben/icons';
|
||||
import { createIconifyIcon } from '@vben/icons';
|
||||
import {
|
||||
BasicLayout,
|
||||
@@ -17,11 +15,9 @@ import {
|
||||
} from '@vben/layouts';
|
||||
import { preferences } from '@vben/preferences';
|
||||
import { useAccessStore, useUserStore } from '@vben/stores';
|
||||
import { openWindow } from '@vben/utils';
|
||||
|
||||
import ImportTaskButton from '#/components/ImportTaskButton.vue';
|
||||
import SwitchAccountModal from '#/components/SwitchAccountModal.vue';
|
||||
import { $t } from '#/locales';
|
||||
import { useAuthStore, useImportTaskStore } from '#/store';
|
||||
import LoginForm from '#/views/_core/authentication/login.vue';
|
||||
|
||||
|
||||
@@ -14,6 +14,8 @@ const staticRouteFiles = import.meta.glob('./static/**/*.ts', { eager: true });
|
||||
|
||||
/** 动态路由 */
|
||||
const dynamicRoutes: RouteRecordRaw[] = mergeRouteModules(dynamicRouteFiles);
|
||||
/** 基本路由列表,这些路由不需要进入权限拦截 */
|
||||
const coreRouteNames = traverseTreeValues(coreRoutes, (route) => route.name);
|
||||
|
||||
/** 外部路由列表,访问这些页面可以不需要Layout,可能用于内嵌在别的系统(不会显示在菜单中) */
|
||||
// const externalRoutes: RouteRecordRaw[] = mergeRouteModules(externalRouteFiles);
|
||||
@@ -37,9 +39,6 @@ const routes: RouteRecordRaw[] = [
|
||||
fallbackNotFoundRoute,
|
||||
];
|
||||
|
||||
/** 基本路由列表,这些路由不需要进入权限拦截 */
|
||||
const coreRouteNames = traverseTreeValues(coreRoutes, (route) => route.name);
|
||||
|
||||
/** 有权限校验的路由列表,包含动态路由 */
|
||||
const accessRoutes = [...dynamicRoutes];
|
||||
export { accessRoutes, coreRouteNames, routes };
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
import type { RouteRecordRaw } from 'vue-router';
|
||||
|
||||
const routes: RouteRecordRaw[] = [
|
||||
{
|
||||
meta: {
|
||||
icon: 'lucide:folder-open',
|
||||
order: 300,
|
||||
title: '媒体管理',
|
||||
},
|
||||
name: 'Media',
|
||||
path: '/media',
|
||||
children: [
|
||||
{
|
||||
name: 'FileRepository',
|
||||
path: '/media/file-repository',
|
||||
component: () => import('#/views/media/file/index.vue'),
|
||||
meta: {
|
||||
icon: 'lucide:folder',
|
||||
title: '文件仓库',
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'ImageRepository',
|
||||
path: '/media/image-repository',
|
||||
component: () => import('#/views/media/image/index.vue'),
|
||||
meta: {
|
||||
icon: 'lucide:image',
|
||||
title: '图片仓库',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
export default routes;
|
||||
@@ -51,15 +51,12 @@ const routes: RouteRecordRaw[] = [
|
||||
name: 'JobPermissionAssign',
|
||||
path: '/organization/position-permission-assign',
|
||||
component: () =>
|
||||
import(
|
||||
'#/views/organization/position-permission-assign/index.vue'
|
||||
),
|
||||
import('#/views/organization/position-permission-assign/index.vue'),
|
||||
meta: {
|
||||
icon: 'lucide:shield-check',
|
||||
title: '职位权限分配',
|
||||
},
|
||||
},
|
||||
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
@@ -44,8 +44,7 @@ const routes: RouteRecordRaw[] = [
|
||||
{
|
||||
name: 'SystemPlatformAccountSuper',
|
||||
path: '/platform-admin/account-super',
|
||||
component: () =>
|
||||
import('#/views/organization/account-super/index.vue'),
|
||||
component: () => import('#/views/organization/account-super/index.vue'),
|
||||
meta: {
|
||||
icon: 'lucide:user-check',
|
||||
title: '平台账户管理',
|
||||
@@ -67,9 +66,7 @@ const routes: RouteRecordRaw[] = [
|
||||
name: 'SystemPlatformCompanyPermissionManage',
|
||||
path: '/platform-admin/company-permission-manage',
|
||||
component: () =>
|
||||
import(
|
||||
'#/views/system/platform/company-permission-manage/index.vue'
|
||||
),
|
||||
import('#/views/system/platform/company-permission-manage/index.vue'),
|
||||
meta: {
|
||||
icon: 'lucide:shield-check',
|
||||
title: '公司权限管理',
|
||||
|
||||
+17
-8
@@ -14,9 +14,7 @@ import {
|
||||
deleteImportMappingApi,
|
||||
getImportMappingPageApi,
|
||||
} from '#/api/ecommerce/import-mapping';
|
||||
import {
|
||||
ImportMappingType,
|
||||
} from '#/api/ecommerce/import-mapping/types/types.enum';
|
||||
import { ImportMappingType } from '#/api/ecommerce/import-mapping/types/types.enum';
|
||||
|
||||
import ImportMappingFormModal from '../import-mapping/components/ImportMappingFormModal.vue';
|
||||
|
||||
@@ -30,7 +28,12 @@ const formModalRef = ref();
|
||||
const gridOptions: VxeGridProps<any> = {
|
||||
columns: [
|
||||
{ type: 'seq', width: 80, title: '序号' },
|
||||
{ field: 'name', title: '模板名称', minWidth: 'auto', showOverflow: 'tooltip' },
|
||||
{
|
||||
field: 'name',
|
||||
title: '模板名称',
|
||||
minWidth: 'auto',
|
||||
showOverflow: 'tooltip',
|
||||
},
|
||||
{ field: 'type', title: '类型', width: 120, slots: { default: 'type' } },
|
||||
{
|
||||
title: '映射字段数',
|
||||
@@ -65,7 +68,7 @@ const gridOptions: VxeGridProps<any> = {
|
||||
filters: { type: ImportMappingType.ORDER },
|
||||
});
|
||||
return { items: result.records || [], total: result.total || 0 };
|
||||
} catch (error) {
|
||||
} catch {
|
||||
message.error('获取字段映射模板列表失败');
|
||||
return { items: [], total: 0 };
|
||||
} finally {
|
||||
@@ -76,7 +79,11 @@ const gridOptions: VxeGridProps<any> = {
|
||||
},
|
||||
};
|
||||
|
||||
const [Grid, gridApi] = useVbenVxeGrid({ gridOptions, showSearchForm: false, tableTitle: '字段映射模板' });
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
gridOptions,
|
||||
showSearchForm: false,
|
||||
tableTitle: '字段映射模板',
|
||||
});
|
||||
|
||||
function refresh() {
|
||||
gridApi?.reload();
|
||||
@@ -95,7 +102,7 @@ async function handleDelete(row: ImportMappingVO.ImportMappingInfoVO) {
|
||||
await deleteImportMappingApi(row.id);
|
||||
message.success('删除成功');
|
||||
refresh();
|
||||
} catch (error) {
|
||||
} catch {
|
||||
message.error('删除失败');
|
||||
}
|
||||
}
|
||||
@@ -141,7 +148,9 @@ function getTypeName(type: ImportMappingType): string {
|
||||
<Tag color="blue">{{ getTypeName(row.type) }}</Tag>
|
||||
</template>
|
||||
|
||||
<template #mappingCount="{ row }: { row: ImportMappingVO.ImportMappingInfoVO }">
|
||||
<template
|
||||
#mappingCount="{ row }: { row: ImportMappingVO.ImportMappingInfoVO }"
|
||||
>
|
||||
<Tag color="green">{{ getMappingCount(row.mapping) }} 个字段</Tag>
|
||||
</template>
|
||||
|
||||
|
||||
+44
-29
@@ -1,32 +1,23 @@
|
||||
<script setup lang="ts">
|
||||
import type { ImportFieldDefVO } from '#/api/ecommerce/import-field-def';
|
||||
import type { OrderStatusVO } from '#/api/ecommerce/order-status';
|
||||
import type { ImportMappingVO } from '#/api/ecommerce/import-mapping';
|
||||
import type { ImportMappingType } from '#/api/ecommerce/import-mapping/types/types.enum';
|
||||
import type { OrderStatusVO } from '#/api/ecommerce/order-status';
|
||||
|
||||
import { ref } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import {
|
||||
Form,
|
||||
Input,
|
||||
message,
|
||||
Select,
|
||||
} from 'ant-design-vue';
|
||||
import { Form, Input, message, Select } from 'ant-design-vue';
|
||||
|
||||
import { getFieldDefsByTypeApi } from '#/api/ecommerce/import-field-def';
|
||||
import {
|
||||
createImportMappingApi,
|
||||
updateImportMappingApi,
|
||||
} from '#/api/ecommerce/import-mapping';
|
||||
import {
|
||||
getFieldDefsByTypeApi,
|
||||
} from '#/api/ecommerce/import-field-def';
|
||||
import { ImportMappingType as MappingTypeEnum } from '#/api/ecommerce/import-mapping/types/types.enum';
|
||||
import { getAllOrderStatusListApi } from '#/api/ecommerce/order-status';
|
||||
|
||||
import {
|
||||
ImportMappingType as MappingTypeEnum,
|
||||
} from '#/api/ecommerce/import-mapping/types/types.enum';
|
||||
|
||||
defineOptions({ name: 'ImportMappingFormModal' });
|
||||
|
||||
// Props: 传入模板类型
|
||||
@@ -97,16 +88,17 @@ async function fetchOrderStatuses() {
|
||||
}
|
||||
|
||||
// 打开弹窗
|
||||
async function open(isNew: boolean, record?: ImportMappingVO.ImportMappingInfoVO) {
|
||||
async function open(
|
||||
isNew: boolean,
|
||||
record?: ImportMappingVO.ImportMappingInfoVO,
|
||||
) {
|
||||
isEdit.value = !isNew;
|
||||
editId.value = record?.id;
|
||||
modalApi.open();
|
||||
|
||||
if (props.type === MappingTypeEnum.ORDER_STATUS) {
|
||||
await fetchOrderStatuses();
|
||||
} else {
|
||||
await fetchFieldDefs();
|
||||
}
|
||||
await (props.type === MappingTypeEnum.ORDER_STATUS
|
||||
? fetchOrderStatuses()
|
||||
: fetchFieldDefs());
|
||||
|
||||
if (isNew) {
|
||||
// 新建:初始化空映射
|
||||
@@ -161,7 +153,9 @@ async function handleConfirm() {
|
||||
let mappingJson = '[]';
|
||||
if (props.type === MappingTypeEnum.ORDER_STATUS) {
|
||||
// 过滤掉未映射的
|
||||
const validMappings = statusMappings.value.filter((m) => m.mappedStatusId);
|
||||
const validMappings = statusMappings.value.filter(
|
||||
(m) => m.mappedStatusId,
|
||||
);
|
||||
mappingJson = JSON.stringify(validMappings);
|
||||
} else {
|
||||
const items: FieldMappingItem[] = fieldDefs.value
|
||||
@@ -205,7 +199,11 @@ defineExpose({ open });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal :loading="loading" :title="isEdit ? '编辑映射模板' : '新建映射模板'" :confirm-text="isEdit ? '保存' : '创建'">
|
||||
<Modal
|
||||
:loading="loading"
|
||||
:title="isEdit ? '编辑映射模板' : '新建映射模板'"
|
||||
:confirm-text="isEdit ? '保存' : '创建'"
|
||||
>
|
||||
<Form :label-col="{ span: 4 }" :wrapper-col="{ span: 20 }">
|
||||
<Form.Item label="模板名称" required>
|
||||
<Input
|
||||
@@ -217,14 +215,20 @@ defineExpose({ open });
|
||||
</Form.Item>
|
||||
|
||||
<!-- 订单状态映射编辑 -->
|
||||
<Form.Item v-if="type === MappingTypeEnum.ORDER_STATUS" label="状态映射" :wrapper-col="{ span: 20 }">
|
||||
<div class="max-h-[400px] overflow-y-auto space-y-2">
|
||||
<Form.Item
|
||||
v-if="type === MappingTypeEnum.ORDER_STATUS"
|
||||
label="状态映射"
|
||||
:wrapper-col="{ span: 20 }"
|
||||
>
|
||||
<div class="max-h-[400px] space-y-2 overflow-y-auto">
|
||||
<div
|
||||
v-for="(item, idx) in statusMappings"
|
||||
:key="idx"
|
||||
class="flex items-center space-x-2 rounded border p-2"
|
||||
>
|
||||
<span class="w-[200px] truncate text-gray-600">{{ item.csvStatus }}</span>
|
||||
<span class="w-[200px] truncate text-gray-600">{{
|
||||
item.csvStatus
|
||||
}}</span>
|
||||
<span class="text-gray-400">→</span>
|
||||
<Select
|
||||
v-model:value="item.mappedStatusId"
|
||||
@@ -232,10 +236,18 @@ defineExpose({ open });
|
||||
class="flex-1"
|
||||
show-search
|
||||
allow-clear
|
||||
:options="orderStatusList.map((s) => ({ label: s.statusName, value: s.id }))"
|
||||
:options="
|
||||
orderStatusList.map((s) => ({
|
||||
label: s.statusName,
|
||||
value: s.id,
|
||||
}))
|
||||
"
|
||||
/>
|
||||
</div>
|
||||
<div v-if="statusMappings.length === 0" class="py-4 text-center text-gray-400">
|
||||
<div
|
||||
v-if="statusMappings.length === 0"
|
||||
class="py-4 text-center text-gray-400"
|
||||
>
|
||||
暂无映射数据
|
||||
</div>
|
||||
</div>
|
||||
@@ -243,12 +255,15 @@ defineExpose({ open });
|
||||
|
||||
<!-- 字段映射编辑(只读展示) -->
|
||||
<Form.Item v-else label="字段映射" :wrapper-col="{ span: 20 }">
|
||||
<div class="max-h-[400px] overflow-y-auto space-y-2">
|
||||
<div class="max-h-[400px] space-y-2 overflow-y-auto">
|
||||
<div
|
||||
v-for="field in fieldDefs"
|
||||
:key="field.id"
|
||||
class="flex items-center space-x-2 rounded border p-2"
|
||||
:class="{ 'border-red-200 bg-red-50': field.required && !fieldMappings[field.fieldName] }"
|
||||
:class="{
|
||||
'border-red-200 bg-red-50':
|
||||
field.required && !fieldMappings[field.fieldName],
|
||||
}"
|
||||
>
|
||||
<span class="w-[140px]">
|
||||
{{ field.fieldLabel }}
|
||||
|
||||
+17
-8
@@ -14,9 +14,7 @@ import {
|
||||
deleteImportMappingApi,
|
||||
getImportMappingPageApi,
|
||||
} from '#/api/ecommerce/import-mapping';
|
||||
import {
|
||||
ImportMappingType,
|
||||
} from '#/api/ecommerce/import-mapping/types/types.enum';
|
||||
import { ImportMappingType } from '#/api/ecommerce/import-mapping/types/types.enum';
|
||||
|
||||
import ImportMappingFormModal from '../import-mapping/components/ImportMappingFormModal.vue';
|
||||
|
||||
@@ -30,7 +28,12 @@ const formModalRef = ref();
|
||||
const gridOptions: VxeGridProps<any> = {
|
||||
columns: [
|
||||
{ type: 'seq', width: 80, title: '序号' },
|
||||
{ field: 'name', title: '模板名称', minWidth: 'auto', showOverflow: 'tooltip' },
|
||||
{
|
||||
field: 'name',
|
||||
title: '模板名称',
|
||||
minWidth: 'auto',
|
||||
showOverflow: 'tooltip',
|
||||
},
|
||||
{ field: 'type', title: '类型', width: 120, slots: { default: 'type' } },
|
||||
{
|
||||
title: '映射状态数',
|
||||
@@ -65,7 +68,7 @@ const gridOptions: VxeGridProps<any> = {
|
||||
filters: { type: ImportMappingType.ORDER_STATUS },
|
||||
});
|
||||
return { items: result.records || [], total: result.total || 0 };
|
||||
} catch (error) {
|
||||
} catch {
|
||||
message.error('获取订单状态映射模板列表失败');
|
||||
return { items: [], total: 0 };
|
||||
} finally {
|
||||
@@ -76,7 +79,11 @@ const gridOptions: VxeGridProps<any> = {
|
||||
},
|
||||
};
|
||||
|
||||
const [Grid, gridApi] = useVbenVxeGrid({ gridOptions, showSearchForm: false, tableTitle: '订单状态映射模板' });
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
gridOptions,
|
||||
showSearchForm: false,
|
||||
tableTitle: '订单状态映射模板',
|
||||
});
|
||||
|
||||
function refresh() {
|
||||
gridApi?.reload();
|
||||
@@ -95,7 +102,7 @@ async function handleDelete(row: ImportMappingVO.ImportMappingInfoVO) {
|
||||
await deleteImportMappingApi(row.id);
|
||||
message.success('删除成功');
|
||||
refresh();
|
||||
} catch (error) {
|
||||
} catch {
|
||||
message.error('删除失败');
|
||||
}
|
||||
}
|
||||
@@ -141,7 +148,9 @@ function getTypeName(type: ImportMappingType): string {
|
||||
<Tag color="orange">{{ getTypeName(row.type) }}</Tag>
|
||||
</template>
|
||||
|
||||
<template #mappingCount="{ row }: { row: ImportMappingVO.ImportMappingInfoVO }">
|
||||
<template
|
||||
#mappingCount="{ row }: { row: ImportMappingVO.ImportMappingInfoVO }"
|
||||
>
|
||||
<Tag color="green">{{ getMappingCount(row.mapping) }} 个状态</Tag>
|
||||
</template>
|
||||
|
||||
|
||||
@@ -471,19 +471,21 @@ const handleExportCompanyOverview = async () => {
|
||||
// 优先使用已加载的 shopComparisons 数据(保持和页面一致的列顺序)
|
||||
let dataToExport: CompanyOverviewVO.ShopComparison[] = [];
|
||||
if (overviewData.value?.shopComparisons) {
|
||||
if (selectedExportShopIds.value.length > 0) {
|
||||
dataToExport = overviewData.value.shopComparisons.filter((s) =>
|
||||
selectedExportShopIds.value.includes(s.shopId),
|
||||
);
|
||||
} else {
|
||||
dataToExport = overviewData.value.shopComparisons;
|
||||
}
|
||||
dataToExport =
|
||||
selectedExportShopIds.value.length > 0
|
||||
? overviewData.value.shopComparisons.filter((s) =>
|
||||
selectedExportShopIds.value.includes(s.shopId),
|
||||
)
|
||||
: overviewData.value.shopComparisons;
|
||||
}
|
||||
|
||||
// 若无缓存数据,走原有接口按 shopIds 过滤
|
||||
let shopIds: number[] | undefined;
|
||||
if (dataToExport.length === 0) {
|
||||
shopIds = selectedExportShopIds.value.length > 0 ? selectedExportShopIds.value : undefined;
|
||||
shopIds =
|
||||
selectedExportShopIds.value.length > 0
|
||||
? selectedExportShopIds.value
|
||||
: undefined;
|
||||
}
|
||||
|
||||
const filename = `公司概览_${startDate.format('YYYYMMDD')}_${endDate.format('YYYYMMDD')}.xlsx`;
|
||||
@@ -535,10 +537,12 @@ const handleExportSelectedShops = async () => {
|
||||
<template #extra>
|
||||
<!-- 时间选择器 - 响应式适配 -->
|
||||
<div
|
||||
class="flex flex-col gap-2 sm:flex-row sm:items-center sm:gap-2 rounded-2xl border border-slate-200 bg-slate-200/50 p-1.5"
|
||||
class="flex flex-col gap-2 rounded-2xl border border-slate-200 bg-slate-200/50 p-1.5 sm:flex-row sm:items-center sm:gap-2"
|
||||
>
|
||||
<!-- 快速选择按钮组 -->
|
||||
<div class="flex items-center gap-1 rounded-xl bg-white/30 p-1 overflow-x-auto">
|
||||
<div
|
||||
class="flex items-center gap-1 overflow-x-auto rounded-xl bg-white/30 p-1"
|
||||
>
|
||||
<Button
|
||||
type="text"
|
||||
size="small"
|
||||
@@ -596,7 +600,9 @@ const handleExportSelectedShops = async () => {
|
||||
<div class="hidden h-6 w-px bg-slate-300 sm:block"></div>
|
||||
<!-- 自定义日期选择器 -->
|
||||
<div class="flex items-center gap-2 rounded-xl bg-white/30 px-3 py-1.5">
|
||||
<span class="hidden text-xs font-bold text-slate-400 sm:inline">自定义日期</span>
|
||||
<span class="hidden text-xs font-bold text-slate-400 sm:inline">
|
||||
自定义日期
|
||||
</span>
|
||||
<DatePicker.RangePicker
|
||||
v-model:value="customDateRange"
|
||||
size="small"
|
||||
@@ -843,12 +849,11 @@ const handleExportSelectedShops = async () => {
|
||||
:indeterminate="someShopsSelected && !allShopsSelected"
|
||||
@change="
|
||||
(e) => {
|
||||
if (
|
||||
(e.target as HTMLInputElement).checked
|
||||
) {
|
||||
if ((e.target as HTMLInputElement).checked) {
|
||||
selectedExportShopIds =
|
||||
overviewData?.shopComparisons?.map(
|
||||
(s: CompanyOverviewVO.ShopComparison) => s.shopId,
|
||||
(s: CompanyOverviewVO.ShopComparison) =>
|
||||
s.shopId,
|
||||
) || [];
|
||||
} else {
|
||||
selectedExportShopIds = [];
|
||||
|
||||
+4
-2
@@ -114,13 +114,14 @@ const gridOptions: VxeGridProps<any> = {
|
||||
};
|
||||
|
||||
// 搜索表单配置
|
||||
const gridReloadRef = ref<(() => void) | null>(null);
|
||||
const formOptions = computed(() => ({
|
||||
schema: [
|
||||
{
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入状态名称(回车搜索)',
|
||||
onPressEnter: () => gridApi?.reload(),
|
||||
onPressEnter: () => gridReloadRef.value?.(),
|
||||
},
|
||||
fieldName: 'statusName',
|
||||
label: '状态名称',
|
||||
@@ -134,7 +135,7 @@ const formOptions = computed(() => ({
|
||||
{ label: '不参与自动统计', value: 0 },
|
||||
],
|
||||
allowClear: true,
|
||||
onChange: () => gridApi?.reload(),
|
||||
onChange: () => gridReloadRef.value?.(),
|
||||
},
|
||||
fieldName: 'autoStatistics',
|
||||
label: '自动统计',
|
||||
@@ -152,6 +153,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
showSearchForm: true,
|
||||
tableTitle: '订单状态配置',
|
||||
});
|
||||
gridReloadRef.value = () => gridApi.reload();
|
||||
|
||||
// 刷新表格数据
|
||||
function refreshTable() {
|
||||
|
||||
+4
-2
@@ -128,13 +128,14 @@ const gridOptions: VxeGridProps<any> = {
|
||||
};
|
||||
|
||||
// 搜索表单配置
|
||||
const gridReloadRef = ref<(() => void) | null>(null);
|
||||
const formOptions = computed(() => ({
|
||||
schema: [
|
||||
{
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入类型名称(回车搜索)',
|
||||
onPressEnter: () => gridApi?.reload(),
|
||||
onPressEnter: () => gridReloadRef.value?.(),
|
||||
},
|
||||
fieldName: 'typeName',
|
||||
label: '类型名称',
|
||||
@@ -148,7 +149,7 @@ const formOptions = computed(() => ({
|
||||
{ label: '禁用', value: 0 },
|
||||
],
|
||||
allowClear: true,
|
||||
onChange: () => gridApi?.reload(),
|
||||
onChange: () => gridReloadRef.value?.(),
|
||||
},
|
||||
fieldName: 'isActive',
|
||||
label: '状态',
|
||||
@@ -166,6 +167,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
showSearchForm: true,
|
||||
tableTitle: '推广费用类型配置',
|
||||
});
|
||||
gridReloadRef.value = () => gridApi.reload();
|
||||
|
||||
// 刷新表格数据
|
||||
function refreshTable() {
|
||||
|
||||
+89
-28
@@ -32,8 +32,8 @@ import {
|
||||
import { createImportTaskApi } from '#/api/ecommerce/import-task';
|
||||
import { getAllOrderStatusListApi } from '#/api/ecommerce/order-status';
|
||||
import { getShopPageApi } from '#/api/ecommerce/shop';
|
||||
import { uploadFileToOss } from '#/utils/oss-upload';
|
||||
import { useImportTaskStore } from '#/store';
|
||||
import { uploadFileToOss } from '#/utils/oss-upload';
|
||||
|
||||
// 定义映射项数据结构
|
||||
interface FieldMappingItem {
|
||||
@@ -97,14 +97,14 @@ const fieldMappings = ref<
|
||||
>({});
|
||||
|
||||
// 映射模板相关
|
||||
const mappingTemplates = ref<ImportMappingVO.ImportMappingVO[]>([]);
|
||||
const mappingTemplates = ref<ImportMappingVO.ImportMappingInfoVO[]>([]);
|
||||
const selectedTemplateId = ref<number | undefined>();
|
||||
const selectedTemplateName = ref('');
|
||||
const templateLoading = ref(false);
|
||||
const savingTemplate = ref(false);
|
||||
const templateName = ref('');
|
||||
// 保存单个字段映射到模板
|
||||
const savingFieldToTemplate = ref<number | null>(null);
|
||||
const savingFieldToTemplate = ref<null | number>(null);
|
||||
// 当前模板的原始映射数据(用于对比哪些字段是模板的)
|
||||
const currentTemplateMappings = ref<FieldMappingItem[]>([]);
|
||||
|
||||
@@ -117,7 +117,7 @@ const selectedStatusTemplateName = ref('');
|
||||
const statusTemplateLoading = ref(false);
|
||||
const savingStatusTemplate = ref(false);
|
||||
const statusTemplateName = ref('');
|
||||
const savingStatusFieldToTemplate = ref<string | null>(null);
|
||||
const savingStatusFieldToTemplate = ref<null | string>(null);
|
||||
// 当前状态模板的原始映射数据
|
||||
const currentStatusTemplateMappings = ref<StatusMappingItem[]>([]);
|
||||
// 订单状态列表
|
||||
@@ -206,7 +206,10 @@ const isMappingChangedFromTemplate = (fieldDefId: number): boolean => {
|
||||
if (!templateItem) return false;
|
||||
const currentMapping = fieldMappings.value[fieldDefId];
|
||||
// 模板有定义,但当前映射与模板不同
|
||||
if (templateItem.fileFieldName && currentMapping?.mappedHeader !== templateItem.fileFieldName) {
|
||||
if (
|
||||
templateItem.fileFieldName &&
|
||||
currentMapping?.mappedHeader !== templateItem.fileFieldName
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -214,7 +217,10 @@ const isMappingChangedFromTemplate = (fieldDefId: number): boolean => {
|
||||
|
||||
// 判断某个订单状态的当前映射是否来自模板
|
||||
const isStatusMappingFromTemplate = (csvStatus: string): boolean => {
|
||||
if (!selectedStatusTemplateId.value || currentStatusTemplateMappings.value.length === 0) {
|
||||
if (
|
||||
!selectedStatusTemplateId.value ||
|
||||
currentStatusTemplateMappings.value.length === 0
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
const templateItem = currentStatusTemplateMappings.value.find(
|
||||
@@ -226,7 +232,10 @@ const isStatusMappingFromTemplate = (csvStatus: string): boolean => {
|
||||
|
||||
// 判断某个订单状态的映射与模板原始定义是否相同
|
||||
const isStatusMappingChangedFromTemplate = (csvStatus: string): boolean => {
|
||||
if (!selectedStatusTemplateId.value || currentStatusTemplateMappings.value.length === 0) {
|
||||
if (
|
||||
!selectedStatusTemplateId.value ||
|
||||
currentStatusTemplateMappings.value.length === 0
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
const templateItem = currentStatusTemplateMappings.value.find(
|
||||
@@ -520,10 +529,10 @@ const handleAddFieldToTemplate = async (fieldDefId: number) => {
|
||||
const existingIdx = mappingItems.findIndex(
|
||||
(item) => item.fieldName === fieldDef.fieldName,
|
||||
);
|
||||
if (existingIdx >= 0) {
|
||||
mappingItems[existingIdx] = fieldItem;
|
||||
} else {
|
||||
if (existingIdx === -1) {
|
||||
mappingItems.push(fieldItem);
|
||||
} else {
|
||||
mappingItems[existingIdx] = fieldItem;
|
||||
}
|
||||
|
||||
const mappingJson = JSON.stringify(mappingItems);
|
||||
@@ -634,10 +643,10 @@ const handleAddStatusFieldToTemplate = async (csvStatus: string) => {
|
||||
const existingIdx = mappingItems.findIndex(
|
||||
(item) => item.csvStatus === csvStatus,
|
||||
);
|
||||
if (existingIdx >= 0) {
|
||||
mappingItems[existingIdx] = statusItem;
|
||||
} else {
|
||||
if (existingIdx === -1) {
|
||||
mappingItems.push(statusItem);
|
||||
} else {
|
||||
mappingItems[existingIdx] = statusItem;
|
||||
}
|
||||
|
||||
const mappingJson = JSON.stringify(mappingItems);
|
||||
@@ -1169,7 +1178,10 @@ const shopOptions = computed(() => {
|
||||
</span>
|
||||
</Select.Option>
|
||||
</Select>
|
||||
<Button :disabled="selectedTemplateId !== undefined" @click="handleSaveTemplate">
|
||||
<Button
|
||||
:disabled="selectedTemplateId !== undefined"
|
||||
@click="handleSaveTemplate"
|
||||
>
|
||||
保存为模板
|
||||
</Button>
|
||||
</div>
|
||||
@@ -1183,7 +1195,9 @@ const shopOptions = computed(() => {
|
||||
'border-red-300 bg-red-50':
|
||||
fieldDef.required && !fieldMappings[fieldDef.id]?.mappedHeader,
|
||||
'border-blue-200 bg-blue-50': isMappingFromTemplate(fieldDef.id),
|
||||
'border-yellow-200 bg-yellow-50': isMappingChangedFromTemplate(fieldDef.id),
|
||||
'border-yellow-200 bg-yellow-50': isMappingChangedFromTemplate(
|
||||
fieldDef.id,
|
||||
),
|
||||
}"
|
||||
>
|
||||
<div class="flex-1">
|
||||
@@ -1193,13 +1207,18 @@ const shopOptions = computed(() => {
|
||||
(必填)
|
||||
</span>
|
||||
<span
|
||||
v-if="selectedTemplateId && isMappingFromTemplate(fieldDef.id)"
|
||||
v-if="
|
||||
selectedTemplateId && isMappingFromTemplate(fieldDef.id)
|
||||
"
|
||||
class="ml-1 rounded bg-blue-100 px-1.5 py-0.5 text-xs text-blue-600"
|
||||
>
|
||||
模板映射
|
||||
</span>
|
||||
<span
|
||||
v-if="selectedTemplateId && isMappingChangedFromTemplate(fieldDef.id)"
|
||||
v-if="
|
||||
selectedTemplateId &&
|
||||
isMappingChangedFromTemplate(fieldDef.id)
|
||||
"
|
||||
class="ml-1 rounded bg-yellow-100 px-1.5 py-0.5 text-xs text-yellow-600"
|
||||
>
|
||||
已变更
|
||||
@@ -1209,10 +1228,20 @@ const shopOptions = computed(() => {
|
||||
字段名: {{ fieldDef.fieldName }}
|
||||
</div>
|
||||
<div
|
||||
v-if="selectedTemplateId && currentTemplateMappings.find((m) => m.fieldName === fieldDef.fieldName)"
|
||||
v-if="
|
||||
selectedTemplateId &&
|
||||
currentTemplateMappings.some(
|
||||
(m) => m.fieldName === fieldDef.fieldName,
|
||||
)
|
||||
"
|
||||
class="mt-1 text-xs text-gray-400"
|
||||
>
|
||||
模板原映射: {{ currentTemplateMappings.find((m) => m.fieldName === fieldDef.fieldName)?.fileFieldName || '(未映射)' }}
|
||||
模板原映射:
|
||||
{{
|
||||
currentTemplateMappings.find(
|
||||
(m) => m.fieldName === fieldDef.fieldName,
|
||||
)?.fileFieldName || '(未映射)'
|
||||
}}
|
||||
</div>
|
||||
</div>
|
||||
<Select
|
||||
@@ -1230,7 +1259,9 @@ const shopOptions = computed(() => {
|
||||
"
|
||||
/>
|
||||
<Button
|
||||
v-if="selectedTemplateId && fieldMappings[fieldDef.id]?.mappedHeader"
|
||||
v-if="
|
||||
selectedTemplateId && fieldMappings[fieldDef.id]?.mappedHeader
|
||||
"
|
||||
size="small"
|
||||
type="link"
|
||||
:disabled="isMappingFromTemplate(fieldDef.id)"
|
||||
@@ -1278,7 +1309,10 @@ const shopOptions = computed(() => {
|
||||
</span>
|
||||
</Select.Option>
|
||||
</Select>
|
||||
<Button :disabled="selectedStatusTemplateId !== undefined" @click="handleSaveStatusTemplate">
|
||||
<Button
|
||||
:disabled="selectedStatusTemplateId !== undefined"
|
||||
@click="handleSaveStatusTemplate"
|
||||
>
|
||||
保存为模板
|
||||
</Button>
|
||||
</div>
|
||||
@@ -1295,21 +1329,31 @@ const shopOptions = computed(() => {
|
||||
:key="statusValue"
|
||||
class="flex items-center space-x-4 rounded border p-3"
|
||||
:class="{
|
||||
'border-blue-200 bg-blue-50': selectedStatusTemplateId && isStatusMappingFromTemplate(statusValue),
|
||||
'border-yellow-200 bg-yellow-50': selectedStatusTemplateId && isStatusMappingChangedFromTemplate(statusValue),
|
||||
'border-blue-200 bg-blue-50':
|
||||
selectedStatusTemplateId &&
|
||||
isStatusMappingFromTemplate(statusValue),
|
||||
'border-yellow-200 bg-yellow-50':
|
||||
selectedStatusTemplateId &&
|
||||
isStatusMappingChangedFromTemplate(statusValue),
|
||||
}"
|
||||
>
|
||||
<div class="flex-1">
|
||||
<div class="flex items-center space-x-2">
|
||||
<span class="font-medium">{{ statusValue }}</span>
|
||||
<span
|
||||
v-if="selectedStatusTemplateId && isStatusMappingFromTemplate(statusValue)"
|
||||
v-if="
|
||||
selectedStatusTemplateId &&
|
||||
isStatusMappingFromTemplate(statusValue)
|
||||
"
|
||||
class="ml-1 rounded bg-blue-100 px-1.5 py-0.5 text-xs text-blue-600"
|
||||
>
|
||||
模板映射
|
||||
</span>
|
||||
<span
|
||||
v-if="selectedStatusTemplateId && isStatusMappingChangedFromTemplate(statusValue)"
|
||||
v-if="
|
||||
selectedStatusTemplateId &&
|
||||
isStatusMappingChangedFromTemplate(statusValue)
|
||||
"
|
||||
class="ml-1 rounded bg-yellow-100 px-1.5 py-0.5 text-xs text-yellow-600"
|
||||
>
|
||||
已变更
|
||||
@@ -1317,10 +1361,24 @@ const shopOptions = computed(() => {
|
||||
</div>
|
||||
<div class="mt-1 text-xs text-gray-500">CSV中的订单状态值</div>
|
||||
<div
|
||||
v-if="selectedStatusTemplateId && currentStatusTemplateMappings.find((m) => m.csvStatus === statusValue)"
|
||||
v-if="
|
||||
selectedStatusTemplateId &&
|
||||
currentStatusTemplateMappings.some(
|
||||
(m) => m.csvStatus === statusValue,
|
||||
)
|
||||
"
|
||||
class="mt-1 text-xs text-gray-400"
|
||||
>
|
||||
模板原映射: {{ orderStatusList.find((s) => s.id === currentStatusTemplateMappings.find((m) => m.csvStatus === statusValue)?.mappedStatusId)?.statusName || '(未映射)' }}
|
||||
模板原映射:
|
||||
{{
|
||||
orderStatusList.find(
|
||||
(s) =>
|
||||
s.id ===
|
||||
currentStatusTemplateMappings.find(
|
||||
(m) => m.csvStatus === statusValue,
|
||||
)?.mappedStatusId,
|
||||
)?.statusName || '(未映射)'
|
||||
}}
|
||||
</div>
|
||||
</div>
|
||||
<Select
|
||||
@@ -1338,7 +1396,10 @@ const shopOptions = computed(() => {
|
||||
"
|
||||
/>
|
||||
<Button
|
||||
v-if="selectedStatusTemplateId && statusMappings[statusValue] !== undefined"
|
||||
v-if="
|
||||
selectedStatusTemplateId &&
|
||||
statusMappings[statusValue] !== undefined
|
||||
"
|
||||
size="small"
|
||||
type="link"
|
||||
:disabled="isStatusMappingFromTemplate(statusValue)"
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<script lang="ts" setup>
|
||||
import type { VxeGridProps } from '#/adapter/vxe-table';
|
||||
import type { OrderDTO, OrderVO } from '#/api/ecommerce/order';
|
||||
import type { OrderStatusVO } from '#/api/ecommerce/order-status/types';
|
||||
import type { ShopDTO, ShopVO } from '#/api/ecommerce/shop/types';
|
||||
import type { PageQueryDTO } from '#/types/common';
|
||||
|
||||
@@ -12,12 +13,8 @@ import { createIconifyIcon } from '@vben/icons';
|
||||
import { Button, message, Popconfirm, Space, Tag } from 'ant-design-vue';
|
||||
|
||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import {
|
||||
deleteOrderApi,
|
||||
getOrderPageApi,
|
||||
} from '#/api/ecommerce/order';
|
||||
import { deleteOrderApi, getOrderPageApi } from '#/api/ecommerce/order';
|
||||
import { getAllOrderStatusListApi } from '#/api/ecommerce/order-status';
|
||||
import type { OrderStatusVO } from '#/api/ecommerce/order-status/types';
|
||||
import { getShopPageApi } from '#/api/ecommerce/shop';
|
||||
|
||||
import OrderFormModal from './components/OrderFormModal.vue';
|
||||
@@ -37,7 +34,7 @@ const shopPageSize = 20;
|
||||
const shopTotal = ref(0);
|
||||
const shopLoading = ref(false);
|
||||
const shopSearchKeyword = ref('');
|
||||
let shopSearchTimer: ReturnType<typeof setTimeout> | null = null;
|
||||
let shopSearchTimer: null | ReturnType<typeof setTimeout> = null;
|
||||
|
||||
// 订单状态选项
|
||||
const orderStatusOptions = ref<{ label: string; value: number }[]>([]);
|
||||
@@ -50,7 +47,7 @@ const searchForm = ref({
|
||||
});
|
||||
|
||||
// 当前排序状态
|
||||
const currentSort = ref<{ field: string; order: 'asc' | 'desc' } | null>(null);
|
||||
const currentSort = ref<null | { field: string; order: 'asc' | 'desc' }>(null);
|
||||
|
||||
// 加载店铺列表(支持分页)
|
||||
async function fetchShops(page = 1, append = false) {
|
||||
@@ -63,17 +60,18 @@ async function fetchShops(page = 1, append = false) {
|
||||
filters: shopSearchKeyword.value ? { name: shopSearchKeyword.value } : {},
|
||||
};
|
||||
const data = await getShopPageApi(params);
|
||||
if (append) {
|
||||
shopOptions.value = [...shopOptions.value, ...data.records.map((shop: ShopVO.Info) => ({
|
||||
label: shop.name,
|
||||
value: shop.id,
|
||||
}))];
|
||||
} else {
|
||||
shopOptions.value = data.records.map((shop: ShopVO.Info) => ({
|
||||
label: shop.name,
|
||||
value: shop.id,
|
||||
}));
|
||||
}
|
||||
shopOptions.value = append
|
||||
? [
|
||||
...shopOptions.value,
|
||||
...data.records.map((shop: ShopVO.Info) => ({
|
||||
label: shop.name,
|
||||
value: shop.id,
|
||||
})),
|
||||
]
|
||||
: data.records.map((shop: ShopVO.Info) => ({
|
||||
label: shop.name,
|
||||
value: shop.id,
|
||||
}));
|
||||
shopTotal.value = data.total;
|
||||
shopPage.value = page;
|
||||
} catch (error) {
|
||||
@@ -182,11 +180,6 @@ const gridOptions: VxeGridProps<any> = {
|
||||
multiple: false,
|
||||
orders: ['desc', 'asc'],
|
||||
},
|
||||
sortChange: ({ field, order }) => {
|
||||
// 保存排序状态并触发搜索
|
||||
currentSort.value = { field, order: order || 'desc' };
|
||||
gridApi?.reload();
|
||||
},
|
||||
toolbarConfig: {
|
||||
custom: true,
|
||||
refresh: true,
|
||||
@@ -226,7 +219,10 @@ const gridOptions: VxeGridProps<any> = {
|
||||
const searchParams = form || {};
|
||||
// 合并表单值和本地状态
|
||||
const filters = {
|
||||
platformOrderNo: searchParams.platformOrderNo || searchForm.value.platformOrderNo || undefined,
|
||||
platformOrderNo:
|
||||
searchParams.platformOrderNo ||
|
||||
searchForm.value.platformOrderNo ||
|
||||
undefined,
|
||||
shopId: searchParams.shopId ?? searchForm.value.shopId,
|
||||
statusId: searchParams.statusId ?? searchForm.value.statusId,
|
||||
};
|
||||
@@ -237,7 +233,12 @@ const gridOptions: VxeGridProps<any> = {
|
||||
};
|
||||
// 处理排序参数
|
||||
if (currentSort.value) {
|
||||
params.sorts = [{ field: currentSort.value.field, order: currentSort.value.order }];
|
||||
params.sorts = [
|
||||
{
|
||||
field: currentSort.value.field,
|
||||
order: currentSort.value.order,
|
||||
},
|
||||
];
|
||||
}
|
||||
const data = await getOrderPageApi(params);
|
||||
return {
|
||||
@@ -260,13 +261,14 @@ const gridOptions: VxeGridProps<any> = {
|
||||
};
|
||||
|
||||
// 搜索表单配置
|
||||
const gridReloadRef = ref<(() => void) | null>(null);
|
||||
const formOptions = computed(() => ({
|
||||
schema: [
|
||||
{
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入平台订单号(回车搜索)',
|
||||
onPressEnter: () => gridApi?.reload(),
|
||||
onPressEnter: () => gridReloadRef.value?.(),
|
||||
},
|
||||
fieldName: 'platformOrderNo',
|
||||
label: '平台订单号',
|
||||
@@ -283,7 +285,7 @@ const formOptions = computed(() => ({
|
||||
onPopupScroll: handleShopPopupScroll,
|
||||
onChange: (val: any) => {
|
||||
searchForm.value.shopId = val;
|
||||
gridApi?.reload();
|
||||
gridReloadRef.value?.();
|
||||
},
|
||||
loading: shopLoading,
|
||||
dropdownMenuColumnStyle: { maxHeight: '300px', overflow: 'auto' },
|
||||
@@ -299,7 +301,7 @@ const formOptions = computed(() => ({
|
||||
allowClear: true,
|
||||
onChange: (val: any) => {
|
||||
searchForm.value.statusId = val;
|
||||
gridApi?.reload();
|
||||
gridReloadRef.value?.();
|
||||
},
|
||||
},
|
||||
fieldName: 'statusId',
|
||||
@@ -318,6 +320,17 @@ function refreshTable() {
|
||||
}
|
||||
}
|
||||
|
||||
function handleSortChange({
|
||||
field,
|
||||
order,
|
||||
}: {
|
||||
field?: string;
|
||||
order?: 'asc' | 'desc' | null;
|
||||
}) {
|
||||
currentSort.value = field ? { field, order: order || 'desc' } : null;
|
||||
gridReloadRef.value?.();
|
||||
}
|
||||
|
||||
// 获取店铺选项(首次加载)
|
||||
async function fetchShopOptions() {
|
||||
await fetchShops(1, false);
|
||||
@@ -343,6 +356,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
showSearchForm: true,
|
||||
tableTitle: '订单管理',
|
||||
});
|
||||
gridReloadRef.value = () => gridApi.reload();
|
||||
|
||||
// 处理添加订单
|
||||
function handleAdd() {
|
||||
@@ -381,7 +395,7 @@ onMounted(async () => {
|
||||
<template>
|
||||
<Page auto-content-height>
|
||||
<!-- VbenVxeGrid 表格 -->
|
||||
<Grid :loading="loading">
|
||||
<Grid :loading="loading" @sort-change="handleSortChange">
|
||||
<!-- 工具栏工具 -->
|
||||
<template #toolbar-tools>
|
||||
<Space>
|
||||
@@ -417,10 +431,7 @@ onMounted(async () => {
|
||||
|
||||
<!-- 订单状态列 -->
|
||||
<template #orderStatus="{ row }: { row: any }">
|
||||
<Tag
|
||||
:color="row.orderStatus?.color || 'blue'"
|
||||
type="outline"
|
||||
>
|
||||
<Tag :color="row.orderStatus?.color || 'blue'" type="outline">
|
||||
{{ row.statusName || '未知状态' }}
|
||||
</Tag>
|
||||
</template>
|
||||
|
||||
+6
-4
@@ -201,13 +201,14 @@ const gridOptions: VxeGridProps<any> = {
|
||||
};
|
||||
|
||||
// 搜索表单配置
|
||||
const gridReloadRef = ref<(() => void) | null>(null);
|
||||
const formOptions = computed(() => ({
|
||||
schema: [
|
||||
{
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入商品名称(回车搜索)',
|
||||
onPressEnter: () => gridApi?.reload(),
|
||||
onPressEnter: () => gridReloadRef.value?.(),
|
||||
},
|
||||
fieldName: 'name',
|
||||
label: '商品名称',
|
||||
@@ -216,7 +217,7 @@ const formOptions = computed(() => ({
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入商品编码(回车搜索)',
|
||||
onPressEnter: () => gridApi?.reload(),
|
||||
onPressEnter: () => gridReloadRef.value?.(),
|
||||
},
|
||||
fieldName: 'productCode',
|
||||
label: '商品编码',
|
||||
@@ -225,7 +226,7 @@ const formOptions = computed(() => ({
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入规格编码(回车搜索)',
|
||||
onPressEnter: () => gridApi?.reload(),
|
||||
onPressEnter: () => gridReloadRef.value?.(),
|
||||
},
|
||||
fieldName: 'specCode',
|
||||
label: '规格编码',
|
||||
@@ -234,7 +235,7 @@ const formOptions = computed(() => ({
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入规格名称(回车搜索)',
|
||||
onPressEnter: () => gridApi?.reload(),
|
||||
onPressEnter: () => gridReloadRef.value?.(),
|
||||
},
|
||||
fieldName: 'specName',
|
||||
label: '规格名称',
|
||||
@@ -259,6 +260,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
showSearchForm: true,
|
||||
tableTitle: '商品管理',
|
||||
});
|
||||
gridReloadRef.value = () => gridApi.reload();
|
||||
|
||||
// 事件处理
|
||||
const handleEdit = (product: ProductVO.Info) => {
|
||||
|
||||
@@ -178,6 +178,7 @@ const gridOptions: VxeGridProps<any> = {
|
||||
};
|
||||
|
||||
// 搜索表单配置
|
||||
const gridReloadRef = ref<(() => void) | null>(null);
|
||||
const formOptions = computed(() => ({
|
||||
schema: [
|
||||
{
|
||||
@@ -187,7 +188,7 @@ const formOptions = computed(() => ({
|
||||
// TODO: 这里需要从店铺API获取店铺列表
|
||||
options: [],
|
||||
allowClear: true,
|
||||
onChange: () => gridApi?.reload(),
|
||||
onChange: () => gridReloadRef.value?.(),
|
||||
},
|
||||
fieldName: 'shopId',
|
||||
label: '店铺',
|
||||
@@ -199,7 +200,7 @@ const formOptions = computed(() => ({
|
||||
// TODO: 这里需要从推广费类型API获取类型列表
|
||||
options: [],
|
||||
allowClear: true,
|
||||
onChange: () => gridApi?.reload(),
|
||||
onChange: () => gridReloadRef.value?.(),
|
||||
},
|
||||
fieldName: 'feeTypeId',
|
||||
label: '推广费类型',
|
||||
@@ -210,7 +211,7 @@ const formOptions = computed(() => ({
|
||||
placeholder: '请选择平台',
|
||||
options: platformOptions,
|
||||
allowClear: true,
|
||||
onChange: () => gridApi?.reload(),
|
||||
onChange: () => gridReloadRef.value?.(),
|
||||
},
|
||||
fieldName: 'platform',
|
||||
label: '平台',
|
||||
@@ -220,7 +221,7 @@ const formOptions = computed(() => ({
|
||||
componentProps: {
|
||||
placeholder: '开始日期',
|
||||
style: { width: '100%' },
|
||||
onChange: () => gridApi?.reload(),
|
||||
onChange: () => gridReloadRef.value?.(),
|
||||
},
|
||||
fieldName: 'feeDateStart',
|
||||
label: '发生日期',
|
||||
@@ -230,7 +231,7 @@ const formOptions = computed(() => ({
|
||||
componentProps: {
|
||||
placeholder: '结束日期',
|
||||
style: { width: '100%' },
|
||||
onChange: () => gridApi?.reload(),
|
||||
onChange: () => gridReloadRef.value?.(),
|
||||
},
|
||||
fieldName: 'feeDateEnd',
|
||||
label: '至',
|
||||
@@ -255,6 +256,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
showSearchForm: true,
|
||||
tableTitle: '推广费管理',
|
||||
});
|
||||
gridReloadRef.value = () => gridApi.reload();
|
||||
|
||||
// 处理新增
|
||||
const handleAdd = () => {
|
||||
|
||||
+4
-2
@@ -139,13 +139,14 @@ const gridOptions: VxeGridProps<any> = {
|
||||
};
|
||||
|
||||
// 搜索表单配置
|
||||
const gridReloadRef = ref<(() => void) | null>(null);
|
||||
const formOptions = computed(() => ({
|
||||
schema: [
|
||||
{
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入商品名称(回车搜索)',
|
||||
onPressEnter: () => gridApi?.reload(),
|
||||
onPressEnter: () => gridReloadRef.value?.(),
|
||||
},
|
||||
fieldName: 'name',
|
||||
label: '商品名称',
|
||||
@@ -154,7 +155,7 @@ const formOptions = computed(() => ({
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入商品编码(回车搜索)',
|
||||
onPressEnter: () => gridApi?.reload(),
|
||||
onPressEnter: () => gridReloadRef.value?.(),
|
||||
},
|
||||
fieldName: 'productCode',
|
||||
label: '商品编码',
|
||||
@@ -172,6 +173,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
showSearchForm: true,
|
||||
tableTitle: '商品列表',
|
||||
});
|
||||
gridReloadRef.value = () => gridApi.reload();
|
||||
|
||||
// 监听 shopId 变化,刷新表格
|
||||
watch(
|
||||
|
||||
+4
-2
@@ -139,13 +139,14 @@ const gridOptions: VxeGridProps<any> = {
|
||||
};
|
||||
|
||||
// 搜索表单配置
|
||||
const gridReloadRef = ref<(() => void) | null>(null);
|
||||
const formOptions = computed(() => ({
|
||||
schema: [
|
||||
{
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入商品名称(回车搜索)',
|
||||
onPressEnter: () => gridApi?.reload(),
|
||||
onPressEnter: () => gridReloadRef.value?.(),
|
||||
},
|
||||
fieldName: 'name',
|
||||
label: '商品名称',
|
||||
@@ -154,7 +155,7 @@ const formOptions = computed(() => ({
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入商品编码(回车搜索)',
|
||||
onPressEnter: () => gridApi?.reload(),
|
||||
onPressEnter: () => gridReloadRef.value?.(),
|
||||
},
|
||||
fieldName: 'productCode',
|
||||
label: '商品编码',
|
||||
@@ -172,6 +173,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
showSearchForm: true,
|
||||
tableTitle: '商品列表',
|
||||
});
|
||||
gridReloadRef.value = () => gridApi.reload();
|
||||
|
||||
// 监听 shopId 变化,刷新表格
|
||||
watch(
|
||||
|
||||
@@ -157,13 +157,14 @@ const gridOptions: VxeGridProps<any> = {
|
||||
};
|
||||
|
||||
// 搜索表单配置
|
||||
const gridReloadRef = ref<(() => void) | null>(null);
|
||||
const formOptions = computed(() => ({
|
||||
schema: [
|
||||
{
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入店铺名称(回车搜索)',
|
||||
onPressEnter: () => gridApi?.reload(),
|
||||
onPressEnter: () => gridReloadRef.value?.(),
|
||||
},
|
||||
fieldName: 'name',
|
||||
label: '店铺名称',
|
||||
@@ -174,7 +175,7 @@ const formOptions = computed(() => ({
|
||||
placeholder: '请选择平台',
|
||||
options: platformOptions,
|
||||
allowClear: true,
|
||||
onChange: () => gridApi?.reload(),
|
||||
onChange: () => gridReloadRef.value?.(),
|
||||
},
|
||||
fieldName: 'platform',
|
||||
label: '平台',
|
||||
@@ -192,6 +193,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
showSearchForm: true,
|
||||
tableTitle: '店铺管理',
|
||||
});
|
||||
gridReloadRef.value = () => gridApi.reload();
|
||||
|
||||
// 刷新表格数据
|
||||
function refreshTable() {
|
||||
|
||||
+2
-3
@@ -5,7 +5,6 @@ import type {
|
||||
} from '#/api/ecommerce/shop-monthly-target';
|
||||
import type { ShopVO } from '#/api/ecommerce/shop/types';
|
||||
|
||||
import dayjs from 'dayjs';
|
||||
import { onMounted, ref, watch } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
@@ -18,12 +17,13 @@ import {
|
||||
message,
|
||||
Select,
|
||||
} from 'ant-design-vue';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
import { getShopPageApi } from '#/api/ecommerce/shop';
|
||||
import {
|
||||
createShopMonthlyTargetApi,
|
||||
updateShopMonthlyTargetApi,
|
||||
} from '#/api/ecommerce/shop-monthly-target';
|
||||
import { getShopPageApi } from '#/api/ecommerce/shop';
|
||||
|
||||
defineOptions({ name: 'ShopMonthlyTargetFormModal' });
|
||||
|
||||
@@ -271,4 +271,3 @@ onMounted(() => {
|
||||
</Form>
|
||||
</Modal>
|
||||
</template>
|
||||
|
||||
|
||||
@@ -161,6 +161,8 @@ const gridOptions: VxeGridProps<any> = {
|
||||
};
|
||||
|
||||
// 搜索表单配置
|
||||
const gridReloadRef = ref<(() => void) | null>(null);
|
||||
|
||||
const formOptions = computed(() => ({
|
||||
schema: [
|
||||
{
|
||||
@@ -169,7 +171,7 @@ const formOptions = computed(() => ({
|
||||
placeholder: '请选择店铺',
|
||||
options: shopOptions,
|
||||
allowClear: true,
|
||||
onChange: () => gridApi?.reload(),
|
||||
onChange: () => gridReloadRef.value?.(),
|
||||
},
|
||||
fieldName: 'shopId',
|
||||
label: '店铺',
|
||||
@@ -180,7 +182,7 @@ const formOptions = computed(() => ({
|
||||
placeholder: '开始月份',
|
||||
picker: 'month',
|
||||
style: { width: '100%' },
|
||||
onChange: () => gridApi?.reload(),
|
||||
onChange: () => gridReloadRef.value?.(),
|
||||
},
|
||||
fieldName: 'startTargetMonth',
|
||||
label: '目标月份',
|
||||
@@ -191,7 +193,7 @@ const formOptions = computed(() => ({
|
||||
placeholder: '结束月份',
|
||||
picker: 'month',
|
||||
style: { width: '100%' },
|
||||
onChange: () => gridApi?.reload(),
|
||||
onChange: () => gridReloadRef.value?.(),
|
||||
},
|
||||
fieldName: 'endTargetMonth',
|
||||
label: '至',
|
||||
@@ -216,6 +218,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
showSearchForm: true,
|
||||
tableTitle: '店铺月销量目标管理',
|
||||
});
|
||||
gridReloadRef.value = () => gridApi.reload();
|
||||
|
||||
// 处理新增
|
||||
const handleAdd = () => {
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
<script lang="ts" setup>
|
||||
import type { EchartsUIType } from '@vben/plugins/echarts';
|
||||
import type { VxeGridProps } from '#/adapter/vxe-table';
|
||||
|
||||
import type { VxeGridProps } from '#/adapter/vxe-table';
|
||||
import type { OrderDTO } from '#/api/ecommerce/order';
|
||||
import type { PageQueryDTO } from '#/types/common';
|
||||
import type { OrderStatusVO } from '#/api/ecommerce/order-status/types';
|
||||
import type { ShopDTO, ShopVO } from '#/api/ecommerce/shop/types';
|
||||
import type { PageQueryDTO } from '#/types/common';
|
||||
|
||||
import { computed, onActivated, onMounted, ref, watch } from 'vue';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
@@ -16,10 +17,9 @@ import { Button, DatePicker, message, Spin, Tag } from 'ant-design-vue';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { getShopOverviewStatisticsApi } from '#/api/ecommerce/shop';
|
||||
import { getOrderPageApi } from '#/api/ecommerce/order';
|
||||
import { getAllOrderStatusListApi } from '#/api/ecommerce/order-status';
|
||||
import type { OrderStatusVO } from '#/api/ecommerce/order-status/types';
|
||||
import { getShopOverviewStatisticsApi } from '#/api/ecommerce/shop';
|
||||
import { exportByPost } from '#/utils/export';
|
||||
|
||||
defineOptions({ name: 'ShopOverview' });
|
||||
@@ -517,7 +517,8 @@ const orderGridOptions: VxeGridProps<any> = {
|
||||
pageSize: page.pageSize,
|
||||
filters: {
|
||||
shopId: shopId.value,
|
||||
platformOrderNo: orderSearchForm.value.platformOrderNo || undefined,
|
||||
platformOrderNo:
|
||||
orderSearchForm.value.platformOrderNo || undefined,
|
||||
statusId: orderSearchForm.value.statusId,
|
||||
minReceivedAmount: orderSearchForm.value.minReceivedAmount,
|
||||
maxReceivedAmount: orderSearchForm.value.maxReceivedAmount,
|
||||
@@ -525,7 +526,10 @@ const orderGridOptions: VxeGridProps<any> = {
|
||||
},
|
||||
};
|
||||
// 添加排序参数
|
||||
if (orderSearchForm.value.sortField && orderSearchForm.value.sortOrder) {
|
||||
if (
|
||||
orderSearchForm.value.sortField &&
|
||||
orderSearchForm.value.sortOrder
|
||||
) {
|
||||
params.sorts = [
|
||||
{
|
||||
field: orderSearchForm.value.sortField,
|
||||
@@ -540,7 +544,11 @@ const orderGridOptions: VxeGridProps<any> = {
|
||||
};
|
||||
} catch (error: any) {
|
||||
console.error('获取订单列表失败:', error);
|
||||
message.error('获取订单列表失败: ' + (error?.message || error?.response?.data?.message || '未知错误'));
|
||||
message.error(
|
||||
`获取订单列表失败: ${
|
||||
error?.message || error?.response?.data?.message || '未知错误'
|
||||
}`,
|
||||
);
|
||||
return {
|
||||
items: [],
|
||||
total: 0,
|
||||
@@ -553,6 +561,9 @@ const orderGridOptions: VxeGridProps<any> = {
|
||||
},
|
||||
};
|
||||
|
||||
/** 避免 orderFormOptions 与 orderGridApi 循环引用导致隐式 any */
|
||||
const orderGridReloadRef = ref<(() => void) | null>(null);
|
||||
|
||||
// 订单搜索表单配置
|
||||
const orderFormOptions = computed(() => ({
|
||||
schema: [
|
||||
@@ -560,7 +571,7 @@ const orderFormOptions = computed(() => ({
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入平台订单号(回车搜索)',
|
||||
onPressEnter: () => orderGridApi?.reload(),
|
||||
onPressEnter: () => orderGridReloadRef.value?.(),
|
||||
},
|
||||
fieldName: 'platformOrderNo',
|
||||
label: '订单号',
|
||||
@@ -571,7 +582,7 @@ const orderFormOptions = computed(() => ({
|
||||
placeholder: '请选择订单状态',
|
||||
options: orderStatusOptions,
|
||||
allowClear: true,
|
||||
onChange: () => orderGridApi?.reload(),
|
||||
onChange: () => orderGridReloadRef.value?.(),
|
||||
},
|
||||
fieldName: 'statusId',
|
||||
label: '订单状态',
|
||||
@@ -582,7 +593,7 @@ const orderFormOptions = computed(() => ({
|
||||
placeholder: '最小金额',
|
||||
min: 0,
|
||||
style: { width: '100%' },
|
||||
onPressEnter: () => orderGridApi?.reload(),
|
||||
onPressEnter: () => orderGridReloadRef.value?.(),
|
||||
},
|
||||
fieldName: 'minReceivedAmount',
|
||||
label: '实收金额(起)',
|
||||
@@ -593,7 +604,7 @@ const orderFormOptions = computed(() => ({
|
||||
placeholder: '最大金额',
|
||||
min: 0,
|
||||
style: { width: '100%' },
|
||||
onPressEnter: () => orderGridApi?.reload(),
|
||||
onPressEnter: () => orderGridReloadRef.value?.(),
|
||||
},
|
||||
fieldName: 'maxReceivedAmount',
|
||||
label: '实收金额(止)',
|
||||
@@ -607,7 +618,7 @@ const orderFormOptions = computed(() => ({
|
||||
{ label: '未确认', value: 0 },
|
||||
],
|
||||
allowClear: true,
|
||||
onChange: () => orderGridApi?.reload(),
|
||||
onChange: () => orderGridReloadRef.value?.(),
|
||||
},
|
||||
fieldName: 'confirm',
|
||||
label: '确认状态',
|
||||
@@ -618,7 +629,7 @@ const orderFormOptions = computed(() => ({
|
||||
placeholder: '选择排序字段',
|
||||
options: orderSortFieldOptions,
|
||||
allowClear: true,
|
||||
onChange: () => orderGridApi?.reload(),
|
||||
onChange: () => orderGridReloadRef.value?.(),
|
||||
},
|
||||
fieldName: 'sortField',
|
||||
label: '排序字段',
|
||||
@@ -629,7 +640,7 @@ const orderFormOptions = computed(() => ({
|
||||
placeholder: '选择排序方式',
|
||||
options: orderSortOrderOptions,
|
||||
allowClear: true,
|
||||
onChange: () => orderGridApi?.reload(),
|
||||
onChange: () => orderGridReloadRef.value?.(),
|
||||
},
|
||||
fieldName: 'sortOrder',
|
||||
label: '排序方式',
|
||||
@@ -646,6 +657,7 @@ const [OrderGrid, orderGridApi] = useVbenVxeGrid({
|
||||
formOptions: orderFormOptions.value,
|
||||
showSearchForm: true,
|
||||
});
|
||||
orderGridReloadRef.value = () => orderGridApi.reload();
|
||||
|
||||
// 刷新订单列表
|
||||
function refreshOrderGrid() {
|
||||
|
||||
@@ -1,121 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
import type { FileDTO, FileVO } from '#/api/system/file/types';
|
||||
|
||||
import { ref, watch } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { Form, Input, message } from 'ant-design-vue';
|
||||
|
||||
import { updateFileApi } from '#/api/system/file';
|
||||
|
||||
defineOptions({ name: 'FileEditModal' });
|
||||
|
||||
const props = defineProps<Props>();
|
||||
|
||||
const emit = defineEmits<Emits>();
|
||||
|
||||
// Props
|
||||
interface Props {
|
||||
open: boolean;
|
||||
fileData?: FileVO.Info | null;
|
||||
}
|
||||
|
||||
// Emits
|
||||
interface Emits {
|
||||
(e: 'update:open', value: boolean): void;
|
||||
(e: 'success'): void;
|
||||
(e: 'cancel'): void;
|
||||
}
|
||||
|
||||
// 创建 vben modal
|
||||
const [Modal, modalApi] = useVbenModal({
|
||||
draggable: true,
|
||||
onCancel() {
|
||||
handleCancel();
|
||||
},
|
||||
onConfirm() {
|
||||
handleOk();
|
||||
},
|
||||
});
|
||||
|
||||
// 响应式数据
|
||||
const formRef = ref();
|
||||
const formData = ref<FileDTO.Update>({
|
||||
tags: '',
|
||||
remark: '',
|
||||
});
|
||||
|
||||
// 监听props变化
|
||||
watch(
|
||||
() => props.open,
|
||||
(newVal) => {
|
||||
if (newVal) {
|
||||
modalApi.open();
|
||||
if (props.fileData) {
|
||||
// 填充表单数据
|
||||
formData.value = {
|
||||
tags: props.fileData.tags,
|
||||
remark: props.fileData.remark,
|
||||
};
|
||||
}
|
||||
} else {
|
||||
modalApi.close();
|
||||
}
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
|
||||
// 确认操作
|
||||
const handleOk = async () => {
|
||||
try {
|
||||
await formRef.value?.validate();
|
||||
if (props.fileData?.id) {
|
||||
await updateFileApi(props.fileData.id, formData.value);
|
||||
message.success('更新成功');
|
||||
emit('success');
|
||||
modalApi.close();
|
||||
emit('update:open', false);
|
||||
}
|
||||
} catch {
|
||||
message.error('更新失败');
|
||||
}
|
||||
};
|
||||
|
||||
// 取消操作
|
||||
const handleCancel = () => {
|
||||
emit('cancel');
|
||||
modalApi.close();
|
||||
emit('update:open', false);
|
||||
// 重置表单数据
|
||||
formData.value = {
|
||||
tags: '',
|
||||
remark: '',
|
||||
};
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal title="编辑文件信息">
|
||||
<Form
|
||||
ref="formRef"
|
||||
:model="formData"
|
||||
:label-col="{ span: 6 }"
|
||||
:wrapper-col="{ span: 18 }"
|
||||
>
|
||||
<Form.Item label="标签" name="tags">
|
||||
<Input
|
||||
v-model:value="formData.tags"
|
||||
placeholder="请输入标签,多个标签用逗号分隔"
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item label="描述" name="remark">
|
||||
<Input.TextArea
|
||||
v-model:value="formData.remark"
|
||||
placeholder="请输入文件描述"
|
||||
:rows="3"
|
||||
/>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</Modal>
|
||||
</template>
|
||||
@@ -1,414 +0,0 @@
|
||||
<script lang="ts" setup>
|
||||
import type { VxeGridProps } from '#/adapter/vxe-table';
|
||||
import type { FileDTO, FileVO } from '#/api/system/file/types';
|
||||
import type { PageQueryDTO } from '#/types/common';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
import { Page } from '@vben/common-ui';
|
||||
import { createIconifyIcon } from '@vben/icons';
|
||||
|
||||
import {
|
||||
Button,
|
||||
message,
|
||||
Popconfirm,
|
||||
Space,
|
||||
Tag,
|
||||
Tooltip,
|
||||
Upload,
|
||||
} from 'ant-design-vue';
|
||||
|
||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import {
|
||||
batchUploadFilesApi,
|
||||
deleteFileApi,
|
||||
getFilePageApi,
|
||||
} from '#/api/system/file';
|
||||
|
||||
import FileEditModal from './components/FileEditModal.vue';
|
||||
|
||||
defineOptions({ name: 'FileRepository' });
|
||||
// 创建图标组件
|
||||
const UploadIcon = createIconifyIcon('lucide:upload');
|
||||
const DeleteIcon = createIconifyIcon('lucide:trash-2');
|
||||
const EditIcon = createIconifyIcon('lucide:edit');
|
||||
const DownloadIcon = createIconifyIcon('lucide:download');
|
||||
const EyeIcon = createIconifyIcon('lucide:eye');
|
||||
|
||||
// 响应式数据
|
||||
const loading = ref(false);
|
||||
const fileList = ref<FileVO.Info[]>([]);
|
||||
const total = ref(0);
|
||||
const editModalVisible = ref(false);
|
||||
const currentFileData = ref<FileVO.Info | null>(null);
|
||||
const uploadLoading = ref(false);
|
||||
|
||||
// 搜索表单
|
||||
const searchForm = ref({
|
||||
filename: '',
|
||||
fileFormat: undefined as string | undefined,
|
||||
});
|
||||
|
||||
// 文件格式选项
|
||||
const fileFormatOptions = [
|
||||
{ label: 'PDF', value: 'pdf' },
|
||||
{ label: 'CAD', value: 'cad' },
|
||||
{ label: 'Excel', value: 'xlsx' },
|
||||
{ label: 'Word', value: 'doc' },
|
||||
{ label: 'PPT', value: 'ppt' },
|
||||
{ label: '图片', value: 'jpg' },
|
||||
{ label: '视频', value: 'mp4' },
|
||||
{ label: '音频', value: 'mp3' },
|
||||
{ label: '压缩包', value: 'zip' },
|
||||
{ label: '其他', value: 'other' },
|
||||
];
|
||||
|
||||
// VbenVxeGrid 表格配置
|
||||
const gridOptions: VxeGridProps<any> = {
|
||||
columns: [
|
||||
{
|
||||
type: 'seq' as const,
|
||||
minWidth: 'auto',
|
||||
title: '序号',
|
||||
},
|
||||
{
|
||||
title: '文件名',
|
||||
minWidth: 300,
|
||||
slots: { default: 'filename' },
|
||||
},
|
||||
{
|
||||
title: '文件格式',
|
||||
minWidth: 120,
|
||||
slots: { default: 'fileFormat' },
|
||||
},
|
||||
{
|
||||
title: '标签',
|
||||
minWidth: 200,
|
||||
slots: { default: 'tags' },
|
||||
},
|
||||
{
|
||||
title: '描述',
|
||||
minWidth: 200,
|
||||
slots: { default: 'remark' },
|
||||
},
|
||||
{
|
||||
field: 'uploadTime',
|
||||
title: '上传时间',
|
||||
minWidth: 180,
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
minWidth: 200,
|
||||
fixed: 'right' as const,
|
||||
slots: { default: 'action' },
|
||||
},
|
||||
],
|
||||
height: 'auto',
|
||||
border: true,
|
||||
stripe: true,
|
||||
highlightHoverRow: true,
|
||||
showOverflow: true,
|
||||
size: 'small',
|
||||
toolbarConfig: {
|
||||
custom: true,
|
||||
refresh: true,
|
||||
zoom: true,
|
||||
},
|
||||
data: [],
|
||||
pagerConfig: {
|
||||
enabled: true,
|
||||
pageSizes: [10, 20, 50, 100],
|
||||
layouts: [
|
||||
'PrevJump',
|
||||
'PrevPage',
|
||||
'Number',
|
||||
'NextPage',
|
||||
'NextJump',
|
||||
'Sizes',
|
||||
'FullJump',
|
||||
'Total',
|
||||
] as (
|
||||
| 'FullJump'
|
||||
| 'NextJump'
|
||||
| 'NextPage'
|
||||
| 'Number'
|
||||
| 'PrevJump'
|
||||
| 'PrevPage'
|
||||
| 'Sizes'
|
||||
| 'Total'
|
||||
)[],
|
||||
},
|
||||
// 配置远程加载
|
||||
proxyConfig: {
|
||||
ajax: {
|
||||
query: async ({ page }) => {
|
||||
try {
|
||||
loading.value = true;
|
||||
const params: PageQueryDTO<FileDTO.Filters> = {
|
||||
page: page.currentPage,
|
||||
pageSize: page.pageSize,
|
||||
filters: {
|
||||
filename: searchForm.value.filename || undefined,
|
||||
fileFormat: searchForm.value.fileFormat || undefined,
|
||||
},
|
||||
};
|
||||
const response = await getFilePageApi(params);
|
||||
fileList.value = response.records;
|
||||
total.value = response.total;
|
||||
return {
|
||||
items: response.records,
|
||||
total: response.total,
|
||||
};
|
||||
} catch (error) {
|
||||
console.error('加载文件列表失败:', error);
|
||||
message.error('加载文件列表失败');
|
||||
return {
|
||||
items: [],
|
||||
total: 0,
|
||||
};
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
// 搜索表单配置
|
||||
const formOptions = computed(() => ({
|
||||
schema: [
|
||||
{
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入文件名(回车搜索)',
|
||||
onPressEnter: () => gridApi?.reload(),
|
||||
},
|
||||
fieldName: 'filename',
|
||||
label: '文件名',
|
||||
},
|
||||
{
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
placeholder: '请选择文件格式',
|
||||
options: fileFormatOptions,
|
||||
allowClear: true,
|
||||
onChange: () => gridApi?.reload(),
|
||||
},
|
||||
fieldName: 'fileFormat',
|
||||
label: '文件格式',
|
||||
},
|
||||
],
|
||||
showDefaultActions: true,
|
||||
collapsed: true,
|
||||
collapsedRows: 1,
|
||||
}));
|
||||
|
||||
// 刷新表格数据
|
||||
function refreshTable() {
|
||||
if (gridApi) {
|
||||
gridApi.reload();
|
||||
}
|
||||
}
|
||||
|
||||
const handleUpload = async (file: File) => {
|
||||
uploadLoading.value = true;
|
||||
try {
|
||||
await batchUploadFilesApi([file]);
|
||||
message.success('文件上传成功');
|
||||
refreshTable();
|
||||
} catch {
|
||||
message.error('文件上传失败');
|
||||
} finally {
|
||||
uploadLoading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
const handleBatchUpload = async (files: File[]) => {
|
||||
uploadLoading.value = true;
|
||||
try {
|
||||
await batchUploadFilesApi(files);
|
||||
message.success(`成功上传 ${files.length} 个文件`);
|
||||
refreshTable();
|
||||
} catch {
|
||||
message.error('批量上传失败');
|
||||
} finally {
|
||||
uploadLoading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
const handleEdit = (record: FileVO.Info) => {
|
||||
currentFileData.value = record;
|
||||
editModalVisible.value = true;
|
||||
};
|
||||
|
||||
const handlePreview = (record: FileVO.Info) => {
|
||||
window.open(record.accessUrl, '_blank');
|
||||
};
|
||||
|
||||
const handleDownload = (record: FileVO.Info) => {
|
||||
const link = document.createElement('a');
|
||||
link.href = record.accessUrl;
|
||||
link.download = record.filename;
|
||||
link.click();
|
||||
};
|
||||
|
||||
const handleDelete = async (id: number) => {
|
||||
try {
|
||||
await deleteFileApi(id);
|
||||
message.success('删除成功');
|
||||
refreshTable();
|
||||
} catch {
|
||||
message.error('删除失败');
|
||||
}
|
||||
};
|
||||
|
||||
const handleEditSuccess = () => {
|
||||
refreshTable();
|
||||
};
|
||||
|
||||
// 上传配置
|
||||
const uploadProps = {
|
||||
multiple: true,
|
||||
showUploadList: false,
|
||||
beforeUpload: (file: any) => {
|
||||
const isValidSize = file.size / 1024 / 1024 < 100; // 100MB
|
||||
if (!isValidSize) {
|
||||
message.error('文件大小不能超过 100MB');
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
customRequest: (options: any) => {
|
||||
const { file } = options;
|
||||
if (Array.isArray(file)) {
|
||||
handleBatchUpload(file);
|
||||
} else {
|
||||
handleUpload(file);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
// 创建 VbenVxeGrid 实例
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
gridOptions,
|
||||
formOptions: formOptions.value,
|
||||
showSearchForm: true,
|
||||
tableTitle: '文件管理',
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page title="文件仓库" auto-content-height>
|
||||
<template #description>
|
||||
<div class="text-foreground/80 mt-2">
|
||||
管理文件资源,支持文件上传、预览、下载和编辑
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<!-- VbenVxeGrid 表格 -->
|
||||
<Grid :loading="loading">
|
||||
<!-- 工具栏工具 -->
|
||||
<template #toolbar-tools>
|
||||
<Space>
|
||||
<Upload v-bind="uploadProps">
|
||||
<Button type="primary" :loading="uploadLoading">
|
||||
<UploadIcon />
|
||||
上传文件
|
||||
</Button>
|
||||
</Upload>
|
||||
</Space>
|
||||
</template>
|
||||
|
||||
<!-- 文件名列 -->
|
||||
<template #filename="{ row }: { row: any }">
|
||||
<div style="display: flex; align-items: center; gap: 8px">
|
||||
<span style="font-weight: 500">{{ row.filename }}</span>
|
||||
<Tag color="blue" size="small">{{ row.fileFormat || '未知' }}</Tag>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<!-- 文件格式列 -->
|
||||
<template #fileFormat="{ row }: { row: any }">
|
||||
<Tag color="blue">{{ row.fileFormat || '未知' }}</Tag>
|
||||
</template>
|
||||
|
||||
<!-- 标签列 -->
|
||||
<template #tags="{ row }: { row: any }">
|
||||
<div v-if="!row.tags" style="color: #999">无标签</div>
|
||||
<div v-else style="display: flex; flex-wrap: wrap; gap: 4px">
|
||||
<Tag
|
||||
v-for="tag in row.tags.split(',').filter((t: string) => t.trim())"
|
||||
:key="tag"
|
||||
color="green"
|
||||
size="small"
|
||||
>
|
||||
{{ tag.trim() }}
|
||||
</Tag>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<!-- 描述列 -->
|
||||
<template #remark="{ row }: { row: any }">
|
||||
<Tooltip v-if="row.remark" :title="row.remark">
|
||||
<span
|
||||
style="
|
||||
display: block;
|
||||
max-width: 150px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
"
|
||||
>
|
||||
{{ row.remark }}
|
||||
</span>
|
||||
</Tooltip>
|
||||
<span v-else style="color: #999">无描述</span>
|
||||
</template>
|
||||
|
||||
<!-- 操作列 -->
|
||||
<template #action="{ row }: { row: any }">
|
||||
<Space>
|
||||
<Tooltip title="预览">
|
||||
<Button type="text" size="small" @click="handlePreview(row)">
|
||||
<EyeIcon class="h-4 w-4" />
|
||||
</Button>
|
||||
</Tooltip>
|
||||
<Tooltip title="下载">
|
||||
<Button type="text" size="small" @click="handleDownload(row)">
|
||||
<DownloadIcon class="h-4 w-4" />
|
||||
</Button>
|
||||
</Tooltip>
|
||||
<Tooltip title="编辑">
|
||||
<Button type="text" size="small" @click="handleEdit(row)">
|
||||
<EditIcon class="h-4 w-4" />
|
||||
</Button>
|
||||
</Tooltip>
|
||||
<Popconfirm
|
||||
title="确定要删除这个文件吗?"
|
||||
@confirm="handleDelete(row.id)"
|
||||
>
|
||||
<Tooltip title="删除">
|
||||
<Button type="text" size="small" danger>
|
||||
<DeleteIcon class="h-4 w-4" />
|
||||
</Button>
|
||||
</Tooltip>
|
||||
</Popconfirm>
|
||||
</Space>
|
||||
</template>
|
||||
</Grid>
|
||||
|
||||
<!-- 编辑弹窗 -->
|
||||
<FileEditModal
|
||||
v-model:open="editModalVisible"
|
||||
:file-data="currentFileData"
|
||||
@success="handleEditSuccess"
|
||||
@cancel="editModalVisible = false"
|
||||
/>
|
||||
</Page>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.ant-upload-list {
|
||||
display: none;
|
||||
}
|
||||
</style>
|
||||
@@ -1,121 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
import type { ImageDTO, ImageVO } from '#/api/media/image/types';
|
||||
|
||||
import { ref, watch } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { Form, Input, message } from 'ant-design-vue';
|
||||
|
||||
import { updateImageApi } from '#/api/media/image';
|
||||
|
||||
defineOptions({ name: 'ImageEditModal' });
|
||||
|
||||
const props = defineProps<Props>();
|
||||
|
||||
const emit = defineEmits<Emits>();
|
||||
|
||||
// Props
|
||||
interface Props {
|
||||
open: boolean;
|
||||
imageData?: ImageVO.Info | null;
|
||||
}
|
||||
|
||||
// Emits
|
||||
interface Emits {
|
||||
(e: 'update:open', value: boolean): void;
|
||||
(e: 'success'): void;
|
||||
(e: 'cancel'): void;
|
||||
}
|
||||
|
||||
// 创建 vben modal
|
||||
const [Modal, modalApi] = useVbenModal({
|
||||
draggable: true,
|
||||
onCancel() {
|
||||
handleCancel();
|
||||
},
|
||||
onConfirm() {
|
||||
handleOk();
|
||||
},
|
||||
});
|
||||
|
||||
// 响应式数据
|
||||
const formRef = ref();
|
||||
const formData = ref<ImageDTO.Update>({
|
||||
tags: '',
|
||||
remark: '',
|
||||
});
|
||||
|
||||
// 监听props变化
|
||||
watch(
|
||||
() => props.open,
|
||||
(newVal) => {
|
||||
if (newVal) {
|
||||
modalApi.open();
|
||||
if (props.imageData) {
|
||||
// 填充表单数据
|
||||
formData.value = {
|
||||
tags: props.imageData.tags,
|
||||
remark: props.imageData.remark,
|
||||
};
|
||||
}
|
||||
} else {
|
||||
modalApi.close();
|
||||
}
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
|
||||
// 确认操作
|
||||
const handleOk = async () => {
|
||||
try {
|
||||
await formRef.value?.validate();
|
||||
if (props.imageData?.id) {
|
||||
await updateImageApi(props.imageData.id, formData.value);
|
||||
message.success('更新成功');
|
||||
emit('success');
|
||||
modalApi.close();
|
||||
emit('update:open', false);
|
||||
}
|
||||
} catch {
|
||||
message.error('更新失败');
|
||||
}
|
||||
};
|
||||
|
||||
// 取消操作
|
||||
const handleCancel = () => {
|
||||
emit('cancel');
|
||||
modalApi.close();
|
||||
emit('update:open', false);
|
||||
// 重置表单数据
|
||||
formData.value = {
|
||||
tags: '',
|
||||
remark: '',
|
||||
};
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal title="编辑图片信息">
|
||||
<Form
|
||||
ref="formRef"
|
||||
:model="formData"
|
||||
:label-col="{ span: 6 }"
|
||||
:wrapper-col="{ span: 18 }"
|
||||
>
|
||||
<Form.Item label="标签" name="tags">
|
||||
<Input
|
||||
v-model:value="formData.tags"
|
||||
placeholder="请输入标签,多个标签用逗号分隔"
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item label="说明" name="remark">
|
||||
<Input.TextArea
|
||||
v-model:value="formData.remark"
|
||||
placeholder="请输入图片说明"
|
||||
:rows="3"
|
||||
/>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</Modal>
|
||||
</template>
|
||||
@@ -1,234 +0,0 @@
|
||||
<script lang="ts" setup>
|
||||
import type { ImageVO } from '#/api/media/image/types';
|
||||
|
||||
import { ref } from 'vue';
|
||||
|
||||
import { Page } from '@vben/common-ui';
|
||||
import { createIconifyIcon } from '@vben/icons';
|
||||
|
||||
import { Button, Divider, Flex, message, Space, Upload } from 'ant-design-vue';
|
||||
|
||||
import {
|
||||
batchUploadImagesApi,
|
||||
deleteImageApi,
|
||||
uploadImageApi,
|
||||
} from '#/api/media/image';
|
||||
|
||||
import ImageEditModal from './components/ImageEditModal.vue';
|
||||
import ImageGridView from './views/ImageGridView/index.vue';
|
||||
import ImageListView from './views/ImageListView/index.vue';
|
||||
|
||||
defineOptions({ name: 'ImageRepository' });
|
||||
// 创建图标组件
|
||||
const UploadIcon = createIconifyIcon('lucide:upload');
|
||||
const GridIcon = createIconifyIcon('lucide:grid-3x3');
|
||||
const ListIcon = createIconifyIcon('lucide:list');
|
||||
|
||||
// 响应式数据
|
||||
const editModalVisible = ref(false);
|
||||
const currentImageData = ref<ImageVO.Info | null>(null);
|
||||
const uploadLoading = ref(false);
|
||||
const viewMode = ref<'grid' | 'list'>('grid'); // 默认使用网格视图
|
||||
|
||||
// 搜索表单
|
||||
const searchForm = ref({
|
||||
filename: '',
|
||||
category: undefined as string | undefined,
|
||||
});
|
||||
|
||||
// 图片分类选项
|
||||
const imageCategoryOptions = [
|
||||
{ label: '普通图片', value: 'image' },
|
||||
{ label: '头像', value: 'avatar' },
|
||||
{ label: 'Logo', value: 'logo' },
|
||||
];
|
||||
|
||||
// 列表视图和网格视图引用
|
||||
const imageListViewRef = ref<null | { refreshTable: () => void }>(null);
|
||||
const imageGridViewRef = ref<null | { refreshTable: () => void }>(null);
|
||||
|
||||
// 刷新表格数据
|
||||
function refreshTable() {
|
||||
if (viewMode.value === 'list' && imageListViewRef.value) {
|
||||
imageListViewRef.value.refreshTable();
|
||||
} else if (viewMode.value === 'grid' && imageGridViewRef.value) {
|
||||
imageGridViewRef.value.refreshTable();
|
||||
}
|
||||
}
|
||||
|
||||
// 处理上传
|
||||
const handleUpload = async (file: File) => {
|
||||
uploadLoading.value = true;
|
||||
try {
|
||||
await uploadImageApi(file);
|
||||
message.success('图片上传成功');
|
||||
refreshTable();
|
||||
} catch {
|
||||
message.error('图片上传失败');
|
||||
} finally {
|
||||
uploadLoading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
// 处理批量上传
|
||||
const handleBatchUpload = async (files: File[]) => {
|
||||
uploadLoading.value = true;
|
||||
try {
|
||||
await batchUploadImagesApi(files);
|
||||
message.success(`成功上传 ${files.length} 张图片`);
|
||||
refreshTable();
|
||||
} catch {
|
||||
message.error('批量上传失败');
|
||||
} finally {
|
||||
uploadLoading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
// 处理编辑
|
||||
const handleEdit = (record: ImageVO.Info) => {
|
||||
currentImageData.value = record;
|
||||
editModalVisible.value = true;
|
||||
};
|
||||
|
||||
// 处理预览
|
||||
const handlePreview = (record: ImageVO.Info) => {
|
||||
window.open(record.url, '_blank');
|
||||
};
|
||||
|
||||
// 处理下载
|
||||
const handleDownload = (record: ImageVO.Info) => {
|
||||
const link = document.createElement('a');
|
||||
link.href = record.url;
|
||||
link.download = record.filename || '未命名';
|
||||
link.click();
|
||||
};
|
||||
|
||||
// 处理删除
|
||||
const handleDelete = async (id: number) => {
|
||||
try {
|
||||
await deleteImageApi(id);
|
||||
message.success('删除成功');
|
||||
refreshTable();
|
||||
} catch {
|
||||
message.error('删除失败');
|
||||
}
|
||||
};
|
||||
|
||||
// 处理列表视图删除
|
||||
const handleListViewDelete = (id: number) => {
|
||||
handleDelete(id);
|
||||
};
|
||||
|
||||
// 处理编辑成功
|
||||
const handleEditSuccess = () => {
|
||||
refreshTable();
|
||||
};
|
||||
|
||||
// 切换视图模式
|
||||
const toggleViewMode = () => {
|
||||
viewMode.value = viewMode.value === 'grid' ? 'list' : 'grid';
|
||||
};
|
||||
|
||||
// 上传配置
|
||||
const uploadProps = {
|
||||
multiple: true,
|
||||
showUploadList: false,
|
||||
accept: 'image/*',
|
||||
beforeUpload: (file: any) => {
|
||||
const isImage = file.type.startsWith('image/');
|
||||
if (!isImage) {
|
||||
message.error('只能上传图片文件');
|
||||
return false;
|
||||
}
|
||||
const isValidSize = file.size / 1024 / 1024 < 10; // 10MB
|
||||
if (!isValidSize) {
|
||||
message.error('图片大小不能超过 10MB');
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
customRequest: (options: any) => {
|
||||
const { file } = options;
|
||||
if (Array.isArray(file)) {
|
||||
handleBatchUpload(file);
|
||||
} else {
|
||||
handleUpload(file);
|
||||
}
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page :auto-content-height="true" content-class="flex-col">
|
||||
<!-- 工具栏区域 -->
|
||||
<template #extra>
|
||||
<Flex gap="small" align="center">
|
||||
<Space>
|
||||
<Upload v-bind="uploadProps">
|
||||
<Button type="primary" :loading="uploadLoading">
|
||||
<UploadIcon class="mr-2 h-4 w-4" />
|
||||
上传图片
|
||||
</Button>
|
||||
</Upload>
|
||||
</Space>
|
||||
|
||||
<Divider type="vertical" />
|
||||
|
||||
<Space>
|
||||
<Button
|
||||
:type="viewMode === 'grid' ? 'primary' : 'default'"
|
||||
@click="toggleViewMode"
|
||||
>
|
||||
<GridIcon class="mr-2 h-4 w-4" />
|
||||
网格视图
|
||||
</Button>
|
||||
<Button
|
||||
:type="viewMode === 'list' ? 'primary' : 'default'"
|
||||
@click="toggleViewMode"
|
||||
>
|
||||
<ListIcon class="mr-2 h-4 w-4" />
|
||||
列表视图
|
||||
</Button>
|
||||
</Space>
|
||||
</Flex>
|
||||
</template>
|
||||
|
||||
<!-- 列表视图 -->
|
||||
<ImageListView
|
||||
v-if="viewMode === 'list'"
|
||||
ref="imageListViewRef"
|
||||
v-model:search-form="searchForm"
|
||||
:category-options="imageCategoryOptions"
|
||||
@edit="handleEdit"
|
||||
@delete="handleListViewDelete"
|
||||
@download="handleDownload"
|
||||
/>
|
||||
|
||||
<!-- 网格视图 -->
|
||||
<ImageGridView
|
||||
v-else
|
||||
ref="imageGridViewRef"
|
||||
v-model:search-form="searchForm"
|
||||
:category-options="imageCategoryOptions"
|
||||
:upload-loading="uploadLoading"
|
||||
@edit="handleEdit"
|
||||
@delete="handleDelete"
|
||||
@download="handleDownload"
|
||||
@preview="handlePreview"
|
||||
/>
|
||||
|
||||
<!-- 编辑弹窗 -->
|
||||
<ImageEditModal
|
||||
v-model:open="editModalVisible"
|
||||
:image-data="currentImageData"
|
||||
@success="handleEditSuccess"
|
||||
@cancel="editModalVisible = false"
|
||||
/>
|
||||
</Page>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.ant-upload-list {
|
||||
display: none;
|
||||
}
|
||||
</style>
|
||||
-178
@@ -1,178 +0,0 @@
|
||||
<script lang="ts" setup>
|
||||
import type { ImageVO } from '#/api/media/image/types';
|
||||
|
||||
import { createIconifyIcon } from '@vben/icons';
|
||||
|
||||
import { Button, Card, Image, Popconfirm, Space, Tag } from 'ant-design-vue';
|
||||
|
||||
defineProps<Props>();
|
||||
const emit = defineEmits<Emits>();
|
||||
// 创建图标组件
|
||||
const DownloadIcon = createIconifyIcon('lucide:download');
|
||||
const EditIcon = createIconifyIcon('lucide:edit');
|
||||
const TrashIcon = createIconifyIcon('lucide:trash-2');
|
||||
|
||||
interface Props {
|
||||
image: ImageVO.Info;
|
||||
}
|
||||
|
||||
interface Emits {
|
||||
(e: 'download', image: ImageVO.Info): void;
|
||||
(e: 'edit', image: ImageVO.Info): void;
|
||||
(e: 'delete', id: number): void;
|
||||
(e: 'preview', image: ImageVO.Info): void;
|
||||
}
|
||||
|
||||
const handleDownload = (image: ImageVO.Info) => {
|
||||
emit('download', image);
|
||||
};
|
||||
|
||||
const handleEdit = (image: ImageVO.Info) => {
|
||||
emit('edit', image);
|
||||
};
|
||||
|
||||
const handleDelete = (id: number) => {
|
||||
emit('delete', id);
|
||||
};
|
||||
|
||||
const getCategoryColor = (category: string | undefined) => {
|
||||
switch (category) {
|
||||
case 'avatar': {
|
||||
return 'green';
|
||||
}
|
||||
case 'image': {
|
||||
return 'blue';
|
||||
}
|
||||
case 'logo': {
|
||||
return 'purple';
|
||||
}
|
||||
default: {
|
||||
return 'default';
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const getCategoryText = (category: string | undefined) => {
|
||||
switch (category) {
|
||||
case 'avatar': {
|
||||
return '头像';
|
||||
}
|
||||
case 'image': {
|
||||
return '普通图片';
|
||||
}
|
||||
case 'logo': {
|
||||
return 'Logo';
|
||||
}
|
||||
default: {
|
||||
return '未分类';
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// 获取标签列表
|
||||
const getTagList = (tags: string | undefined) => {
|
||||
if (!tags) return [];
|
||||
return tags
|
||||
.split(',')
|
||||
.map((tag) => tag.trim())
|
||||
.filter(Boolean);
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Card
|
||||
hoverable
|
||||
:body-style="{ padding: 0 }"
|
||||
class="group border border-gray-200 transition-all duration-300 ease-out hover:-translate-y-1 hover:border-blue-500 hover:shadow-lg dark:border-gray-700"
|
||||
>
|
||||
<!-- 图片区域 -->
|
||||
<div
|
||||
class="relative cursor-pointer overflow-hidden rounded-t-lg bg-gray-100 dark:bg-neutral-800"
|
||||
>
|
||||
<Image
|
||||
:src="image.url"
|
||||
:alt="image.filename"
|
||||
class="w-full object-contain transition-transform duration-300 group-hover:scale-105"
|
||||
:preview="true"
|
||||
/>
|
||||
|
||||
<!-- 分类标签 -->
|
||||
<div class="absolute left-2 top-2">
|
||||
<Tag :color="getCategoryColor(image.category)" size="small">
|
||||
{{ getCategoryText(image.category) }}
|
||||
</Tag>
|
||||
</div>
|
||||
|
||||
<!-- 标签列表(如果有多个标签) -->
|
||||
<div
|
||||
v-if="getTagList(image.tags).length > 0"
|
||||
class="absolute right-2 top-2 flex max-w-[calc(100%-80px)] flex-wrap gap-1"
|
||||
>
|
||||
<Tag
|
||||
v-for="(tag, index) in getTagList(image.tags).slice(0, 2)"
|
||||
:key="index"
|
||||
size="small"
|
||||
color="blue"
|
||||
class="max-w-[80px] truncate"
|
||||
>
|
||||
{{ tag }}
|
||||
</Tag>
|
||||
<Tag v-if="getTagList(image.tags).length > 2" size="small" color="blue">
|
||||
+{{ getTagList(image.tags).length - 2 }}
|
||||
</Tag>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 信息区域 -->
|
||||
<div class="p-3">
|
||||
<div
|
||||
class="mb-1 truncate text-sm font-medium text-gray-900 dark:text-gray-100"
|
||||
:title="image.filename"
|
||||
>
|
||||
{{ image.filename || '未命名' }}
|
||||
</div>
|
||||
<div class="mb-3 text-xs text-gray-500 dark:text-gray-400">
|
||||
{{ image.uploadTime }}
|
||||
</div>
|
||||
|
||||
<!-- 操作按钮 -->
|
||||
<Space size="small" class="w-full justify-between">
|
||||
<Space size="small">
|
||||
<Button
|
||||
type="text"
|
||||
size="small"
|
||||
@click="handleDownload(image)"
|
||||
title="下载"
|
||||
>
|
||||
<template #icon>
|
||||
<DownloadIcon class="h-4 w-4" />
|
||||
</template>
|
||||
下载
|
||||
</Button>
|
||||
<Button
|
||||
type="text"
|
||||
size="small"
|
||||
@click="handleEdit(image)"
|
||||
title="编辑"
|
||||
>
|
||||
<template #icon>
|
||||
<EditIcon class="h-4 w-4" />
|
||||
</template>
|
||||
编辑
|
||||
</Button>
|
||||
</Space>
|
||||
<Popconfirm
|
||||
title="确定要删除这张图片吗?"
|
||||
@confirm="handleDelete(image.id)"
|
||||
>
|
||||
<Button type="text" size="small" danger title="删除">
|
||||
<template #icon>
|
||||
<TrashIcon class="h-4 w-4" />
|
||||
</template>
|
||||
删除
|
||||
</Button>
|
||||
</Popconfirm>
|
||||
</Space>
|
||||
</div>
|
||||
</Card>
|
||||
</template>
|
||||
@@ -1,317 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
import type { ImageDTO, ImageVO } from '#/api/media/image/types';
|
||||
import type { PageQueryDTO } from '#/types/common';
|
||||
|
||||
import { computed, onMounted, onUnmounted, ref, watch } from 'vue';
|
||||
import { Waterfall } from 'vue-waterfall-plugin-next';
|
||||
import 'vue-waterfall-plugin-next/dist/style.css';
|
||||
|
||||
import {
|
||||
Button,
|
||||
Card,
|
||||
Empty,
|
||||
Flex,
|
||||
Form,
|
||||
Input,
|
||||
message,
|
||||
Select,
|
||||
Space,
|
||||
Spin,
|
||||
} from 'ant-design-vue';
|
||||
|
||||
import { getImagePageApi } from '#/api/media/image';
|
||||
|
||||
import ImageCard from './components/ImageCard.vue';
|
||||
|
||||
defineOptions({ name: 'ImageGridView' });
|
||||
|
||||
const props = defineProps<{
|
||||
categoryOptions: Array<{ label: string; value: string }>;
|
||||
searchForm: {
|
||||
category?: string;
|
||||
filename: string;
|
||||
};
|
||||
uploadLoading?: boolean;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'edit', image: ImageVO.Info): void;
|
||||
(e: 'delete', id: number): void;
|
||||
(e: 'download', image: ImageVO.Info): void;
|
||||
(e: 'preview', image: ImageVO.Info): void;
|
||||
(e: 'update:searchForm', value: typeof props.searchForm): void;
|
||||
}>();
|
||||
|
||||
// 响应式数据
|
||||
const loading = ref(false);
|
||||
const imageList = ref<ImageVO.Info[]>([]);
|
||||
const total = ref(0);
|
||||
const current = ref(1);
|
||||
const pageSize = ref(24); // 无限滚动默认每页24个
|
||||
const hasMore = ref(true); // 是否还有更多数据
|
||||
const scrollContainerRef = ref<HTMLElement | null>(null);
|
||||
|
||||
// 显示列表(只包含图片数据,不包含占位项)
|
||||
const displayList = computed(() => {
|
||||
return imageList.value;
|
||||
});
|
||||
|
||||
// 本地搜索表单副本(用于 v-model)
|
||||
const localSearchForm = ref({
|
||||
filename: props.searchForm.filename,
|
||||
category: props.searchForm.category,
|
||||
});
|
||||
|
||||
// 监听 props 变化,同步到本地
|
||||
watch(
|
||||
() => props.searchForm,
|
||||
(newForm) => {
|
||||
if (
|
||||
localSearchForm.value.filename !== newForm.filename ||
|
||||
localSearchForm.value.category !== newForm.category
|
||||
) {
|
||||
localSearchForm.value.filename = newForm.filename;
|
||||
localSearchForm.value.category = newForm.category;
|
||||
// 重置分页和列表
|
||||
current.value = 1;
|
||||
imageList.value = [];
|
||||
hasMore.value = true;
|
||||
loadImageList(true);
|
||||
}
|
||||
},
|
||||
{ deep: true },
|
||||
);
|
||||
|
||||
// 监听本地表单变化,同步到父组件
|
||||
watch(
|
||||
localSearchForm,
|
||||
(newForm) => {
|
||||
if (
|
||||
props.searchForm.filename !== newForm.filename ||
|
||||
props.searchForm.category !== newForm.category
|
||||
) {
|
||||
emit('update:searchForm', { ...newForm });
|
||||
}
|
||||
},
|
||||
{ deep: true },
|
||||
);
|
||||
|
||||
// 加载图片列表
|
||||
const loadImageList = async (reset = false) => {
|
||||
if (loading.value || (!hasMore.value && !reset)) return;
|
||||
|
||||
loading.value = true;
|
||||
try {
|
||||
const params: PageQueryDTO<ImageDTO.Filters> = {
|
||||
page: current.value,
|
||||
pageSize: pageSize.value,
|
||||
filters: {
|
||||
filename: localSearchForm.value.filename || undefined,
|
||||
category: localSearchForm.value.category || undefined,
|
||||
},
|
||||
};
|
||||
|
||||
const response = await getImagePageApi(params);
|
||||
|
||||
if (reset) {
|
||||
imageList.value = response.records;
|
||||
} else {
|
||||
imageList.value.push(...response.records);
|
||||
}
|
||||
|
||||
total.value = response.total;
|
||||
|
||||
// 判断是否还有更多数据
|
||||
if (imageList.value.length >= response.total) {
|
||||
hasMore.value = false;
|
||||
} else {
|
||||
current.value++;
|
||||
hasMore.value = true;
|
||||
}
|
||||
} catch {
|
||||
message.error('加载图片列表失败');
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
// 搜索
|
||||
const handleSearch = () => {
|
||||
current.value = 1;
|
||||
imageList.value = [];
|
||||
hasMore.value = true;
|
||||
loadImageList(true);
|
||||
};
|
||||
|
||||
// 重置
|
||||
const handleReset = () => {
|
||||
localSearchForm.value.filename = '';
|
||||
localSearchForm.value.category = undefined;
|
||||
handleSearch();
|
||||
};
|
||||
|
||||
// 滚动监听
|
||||
const handleScroll = () => {
|
||||
const container = scrollContainerRef.value;
|
||||
if (!container || loading.value || !hasMore.value) return;
|
||||
|
||||
const { scrollTop, scrollHeight, clientHeight } = container;
|
||||
// 当滚动到距离底部 200px 时加载更多
|
||||
if (scrollTop + clientHeight >= scrollHeight - 200) {
|
||||
loadImageList();
|
||||
}
|
||||
};
|
||||
|
||||
// 事件处理
|
||||
const handleEdit = (image: ImageVO.Info) => {
|
||||
emit('edit', image);
|
||||
};
|
||||
|
||||
const handleDelete = (id: number) => {
|
||||
emit('delete', id);
|
||||
};
|
||||
|
||||
const handleDownload = (image: ImageVO.Info) => {
|
||||
emit('download', image);
|
||||
};
|
||||
|
||||
const handlePreview = (image: ImageVO.Info) => {
|
||||
emit('preview', image);
|
||||
};
|
||||
|
||||
// 刷新列表
|
||||
function refreshTable() {
|
||||
handleSearch();
|
||||
}
|
||||
|
||||
// 暴露方法
|
||||
defineExpose({
|
||||
refreshTable,
|
||||
});
|
||||
|
||||
// 滚动监听
|
||||
onMounted(() => {
|
||||
loadImageList(true);
|
||||
// 延迟绑定滚动事件,确保 DOM 已渲染
|
||||
setTimeout(() => {
|
||||
if (scrollContainerRef.value) {
|
||||
scrollContainerRef.value.addEventListener('scroll', handleScroll);
|
||||
}
|
||||
}, 100);
|
||||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
if (scrollContainerRef.value) {
|
||||
scrollContainerRef.value.removeEventListener('scroll', handleScroll);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex h-full flex-col">
|
||||
<!-- 搜索区域 -->
|
||||
<Card class="mb-4" :body-style="{ padding: '16px' }">
|
||||
<Form :model="localSearchForm" layout="inline" class="w-full">
|
||||
<Flex class="w-full" justify="end" align="center" gap="4">
|
||||
<Form.Item label="文件名" class="mb-0">
|
||||
<Input
|
||||
v-model:value="localSearchForm.filename"
|
||||
placeholder="请输入文件名"
|
||||
style="width: 200px"
|
||||
allow-clear
|
||||
@press-enter="handleSearch"
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item label="图片分类" class="mb-0">
|
||||
<Select
|
||||
v-model:value="localSearchForm.category"
|
||||
placeholder="请选择图片分类"
|
||||
style="width: 150px"
|
||||
allow-clear
|
||||
>
|
||||
<Select.Option
|
||||
v-for="option in categoryOptions"
|
||||
:key="option.value"
|
||||
:value="option.value"
|
||||
>
|
||||
{{ option.label }}
|
||||
</Select.Option>
|
||||
</Select>
|
||||
</Form.Item>
|
||||
<Form.Item class="mb-0">
|
||||
<Space>
|
||||
<Button type="primary" @click="handleSearch">搜索</Button>
|
||||
<Button @click="handleReset">重置</Button>
|
||||
</Space>
|
||||
</Form.Item>
|
||||
<div class="ml-auto text-sm text-gray-500 dark:text-gray-400">
|
||||
共 {{ total }} 张图片
|
||||
</div>
|
||||
</Flex>
|
||||
</Form>
|
||||
</Card>
|
||||
|
||||
<!-- 网格内容 -->
|
||||
<Card
|
||||
class="flex flex-1 flex-col overflow-y-auto"
|
||||
:body-style="{
|
||||
padding: '16px',
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
height: '100%',
|
||||
}"
|
||||
>
|
||||
<Spin :spinning="loading && imageList.length === 0">
|
||||
<!-- 空状态 -->
|
||||
<div
|
||||
v-if="!loading && imageList.length === 0"
|
||||
class="flex h-full items-center justify-center py-8"
|
||||
>
|
||||
<Empty />
|
||||
</div>
|
||||
|
||||
<!-- 瀑布流 -->
|
||||
<div ref="scrollContainerRef" class="flex-1 overflow-auto">
|
||||
<Waterfall
|
||||
v-if="imageList.length > 0"
|
||||
:list="displayList"
|
||||
row-key="id"
|
||||
:width="280"
|
||||
:breakpoints="{
|
||||
1600: { rowPerView: 5 },
|
||||
1400: { rowPerView: 4 },
|
||||
1200: { rowPerView: 4 },
|
||||
992: { rowPerView: 3 },
|
||||
768: { rowPerView: 2 },
|
||||
500: { rowPerView: 1 },
|
||||
}"
|
||||
:gutter="16"
|
||||
>
|
||||
<template #default="{ item }">
|
||||
<div class="w-full">
|
||||
<ImageCard
|
||||
:image="item"
|
||||
@download="handleDownload"
|
||||
@edit="handleEdit"
|
||||
@delete="handleDelete"
|
||||
@preview="handlePreview"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
</Waterfall>
|
||||
</div>
|
||||
|
||||
<!-- 加载更多提示 -->
|
||||
<div v-if="imageList.length > 0" class="mt-4 flex justify-center py-4">
|
||||
<Spin v-if="loading" />
|
||||
<div
|
||||
v-else-if="!hasMore"
|
||||
class="text-sm text-gray-500 dark:text-gray-400"
|
||||
>
|
||||
没有更多图片了
|
||||
</div>
|
||||
</div>
|
||||
</Spin>
|
||||
</Card>
|
||||
</div>
|
||||
</template>
|
||||
@@ -1,348 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
import type { VxeGridProps } from '#/adapter/vxe-table';
|
||||
import type { ImageDTO, ImageVO } from '#/api/media/image/types';
|
||||
import type { PageQueryDTO } from '#/types/common';
|
||||
|
||||
import { computed, ref, watch } from 'vue';
|
||||
|
||||
import { Button, Image, message, Popconfirm, Space, Tag } from 'ant-design-vue';
|
||||
|
||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { getImagePageApi } from '#/api/media/image';
|
||||
|
||||
defineOptions({ name: 'ImageListView' });
|
||||
|
||||
const props = defineProps<{
|
||||
categoryOptions: Array<{ label: string; value: string }>;
|
||||
searchForm: {
|
||||
category?: string;
|
||||
filename: string;
|
||||
};
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'edit', image: ImageVO.Info): void;
|
||||
(e: 'delete', id: number): void;
|
||||
(e: 'download', image: ImageVO.Info): void;
|
||||
(e: 'update:searchForm', value: typeof props.searchForm): void;
|
||||
}>();
|
||||
|
||||
// 响应式数据
|
||||
const loading = ref(false);
|
||||
|
||||
// 本地搜索表单副本(用于 v-model)
|
||||
const localSearchForm = ref({
|
||||
filename: props.searchForm.filename,
|
||||
category: props.searchForm.category,
|
||||
});
|
||||
|
||||
// 监听 props 变化,同步到本地
|
||||
watch(
|
||||
() => props.searchForm,
|
||||
(newForm) => {
|
||||
if (
|
||||
localSearchForm.value.filename !== newForm.filename ||
|
||||
localSearchForm.value.category !== newForm.category
|
||||
) {
|
||||
localSearchForm.value.filename = newForm.filename;
|
||||
localSearchForm.value.category = newForm.category;
|
||||
refreshTable();
|
||||
}
|
||||
},
|
||||
{ deep: true },
|
||||
);
|
||||
|
||||
// 监听本地表单变化,同步到父组件
|
||||
watch(
|
||||
localSearchForm,
|
||||
(newForm) => {
|
||||
if (
|
||||
props.searchForm.filename !== newForm.filename ||
|
||||
props.searchForm.category !== newForm.category
|
||||
) {
|
||||
emit('update:searchForm', { ...newForm });
|
||||
}
|
||||
},
|
||||
{ deep: true },
|
||||
);
|
||||
|
||||
// VbenVxeGrid 表格配置
|
||||
const gridOptions: VxeGridProps<any> = {
|
||||
columns: [
|
||||
{
|
||||
type: 'seq' as const,
|
||||
minWidth: 'auto',
|
||||
title: '序号',
|
||||
},
|
||||
{
|
||||
title: '预览',
|
||||
width: '60',
|
||||
slots: { default: 'preview' },
|
||||
},
|
||||
{
|
||||
field: 'filename',
|
||||
title: '文件名',
|
||||
minWidth: 'auto',
|
||||
showOverflow: 'tooltip' as const,
|
||||
},
|
||||
{
|
||||
title: '分类',
|
||||
minWidth: 'auto',
|
||||
slots: { default: 'category' },
|
||||
},
|
||||
{
|
||||
title: '标签',
|
||||
minWidth: 'auto',
|
||||
slots: { default: 'tags' },
|
||||
},
|
||||
{
|
||||
field: 'remark',
|
||||
title: '说明',
|
||||
minWidth: 'auto',
|
||||
showOverflow: 'tooltip' as const,
|
||||
},
|
||||
{
|
||||
field: 'uploadTime',
|
||||
title: '上传时间',
|
||||
minWidth: 'auto',
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
minWidth: 'auto',
|
||||
fixed: 'right' as const,
|
||||
slots: { default: 'action' },
|
||||
},
|
||||
],
|
||||
height: 'auto',
|
||||
border: true,
|
||||
stripe: true,
|
||||
highlightHoverRow: true,
|
||||
showOverflow: true,
|
||||
size: 'small',
|
||||
toolbarConfig: {
|
||||
custom: true,
|
||||
refresh: true,
|
||||
zoom: true,
|
||||
},
|
||||
data: [],
|
||||
pagerConfig: {
|
||||
enabled: true,
|
||||
pageSizes: [10, 20, 50, 100],
|
||||
layouts: [
|
||||
'PrevJump',
|
||||
'PrevPage',
|
||||
'Number',
|
||||
'NextPage',
|
||||
'NextJump',
|
||||
'Sizes',
|
||||
'FullJump',
|
||||
'Total',
|
||||
] as (
|
||||
| 'FullJump'
|
||||
| 'NextJump'
|
||||
| 'NextPage'
|
||||
| 'Number'
|
||||
| 'PrevJump'
|
||||
| 'PrevPage'
|
||||
| 'Sizes'
|
||||
| 'Total'
|
||||
)[],
|
||||
},
|
||||
// 配置远程加载
|
||||
proxyConfig: {
|
||||
ajax: {
|
||||
query: async ({ page }) => {
|
||||
try {
|
||||
loading.value = true;
|
||||
const params: PageQueryDTO<ImageDTO.Filters> = {
|
||||
page: page.currentPage,
|
||||
pageSize: page.pageSize,
|
||||
filters: {
|
||||
filename: localSearchForm.value.filename || undefined,
|
||||
category: localSearchForm.value.category || undefined,
|
||||
},
|
||||
};
|
||||
const data = await getImagePageApi(params);
|
||||
return {
|
||||
items: data.records,
|
||||
total: data.total,
|
||||
};
|
||||
} catch (error) {
|
||||
console.error('获取图片列表失败:', error);
|
||||
message.error('获取图片列表失败');
|
||||
return {
|
||||
items: [],
|
||||
total: 0,
|
||||
};
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
// 搜索表单配置
|
||||
const formOptions = computed(() => ({
|
||||
schema: [
|
||||
{
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入文件名(回车搜索)',
|
||||
onPressEnter: () => gridApi?.reload(),
|
||||
},
|
||||
fieldName: 'filename',
|
||||
label: '文件名',
|
||||
},
|
||||
{
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
placeholder: '请选择图片分类',
|
||||
options: props.categoryOptions,
|
||||
allowClear: true,
|
||||
onChange: () => gridApi?.reload(),
|
||||
},
|
||||
fieldName: 'category',
|
||||
label: '图片分类',
|
||||
},
|
||||
],
|
||||
showDefaultActions: true,
|
||||
collapsed: true,
|
||||
collapsedRows: 1,
|
||||
}));
|
||||
|
||||
// 刷新表格数据
|
||||
function refreshTable() {
|
||||
if (gridApi) {
|
||||
gridApi.reload();
|
||||
}
|
||||
}
|
||||
|
||||
// 创建 VbenVxeGrid 实例
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
gridOptions,
|
||||
formOptions: formOptions.value,
|
||||
showSearchForm: true,
|
||||
tableTitle: '图片管理',
|
||||
});
|
||||
|
||||
// 事件处理
|
||||
const handleEdit = (image: ImageVO.Info) => {
|
||||
emit('edit', image);
|
||||
};
|
||||
|
||||
const handleDelete = (id: number) => {
|
||||
emit('delete', id);
|
||||
};
|
||||
|
||||
const handleDownload = (image: ImageVO.Info) => {
|
||||
emit('download', image);
|
||||
};
|
||||
|
||||
// 预览功能在列表视图中直接通过 Image 组件的 preview 属性实现
|
||||
// const handlePreview = (image: ImageVO.Info) => {
|
||||
// emit('preview', image);
|
||||
// };
|
||||
|
||||
// 获取分类标签颜色
|
||||
const getCategoryColor = (category: string | undefined) => {
|
||||
switch (category) {
|
||||
case 'avatar': {
|
||||
return 'green';
|
||||
}
|
||||
case 'image': {
|
||||
return 'blue';
|
||||
}
|
||||
case 'logo': {
|
||||
return 'purple';
|
||||
}
|
||||
default: {
|
||||
return 'default';
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// 获取分类显示文本
|
||||
const getCategoryText = (category: string | undefined) => {
|
||||
switch (category) {
|
||||
case 'avatar': {
|
||||
return '头像';
|
||||
}
|
||||
case 'image': {
|
||||
return '普通图片';
|
||||
}
|
||||
case 'logo': {
|
||||
return 'Logo';
|
||||
}
|
||||
default: {
|
||||
return '未分类';
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// 获取标签列表
|
||||
const getTagList = (tags: string | undefined) => {
|
||||
if (!tags) return [];
|
||||
return tags
|
||||
.split(',')
|
||||
.map((tag) => tag.trim())
|
||||
.filter(Boolean);
|
||||
};
|
||||
|
||||
// 暴露刷新方法
|
||||
defineExpose({
|
||||
refreshTable,
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Grid :loading="loading">
|
||||
<!-- 预览列 -->
|
||||
<template #preview="{ row }: { row: any }">
|
||||
<Image
|
||||
:src="row.url"
|
||||
:alt="row.filename"
|
||||
width="40"
|
||||
height="40"
|
||||
style="object-fit: cover; border-radius: 4px"
|
||||
:preview="true"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<!-- 分类列 -->
|
||||
<template #category="{ row }: { row: any }">
|
||||
<Tag :color="getCategoryColor(row.category)">
|
||||
{{ getCategoryText(row.category) }}
|
||||
</Tag>
|
||||
</template>
|
||||
|
||||
<!-- 标签列 -->
|
||||
<template #tags="{ row }: { row: any }">
|
||||
<div v-if="row.tags" class="flex flex-wrap gap-1">
|
||||
<Tag
|
||||
v-for="tag in getTagList(row.tags)"
|
||||
:key="tag"
|
||||
size="small"
|
||||
color="blue"
|
||||
>
|
||||
{{ tag }}
|
||||
</Tag>
|
||||
</div>
|
||||
<span v-else class="text-gray-400">无标签</span>
|
||||
</template>
|
||||
|
||||
<!-- 操作列 -->
|
||||
<template #action="{ row }: { row: any }">
|
||||
<Space>
|
||||
<Button size="small" @click="handleDownload(row)"> 下载 </Button>
|
||||
<Button size="small" @click="handleEdit(row)"> 编辑 </Button>
|
||||
<Popconfirm
|
||||
title="确定要删除这张图片吗?"
|
||||
@confirm="handleDelete(row.id)"
|
||||
>
|
||||
<Button size="small" danger> 删除 </Button>
|
||||
</Popconfirm>
|
||||
</Space>
|
||||
</template>
|
||||
</Grid>
|
||||
</template>
|
||||
@@ -51,6 +51,7 @@ const statusOptions = [
|
||||
];
|
||||
|
||||
// 搜索表单配置
|
||||
const gridReloadRef = ref<(() => void) | null>(null);
|
||||
const formOptions = computed(() => ({
|
||||
schemas: [
|
||||
{
|
||||
@@ -59,7 +60,7 @@ const formOptions = computed(() => ({
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入登录账号(回车搜索)',
|
||||
onPressEnter: () => gridApi?.reload(),
|
||||
onPressEnter: () => gridReloadRef.value?.(),
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -68,7 +69,7 @@ const formOptions = computed(() => ({
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入真实姓名(回车搜索)',
|
||||
onPressEnter: () => gridApi?.reload(),
|
||||
onPressEnter: () => gridReloadRef.value?.(),
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -77,7 +78,7 @@ const formOptions = computed(() => ({
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入手机号(回车搜索)',
|
||||
onPressEnter: () => gridApi?.reload(),
|
||||
onPressEnter: () => gridReloadRef.value?.(),
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -87,7 +88,7 @@ const formOptions = computed(() => ({
|
||||
componentProps: {
|
||||
options: statusOptions,
|
||||
placeholder: '请选择状态',
|
||||
onChange: () => gridApi?.reload(),
|
||||
onChange: () => gridReloadRef.value?.(),
|
||||
},
|
||||
},
|
||||
],
|
||||
@@ -232,6 +233,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
showSearchForm: true,
|
||||
tableTitle: '超级账户管理',
|
||||
});
|
||||
gridReloadRef.value = () => gridApi.reload();
|
||||
|
||||
// 计算属性
|
||||
const hasSelected = computed(() => {
|
||||
|
||||
+12
-4
@@ -127,7 +127,7 @@ function findDepartmentPathById(
|
||||
options: DepartmentCascaderOption[],
|
||||
departmentId: number,
|
||||
currentPath: number[] = [],
|
||||
): number[] | null {
|
||||
): null | number[] {
|
||||
for (const option of options) {
|
||||
const nextPath = [...currentPath, option.value];
|
||||
if (option.value === departmentId) return nextPath;
|
||||
@@ -207,7 +207,9 @@ function handleDepartmentChange(value: number[]) {
|
||||
if (
|
||||
previousDepartmentId !== selectedDepartmentId &&
|
||||
formData.value.positionId &&
|
||||
!positionOptions.value.some((item) => item.value === formData.value.positionId)
|
||||
!positionOptions.value.some(
|
||||
(item) => item.value === formData.value.positionId,
|
||||
)
|
||||
) {
|
||||
formData.value.positionId = undefined;
|
||||
}
|
||||
@@ -279,7 +281,9 @@ watch(
|
||||
() => {
|
||||
if (
|
||||
formData.value.positionId &&
|
||||
!positionOptions.value.some((item) => item.value === formData.value.positionId)
|
||||
!positionOptions.value.some(
|
||||
(item) => item.value === formData.value.positionId,
|
||||
)
|
||||
) {
|
||||
formData.value.positionId = undefined;
|
||||
}
|
||||
@@ -345,7 +349,11 @@ defineExpose({
|
||||
:options="departmentTreeOptions"
|
||||
:loading="departmentOptionsLoading"
|
||||
placeholder="请选择所属部门"
|
||||
:field-names="{ label: 'label', value: 'value', children: 'children' }"
|
||||
:field-names="{
|
||||
label: 'label',
|
||||
value: 'value',
|
||||
children: 'children',
|
||||
}"
|
||||
change-on-select
|
||||
class="w-full"
|
||||
@change="(value) => handleDepartmentChange((value || []) as number[])"
|
||||
|
||||
@@ -48,6 +48,7 @@ const statusOptions = [
|
||||
];
|
||||
|
||||
// 搜索表单配置
|
||||
const gridReloadRef = ref<(() => void) | null>(null);
|
||||
const formOptions = computed(() => ({
|
||||
schemas: [
|
||||
{
|
||||
@@ -56,7 +57,7 @@ const formOptions = computed(() => ({
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入登录账号(回车搜索)',
|
||||
onPressEnter: () => gridApi?.reload(),
|
||||
onPressEnter: () => gridReloadRef.value?.(),
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -65,7 +66,7 @@ const formOptions = computed(() => ({
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入真实姓名(回车搜索)',
|
||||
onPressEnter: () => gridApi?.reload(),
|
||||
onPressEnter: () => gridReloadRef.value?.(),
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -74,7 +75,7 @@ const formOptions = computed(() => ({
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入手机号(回车搜索)',
|
||||
onPressEnter: () => gridApi?.reload(),
|
||||
onPressEnter: () => gridReloadRef.value?.(),
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -84,7 +85,7 @@ const formOptions = computed(() => ({
|
||||
componentProps: {
|
||||
options: statusOptions,
|
||||
placeholder: '请选择状态',
|
||||
onChange: () => gridApi?.reload(),
|
||||
onChange: () => gridReloadRef.value?.(),
|
||||
},
|
||||
},
|
||||
],
|
||||
@@ -229,6 +230,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
showSearchForm: true,
|
||||
tableTitle: '账户管理',
|
||||
});
|
||||
gridReloadRef.value = () => gridApi.reload();
|
||||
|
||||
// 计算属性
|
||||
const hasSelected = computed(() => {
|
||||
|
||||
+12
-3
@@ -416,15 +416,24 @@ onUnmounted(() => {
|
||||
name="ownerName"
|
||||
:rules="[{ required: true, message: '请输入公司拥有者姓名' }]"
|
||||
>
|
||||
<Input v-model:value="formData.ownerName" placeholder="请输入公司拥有者姓名" />
|
||||
<Input
|
||||
v-model:value="formData.ownerName"
|
||||
placeholder="请输入公司拥有者姓名"
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
label="拥有者电话"
|
||||
name="ownerPhone"
|
||||
:rules="[{ required: true, message: '请输入公司拥有者电话' }, { pattern: /^1[3-9]\d{9}$/, message: '请输入正确的手机号码' }]"
|
||||
:rules="[
|
||||
{ required: true, message: '请输入公司拥有者电话' },
|
||||
{ pattern: /^1[3-9]\d{9}$/, message: '请输入正确的手机号码' },
|
||||
]"
|
||||
>
|
||||
<Input v-model:value="formData.ownerPhone" placeholder="请输入公司拥有者电话" />
|
||||
<Input
|
||||
v-model:value="formData.ownerPhone"
|
||||
placeholder="请输入公司拥有者电话"
|
||||
/>
|
||||
</Form.Item>
|
||||
</template>
|
||||
|
||||
|
||||
@@ -195,13 +195,15 @@ const gridOptions: VxeGridProps<any> = {
|
||||
};
|
||||
|
||||
// 搜索表单配置
|
||||
const gridReloadRef = ref<(() => void) | null>(null);
|
||||
|
||||
const formOptions = computed(() => ({
|
||||
schema: [
|
||||
{
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入公司名称(回车搜索)',
|
||||
onPressEnter: () => gridApi?.reload(),
|
||||
onPressEnter: () => gridReloadRef.value?.(),
|
||||
},
|
||||
fieldName: 'name',
|
||||
label: '公司名称',
|
||||
@@ -210,7 +212,7 @@ const formOptions = computed(() => ({
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入拥有者姓名(回车搜索)',
|
||||
onPressEnter: () => gridApi?.reload(),
|
||||
onPressEnter: () => gridReloadRef.value?.(),
|
||||
},
|
||||
fieldName: 'ownerName',
|
||||
label: '拥有者姓名',
|
||||
@@ -219,7 +221,7 @@ const formOptions = computed(() => ({
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入拥有者电话(回车搜索)',
|
||||
onPressEnter: () => gridApi?.reload(),
|
||||
onPressEnter: () => gridReloadRef.value?.(),
|
||||
},
|
||||
fieldName: 'ownerPhone',
|
||||
label: '拥有者电话',
|
||||
@@ -228,7 +230,7 @@ const formOptions = computed(() => ({
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入邮箱(回车搜索)',
|
||||
onPressEnter: () => gridApi?.reload(),
|
||||
onPressEnter: () => gridReloadRef.value?.(),
|
||||
},
|
||||
fieldName: 'email',
|
||||
label: '邮箱',
|
||||
@@ -239,7 +241,7 @@ const formOptions = computed(() => ({
|
||||
placeholder: '请选择状态',
|
||||
options: statusOptions,
|
||||
allowClear: true,
|
||||
onChange: () => gridApi?.reload(),
|
||||
onChange: () => gridReloadRef.value?.(),
|
||||
},
|
||||
fieldName: 'status',
|
||||
label: '状态',
|
||||
@@ -253,7 +255,7 @@ const formOptions = computed(() => ({
|
||||
{ label: '正常', value: 'false' },
|
||||
],
|
||||
allowClear: true,
|
||||
onChange: () => gridApi?.reload(),
|
||||
onChange: () => gridReloadRef.value?.(),
|
||||
},
|
||||
fieldName: 'expired',
|
||||
label: '过期状态',
|
||||
@@ -315,6 +317,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
showSearchForm: true,
|
||||
tableTitle: '公司管理',
|
||||
});
|
||||
gridReloadRef.value = () => gridApi.reload();
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -383,7 +386,12 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
<Button size="small" type="primary" @click="handleMenuManage(row)">
|
||||
菜单
|
||||
</Button>
|
||||
<Button size="small" type="primary" ghost @click="handlePermissionManage(row)">
|
||||
<Button
|
||||
size="small"
|
||||
type="primary"
|
||||
ghost
|
||||
@click="handlePermissionManage(row)"
|
||||
>
|
||||
权限
|
||||
</Button>
|
||||
<Popconfirm
|
||||
|
||||
@@ -202,13 +202,15 @@ function findParentDepartment(
|
||||
}
|
||||
|
||||
// 搜索表单配置
|
||||
const gridReloadRef = ref<(() => void) | null>(null);
|
||||
|
||||
const formOptions = computed(() => ({
|
||||
schema: [
|
||||
{
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入部门名称(回车搜索)',
|
||||
onPressEnter: () => gridApi?.reload(),
|
||||
onPressEnter: () => gridReloadRef.value?.(),
|
||||
},
|
||||
fieldName: 'name',
|
||||
label: '部门名称',
|
||||
@@ -219,7 +221,7 @@ const formOptions = computed(() => ({
|
||||
placeholder: '请选择父部门',
|
||||
options: parentDepartmentOptions,
|
||||
allowClear: true,
|
||||
onChange: () => gridApi?.reload(),
|
||||
onChange: () => gridReloadRef.value?.(),
|
||||
},
|
||||
fieldName: 'parentId',
|
||||
label: '父部门',
|
||||
@@ -230,7 +232,7 @@ const formOptions = computed(() => ({
|
||||
placeholder: '请选择状态',
|
||||
options: statusOptions,
|
||||
allowClear: true,
|
||||
onChange: () => gridApi?.reload(),
|
||||
onChange: () => gridReloadRef.value?.(),
|
||||
},
|
||||
fieldName: 'status',
|
||||
label: '状态',
|
||||
@@ -282,6 +284,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
showSearchForm: true,
|
||||
tableTitle: '部门管理',
|
||||
});
|
||||
gridReloadRef.value = () => gridApi.reload();
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
||||
+18
-6
@@ -18,12 +18,12 @@ import {
|
||||
Tag,
|
||||
} from 'ant-design-vue';
|
||||
|
||||
import { getPositionPageApi } from '#/api/organization/position';
|
||||
import {
|
||||
batchUpdatePositionPermissionsApi,
|
||||
getAllPermissionsApi,
|
||||
getPositionPermissionIdsApi,
|
||||
} from '#/api/organization/position-permission-assign/apis';
|
||||
import { getPositionPageApi } from '#/api/organization/position';
|
||||
|
||||
defineOptions({
|
||||
name: 'PositionPermissionAssignPage',
|
||||
@@ -338,8 +338,8 @@ onMounted(() => {
|
||||
? 'text-[var(--warning)]'
|
||||
: 'text-[var(--success)]'
|
||||
"
|
||||
>{{ stats.selected }}</span
|
||||
>
|
||||
>{{ stats.selected }}
|
||||
</span>
|
||||
</span>
|
||||
<span v-if="stats.changed" class="text-[var(--warning)]">
|
||||
(有未保存的更改)
|
||||
@@ -357,10 +357,22 @@ onMounted(() => {
|
||||
class="rounded border p-3"
|
||||
>
|
||||
<div class="mb-2 text-sm font-semibold">
|
||||
{{ type === 'api' ? '接口权限' : type === 'button' ? '按钮权限' : type === 'data' ? '数据权限' : '其他权限' }}
|
||||
<Tag class="ml-2" color="blue">{{ permissions.length }}</Tag>
|
||||
{{
|
||||
type === 'api'
|
||||
? '接口权限'
|
||||
: type === 'button'
|
||||
? '按钮权限'
|
||||
: type === 'data'
|
||||
? '数据权限'
|
||||
: '其他权限'
|
||||
}}
|
||||
<Tag class="ml-2" color="blue">
|
||||
{{ permissions.length }}
|
||||
</Tag>
|
||||
</div>
|
||||
<div class="grid grid-cols-2 gap-2 lg:grid-cols-3 xl:grid-cols-4">
|
||||
<div
|
||||
class="grid grid-cols-2 gap-2 lg:grid-cols-3 xl:grid-cols-4"
|
||||
>
|
||||
<div
|
||||
v-for="perm in permissions"
|
||||
:key="perm.id"
|
||||
|
||||
+1
-4
@@ -229,10 +229,7 @@ async function savePositionPermissions() {
|
||||
try {
|
||||
// 确保提交时包含必要的父菜单ID
|
||||
const finalMenuIds = ensureParentMenuIds(checkedKeys.value);
|
||||
await batchUpdatePositionMenusApi(
|
||||
currentPosition.value.id,
|
||||
finalMenuIds,
|
||||
);
|
||||
await batchUpdatePositionMenusApi(currentPosition.value.id, finalMenuIds);
|
||||
message.success('权限配置保存成功');
|
||||
|
||||
// 重新加载权限数据
|
||||
|
||||
@@ -13,13 +13,13 @@ export default defineConfig(async () => {
|
||||
changeOrigin: true,
|
||||
rewrite: (path) => path.replace(/^\/api/, ''),
|
||||
// 后端服务地址
|
||||
target: 'http://localhost:8080',
|
||||
target: 'http://192.168.3.101:8080',
|
||||
ws: true,
|
||||
},
|
||||
// 静态资源代理 - 用于访问上传的图片和文件
|
||||
'/uploads': {
|
||||
changeOrigin: true,
|
||||
target: 'http://localhost:8080',
|
||||
target: 'http://192.168.3.101:8080',
|
||||
ws: false,
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user