王震
2023-09-25 712b72a5bf70818ae60550a32543b3220e4918f2
src/components/view/equipmentmaintain.vue
@@ -17,16 +17,12 @@
            <el-dialog
            title="技术指标编辑"
            :visible.sync="modifyevent"
            width="40%"
            :before-close="handleClose">
            width="40%">
            <el-form ref="form" :model="form" label-width="80px">
                <el-form-item label="类型">
                    <template>
                        <el-select v-model="form.type" placeholder="请选择" >
                            <el-option label="橡胶连接器" :value="0"></el-option>
                     <el-option label="金属连接器" :value="1"></el-option>
                     <el-option label="湿插拔电连接器" :value="2"></el-option>
                     <el-option label="分支组件" :value="3"></el-option>
                        <el-select v-model="edit.type" disabled placeholder="请选择"  style="width: 560px;">
                            <el-option v-for="(a, ai) in bigType" :key="ai" :value="a"></el-option>
                        </el-select>
                        </template>
                    </el-form-item>
@@ -34,7 +30,7 @@
                    <el-col :span="11">
                        <el-form-item label="工序">
                            <template>
                        <el-select v-model="form.work"
                        <el-select v-model="edit.techFather"  disabled
                  placeholder="请选择" >
                            <el-option
                            v-for="item in process"
@@ -46,46 +42,77 @@
                        </template>
                        </el-form-item>
                    </el-col>
                    <el-col :span="11" :offset="2">
                        <el-form-item label="工艺">
                            <el-input v-model="edit.techName" :disabled="true" placeholder="请选择"></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="11">
                        <el-form-item label="设备">
                            <el-input v-model="form.father"  placeholder="请选择"></el-input>
                            <el-input v-model="edit.dname" disabled placeholder="请选择"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="11" :offset="2">
                        <el-form-item label="项目">
                            <el-input v-model="form.name"  placeholder="请输入项目"></el-input>
                            <!-- <el-input v-model="edit.father" :disabled="true" placeholder="请输入项目"></el-input> -->
                            <template>
                            <el-select v-model="edit.father" @change="projectApi" placeholder="请选择" >
                            <el-option
                            v-for="item in project"
                            :key="item.name"
                            :label="item.name"
                            :value="item.name">
                            </el-option>
                        </el-select>
                        </template>
                        </el-form-item>
                     </el-col>
                </el-row>
                <el-form-item label="单位">
                    <el-input v-model="form.unit"  placeholder="请输入单位" style="width: 220px;"></el-input>
                </el-form-item>
                <el-row>
                    <el-col :span="11">
                        <el-form-item label="指标">
                            <template>
                            <el-select v-model="edit.name" @change="scale" placeholder="请选择" >
                            <el-option
                            v-for="item in quota"
                            :key="item.id"
                            :label="item.name"
                            :value="item.id">
                            </el-option>
                        </el-select>
                    </template>
                        </el-form-item>
                    </el-col>
                    <el-col :span="11" :offset="2">
                        <el-form-item label="单位">
                            <el-input v-model="unitrow" :value="unitrow" :disabled="true" placeholder="请输入项目"></el-input>
                        </el-form-item>
                     </el-col>
                </el-row>
                </el-form>
            <span slot="footer" class="dialog-footer">
                <el-button @click="modifyevent = false">取 消</el-button>
                <el-button type="primary" @click="modifyevent = false">确 定</el-button>
                <el-button type="primary" @click="editApi">确 定</el-button>
            </span>
            </el-dialog>
            </div>
            <!-- 新增弹窗 -->
        <div>
            <el-dialog
            title="技术指标新增"
            title="生产工艺新增"
            :visible.sync="dialogVisible"
            width="40%"
            :before-close="handleClose">
            width="40%">
            <el-form ref="form" :model="form" label-width="80px">
                <el-form-item label="类型">
                    <template>
                        <el-select v-model="form.type" placeholder="请选择" style="width: 480px;">
                            <el-option label="橡胶连接器" :value="0"></el-option>
                     <el-option label="金属连接器" :value="1"></el-option>
                     <el-option label="湿插拔电连接器" :value="2"></el-option>
                     <el-option label="分支组件" :value="3"></el-option>
                        <el-select v-model="form.type" placeholder="请选择" @change="edittype" style="width: 100%;">
                            <el-option v-for="(a, ai) in bigType" :key="ai" :value="a"></el-option>
                        </el-select>
                        </template>
                    </el-form-item>
