From dcf9c9e0410fe1186239e3f8d6f7bdc789c08010 Mon Sep 17 00:00:00 2001 From: lzhe <lzhe@example.com> Date: 星期三, 05 六月 2024 18:00:39 +0800 Subject: [PATCH] 1 --- src/views/tpm/MachineTab.vue | 87 +++++++++++++++++++++++++++++++++++-------- 1 files changed, 70 insertions(+), 17 deletions(-) diff --git a/src/views/tpm/MachineTab.vue b/src/views/tpm/MachineTab.vue index b4b362d..7760cd4 100644 --- a/src/views/tpm/MachineTab.vue +++ b/src/views/tpm/MachineTab.vue @@ -1,7 +1,7 @@ <!-- * @Date: 2024-04-27 20:04:34 * @LastEditors: Sneed - * @LastEditTime: 2024-04-27 21:51:12 + * @LastEditTime: 2024-05-08 23:13:10 * @FilePath: /belleson-frontend/Users/mache/Documents/demo/cps-web/src/views/tpm/MachineTab.vue --> <template> @@ -18,25 +18,26 @@ <el-header> <div class="left-panel"> <el-button size="small" @click="table_add" type="primary" icon="el-icon-plus"></el-button> - <el-button size="small" type="danger" plain icon="el-icon-delete" @click="batchDel"></el-button> + <el-button size="small" type="danger" plain icon="el-icon-delete" @click="batchDel" + :disabled="selection.length == 0"></el-button> <!-- <el-button type="primary" plain>瀵煎叆</el-button> <el-button type="primary" plain>鎵归噺鎿嶄綔</el-button> --> </div> <div class="right-panel"> <div class="right-panel-search"> <span>绫诲瀷</span> - <el-select size="small" v-model="params.machineTypeId" style="width: 240px"> - <el-option size="small" v-for="item in types" :key="item.value" :label="item.label" + <el-select v-model="params.machineTypeId" style="width: 240px" clearable> + <el-option v-for="item in types" :key="item.value" :label="item.label" :value="item.value" /> </el-select> <span>鐘舵��</span> - <el-select size="small" v-model="params.status" style="width: 240px"> - <el-option size="small" v-for="item in status" :key="item.value" :label="item.label" + <el-select v-model="params.status" style="width: 240px"> + <el-option v-for="item in status" :key="item.value" :label="item.label" :value="item.value" /> </el-select> - <el-input size="small" v-model="params.machineName" style="width: 240px" placeholder="璇疯緭鍏ユ満鍣ㄥ悕绉�" + <el-input v-model="params.machineName" style="width: 240px" placeholder="璇疯緭鍏ユ満鍣ㄥ悕绉�" clearable></el-input> - <el-button size="small" @click="search" type="primary" icon="el-icon-search"></el-button> + <el-button @click="search" type="primary" icon="el-icon-search"></el-button> </div> </div> </el-header> @@ -57,7 +58,10 @@ <el-button-group> <el-button text type="primary" size="small" @click="table_edit(scope.row, scope.$index)">缂栬緫</el-button> - <el-popconfirm title="纭畾鍒犻櫎鍚楋紵" @confirm="table_del(scope.row, scope.$index, '0')"> + <el-popconfirm width="220" cancel-button-text="鍋滅敤" confirm-button-text="鍒犻櫎" + title="鍒犻櫎鏁版嵁浼氬奖鍝嶅凡鍏宠仈鐨勪笟鍔� ,鑻ユ偍鎯冲湪宸插叧鑱旂殑涓氬姟涓緷鐒舵樉绀鸿繖浜涙暟鎹�, 鎮ㄥ彲浠ラ�夋嫨 鍋滅敤 鎿嶄綔銆傚仠鐢ㄥ悗姝ゆ暟鎹皢涓嶈兘鍐嶈鏂颁笟鍔′娇鐢ㄣ��" + @confirm="table_del(scope.row, scope.$index, '0')" + @cancel="table_del(scope.row, scope.$index, '1')"> <template #reference> <el-button text type="primary" size="small">鍒犻櫎</el-button> </template> @@ -66,26 +70,28 @@ </template> </el-table-column> </scTable> - </el-main> </el-container> + <Dialog ref="dialog" @success="success"></Dialog> </el-container> </template> <script> +import Dialog from './machine/Dialog.vue' export default { + components: { + Dialog + }, data() { return { apiObj: this.$API.machineManagement.getList, group: [], - treeCheckKey: '', params: { groupId: '', - machineCode: '', - machineName: '', machineTypeId: '', status: 1, }, + treeCheckKey: '', status: [ { label: '鍚敤', @@ -96,31 +102,78 @@ value: 0 } ], - types: [] + types: [], + selection: [] } }, created() { + this.init() this.getTreeData() }, methods: { + init() { + this.$HTTP.get('/api/blade-cps/device-types/page?keyWord=¤t=1&size=-1').then(res => { + if (res.code === 200) { + this.types = res.data.records.map(item => ({ + label: item.name, + value: item.id + })) + } + }) + }, getTreeData() { this.$HTTP.get('/api/blade-cps/group/tree?groupCategory=1&groupType=group_machine').then(res => { if (res.code === 200) { this.group = res.data - this.params.groupId = res.data[0].id + // this.params.groupId = res.data[0].id + this.nodeClick(res.data[0]) } }) }, nodeClick(node) { this.params.groupId = node.id + this.search() }, search() { this.$refs.table.reload(this.params) }, table_add() { - this.$router.push(`/tpm/machine/create`); + this.$refs.dialog.open('add', { + groupId: this.params.groupId + }) }, - batchDel() { }, + table_edit(row) { + this.$refs.dialog.open('edit', { id: row.id }) + }, + success() { + this.getTreeData() + }, + table_del(row, index, type) { + this.$HTTP.delete(`/api/blade-cps/machine?type=${type}`, { + ids: [row.id] + }).then(res => { + if (res.code === 200) { + this.$message.success("鎿嶄綔鎴愬姛"); + this.getTreeData() + } + }) + }, + selectionChange(selection) { + this.selection = selection + }, + batchDel() { + if (this.selection.length === 0) { + return this.$message.warning("璇烽�夋嫨"); + } + this.$HTTP.delete(`/api/blade-cps/machine?type=1`, { + ids: this.selection.map(item => item.id) + }).then(res => { + if (res.code === 200) { + this.$message.success("鎿嶄綔鎴愬姛"); + this.getTreeData() + } + }) + }, } } </script> -- Gitblit v1.9.3