<template>
    <div id="modelFile">
        <span class="modelFile" style="margin-right: 12px;">模型文件</span>
        <el-cascader :options="options" :props="props" :show-all-levels="false" @change="handleChange" style="width:160px;"
        clearable placeholder="请选择模型文件" v-model="casVal"></el-cascader>
    </div>
</template>
<script>
import tools from "@/utils/scan/tools"
import { queryModelFile } from "@/api/data_admin/buildTaskApi"
import { mapGetters, mapActions } from "vuex"

export default {
  computed: {
    ...mapGetters("layout", [ "projectId", "secret", "userId" ])
  },
  data() {
    return {
      casVal: [],
      options: [],
      modelIdToFloorId: {},
      props: {
        value: "FileId",
        label: "FileName",
        children: "FileList"
      },
    };
  },
  created() {
    this.init()
  },
  watch: {
    projectId() {
      this.casVal =[]
      this.options = []
      this.init()
    }
  },
  methods: {
    //设置默认选项
    setValue(val) {
        if (val && val.length) {
          this.casVal = val
        }
    },
    //获取数据
    init() {
      this.getDirectory()
    },
    // 获取文件夹
    getDirectory() {
      queryModelFile("", res => {
        this.options = res.Content.map(item => {
          item.FileId = item.FolderId
          item.FileName = item.FolderName
          return item
        })
      });
    },
    //改变item
    handleChange(value) {
      this.$emit("change", value)
    }
  }
};
</script>
<style lang="less">
    .el-cascader .el-input .el-input__inner {
        vertical-align: bottom;
    }
</style>
<style lang="less" scoped>
    #modelFile {
        margin-left: 10px;
        float: left;
        .modelFile {
            color: #999999;
            font-size: 14px;
        }
    }
</style>