From 1c1af9b0fc10778ae5ac13cc68fd4030affbcfe1 Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期三, 09 九月 2026 10:59:53 +0800
Subject: [PATCH] feat(wm): 新增SN码管理和设备入库功能
---
src/views/wls/sn/data.ts | 289 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 288 insertions(+), 1 deletions(-)
diff --git a/src/views/wls/sn/data.ts b/src/views/wls/sn/data.ts
index 2023366..880c7a0 100644
--- a/src/views/wls/sn/data.ts
+++ b/src/views/wls/sn/data.ts
@@ -1,11 +1,26 @@
-import type { VbenFormSchema } from '#/adapter/form';
+import type { VbenFormApi, VbenFormSchema } from '#/adapter/form';
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { MesWmSnApi } from '#/api/mes/wm/sn';
+import type { DescriptionItemSchema } from '#/components/description';
import { markRaw } from 'vue';
+import { MesWmSnStatusEnum } from '@vben/constants';
+import { formatDateTime } from '@vben/utils';
+
import { getRangePickerDefaultProps } from '#/utils';
import { MdItemSelect } from '#/views/mes/md/item/components';
+import {
+ WmWarehouseAreaSelect,
+ WmWarehouseLocationSelect,
+ WmWarehouseSelect,
+} from '#/views/wls/warehouse/components';
+
+/** SN 鐘舵�侀�夐」锛堟棤鐙珛瀛楀吀锛屼娇鐢ㄥ父閲忔槧灏勶級 */
+export const SN_STATUS_OPTIONS = [
+ { label: '鍦ㄥ簱', value: MesWmSnStatusEnum.IN_STOCK },
+ { label: '宸插嚭搴�', value: MesWmSnStatusEnum.OUT_STOCK },
+];
/** 鐢熸垚 SN 鐮佺殑琛ㄥ崟 */
export function useFormSchema(): VbenFormSchema[] {
@@ -181,3 +196,275 @@
},
];
}
+
+/** 鍦ㄥ簱鍗曚欢鍒楄〃鐨勬悳绱㈣〃鍗� */
+export function useInStockGridFormSchema(): VbenFormSchema[] {
+ return [
+ {
+ fieldName: 'code',
+ label: 'SN 鐮�',
+ component: 'Input',
+ componentProps: {
+ allowClear: true,
+ placeholder: '璇疯緭鍏� SN 鐮�',
+ },
+ },
+ {
+ fieldName: 'itemId',
+ label: '鐗╂枡',
+ component: markRaw(MdItemSelect),
+ componentProps: {
+ placeholder: '璇烽�夋嫨鐗╂枡',
+ },
+ },
+ {
+ fieldName: 'batchCode',
+ label: '鎵规鍙�',
+ component: 'Input',
+ componentProps: {
+ allowClear: true,
+ placeholder: '璇疯緭鍏ユ壒娆″彿',
+ },
+ },
+ {
+ fieldName: 'status',
+ label: '鐘舵��',
+ component: 'Select',
+ componentProps: {
+ allowClear: true,
+ options: SN_STATUS_OPTIONS,
+ placeholder: '璇烽�夋嫨鐘舵��',
+ },
+ },
+ ];
+}
+
+/** 鍦ㄥ簱鍗曚欢鍒楄〃鐨勫瓧娈� */
+export function useInStockGridColumns(): VxeTableGridOptions<MesWmSnApi.Sn>['columns'] {
+ return [
+ {
+ field: 'code',
+ title: 'SN 鐮�',
+ minWidth: 180,
+ },
+ {
+ field: 'itemCode',
+ title: '鐗╂枡缂栫爜',
+ minWidth: 120,
+ },
+ {
+ field: 'itemName',
+ title: '鐗╂枡鍚嶇О',
+ minWidth: 150,
+ },
+ {
+ field: 'specification',
+ title: '瑙勬牸鍨嬪彿',
+ minWidth: 120,
+ },
+ {
+ field: 'unitName',
+ title: '鍗曚綅',
+ width: 80,
+ },
+ {
+ field: 'batchCode',
+ title: '鎵规鍙�',
+ minWidth: 120,
+ },
+ {
+ field: 'status',
+ title: '鐘舵��',
+ width: 90,
+ slots: { default: 'status' },
+ },
+ {
+ field: 'warehouseId',
+ title: '浠撳簱',
+ minWidth: 140,
+ slots: { default: 'locations' },
+ },
+ {
+ field: 'createTime',
+ title: '鐢熸垚鏃堕棿',
+ width: 180,
+ formatter: 'formatDateTime',
+ },
+ {
+ title: '鎿嶄綔',
+ width: 140,
+ fixed: 'right',
+ slots: { default: 'actions' },
+ },
+ ];
+}
+
+/** SN 鐮佸叆搴撶櫥璁扮殑琛ㄥ崟 */
+export function useInStockFormSchema(
+ formApi?: VbenFormApi,
+): VbenFormSchema[] {
+ return [
+ {
+ fieldName: 'code',
+ label: 'SN 鐮�',
+ component: 'Input',
+ componentProps: {
+ placeholder: '鎵爜鏋壂鍏ユ垨杈撳叆 SN 鐮�',
+ },
+ rules: 'required',
+ },
+ {
+ fieldName: 'itemId',
+ label: '鐗╂枡',
+ component: markRaw(MdItemSelect),
+ componentProps: {
+ placeholder: '璇烽�夋嫨鐗╂枡锛堥』鍚敤搴忓垪鍙风鐞嗭級',
+ },
+ rules: 'selectRequired',
+ },
+ {
+ fieldName: 'warehouseId',
+ label: '浠撳簱',
+ component: markRaw(WmWarehouseSelect),
+ componentProps: {
+ onChange: () =>
+ formApi?.setValues({ areaId: undefined, locationId: undefined }),
+ placeholder: '璇烽�夋嫨浠撳簱',
+ },
+ rules: 'selectRequired',
+ },
+ {
+ fieldName: 'locationId',
+ label: '搴撳尯',
+ component: markRaw(WmWarehouseLocationSelect),
+ dependencies: {
+ triggerFields: ['warehouseId'],
+ show: (values) => !!values.warehouseId,
+ componentProps: (values) => ({
+ onChange: () => formApi?.setFieldValue('areaId', undefined),
+ placeholder: '璇烽�夋嫨搴撳尯',
+ warehouseId: values.warehouseId,
+ }),
+ },
+ rules: 'selectRequired',
+ },
+ {
+ fieldName: 'areaId',
+ label: '搴撲綅',
+ component: markRaw(WmWarehouseAreaSelect),
+ dependencies: {
+ triggerFields: ['locationId'],
+ show: (values) => !!values.locationId,
+ componentProps: (values) => ({
+ locationId: values.locationId,
+ placeholder: '璇烽�夋嫨搴撲綅',
+ }),
+ },
+ rules: 'selectRequired',
+ },
+ {
+ fieldName: 'batchCode',
+ label: '鎵规鍙�',
+ component: 'Input',
+ componentProps: {
+ allowClear: true,
+ placeholder: '璇疯緭鍏ユ壒娆″彿',
+ },
+ },
+ {
+ fieldName: 'remark',
+ label: '澶囨敞',
+ component: 'Textarea',
+ formItemClass: 'col-span-2',
+ componentProps: {
+ placeholder: '璇疯緭鍏ュ娉�',
+ rows: 2,
+ },
+ },
+ ];
+}
+
+/** SN 鐮佸嚭搴撴牳閿�鐨勮〃鍗� */
+export function useOutStockFormSchema(): VbenFormSchema[] {
+ return [
+ {
+ fieldName: 'code',
+ label: 'SN 鐮�',
+ component: 'Input',
+ componentProps: {
+ placeholder: '鎵爜鏋壂鍏ユ垨杈撳叆 SN 鐮�',
+ },
+ rules: 'required',
+ },
+ {
+ fieldName: 'itemId',
+ label: '鐗╂枡',
+ component: markRaw(MdItemSelect),
+ componentProps: {
+ placeholder: '璇烽�夋嫨鐗╂枡',
+ },
+ rules: 'selectRequired',
+ },
+ {
+ fieldName: 'remark',
+ label: '澶囨敞',
+ component: 'Textarea',
+ formItemClass: 'col-span-2',
+ componentProps: {
+ placeholder: '璇疯緭鍏ュ娉�',
+ rows: 2,
+ },
+ },
+ ];
+}
+
+/** SN 鐮佸崟浠惰鎯呯殑鎻忚堪瀛楁 */
+export function useSnDetailSchema(): DescriptionItemSchema[] {
+ return [
+ {
+ field: 'code',
+ label: 'SN 鐮�',
+ render: (value) => value || '-',
+ },
+ {
+ field: 'itemCode',
+ label: '鐗╂枡缂栫爜',
+ render: (value) => value || '-',
+ },
+ {
+ field: 'itemName',
+ label: '鐗╂枡鍚嶇О',
+ render: (value) => value || '-',
+ },
+ {
+ field: 'batchCode',
+ label: '鎵规鍙�',
+ render: (value) => value || '-',
+ },
+ {
+ field: 'status',
+ label: '鐘舵��',
+ render: (value) =>
+ value === MesWmSnStatusEnum.OUT_STOCK
+ ? '宸插嚭搴�'
+ : value === MesWmSnStatusEnum.IN_STOCK
+ ? '鍦ㄥ簱'
+ : '-',
+ },
+ {
+ field: 'warehouseId',
+ label: '鍦ㄥ簱浣嶇疆',
+ slot: 'location',
+ },
+ {
+ field: 'lastTransactionTypeName',
+ label: '鏈�杩戞祦姘�',
+ slot: 'lastTransaction',
+ },
+ {
+ field: 'lastTransactionTime',
+ label: '鏈�杩戞祦姘存椂闂�',
+ render: (value) => formatDateTime(value) || '-',
+ },
+ ];
+}
--
Gitblit v1.9.3