feat: 增加LMS日计划管理页面

This commit is contained in:
zhouz
2026-08-14 15:25:59 +08:00
parent 558d8ad285
commit ea61e16d9b
6 changed files with 549 additions and 0 deletions

View File

@@ -0,0 +1,138 @@
import type { VbenFormSchema } from '#/adapter/form';
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { LmsDailyPlanApi } from '#/api/lms/dailyplan';
import { DICT_TYPE } from '@vben/constants';
import { getDictOptions } from '@vben/hooks';
import { getRangePickerDefaultProps } from '#/utils';
const DAILY_PLAN_DICT_TYPE = DICT_TYPE as typeof DICT_TYPE & {
LMS_DAILY_PLAN_ORDER_STATUS: string;
LMS_DAILY_PLAN_SOURCE_TYPE: string;
LMS_DAILY_PLAN_WORK_STATUS: string;
};
export function useGridFormSchema(): VbenFormSchema[] {
return [
{
fieldName: 'planOrOrderCode',
label: '计划/订单号',
component: 'Input',
componentProps: { allowClear: true, placeholder: '请输入计划或订单号' },
},
{
fieldName: 'planDateRange',
label: '计划日期',
component: 'RangePicker',
componentProps: {
...getRangePickerDefaultProps(),
allowClear: true,
valueFormat: 'YYYY-MM-DD',
},
},
{
fieldName: 'materialKeyword',
label: '管芯',
component: 'Input',
componentProps: { allowClear: true, placeholder: '请输入管芯编码或名称' },
},
{
fieldName: 'sourceType',
label: '来源',
component: 'Select',
componentProps: {
allowClear: true,
options: getDictOptions(DAILY_PLAN_DICT_TYPE.LMS_DAILY_PLAN_SOURCE_TYPE),
placeholder: '请选择来源',
},
},
{
fieldName: 'orderStatus',
label: '订单状态',
component: 'Select',
componentProps: {
allowClear: true,
options: getDictOptions(DAILY_PLAN_DICT_TYPE.LMS_DAILY_PLAN_ORDER_STATUS),
placeholder: '请选择订单状态',
},
},
];
}
export function useGridColumns(): VxeTableGridOptions<LmsDailyPlanApi.DailyPlan>['columns'] {
return [
{ field: 'planCode', title: '日计划编号', minWidth: 150 },
{ field: 'orderCode', title: '订单号', minWidth: 150, slots: { default: 'orderCode' } },
{ field: 'planDate', title: '计划日期', minWidth: 115 },
{ field: 'materialCode', title: '管芯编码', minWidth: 140 },
{ field: 'materialName', title: '管芯名称', minWidth: 150 },
{ field: 'materialSpec', title: '规格', minWidth: 120 },
{ field: 'totalQty', title: '需求总量', minWidth: 100 },
{ field: 'stockingProgress', title: '备货进度', minWidth: 115, slots: { default: 'stockingProgress' } },
{ field: 'sleevingProgress', title: '套管进度', minWidth: 115, slots: { default: 'sleevingProgress' } },
{
field: 'orderStatus', title: '订单状态', minWidth: 105,
cellRender: { name: 'CellDict', props: { type: DAILY_PLAN_DICT_TYPE.LMS_DAILY_PLAN_ORDER_STATUS } },
},
{
field: 'stockingStatus', title: '备货状态', minWidth: 105,
cellRender: { name: 'CellDict', props: { type: DAILY_PLAN_DICT_TYPE.LMS_DAILY_PLAN_WORK_STATUS } },
},
{
field: 'sleevingStatus', title: '套管状态', minWidth: 105,
cellRender: { name: 'CellDict', props: { type: DAILY_PLAN_DICT_TYPE.LMS_DAILY_PLAN_WORK_STATUS } },
},
{
field: 'sourceType', title: '来源', minWidth: 90,
cellRender: { name: 'CellDict', props: { type: DAILY_PLAN_DICT_TYPE.LMS_DAILY_PLAN_SOURCE_TYPE } },
},
{ field: 'updaterName', title: '修改人', minWidth: 110 },
{ field: 'updateTime', title: '修改时间', minWidth: 170, formatter: 'formatDateTime' },
{ title: '操作', width: 210, fixed: 'right', slots: { default: 'actions' } },
];
}
export function usePlanFormSchema(): VbenFormSchema[] {
return [
{ fieldName: 'dailyPlanId', component: 'Input', dependencies: { triggerFields: [''], show: () => false } },
{ fieldName: 'version', component: 'Input', dependencies: { triggerFields: [''], show: () => false } },
{
fieldName: 'planDate', label: '计划日期', component: 'DatePicker', rules: 'required',
componentProps: { class: 'w-full', valueFormat: 'YYYY-MM-DD', placeholder: '请选择计划日期' },
},
{
fieldName: 'manualOrderCode', label: '人工订单号', component: 'Input',
componentProps: { maxlength: 64, placeholder: '不填写时自动使用日计划编号' },
},
{ fieldName: 'materialId', component: 'Input', rules: 'required', dependencies: { triggerFields: [''], show: () => false } },
{
fieldName: 'materialCode', label: '管芯物料', component: 'Input', rules: 'required',
componentProps: { readonly: true, placeholder: '点击选择管芯物料' },
},
{
fieldName: 'materialName', label: '管芯名称', component: 'Input',
componentProps: { disabled: true },
},
{
fieldName: 'materialSpec', label: '管芯规格', component: 'Input',
componentProps: { disabled: true },
},
{
fieldName: 'planQty', label: '计划数量', component: 'InputNumber', rules: 'required',
componentProps: { min: 1, precision: 0, placeholder: '请输入计划数量' },
},
{
fieldName: 'sortSeq', label: '顺序', component: 'InputNumber', rules: 'required',
componentProps: { min: 1, precision: 0, placeholder: '请输入顺序' },
},
{
fieldName: 'weight', label: '权重', component: 'InputNumber', rules: 'required',
componentProps: { min: 1, precision: 0, placeholder: '请输入权重' },
},
{
fieldName: 'packingInfo', label: '装箱信息', component: 'Textarea', formItemClass: 'col-span-2',
componentProps: { maxlength: 4000, placeholder: '请输入装箱信息', rows: 5, showCount: true },
},
];
}

