|
|
|
@ -52,7 +52,8 @@
|
|
|
|
<el-col :span="12">
|
|
|
|
<el-col :span="12">
|
|
|
|
<el-form-item :label="t('FactoryModeling.ProductInformation.dialogUnitLabel')" prop="unitId">
|
|
|
|
<el-form-item :label="t('FactoryModeling.ProductInformation.dialogUnitLabel')" prop="unitId">
|
|
|
|
<el-select v-model="formData.unitId" clearable
|
|
|
|
<el-select v-model="formData.unitId" clearable
|
|
|
|
:placeholder="t('FactoryModeling.ProductInformation.dialogUnitPlaceholder')" class="w-1/1">
|
|
|
|
:placeholder="t('FactoryModeling.ProductInformation.dialogUnitPlaceholder')" class="w-1/1"
|
|
|
|
|
|
|
|
@change="validatePurchaseUnitFields">
|
|
|
|
<el-option v-for="unit in unitList" :key="unit.id" :label="getProductUnitName(unit)" :value="unit.id" />
|
|
|
|
<el-option v-for="unit in unitList" :key="unit.id" :label="getProductUnitName(unit)" :value="unit.id" />
|
|
|
|
<template #footer>
|
|
|
|
<template #footer>
|
|
|
|
<div v-if="!isAddingUnit" class="px-10px py-6px">
|
|
|
|
<div v-if="!isAddingUnit" class="px-10px py-6px">
|
|
|
|
@ -99,7 +100,8 @@
|
|
|
|
<el-col v-if="formData.categoryType === 2 || formData.categoryType === 3" :span="12">
|
|
|
|
<el-col v-if="formData.categoryType === 2 || formData.categoryType === 3" :span="12">
|
|
|
|
<el-form-item :label="t('FactoryModeling.ProductInformation.dialogPurchaseUnitConvertLabel')"
|
|
|
|
<el-form-item :label="t('FactoryModeling.ProductInformation.dialogPurchaseUnitConvertLabel')"
|
|
|
|
prop="purchaseUnitConvertQuantity">
|
|
|
|
prop="purchaseUnitConvertQuantity">
|
|
|
|
<el-input-number v-model="formData.purchaseUnitConvertQuantity" :min="0" :step="0.01" class="!w-1/1" />
|
|
|
|
<el-input-number v-model="formData.purchaseUnitConvertQuantity" :min="0" :step="0.01" class="!w-1/1"
|
|
|
|
|
|
|
|
@change="validatePurchaseUnitFields" />
|
|
|
|
<div class="form-item-tip">{{ purchaseUnitConvertTipText }}</div>
|
|
|
|
<div class="form-item-tip">{{ purchaseUnitConvertTipText }}</div>
|
|
|
|
</el-form-item>
|
|
|
|
</el-form-item>
|
|
|
|
</el-col>
|
|
|
|
</el-col>
|
|
|
|
@ -642,12 +644,40 @@ const validateSuppliers = (_rule, value, callback) => {
|
|
|
|
callback()
|
|
|
|
callback()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const isMaterialOrSparePart = () => formData.value.categoryType === 2 || formData.value.categoryType === 3
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const hasValue = (value: unknown) => value !== undefined && value !== null && value !== ''
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const validateInventoryUnit = (_rule, value, callback) => {
|
|
|
|
|
|
|
|
if (!isMaterialOrSparePart()) {
|
|
|
|
|
|
|
|
callback()
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((hasValue(formData.value.purchaseUnitId) || hasValue(formData.value.purchaseUnitConvertQuantity)) && !hasValue(value)) {
|
|
|
|
|
|
|
|
callback(new Error(t('FactoryModeling.ProductInformation.validatorUnitRequired')))
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
callback()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const validatePurchaseUnit = (_rule, value, callback) => {
|
|
|
|
|
|
|
|
if (isMaterialOrSparePart() && hasValue(formData.value.purchaseUnitConvertQuantity) && !hasValue(value)) {
|
|
|
|
|
|
|
|
callback(new Error(t('FactoryModeling.ProductInformation.validatorPurchaseUnitRequired')))
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
callback()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const validatePurchaseUnitConvertQuantity = (_rule, value, callback) => {
|
|
|
|
const validatePurchaseUnitConvertQuantity = (_rule, value, callback) => {
|
|
|
|
if (formData.value.categoryType !== 2 && formData.value.categoryType !== 3) {
|
|
|
|
if (formData.value.categoryType !== 2 && formData.value.categoryType !== 3) {
|
|
|
|
callback()
|
|
|
|
callback()
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (value === undefined || value === null || value === '') {
|
|
|
|
if (!hasValue(value)) {
|
|
|
|
|
|
|
|
if (!hasValue(formData.value.purchaseUnitId)) {
|
|
|
|
|
|
|
|
callback()
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
}
|
|
|
|
callback(new Error(t('FactoryModeling.ProductInformation.validatorPurchaseUnitConvertRequired')))
|
|
|
|
callback(new Error(t('FactoryModeling.ProductInformation.validatorPurchaseUnitConvertRequired')))
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -658,6 +688,10 @@ const validatePurchaseUnitConvertQuantity = (_rule, value, callback) => {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
callback()
|
|
|
|
callback()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const validatePurchaseUnitFields = () => {
|
|
|
|
|
|
|
|
formRef.value?.validateField(['unitId', 'purchaseUnitId', 'purchaseUnitConvertQuantity']).catch(() => undefined)
|
|
|
|
|
|
|
|
}
|
|
|
|
// 包装方案弹框相关
|
|
|
|
// 包装方案弹框相关
|
|
|
|
const packagingSchemeDialogVisible = ref(false)
|
|
|
|
const packagingSchemeDialogVisible = ref(false)
|
|
|
|
const packagingSchemeDialogLoading = ref(false)
|
|
|
|
const packagingSchemeDialogLoading = ref(false)
|
|
|
|
@ -911,12 +945,12 @@ const formRules = reactive({
|
|
|
|
name: [{ required: true, message: t('FactoryModeling.ProductInformation.validatorNameRequired'), trigger: 'blur' }],
|
|
|
|
name: [{ required: true, message: t('FactoryModeling.ProductInformation.validatorNameRequired'), trigger: 'blur' }],
|
|
|
|
barCode: [{ validator: validateBarCode, trigger: ['blur', 'change'] }],
|
|
|
|
barCode: [{ validator: validateBarCode, trigger: ['blur', 'change'] }],
|
|
|
|
categoryId: [{ required: true, message: t('FactoryModeling.ProductInformation.validatorCategoryRequired'), trigger: 'blur' }],
|
|
|
|
categoryId: [{ required: true, message: t('FactoryModeling.ProductInformation.validatorCategoryRequired'), trigger: 'blur' }],
|
|
|
|
unitId: [{ required: true, message: t('FactoryModeling.ProductInformation.validatorUnitRequired'), trigger: 'blur' }],
|
|
|
|
unitId: [{ validator: validateInventoryUnit, trigger: 'change' }],
|
|
|
|
status: [{ required: true, message: t('FactoryModeling.ProductInformation.validatorStatusRequired'), trigger: 'blur' }],
|
|
|
|
status: [{ required: true, message: t('FactoryModeling.ProductInformation.validatorStatusRequired'), trigger: 'blur' }],
|
|
|
|
packagingSchemes: [{ required: true, validator: validatePackagingSchemes, trigger: ['change', 'blur'] }],
|
|
|
|
packagingSchemes: [{ required: true, validator: validatePackagingSchemes, trigger: ['change', 'blur'] }],
|
|
|
|
suppliers: [{ required: true, validator: validateSuppliers, trigger: ['change', 'blur'] }],
|
|
|
|
suppliers: [{ required: true, validator: validateSuppliers, trigger: ['change', 'blur'] }],
|
|
|
|
purchaseUnitId: [{ required: true, message: t('FactoryModeling.ProductInformation.validatorPurchaseUnitRequired'), trigger: 'change' }],
|
|
|
|
purchaseUnitId: [{ validator: validatePurchaseUnit, trigger: 'change' }],
|
|
|
|
purchaseUnitConvertQuantity: [{ required: true, validator: validatePurchaseUnitConvertQuantity, trigger: ['blur', 'change'] }]
|
|
|
|
purchaseUnitConvertQuantity: [{ validator: validatePurchaseUnitConvertQuantity, trigger: ['blur', 'change'] }]
|
|
|
|
})
|
|
|
|
})
|
|
|
|
const formRef = ref()
|
|
|
|
const formRef = ref()
|
|
|
|
const categoryList = ref<ProductCategoryVO[]>([])
|
|
|
|
const categoryList = ref<ProductCategoryVO[]>([])
|
|
|
|
@ -1033,10 +1067,11 @@ const handleCategoryTypeChange = async () => {
|
|
|
|
const handlePurchaseUnitChange = (val: any) => {
|
|
|
|
const handlePurchaseUnitChange = (val: any) => {
|
|
|
|
if (!val) {
|
|
|
|
if (!val) {
|
|
|
|
formData.value.purchaseUnitName = undefined
|
|
|
|
formData.value.purchaseUnitName = undefined
|
|
|
|
return
|
|
|
|
} else {
|
|
|
|
|
|
|
|
const unit = unitList.value.find((u: any) => u.id === val)
|
|
|
|
|
|
|
|
formData.value.purchaseUnitName = unit?.name ?? undefined
|
|
|
|
}
|
|
|
|
}
|
|
|
|
const unit = unitList.value.find((u: any) => u.id === val)
|
|
|
|
validatePurchaseUnitFields()
|
|
|
|
formData.value.purchaseUnitName = unit?.name ?? undefined
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const isAddingUnit = ref(false)
|
|
|
|
const isAddingUnit = ref(false)
|
|
|
|
|