Fixiaobai
2023-09-20 039d01c3ee6217e18ef3bcaec263fd2ad59e6f68
src/components/view/equipmentmaintain.vue
@@ -108,13 +108,13 @@
            <!-- 新增弹窗 -->
        <div>
            <el-dialog
            title="技术指标新增"
            title="生产工艺新增"
            :visible.sync="dialogVisible"
            width="40%">
            <el-form ref="form" :model="form" label-width="80px">
                <el-form-item label="类型">
                    <template>
                        <el-select v-model="form.type" placeholder="请选择" @change="edittype" style="width: 480px;">
                        <el-select v-model="form.type" placeholder="请选择" @change="edittype" style="width: 100%;">
                            <el-option label="橡胶连接器" :value="0"></el-option>
                     <el-option label="金属连接器" :value="1"></el-option>
                     <el-option label="湿插拔电连接器" :value="2"></el-option>
@@ -141,7 +141,7 @@
                    <el-col :span="11" :offset="2">
                        <el-form-item label="工艺名称">
                            <template>
                        <el-select v-model="form.craft" placeholder="请选择" >
                        <el-select v-model="form.craft" @change="carftapi" placeholder="请选择" >
                            <el-option
                            v-for="item in craftapi"
                            :key="item.id"
@@ -202,7 +202,7 @@
                    <el-col :span="11" :offset="2">
                        <el-form-item label="单位">
                            <template>
                        <el-input v-model="unitrow" :disabled="true" placeholder="请输入单位" style="width: 200px;"></el-input>
                        <el-input v-model="unitrow" :disabled="true" placeholder="请输入单位" style="width: 100%;"></el-input>
                        </template>
                        </el-form-item>
                     </el-col>
@@ -245,7 +245,6 @@
                placeholder="请输入搜索内容" 
                size="small" clearable ></el-input>
                    <el-tree :data="list" ref="tree" 
                    style="height: 500px;overflow-y: auto;"
                    :props="{children: 'children',label: 'name'}" highlight-current node-key="name" default-expand-all
                         
                        @node-click="handleNodeClick"
@@ -262,12 +261,15 @@
            <!-- 主体右 -->
         <div class="right">
                <el-table
                height="calc(90vh - 200px)"
                    :data="tableData"
                    style="width: 100%;margin-bottom: 20px;"
                    row-key="name"
                    row-key="rowId"
                    border
                    @select-all="selectAll"
                    @select="selectTr"
                    @selection-change="handleSelectionChange"
                    default-expand-all
                    ref="multipleTable"
                    :tree-props="{children: 'children', hasChildren: 'hasChildren'}">
                    <el-table-column
                    type="selection"
@@ -318,7 +320,7 @@
                        width="200px">
                        <template slot-scope="scope" style="text-align: center;">
                            <div v-if="!scope.row.children">
                        <el-button type="text" size="mini" @click="childrenClick(scope.row)">编辑</el-button>
                        <!-- <el-button type="text" size="mini" @click="childrenClick(scope.row)">编辑</el-button> -->
                        <el-button type="text" size="mini" @click="deleteRow(scope.$index, scope.row)">删除</el-button>
                            </div>
                    </template>
@@ -368,6 +370,7 @@
                tableData: [],
                higherlevel:{},
                quota:{},
                carftrow:"",
                unitrow:'',
            }
            