View File

@@ -0,0 +1,137 @@
<script lang="ts" setup>
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { LmsDailyPlanApi } from '#/api/lms/dailyplan';
import { Page, useVbenDrawer, useVbenModal } from '@vben/common-ui';
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
import { getDailyPlanManagementPage } from '#/api/lms/dailyplan';
import { useGridColumns, useGridFormSchema } from './data';
import Detail from './modules/detail.vue';
import Form from './modules/form.vue';
import StartOrder from './modules/start-order.vue';
const SOURCE_MANUAL = 2;
const ORDER_NOT_STARTED = 0;
const [FormDrawer, formDrawerApi] = useVbenDrawer({
connectedComponent: Form,
destroyOnClose: true,
});
const [DetailDrawer, detailDrawerApi] = useVbenDrawer({
connectedComponent: Detail,
destroyOnClose: true,
});
const [StartOrderModal, startOrderModalApi] = useVbenModal({
connectedComponent: StartOrder,
destroyOnClose: true,
});
function handleRefresh() {
gridApi.query();
}
function handleCreate() {
formDrawerApi.setData(null).open();
}
function handleEdit(row: LmsDailyPlanApi.DailyPlan) {
formDrawerApi.setData(row).open();
}
function handleDetail(row: LmsDailyPlanApi.DailyPlan) {
detailDrawerApi.setData(row).open();
}
function handleStart(row: LmsDailyPlanApi.DailyPlan) {
startOrderModalApi.setData(row).open();
}
const [Grid, gridApi] = useVbenVxeGrid({
formOptions: {
schema: useGridFormSchema(),
wrapperClass: 'grid grid-cols-1 gap-x-3 md:grid-cols-3 2xl:grid-cols-5',
},
gridOptions: {
columns: useGridColumns(),
height: 'auto',
keepSource: true,
proxyConfig: {
ajax: {
query: async ({ page }, formValues) => {
const { planDateRange, ...filters } = formValues;
return await getDailyPlanManagementPage({
pageNo: page.currentPage,
pageSize: page.pageSize,
...filters,
planDateStart: planDateRange?.[0],
planDateEnd: planDateRange?.[1],
});
},
},
},
rowConfig: { keyField: 'dailyPlanId', isHover: true },
toolbarConfig: { refresh: true, search: true },
} as VxeTableGridOptions<LmsDailyPlanApi.DailyPlan>,
});
</script>
<template>
<Page auto-content-height>
<FormDrawer @success="handleRefresh" />
<DetailDrawer />
<StartOrderModal @success="handleRefresh" />
<Grid table-title="日计划管理">
<template #toolbar-tools>
<TableAction
:actions="[
{
label: '新增日计划',
type: 'primary',
icon: ACTION_ICON.ADD,
auth: ['lms:daily-plan:create'],
onClick: handleCreate,
},
]"
/>
</template>
<template #orderCode="{ row }">
{{ row.erpOrderCode || row.manualOrderCode || '-' }}
</template>
<template #stockingProgress="{ row }">{{ row.stockedQty }} / {{ row.totalQty }}</template>
<template #sleevingProgress="{ row }">{{ row.sleevedQty }} / {{ row.totalQty }}</template>
<template #actions="{ row }">
<TableAction
:actions="[
{
label: '详情',
type: 'link',
icon: ACTION_ICON.VIEW,
auth: ['lms:daily-plan:query'],
onClick: handleDetail.bind(null, row),
},
{
label: '编辑',
type: 'link',
icon: ACTION_ICON.EDIT,
auth: ['lms:daily-plan:update'],
ifShow: row.sourceType === SOURCE_MANUAL && row.orderStatus === ORDER_NOT_STARTED,
onClick: handleEdit.bind(null, row),
},
{
label: '开始订单',
type: 'link',
auth: ['lms:daily-plan:start'],
ifShow: row.orderStatus === ORDER_NOT_STARTED,
popConfirm: {
title: `确认开始日计划「${row.planCode}」吗?`,
confirm: handleStart.bind(null, row),
},
},
]"
/>
</template>
</Grid>
</Page>
</template>

