xyc
2024-08-02 d9b3b4b0ad0f4022cbb406a9fb3ad56a5e7f7ff3
web/src/views/modules/basicInfo/ProductModelTree.vue
@@ -1,13 +1,15 @@
<template>
  <div class="product-tree-container">
    <el-input
      placeholder="输入名称进行过滤"
      style="width: 60%"
      v-model="filterText"
      size="small"
      clearable
    ></el-input>
    <el-button v-if="isShow" type="primary" @click="add()" style="margin: 10px 0 0 10px;padding: 9px 18px !important;">新增型号</el-button>
    <!-- <el-input
       placeholder="输入名称进行过滤"
       style="width: 60%"
       v-model="filterText"
       size="small"
       clearable
     ></el-input>-->
    <el-button v-if="isShow" type="primary" @click="add()"
               style="margin: 10px 0 0 10px;padding: 9px 18px !important;">新增型号
    </el-button>
    <el-divider></el-divider>
    <el-tree
      style="height: 90%;overflow: auto"
@@ -45,6 +47,10 @@
        type: Number,
        default: 1
      },
      productId: {
        type: Number,
        default: null
      },
    },
    data() {
@@ -69,19 +75,20 @@
      AddOrUpdate
    }
    ,
    mounted() {
      this.getProductList()
    },
    /* mounted() {
       this.getProductList()
     },*/
    methods: {
      // 获取系统列表
      async getProductList() {
        let params = {
          showXdy: this.showXdy,
          ztShow: this.basic
          ztShow: this.basic,
          productId: this.productId
        }
        let res = await this.$http.get('/basicInfo/XhProductModel/tree', {params: params})
        this.productList = res.data
        if (this.basic) {
        if (this.basic === '3') {
          if (this.productList && this.productList[0].children) {
            this.defaultId = this.productList[0].children[0].id
            this.$nextTick(() => {
@@ -89,6 +96,14 @@
            });
            this.$emit('on-default', this.defaultId)
          }
        } else{
          if (this.productList[0].id) {
            this.defaultId = this.productList[0].id
            this.$nextTick(() => {
              this.$refs.tree.setCurrentKey(this.defaultId); //一定要加这个选中了否则样式没有出来
            });
            this.$emit('on-default', this.defaultId)
          }
        }
        console.log(res.data, 'async getProductList()')
      },