数组树状子节点显示在列表

9 篇文章 1 订阅

在这里插入图片描述

<template>
  <div class="qingwu">

        <el-table
          :data="list"
          @selection-change="handleSelectionChange"
          row-key="id"
          :lazy="true"
          :load="load"
          :tree-props="{ children: 'area', hasChildren: 'hasChildren' }"
        >
          <el-table-column prop="id" label="编号"></el-table-column>
          <el-table-column prop="name" label="城市"></el-table-column>
          <el-table-column prop="money" label="工资"></el-table-column>

          <el-table-column label="操作" fixed="right" width="120px">
            <template slot-scope="scope">
              <el-button
                v-show="!scope.row.area"
                icon="el-icon-edit"
                @click="
                  $router.push({
                    name: 'urban_averge_wage_form',
                    params: { id: scope.row.id },
                  })
                "
                >编辑</el-button
              >
            </template>
          </el-table-column>
        </el-table>
      </div>
</template>

<script>
export default {
  components: {},
  props: {},
  data() {
    return {
      isJuded: false,
      list: [],
      select_id: "",
    };
  },
  watch: {},
  computed: {},
  methods: {
    handleSelectionChange: function (e) {
      let ids = [];
      e.forEach((v) => {
        ids.push(v.id);
      });
      this.select_id = ids.join(",");
    },
    get_area_list: function () {
      let _this = this;
      this.$get(this.$api.city_wage_list).then(function (res) {
        var tempArray = [];

        for (var i = 0; i < res.data.length; i++) {}

        _this.list = res.data;

        //_this.list = res.data;
      });
    },
    load: function (e, treeNode, resolve) {
      let treeNodes = treeNode; // 无效代码
      this.$post(this.$api.getAreaChildren, { area_id: e.area_id }).then(
        (res) => {
          resolve(res);
        }
      );
    },
    // 删除处理
    del: function (id) {
      let _this = this;
      if (this.$isEmpty(id)) {
        return this.$message.error("请先选择删除的对象");
      }
      this.$post(this.$api.delArea, { id: id }).then(function (res) {
        if (res.code == 200) {
          _this.get_area_list();
          return _this.$message.success("删除成功");
        } else {
          return _this.$message.error("删除失败");
        }
      });
    },
  },
  created() {
    this.get_area_list();
  },
};
</script>
<style lang="scss" scoped>
</style>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值