From 71cec9ac6a5d4ea63967ca9bdbfe8f14fa6e621e Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sat, 30 May 2026 16:34:12 +0800 Subject: [PATCH] feat(mes): update chart options to use EChartsOption type and refactor imports --- .../src/views/mes/home/chart-options.ts | 6 +- .../src/views/mes/wm/transfer/data.ts | 4 +- .../src/views/mes/wm/transfer/index.vue | 11 +- .../wms-home-inventory-chart-options.ts | 10 +- .../wms-home-order-trend-chart-options.ts | 10 +- .../src/views/mes/home/chart-options.ts | 6 +- .../web-ele/src/views/mes/wm/transfer/data.ts | 4 +- .../src/views/mes/wm/transfer/index.vue | 225 +++++++++++++++ .../views/mes/wm/transfer/modules/form.vue | 267 ++++++++++++++++++ .../wms-home-inventory-chart-options.ts | 10 +- .../wms-home-order-trend-chart-options.ts | 10 +- packages/effects/plugins/src/echarts/index.ts | 6 +- 12 files changed, 527 insertions(+), 42 deletions(-) create mode 100644 apps/web-ele/src/views/mes/wm/transfer/index.vue create mode 100644 apps/web-ele/src/views/mes/wm/transfer/modules/form.vue diff --git a/apps/web-antd/src/views/mes/home/chart-options.ts b/apps/web-antd/src/views/mes/home/chart-options.ts index f2390563a..e83f2a8db 100644 --- a/apps/web-antd/src/views/mes/home/chart-options.ts +++ b/apps/web-antd/src/views/mes/home/chart-options.ts @@ -1,10 +1,12 @@ +import type { EChartsOption } from '@vben/plugins/echarts'; + /** 生产趋势折线图配置 */ export function getProductionTrendChartOptions( dates: string[], quantities: number[], qualified: number[], unqualified: number[], -): any { +): EChartsOption { return { grid: { bottom: 40, left: 50, right: 20, top: 20 }, legend: { bottom: 0, data: ['产量', '合格品', '不良品'] }, @@ -41,7 +43,7 @@ export function getProductionTrendChartOptions( /** 工单状态分布饼图配置 */ export function getWorkOrderStatusChartOptions( data: Array<{ itemStyle: { color: string }; name: string; value: number }>, -): any { +): EChartsOption { return { legend: { bottom: 0, type: 'scroll' }, series: [ diff --git a/apps/web-antd/src/views/mes/wm/transfer/data.ts b/apps/web-antd/src/views/mes/wm/transfer/data.ts index 41caadaec..64f3f80cd 100644 --- a/apps/web-antd/src/views/mes/wm/transfer/data.ts +++ b/apps/web-antd/src/views/mes/wm/transfer/data.ts @@ -12,12 +12,13 @@ import { getDictOptions } from '@vben/hooks'; import { Button } from 'ant-design-vue'; +import { z } from '#/adapter/form'; import { generateAutoCode } from '#/api/mes/md/autocode/record'; import { MdItemSelect } from '#/views/mes/md/item/components'; import { MesAutoCodeRuleCode, MesWmTransferTypeEnum, -} from '#/views/mes/utils/constants'; +} from '/constants'; import { WmMaterialStockSelect } from '#/views/mes/wm/materialstock/components'; import { WmWarehouseAreaSelect, @@ -130,6 +131,7 @@ export function useFormSchema( componentProps: { disabled: headerReadonly, }, + rules: z.boolean().default(false), dependencies: { triggerFields: ['type'], show: (values) => values.type === MesWmTransferTypeEnum.OUTER, diff --git a/apps/web-antd/src/views/mes/wm/transfer/index.vue b/apps/web-antd/src/views/mes/wm/transfer/index.vue index aa6fe7535..56e173ab1 100644 --- a/apps/web-antd/src/views/mes/wm/transfer/index.vue +++ b/apps/web-antd/src/views/mes/wm/transfer/index.vue @@ -15,7 +15,7 @@ import { getTransferPage, } from '#/api/mes/wm/transfer'; import { $t } from '#/locales'; -import { MesWmTransferStatusEnum } from '#/views/mes/utils/constants'; +import { MesWmTransferStatusEnum } from '/constants'; import { useGridColumns, useGridFormSchema } from './data'; import Form from './modules/form.vue'; @@ -205,11 +205,10 @@ const [Grid, gridApi] = useVbenVxeGrid({ type: 'link', danger: true, auth: ['mes:wm-transfer:update'], - ifShow: [ - MesWmTransferStatusEnum.UNCONFIRMED, - MesWmTransferStatusEnum.APPROVING, - MesWmTransferStatusEnum.APPROVED, - ].includes(row.status), + ifShow: + row.status === MesWmTransferStatusEnum.UNCONFIRMED || + row.status === MesWmTransferStatusEnum.APPROVING || + row.status === MesWmTransferStatusEnum.APPROVED, popConfirm: { title: '确认取消该转移单?取消后不可恢复。', confirm: handleCancel.bind(null, row), diff --git a/apps/web-antd/src/views/wms/home/modules/wms-home-inventory-chart-options.ts b/apps/web-antd/src/views/wms/home/modules/wms-home-inventory-chart-options.ts index ce4ac4555..bc55e5d2d 100644 --- a/apps/web-antd/src/views/wms/home/modules/wms-home-inventory-chart-options.ts +++ b/apps/web-antd/src/views/wms/home/modules/wms-home-inventory-chart-options.ts @@ -1,13 +1,9 @@ -import type { useEcharts } from '@vben/plugins/echarts'; +import type { EChartsOption } from '@vben/plugins/echarts'; import type { WmsHomeStatisticsApi } from '#/api/wms/home'; import { formatQuantity } from '#/views/wms/utils/format'; -type WmsHomeChartOption = Parameters< - ReturnType['renderEcharts'] ->[0]; - export interface InventoryChartItem { name: string; value: number; @@ -44,7 +40,7 @@ function formatGoodsLegend(name: string, goodsShareList: InventoryChartItem[]) { /** 货物占比图表配置 */ export function getGoodsShareChartOptions( goodsShareList: InventoryChartItem[], -): WmsHomeChartOption { +): EChartsOption { return { color: ['#2f7df6', '#18a058', '#f59e0b', '#7c3aed', '#14b8a6'], legend: { @@ -78,7 +74,7 @@ export function getGoodsShareChartOptions( /** 库存分布图表配置 */ export function getWarehouseDistributionChartOptions( warehouseDistributionList: InventoryChartItem[], -): WmsHomeChartOption { +): EChartsOption { const sortedList = warehouseDistributionList.toReversed(); return { color: ['#2f7df6'], diff --git a/apps/web-antd/src/views/wms/home/modules/wms-home-order-trend-chart-options.ts b/apps/web-antd/src/views/wms/home/modules/wms-home-order-trend-chart-options.ts index 47d025cee..f2b6c5832 100644 --- a/apps/web-antd/src/views/wms/home/modules/wms-home-order-trend-chart-options.ts +++ b/apps/web-antd/src/views/wms/home/modules/wms-home-order-trend-chart-options.ts @@ -1,4 +1,4 @@ -import type { useEcharts } from '@vben/plugins/echarts'; +import type { EChartsOption } from '@vben/plugins/echarts'; import type { WmsHomeStatisticsApi } from '#/api/wms/home'; @@ -6,11 +6,7 @@ import { DICT_TYPE } from '@vben/constants'; import { getDictLabel } from '@vben/hooks'; import { formatDate } from '@vben/utils'; -import { OrderTypeEnum } from '#/views/wms/utils/constants'; - -type WmsHomeChartOption = Parameters< - ReturnType['renderEcharts'] ->[0]; +import { OrderTypeEnum } from '/constants'; interface OrderDefinition { color: string; @@ -72,7 +68,7 @@ function formatTrendTime(time: number | string) { /** 单据趋势图表配置 */ export function getOrderTrendChartOptions( list: WmsHomeStatisticsApi.OrderTrend[], -): WmsHomeChartOption { +): EChartsOption { const labels = list.map((item) => formatTrendTime(item.time)); return { color: orderDefinitions.map((item) => item.color), diff --git a/apps/web-ele/src/views/mes/home/chart-options.ts b/apps/web-ele/src/views/mes/home/chart-options.ts index f2390563a..e83f2a8db 100644 --- a/apps/web-ele/src/views/mes/home/chart-options.ts +++ b/apps/web-ele/src/views/mes/home/chart-options.ts @@ -1,10 +1,12 @@ +import type { EChartsOption } from '@vben/plugins/echarts'; + /** 生产趋势折线图配置 */ export function getProductionTrendChartOptions( dates: string[], quantities: number[], qualified: number[], unqualified: number[], -): any { +): EChartsOption { return { grid: { bottom: 40, left: 50, right: 20, top: 20 }, legend: { bottom: 0, data: ['产量', '合格品', '不良品'] }, @@ -41,7 +43,7 @@ export function getProductionTrendChartOptions( /** 工单状态分布饼图配置 */ export function getWorkOrderStatusChartOptions( data: Array<{ itemStyle: { color: string }; name: string; value: number }>, -): any { +): EChartsOption { return { legend: { bottom: 0, type: 'scroll' }, series: [ diff --git a/apps/web-ele/src/views/mes/wm/transfer/data.ts b/apps/web-ele/src/views/mes/wm/transfer/data.ts index c9a0f03f4..385f8183f 100644 --- a/apps/web-ele/src/views/mes/wm/transfer/data.ts +++ b/apps/web-ele/src/views/mes/wm/transfer/data.ts @@ -12,12 +12,13 @@ import { getDictOptions } from '@vben/hooks'; import { ElButton } from 'element-plus'; +import { z } from '#/adapter/form'; import { generateAutoCode } from '#/api/mes/md/autocode/record'; import { MdItemSelect } from '#/views/mes/md/item/components'; import { MesAutoCodeRuleCode, MesWmTransferTypeEnum, -} from '#/views/mes/utils/constants'; +} from '/constants'; import { WmMaterialStockSelect } from '#/views/mes/wm/materialstock/components'; import { WmWarehouseAreaSelect, @@ -129,6 +130,7 @@ export function useFormSchema( componentProps: { disabled: headerReadonly, }, + rules: z.boolean().default(false), dependencies: { triggerFields: ['type'], show: (values) => values.type === MesWmTransferTypeEnum.OUTER, diff --git a/apps/web-ele/src/views/mes/wm/transfer/index.vue b/apps/web-ele/src/views/mes/wm/transfer/index.vue new file mode 100644 index 000000000..82d13670a --- /dev/null +++ b/apps/web-ele/src/views/mes/wm/transfer/index.vue @@ -0,0 +1,225 @@ + + + diff --git a/apps/web-ele/src/views/mes/wm/transfer/modules/form.vue b/apps/web-ele/src/views/mes/wm/transfer/modules/form.vue new file mode 100644 index 000000000..c6a972619 --- /dev/null +++ b/apps/web-ele/src/views/mes/wm/transfer/modules/form.vue @@ -0,0 +1,267 @@ + + + diff --git a/apps/web-ele/src/views/wms/home/modules/wms-home-inventory-chart-options.ts b/apps/web-ele/src/views/wms/home/modules/wms-home-inventory-chart-options.ts index ce4ac4555..bc55e5d2d 100644 --- a/apps/web-ele/src/views/wms/home/modules/wms-home-inventory-chart-options.ts +++ b/apps/web-ele/src/views/wms/home/modules/wms-home-inventory-chart-options.ts @@ -1,13 +1,9 @@ -import type { useEcharts } from '@vben/plugins/echarts'; +import type { EChartsOption } from '@vben/plugins/echarts'; import type { WmsHomeStatisticsApi } from '#/api/wms/home'; import { formatQuantity } from '#/views/wms/utils/format'; -type WmsHomeChartOption = Parameters< - ReturnType['renderEcharts'] ->[0]; - export interface InventoryChartItem { name: string; value: number; @@ -44,7 +40,7 @@ function formatGoodsLegend(name: string, goodsShareList: InventoryChartItem[]) { /** 货物占比图表配置 */ export function getGoodsShareChartOptions( goodsShareList: InventoryChartItem[], -): WmsHomeChartOption { +): EChartsOption { return { color: ['#2f7df6', '#18a058', '#f59e0b', '#7c3aed', '#14b8a6'], legend: { @@ -78,7 +74,7 @@ export function getGoodsShareChartOptions( /** 库存分布图表配置 */ export function getWarehouseDistributionChartOptions( warehouseDistributionList: InventoryChartItem[], -): WmsHomeChartOption { +): EChartsOption { const sortedList = warehouseDistributionList.toReversed(); return { color: ['#2f7df6'], diff --git a/apps/web-ele/src/views/wms/home/modules/wms-home-order-trend-chart-options.ts b/apps/web-ele/src/views/wms/home/modules/wms-home-order-trend-chart-options.ts index 47d025cee..f2b6c5832 100644 --- a/apps/web-ele/src/views/wms/home/modules/wms-home-order-trend-chart-options.ts +++ b/apps/web-ele/src/views/wms/home/modules/wms-home-order-trend-chart-options.ts @@ -1,4 +1,4 @@ -import type { useEcharts } from '@vben/plugins/echarts'; +import type { EChartsOption } from '@vben/plugins/echarts'; import type { WmsHomeStatisticsApi } from '#/api/wms/home'; @@ -6,11 +6,7 @@ import { DICT_TYPE } from '@vben/constants'; import { getDictLabel } from '@vben/hooks'; import { formatDate } from '@vben/utils'; -import { OrderTypeEnum } from '#/views/wms/utils/constants'; - -type WmsHomeChartOption = Parameters< - ReturnType['renderEcharts'] ->[0]; +import { OrderTypeEnum } from '/constants'; interface OrderDefinition { color: string; @@ -72,7 +68,7 @@ function formatTrendTime(time: number | string) { /** 单据趋势图表配置 */ export function getOrderTrendChartOptions( list: WmsHomeStatisticsApi.OrderTrend[], -): WmsHomeChartOption { +): EChartsOption { const labels = list.map((item) => formatTrendTime(item.time)); return { color: orderDefinitions.map((item) => item.color), diff --git a/packages/effects/plugins/src/echarts/index.ts b/packages/effects/plugins/src/echarts/index.ts index acb0f1e25..dbc5e2e11 100644 --- a/packages/effects/plugins/src/echarts/index.ts +++ b/packages/effects/plugins/src/echarts/index.ts @@ -1,4 +1,6 @@ -export * from './echarts'; export { default as EchartsUI } from './echarts-ui.vue'; -export * from './types'; +export type { ECOption } from './types'; export * from './use-echarts'; + +// add by 芋艿:额外透出 echarts 原生 EChartsOption 类型,方便业务模块(如 mes/home 图表配置)声明 option 返回值类型,避免业务侧直接依赖 echarts 包(apps 未把 echarts 列为直接依赖) +export type { EChartsOption } from 'echarts';