王震
2023-09-14 38f0cd1459ec587053ae37ecbacb20835c38cfa8
src/components/view/laboratoryManagement.vue
@@ -1,8 +1,8 @@
<template>
  <div>
  <div class="laboratoryMangement">
    <el-row>
      <el-col :span="12" class="top_left_name">实验室管理</el-col>
      <el-col :span="12" style="text-align: right;">
      <el-col :span="12" class="top_left_name">设备维护</el-col>
      <el-col :span="12" style="text-align: right;" class="title">
        <el-button
          @click="testItem()"
          type="primary"
@@ -39,6 +39,7 @@
                <el-form-item label="设备用途" prop="type">
                  <el-select
                    v-model="ruleForm.type"
                    @change="selectinstall"
                    placeholder="请选择设备用途"
                  >
                    <el-option label="生产设备" value="1"></el-option>
@@ -50,18 +51,27 @@
            <el-row>
              <el-col :span="12">
                <el-form-item label="设备组" prop="name">
                  <el-select
                  <!-- <el-select
                    v-model="ruleForm.equr"
                    allow-create
                    filterable
                    @blur="selectInput"
                    placeholder="请选择设备组"
                  >
                    <el-option
                      v-for="list in equip"
                      v-for="list in equaip"
                      :key="list"
                      :label="list"
                      :value="list"
                    >
                    </el-option>
                  </el-select>
                  </el-select> -->
                <el-autocomplete
                class="inline-input"
                v-model="ruleForm.equr"
                :fetch-suggestions="querySearch"
                 placeholder="请输入内容"
    ></el-autocomplete>
                </el-form-item>
              </el-col>
              <el-col :span="12">
@@ -190,7 +200,7 @@
        <el-radio-button  label="1">生产设备</el-radio-button>
        <el-radio-button  label="2">检验设备</el-radio-button>
        </el-radio-group>
        <el-input
        <!-- <el-input
          class="frame_input"
          v-model="search_class"
          placeholder="请输入分类名称"
@@ -202,13 +212,15 @@
            style="font-size: 23px; padding: 5px 0;cursor:pointer;"
            @click="handlerDeptList"
          ></i>
        </el-input>
        </el-input> -->
        <el-tree
          :data="towTree"
          ref="tree"
          :props="{ children: 'children', label: 'father' }"
          node-key="id"
          node-key="father"
          default-expand-all
          highlight-current
          style="margin-top: 20px;"
          @node-click="handleNodeClick"
        >
          <div class="custom-tree-node" slot-scope="{ node, data }">
@@ -224,9 +236,9 @@
              ></i>
              {{ data.father }}</span
            >
            <el-button type="text" size="mini" @click.stop="remove(node, data)">
           <!--  <el-button type="text" size="mini" @click.stop="remove(node, data)">
              <i class="el-icon-delete"></i>
            </el-button>
            </el-button> -->
          </div>
        </el-tree>
      </div>
