fix: support bit sample defaults in product form

besure_bit
ck-chenkang 3 weeks ago
parent a4c2ccac74
commit 9954bceaa8

@ -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 // 保质期天数

@ -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)

@ -196,6 +196,35 @@
</el-radio-group>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="是否样品" prop="isSample">
<el-switch v-model="formData.isSample" />
</el-form-item>
</el-col>
<template v-if="formData.isSample">
<el-col :span="8">
<el-form-item label="样品分类" prop="sampleCategory">
<el-select v-model="formData.sampleCategory" clearable placeholder="请选择样品分类" class="w-1/1">
<el-option
v-for="dict in getStrDictOptions(DICT_TYPE.BIT_SAMPLE_CATEGORY)"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="所属事业部" prop="bizUnit">
<el-input v-model="formData.bizUnit" placeholder="请输入所属事业部" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="客户名称" prop="customerName">
<el-input v-model="formData.customerName" placeholder="请输入客户名称" />
</el-form-item>
</el-col>
</template>
<el-col v-if="formType === 'update'" :span="24">
<div class="flex items-start gap-20px">
<el-form-item :label="t('FactoryModeling.ProductInformation.qrcode')" prop="qrcodeUrl" class="flex-1">
@ -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<any[]>([])
let openRequestId = 0
const open = async (type: string, id?: number) => {
const open = async (type: string, id?: number, defaultData?: Record<string, any>) => {
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,

Loading…
Cancel
Save