View File

@@ -0,0 +1,98 @@
<script lang="ts" setup>
import type { LmsDailyPlanApi } from '#/api/lms/dailyplan';
import { ref } from 'vue';
import { useVbenDrawer } from '@vben/common-ui';
import { DICT_TYPE } from '@vben/constants';
import { formatDateTime } from '@vben/utils';
import {
Descriptions, DescriptionsItem, Empty, Timeline, TimelineItem,
} from 'antdv-next';
import { getDailyPlan, getDailyPlanOperationLogList } from '#/api/lms/dailyplan';
import { DictTag } from '#/components/dict-tag';
const plan = ref<LmsDailyPlanApi.DailyPlan>();
const logs = ref<LmsDailyPlanApi.OperationLog[]>([]);
const DAILY_PLAN_DICT_TYPE = DICT_TYPE as typeof DICT_TYPE & {
LMS_DAILY_PLAN_ORDER_STATUS: string;
LMS_DAILY_PLAN_SOURCE_TYPE: string;
LMS_DAILY_PLAN_WORK_STATUS: string;
};
function showTime(value?: number) {
return value ? formatDateTime(value) : '-';
}
const [Drawer, drawerApi] = useVbenDrawer({
showConfirmButton: false,
async onOpenChange(isOpen: boolean) {
if (!isOpen) {
plan.value = undefined;
logs.value = [];
return;
}
const row = drawerApi.getData<LmsDailyPlanApi.DailyPlan>();
if (!row?.dailyPlanId) return;
drawerApi.lock();
try {
[plan.value, logs.value] = await Promise.all([
getDailyPlan(row.dailyPlanId),
getDailyPlanOperationLogList(row.dailyPlanId),
]);
} finally {
drawerApi.unlock();
}
},
});
</script>
<template>
<Drawer class="w-[900px]" title="日计划详情">
<template v-if="plan">
<Descriptions bordered class="mb-5" :column="3" size="small" title="基本信息">
<DescriptionsItem label="日计划编号">{{ plan.planCode }}</DescriptionsItem>
<DescriptionsItem label="订单号">{{ plan.erpOrderCode || plan.manualOrderCode || '-' }}</DescriptionsItem>
<DescriptionsItem label="计划日期">{{ plan.planDate }}</DescriptionsItem>
<DescriptionsItem label="来源"><DictTag :type="DAILY_PLAN_DICT_TYPE.LMS_DAILY_PLAN_SOURCE_TYPE" :value="plan.sourceType" /></DescriptionsItem>
<DescriptionsItem label="管芯编码">{{ plan.materialCode }}</DescriptionsItem>
<DescriptionsItem label="管芯名称">{{ plan.materialName }}</DescriptionsItem>
<DescriptionsItem label="规格">{{ plan.materialSpec || '-' }}</DescriptionsItem>
<DescriptionsItem label="计划/追加">{{ plan.planQty }} / {{ plan.appendQty }}</DescriptionsItem>
<DescriptionsItem label="需求总量">{{ plan.totalQty }}</DescriptionsItem>
<DescriptionsItem label="顺序/权重">{{ plan.sortSeq }} / {{ plan.weight }}</DescriptionsItem>
<DescriptionsItem label="备货进度">{{ plan.stockedQty }} / {{ plan.totalQty }}</DescriptionsItem>
<DescriptionsItem label="套管进度">{{ plan.sleevedQty }} / {{ plan.totalQty }}</DescriptionsItem>
<DescriptionsItem label="装箱信息" :span="3"><div class="whitespace-pre-wrap">{{ plan.packingInfo || '-' }}</div></DescriptionsItem>
</Descriptions>
<Descriptions bordered class="mb-5" :column="3" size="small" title="状态与时间">
<DescriptionsItem label="订单状态"><DictTag :type="DAILY_PLAN_DICT_TYPE.LMS_DAILY_PLAN_ORDER_STATUS" :value="plan.orderStatus" /></DescriptionsItem>
<DescriptionsItem label="订单开始">{{ showTime(plan.orderStartTime) }}</DescriptionsItem>
<DescriptionsItem label="订单结束">{{ showTime(plan.orderEndTime) }}</DescriptionsItem>
<DescriptionsItem label="备货状态"><DictTag :type="DAILY_PLAN_DICT_TYPE.LMS_DAILY_PLAN_WORK_STATUS" :value="plan.stockingStatus" /></DescriptionsItem>
<DescriptionsItem label="备货开始">{{ showTime(plan.stockingStartTime) }}</DescriptionsItem>
<DescriptionsItem label="备货完成">{{ showTime(plan.stockingCompleteTime) }}</DescriptionsItem>
<DescriptionsItem label="套管状态"><DictTag :type="DAILY_PLAN_DICT_TYPE.LMS_DAILY_PLAN_WORK_STATUS" :value="plan.sleevingStatus" /></DescriptionsItem>
<DescriptionsItem label="套管开始">{{ showTime(plan.sleevingStartTime) }}</DescriptionsItem>
<DescriptionsItem label="套管完成">{{ showTime(plan.sleevingCompleteTime) }}</DescriptionsItem>
</Descriptions>
<div class="mb-3 text-base font-medium">操作记录最新在前</div>
<Empty v-if="logs.length === 0" description="暂无操作记录" />
<Timeline v-else>
<TimelineItem v-for="log in logs" :key="String(log.operationLogId)">
<div class="font-medium">{{ log.operationType }} · {{ log.operationTarget }}</div>
<div class="text-sm text-gray-500">{{ showTime(log.operationTime) }} · {{ log.operator || '-' }}</div>
<div v-if="log.beforeValue || log.afterValue" class="mt-1">
{{ log.beforeValue || '-' }} {{ log.afterValue || '-' }}
</div>
<div v-if="log.changeQty" class="mt-1">数量变化{{ log.changeQty > 0 ? '+' : '' }}{{ log.changeQty }}</div>
<div v-if="log.operationReason" class="mt-1 whitespace-pre-wrap">原因{{ log.operationReason }}</div>
</TimelineItem>
</Timeline>
</template>
</Drawer>
</template>