@@ -93,13 +120,27 @@
                    <el-col :span="11">
                        <el-form-item label="工序">
                            <template>
                        <el-select v-model="form.father"
                        <el-select v-model="form.father" @change="workevent"
                  placeholder="请选择" >
                            <el-option
                            v-for="item in process"
                            :key="item.name"
                            :label="item.name"
                            :value="item.name">
                            </el-option>
                        </el-select>
                        </template>
                        </el-form-item>
                    </el-col>
                    <el-col :span="11" :offset="2">
                        <el-form-item label="工艺名称">
                            <template>
                        <el-select v-model="form.craft" @change="carftapi" placeholder="请选择" >
                            <el-option
                            v-for="item in craftapi"
                            :key="item.id"
                            :label="item.name"
                            :value="item.id">
                            </el-option>
                        </el-select>
                        </template>
@@ -113,9 +154,9 @@
                        <el-select v-model="form.work" placeholder="请选择" >
                            <el-option
                            v-for="item in higherlevel"
                            :key="item.name"
                            :key="item.devId"
                            :label="item.name"
                            :value="item.name">
                            :value="item.devId">
                            </el-option>
                        </el-select>
                        </template>
@@ -123,14 +164,47 @@
                    </el-col>
                    <el-col :span="11" :offset="2">
                        <el-form-item label="项目">
                            <el-input v-model="form.name"  placeholder="请输入项目"></el-input>
                            <template>
                        <el-select v-model="form.ee" @change="projectApi" placeholder="请选择" >
                            <el-option
                            v-for="item in project"
                            :key="item.name"
                            :label="item.name"
                            :value="item.name">
                            </el-option>
                        </el-select>
                        </template>
                        </el-form-item>
                     </el-col>
                </el-row>
                <el-form-item label="单位">
                <el-row>
                    <el-col :span="11">
                        <el-form-item label="指标">
                            <template>
                            <el-select v-model="form.aa" @change="scale" placeholder="请选择" >
                            <el-option
                            v-for="item in quota"
                            :key="item.id"
                            :label="item.name"
                            :value="item.id">
                            </el-option>
                        </el-select>
                        </template>
                        </el-form-item>
                    </el-col>
                    <el-col :span="11" :offset="2">
                        <el-form-item label="单位">
                            <template>
                        <el-input v-model="unitrow" :disabled="true" placeholder="请输入单位" style="width: 100%;"></el-input>
                        </template>
                        </el-form-item>
                     </el-col>
                </el-row>
                <!-- <el-form-item label="单位">
                    <el-input v-model="form.unit"  placeholder="请输入单位" style="width: 220px;"></el-input>
                </el-form-item>
                </el-form-item> -->
            </el-form>
            <span slot="footer" class="dialog-footer">
                <el-button @click="dialogVisible = false">取 消</el-button>
@@ -144,10 +218,7 @@
      <div class="choose">
            <span>类型:</span>
         <el-select v-model="search.type" size="small" @change="TYpe" placeholder="请选择" style="width: 224px;margin-right: 30px;">
            <el-option label="橡胶连接器" :value="0"></el-option>
            <el-option label="金属连接器" :value="1"></el-option>
            <el-option label="湿插拔电连接器" :value="2"></el-option>
            <el-option label="分支组件" :value="3"></el-option>
                <el-option v-for="(a, ai) in bigType" :key="ai" :value="a"></el-option>
         </el-select>
         <!-- <span>工序:</span>
         <el-select v-model="search.name" size="small" placeholder="请选择" style="width: 224px;margin-right: 30px;">
@@ -160,11 +231,13 @@
        <!-- 主体左 -->
         <div  class="left">
            <el-input v-model="search.technology" 
                @input="query"
                suffix-icon="el-icon-search" 
                placeholder="请输入搜索内容" 
                size="small" clearable ></el-input>
                    <el-tree :data="list" ref="tree" :props="{children: 'children',label: 'name'}" node-key="id" default-expand-all
                        highlight-current  :filter-node-method="filterNode"
                    <el-tree :data="list" ref="tree"
                    :props="{children: 'children',label: 'name'}" highlight-current node-key="name" default-expand-all
                        @node-click="handleNodeClick"
                        >
                    <div class="custom-tree-node" slot-scope="{ node, data }">