@@ -397,27 +400,25 @@
            // //新增
            choosePro() {//项目
         this.$axios.get(this.$api.url.choosePro,{
                params:{techTemId:this.checkTreeNode.id}
                params:{techTemId:this.carftrow}
            }).then(res => {
            this.project = res.data;
                console.log(this.process);
         }, {
            headers: {
                      "Content-Type": "application/json"
                    }
            })
         })
            },
            carftapi(val) {
                console.log(val);
                this.carftrow = val
                this.chooseDeiv()
                this.choosePro()
            },
            chooseDeiv() {//设备
         this.$axios.get(this.$api.url.chooseDeiv,{
                params:{techTemId:this.checkTreeNode.id}
                params:{techTemId:this.carftrow}
            }).then(res => {
            this.higherlevel = res.data;
                console.log(this.process);
         }, {
            headers: {
                      "Content-Type": "application/json"
                    }
            })
         })
            },
            //新增
            edittype(val) {
@@ -538,9 +539,26 @@
                this.$nextTick(() => {
            this.$refs.tree.setCurrentKey(this.list[0].children[0].name) // 默认选中节点第一个
         })
                let one=this.list.filter(item=>{
                return item.children.length>0
                })[0]
                console.log(one);
                let name=one.children[0].id
                console.log(name);
                this.checkTreeNode.id = name
                this.selectAllTequeStart(name)
                this.selectDataList();
         })
         },
            selectAllTequeStart(name) {
         this.$axios.get(this.$api.url.selectAllTeque,{
            params:{id:this.checkTreeNode.id}
         }).then(res => {
            this.tableData = res.data;
                console.log(this.tableData);
                this.formatData(res.data)
         })
         },
            //主体右
            selectAllTeque() {
         this.$axios.get(this.$api.url.selectAllTeque,{
@@ -548,12 +566,21 @@
         }).then(res => {
            this.tableData = res.data;
                console.log(this.tableData);
                this.formatData(res.data)
         })
         },
            modify(){
                this.modifyevent = true
            },
            formatData(data){
                let arr = data;
                for(var i=0;i<arr.length;i++){
                        arr[i].rowId = Math.random();
                        if(arr[i].children != undefined){
                        this.formatData(arr[i].children);
                        }
                    }
                },
            //delQueById
            delQueById() {
            this.$axios.post(this.$api.url.delQueById,{
@@ -569,9 +596,6 @@
                console.log(this.upData.id);
            this.delQueById()
         },
            handleSelectionChange(val) {
            this.selects = val
         },
            //批量删除
         delAllQue() {
            this.$axios.post(this.$api.url.delAllQue,{
@@ -583,18 +607,17 @@
         },
            dels() {
            this.selects.forEach(a => {
               for (var b = 0; b < this.tableData.length; b++) {
                  if (this.tableData[b].id == a.id) {
                     this.tableData.splice(b, 1)
                     b--
                  }
               }
            })
                let cc = this.selects.map(el => {
               return el.id
            })
            this.delete = cc.join(',')
                let ee = []
                console.log(this.selects);
                this.selects.forEach(el =>{
                    if(el.children){
                        el.children.forEach(ele =>{
                            ee.push(ele.id)
                        })
                    }
                })
                console.log(ee);
            this.delete = ee.join(',')
            console.log(this.delete);
            this.delAllQue()
            this.$message.success('删除完成')
@@ -609,7 +632,66 @@
            // // filterNode(){
            // },
            handleSelectionChange(val) {
                this.selects = val
                // console.log(this.selects);
                this.deleteList = [];
                val.forEach((v) => {
                if (v.id !== undefined) {
                    this.deleteList.push(v.id);
                }
                });
         },
            // 全选/取消选操作
            selectAll(val) {
                // console.log(val);
                this.isAllSelect = !this.isAllSelect;
                let data = this.tableData;
                this.$nextTick(() =>{
                    this.toggleSelect(data, this.isAllSelect, "all");
                })
            },
             //选择某行
          selectTr(selection, row) {
                console.log(selection,row);
                this.$set(row, "isChecked", !row.isChecked);
                this.$nextTick(() => {
                    this.isAllSelect = row.isChecked;
                    this.toggleSelect(row, row.isChecked, "tr");
                });
            },
            toggleSelection(row, flag) {
                this.$set(row, "isChecked", flag);
                this.$nextTick(() => {
                if (flag) {
                    this.$refs.multipleTable.toggleRowSelection(row, flag);
                } else {
                    this.$refs.multipleTable.clearSelection();
                }
                });
            },
             //递归子级
            toggleSelect(data, flag, type) {
                if (type === "all") {
                    if (data.length > 0) {
                        data.forEach((item) => {
                        this.toggleSelection(item, flag);
                        if (item.children && item.children.length > 0) {
                            this.toggleSelect(item.children, flag, type);
                        }
                        });
                    }
                } else {
                    if (data.children && data.children.length > 0) {
                        data.children.forEach((item) => {
                        item.isChecked = !item.isChecked;
                        this.$refs.multipleTable.toggleRowSelection(item, flag);
                        this.toggleSelect(item, flag, type);
                        });
                    }
                }
            },
        }
    }
</script>
@@ -662,6 +744,7 @@
      height: calc(100% - 20px);
      border-right: 3px solid rgb(245, 247, 251);
      padding: 16px;
      overflow-y: auto;
   }
   .thing .left .custom-tree-node span {
@@ -693,7 +776,9 @@
   .thing .right {
      width: calc(100% - 305px);
      height: calc(100% - 25px);
      overflow: hidden;
      /* overflow: hidden; */
        overflow-y: scroll;
        overflow-x: scroll;
      padding: 10px;
   }