feat:产品物料信息-添加产品/物料类型分类

main
黄伟杰 1 week ago
parent e8d0130a17
commit f887843d41

@ -19,8 +19,8 @@ export const ProductCategoryApi = {
},
// 查询产品分类精简列表
getProductCategorySimpleList: async () => {
return await request.get({ url: `/erp/product-category/simple-list` })
getProductCategorySimpleList: async (type?: number) => {
return await request.get({ url: `/erp/product-category/simple-list`, params: { type } })
},
// 查询产品分类详情

@ -2055,6 +2055,7 @@ export default {
validatorNameRequired: 'Product name can not be empty',
validatorBarCodeRequired: 'Product barcode can not be empty',
validatorCategoryRequired: 'Product category id can not be empty',
validatorCategoryTypeRequired: 'Type can not be empty',
validatorUnitRequired: 'Unit id can not be empty',
validatorStatusRequired: 'Product status can not be empty'
},

@ -2894,6 +2894,7 @@ export default {
dialogBarCodePlaceholder: '请输入编码',
dialogNameLabel: '名称',
dialogNamePlaceholder: '请输入名称',
dialogCategoryTypeLabel: '类型',
dialogCategoryLabel: '分类',
dialogCategoryPlaceholder: '请选择分类',
dialogUnitLabel: '单位',
@ -2920,6 +2921,7 @@ export default {
validatorNameRequired: '产品名称不能为空',
validatorBarCodeRequired: '产品条码不能为空',
validatorCategoryRequired: '产品分类编号不能为空',
validatorCategoryTypeRequired: '类型不能为空',
validatorUnitRequired: '单位编号不能为空',
validatorStatusRequired: '产品状态不能为空'
},

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

@ -33,8 +33,13 @@
</ContentWrap>
<ContentWrap>
<el-tabs v-model="activeName" @tab-click="handleTabClick">
<el-tab-pane v-for="item in parentList" :key="item.id" :label="item.name" :name="item.id.toString()" />
<el-tabs v-model="activeName" @tab-change="handleTabChange">
<el-tab-pane
v-for="dict in getIntDictOptions(DICT_TYPE.MATERIAL_CLASSIFICATION_TYPE)"
:key="dict.value"
:label="dict.label"
:name="String(dict.value)"
/>
</el-tabs>
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
<el-table-column :label="t('FactoryModeling.ProductInformation.tableBarCodeColumn')" align="center" prop="barCode"
@ -80,10 +85,8 @@
import { dateFormatter } from '@/utils/formatTime'
import download from '@/utils/download'
import { ProductApi, ProductVO } from '@/api/erp/product/product'
import { ProductCategoryApi, ProductCategoryVO } from '@/api/erp/product/category'
import ProductForm from './ProductForm.vue'
import { DICT_TYPE } from '@/utils/dict'
import { handleTree } from '@/utils/tree'
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
import BomForm from "@/views/mes/bom/BomForm.vue";
/** ERP 产品列表 */
@ -100,12 +103,11 @@ const queryParams = reactive({
pageSize: 10,
name: undefined,
barCode: undefined,
categoryId: undefined
categoryId: undefined,
categoryType: undefined
})
const queryFormRef = ref()
const exportLoading = ref(false)
const categoryList = ref<ProductCategoryVO[]>([])
const parentList = ref<ProductCategoryVO[]>([])
const formVisible = ref(false)
const formType = ref('')
@ -161,21 +163,17 @@ const handleExport = async () => {
}
onMounted(async () => {
queryParams.categoryId = 2
await getList()
const categoryData = await ProductCategoryApi.getProductCategorySimpleList()
categoryList.value = handleTree(categoryData, 'id', 'parentId')
for (let i = 0; i < categoryData.length; i++) {
if (categoryData[i].parentId === 0) {
parentList.value.push(categoryData[i]);
}
const typeOptions = getIntDictOptions(DICT_TYPE.MATERIAL_CLASSIFICATION_TYPE)
if (typeOptions.length > 0) {
activeName = String(typeOptions[0].value)
queryParams.categoryType = typeOptions[0].value
}
parentList.value.sort((a, b) => a.sort - b.sort);
await getList()
})
let activeName = '2'
const handleTabClick = (tab: TabsPaneContext) => {
queryParams.categoryId = tab.paneName
let activeName = ''
const handleTabChange = (name: string) => {
queryParams.categoryType = name ? Number(name) : undefined
handleQuery()
}

Loading…
Cancel
Save