|
|
|
|
@ -66,7 +66,7 @@
|
|
|
|
|
<el-form-item :label="t('FactoryModeling.ProductInformation.dialogUnitLabel')" prop="unitId">
|
|
|
|
|
<el-select v-model="formData.unitId" clearable :placeholder="t('FactoryModeling.ProductInformation.dialogUnitPlaceholder')" class="w-1/1">
|
|
|
|
|
<el-option
|
|
|
|
|
v-for="unit in unitList"
|
|
|
|
|
v-for="unit in inventoryUnitOptions"
|
|
|
|
|
:key="unit.id"
|
|
|
|
|
:label="unit.name"
|
|
|
|
|
:value="unit.id"
|
|
|
|
|
@ -165,6 +165,24 @@
|
|
|
|
|
<el-input v-model="formData.brand" :placeholder="t('FactoryModeling.ProductInformation.dialogBrandPlaceholder')" />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col v-if="formData.categoryType === 2 || formData.categoryType === 3" :span="12">
|
|
|
|
|
<el-form-item :label="t('FactoryModeling.ProductInformation.dialogPurchaseUnitLabel')" prop="purchaseUnitId">
|
|
|
|
|
<el-select v-model="formData.purchaseUnitId" clearable :placeholder="t('FactoryModeling.ProductInformation.dialogUnitPlaceholder')" class="w-1/1" @change="handlePurchaseUnitChange">
|
|
|
|
|
<el-option
|
|
|
|
|
v-for="unit in purchaseUnitOptions"
|
|
|
|
|
:key="unit.id"
|
|
|
|
|
:label="unit.name"
|
|
|
|
|
:value="unit.id"
|
|
|
|
|
/>
|
|
|
|
|
</el-select>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col v-if="formData.categoryType === 2 || formData.categoryType === 3" :span="12">
|
|
|
|
|
<el-form-item :label="t('FactoryModeling.ProductInformation.dialogPurchaseUnitConvertLabel')" prop="purchaseUnitConvertQuantity">
|
|
|
|
|
<el-input-number v-model="formData.purchaseUnitConvertQuantity" :min="1" :precision="0" class="!w-1/1" />
|
|
|
|
|
<div class="form-item-tip">{{ purchaseUnitConvertTipText }}</div>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="12">
|
|
|
|
|
<el-form-item :label="t('FactoryModeling.ProductInformation.dialogStatusLabel')" prop="status">
|
|
|
|
|
<el-radio-group v-model="formData.status">
|
|
|
|
|
@ -458,7 +476,10 @@ const formData = ref({
|
|
|
|
|
purchaseCycle: undefined as number | undefined,
|
|
|
|
|
brand: undefined as string | undefined,
|
|
|
|
|
images: undefined as string | undefined,
|
|
|
|
|
sparePartLevel: undefined as number | undefined
|
|
|
|
|
sparePartLevel: undefined as number | undefined,
|
|
|
|
|
purchaseUnitId: undefined as string | undefined,
|
|
|
|
|
purchaseUnitName: undefined as string | undefined,
|
|
|
|
|
purchaseUnitConvertQuantity: undefined as number | undefined
|
|
|
|
|
})
|
|
|
|
|
const selectedDeviceRows = ref<any[]>([])
|
|
|
|
|
const selectedMoldRows = ref<any[]>([])
|
|
|
|
|
@ -884,12 +905,30 @@ const formRules = reactive({
|
|
|
|
|
categoryId: [{ required: true, message: t('FactoryModeling.ProductInformation.validatorCategoryRequired'), trigger: 'blur' }],
|
|
|
|
|
unitId: [{ required: true, message: t('FactoryModeling.ProductInformation.validatorUnitRequired'), trigger: 'blur' }],
|
|
|
|
|
status: [{ required: true, message: t('FactoryModeling.ProductInformation.validatorStatusRequired'), trigger: 'blur' }],
|
|
|
|
|
packagingSchemes: [{ validator: validatePackagingSchemes, trigger: 'change' }],
|
|
|
|
|
suppliers: [{ validator: validateSuppliers, trigger: 'change' }]
|
|
|
|
|
packagingSchemes: [{ required: true, validator: validatePackagingSchemes, trigger: ['change', 'blur'] }],
|
|
|
|
|
suppliers: [{ required: true, validator: validateSuppliers, trigger: ['change', 'blur'] }],
|
|
|
|
|
purchaseUnitId: [{ required: true, message: t('FactoryModeling.ProductInformation.validatorPurchaseUnitRequired'), trigger: 'change' }],
|
|
|
|
|
purchaseUnitConvertQuantity: [{ required: true, message: t('FactoryModeling.ProductInformation.validatorPurchaseUnitConvertRequired'), trigger: 'blur' }]
|
|
|
|
|
})
|
|
|
|
|
const formRef = ref()
|
|
|
|
|
const categoryList = ref<ProductCategoryVO[]>([])
|
|
|
|
|
const unitList = ref<ProductUnitVO[]>([])
|
|
|
|
|
const inventoryUnitOptions = computed(() => {
|
|
|
|
|
if (!formData.value.purchaseUnitId) return unitList.value
|
|
|
|
|
return unitList.value.filter((u: any) => u.id !== formData.value.purchaseUnitId)
|
|
|
|
|
})
|
|
|
|
|
const purchaseUnitOptions = computed(() => {
|
|
|
|
|
if (!formData.value.unitId) return unitList.value
|
|
|
|
|
return unitList.value.filter((u: any) => u.id !== formData.value.unitId)
|
|
|
|
|
})
|
|
|
|
|
const purchaseUnitConvertTipText = computed(() => {
|
|
|
|
|
const inventoryUnitName = unitList.value.find((u: any) => u.id === formData.value.unitId)?.name
|
|
|
|
|
const purchaseUnitName = unitList.value.find((u: any) => u.id === formData.value.purchaseUnitId)?.name
|
|
|
|
|
const qty = formData.value.purchaseUnitConvertQuantity
|
|
|
|
|
const base = t('FactoryModeling.ProductInformation.dialogPurchaseUnitConvertTip')
|
|
|
|
|
if (!inventoryUnitName || !purchaseUnitName || !qty) return base
|
|
|
|
|
return `${base}(${inventoryUnitName} = ${qty} × ${purchaseUnitName})`
|
|
|
|
|
})
|
|
|
|
|
const packagingSchemeList = ref<any[]>([])
|
|
|
|
|
const supplierList = ref<any[]>([])
|
|
|
|
|
|
|
|
|
|
@ -981,10 +1020,22 @@ const handleCategoryTypeChange = async () => {
|
|
|
|
|
formData.value.purchaseCycle = undefined
|
|
|
|
|
formData.value.brand = undefined
|
|
|
|
|
formData.value.sparePartLevel = undefined
|
|
|
|
|
formData.value.purchaseUnitId = undefined
|
|
|
|
|
formData.value.purchaseUnitName = undefined
|
|
|
|
|
formData.value.purchaseUnitConvertQuantity = undefined
|
|
|
|
|
const categoryData = await ProductCategoryApi.getProductCategorySimpleList(formData.value.categoryType)
|
|
|
|
|
categoryList.value = handleTree(categoryData, 'id', 'parentId')
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const handlePurchaseUnitChange = (val: any) => {
|
|
|
|
|
if (!val) {
|
|
|
|
|
formData.value.purchaseUnitName = undefined
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
const unit = unitList.value.find((u: any) => u.id === val)
|
|
|
|
|
formData.value.purchaseUnitName = unit?.name ?? undefined
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const getQrcodeRefreshUrl = () => {
|
|
|
|
|
if (!formData.value.id || !formData.value.barCode) return ''
|
|
|
|
|
return `/erp/product/regenerate-code?id=${formData.value.id}&code=${encodeURIComponent(String(formData.value.barCode))}`
|
|
|
|
|
@ -1088,7 +1139,10 @@ const resetForm = () => {
|
|
|
|
|
fragileFlag: undefined,
|
|
|
|
|
purchaseCycle: undefined,
|
|
|
|
|
brand: undefined,
|
|
|
|
|
sparePartLevel: undefined
|
|
|
|
|
sparePartLevel: undefined,
|
|
|
|
|
purchaseUnitId: undefined,
|
|
|
|
|
purchaseUnitName: undefined,
|
|
|
|
|
purchaseUnitConvertQuantity: undefined
|
|
|
|
|
}
|
|
|
|
|
selectedDeviceRows.value = []
|
|
|
|
|
selectedMoldRows.value = []
|
|
|
|
|
@ -1170,4 +1224,11 @@ watch(
|
|
|
|
|
padding: 16px;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.form-item-tip {
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
color: var(--el-text-color-placeholder);
|
|
|
|
|
line-height: 1.4;
|
|
|
|
|
margin-top: 4px;
|
|
|
|
|
}
|
|
|
|
|
</style>
|
|
|
|
|
|