| | |
| | | <!-- |
| | | * @Date: 2024-04-27 20:04:34 |
| | | * @LastEditors: Sneed |
| | | * @LastEditTime: 2024-04-27 21:44:31 |
| | | * @FilePath: /belleson-frontend/Users/mache/Documents/demo/cps-web/src/views/tpm/Machine.vue |
| | | * @LastEditTime: 2024-05-08 23:13:10 |
| | | * @FilePath: /belleson-frontend/Users/mache/Documents/demo/cps-web/src/views/tpm/MachineTab.vue |
| | | --> |
| | | <template> |
| | | <el-container> |
| | |
| | | <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> |
| | |
| | | <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> |
| | |
| | | </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: '启用', |
| | |
| | | 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?type=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> |