feat(物料管理): 优化物料分类选择功能并简化物料类型显示

- 在物料分类表格中添加row-key属性以支持树形结构
- 新增获取物料分类名称下拉列表的API接口
- 将物料分类名称输入框改为下拉选择框
- 简化物料类型显示,使用字典标签替代长文本
- 预定义物料类型选项,避免硬编码
This commit is contained in:
Tom
2025-12-26 14:59:37 +08:00
parent fea9bb55ec
commit 05c185eec5
3 changed files with 49 additions and 6 deletions

View File

@@ -14,7 +14,9 @@
<el-input v-model="queryParams.materialName" placeholder="请输入物料名称" />
</el-form-item>
<el-form-item label="物料分类名称" prop="categoryName">
<el-input v-model="queryParams.categoryName" placeholder="请输入物料分类" />
<el-select v-model="value" filterable placeholder="请选择" @visible-change="handleCategoryNameChange">
<el-option v-for="item in categoryNameOptions" :key="item.value" :label="item.label" :value="item.value"> </el-option>
</el-select>
</el-form-item>
<el-form-item>
<el-button icon="search" type="primary" @click="handleQuery">{{ $t('btn.search') }}</el-button>
@@ -46,7 +48,7 @@
<el-table-column prop="categoryCode" label="物料分类编码" align="center" :show-overflow-tooltip="true" v-if="columns.showColumn('categoryCode')" />
<el-table-column prop="categoryName" label="物料分类名称" align="center" :show-overflow-tooltip="true" v-if="columns.showColumn('categoryName')" />
<el-table-column prop="unit" label="计量单位" align="center" :show-overflow-tooltip="true" v-if="columns.showColumn('unit')" />
<el-table-column prop="type" label="物料类型(原材料/半成品/产成品/打包材料/辅料)" align="center" v-if="columns.showColumn('type')">
<el-table-column prop="type" label="物料类型" align="center" v-if="columns.showColumn('type')">
<template #default="scope">
<dict-tag :options="options.typeOptions" :value="scope.row.type" />
</template>
@@ -129,7 +131,7 @@
</el-col>
<el-col :lg="12">
<el-form-item label="物料类型(原材料/半成品/产成品/打包材料/辅料)" prop="type">
<el-form-item label="物料类型" prop="type">
<el-select v-model="form.type" placeholder="请选择物料类型(原材料/半成品/产成品/打包材料/辅料)">
<el-option
v-for="item in options.typeOptions"
@@ -198,7 +200,7 @@
</template>
<script setup name="mmmaterial">
import { listMmMaterial, addMmMaterial, delMmMaterial, updateMmMaterial, getMmMaterial } from '@/api/materialManagement/productionMaterial/mmmaterial.js'
import { listMmMaterial, addMmMaterial, delMmMaterial, updateMmMaterial, getMmMaterial, getMmMaterialCategoryName } from '@/api/materialManagement/productionMaterial/mmmaterial.js'
const { proxy } = getCurrentInstance()
const ids = ref([])
const loading = ref(false)
@@ -210,7 +212,7 @@ const queryParams = reactive({
sortType: 'asc',
materialCode: '',
materialName: '',
categoryName: '',
categoryName: ''
})
const columns = ref([
{ visible: true, align: 'center', type: '', prop: 'id', label: '主键ID' },
@@ -290,7 +292,22 @@ const state = reactive({
},
options: {
// 物料类型(原材料/半成品/产成品/打包材料/辅料) 选项列表 格式 eg:{ dictLabel: '标签', dictValue: '0'}
typeOptions: []
typeOptions: [{
dictValue: '0',
dictLabel: '原材料'
},{
dictValue: '1',
dictLabel: '半成品'
},{
dictValue: '2',
dictLabel: '产成品'
},{
dictValue: '3',
dictLabel: '打包材料'
},{
dictValue: '4',
dictLabel: '辅料'
}]
}
})
@@ -388,6 +405,20 @@ function handleDelete(row) {
proxy.$modal.msgSuccess('删除成功')
})
}
// 物料分类名称下拉列表
const categoryNameOptions = reactive([])
// 物料分类名称下拉列表 可见性变化时触发
function handleCategoryNameChange(visible) {
if (visible) {
getMmMaterialCategoryName().then((res) => {
const { code, data } = res
if (code == 200) {
categoryNameOptions.value = data
}
})
}
}
handleQuery()
</script>

View File

@@ -23,6 +23,7 @@
<el-table
:data="dataList"
row-key="id"
v-loading="loading"
ref="table"
border