From 9954bceaa81597276b4bf4b925647a6359570fb9 Mon Sep 17 00:00:00 2001 From: ck-chenkang Date: Mon, 22 Jun 2026 16:53:34 +0800 Subject: [PATCH] fix: support bit sample defaults in product form --- src/api/erp/product/product/index.ts | 5 ++ src/views/erp/bitwms/sample/index.vue | 9 +++- src/views/erp/product/product/ProductForm.vue | 51 +++++++++++++++++-- 3 files changed, 61 insertions(+), 4 deletions(-) diff --git a/src/api/erp/product/product/index.ts b/src/api/erp/product/product/index.ts index 38eaa599..9bf56b8a 100644 --- a/src/api/erp/product/product/index.ts +++ b/src/api/erp/product/product/index.ts @@ -14,6 +14,11 @@ export interface ProductVO { unitId: number // 单位编号 unitName?: string // 单位名字 status: number // 产品状态 + isSample?: boolean // 是否样品 + sampleCategory?: string // 样品分类 + bizUnit?: string // 所属事业部 + customerId?: number // 客户编号 + customerName?: string // 客户名称 standard: string // 产品规格 remark: string // 产品备注 expiryDay: number // 保质期天数 diff --git a/src/views/erp/bitwms/sample/index.vue b/src/views/erp/bitwms/sample/index.vue index 44a6832d..57fa9fa2 100644 --- a/src/views/erp/bitwms/sample/index.vue +++ b/src/views/erp/bitwms/sample/index.vue @@ -129,7 +129,14 @@ const loadSampleLabel = async (id: number) => await BitWmsApi.getSampleLabel(id) const openProductForm = async (type: 'create' | 'update' | 'detail', id?: number) => { formVisible.value = true await nextTick() - formRef.value.open(type, id) + const defaultData = + type === 'create' + ? { + isSample: true, + bizUnit: 'BIT' + } + : undefined + formRef.value.open(type, id, defaultData) } const openProductCreate = () => openProductForm('create') const openProductEdit = (id: number) => openProductForm('update', id) diff --git a/src/views/erp/product/product/ProductForm.vue b/src/views/erp/product/product/ProductForm.vue index 3899508d..4d66fb59 100644 --- a/src/views/erp/product/product/ProductForm.vue +++ b/src/views/erp/product/product/ProductForm.vue @@ -196,6 +196,35 @@ + + + + + +
@@ -405,7 +434,7 @@ import { PackagingSchemeApi } from '@/api/erp/stock/packagingScheme' import { SupplierApi } from '@/api/erp/purchase/supplier' import { CommonStatusEnum } from '@/utils/constants' import { defaultProps, handleTree } from '@/utils/tree' -import { DICT_TYPE, getIntDictOptions } from '@/utils/dict' +import { DICT_TYPE, getIntDictOptions, getStrDictOptions } from '@/utils/dict' /** ERP 产品 表单 */ defineOptions({ name: 'ProductForm' }) @@ -460,6 +489,11 @@ const formData = ref({ categoryId: undefined, unitId: undefined, status: undefined, + isSample: false, + sampleCategory: undefined, + bizUnit: undefined, + customerId: undefined, + customerName: undefined, standard: undefined, remark: undefined, expiryDay: undefined, @@ -934,14 +968,20 @@ const supplierList = ref([]) let openRequestId = 0 -const open = async (type: string, id?: number) => { +const open = async (type: string, id?: number, defaultData?: Record) => { const currentOpenId = ++openRequestId dialogTitle.value = t('action.' + type) formType.value = type resetForm() if (!id) { + if (defaultData) { + formData.value = { + ...formData.value, + ...defaultData + } + } const typeOptions = getIntDictOptions(DICT_TYPE.MATERIAL_CLASSIFICATION_TYPE) - if (typeOptions.length > 0) { + if (formData.value.categoryType === undefined && typeOptions.length > 0) { formData.value.categoryType = typeOptions[0].value } } @@ -1125,6 +1165,11 @@ const resetForm = () => { categoryId: undefined, unitId: undefined, status: CommonStatusEnum.ENABLE, + isSample: false, + sampleCategory: undefined, + bizUnit: undefined, + customerId: undefined, + customerName: undefined, standard: undefined, remark: undefined, expiryDay: undefined,