报警类型修改

This commit is contained in:
17630416519 2025-12-19 16:23:26 +08:00
parent f9b6f74d92
commit c0b32706e2

View File

@ -7,273 +7,292 @@
* @LastEditTime: (2025-12-10)
-->
<template>
<div class="app-container">
<!-- :model属性用于表单验证使用 比如下面的el-form-item prop属性用于对表单值进行验证操作 -->
<el-form :model="queryParams" size="small" label-position="right" inline ref="queryForm" :label-width="labelWidth" v-show="showSearch"
@submit.native.prevent>
<el-form-item label="报警类型名称" prop="typeName">
<el-input v-model="queryParams.typeName" placeholder="请输入报警类型名称" clearable size="small" @keyup.enter.native="handleQuery" />
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<!-- 工具区域 -->
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button type="primary" v-hasPermi="['business:andonalarmtypedict:add']" plain icon="el-icon-plus" size="mini" @click="handleAdd">新增</el-button>
</el-col>
<!-- <el-col :span="1.5">
<div class="app-container">
<!-- :model属性用于表单验证使用 比如下面的el-form-item prop属性用于对表单值进行验证操作 -->
<el-form :model="queryParams" size="small" label-position="right" inline ref="queryForm" :label-width="labelWidth"
v-show="showSearch" @submit.native.prevent>
<el-form-item label="报警类型名称" prop="typeName">
<el-input v-model="queryParams.typeName" placeholder="请输入报警类型名称" clearable size="small"
@keyup.enter.native="handleQuery" />
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<!-- 工具区域 -->
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button type="primary" v-hasPermi="['business:andonalarmtypedict:add']" plain icon="el-icon-plus" size="mini"
@click="handleAdd">新增</el-button>
</el-col>
<!-- <el-col :span="1.5">
<el-button type="success" :disabled="single" v-hasPermi="['business:andonalarmtypedict:edit']" plain icon="el-icon-edit" size="mini" @click="handleUpdate">修改</el-button>
</el-col> -->
<el-col :span="1.5">
<el-button type="danger" :disabled="multiple" v-hasPermi="['business:andonalarmtypedict:delete']" plain icon="el-icon-delete" size="mini" @click="handleDelete">删除</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<!-- 数据区域 -->
<el-table :data="dataList" v-loading="loading" ref="table" border highlight-current-row @sort-change="sortChange" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="50" align="center"/>
<!-- <el-table-column prop="id" label="主键" align="center" /> -->
<el-table-column prop="typeCode" label="报警类型编码" align="center" :show-overflow-tooltip="true" />
<el-table-column prop="typeName" label="报警类型名称" align="center" :show-overflow-tooltip="true" />
<el-table-column prop="createdBy" label="创建人" align="center" :show-overflow-tooltip="true" />
<el-table-column prop="createdTime" label="创建时间" align="center" :show-overflow-tooltip="true" />
<el-table-column prop="updatedBy" label="更新人" align="center" :show-overflow-tooltip="true" />
<el-table-column prop="updatedTime" label="更新时间" align="center" :show-overflow-tooltip="true" />
<el-table-column label="操作" align="center" width="140">
<template slot-scope="scope">
<el-button size="mini" v-hasPermi="['business:andonalarmtypedict:edit']" type="success" icon="el-icon-edit" title="编辑"
@click="handleUpdate(scope.row)"></el-button>
<el-button size="mini" v-hasPermi="['business:andonalarmtypedict:delete']" type="danger" icon="el-icon-delete" title="删除"
@click="handleDelete(scope.row)"></el-button>
</template>
</el-table-column>
</el-table>
<pagination class="mt10" background :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />
<!-- 添加或修改报警类型字典对话框 -->
<el-dialog :title="title" :lock-scroll="false" :visible.sync="open" >
<el-form ref="form" :model="form" :rules="rules" :label-width="formLabelWidth">
<el-row :gutter="20">
<el-col :lg="12">
<el-form-item label="报警类型名称" prop="typeName">
<el-input v-model="form.typeName" placeholder="请输入报警类型名称" />
</el-form-item>
</el-col>
</el-row>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="text" @click="cancel"> </el-button>
<el-button type="primary" @click="submitForm"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import {
listAndonAlarmTypeDict,
addAndonAlarmTypeDict,
delAndonAlarmTypeDict,
updateAndonAlarmTypeDict,
getAndonAlarmTypeDict,
} from '@/api/andonManagement/AndonAlarmTypeDict/index.js';
export default {
name: "andonalarmtypedict",
data() {
return {
labelWidth: "100px",
formLabelWidth:"120px",
// id
ids: [],
//
single: true,
//
multiple: true,
//
loading: false,
//
showSearch: true,
//
queryParams: {
pageNum: 1,
pageSize: 10,
sort: undefined,
sortType: undefined,
},
//
title: "",
// 1add 2edit
opertype: 0,
//
open: false,
//
form: {},
columns: [
{ index: 0, key: 'id', label: `主键`, checked: true },
{ index: 1, key: 'typeCode', label: `报警类型编码`, checked: true },
{ index: 2, key: 'typeName', label: `报警类型名称`, checked: true },
{ index: 3, key: 'createdBy', label: `创建人`, checked: true },
{ index: 4, key: 'createdTime', label: `创建时间`, checked: true },
{ index: 5, key: 'updatedBy', label: `更新人`, checked: true },
{ index: 6, key: 'updatedTime', label: `更新时间`, checked: true },
<el-col :span="1.5">
<el-button type="danger" :disabled="multiple" v-hasPermi="['business:andonalarmtypedict:delete']" plain
icon="el-icon-delete" size="mini" @click="handleDelete">删除</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<!-- 数据区域 -->
<el-table :data="dataList" v-loading="loading" ref="table" border highlight-current-row @sort-change="sortChange"
@selection-change="handleSelectionChange">
<el-table-column type="selection" width="50" align="center" />
<!-- <el-table-column prop="id" label="主键" align="center" /> -->
<el-table-column prop="typeCode" label="报警类型编码" align="center" :show-overflow-tooltip="true" />
<el-table-column prop="typeName" label="报警类型名称" align="center" :show-overflow-tooltip="true" />
<el-table-column prop="responseTime" label="最晚响应时间(分钟)" align="center" :show-overflow-tooltip="true" />
<el-table-column prop="createdBy" label="创建人" align="center" :show-overflow-tooltip="true" />
<el-table-column prop="createdTime" label="创建时间" align="center" :show-overflow-tooltip="true" />
<el-table-column prop="updatedBy" label="更新人" align="center" :show-overflow-tooltip="true" />
<el-table-column prop="updatedTime" label="更新时间" align="center" :show-overflow-tooltip="true" />
<el-table-column label="操作" align="center" width="140">
<template slot-scope="scope">
<el-button size="mini" v-hasPermi="['business:andonalarmtypedict:edit']" type="success" icon="el-icon-edit"
title="编辑" @click="handleUpdate(scope.row)"></el-button>
<el-button size="mini" v-hasPermi="['business:andonalarmtypedict:delete']" type="danger" icon="el-icon-delete"
title="删除" @click="handleDelete(scope.row)"></el-button>
</template>
</el-table-column>
</el-table>
<pagination class="mt10" background :total="total" :page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize" @pagination="getList" />
<!-- 添加或修改报警类型字典对话框 -->
<el-dialog :title="title" :lock-scroll="false" :visible.sync="open">
<el-form ref="form" :model="form" :rules="rules" :label-width="formLabelWidth">
<el-row :gutter="20">
<el-col :lg="12">
<el-form-item label="报警类型名称" prop="typeName">
<el-input v-model="form.typeName" placeholder="请输入报警类型名称" />
</el-form-item>
</el-col>
<el-col :lg="12">
<el-form-item label="最晚响应时间" prop="responseTime">
<el-input-number v-model="form.responseTime" @change="handleChange" :min="0"
label="请输入时间"></el-input-number>
</el-form-item>
</el-col>
</el-row>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="text" @click="cancel"> </el-button>
<el-button type="primary" @click="submitForm"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import {
listAndonAlarmTypeDict,
addAndonAlarmTypeDict,
delAndonAlarmTypeDict,
updateAndonAlarmTypeDict,
getAndonAlarmTypeDict,
} from '@/api/andonManagement/AndonAlarmTypeDict/index.js';
export default {
name: "andonalarmtypedict",
data() {
return {
labelWidth: "100px",
formLabelWidth: "120px",
// id
ids: [],
//
single: true,
//
multiple: true,
//
loading: false,
//
showSearch: true,
//
queryParams: {
pageNum: 1,
pageSize: 10,
sort: undefined,
sortType: undefined,
},
//
title: "",
// 1add 2edit
opertype: 0,
//
open: false,
//
form: {
responseTime: 0
},
columns: [
{ index: 0, key: 'id', label: `主键`, checked: true },
{ index: 1, key: 'typeCode', label: `报警类型编码`, checked: true },
{ index: 2, key: 'typeName', label: `报警类型名称`, checked: true },
{ index: 3, key: 'createdBy', label: `创建人`, checked: true },
{ index: 4, key: 'createdTime', label: `创建时间`, checked: true },
{ index: 5, key: 'updatedBy', label: `更新人`, checked: true },
{ index: 6, key: 'updatedTime', label: `更新时间`, checked: true },
],
//
dataList: [],
//
total: 0,
//
btnSubmitVisible: true,
//
rules: {
typeName: [
{ required: true, message: "报警类型名称不能为空", trigger: "blur" },
],
//
dataList: [],
//
total: 0,
//
btnSubmitVisible: true,
//
rules: {
typeName: [
{ required: true, message: "报警类型名称不能为空", trigger: "blur" },
],
},
};
},
created() {
//
this.getList();
var dictParams = [
];
},
methods: {
//
getList() {
this.loading = true;
listAndonAlarmTypeDict(this.queryParams).then(res => {
if (res.code == 200) {
this.dataList = res.data.result;
this.total = res.data.totalNum;
this.loading = false;
}
})
},
//
cancel() {
this.open = false;
this.reset();
},
//
reset() {
this.form = {
id: undefined,
typeCode: undefined,
typeName: undefined,
createdBy: undefined,
createdTime: undefined,
updatedBy: undefined,
updatedTime: undefined,
};
this.resetForm("form");
},
//
resetQuery() {
this.timeRange = [];
this.resetForm("queryForm");
this.handleQuery();
},
//
handleSelectionChange(selection) {
this.ids = selection.map((item) => item.id);
this.single = selection.length != 1
this.multiple = !selection.length;
},
//
sortChange(column) {
if (column.prop == null || column.order == null) {
this.queryParams.sort = undefined;
this.queryParams.sortType = undefined;
} else {
this.queryParams.sort = column.prop;
this.queryParams.sortType = column.order;
};
},
created() {
//
this.getList();
var dictParams = [
];
},
methods: {
//
getList() {
this.loading = true;
listAndonAlarmTypeDict(this.queryParams).then(res => {
if (res.code == 200) {
this.dataList = res.data.result;
this.total = res.data.totalNum;
this.loading = false;
}
this.handleQuery();
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "添加";
this.opertype = 1;
},
/** 删除按钮操作 */
handleDelete(row) {
const Ids = row.id || this.ids;
this.$confirm('是否确认删除参数编号为"' + Ids + '"的数据项?')
.then(function () {
return delAndonAlarmTypeDict(Ids);
})
.then(() => {
this.handleQuery();
this.msgSuccess("删除成功");
})
.catch(() => {});
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const id = row.id || this.ids;
getAndonAlarmTypeDict(id).then((res) => {
const { code, data } = res;
if (code == 200) {
this.open = true;
this.title = "修改数据";
this.opertype = 2;
this.form = {
...data,
};
}
});
},
/** 提交按钮 */
submitForm: function () {
this.$refs["form"].validate((valid) => {
if (valid) {
console.log(JSON.stringify(this.form));
if (this.form.id != undefined && this.opertype === 2) {
updateAndonAlarmTypeDict(this.form)
.then((res) => {
this.msgSuccess("修改成功");
this.open = false;
this.getList();
})
.catch((err) => {
//TODO
});
} else {
addAndonAlarmTypeDict(this.form)
.then((res) => {
this.msgSuccess("新增成功");
this.open = false;
this.getList();
})
.catch((err) => {
//TODO
});
}
}
});
},
})
},
};
</script>
//
cancel() {
this.open = false;
this.reset();
},
//
reset() {
this.form = {
id: undefined,
typeCode: undefined,
typeName: undefined,
createdBy: undefined,
createdTime: undefined,
updatedBy: undefined,
updatedTime: undefined,
responseTime: 0
};
this.resetForm("form");
},
handleChange(val) {
this.form.responseTime = val
},
//
resetQuery() {
this.timeRange = [];
this.resetForm("queryForm");
this.handleQuery();
},
//
handleSelectionChange(selection) {
this.ids = selection.map((item) => item.id);
this.single = selection.length != 1
this.multiple = !selection.length;
},
//
sortChange(column) {
if (column.prop == null || column.order == null) {
this.queryParams.sort = undefined;
this.queryParams.sortType = undefined;
} else {
this.queryParams.sort = column.prop;
this.queryParams.sortType = column.order;
}
this.handleQuery();
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "添加";
this.opertype = 1;
},
/** 删除按钮操作 */
handleDelete(row) {
const Ids = row.id || this.ids;
this.$confirm('是否确认删除参数编号为"' + Ids + '"的数据项?')
.then(function () {
return delAndonAlarmTypeDict(Ids);
})
.then(() => {
this.handleQuery();
this.msgSuccess("删除成功");
})
.catch(() => { });
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const id = row.id || this.ids;
getAndonAlarmTypeDict(id).then((res) => {
const { code, data } = res;
if (code == 200) {
this.open = true;
this.title = "修改数据";
this.opertype = 2;
this.form = {
...data,
};
}
});
},
/** 提交按钮 */
submitForm: function () {
this.$refs["form"].validate((valid) => {
if (valid) {
console.log(JSON.stringify(this.form));
if (this.form.id != undefined && this.opertype === 2) {
updateAndonAlarmTypeDict(this.form)
.then((res) => {
this.msgSuccess("修改成功");
this.open = false;
this.getList();
})
.catch((err) => {
//TODO
});
} else {
addAndonAlarmTypeDict(this.form)
.then((res) => {
this.msgSuccess("新增成功");
this.open = false;
this.getList();
})
.catch((err) => {
//TODO
});
}
}
});
},
},
};
</script>