<!--
|
* @Date: 2024-04-27 20:04:34
|
* @LastEditors: gaoshp
|
* @LastEditTime: 2024-09-24 21:03:08
|
* @FilePath: /cps-web/src/views/tpm/MachineTab.vue
|
-->
|
<template>
|
<el-container>
|
<el-aside width="200px" v-loading="showGrouploading">
|
<el-container>
|
<el-main class="nopadding">
|
<el-tree :expand-on-click-node="false" ref="group" default-expand-all node-key="id" :data="group"
|
:current-node-key="params.groupId" :highlight-current="true" @node-click="nodeClick"></el-tree>
|
</el-main>
|
</el-container>
|
</el-aside>
|
<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"
|
: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 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 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 v-model="params.machineName" style="width: 240px" placeholder="请输入机器名称"
|
clearable></el-input>
|
<el-button @click="search" type="primary" icon="el-icon-search"></el-button>
|
</div>
|
</div>
|
</el-header>
|
<el-main class="nopadding">
|
<scTable highlight-current-row @dataChange="dataChange" @row-click="rowClick" ref="table"
|
:params="params" :apiObj="apiObj" @selection-change="selectionChange" stripe>
|
<el-table-column type="selection" width="50"></el-table-column>
|
<el-table-column label="机器编号" prop="machineCode" width="120"></el-table-column>
|
<el-table-column label="机器名称" prop="machineName" width="120"></el-table-column>
|
<el-table-column label="所属机器组" prop="groupName" width="120"></el-table-column>
|
<el-table-column label="机器类型" prop="machineTypeName" width="120"></el-table-column>
|
<el-table-column label="机器序列号" prop="serialNo" width="120"></el-table-column>
|
<el-table-column label="短编号" prop="shortCode" width="120"></el-table-column>
|
<el-table-column label="机器规格" prop="machineModel" width="120"></el-table-column>
|
<el-table-column label="使用状态" prop="machineUseStatusName" width="120"></el-table-column>
|
<el-table-column label="操作" fixed="right" align="right" width="160">
|
<template #default="scope">
|
<el-button-group>
|
<el-button text type="primary" size="small"
|
@click="table_edit(scope.row, scope.$index)">编辑</el-button>
|
<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>
|
</el-popconfirm>
|
</el-button-group>
|
</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: [],
|
params: {
|
groupId: '',
|
machineTypeId: '',
|
status: 1,
|
},
|
treeCheckKey: '',
|
status: [
|
{
|
label: '启用',
|
value: 1
|
},
|
{
|
label: '停用',
|
value: 0
|
}
|
],
|
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.nodeClick(res.data[0])
|
}
|
})
|
},
|
nodeClick(node) {
|
this.params.groupId = node.id
|
this.search()
|
},
|
search() {
|
this.$refs.table.reload(this.params)
|
},
|
table_add() {
|
this.$refs.dialog.open('add', {
|
groupId: this.params.groupId
|
})
|
},
|
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()
|
} else {
|
this.$message.error(res.msg);
|
}
|
})
|
},
|
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()
|
} else {
|
this.$message.error(res.msg);
|
}
|
})
|
},
|
}
|
}
|
</script>
|
|
<style lang="scss" scoped></style>
|