View File

@@ -0,0 +1,109 @@
<script lang="ts" setup>
import type { BaseMaterialBaseApi } from '#/api/base/materialbase';
import type { LmsDailyPlanApi } from '#/api/lms/dailyplan';
import { computed, ref } from 'vue';
import { useVbenDrawer, useVbenModal } from '@vben/common-ui';
import { message } from 'antdv-next';
import { useVbenForm } from '#/adapter/form';
import { createDailyPlan, getDailyPlan, updateDailyPlan } from '#/api/lms/dailyplan';
import MaterialSelectModalComponent from '#/views/base/materialbase/components/MaterialSelectModal.vue';
import { usePlanFormSchema } from '../data';
const emit = defineEmits(['success']);
const formData = ref<LmsDailyPlanApi.DailyPlan>();
const title = computed(() => formData.value ? '编辑日计划' : '新增日计划');
const [MaterialSelectModal, materialSelectModalApi] = useVbenModal({
connectedComponent: MaterialSelectModalComponent,
destroyOnClose: true,
});
function openMaterialSelect() {
materialSelectModalApi.setData({ multiple: false }).open();
}
async function handleMaterialSelect(rows: BaseMaterialBaseApi.MaterialBase[]) {
const material = rows[0];
if (!material) return;
await formApi.setValues({
materialId: material.materialId,
materialCode: material.materialCode,
materialName: material.materialName,
materialSpec: material.materialSpec,
});
}
const formSchema = usePlanFormSchema().map((item) => item.fieldName === 'materialCode'
? {
...item,
componentProps: {
...item.componentProps,
onClick: openMaterialSelect,
style: 'cursor: pointer',
},
}
: item);
const [Form, formApi] = useVbenForm({
commonConfig: {
componentProps: { class: 'w-full' },
formItemClass: 'col-span-1',
labelWidth: 90,
},
layout: 'horizontal',
schema: formSchema,
showDefaultActions: false,
});
const [Drawer, drawerApi] = useVbenDrawer({
async onConfirm() {
const { valid } = await formApi.validate();
if (!valid) return;
drawerApi.lock();
try {
const values = await formApi.getValues();
if (formData.value) {
await updateDailyPlan(values as LmsDailyPlanApi.UpdateReq);
} else {
await createDailyPlan(values as LmsDailyPlanApi.CreateReq);
}
await drawerApi.close();
message.success('操作成功');
emit('success');
} finally {
drawerApi.unlock();
}
},
async onOpenChange(isOpen: boolean) {
if (!isOpen) {
formData.value = undefined;
await formApi.resetForm();
return;
}
const row = drawerApi.getData<LmsDailyPlanApi.DailyPlan>();
if (!row?.dailyPlanId) {
await formApi.setValues({ sortSeq: 1, weight: 1 });
return;
}
drawerApi.lock();
try {
formData.value = await getDailyPlan(row.dailyPlanId);
await formApi.setValues(formData.value);
} finally {
drawerApi.unlock();
}
},
});
</script>
<template>
<Drawer :title="title" class="w-[720px]">
<Form class="mx-4" />
<MaterialSelectModal @select="handleMaterialSelect" />
</Drawer>
</template>

