|
|
|
|
@ -22,8 +22,8 @@
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="12">
|
|
|
|
|
<el-form-item :label="t('MoldManagement.MoldBrandFormPage.productName')" prop="productId">
|
|
|
|
|
<el-select v-model="formData.productId" filterable clearable :placeholder="t('MoldManagement.MoldBrandFormPage.placeholderProduct')" class="w-1/1" @change="handleProductChange">
|
|
|
|
|
<el-form-item :label="t('MoldManagement.MoldBrandFormPage.productName')" prop="productIds">
|
|
|
|
|
<el-select v-model="formData.productIds" multiple filterable clearable :placeholder="t('MoldManagement.MoldBrandFormPage.placeholderProduct')" class="w-1/1" @change="handleProductChange">
|
|
|
|
|
<el-option v-for="item in productList" :key="item.id" :label="item.name" :value="item.id" />
|
|
|
|
|
</el-select>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
@ -153,7 +153,7 @@ const formRules = reactive({
|
|
|
|
|
code: [{ validator: validateCode, trigger: 'blur' }],
|
|
|
|
|
name: [{ required: true, message: t('MoldManagement.MoldBrandFormPage.validatorNameRequired'), trigger: 'blur' }],
|
|
|
|
|
moldType: [{ required: true, message: t('MoldManagement.MoldBrandFormPage.validatorNameRequired'), trigger: 'blur' }],
|
|
|
|
|
productId: [{ required: true, message: t('MoldManagement.MoldBrandFormPage.validatorProductRequired'), trigger: 'change' }],
|
|
|
|
|
productIds: [{ required: true, message: t('MoldManagement.MoldBrandFormPage.validatorProductRequired'), trigger: 'change' }],
|
|
|
|
|
moldSize: [{ required: true, message: t('MoldManagement.MoldBrandFormPage.validatorMoldSizeRequired'), trigger: 'blur' }],
|
|
|
|
|
isEnable: [{ required: true, message: t('MoldManagement.MoldBrandFormPage.validatorIsEnableRequired'), trigger: 'change' }]
|
|
|
|
|
})
|
|
|
|
|
@ -181,10 +181,11 @@ const resetForm = () => {
|
|
|
|
|
formRef.value?.resetFields()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const handleProductChange = (value?: number) => {
|
|
|
|
|
const current = productList.value.find((item) => item.id === value)
|
|
|
|
|
formData.value.productName = current?.name || ''
|
|
|
|
|
formData.value.productIds = value ? [value] : []
|
|
|
|
|
const handleProductChange = (value?: number[] | number) => {
|
|
|
|
|
const ids = Array.isArray(value) ? value : value ? [value] : []
|
|
|
|
|
formData.value.productIds = ids
|
|
|
|
|
const names = productList.value.filter((item) => ids.includes(item.id)).map((p) => p.name)
|
|
|
|
|
formData.value.productName = names.join(',')
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const open = async (type: string, id?: number) => {
|
|
|
|
|
@ -220,16 +221,12 @@ const emit = defineEmits(['success'])
|
|
|
|
|
const submitForm = async () => {
|
|
|
|
|
await formRef.value.validate()
|
|
|
|
|
formLoading.value = true
|
|
|
|
|
try {
|
|
|
|
|
handleProductChange(formData.value.productId)
|
|
|
|
|
try {
|
|
|
|
|
handleProductChange(formData.value.productIds)
|
|
|
|
|
const payload: MoldBrandVO = {
|
|
|
|
|
...formData.value,
|
|
|
|
|
version: addVersionPrefix(formData.value.version),
|
|
|
|
|
productIds: Array.isArray(formData.value.productIds)
|
|
|
|
|
? formData.value.productIds
|
|
|
|
|
: formData.value.productId
|
|
|
|
|
? [formData.value.productId]
|
|
|
|
|
: [],
|
|
|
|
|
productIds: Array.isArray(formData.value.productIds) ? formData.value.productIds : [],
|
|
|
|
|
isEnable: Boolean(formData.value.isEnable)
|
|
|
|
|
}
|
|
|
|
|
if (formType.value === 'create') {
|
|
|
|
|
|