@@ -179,12 +252,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"
@@ -197,30 +273,28 @@
                    <el-table-column
                    label="设备名称"
                    sortable
                    prop="dname"
                    width="300px">
                        <template slot-scope="scope">
                        <el-tag>
                        <!-- <el-tag>
                            <div class="firstDiv" :style="`color: ${scope.row.children ? '#16a7ff' : '#58c173'}`">
                            {{ scope.row.children  ? "01" : "02" }}
                            </div>
                        </el-tag>
                        <span style="children: black">{{ scope.row.name }}</span>
                        <span style="children: black">{{ scope.row.name }}</span> -->
                        <el-tag v-if="scope.row.children" type="primary">01</el-tag>
                        <span style="color: black" v-if="scope.row.children">
                        {{ scope.row.dname }}
                        </span>
                        </template>
                        </el-table-column>
                    <el-table-column
                    label="项目"
                    sortable
                    width="300px">
                        <template slot-scope="scope">
                        <el-tag>
                            <div class="firstDiv" :style="`color: ${scope.row.children ? '#16a7ff' : '#58c173'}`">
                            {{ scope.row.children ? "01" : "02" }}
                            </div>
                        </el-tag>
                        <span style="color: black">{{ scope.row.name }}</span>
                        <el-tag type="success" v-if="!scope.row.children">02</el-tag>
                        <span style="color: black" v-if="!scope.row.children">{{ scope.row.father  }}</span>
                        </template>
                        </el-table-column>
                        <el-table-column
@@ -228,7 +302,7 @@
                        label="单位">
                        </el-table-column>
                        <el-table-column
                        prop="address"
                        prop="name"
                        label="指标">
                        </el-table-column>
                        <el-table-column
@@ -236,9 +310,11 @@
                        label="操作"
                        width="200px">
                        <template slot-scope="scope" style="text-align: center;">
                        <el-button type="text" size="mini" @click="childrenClick(scope)">编辑</el-button>
                        <el-button type="text" size="mini" @click="deleteRow(scope.$index, tableData)">删除</el-button>
                        </template>
                            <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="deleteRow(scope.$index, scope.row)">删除</el-button>
                            </div>
                    </template>
                    </el-table-column>
                </el-table>
         </div>
