vue 通过一级,异步请求二级数据并写入data,渲染页面

通过点击一级,请求二级数据并写入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)
          }
        })
      },
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值