@@ -394,8 +406,10 @@
  name: "LaboratoryManagement",
  data() {
    return {
      value: "",
      dialogVisible: false,
      checkTreeNode:{},
      isCollapse: true, //默认为展开
      radio1: "true", // 分类切换
      tableData: [], // 主页表格数据
@@ -408,8 +422,8 @@
      staue_value: "", // 主页表格上方的状态选择
      // BOM树数据结构
      towTree: [],
      equipment: '',
      equip:'',
      equipment: '1',
      equaip:[],
      ruleForm: {
        // 新增仪器表单
        code: "",
@@ -421,10 +435,11 @@
        name: "",
        rawInsProductId: "",
        type: "",
        treedata:{
            father:'设备组1',
        },
        equr:1,
        // treedata:{
        //     father:'设备组1',
        // },
        equr:'',
      },
      delete:{},
      equip:1,
@@ -470,25 +485,43 @@
    this.twoTreeApi();
    // 初始化调用表格数据
    // this.tableDataApi();
    this.selectDevice()//右边
    // this.selectDevice()
  },
  methods: {
    selectDevice() {//右边数据
      console.log(this.ruleForm.treedata.father);
      console.log(this.equip);
      this.$axios.get(this.$api.url.selectDevice,{
        params:{
          father:this.ruleForm.treedata.father,
          type:this.equip,
        }
      }).then(res =>{
        console.log(res);
        this.tableData = res.data
      }, {
            headers: {
                      "Content-Type": "application/json"
                    }
      })
    handleNodeClick(val) {
      this.checkTreeNode = val
      console.log(this.checkTreeNode);
        this.selectDevice()
    },
    selectInput(){
    },
    querySearch(queryString, cb) {
      console.log(this.equaip);
        var restaurants = this.equaip;
        var results = queryString ? restaurants.filter(this.createFilter(queryString)) : restaurants;
        // 调用 callback 返回建议列表的数据
        cb(results);
      },
      createFilter(queryString) {
        return (restaurant) => {
          return (restaurant.value.toLowerCase().indexOf(queryString.toLowerCase()) === 0);
        };
      },
    staueValueChange() {
      this.selectDevice()
      // this.tableData = [];
      // let val = 1;
      // if (this.radio1 === "false") {
      //   val = 2;
      // }
      // this.$axios
      //   .get(this.$api.url.tableDeviceList, {
      //     params: { type: val, deviceStatue: this.staue_value }
      //   })
      //   .then(res => {
      //     this.tableData = res.data;
      //   });
    },
    // 动态控制展开与收起和切换对应图标
    isC() {
@@ -536,11 +569,25 @@
      this.$axios.get(this.$api.url.addDeviceKeeper).then(res => {
        this.keeperList = res.data;
      });
    },
    selectinstall(val) {
      this.equip = val
      this.listgroup()
    },
    listgroup() {
        this.$axios.get(this.$api.url.listgroup).then(res =>{
            this.equip = res.data
        this.$axios.get(this.$api.url.listgroup,{
            params:{
              type:this.equip
            }
        }).then(res =>{
          res.data.forEach(item=>{
            let obj={
              id: item,
              value: item
            }
            this.equaip.push(obj)
            console.log("设备组",this.equip);
          })
        })
    },
    RadioChange(val){
@@ -551,7 +598,7 @@
    twoTreeApi() {
      this.$axios.get(this.$api.url.towTree,{
        params:{
            type:this.equip
            type:this.equip,
        }
      }).then(res => {
        // let list = res.data;
@@ -563,7 +610,52 @@
        //   }
        // });
        this.towTree = res.data;
      });
        this.$nextTick(() => {
            this.$refs.tree.setCurrentKey(this.towTree[0].father) // 默认选中节点第一个
         })
      console.log(this.towTree);
        let one=this.towTree[0]
        console.log(one);
        let name =one.father
        this.checkTreeNode.father = name
           console.log(name);
        this.selectDeviceStart(name)
        });
    },
    selectDeviceStart(name,) {//右边数据
      this.$axios.get(this.$api.url.selectDevice,{
        params:{
          father:name,
          type:this.equip,
          deviceStatus:this.staue_value,
          message:this.codeNameModel,
        }
      }).then(res =>{
        console.log(res);
        this.tableData = res.data
      }, {
            headers: {
                      "Content-Type": "application/json"
                    }
      })
    },
    selectDevice() {//右边数据
      this.$axios.get(this.$api.url.selectDevice,{
        params:{
          father:this.checkTreeNode.father,
          type:this.equip,
          deviceStatus:this.staue_value,
          message:this.codeNameModel,
        }
      }).then(res =>{
        console.log(res);
        this.tableData = res.data
      }, {
            headers: {
                      "Content-Type": "application/json"
                    }
      })
    },
    addApi() {
      this.$axios.post(this.$api.url.addApi,{
@@ -575,7 +667,12 @@
        keeper:this.ruleForm.keeper,
        name:this.ruleForm.name,
        type:this.ruleForm.type,
      }, {headers: {"Content-Type": "application/json"}})
      }, {headers: {"Content-Type": "application/json"}
    }).then(res =>{
      this.$message.success('新增成功')
      this.ruleForm = {}
      this.selectDevice()
    })
    },
    // tableDataApi() {
    //   this.$axios.get(this.$api.url.tableDeviceList).then(res => {
@@ -583,15 +680,13 @@
    //   });
    // },
    reset() {
      this.tableDataApi();
      this.radio1 = "true";
      this.codeNameModel = "";
      this.staue_value = "";
    },
    handleNodeClick(data) {
      console.log(data);
        // this.treedata = data
        this.selectDevice()
      // this.tableDataApi();
      // this.radio1 = "true";
      // this.codeNameModel = "";
      // this.staue_value = "";
      this.staue_value = ""
      this.codeNameModel = ""
      this.selectDevice()
    },
    handlerDeptList() {
      this.towTree = [];
@@ -608,29 +703,32 @@
        });
    },
    selectSearch() {
      this.tableData = [];
      if (this.radio1 === "false") {
        this.$axios
          .get(this.$api.url.tableDeviceList, {
            params: { type: 1, codeNameModel: this.codeNameModel }
          })
          .then(res => {
            this.tableData = res.data;
          });
      } else if (this.radio1 === "true") {
        this.$axios
          .get(this.$api.url.tableDeviceList, {
            params: { type: 2, codeNameModel: this.codeNameModel }
          })
          .then(res => {
            this.tableData = res.data;
          });
      }
      this.selectDevice()
      // this.tableData = [];
      // if (this.radio1 === "false") {
      //   this.$axios
      //     .get(this.$api.url.tableDeviceList, {
      //       params: { type: 1, codeNameModel: this.codeNameModel }
      //     })
      //     .then(res => {
      //       this.tableData = res.data;
      //     });
      // } else if (this.radio1 === "true") {
      //   this.$axios
      //     .get(this.$api.url.tableDeviceList, {
      //       params: { type: 2, codeNameModel: this.codeNameModel }
      //     })
      //     .then(res => {
      //       this.tableData = res.data;
      //     });
      // }
    },
    delDeviceById() {
      this.$axios.post(this.$api.url.delDeviceById,{
          id:this.delete.id
      })
      }).then(res=>{
        this.$parent.removeAllTab()
      });
    },
    handleClick(row) {
      console.log(row);
@@ -713,20 +811,7 @@
        }
      });
    },
    staueValueChange() {
      this.tableData = [];
      let val = 1;
      if (this.radio1 === "false") {
        val = 2;
      }
      this.$axios
        .get(this.$api.url.tableDeviceList, {
          params: { type: val, deviceStatue: this.staue_value }
        })
        .then(res => {
          this.tableData = res.data;
        });
    }
  },
 
  watch: {
@@ -942,3 +1027,25 @@
  line-height: 14px;
}
</style>
<style>
   .laboratoryMangement .title *{
      font-size: 14px;
   }
   .laboratoryMangement .table_top_div *{
      font-size: 14px;
   }
   .laboratoryMangement .title .el-button {
     height: 32px;
     border: 1px solid rgba(190, 190, 190, 0.44);
     box-shadow: 0px 2px 4px rgba(220, 220, 220, 0.41);
     padding: 0 12px;
   }
   .laboratoryMangement .table_top_div .el-button {
     height: 32px;
     border: 1px solid rgba(190, 190, 190, 0.44);
     box-shadow: 0px 2px 4px rgba(220, 220, 220, 0.41);
     padding: 0 12px;
   }
</style>