opt:物料相关页面添加物料分类字段

This commit is contained in:
zds
2025-06-16 17:22:37 +08:00
parent 68da12a72a
commit 4eb0f8b060
5 changed files with 68 additions and 230 deletions

View File

@@ -89,7 +89,7 @@
</el-table>
<!--分页组件-->
<pagination />
<MaterDialog :dialog-show.sync="materShow" @setMaterValue="tableChanged" />
<MaterDialog :dialog-show.sync="materShow" :mater-opt-code="materType" @setMaterValue="tableChanged" />
</div>
</div>
</template>
@@ -142,6 +142,7 @@ export default {
del: ['admin', 'paper:del']
},
materShow: false,
materType: '',
rules: {
standard_weight: [
{ required: true, message: '标准重量不能为空', trigger: 'blur' }
@@ -159,6 +160,7 @@ export default {
},
async queryMater() {
this.materShow = true
this.materType = '7019,4822'
},
print() {
const _selectData = this.$refs.table.selection

View File

@@ -9,13 +9,21 @@
<span style="line-height:36px;text-align: center">物料类别</span>
</el-col>
<el-col :span="12">
<treeselect
<el-select
size="mini"
v-model="query.material_type_id"
:load-options="loadChildNodes"
:options="classes1"
style="width: 200px;"
placeholder="请选择"
/>
placeholder="全部"
clearable
class="filter-item"
@change="crud.toQuery"
>
<el-option
v-for="item in dict.material_type"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-col>
</el-row>
</el-col>
@@ -79,34 +87,23 @@
</el-col>
<el-col :span="8">
<el-form-item label="物料分类" prop="material_type_id">
<treeselect
<el-select
size="mini"
v-model="form.material_type_id"
:load-options="loadChildNodes"
:options="classes2"
style="width: 200px;"
placeholder="请选择"
/>
class="filter-item"
>
<el-option
v-for="item in dict.material_type"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="8">
<el-form-item label="产品系列">
<treeselect
v-model="form.product_series"
:options="classes3"
:auto-load-root-options="false"
:load-options="loadChildNodes"
style="width: 200px;"
placeholder="请选择"
/>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="静置时间" prop="standing_time">
<el-input-number v-model="form.standing_time" :controls="false" :min="0" label="分钟" style="width: 200px;" />
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="是否启用" prop="is_used">
<el-radio v-model="form.is_used" label="0">否</el-radio>
@@ -133,10 +130,10 @@
<el-table-column prop="material_name" label="物料名称" width="180" show-overflow-tooltip />
<el-table-column prop="material_spec" label="物料规格" width="140" />
<el-table-column prop="material_model" label="物料型号" />
<el-table-column prop="class_code" label="物料分类编码" width="120" />
<el-table-column prop="class_name" label="物料分类" width="140" />
<el-table-column prop="unit_name" label="计量单位" />
<el-table-column prop="standing_time" label="静置时间分钟" width="130px" />
<el-table-column prop="product_series_name" label="系列" />
<el-table-column label="启用" align="center" prop="is_used">
<template slot-scope="scope">
<el-switch
@@ -179,9 +176,6 @@ import rrOperation from '@crud/RR.operation'
import crudOperation from '@crud/CRUD.operation'
import udOperation from '@crud/UD.operation'
import pagination from '@crud/Pagination'
import Treeselect, { LOAD_CHILDREN_OPTIONS } from '@riophae/vue-treeselect'
import '@riophae/vue-treeselect/dist/vue-treeselect.css'
import crudClassstandard from '@/views/wms/basedata/master/customer/customerbase'
import crudMdPbMeasureunit from '@/views/wms/basedata/master/measure/mdPbMeasureunit'
const defaultForm = {
@@ -215,14 +209,13 @@ const defaultForm = {
is_used: null,
is_delete: null,
ext_id: null,
material_height_type: null,
product_series: null
}
export default {
name: 'Materialbase',
// 数据字典
dicts: ['is_used'],
components: { pagination, crudOperation, rrOperation, udOperation, Treeselect },
dicts: ['is_used', 'material_type'],
components: { pagination, crudOperation, rrOperation, udOperation },
mixins: [presenter(), header(), form(defaultForm), crud()],
cruds() {
return CRUD({
@@ -236,9 +229,6 @@ export default {
},
data() {
return {
classes1: [],
classes2: [],
classes3: [],
fullscreenLoading: false,
measure_unit: [],
productSeries: [],
@@ -262,104 +252,23 @@ export default {
is_used: [
{ required: true, message: '是否启用不能为空', trigger: 'blur' }
],
material_height_type: [
material_type_id: [
{ required: true, message: '不能为空', trigger: 'blur' }
]
}
}
},
created() {
this.initClass1()
this.initClass2()
this.initClass3()
},
methods: {
// 钩子在获取表格数据之前执行false 则代表不获取数据
[CRUD.HOOK.beforeRefresh]() {
return true
},
initClass1() {
const param = {
parent_class_code: '09'
}
crudClassstandard.getClassType(param).then(res => {
const data = res.content
this.buildTree(data)
this.classes1 = data
})
},
initClass2() {
const param = {
parent_class_code: '09'
}
crudClassstandard.getClassType(param).then(res => {
const data = res.content
this.buildTree(data)
this.classes2 = data
})
},
initClass3() {
const param = {
parent_class_code: '07'
}
crudClassstandard.getClassType(param).then(res => {
const data = res.content
this.buildTree(data)
this.classes3 = data
})
},
[CRUD.HOOK.beforeToCU](crud, form) {
crudMdPbMeasureunit.getUnit().then(res => {
this.measure_unit = res.content
})
// 物料标识为空,新增
if (!form.material_type_id) {
form.material_type_id = null // 必须为null否则会出现unknown
} else { // 更新
this.getSubTypes('02', form.material_type_id)
}
// 物料系列为空,新增
if (!form.product_series) {
form.product_series = null // 必须为null否则会出现unknown
} else { // 更新
this.getSubTypes('03', form.product_series)
}
},
getSubTypes(type, id) {
const that = this
crudClassstandard.getClassSuperior(id).then(res => {
const data = res.content
that.buildTree(data)
if (type == '02') {
that.classes2 = data
}
if (type == '03') {
that.classes3 = data
}
})
},
queryClassId() {
const param = {
'class_idStr': this.class_idStr
}
crudClassstandard.queryClassById(param).then(res => {
this.classes = res.content.map(obj => {
if (obj.hasChildren) {
obj.children = null
}
return obj
})
})
},
buildTree(classes) {
classes.forEach(data => {
if (data.children) {
this.buildTree(data.children)
}
if (data.hasChildren && !data.children) {
data.children = null // 重点代码
}
})
},
// 改变状态
changeEnabled(data, val) {
@@ -388,22 +297,6 @@ export default {
data.is_used = '0'
}
})
},
// 获取子节点数据
loadChildNodes({ action, parentNode, callback }) {
if (action === LOAD_CHILDREN_OPTIONS) {
crudClassstandard.getClass({ pid: parentNode.id }).then(res => {
parentNode.children = res.content.map(function(obj) {
if (obj.hasChildren) {
obj.children = null
}
return obj
})
setTimeout(() => {
callback()
}, 100)
})
}
}
}
}

View File

@@ -15,21 +15,12 @@
label-width="80px"
label-suffix=":"
>
<el-form-item label="物料类别">
<treeselect
v-model="query.material_type_id"
:load-options="loadClass"
:options="classes"
style="width: 200px;"
placeholder="选择物料类别"
/>
</el-form-item>
<el-form-item label="模糊搜索">
<el-input
v-model="query.search"
clearable
size="mini"
placeholder="编码、名称"
placeholder="可物料编码、物料名称"
@keyup.enter.native="crud.toQuery"
/>
</el-form-item>
@@ -79,13 +70,10 @@ import crudMaterialbase from '@/views/wms/basedata/master/material/materialbase'
import CRUD, { header, presenter } from '@crud/crud'
import rrOperation from '@crud/RR.operation'
import pagination from '@crud/Pagination'
import Treeselect, { LOAD_CHILDREN_OPTIONS } from '@riophae/vue-treeselect'
import '@riophae/vue-treeselect/dist/vue-treeselect.css'
import crudClassstandard from '@/views/wms/basedata/master/customer/customerbase'
export default {
name: 'MaterDtl',
components: { rrOperation, pagination, Treeselect },
components: { rrOperation, pagination },
cruds() {
return CRUD({ title: '物料', url: 'api/Materialbase', crudMethod: { ...crudMaterialbase }, optShow: {}})
},
@@ -102,15 +90,13 @@ export default {
},
materOptCode: {
type: String,
default: '00'
default: ''
}
},
data() {
return {
dialogVisible: false,
classes: [],
tableRadio: null,
class_idStr: null,
checkrow: null,
rows: []
}
@@ -130,28 +116,8 @@ export default {
return this.dict.label.product_series[row.product_series]
},
open() {
const param = {
'materOpt_code': this.materOptCode
}
crudMaterialbase.getMaterOptType(param).then(res => {
this.class_idStr = res.class_idStr
this.crud.query.class_idStr = res.class_idStr
this.crud.toQuery()
this.queryClassId()
})
},
queryClassId() {
const param = {
'class_idStr': this.class_idStr
}
crudClassstandard.queryClassById(param).then(res => {
this.classes = res.content.map(obj => {
if (obj.hasChildren) {
obj.children = null
}
return obj
})
})
this.crud.query.material_type_id = this.materOptCode
this.crud.toQuery()
},
handleSelectionChange(val, row) {
if (this.isSingle) {
@@ -185,21 +151,6 @@ export default {
this.crud.resetQuery(false)
this.$emit('update:dialogShow', false)
this.$emit('setMaterValue', this.rows)
},
loadClass({ action, parentNode, callback }) {
if (action === LOAD_CHILDREN_OPTIONS) {
crudClassstandard.getClass({ pid: parentNode.id }).then(res => {
parentNode.children = res.content.map(function(obj) {
if (obj.hasChildren) {
obj.children = null
}
return obj
})
setTimeout(() => {
callback()
}, 100)
})
}
}
}
}