fix: 修复前端 TypeScript 类型错误

- file-upload.ts: 重写上传逻辑,正确使用 files 数组和类型
- CompanyMenuDrawer/CompanyPermissionDrawer: 修复 Tree @check 事件类型
- 移除各页面未使用的导入和函数
- promotion-fee: 修复类型导出问题
- 修复 VxeGrid 配置重复和无效属性问题
This commit is contained in:
小蟑螂
2026-05-07 20:41:03 +08:00
parent ff790a7a97
commit d8da5a1b33
17 changed files with 314 additions and 100 deletions
@@ -27,11 +27,6 @@ const formatAmount = (amount: number) => {
return `¥${amount.toLocaleString('zh-CN')}`;
};
const safeNumber = (value: number | string | undefined) => {
const num = Number(value);
return Number.isFinite(num) ? num : 0;
};
// 渲染店铺销售占比排行图表
const renderShopBarChart = () => {
if (!barChartRef.value || !props.shopSalesRatios) return;
@@ -7,7 +7,7 @@ import { computed, ref } from 'vue';
import { Page } from '@vben/common-ui';
import { createIconifyIcon } from '@vben/icons';
import { Button, message, Popconfirm, Space, Tag } from 'ant-design-vue';
import { Button, message, Popconfirm, Space } from 'ant-design-vue';
import { useVbenVxeGrid } from '#/adapter/vxe-table';
import {
@@ -533,11 +533,6 @@ function handleSortChange({
gridReloadRef.value?.();
}
// 获取店铺选项(首次加载)
async function fetchShopOptions() {
await fetchShops(1, false);
}
// 获取订单状态选项
async function fetchOrderStatusOptions() {
try {
@@ -5,7 +5,7 @@ import { computed, ref } from 'vue';
import { useVbenModal } from '@vben/common-ui';
import { Form, Input, message, Select, Switch } from 'ant-design-vue';
import { Form, Input, message, Switch } from 'ant-design-vue';
import { createPlatformApi, updatePlatformApi } from '#/api/ecommerce/platform';
@@ -7,14 +7,12 @@ import { computed, ref } from 'vue';
import { Page } from '@vben/common-ui';
import { createIconifyIcon } from '@vben/icons';
import { Avatar, Button, message, Popconfirm, Space, Tag } from 'ant-design-vue';
import { Button, message, Popconfirm, Space, Tag } from 'ant-design-vue';
import { useVbenVxeGrid } from '#/adapter/vxe-table';
import {
createPlatformApi,
deletePlatformApi,
getPlatformPageApi,
updatePlatformApi,
} from '#/api/ecommerce/platform';
import PlatformFormModal from './components/PlatformFormModal.vue';
@@ -226,23 +226,12 @@ function refreshTable() {
}
}
// 重置搜索表单
function handleReset() {
searchForm.value = {
shopId: undefined,
startTargetMonth: undefined,
endTargetMonth: undefined,
};
gridReloadRef.value?.();
}
// 创建 VbenVxeGrid 实例
const [Grid, gridApi] = useVbenVxeGrid({
gridOptions,
formOptions: formOptions.value,
showSearchForm: true,
tableTitle: '店铺月销量目标管理',
handleReset,
});
gridReloadRef.value = () => gridApi.reload();
@@ -8,7 +8,6 @@ import { Page } from '@vben/common-ui';
import {
Button,
Card,
Checkbox,
Flex,
Input,
message,
@@ -135,10 +134,13 @@ async function loadCompanyMenus() {
}
// Tree勾选变化
function handleTreeCheckChange(checkedKeys: any) {
function handleTreeCheckChange(
checked: (number | string)[] | { checked: (number | string)[]; halfChecked: (number | string)[] },
) {
const checkedKeys = Array.isArray(checked) ? checked : checked.checked;
// 对比新旧值,找出被取消勾选的节点
const oldKeys = new Set(selectedMenuIds.value);
const newKeys = new Set(Array.isArray(checkedKeys) ? checkedKeys : checkedKeys);
const oldKeys = new Set<number>(selectedMenuIds.value);
const newKeys = new Set<number>(checkedKeys as number[]);
const removedKeys = [...oldKeys].filter((k) => !newKeys.has(k));
const addedKeys = [...newKeys].filter((k) => !oldKeys.has(k));
@@ -4,6 +4,7 @@ import type { PermissionVO } from '#/api/system/permission/types';
import { createIconifyIcon } from '@vben/icons';
import { Checkbox, Tag } from 'ant-design-vue';
import type { CheckboxChangeEvent } from 'ant-design-vue/es/checkbox/interface';
const ChevronDownIcon = createIconifyIcon('lucide:chevron-down');
const ChevronRightIcon = createIconifyIcon('lucide:chevron-right');
@@ -56,10 +57,18 @@ function getDescendantIds(node: PermissionVO.PermissionInfoVO): number[] {
return result;
}
function onCheckboxChange(e: Event) {
const checked = (e.target as HTMLInputElement).checked;
function onCheckboxChange(e: CheckboxChangeEvent) {
const checked = e.target.checked;
emit('check', props.node.id, checked);
}
function handleToggle(id: number) {
emit('toggle', id);
}
function handleCheck(id: number, checked: boolean) {
emit('check', id, checked);
}
</script>
<template>
@@ -111,8 +120,8 @@ function onCheckboxChange(e: Event) {
:level="level + 1"
:expanded-ids="expandedIds"
:selected-ids="selectedIds"
@toggle="(id) => emit('toggle', id)"
@check="(id, checked) => emit('check', id, checked)"
@toggle="handleToggle"
@check="handleCheck"
/>
</template>
</div>
@@ -6,7 +6,7 @@ import { computed, onMounted, ref } from 'vue';
import { Page } from '@vben/common-ui';
import { Button, Card, Checkbox, Flex, Input, message, Pagination, Select, Spin, Tag } from 'ant-design-vue';
import { Button, Card, Flex, Input, message, Pagination, Select, Spin, Tag } from 'ant-design-vue';
import { batchUpdateCompanyPermissionsApi, getCompanyPermissionIdsApi } from '#/api/organization/company-permission/apis';
import { getCompanyPageApi } from '#/api/organization/company';
@@ -223,23 +223,6 @@ function findNode(nodes: PermissionVO.PermissionInfoVO[], id: number): Permissio
return null;
}
// 节点是否全选
function isNodeChecked(node: PermissionVO.PermissionInfoVO): boolean {
if (!node.children || node.children.length === 0) {
return selectedPermissionIds.value.includes(node.id);
}
const allIds = getDescendantIds(node.id);
return allIds.length > 0 && allIds.every((id) => selectedPermissionIds.value.includes(id));
}
// 节点是否半选
function isNodeIndeterminate(node: PermissionVO.PermissionInfoVO): boolean {
if (!node.children || node.children.length === 0) return false;
const allIds = getDescendantIds(node.id);
const selectedCount = allIds.filter((id) => selectedPermissionIds.value.includes(id)).length;
return selectedCount > 0 && selectedCount < allIds.length;
}
// 展开/收起
function toggleExpand(nodeId: number) {
const newSet = new Set(expandedIds.value);
@@ -2,12 +2,12 @@
import type { VxeGridProps } from '#/adapter/vxe-table';
import type { PermissionVO } from '#/api/system/permission';
import { computed, ref } from 'vue';
import { ref } from 'vue';
import { Page } from '@vben/common-ui';
import { createIconifyIcon } from '@vben/icons';
import { Button, message, Popconfirm, Space, Tag, Spin } from 'ant-design-vue';
import { Button, message, Popconfirm, Space, Tag } from 'ant-design-vue';
import { useVbenVxeGrid } from '#/adapter/vxe-table';
import {
@@ -100,11 +100,10 @@ const gridOptions: VxeGridProps<any> = {
height: 'auto',
border: true,
stripe: true,
rowConfig: { isHover: true },
showOverflow: true,
size: 'small',
expandAll: false,
rowConfig: {
isHover: true,
drag: true,
},
rowDragConfig: {
@@ -71,7 +71,6 @@ const gridOptions: VxeGridProps<FlatNode> = {
stripe: true,
showOverflow: true,
size: 'small',
expandAll: true,
columnConfig: {
resizable: true,
},
@@ -131,16 +130,6 @@ function getTypeText(type: string) {
return map[type] || type;
}
function getTypeColor(type: string) {
const map: Record<string, string> = {
api: 'blue',
button: 'green',
data: 'orange',
module: 'purple',
};
return map[type] || 'default';
}
function getTypeTagColor(type: string) {
const map: Record<string, string> = {
api: 'processing',