View File

@@ -0,0 +1,63 @@
<script lang="ts" setup>
import type { LmsDailyPlanApi } from '#/api/lms/dailyplan';
import { computed, ref } from 'vue';
import { useVbenModal } from '@vben/common-ui';
import { Descriptions, DescriptionsItem, InputNumber, message } from 'antdv-next';
import { startDailyPlanOrder } from '#/api/lms/dailyplan';
const emit = defineEmits(['success']);
const row = ref<LmsDailyPlanApi.DailyPlan>();
const appendQty = ref(0);
const totalAfterStart = computed(() => (row.value?.totalQty ?? 0) + appendQty.value);
const [Modal, modalApi] = useVbenModal({
async onConfirm() {
if (!row.value) return;
if (!Number.isInteger(appendQty.value) || appendQty.value < 0) {
message.warning('追加数量必须为不小于 0 的整数');
return;
}
modalApi.lock();
try {
await startDailyPlanOrder({
id: row.value.dailyPlanId,
version: row.value.version,
appendQty: appendQty.value,
});
await modalApi.close();
message.success('订单已开始');
emit('success');
} finally {
modalApi.unlock();
}
},
onOpenChange(isOpen: boolean) {
if (!isOpen) {
row.value = undefined;
appendQty.value = 0;
return;
}
row.value = modalApi.getData<LmsDailyPlanApi.DailyPlan>();
appendQty.value = 0;
},
});
</script>
<template>
<Modal class="w-[560px]" title="开始订单">
<Descriptions v-if="row" bordered :column="1" size="small">
<DescriptionsItem label="日计划编号">{{ row.planCode }}</DescriptionsItem>
<DescriptionsItem label="管芯">{{ row.materialCode }} / {{ row.materialName }}</DescriptionsItem>
<DescriptionsItem label="当前计划数量">{{ row.planQty }}</DescriptionsItem>
<DescriptionsItem label="已有追加数量">{{ row.appendQty }}</DescriptionsItem>
<DescriptionsItem label="本次追加数量">
<InputNumber v-model:value="appendQty" :min="0" :precision="0" class="w-full" />
</DescriptionsItem>
<DescriptionsItem label="开始后需求总量">{{ totalAfterStart }}</DescriptionsItem>
</Descriptions>
</Modal>
</template>

View File

@@ -311,6 +311,10 @@ const RawFoil_DICT = {
EMPTYROLLER_CASHEPOSITION_TYPE: 'emptyroller_casheposition_type', // 空辊缓存位点位类型
LMS_STOCKING_IVT_POINT_TYPE: 'lms_stocking_ivt_point_type', // LMS 备货区域点位类型
LMS_STOCKING_IVT_STATUS: 'lms_stocking_ivt_status', // LMS 备货区域点位状态
LMS_DAILY_PLAN_SOURCE_TYPE: 'lms_daily_plan_source_type', // LMS 日计划来源
LMS_DAILY_PLAN_ORDER_STATUS: 'lms_daily_plan_order_status', // LMS 日计划订单状态
LMS_DAILY_PLAN_WORK_STATUS: 'lms_daily_plan_work_status', // LMS 日计划作业状态
LMS_DAILY_PLAN_STRATEGY_MODE: 'lms_daily_plan_strategy_mode', // LMS 日计划策略模式
} as const;
/** 字典类型枚举 - 统一导出 */