@@ -249,6 +325,7 @@
export default {
      data() {
         return {
              bigType: [],
              search: {
               type: 0,
               technology: null
@@ -258,12 +335,18 @@
              options:[],
              process:[],
              list: [],
              TYpe:'',
              selects:'',
              process:{},
              options:{},
              craftapi:{},
              project:{},
              edit:{},
              upData:{
              },
              checkTreeNode:{
                id:2,
                id:1,
              },
                form:{
                    type:'',
@@ -271,21 +354,34 @@
                    work:'',
                    name:'',
                    unit:'',
                },
                modifyevent:false,
                dialogVisible:false,
                tableData: [],
                higherlevel:{},
                quota:{},
                carftrow:"",
                unitrow:'',
            }
            
        },
        mounted() {
            this.chooseType()
         this.selectAllleft()
            this.selectAllTeque()        
      },
        methods:{
            chooseType() {
            this.$axios.get(this.$api.url.chooseType).then(res => {
               this.bigType = res.data
               this.typeselect = res.data[0]
               console.log(this.typeselect);
               this.search.type = res.data[0]
            })
         },
            selectDataList() {
            this.list.forEach(a => {
               a.code = '[1]'
@@ -303,10 +399,56 @@
            this.upIndex++
         },
            elForm() {},
            //新增
            choosePro() {//工序
            // //新增
            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);
         })
            },
            carftapi(val) {
                console.log(val);
                this.carftrow = val
                this.chooseDeiv()
                this.choosePro()
            },
            chooseDeiv() {//设备
         this.$axios.get(this.$api.url.chooseDeiv,{
                params:{techTemId:this.carftrow}
            }).then(res => {
            this.higherlevel = res.data;
                console.log(this.process);
         })
            },
            //新增
            edittype(val) {
            this.typeselect = val
            this.chooseTechFath()
         },
            projectApi(val) {
                console.log(val);
                let idx = this.project.findIndex(el => el.name === val)
                this.quota = this.project[idx].children
            console.log( this.quota);
            },
            scale(val) {
                console.log(val);
                let cc = this.quota.findIndex(el => el.id === val)
                console.log(cc);
                this.unitrow = this.quota[cc].unit
                console.log(this.unitrow);
            },
         workevent(val){
                console.log(val);
                let idx = this.process.findIndex(el => el.name === val)
                this.craftapi = this.process[idx].children
            console.log( this.craftapi);
            },
         chooseTechFath() {
         this.$axios.get(this.$api.url.chooseTechFath,{
                params:{type:this.typeselect}
            }).then(res => {
            this.process = res.data;
                console.log(this.process);
@@ -314,20 +456,10 @@
            headers: {
                      "Content-Type": "application/json"
                    }
            })
            },
            chooseDeiv() {//设备
         this.$axios.get(this.$api.url.chooseDeiv,{
                params:{techTemId:this.checkTreeNode.id}
            }).then(res => {
            this.higherlevel = res.data;
                console.log(this.process);
         }, {
            headers: {
                      "Content-Type": "application/json"
                    }
            })
            },
            }).then(res =>{
         })
         },
             //新增
             event(){
                this.dialogVisible = true
@@ -337,21 +469,54 @@
            //确认
            add() { 
                this.dialogVisible = false
                this.addQeMode()
            },
            addQeMode(){
                this.$axios.get(this.$api.url.addQeMode,{
                    devId:this.form.xxx,
                    techTemId:this.form.xxx,
                    technicalModelId:this.form.xxx,
                this.$axios.post(this.$api.url.addQeMode,{
                    devId:this.form.work,
                    techTemId:this.form.craft,
                    technicalModelId:this.form.aa,
                }, {headers: {"Content-Type": "application/json"}
                }).then(res =>{
                    this.selectAllTeque()
                    this.form = {}
                    this.unitrow = ""
                })
            },
           
            //编辑
            childrenClick() {
            childrenClick(ob) {
                this.modifyevent=true
                this.chooseTechFath()
                this.upData = ob
                this.selecQueById()
                this.choosePro()
            },
            TYpe() {
            //编辑 selecQueById
            selecQueById() {
             this.$axios.get(this.$api.url.selecQueById,{
                params:{id:this.upData.id}
             }).then(res => {
                    console.log(res);
                    this.edit = res.data[0]
                    console.log(this.edit);
                    this.unitrow = this.edit.unit
             })
         },
            editApi() {
                this.modifyevent = false
                this.writeQueById()
            },
            writeQueById() {
                this.$axios.post(this.$api.url.writeQueById,{
                    devId:this.edit.did,
                    techTemId:this.edit.tid,
                    technicalModelId:this.edit.name,
                }, {headers: {"Content-Type": "application/json"}
                }).then(res =>{
                })
            },
            //========================
            TYpe(val) {
                this.typeselect = val
            this.selectAllleft()
            },
@@ -361,15 +526,39 @@
            this.selectAllTeque()
            },
             //查询
             query(val) {
                this.selectAllleft()
            },
             //主体左
             selectAllleft() {
         this.$axios.get(this.$api.url.selectAllleft,{
            params:{type:this.typeselect}
            params:{type:this.typeselect,message:this.search.technology}
         }).then(res => {
            this.list = res.data;
                console.log(this.list);
                this.selectDataList()
                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)
         })
         },
            //主体右
@@ -379,40 +568,132 @@
         }).then(res => {
            this.tableData = res.data;
                console.log(this.tableData);
                this.formatData(res.data)
         })
         },
            modify(){
                this.modifyevent = true
            },
            deleteRow(index, rows) {
            rows.splice(index, 1);
            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,{
                  id:this.upData.id
            }).then(res =>{
                    this.selectAllTeque()
                    this.$message.success('删除完成')
                })
         },
            handleSelectionChange(val) {
            this.selects = val
            deleteRow(index, row) {
            this.tableData.splice(index,1)
            this.upData.id = row.id
                console.log(this.upData.id);
            this.delQueById()
         },
            //批量删除
         delAllQue() {
            this.$axios.post(this.$api.url.delAllQue,{
                  ids:this.delete
            }).then(res =>{
                    this.selectAllTeque()
                    this.$message.success('删除完成')
                })
         },
            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 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('删除完成')
         },
            handleClose(){
                        this.$confirm('确认关闭?')
                .then(_ => {
                    done();
            // handleClose(){
            // //             this.$confirm('确认关闭?')
            // //     .then(_ => {
            // //         done();
            // //     })
            // //     .catch(_ => {})
            // // },
            // // 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");
                })
                .catch(_ => {})
            },
            filterNode(){
             //选择某行
          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>
@@ -465,6 +746,7 @@
      height: calc(100% - 20px);
      border-right: 3px solid rgb(245, 247, 251);
      padding: 16px;
      overflow-y: auto;
   }
   .thing .left .custom-tree-node span {
@@ -496,7 +778,9 @@
   .thing .right {
      width: calc(100% - 305px);
      height: calc(100% - 25px);
      overflow: hidden;
      /* overflow: hidden; */
        overflow-y: scroll;
        overflow-x: scroll;
      padding: 10px;
   }