|
|
|
|
@ -31,6 +31,19 @@
|
|
|
|
|
</el-row>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="12">
|
|
|
|
|
<el-form-item :label="t('FactoryModeling.ProductInformation.dialogCategoryTypeLabel')" prop="categoryType">
|
|
|
|
|
<el-radio-group v-model="formData.categoryType" @change="handleCategoryTypeChange">
|
|
|
|
|
<el-radio
|
|
|
|
|
v-for="dict in getIntDictOptions(DICT_TYPE.MATERIAL_CLASSIFICATION_TYPE)"
|
|
|
|
|
:key="dict.value"
|
|
|
|
|
:label="dict.value"
|
|
|
|
|
>
|
|
|
|
|
{{ dict.label }}
|
|
|
|
|
</el-radio>
|
|
|
|
|
</el-radio-group>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="12">
|
|
|
|
|
<el-form-item :label="t('FactoryModeling.ProductInformation.dialogNameLabel')" prop="name">
|
|
|
|
|
<el-input v-model="formData.name" :placeholder="t('FactoryModeling.ProductInformation.dialogNamePlaceholder')" />
|
|
|
|
|
@ -253,6 +266,7 @@ const formData = ref({
|
|
|
|
|
isCode: undefined,
|
|
|
|
|
qrcodeUrl: undefined,
|
|
|
|
|
templateJson: undefined,
|
|
|
|
|
categoryType: undefined,
|
|
|
|
|
categoryId: undefined,
|
|
|
|
|
unitId: undefined,
|
|
|
|
|
status: undefined,
|
|
|
|
|
@ -432,6 +446,7 @@ const validateBarCode = (_rule, value, callback) => {
|
|
|
|
|
callback()
|
|
|
|
|
}
|
|
|
|
|
const formRules = reactive({
|
|
|
|
|
categoryType: [{ required: true, message: t('FactoryModeling.ProductInformation.validatorCategoryTypeRequired'), trigger: 'change' }],
|
|
|
|
|
name: [{ required: true, message: t('FactoryModeling.ProductInformation.validatorNameRequired'), trigger: 'blur' }],
|
|
|
|
|
barCode: [{ validator: validateBarCode, trigger: ['blur', 'change'] }],
|
|
|
|
|
categoryId: [{ required: true, message: t('FactoryModeling.ProductInformation.validatorCategoryRequired'), trigger: 'blur' }],
|
|
|
|
|
@ -449,9 +464,12 @@ const open = async (type: string, id?: number) => {
|
|
|
|
|
dialogTitle.value = t('action.' + type)
|
|
|
|
|
formType.value = type
|
|
|
|
|
resetForm()
|
|
|
|
|
const categoryData = await ProductCategoryApi.getProductCategorySimpleList()
|
|
|
|
|
categoryList.value = handleTree(categoryData, 'id', 'parentId')
|
|
|
|
|
unitList.value = await ProductUnitApi.getProductUnitSimpleList()
|
|
|
|
|
if (!id) {
|
|
|
|
|
const typeOptions = getIntDictOptions(DICT_TYPE.MATERIAL_CLASSIFICATION_TYPE)
|
|
|
|
|
if (typeOptions.length > 0) {
|
|
|
|
|
formData.value.categoryType = typeOptions[0].value
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (id) {
|
|
|
|
|
formLoading.value = true
|
|
|
|
|
try {
|
|
|
|
|
@ -485,6 +503,9 @@ const open = async (type: string, id?: number) => {
|
|
|
|
|
formLoading.value = false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
const categoryData = await ProductCategoryApi.getProductCategorySimpleList(formData.value.categoryType)
|
|
|
|
|
categoryList.value = handleTree(categoryData, 'id', 'parentId')
|
|
|
|
|
unitList.value = await ProductUnitApi.getProductUnitSimpleList()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
defineExpose({ open })
|
|
|
|
|
@ -507,6 +528,12 @@ const handleCodeAutoChange = (value: boolean) => {
|
|
|
|
|
formRef.value?.clearValidate('barCode')
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const handleCategoryTypeChange = async () => {
|
|
|
|
|
formData.value.categoryId = undefined
|
|
|
|
|
const categoryData = await ProductCategoryApi.getProductCategorySimpleList(formData.value.categoryType)
|
|
|
|
|
categoryList.value = handleTree(categoryData, 'id', 'parentId')
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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))}`
|
|
|
|
|
@ -572,6 +599,7 @@ const resetForm = () => {
|
|
|
|
|
barCode: undefined,
|
|
|
|
|
isCode: true,
|
|
|
|
|
qrcodeUrl: undefined,
|
|
|
|
|
categoryType: undefined,
|
|
|
|
|
categoryId: undefined,
|
|
|
|
|
unitId: undefined,
|
|
|
|
|
status: CommonStatusEnum.ENABLE,
|
|
|
|
|
|