Fixiaobai
2023-09-11 839597ccc640a10ed9de88bd30916fc454693f0b
src/components/view/standard.vue
@@ -19,8 +19,8 @@
        <el-tree :data="list" ref="tree" default-expand-all :props="{ children: 'children', label: 'name' }"
          node-key="id" :filter-node-method="filterNode" @node-click="handleNodeClick" highlight-current>
          <div class="custom-tree-node" slot-scope="{ node, data }">
            <span><i :class="`node_i ${data.code != '[4]' ? 'el-icon-folder-opened' : 'el-icon-tickets'}`"></i>
              {{ data.name }}</span>
            <span><i :class="`node_i ${data.code != '[5]' ? 'el-icon-folder-opened' : 'el-icon-tickets'}`"></i>
              {{ data.code }}{{ data.name }}</span>
            <el-button type="text" size="mini" @click.stop="remove(node, data)">
              <i class="el-icon-delete"></i>
            </el-button>
@@ -77,7 +77,7 @@
    <div class="bom-add-model">
      <el-dialog title="BOM新增" :visible.sync="bomAddModelVisible" width="30%">
        <el-form>
        </el-form>
        <span slot="footer" class="dialog-footer">
          <el-button @click="bomAddModelVisible = false">取 消</el-button>
@@ -124,18 +124,43 @@
  //   }
  // },
  mounted() {
    this.tableType=0
    this.selectMaterialTree()
    this.selectAll()
    this.selectVersion()
  },
  methods: {
    selectDataList() {
            this.list.forEach(a => {
               a.code = '[1]'
               if (a.children != undefined) {
                  a.children.forEach(b => {
                     b.code = '[2]'
                     if (b.children != undefined) {
                        b.children.forEach(c => {
                           c.code = '[3]'
                  if (c.children != undefined) {
                        c.children.forEach(d => {
                           d.code = '[4]'
                  if (d.children != undefined) {
                        d.children.forEach(e => {
                           e.code = '[5]'
                        })
                     }
                        })
                     }
                        })
                     }
                  })
               }
            })
         },
    handleSelectionChange() {
    },
    TYPE(val) {//类型.数据
      console.log(val);
      this.typeselect = val
      // console.log(this.typeselect);
      this.selectVersion()
    },
@@ -143,8 +168,8 @@
      console.log(val);
      this.returntree = val
    },
    selectVersion() {//版本
      this.$axios.get(this.$api.url.selectVersion, {
    async selectVersion() {//版本
      let v=await this.$axios.get(this.$api.url.selectVersion, {
        params: {
          specificationsId: this.returntree.id,
          type: this.typeselect,
@@ -154,12 +179,16 @@
        this.version = this.verdata.map(el => {
          return el = `v${el}`
        })
        console.log(this.verdata);
        // console.log("版本");
        return this.verdata[0]
      })
      this.character=v
      this.VER="v"+v
      console.log(this.character);
      this.selectAll()
    },
    //右侧数据
    selectAll() {
      console.log(this.$axios.get(this.$api.url.selectAll));
      this.$axios.get(this.$api.url.selectAll, {
        params: {
          specificationsId: this.returntree.id,//tree的点击反馈
@@ -182,9 +211,10 @@
      // console.log(newObj);
    },
    //五级树
    selectMaterialTree() {
      this.$axios.get(this.$api.url.selectTreeByMaterial).then(res => {
        this.list = res.data
    async selectMaterialTree() {
      let _that=this
      let res=await this.$axios.get(this.$api.url.selectTreeByMaterial).then( res => {
        _that.list = res.data
        this.list.forEach((el, idx, arr) => {
          if (idx == 0) {
            arr[idx].name = '成品'
@@ -192,24 +222,34 @@
          if (idx == 1) {
            arr[idx].name = '半成品'
          }
          el.children.forEach((newEl, newIdx, newArr) => {
            if (newIdx == 0) {
              newArr[newIdx].name = '橡胶连接器'
            }
            if (newIdx == 1) {
              newArr[newIdx].name = '金属连接器'
            }
            if (newIdx == 2) {
              newArr[newIdx].name = '湿插拔电连接器'
            }
            if (newIdx == 3) {
              newArr[newIdx].name = '分支组件'
            }
          })
        })
        console.log(this.list);
        this.selectDataList()
        return _that.list
      })
     let s= this.filterChildren(res)
     console.log(s);
    },
    filterChildren(list){
       let one=list.filter(item=>{
        return item.children!=undefined
      })[0]
      let two=one.children.filter(item=>{
        return item.children!=undefined
      })[0]
      let three=two.children.filter(item=>{
        return item.children!=undefined
      })[0]
      let four=three.children.filter(item=>{
        return item.children!=undefined
      })[0]
      return four.children[0]
    },
     isObject(param) {
        return typeof param === 'object' && param !== null;
    },
    isArray(param) {
  return Array.isArray(param);
},
    filterNode(value, data) {
      if (!value) return true;
      return data.label.indexOf(value) !== -1;