yudao-dev/src/views/equipment/base/config/AlarmGroup/index.vue

462 lines
11 KiB
Vue
Raw Normal View History

2023-08-10 16:52:47 +08:00
<template>
2023-08-17 09:37:39 +08:00
<div class="app-container">
<!-- 搜索工作栏 -->
<SearchBar
:formConfigs="searchBarFormConfig"
ref="search-bar"
@headBtnClick="handleSearchBarBtnClick" />
2023-08-10 16:52:47 +08:00
2023-08-17 09:37:39 +08:00
<!-- 列表 -->
<base-table
:table-props="tableProps"
:page="queryParams.pageNo"
:limit="queryParams.pageSize"
:table-data="list"
@emitFun="handleEmitFun">
<method-btn
v-if="tableBtn.length"
slot="handleBtn"
label="操作"
2023-09-15 15:45:37 +08:00
:width="120"
2023-08-17 09:37:39 +08:00
:method-list="tableBtn"
@clickBtn="handleTableBtnClick" />
</base-table>
2023-08-10 16:52:47 +08:00
2023-08-17 09:37:39 +08:00
<!-- 分页组件 -->
<pagination
v-show="total > 0"
:total="total"
:page.sync="queryParams.pageNo"
:limit.sync="queryParams.pageSize"
@pagination="getList" />
2023-08-10 16:52:47 +08:00
2023-08-17 09:37:39 +08:00
<!-- 对话框(添加 / 修改) -->
<base-dialog
:dialogTitle="title"
:dialogVisible="open"
2023-08-28 09:22:28 +08:00
width="500px"
2023-08-17 09:37:39 +08:00
@close="cancel"
@cancel="cancel"
@confirm="submitForm">
<DialogForm v-if="open" ref="form" :dataForm="form" :rows="rows" />
</base-dialog>
2023-10-09 16:27:44 +08:00
<!-- 抽屉 详情 -->
<BasicDrawer
v-if="editVisible"
ref="drawer"
2023-10-09 17:01:19 +08:00
:default-mode="editMode"
2023-10-10 14:22:00 +08:00
:data-id="alarmForm.id"
2023-10-09 16:27:44 +08:00
:sections="[
{
name: '基本信息',
key: 'base',
rows: drawerBaseInfoRows,
url: '/base/equipment-group/get',
urlUpdate: '/base/equipment-group/update',
urlCreate: '/base/equipment-group/create',
2023-10-10 14:22:00 +08:00
queryParams: { id: alarmForm.id },
2023-10-09 16:27:44 +08:00
},
{
name: '报警明细',
2023-10-09 16:27:44 +08:00
key: 'attrs',
props: drawerListProps,
url: '/base/equipment-group-alarm/page',
urlCreate: '/base/equipment-group-alarm/create',
urlUpdate: '/base/equipment-group-alarm/update',
urlDelete: '/base/equipment-group-alarm/delete',
urlDetail: '/base/equipment-group-alarm/get',
queryParams: {
2023-10-10 14:22:00 +08:00
equipmentGroupId: alarmForm.id,
2023-10-09 16:27:44 +08:00
pageNo: 1,
pageSize: 10,
},
tableBtn: [
this.$auth.hasPermi('equipment:alarm-group:update')
2023-10-09 16:27:44 +08:00
? {
type: 'edit',
btnName: '修改',
}
: undefined,
this.$auth.hasPermi('equipment:alarm-group:delete')
2023-10-09 16:27:44 +08:00
? {
type: 'delete',
btnName: '删除',
}
: undefined,
].filter((v) => v),
allowAdd: true,
},
]"
@refreshDataList="getList"
@cancel="editVisible = false"
@destroy="editVisible = false" />
2023-08-17 09:37:39 +08:00
</div>
2023-08-10 16:52:47 +08:00
</template>
<script>
2023-08-17 09:37:39 +08:00
import {
createEquipmentGroup,
updateEquipmentGroup,
deleteEquipmentGroup,
getEquipmentGroup,
getEquipmentGroupPage,
exportEquipmentGroupExcel,
} from '@/api/base/equipmentGroup';
import moment from 'moment';
2023-10-09 16:27:44 +08:00
import { publicFormatter } from '@/utils/dict';
import basicPageMixin from '@/mixins/lb/basicPageMixin';
2023-10-09 16:27:44 +08:00
// import { getAccessToken } from '@/utils/auth';
import BasicDrawer from './components/BasicDrawer.vue';
2023-08-10 16:52:47 +08:00
export default {
2023-08-17 09:37:39 +08:00
name: 'EquipmentGroup',
mixins: [basicPageMixin],
2023-10-09 16:27:44 +08:00
components: { BasicDrawer },
2023-08-17 09:37:39 +08:00
data() {
return {
2023-10-09 16:27:44 +08:00
editVisible: false,
editMode: '',
2023-08-17 09:37:39 +08:00
searchBarKeys: ['name', 'code'],
tableBtn: [
this.$auth.hasPermi('equipment:alarm-group:update')
2023-10-09 16:27:44 +08:00
? {
type: 'detail',
btnName: '查看报警',
}
: undefined,
this.$auth.hasPermi('equipment:alarm-group:update')
2023-08-17 09:37:39 +08:00
? {
type: 'edit',
btnName: '修改',
}
: undefined,
this.$auth.hasPermi('equipment:alarm-group:delete')
2023-08-17 09:37:39 +08:00
? {
type: 'delete',
btnName: '删除',
}
: undefined,
].filter((v) => v),
tableProps: [
{
prop: 'createTime',
label: '添加时间',
fixed: true,
width: 180,
filter: (val) => moment(val).format('yyyy-MM-DD HH:mm:ss'),
},
2023-09-15 14:30:19 +08:00
{ prop: 'name', label: '设备分组名称' },
{ prop: 'code', label: '设备分组编码' },
{ prop: 'remark', label: '备注' },
2023-10-09 16:27:44 +08:00
// {
// _action: 'equipment-group-show-alert',
// label: '报警',
// subcomponent: {
// props: ['injectData'],
// render: function (h) {
// const _this = this;
// return h(
// 'el-button',
// {
// props: { type: 'text' },
// on: {
// click: function () {
// console.log('inejctdata', _this.injectData);
// _this.$emit('emitData', {
// action: _this.injectData._action,
// // value: _this.injectData.id,
// value: _this.injectData,
// });
// },
// },
// },
// '查看报警'
// );
// },
// },
// },
],
drawerBaseInfoRows: [
[
{
input: true,
label: '设备分组名称',
prop: 'name',
rules: [{ required: true, message: '不能为空', trigger: 'blur' }],
// bind: {
// disabled: this.editMode == 'detail', // some condition, like detail mode...
// }
2023-08-17 09:37:39 +08:00
},
2023-10-09 16:27:44 +08:00
{
input: true,
label: '设备分组编码',
prop: 'code',
2023-10-17 15:22:17 +08:00
// url: '/base/core-equipment/getCode',
},
],
2023-10-09 16:27:44 +08:00
],
drawerListProps: [
{
prop: 'createTime',
label: '添加时间',
fixed: true,
width: 180,
filter: (val) => moment(val).format('yyyy-MM-DD HH:mm:ss'),
2023-08-17 09:37:39 +08:00
},
2023-10-09 16:27:44 +08:00
{ width: 240, prop: 'code', label: '报警编码' },
{
width: 100,
prop: 'type',
label: '报警类型',
filter: (val) =>
val != null ? ['-', '字符型', '布尔型', '-'][val] : '-',
},
{
width: 90,
prop: 'grade',
label: '报警级别',
filter: publicFormatter(this.DICT_TYPE.EQU_ALARM_LEVEL),
},
{ width: 180, prop: 'alarmCode', label: '设备报警编码' },
{ width: 128, prop: 'plcParamName', label: '参数列名' },
{ width: 128, prop: 'alarmContent', label: '报警内容' },
2023-08-17 09:37:39 +08:00
],
2023-10-10 14:22:00 +08:00
alarmForm: {
id: undefined,
equipmentGroupCode: undefined,
equipmentGroupName: undefined,
},
2023-08-17 09:37:39 +08:00
searchBarFormConfig: [
{
type: 'input',
label: '分组名称',
placeholder: '请输入设备分组名称',
param: 'name',
},
{
type: 'input',
label: '分组编码',
placeholder: '请输入设备分组编码',
2023-09-15 14:30:19 +08:00
param: 'code',
2023-08-17 09:37:39 +08:00
},
{
type: 'button',
btnName: '查询',
name: 'search',
color: 'primary',
},
{
type: 'separate',
},
{
type: this.$auth.hasPermi('equipment:alarm-group:create')
2023-08-17 09:37:39 +08:00
? 'button'
: '',
btnName: '新增',
name: 'add',
plain: true,
color: 'success',
},
// {
// type: this.$auth.hasPermi('equipment:alarm-group:export') ? 'button' : '',
2023-08-17 09:37:39 +08:00
// btnName: '导出',
// name: 'export',
// color: 'warning',
// },
],
rows: [
[
{
input: true,
label: '分组名称',
prop: 'name',
rules: [{ required: true, message: '不能为空', trigger: 'blur' }],
// bind: {
// disabled: true, // some condition, like detail mode...
// }
},
],
[
{
input: true,
label: '分组编码',
prop: 'code',
url: '/base/equipment-group/getCode',
2023-09-15 14:30:19 +08:00
rules: [{ required: true, message: '不能为空', trigger: 'blur' }],
2023-08-17 09:37:39 +08:00
},
],
[
{
input: true,
label: '备注',
prop: 'remark',
// rules: [{ required: true, message: '不能为空', trigger: 'blur' }],
bind: {
placeholder: '请输入备注',
},
},
],
],
// 是否显示弹出层
open: false,
// 查询参数
queryParams: {
pageNo: 1,
pageSize: 10,
code: null,
name: null,
},
// 表单参数
form: {},
};
},
created() {
this.getList();
},
methods: {
2023-08-28 14:56:56 +08:00
/** 覆盖 handleEmitFun 的默认实现 */
handleEmitFun({ action, value }) {
const {
id: equipmentGroupId,
name: equipmentGroupName,
code: equipmentGroupCode,
} = value;
switch (action) {
case 'equipment-group-show-alert':
// this.$router.push({ path: '/equipment/base/equipment-group-alarm' });
this.$router.push({
name: 'EquipmentGroupAlarm',
params: {
equipmentGroupId,
equipmentGroupCode,
equipmentGroupName,
},
});
break;
}
},
2023-08-17 09:37:39 +08:00
/** 查询列表 */
getList() {
this.loading = true;
// 执行查询
getEquipmentGroupPage(this.queryParams).then((response) => {
this.list = response.data.list;
this.total = response.data.total;
this.loading = false;
});
},
/** 取消按钮 */
cancel() {
this.open = false;
this.reset();
},
/** 表单重置 */
reset() {
this.form = {
id: undefined,
code: undefined,
name: undefined,
remark: undefined,
};
this.resetForm('form');
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNo = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm('queryForm');
this.handleQuery();
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = '添加设备分组';
2023-08-17 09:37:39 +08:00
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const id = row.id;
getEquipmentGroup(id).then((response) => {
this.form = response.data;
this.open = true;
this.title = '修改设备分组';
2023-08-17 09:37:39 +08:00
});
},
/** 提交按钮 */
submitForm() {
this.$refs['form'].validate((valid) => {
if (!valid) {
return;
}
// 修改的提交
if (this.form.id != null) {
updateEquipmentGroup(this.form).then((response) => {
this.$modal.msgSuccess('修改成功');
this.open = false;
this.getList();
});
return;
}
// 添加的提交
createEquipmentGroup(this.form).then((response) => {
this.$modal.msgSuccess('新增成功');
this.open = false;
this.getList();
});
});
},
2023-10-10 14:22:00 +08:00
// 查看报警
2023-10-09 16:27:44 +08:00
handleDetail(row) {
2023-10-10 14:22:00 +08:00
// debugger;
2023-10-09 16:27:44 +08:00
const { id, code, name, createTime } = row;
// 打开抽屉
this.editMode = 'detail';
2023-10-10 14:22:00 +08:00
this.alarmForm.id = id;
this.alarmForm.equipmentGroupCode = code;
this.alarmForm.equipmentGroupName = name;
2023-10-09 16:27:44 +08:00
this.editVisible = true;
this.$nextTick(() => {
this.$refs['drawer'].init();
});
},
2023-08-17 09:37:39 +08:00
/** 删除按钮操作 */
handleDelete(row) {
const id = row.id;
this.$modal
2023-09-15 14:30:19 +08:00
.confirm('是否确认删除设备分组 "' + row.name + '"?')
2023-08-17 09:37:39 +08:00
.then(function () {
return deleteEquipmentGroup(id);
})
.then(() => {
this.getList();
this.$modal.msgSuccess('删除成功');
})
.catch(() => {});
},
/** 导出按钮操作 */
handleExport() {
// 处理查询参数
let params = { ...this.queryParams };
params.pageNo = undefined;
params.pageSize = undefined;
this.$modal
.confirm('是否确认导出所有设备分组数据项?')
2023-08-17 09:37:39 +08:00
.then(() => {
this.exportLoading = true;
return exportEquipmentGroupExcel(params);
})
.then((response) => {
this.$download.excel(response, '设备分组.xls');
2023-08-17 09:37:39 +08:00
this.exportLoading = false;
})
.catch(() => {});
},
},
2023-08-10 16:52:47 +08:00
};
</script>