通过点击一级,请求二级数据并写入data,渲染页面;
需要异步
<template>
<p>当前分类:
<el-select v-model="params2.one" placeholder="一级分类" @change="oneCate">
<el-option v-for="item in treeData" :key="item.id" :label="item.name" :value="item.id">
</el-option>
</el-select>
<el-select v-model="params2.two" placeholder="所属部门" @change="twoCate">
<el-option v-for="item in twoList" :key="item.id" :label="item.name" :value="item.id">
</el-option>
</el-select>
<el-select v-model="params2.three" placeholder="所属部门" @change="threeCate">
<el-option v-for="item in threeList" :key="item.id" :label="item.name" :value="item.id">
</el-option>
</el-select>
<el-button style="float: right; margin: 0 10px;" type="primary" @click="setCategory">档案归类</el-button>
<el-button style="float: right; margin: 0 10px;" @click="fileBox=false">返回</el-button>
</p>
<template>
data:{
twoList: [],
threeList: [],
params2: {
one: null,
two: null,
three: null
},
}
method:{
oneCate(val) {
this.getCategoryChild(val).then(res => {
this.twoList = res
});
this.params2 = {
one: val,
two: null,
three: null
}
this.theCateId = val
},
twoCate(val) {
this.getCategoryChild(val).then(res => {
this.threeList = res
});
this.params2 = {
one: this.params2.one,
two: this.params2.two,
three: null
}
this.theCateId = val
},
threeCate(val) {
this.params2 = {
one: this.params2.one,
two: this.params2.two,
three: val
}
this.theCateId = val
},
async getCategoryChild(val) {
var data = null
await request.getCategoryChild(val).then(({ object }) => {
data = object
})
return data
},
setCategory() {
var secId = []
this.selectedData2.forEach(item => {
secId.push(item.id)
});
var obj = { secId, }
console.log('v2', secId, this.theCateId)
request.setArchiveCategory({
archiveCategoryId: this.theCateId,
employeeIdList: secId
}).then(({ flag, msg }) => {
if (flag == 0) {
this.$fns.success(msg, false)
this.getUnClassList();
this.getData();
} else {
this.$fns.error(msg, false)
}
})
},
}