feat(wms):将首页的枚举值去掉,统一合并到 constants 里,更聚焦点
parent
84b91c6795
commit
3da4a3f417
|
|
@ -1,19 +1,45 @@
|
|||
<script lang="ts" setup>
|
||||
import type { WmsHomeStatisticsApi } from '#/api/wms/home';
|
||||
|
||||
import { ref } from 'vue';
|
||||
|
||||
import { DICT_TYPE } from '@vben/constants';
|
||||
import { getDictLabel } from '@vben/hooks';
|
||||
|
||||
import { getOrderSummary } from '#/api/wms/home';
|
||||
import { OrderStatusEnum } from '#/views/wms/utils/constants';
|
||||
import { OrderStatusEnum, OrderTypeEnum } from '#/views/wms/utils/constants';
|
||||
|
||||
defineOptions({ name: 'WmsHomeOrderSummaryCards' });
|
||||
|
||||
const orderDefinitions = [
|
||||
{ color: '#2f7df6', title: '入库', type: 1 },
|
||||
{ color: '#18a058', title: '出库', type: 2 },
|
||||
{ color: '#f59e0b', title: '移库', type: 3 },
|
||||
{ color: '#7c3aed', title: '盘库', type: 4 },
|
||||
interface OrderSummaryItem {
|
||||
color: string;
|
||||
statuses?: WmsHomeStatisticsApi.OrderStatus[];
|
||||
title: string;
|
||||
total?: number;
|
||||
type: number;
|
||||
}
|
||||
|
||||
const orderDefinitions: OrderSummaryItem[] = [
|
||||
{
|
||||
color: '#2f7df6',
|
||||
title: getDictLabel(DICT_TYPE.WMS_ORDER_TYPE, OrderTypeEnum.RECEIPT).replace(/单$/, ''),
|
||||
type: OrderTypeEnum.RECEIPT,
|
||||
},
|
||||
{
|
||||
color: '#18a058',
|
||||
title: getDictLabel(DICT_TYPE.WMS_ORDER_TYPE, OrderTypeEnum.SHIPMENT).replace(/单$/, ''),
|
||||
type: OrderTypeEnum.SHIPMENT,
|
||||
},
|
||||
{
|
||||
color: '#f59e0b',
|
||||
title: getDictLabel(DICT_TYPE.WMS_ORDER_TYPE, OrderTypeEnum.MOVEMENT).replace(/单$/, ''),
|
||||
type: OrderTypeEnum.MOVEMENT,
|
||||
},
|
||||
{
|
||||
color: '#7c3aed',
|
||||
title: getDictLabel(DICT_TYPE.WMS_ORDER_TYPE, OrderTypeEnum.CHECK).replace(/单$/, ''),
|
||||
type: OrderTypeEnum.CHECK,
|
||||
},
|
||||
];
|
||||
|
||||
const statusList = [
|
||||
|
|
@ -23,12 +49,10 @@ const statusList = [
|
|||
];
|
||||
|
||||
const loading = ref(false);
|
||||
const summaryList = ref<any[]>(
|
||||
orderDefinitions.map((item) => ({ ...item, statuses: [], total: 0 })),
|
||||
);
|
||||
const summaryList = ref<OrderSummaryItem[]>(orderDefinitions);
|
||||
|
||||
function getStatusCount(item: any, status: number) {
|
||||
return item.statuses?.find((row: any) => row.status === status)?.count || 0;
|
||||
function getStatusCount(item: OrderSummaryItem, status: number) {
|
||||
return item.statuses?.find((row) => row.status === status)?.count;
|
||||
}
|
||||
|
||||
async function load(warehouseId?: number) {
|
||||
|
|
@ -39,11 +63,8 @@ async function load(warehouseId?: number) {
|
|||
const summary = data.find((item) => item.type === definition.type);
|
||||
return {
|
||||
...definition,
|
||||
title:
|
||||
getDictLabel(DICT_TYPE.WMS_ORDER_TYPE, definition.type)?.replace(/单$/, '') ||
|
||||
definition.title,
|
||||
statuses: summary?.statuses || [],
|
||||
total: summary?.total || 0,
|
||||
statuses: summary?.statuses,
|
||||
total: summary?.total,
|
||||
};
|
||||
});
|
||||
} finally {
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@ import { DICT_TYPE } from '@vben/constants';
|
|||
import { getDictLabel } from '@vben/hooks';
|
||||
import { formatDate } from '@vben/utils';
|
||||
|
||||
import { OrderTypeEnum } from '#/views/wms/utils/constants';
|
||||
|
||||
interface OrderDefinition {
|
||||
color: string;
|
||||
title: string;
|
||||
|
|
@ -14,41 +16,28 @@ interface OrderDefinition {
|
|||
type: number;
|
||||
}
|
||||
|
||||
const OrderTypeEnum = {
|
||||
CHECK: 4,
|
||||
MOVEMENT: 3,
|
||||
RECEIPT: 1,
|
||||
SHIPMENT: 2,
|
||||
} as const;
|
||||
|
||||
/** 获取 WMS 单据类型标题,用于消除字典里的“单”后缀 */
|
||||
function getOrderTypeTitle(type: number, defaultTitle: string) {
|
||||
const label = getDictLabel(DICT_TYPE.WMS_ORDER_TYPE, type) || defaultTitle;
|
||||
return label.endsWith('单') ? label.slice(0, -1) : label;
|
||||
}
|
||||
|
||||
const orderDefinitions: OrderDefinition[] = [
|
||||
{
|
||||
color: '#2f7df6',
|
||||
title: getOrderTypeTitle(OrderTypeEnum.RECEIPT, '入库'),
|
||||
title: getDictLabel(DICT_TYPE.WMS_ORDER_TYPE, OrderTypeEnum.RECEIPT).replace(/单$/, ''),
|
||||
trendField: 'receiptCount',
|
||||
type: OrderTypeEnum.RECEIPT,
|
||||
},
|
||||
{
|
||||
color: '#18a058',
|
||||
title: getOrderTypeTitle(OrderTypeEnum.SHIPMENT, '出库'),
|
||||
title: getDictLabel(DICT_TYPE.WMS_ORDER_TYPE, OrderTypeEnum.SHIPMENT).replace(/单$/, ''),
|
||||
trendField: 'shipmentCount',
|
||||
type: OrderTypeEnum.SHIPMENT,
|
||||
},
|
||||
{
|
||||
color: '#f59e0b',
|
||||
title: getOrderTypeTitle(OrderTypeEnum.MOVEMENT, '移库'),
|
||||
title: getDictLabel(DICT_TYPE.WMS_ORDER_TYPE, OrderTypeEnum.MOVEMENT).replace(/单$/, ''),
|
||||
trendField: 'movementCount',
|
||||
type: OrderTypeEnum.MOVEMENT,
|
||||
},
|
||||
{
|
||||
color: '#7c3aed',
|
||||
title: getOrderTypeTitle(OrderTypeEnum.CHECK, '盘库'),
|
||||
title: getDictLabel(DICT_TYPE.WMS_ORDER_TYPE, OrderTypeEnum.CHECK).replace(/单$/, ''),
|
||||
trendField: 'checkCount',
|
||||
type: OrderTypeEnum.CHECK,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -5,6 +5,16 @@ export const OrderStatusEnum = {
|
|||
CANCELED: 5, // 已作废
|
||||
} as const;
|
||||
|
||||
/** 单据类型枚举 */
|
||||
export const OrderTypeEnum = {
|
||||
RECEIPT: 1, // 入库
|
||||
SHIPMENT: 2, // 出库
|
||||
MOVEMENT: 3, // 移库
|
||||
CHECK: 4, // 盘库
|
||||
} as const;
|
||||
|
||||
export type OrderType = (typeof OrderTypeEnum)[keyof typeof OrderTypeEnum];
|
||||
|
||||
/** 可修改的单据状态 */
|
||||
export const OrderUpdateStatusList: number[] = [OrderStatusEnum.PREPARE];
|
||||
|
||||
|
|
|
|||
|
|
@ -1,19 +1,45 @@
|
|||
<script lang="ts" setup>
|
||||
import type { WmsHomeStatisticsApi } from '#/api/wms/home';
|
||||
|
||||
import { ref } from 'vue';
|
||||
|
||||
import { DICT_TYPE } from '@vben/constants';
|
||||
import { getDictLabel } from '@vben/hooks';
|
||||
|
||||
import { getOrderSummary } from '#/api/wms/home';
|
||||
import { OrderStatusEnum } from '#/views/wms/utils/constants';
|
||||
import { OrderStatusEnum, OrderTypeEnum } from '#/views/wms/utils/constants';
|
||||
|
||||
defineOptions({ name: 'WmsHomeOrderSummaryCards' });
|
||||
|
||||
const orderDefinitions = [
|
||||
{ color: '#2f7df6', title: '入库', type: 1 },
|
||||
{ color: '#18a058', title: '出库', type: 2 },
|
||||
{ color: '#f59e0b', title: '移库', type: 3 },
|
||||
{ color: '#7c3aed', title: '盘库', type: 4 },
|
||||
interface OrderSummaryItem {
|
||||
color: string;
|
||||
statuses?: WmsHomeStatisticsApi.OrderStatus[];
|
||||
title: string;
|
||||
total?: number;
|
||||
type: number;
|
||||
}
|
||||
|
||||
const orderDefinitions: OrderSummaryItem[] = [
|
||||
{
|
||||
color: '#2f7df6',
|
||||
title: getDictLabel(DICT_TYPE.WMS_ORDER_TYPE, OrderTypeEnum.RECEIPT).replace(/单$/, ''),
|
||||
type: OrderTypeEnum.RECEIPT,
|
||||
},
|
||||
{
|
||||
color: '#18a058',
|
||||
title: getDictLabel(DICT_TYPE.WMS_ORDER_TYPE, OrderTypeEnum.SHIPMENT).replace(/单$/, ''),
|
||||
type: OrderTypeEnum.SHIPMENT,
|
||||
},
|
||||
{
|
||||
color: '#f59e0b',
|
||||
title: getDictLabel(DICT_TYPE.WMS_ORDER_TYPE, OrderTypeEnum.MOVEMENT).replace(/单$/, ''),
|
||||
type: OrderTypeEnum.MOVEMENT,
|
||||
},
|
||||
{
|
||||
color: '#7c3aed',
|
||||
title: getDictLabel(DICT_TYPE.WMS_ORDER_TYPE, OrderTypeEnum.CHECK).replace(/单$/, ''),
|
||||
type: OrderTypeEnum.CHECK,
|
||||
},
|
||||
];
|
||||
|
||||
const statusList = [
|
||||
|
|
@ -23,12 +49,10 @@ const statusList = [
|
|||
];
|
||||
|
||||
const loading = ref(false);
|
||||
const summaryList = ref<any[]>(
|
||||
orderDefinitions.map((item) => ({ ...item, statuses: [], total: 0 })),
|
||||
);
|
||||
const summaryList = ref<OrderSummaryItem[]>(orderDefinitions);
|
||||
|
||||
function getStatusCount(item: any, status: number) {
|
||||
return item.statuses?.find((row: any) => row.status === status)?.count || 0;
|
||||
function getStatusCount(item: OrderSummaryItem, status: number) {
|
||||
return item.statuses?.find((row) => row.status === status)?.count;
|
||||
}
|
||||
|
||||
async function load(warehouseId?: number) {
|
||||
|
|
@ -39,11 +63,8 @@ async function load(warehouseId?: number) {
|
|||
const summary = data.find((item) => item.type === definition.type);
|
||||
return {
|
||||
...definition,
|
||||
title:
|
||||
getDictLabel(DICT_TYPE.WMS_ORDER_TYPE, definition.type)?.replace(/单$/, '') ||
|
||||
definition.title,
|
||||
statuses: summary?.statuses || [],
|
||||
total: summary?.total || 0,
|
||||
statuses: summary?.statuses,
|
||||
total: summary?.total,
|
||||
};
|
||||
});
|
||||
} finally {
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@ import { DICT_TYPE } from '@vben/constants';
|
|||
import { getDictLabel } from '@vben/hooks';
|
||||
import { formatDate } from '@vben/utils';
|
||||
|
||||
import { OrderTypeEnum } from '#/views/wms/utils/constants';
|
||||
|
||||
interface OrderDefinition {
|
||||
color: string;
|
||||
title: string;
|
||||
|
|
@ -14,41 +16,28 @@ interface OrderDefinition {
|
|||
type: number;
|
||||
}
|
||||
|
||||
const OrderTypeEnum = {
|
||||
CHECK: 4,
|
||||
MOVEMENT: 3,
|
||||
RECEIPT: 1,
|
||||
SHIPMENT: 2,
|
||||
} as const;
|
||||
|
||||
/** 获取 WMS 单据类型标题,用于消除字典里的“单”后缀 */
|
||||
function getOrderTypeTitle(type: number, defaultTitle: string) {
|
||||
const label = getDictLabel(DICT_TYPE.WMS_ORDER_TYPE, type) || defaultTitle;
|
||||
return label.endsWith('单') ? label.slice(0, -1) : label;
|
||||
}
|
||||
|
||||
const orderDefinitions: OrderDefinition[] = [
|
||||
{
|
||||
color: '#2f7df6',
|
||||
title: getOrderTypeTitle(OrderTypeEnum.RECEIPT, '入库'),
|
||||
title: getDictLabel(DICT_TYPE.WMS_ORDER_TYPE, OrderTypeEnum.RECEIPT).replace(/单$/, ''),
|
||||
trendField: 'receiptCount',
|
||||
type: OrderTypeEnum.RECEIPT,
|
||||
},
|
||||
{
|
||||
color: '#18a058',
|
||||
title: getOrderTypeTitle(OrderTypeEnum.SHIPMENT, '出库'),
|
||||
title: getDictLabel(DICT_TYPE.WMS_ORDER_TYPE, OrderTypeEnum.SHIPMENT).replace(/单$/, ''),
|
||||
trendField: 'shipmentCount',
|
||||
type: OrderTypeEnum.SHIPMENT,
|
||||
},
|
||||
{
|
||||
color: '#f59e0b',
|
||||
title: getOrderTypeTitle(OrderTypeEnum.MOVEMENT, '移库'),
|
||||
title: getDictLabel(DICT_TYPE.WMS_ORDER_TYPE, OrderTypeEnum.MOVEMENT).replace(/单$/, ''),
|
||||
trendField: 'movementCount',
|
||||
type: OrderTypeEnum.MOVEMENT,
|
||||
},
|
||||
{
|
||||
color: '#7c3aed',
|
||||
title: getOrderTypeTitle(OrderTypeEnum.CHECK, '盘库'),
|
||||
title: getDictLabel(DICT_TYPE.WMS_ORDER_TYPE, OrderTypeEnum.CHECK).replace(/单$/, ''),
|
||||
trendField: 'checkCount',
|
||||
type: OrderTypeEnum.CHECK,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -5,6 +5,16 @@ export const OrderStatusEnum = {
|
|||
CANCELED: 5, // 已作废
|
||||
} as const;
|
||||
|
||||
/** 单据类型枚举 */
|
||||
export const OrderTypeEnum = {
|
||||
RECEIPT: 1, // 入库
|
||||
SHIPMENT: 2, // 出库
|
||||
MOVEMENT: 3, // 移库
|
||||
CHECK: 4, // 盘库
|
||||
} as const;
|
||||
|
||||
export type OrderType = (typeof OrderTypeEnum)[keyof typeof OrderTypeEnum];
|
||||
|
||||
/** 可修改的单据状态 */
|
||||
export const OrderUpdateStatusList: number[] = [OrderStatusEnum.PREPARE];
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue