gaoshp
2024-11-04 eef1ef0be935d4a3d8fc691b2666f41796b2d4a5
src/views/tpm/MachineGroup.vue
@@ -1,8 +1,8 @@
<!--
 * @Date: 2024-04-27 20:02:44
 * @LastEditors: Sneed
 * @LastEditTime: 2024-04-27 21:40:33
 * @FilePath: /belleson-frontend/Users/mache/Documents/demo/cps-web/src/views/tpm/MachineGroup.vue
 * @LastEditors: gaoshp
 * @LastEditTime: 2024-09-29 19:33:58
 * @FilePath: /cps-web/src/views/tpm/MachineGroup.vue
-->
<template>
    <el-container>
@@ -19,7 +19,7 @@
            <el-header>
                <div class="left-panel">
                    <el-button @click="addChild" type="primary" plain>新增下级</el-button>
                    <el-button @click="del" type="danger" plain>删除</el-button>
                    <el-button :disabled="!form.id" @click="del" type="danger" plain>删除</el-button>
                </div>
            </el-header>
            <el-main class="">
@@ -61,7 +61,7 @@
    },
    methods: {
        getTreeData() {
            this.$HTTP.get('/api/blade-cps/group/tree?groupCategory=1&groupType=group_machine').then(res => {
            this.$HTTP.get('/api/smis/group/tree?groupCategory=1&groupType=group_machine').then(res => {
                if (res.code === 200) {
                    this.group = res.data
                    this.groupClick(res.data[0])
@@ -83,6 +83,9 @@
            }
        },
        addChild() {
            if (!this.form.id) {
                return
            }
            let { name, id, groupType, groupCategory } = this.form
            this.form.id = ''
            this.form.name = ''
@@ -102,7 +105,7 @@
                }
            )
                .then(() => {
                    this.$HTTP.delete('/api/blade-cps/group/deleteGroup', {}, { params: { groupId: this.form.id } }).then(res => {
                    this.$HTTP.delete('/api/smis/group/deleteGroup', {}, { params: { groupId: this.form.id } }).then(res => {
                        if (res.code === 200) {
                            this.$message.success("操作成功");
                            this.getTreeData()
@@ -115,11 +118,20 @@
        },
        save() {
            this.group = []
            this.$HTTP.post('/api/blade-cps/group', this.form).then(res => {
                if (res.code === 200) {
                    this.getTreeData()
                }
            })
            if (this.form.id) {
                this.$HTTP.put('/api/smis/group', this.form).then(res => {
                    if (res.code === 200) {
                        this.getTreeData()
                    }
                })
            } else {
                this.$HTTP.post('/api/smis/group', this.form).then(res => {
                    if (res.code === 200) {
                        this.getTreeData()
                    }
                })
            }
        }
    }
}