feat(mes): update chart options to use EChartsOption type and refactor imports
parent
c8deb9e91e
commit
71cec9ac6a
|
|
@ -1,10 +1,12 @@
|
||||||
|
import type { EChartsOption } from '@vben/plugins/echarts';
|
||||||
|
|
||||||
/** 生产趋势折线图配置 */
|
/** 生产趋势折线图配置 */
|
||||||
export function getProductionTrendChartOptions(
|
export function getProductionTrendChartOptions(
|
||||||
dates: string[],
|
dates: string[],
|
||||||
quantities: number[],
|
quantities: number[],
|
||||||
qualified: number[],
|
qualified: number[],
|
||||||
unqualified: number[],
|
unqualified: number[],
|
||||||
): any {
|
): EChartsOption {
|
||||||
return {
|
return {
|
||||||
grid: { bottom: 40, left: 50, right: 20, top: 20 },
|
grid: { bottom: 40, left: 50, right: 20, top: 20 },
|
||||||
legend: { bottom: 0, data: ['产量', '合格品', '不良品'] },
|
legend: { bottom: 0, data: ['产量', '合格品', '不良品'] },
|
||||||
|
|
@ -41,7 +43,7 @@ export function getProductionTrendChartOptions(
|
||||||
/** 工单状态分布饼图配置 */
|
/** 工单状态分布饼图配置 */
|
||||||
export function getWorkOrderStatusChartOptions(
|
export function getWorkOrderStatusChartOptions(
|
||||||
data: Array<{ itemStyle: { color: string }; name: string; value: number }>,
|
data: Array<{ itemStyle: { color: string }; name: string; value: number }>,
|
||||||
): any {
|
): EChartsOption {
|
||||||
return {
|
return {
|
||||||
legend: { bottom: 0, type: 'scroll' },
|
legend: { bottom: 0, type: 'scroll' },
|
||||||
series: [
|
series: [
|
||||||
|
|
|
||||||
|
|
@ -12,12 +12,13 @@ import { getDictOptions } from '@vben/hooks';
|
||||||
|
|
||||||
import { Button } from 'ant-design-vue';
|
import { Button } from 'ant-design-vue';
|
||||||
|
|
||||||
|
import { z } from '#/adapter/form';
|
||||||
import { generateAutoCode } from '#/api/mes/md/autocode/record';
|
import { generateAutoCode } from '#/api/mes/md/autocode/record';
|
||||||
import { MdItemSelect } from '#/views/mes/md/item/components';
|
import { MdItemSelect } from '#/views/mes/md/item/components';
|
||||||
import {
|
import {
|
||||||
MesAutoCodeRuleCode,
|
MesAutoCodeRuleCode,
|
||||||
MesWmTransferTypeEnum,
|
MesWmTransferTypeEnum,
|
||||||
} from '#/views/mes/utils/constants';
|
} from '/constants';
|
||||||
import { WmMaterialStockSelect } from '#/views/mes/wm/materialstock/components';
|
import { WmMaterialStockSelect } from '#/views/mes/wm/materialstock/components';
|
||||||
import {
|
import {
|
||||||
WmWarehouseAreaSelect,
|
WmWarehouseAreaSelect,
|
||||||
|
|
@ -130,6 +131,7 @@ export function useFormSchema(
|
||||||
componentProps: {
|
componentProps: {
|
||||||
disabled: headerReadonly,
|
disabled: headerReadonly,
|
||||||
},
|
},
|
||||||
|
rules: z.boolean().default(false),
|
||||||
dependencies: {
|
dependencies: {
|
||||||
triggerFields: ['type'],
|
triggerFields: ['type'],
|
||||||
show: (values) => values.type === MesWmTransferTypeEnum.OUTER,
|
show: (values) => values.type === MesWmTransferTypeEnum.OUTER,
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ import {
|
||||||
getTransferPage,
|
getTransferPage,
|
||||||
} from '#/api/mes/wm/transfer';
|
} from '#/api/mes/wm/transfer';
|
||||||
import { $t } from '#/locales';
|
import { $t } from '#/locales';
|
||||||
import { MesWmTransferStatusEnum } from '#/views/mes/utils/constants';
|
import { MesWmTransferStatusEnum } from '/constants';
|
||||||
|
|
||||||
import { useGridColumns, useGridFormSchema } from './data';
|
import { useGridColumns, useGridFormSchema } from './data';
|
||||||
import Form from './modules/form.vue';
|
import Form from './modules/form.vue';
|
||||||
|
|
@ -205,11 +205,10 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||||
type: 'link',
|
type: 'link',
|
||||||
danger: true,
|
danger: true,
|
||||||
auth: ['mes:wm-transfer:update'],
|
auth: ['mes:wm-transfer:update'],
|
||||||
ifShow: [
|
ifShow:
|
||||||
MesWmTransferStatusEnum.UNCONFIRMED,
|
row.status === MesWmTransferStatusEnum.UNCONFIRMED ||
|
||||||
MesWmTransferStatusEnum.APPROVING,
|
row.status === MesWmTransferStatusEnum.APPROVING ||
|
||||||
MesWmTransferStatusEnum.APPROVED,
|
row.status === MesWmTransferStatusEnum.APPROVED,
|
||||||
].includes(row.status),
|
|
||||||
popConfirm: {
|
popConfirm: {
|
||||||
title: '确认取消该转移单?取消后不可恢复。',
|
title: '确认取消该转移单?取消后不可恢复。',
|
||||||
confirm: handleCancel.bind(null, row),
|
confirm: handleCancel.bind(null, row),
|
||||||
|
|
|
||||||
|
|
@ -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 type { WmsHomeStatisticsApi } from '#/api/wms/home';
|
||||||
|
|
||||||
import { formatQuantity } from '#/views/wms/utils/format';
|
import { formatQuantity } from '#/views/wms/utils/format';
|
||||||
|
|
||||||
type WmsHomeChartOption = Parameters<
|
|
||||||
ReturnType<typeof useEcharts>['renderEcharts']
|
|
||||||
>[0];
|
|
||||||
|
|
||||||
export interface InventoryChartItem {
|
export interface InventoryChartItem {
|
||||||
name: string;
|
name: string;
|
||||||
value: number;
|
value: number;
|
||||||
|
|
@ -44,7 +40,7 @@ function formatGoodsLegend(name: string, goodsShareList: InventoryChartItem[]) {
|
||||||
/** 货物占比图表配置 */
|
/** 货物占比图表配置 */
|
||||||
export function getGoodsShareChartOptions(
|
export function getGoodsShareChartOptions(
|
||||||
goodsShareList: InventoryChartItem[],
|
goodsShareList: InventoryChartItem[],
|
||||||
): WmsHomeChartOption {
|
): EChartsOption {
|
||||||
return {
|
return {
|
||||||
color: ['#2f7df6', '#18a058', '#f59e0b', '#7c3aed', '#14b8a6'],
|
color: ['#2f7df6', '#18a058', '#f59e0b', '#7c3aed', '#14b8a6'],
|
||||||
legend: {
|
legend: {
|
||||||
|
|
@ -78,7 +74,7 @@ export function getGoodsShareChartOptions(
|
||||||
/** 库存分布图表配置 */
|
/** 库存分布图表配置 */
|
||||||
export function getWarehouseDistributionChartOptions(
|
export function getWarehouseDistributionChartOptions(
|
||||||
warehouseDistributionList: InventoryChartItem[],
|
warehouseDistributionList: InventoryChartItem[],
|
||||||
): WmsHomeChartOption {
|
): EChartsOption {
|
||||||
const sortedList = warehouseDistributionList.toReversed();
|
const sortedList = warehouseDistributionList.toReversed();
|
||||||
return {
|
return {
|
||||||
color: ['#2f7df6'],
|
color: ['#2f7df6'],
|
||||||
|
|
|
||||||
|
|
@ -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';
|
import type { WmsHomeStatisticsApi } from '#/api/wms/home';
|
||||||
|
|
||||||
|
|
@ -6,11 +6,7 @@ import { DICT_TYPE } from '@vben/constants';
|
||||||
import { getDictLabel } from '@vben/hooks';
|
import { getDictLabel } from '@vben/hooks';
|
||||||
import { formatDate } from '@vben/utils';
|
import { formatDate } from '@vben/utils';
|
||||||
|
|
||||||
import { OrderTypeEnum } from '#/views/wms/utils/constants';
|
import { OrderTypeEnum } from '/constants';
|
||||||
|
|
||||||
type WmsHomeChartOption = Parameters<
|
|
||||||
ReturnType<typeof useEcharts>['renderEcharts']
|
|
||||||
>[0];
|
|
||||||
|
|
||||||
interface OrderDefinition {
|
interface OrderDefinition {
|
||||||
color: string;
|
color: string;
|
||||||
|
|
@ -72,7 +68,7 @@ function formatTrendTime(time: number | string) {
|
||||||
/** 单据趋势图表配置 */
|
/** 单据趋势图表配置 */
|
||||||
export function getOrderTrendChartOptions(
|
export function getOrderTrendChartOptions(
|
||||||
list: WmsHomeStatisticsApi.OrderTrend[],
|
list: WmsHomeStatisticsApi.OrderTrend[],
|
||||||
): WmsHomeChartOption {
|
): EChartsOption {
|
||||||
const labels = list.map((item) => formatTrendTime(item.time));
|
const labels = list.map((item) => formatTrendTime(item.time));
|
||||||
return {
|
return {
|
||||||
color: orderDefinitions.map((item) => item.color),
|
color: orderDefinitions.map((item) => item.color),
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,12 @@
|
||||||
|
import type { EChartsOption } from '@vben/plugins/echarts';
|
||||||
|
|
||||||
/** 生产趋势折线图配置 */
|
/** 生产趋势折线图配置 */
|
||||||
export function getProductionTrendChartOptions(
|
export function getProductionTrendChartOptions(
|
||||||
dates: string[],
|
dates: string[],
|
||||||
quantities: number[],
|
quantities: number[],
|
||||||
qualified: number[],
|
qualified: number[],
|
||||||
unqualified: number[],
|
unqualified: number[],
|
||||||
): any {
|
): EChartsOption {
|
||||||
return {
|
return {
|
||||||
grid: { bottom: 40, left: 50, right: 20, top: 20 },
|
grid: { bottom: 40, left: 50, right: 20, top: 20 },
|
||||||
legend: { bottom: 0, data: ['产量', '合格品', '不良品'] },
|
legend: { bottom: 0, data: ['产量', '合格品', '不良品'] },
|
||||||
|
|
@ -41,7 +43,7 @@ export function getProductionTrendChartOptions(
|
||||||
/** 工单状态分布饼图配置 */
|
/** 工单状态分布饼图配置 */
|
||||||
export function getWorkOrderStatusChartOptions(
|
export function getWorkOrderStatusChartOptions(
|
||||||
data: Array<{ itemStyle: { color: string }; name: string; value: number }>,
|
data: Array<{ itemStyle: { color: string }; name: string; value: number }>,
|
||||||
): any {
|
): EChartsOption {
|
||||||
return {
|
return {
|
||||||
legend: { bottom: 0, type: 'scroll' },
|
legend: { bottom: 0, type: 'scroll' },
|
||||||
series: [
|
series: [
|
||||||
|
|
|
||||||
|
|
@ -12,12 +12,13 @@ import { getDictOptions } from '@vben/hooks';
|
||||||
|
|
||||||
import { ElButton } from 'element-plus';
|
import { ElButton } from 'element-plus';
|
||||||
|
|
||||||
|
import { z } from '#/adapter/form';
|
||||||
import { generateAutoCode } from '#/api/mes/md/autocode/record';
|
import { generateAutoCode } from '#/api/mes/md/autocode/record';
|
||||||
import { MdItemSelect } from '#/views/mes/md/item/components';
|
import { MdItemSelect } from '#/views/mes/md/item/components';
|
||||||
import {
|
import {
|
||||||
MesAutoCodeRuleCode,
|
MesAutoCodeRuleCode,
|
||||||
MesWmTransferTypeEnum,
|
MesWmTransferTypeEnum,
|
||||||
} from '#/views/mes/utils/constants';
|
} from '/constants';
|
||||||
import { WmMaterialStockSelect } from '#/views/mes/wm/materialstock/components';
|
import { WmMaterialStockSelect } from '#/views/mes/wm/materialstock/components';
|
||||||
import {
|
import {
|
||||||
WmWarehouseAreaSelect,
|
WmWarehouseAreaSelect,
|
||||||
|
|
@ -129,6 +130,7 @@ export function useFormSchema(
|
||||||
componentProps: {
|
componentProps: {
|
||||||
disabled: headerReadonly,
|
disabled: headerReadonly,
|
||||||
},
|
},
|
||||||
|
rules: z.boolean().default(false),
|
||||||
dependencies: {
|
dependencies: {
|
||||||
triggerFields: ['type'],
|
triggerFields: ['type'],
|
||||||
show: (values) => values.type === MesWmTransferTypeEnum.OUTER,
|
show: (values) => values.type === MesWmTransferTypeEnum.OUTER,
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,225 @@
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||||
|
import type { MesWmTransferApi } from '#/api/mes/wm/transfer';
|
||||||
|
|
||||||
|
import { DocAlert, Page, useVbenModal } from '@vben/common-ui';
|
||||||
|
import { downloadFileFromBlobPart } from '@vben/utils';
|
||||||
|
|
||||||
|
import { ElButton, ElLoading, ElMessage } from 'element-plus';
|
||||||
|
|
||||||
|
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||||
|
import {
|
||||||
|
cancelTransfer,
|
||||||
|
deleteTransfer,
|
||||||
|
exportTransfer,
|
||||||
|
getTransferPage,
|
||||||
|
} from '#/api/mes/wm/transfer';
|
||||||
|
import { $t } from '#/locales';
|
||||||
|
import { MesWmTransferStatusEnum } from '/constants';
|
||||||
|
|
||||||
|
import { useGridColumns, useGridFormSchema } from './data';
|
||||||
|
import Form from './modules/form.vue';
|
||||||
|
|
||||||
|
const [FormModal, formModalApi] = useVbenModal({
|
||||||
|
connectedComponent: Form,
|
||||||
|
destroyOnClose: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
/** 刷新表格 */
|
||||||
|
function handleRefresh() {
|
||||||
|
gridApi.query();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 创建转移单 */
|
||||||
|
function handleCreate() {
|
||||||
|
formModalApi.setData({ formType: 'create' }).open();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 查看转移单详情 */
|
||||||
|
function handleDetail(row: MesWmTransferApi.Transfer) {
|
||||||
|
formModalApi.setData({ formType: 'detail', id: row.id }).open();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 编辑转移单 */
|
||||||
|
function handleEdit(row: MesWmTransferApi.Transfer) {
|
||||||
|
formModalApi.setData({ formType: 'update', id: row.id }).open();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 到货确认 */
|
||||||
|
function handleConfirm(row: MesWmTransferApi.Transfer) {
|
||||||
|
formModalApi.setData({ formType: 'confirm', id: row.id }).open();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 执行上架 */
|
||||||
|
function handleStock(row: MesWmTransferApi.Transfer) {
|
||||||
|
formModalApi.setData({ formType: 'stock', id: row.id }).open();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 执行转移 */
|
||||||
|
function handleFinish(row: MesWmTransferApi.Transfer) {
|
||||||
|
formModalApi.setData({ formType: 'finish', id: row.id }).open();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 删除转移单 */
|
||||||
|
async function handleDelete(row: MesWmTransferApi.Transfer) {
|
||||||
|
const loadingInstance = ElLoading.service({
|
||||||
|
text: $t('ui.actionMessage.deleting', [row.code]),
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
await deleteTransfer(row.id!);
|
||||||
|
ElMessage.success($t('ui.actionMessage.deleteSuccess', [row.code]));
|
||||||
|
handleRefresh();
|
||||||
|
} finally {
|
||||||
|
loadingInstance.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 取消转移单 */
|
||||||
|
async function handleCancel(row: MesWmTransferApi.Transfer) {
|
||||||
|
await cancelTransfer(row.id!);
|
||||||
|
ElMessage.success('取消成功');
|
||||||
|
handleRefresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 导出表格 */
|
||||||
|
async function handleExport() {
|
||||||
|
const data = await exportTransfer(await gridApi.formApi.getValues());
|
||||||
|
downloadFileFromBlobPart({ fileName: '转移单.xls', source: data });
|
||||||
|
}
|
||||||
|
|
||||||
|
const [Grid, gridApi] = useVbenVxeGrid({
|
||||||
|
formOptions: {
|
||||||
|
schema: useGridFormSchema(),
|
||||||
|
},
|
||||||
|
gridOptions: {
|
||||||
|
columns: useGridColumns(),
|
||||||
|
height: 'auto',
|
||||||
|
keepSource: true,
|
||||||
|
proxyConfig: {
|
||||||
|
ajax: {
|
||||||
|
query: async ({ page }, formValues) => {
|
||||||
|
return await getTransferPage({
|
||||||
|
pageNo: page.currentPage,
|
||||||
|
pageSize: page.pageSize,
|
||||||
|
...formValues,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
rowConfig: {
|
||||||
|
keyField: 'id',
|
||||||
|
isHover: true,
|
||||||
|
},
|
||||||
|
toolbarConfig: {
|
||||||
|
refresh: true,
|
||||||
|
search: true,
|
||||||
|
},
|
||||||
|
} as VxeTableGridOptions<MesWmTransferApi.Transfer>,
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Page auto-content-height>
|
||||||
|
<template #doc>
|
||||||
|
<DocAlert
|
||||||
|
title="【仓库】调拨单、装箱管理"
|
||||||
|
url="https://doc.iocoder.cn/mes/wm/transfer/"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<FormModal @success="handleRefresh" />
|
||||||
|
|
||||||
|
<Grid table-title="转移单列表">
|
||||||
|
<template #toolbar-tools>
|
||||||
|
<TableAction
|
||||||
|
:actions="[
|
||||||
|
{
|
||||||
|
label: $t('ui.actionTitle.create', ['转移单']),
|
||||||
|
type: 'primary',
|
||||||
|
icon: ACTION_ICON.ADD,
|
||||||
|
auth: ['mes:wm-transfer:create'],
|
||||||
|
onClick: handleCreate,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: $t('ui.actionTitle.export'),
|
||||||
|
type: 'primary',
|
||||||
|
icon: ACTION_ICON.DOWNLOAD,
|
||||||
|
auth: ['mes:wm-transfer:export'],
|
||||||
|
onClick: handleExport,
|
||||||
|
},
|
||||||
|
]"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
<template #code="{ row }">
|
||||||
|
<ElButton link type="primary" @click="handleDetail(row)">
|
||||||
|
{{ row.code }}
|
||||||
|
</ElButton>
|
||||||
|
</template>
|
||||||
|
<template #actions="{ row }">
|
||||||
|
<TableAction
|
||||||
|
:actions="[
|
||||||
|
{
|
||||||
|
label: $t('common.edit'),
|
||||||
|
type: 'primary',
|
||||||
|
link: true,
|
||||||
|
icon: ACTION_ICON.EDIT,
|
||||||
|
auth: ['mes:wm-transfer:update'],
|
||||||
|
ifShow: row.status === MesWmTransferStatusEnum.PREPARE,
|
||||||
|
onClick: handleEdit.bind(null, row),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: $t('common.delete'),
|
||||||
|
type: 'danger',
|
||||||
|
link: true,
|
||||||
|
icon: ACTION_ICON.DELETE,
|
||||||
|
auth: ['mes:wm-transfer:delete'],
|
||||||
|
ifShow: row.status === MesWmTransferStatusEnum.PREPARE,
|
||||||
|
popConfirm: {
|
||||||
|
title: $t('ui.actionMessage.deleteConfirm', [row.code]),
|
||||||
|
confirm: handleDelete.bind(null, row),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '到货确认',
|
||||||
|
type: 'primary',
|
||||||
|
link: true,
|
||||||
|
auth: ['mes:wm-transfer:update'],
|
||||||
|
ifShow: row.status === MesWmTransferStatusEnum.UNCONFIRMED,
|
||||||
|
onClick: handleConfirm.bind(null, row),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '执行上架',
|
||||||
|
type: 'primary',
|
||||||
|
link: true,
|
||||||
|
auth: ['mes:wm-transfer:update'],
|
||||||
|
ifShow: row.status === MesWmTransferStatusEnum.APPROVING,
|
||||||
|
onClick: handleStock.bind(null, row),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '执行转移',
|
||||||
|
type: 'primary',
|
||||||
|
link: true,
|
||||||
|
auth: ['mes:wm-transfer:finish'],
|
||||||
|
ifShow: row.status === MesWmTransferStatusEnum.APPROVED,
|
||||||
|
onClick: handleFinish.bind(null, row),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '取消',
|
||||||
|
type: 'danger',
|
||||||
|
link: true,
|
||||||
|
auth: ['mes:wm-transfer:update'],
|
||||||
|
ifShow:
|
||||||
|
row.status === MesWmTransferStatusEnum.UNCONFIRMED ||
|
||||||
|
row.status === MesWmTransferStatusEnum.APPROVING ||
|
||||||
|
row.status === MesWmTransferStatusEnum.APPROVED,
|
||||||
|
popConfirm: {
|
||||||
|
title: '确认取消该转移单?取消后不可恢复。',
|
||||||
|
confirm: handleCancel.bind(null, row),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</Grid>
|
||||||
|
</Page>
|
||||||
|
</template>
|
||||||
|
|
@ -0,0 +1,267 @@
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import type { FormType } from '../data';
|
||||||
|
|
||||||
|
import type { MesWmTransferApi } from '#/api/mes/wm/transfer';
|
||||||
|
|
||||||
|
import { computed, ref } from 'vue';
|
||||||
|
|
||||||
|
import { useVbenModal } from '@vben/common-ui';
|
||||||
|
|
||||||
|
import { ElButton, ElDivider, ElMessage, ElPopconfirm } from 'element-plus';
|
||||||
|
|
||||||
|
import { useVbenForm } from '#/adapter/form';
|
||||||
|
import {
|
||||||
|
confirmTransfer,
|
||||||
|
createTransfer,
|
||||||
|
finishTransfer,
|
||||||
|
getTransfer,
|
||||||
|
stockTransfer,
|
||||||
|
submitTransfer,
|
||||||
|
updateTransfer,
|
||||||
|
} from '#/api/mes/wm/transfer';
|
||||||
|
import { $t } from '#/locales';
|
||||||
|
import { MesWmTransferStatusEnum } from '/constants';
|
||||||
|
|
||||||
|
import { useFormSchema } from '../data';
|
||||||
|
import LineList from './line-list.vue';
|
||||||
|
|
||||||
|
const emit = defineEmits(['success']);
|
||||||
|
const formType = ref<FormType>('create');
|
||||||
|
const formData = ref<MesWmTransferApi.Transfer>();
|
||||||
|
const originalSnapshot = ref(''); // 表单原始数据快照,用于提交时跳过未变更的保存请求
|
||||||
|
const isEditable = computed(() => // 是否为编辑模式(可保存)
|
||||||
|
['create', 'update'].includes(formType.value),
|
||||||
|
);
|
||||||
|
const isConfirm = computed(() => formType.value === 'confirm'); // 是否为到货确认模式
|
||||||
|
const isStock = computed(() => formType.value === 'stock'); // 是否为上架模式
|
||||||
|
const isFinish = computed(() => formType.value === 'finish'); // 是否为执行转移模式
|
||||||
|
const canSubmit = computed(() => // 编辑态草稿可提交
|
||||||
|
formType.value === 'update' &&
|
||||||
|
formData.value?.status === MesWmTransferStatusEnum.PREPARE,
|
||||||
|
);
|
||||||
|
const getTitle = computed(() => {
|
||||||
|
switch (formType.value) {
|
||||||
|
case 'confirm': {
|
||||||
|
return '到货确认';
|
||||||
|
}
|
||||||
|
case 'detail': {
|
||||||
|
return $t('ui.actionTitle.view', ['转移单']);
|
||||||
|
}
|
||||||
|
case 'finish': {
|
||||||
|
return '执行转移';
|
||||||
|
}
|
||||||
|
case 'stock': {
|
||||||
|
return '执行上架';
|
||||||
|
}
|
||||||
|
case 'update': {
|
||||||
|
return $t('ui.actionTitle.edit', ['转移单']);
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
return $t('ui.actionTitle.create', ['转移单']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const [Form, formApi] = useVbenForm({
|
||||||
|
commonConfig: {
|
||||||
|
componentProps: {
|
||||||
|
class: 'w-full',
|
||||||
|
},
|
||||||
|
formItemClass: 'col-span-1',
|
||||||
|
labelWidth: 110,
|
||||||
|
},
|
||||||
|
layout: 'horizontal',
|
||||||
|
schema: [],
|
||||||
|
showDefaultActions: false,
|
||||||
|
wrapperClass: 'grid-cols-3',
|
||||||
|
});
|
||||||
|
|
||||||
|
/** 提交转移单:表单有修改时先保存,再调用提交接口 */
|
||||||
|
async function handleSubmit() {
|
||||||
|
const { valid } = await formApi.validate();
|
||||||
|
if (!valid || !formData.value?.id) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
modalApi.lock();
|
||||||
|
try {
|
||||||
|
const current = JSON.stringify(await formApi.getValues());
|
||||||
|
if (current !== originalSnapshot.value) {
|
||||||
|
const data = (await formApi.getValues()) as MesWmTransferApi.Transfer;
|
||||||
|
await updateTransfer({ ...formData.value, ...data });
|
||||||
|
originalSnapshot.value = current;
|
||||||
|
}
|
||||||
|
await submitTransfer(formData.value.id);
|
||||||
|
ElMessage.success('提交成功');
|
||||||
|
await modalApi.close();
|
||||||
|
emit('success');
|
||||||
|
} finally {
|
||||||
|
modalApi.unlock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 到货确认 */
|
||||||
|
async function handleConfirm() {
|
||||||
|
if (!formData.value?.id) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
modalApi.lock();
|
||||||
|
try {
|
||||||
|
await confirmTransfer(formData.value.id);
|
||||||
|
ElMessage.success('确认成功');
|
||||||
|
await modalApi.close();
|
||||||
|
emit('success');
|
||||||
|
} finally {
|
||||||
|
modalApi.unlock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 执行上架 */
|
||||||
|
async function handleStock() {
|
||||||
|
if (!formData.value?.id) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
modalApi.lock();
|
||||||
|
try {
|
||||||
|
await stockTransfer(formData.value.id);
|
||||||
|
ElMessage.success('上架成功');
|
||||||
|
await modalApi.close();
|
||||||
|
emit('success');
|
||||||
|
} finally {
|
||||||
|
modalApi.unlock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 执行转移 */
|
||||||
|
async function handleFinish() {
|
||||||
|
if (!formData.value?.id) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
modalApi.lock();
|
||||||
|
try {
|
||||||
|
await finishTransfer(formData.value.id);
|
||||||
|
ElMessage.success('执行成功');
|
||||||
|
await modalApi.close();
|
||||||
|
emit('success');
|
||||||
|
} finally {
|
||||||
|
modalApi.unlock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const [Modal, modalApi] = useVbenModal({
|
||||||
|
async onConfirm() {
|
||||||
|
if (!isEditable.value) {
|
||||||
|
await modalApi.close();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const { valid } = await formApi.validate();
|
||||||
|
if (!valid) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
modalApi.lock();
|
||||||
|
// 提交表单
|
||||||
|
const data = (await formApi.getValues()) as MesWmTransferApi.Transfer;
|
||||||
|
try {
|
||||||
|
if (formData.value?.id) {
|
||||||
|
await updateTransfer({ ...formData.value, ...data });
|
||||||
|
formData.value = { ...formData.value, ...data };
|
||||||
|
} else {
|
||||||
|
const id = await createTransfer(data);
|
||||||
|
formData.value = {
|
||||||
|
...data,
|
||||||
|
id,
|
||||||
|
status: MesWmTransferStatusEnum.PREPARE,
|
||||||
|
};
|
||||||
|
formType.value = 'update';
|
||||||
|
// 创建成功后切换编辑态,重挂 schema 并回填主键 / 状态
|
||||||
|
formApi.setState({ schema: useFormSchema(formType.value, formApi) });
|
||||||
|
await formApi.setValues(formData.value);
|
||||||
|
}
|
||||||
|
originalSnapshot.value = JSON.stringify(await formApi.getValues());
|
||||||
|
emit('success');
|
||||||
|
ElMessage.success($t('ui.actionMessage.operationSuccess'));
|
||||||
|
} finally {
|
||||||
|
modalApi.unlock();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async onOpenChange(isOpen: boolean) {
|
||||||
|
if (!isOpen) {
|
||||||
|
formData.value = undefined;
|
||||||
|
originalSnapshot.value = '';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 加载数据
|
||||||
|
const data = modalApi.getData<{ formType: FormType; id?: number }>();
|
||||||
|
formType.value = data.formType;
|
||||||
|
formApi.setState({ schema: useFormSchema(formType.value, formApi) });
|
||||||
|
modalApi.setState({ showConfirmButton: isEditable.value });
|
||||||
|
if (data?.id) {
|
||||||
|
modalApi.lock();
|
||||||
|
try {
|
||||||
|
formData.value = await getTransfer(data.id);
|
||||||
|
// 设置到 values
|
||||||
|
await formApi.setValues(formData.value);
|
||||||
|
} finally {
|
||||||
|
modalApi.unlock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
originalSnapshot.value = JSON.stringify(await formApi.getValues());
|
||||||
|
},
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Modal :title="getTitle" class="w-3/5">
|
||||||
|
<Form class="mx-4" />
|
||||||
|
<!-- 非新建模式展示物料信息 -->
|
||||||
|
<template v-if="formData?.id">
|
||||||
|
<ElDivider>物料信息</ElDivider>
|
||||||
|
<div class="mx-4">
|
||||||
|
<LineList :form-type="formType" :transfer-id="formData.id" />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<template #prepend-footer>
|
||||||
|
<div class="flex flex-auto items-center gap-2">
|
||||||
|
<ElPopconfirm
|
||||||
|
v-if="canSubmit"
|
||||||
|
title="确认提交该转移单?【提交后将不能修改】"
|
||||||
|
width="280"
|
||||||
|
@confirm="handleSubmit"
|
||||||
|
>
|
||||||
|
<template #reference>
|
||||||
|
<ElButton type="primary">提交</ElButton>
|
||||||
|
</template>
|
||||||
|
</ElPopconfirm>
|
||||||
|
<ElPopconfirm
|
||||||
|
v-if="isConfirm"
|
||||||
|
title="确认到货后,将进入待上架状态,是否继续?"
|
||||||
|
width="280"
|
||||||
|
@confirm="handleConfirm"
|
||||||
|
>
|
||||||
|
<template #reference>
|
||||||
|
<ElButton type="primary">到货确认</ElButton>
|
||||||
|
</template>
|
||||||
|
</ElPopconfirm>
|
||||||
|
<ElPopconfirm
|
||||||
|
v-if="isStock"
|
||||||
|
title="确认执行上架?"
|
||||||
|
width="220"
|
||||||
|
@confirm="handleStock"
|
||||||
|
>
|
||||||
|
<template #reference>
|
||||||
|
<ElButton type="primary">执行上架</ElButton>
|
||||||
|
</template>
|
||||||
|
</ElPopconfirm>
|
||||||
|
<ElPopconfirm
|
||||||
|
v-if="isFinish"
|
||||||
|
title="确认执行调拨?执行后将更新库存。"
|
||||||
|
width="280"
|
||||||
|
@confirm="handleFinish"
|
||||||
|
>
|
||||||
|
<template #reference>
|
||||||
|
<ElButton type="primary">执行转移</ElButton>
|
||||||
|
</template>
|
||||||
|
</ElPopconfirm>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</Modal>
|
||||||
|
</template>
|
||||||
|
|
@ -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 type { WmsHomeStatisticsApi } from '#/api/wms/home';
|
||||||
|
|
||||||
import { formatQuantity } from '#/views/wms/utils/format';
|
import { formatQuantity } from '#/views/wms/utils/format';
|
||||||
|
|
||||||
type WmsHomeChartOption = Parameters<
|
|
||||||
ReturnType<typeof useEcharts>['renderEcharts']
|
|
||||||
>[0];
|
|
||||||
|
|
||||||
export interface InventoryChartItem {
|
export interface InventoryChartItem {
|
||||||
name: string;
|
name: string;
|
||||||
value: number;
|
value: number;
|
||||||
|
|
@ -44,7 +40,7 @@ function formatGoodsLegend(name: string, goodsShareList: InventoryChartItem[]) {
|
||||||
/** 货物占比图表配置 */
|
/** 货物占比图表配置 */
|
||||||
export function getGoodsShareChartOptions(
|
export function getGoodsShareChartOptions(
|
||||||
goodsShareList: InventoryChartItem[],
|
goodsShareList: InventoryChartItem[],
|
||||||
): WmsHomeChartOption {
|
): EChartsOption {
|
||||||
return {
|
return {
|
||||||
color: ['#2f7df6', '#18a058', '#f59e0b', '#7c3aed', '#14b8a6'],
|
color: ['#2f7df6', '#18a058', '#f59e0b', '#7c3aed', '#14b8a6'],
|
||||||
legend: {
|
legend: {
|
||||||
|
|
@ -78,7 +74,7 @@ export function getGoodsShareChartOptions(
|
||||||
/** 库存分布图表配置 */
|
/** 库存分布图表配置 */
|
||||||
export function getWarehouseDistributionChartOptions(
|
export function getWarehouseDistributionChartOptions(
|
||||||
warehouseDistributionList: InventoryChartItem[],
|
warehouseDistributionList: InventoryChartItem[],
|
||||||
): WmsHomeChartOption {
|
): EChartsOption {
|
||||||
const sortedList = warehouseDistributionList.toReversed();
|
const sortedList = warehouseDistributionList.toReversed();
|
||||||
return {
|
return {
|
||||||
color: ['#2f7df6'],
|
color: ['#2f7df6'],
|
||||||
|
|
|
||||||
|
|
@ -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';
|
import type { WmsHomeStatisticsApi } from '#/api/wms/home';
|
||||||
|
|
||||||
|
|
@ -6,11 +6,7 @@ import { DICT_TYPE } from '@vben/constants';
|
||||||
import { getDictLabel } from '@vben/hooks';
|
import { getDictLabel } from '@vben/hooks';
|
||||||
import { formatDate } from '@vben/utils';
|
import { formatDate } from '@vben/utils';
|
||||||
|
|
||||||
import { OrderTypeEnum } from '#/views/wms/utils/constants';
|
import { OrderTypeEnum } from '/constants';
|
||||||
|
|
||||||
type WmsHomeChartOption = Parameters<
|
|
||||||
ReturnType<typeof useEcharts>['renderEcharts']
|
|
||||||
>[0];
|
|
||||||
|
|
||||||
interface OrderDefinition {
|
interface OrderDefinition {
|
||||||
color: string;
|
color: string;
|
||||||
|
|
@ -72,7 +68,7 @@ function formatTrendTime(time: number | string) {
|
||||||
/** 单据趋势图表配置 */
|
/** 单据趋势图表配置 */
|
||||||
export function getOrderTrendChartOptions(
|
export function getOrderTrendChartOptions(
|
||||||
list: WmsHomeStatisticsApi.OrderTrend[],
|
list: WmsHomeStatisticsApi.OrderTrend[],
|
||||||
): WmsHomeChartOption {
|
): EChartsOption {
|
||||||
const labels = list.map((item) => formatTrendTime(item.time));
|
const labels = list.map((item) => formatTrendTime(item.time));
|
||||||
return {
|
return {
|
||||||
color: orderDefinitions.map((item) => item.color),
|
color: orderDefinitions.map((item) => item.color),
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
export * from './echarts';
|
|
||||||
export { default as EchartsUI } from './echarts-ui.vue';
|
export { default as EchartsUI } from './echarts-ui.vue';
|
||||||
export * from './types';
|
export type { ECOption } from './types';
|
||||||
export * from './use-echarts';
|
export * from './use-echarts';
|
||||||
|
|
||||||
|
// add by 芋艿:额外透出 echarts 原生 EChartsOption 类型,方便业务模块(如 mes/home 图表配置)声明 option 返回值类型,避免业务侧直接依赖 echarts 包(apps 未把 echarts 列为直接依赖)
|
||||||
|
export type { EChartsOption } from 'echarts';
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue