diff --git a/nl-ui/nl-ui-admin-vben/yudao-ui-admin-vben/apps/web-antdv-next/src/views/lms/daily-plan/work/data.ts b/nl-ui/nl-ui-admin-vben/yudao-ui-admin-vben/apps/web-antdv-next/src/views/lms/daily-plan/work/data.ts index 80a93c1a..7c7460cf 100644 --- a/nl-ui/nl-ui-admin-vben/yudao-ui-admin-vben/apps/web-antdv-next/src/views/lms/daily-plan/work/data.ts +++ b/nl-ui/nl-ui-admin-vben/yudao-ui-admin-vben/apps/web-antdv-next/src/views/lms/daily-plan/work/data.ts @@ -26,24 +26,30 @@ export function useGridFormSchema(): VbenFormSchema[] { ]; } -export function useGridColumns(showWeight: boolean): VxeTableGridOptions['columns'] { +export function useGridColumns( + workType: number, + showWeight: boolean, +): VxeTableGridOptions['columns'] { + const isStocking = workType === 1; return [ { field: 'sortSeq', title: '顺序', width: 80, fixed: 'left' }, - ...(showWeight ? [{ field: 'weight', title: '权重', width: 80 }] : []), + ...(showWeight ? [{ field: 'weight', title: '权重', width: 150, slots: { default: 'weight' } }] : []), { field: 'planCode', title: '日计划编号', minWidth: 150 }, { field: 'orderCode', title: '订单号', minWidth: 150, slots: { default: 'orderCode' } }, { field: 'planDate', title: '计划日期', minWidth: 115 }, { field: 'materialCode', title: '管芯编码', minWidth: 130 }, { field: 'materialName', title: '管芯名称', minWidth: 140 }, { field: 'totalQty', title: '需求总量', minWidth: 95 }, - { field: 'stockingProgress', title: '备货进度', minWidth: 115, slots: { default: 'stockingProgress' } }, { - field: 'stockingStatus', title: '备货状态', minWidth: 105, - cellRender: { name: 'CellDict', props: { type: DAILY_PLAN_DICT_TYPE.LMS_DAILY_PLAN_WORK_STATUS } }, + field: isStocking ? 'stockingProgress' : 'sleevingProgress', + title: isStocking ? '备货进度' : '套管进度', + minWidth: 115, + slots: { default: isStocking ? 'stockingProgress' : 'sleevingProgress' }, }, - { field: 'sleevingProgress', title: '套管进度', minWidth: 115, slots: { default: 'sleevingProgress' } }, { - field: 'sleevingStatus', title: '套管状态', minWidth: 105, + field: isStocking ? 'stockingStatus' : 'sleevingStatus', + title: isStocking ? '备货状态' : '套管状态', + minWidth: 105, cellRender: { name: 'CellDict', props: { type: DAILY_PLAN_DICT_TYPE.LMS_DAILY_PLAN_WORK_STATUS } }, }, { diff --git a/nl-ui/nl-ui-admin-vben/yudao-ui-admin-vben/apps/web-antdv-next/src/views/lms/daily-plan/work/index.vue b/nl-ui/nl-ui-admin-vben/yudao-ui-admin-vben/apps/web-antdv-next/src/views/lms/daily-plan/work/index.vue index 60c8df84..d9f6d551 100644 --- a/nl-ui/nl-ui-admin-vben/yudao-ui-admin-vben/apps/web-antdv-next/src/views/lms/daily-plan/work/index.vue +++ b/nl-ui/nl-ui-admin-vben/yudao-ui-admin-vben/apps/web-antdv-next/src/views/lms/daily-plan/work/index.vue @@ -7,7 +7,7 @@ import { computed, onMounted, ref } from 'vue'; import { confirm, Page, useVbenDrawer, useVbenModal } from '@vben/common-ui'; import { formatDateTime } from '@vben/utils'; -import { Card, message, TabPane, Tabs, Tag } from 'antdv-next'; +import { Card, InputNumber, message, TabPane, Tabs, Tag } from 'antdv-next'; import { TableAction, useVbenVxeGrid } from '#/adapter/vxe-table'; import { @@ -16,6 +16,7 @@ import { getDailyPlanWorkPage, startDailyPlanSleeving, startDailyPlanStocking, + updateDailyPlanWeight, } from '#/api/lms/dailyplan'; import Detail from '../management/modules/detail.vue'; @@ -32,8 +33,10 @@ const WORK_CANCELED = 3; const STRATEGY_WEIGHT = 2; const activeOrderStatus = ref(String(ORDER_IN_PROGRESS)); +const activeWorkType = ref('1'); const strategies = ref([]); -const showWeight = computed(() => strategies.value.some((item) => item.strategyMode === STRATEGY_WEIGHT)); +const showWeight = computed(() => strategyOf(Number(activeWorkType.value))?.strategyMode === STRATEGY_WEIGHT); +const weightDrafts = ref>({}); const [DetailDrawer, detailDrawerApi] = useVbenDrawer({ connectedComponent: Detail, destroyOnClose: true }); const [OperationModal, operationModalApi] = useVbenModal({ connectedComponent: Operation, destroyOnClose: true }); @@ -49,7 +52,7 @@ function strategyName(mode?: number) { } function updateColumns() { - gridApi.setGridOptions({ columns: useGridColumns(showWeight.value) }); + gridApi.setGridOptions({ columns: useGridColumns(Number(activeWorkType.value), showWeight.value) }); } async function loadStrategies() { @@ -74,6 +77,11 @@ function handleTabChange() { handleRefresh(); } +function handleWorkTypeChange() { + weightDrafts.value = {}; + updateColumns(); +} + function handleDetail(row: LmsDailyPlanApi.DailyPlan) { detailDrawerApi.setData(row).open(); } @@ -82,20 +90,59 @@ function handleOperation(row: LmsDailyPlanApi.DailyPlan, type: string) { operationModalApi.setData({ row, type }).open(); } +function isCancelableWorkStatus(status: number) { + return status === WORK_NOT_STARTED || status === WORK_IN_PROGRESS; +} + function handleStrategy(type: number) { const strategy = strategyOf(type); if (strategy) strategyModalApi.setData(strategy).open(); } -function handleSort() { - const rows = gridApi.grid?.getData() as LmsDailyPlanApi.DailyPlan[]; - if (!rows?.length) { - message.warning('当前页没有可调整的日计划'); +async function handleSort() { + const filters = await gridApi.formApi.getValues(); + const pageSize = 100; + let pageNo = 1; + const rows: LmsDailyPlanApi.DailyPlan[] = []; + while (true) { + const page = await getDailyPlanWorkPage({ + ...filters, + orderStatus: Number(activeOrderStatus.value), + pageNo, + pageSize, + }); + rows.push(...page.list); + if (page.list.length === 0 || rows.length >= page.total) break; + pageNo += 1; + } + if (rows.length === 0) { + message.warning('当前状态没有可调整的日计划'); return; } sortModalApi.setData(rows).open(); } +function getWeightDraft(row: LmsDailyPlanApi.DailyPlan) { + return weightDrafts.value[String(row.dailyPlanId)] ?? row.weight; +} + +function setWeightDraft(row: LmsDailyPlanApi.DailyPlan, value: null | number) { + weightDrafts.value[String(row.dailyPlanId)] = value ?? row.weight; +} + +async function handleWeightSave(row: LmsDailyPlanApi.DailyPlan) { + const weight = getWeightDraft(row); + if (!Number.isInteger(weight) || weight <= 0) { + message.warning('权重必须为正整数'); + return; + } + await confirm(`确认将 ${row.planCode} 的权重调整为 ${weight} 吗?`); + await updateDailyPlanWeight({ id: row.dailyPlanId, version: row.version, weight }); + message.success('权重修改成功'); + delete weightDrafts.value[String(row.dailyPlanId)]; + handleRefresh(); +} + async function handleStartWork(row: LmsDailyPlanApi.DailyPlan, target: 'sleeving' | 'stocking') { const label = target === 'stocking' ? '备货' : '套管'; await confirm(`确认开始${label}吗?本操作只改变日计划状态,实际任务由定时器后续生成。`); @@ -118,7 +165,7 @@ const [Grid, gridApi] = useVbenVxeGrid({ wrapperClass: 'grid grid-cols-1 gap-x-3 md:grid-cols-2 xl:grid-cols-4', }, gridOptions: { - columns: useGridColumns(false), + columns: useGridColumns(1, false), height: 'auto', keepSource: true, proxyConfig: { @@ -148,7 +195,12 @@ onMounted(loadStrategies);
- +
{{ type === 1 ? '备货策略' : '套管策略' }}
@@ -166,6 +218,11 @@ onMounted(loadStrategies);
+ + + + + @@ -180,18 +237,31 @@ onMounted(loadStrategies); +