You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

520 lines
13 KiB

<template>
<div class="">
<el-breadcrumb separator="/" style="margin-bottom: 20px">
<el-breadcrumb-item
v-for="(item, index) in routeList"
:key="item + index"
:to="{ path: item.path }"
>
{{ item.routeName }}
</el-breadcrumb-item>
</el-breadcrumb>
<el-form
:model="queryParams"
ref="queryForm"
:inline="true"
v-show="showSearch"
label-width="68px"
>
<el-form-item label="关联水闸" prop="wagaId">
<el-select
v-model="queryParams.data.wagaId"
placeholder="请选择关联水闸"
style="width: 100%"
@change="handleQuery"
>
<el-option
v-for="dict in wagaNameOptions"
:key="dict.id"
:label="dict.wagaName"
:value="dict.id"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="备用电源种类" prop="powerType" label-width="96px">
<el-select
v-model="queryParams.data.powerType"
placeholder="请选择备用电源种类"
clearable
size="small"
>
<el-option
v-for="dict in powerTypeOptions"
:key="dict.dictValue"
:label="dict.dictLabel"
:value="dict.dictValue"
/>
</el-select>
</el-form-item>
<el-form-item>
<!-- <el-button
type="cyan"
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"
icon="el-icon-plus"
size="mini"
@click="handleAdd"
v-hasPermi="['bydyzb:bydyzb:add']"
>新增电源种类</el-button
>
</el-col>
<el-col :span="1.5">
<el-button
type="success"
icon="el-icon-edit"
size="mini"
:disabled="single"
@click="handleUpdate"
v-hasPermi="['bydyzb:bydyzb:edit']"
>修改</el-button
>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
icon="el-icon-delete"
size="mini"
:disabled="multiple"
@click="handleDelete"
v-hasPermi="['bydyzb:bydyzb:remove']"
>删除</el-button
>
</el-col>
<right-toolbar
:showSearch.sync="showSearch"
@queryTable="getList"
></right-toolbar>
</el-row>
<el-table
v-loading="loading"
:data="bydyzbList"
@selection-change="handleSelectionChange"
>
<el-table-column type="selection" width="55" align="center" fixed />
<el-table-column
label="序号"
type="index"
width="50"
align="center"
fixed
/>
<el-table-column
label="关联水闸"
align="center"
prop="wagaId"
:formatter="wageIdFormat"
min-width="120"
/>
<el-table-column
label="备用电源数量(字段未有)"
align="center"
prop="powerNumber"
min-width="120"
/>
<el-table-column
label="备用电源种类"
align="center"
prop="powerType"
:formatter="powerTypeFormat"
min-width="120"
/>
<el-table-column
label="操作"
align="center"
class-name="small-padding fixed-width"
width="210"
fixed="right"
>
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
v-hasPermi="['bydyzb:bydyzb:edit']"
>修改</el-button
>
<el-button
size="mini"
type="text"
icon="el-icon-plus"
@click="addPowerList(scope.row)"
v-hasPermi="['bydyzb:bydyzb:addPowerList']"
>新增电源</el-button
>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['bydyzb:bydyzb:remove']"
>删除</el-button
>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total > 0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<!-- 添加或修改备用电源种类 -->
<el-dialog
:title="title"
:visible.sync="open"
width="800px"
append-to-body
:close-on-click-modal="false"
>
<el-form ref="form" :model="form" :rules="rules" label-width="110px">
<el-form-item label="关联水闸" prop="wagaId">
<!-- <el-input v-model="form.wagaId" placeholder="请输入水闸id" /> -->
<el-select
v-model="form.wagaId"
placeholder="请选择关联水闸"
style="width: 100%"
>
<el-option
v-for="dict in wagaNameOptions"
:key="dict.id"
:label="dict.wagaName"
:value="dict.id"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="备用电源种类" prop="powerType">
<el-select
v-model="form.powerType"
placeholder="请选择备用电源种类"
style="width: 100%"
>
<el-option
v-for="dict in powerTypeOptions"
:key="dict.dictValue"
:label="dict.dictLabel"
:value="dict.dictValue"
></el-option>
</el-select>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
<!-- 备用电源 -->
<el-dialog
:title="addTitle"
:visible.sync="addOpen"
width="1200px"
append-to-body
:close-on-click-modal="false"
@close="close"
>
<el-tabs v-model="activeName" style="margin-bottom: 20px" v-if="addOpen">
<el-tab-pane label="备用电源信息" name="powerList" :lazy="true">
<powerList ref="powerList" :prowerTypeId="prowerTypeId" />
</el-tab-pane>
<el-tab-pane label="试运行记录" name="powerRecords" :lazy="true">
<powerRecords
:prowerTypeId="prowerTypeId"
v-if="activeName === 'powerRecords'"
/>
</el-tab-pane>
</el-tabs>
</el-dialog>
</div>
</template>
<script>
import {
listBydyzb,
getBydyzb,
delBydyzb,
addBydyzb,
updateBydyzb,
exportBydyzb,
} from "@/api/yg/bydyzb";
import { listJbxx, getJbxx } from "@/api/yg/jbxx";
import powerList from "./components/powerList.vue";
import powerRecords from "./components/powerRecords.vue";
export default {
name: "Bydyzb",
components: {
powerList,
powerRecords,
},
data() {
return {
// 面包屑,路由信息
routeList: [
{
path: "/dike/safetyManage/floodControlManagement/power",
routeName: "防汛电源管理",
},
],
activeName: "powerList",
// 遮罩层
loading: true,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
// 水闸备用电源主表格数据
bydyzbList: [],
// 弹出层标题
title: "",
addTitle: "",
// 是否显示弹出层
open: false,
addOpen: false,
// 电源种类字典
powerTypeOptions: [],
// 水闸项目
wagaNameOptions: [],
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
ids: null,
data: {
wagaId: null,
powerType: null,
powerModel: null,
wagaName: null,
createUid: null,
updateUid: null,
owerDept: null,
relation: null,
},
// 排序方式
params: {
// 按哪个字段排序
orderBy: "create_time",
// desc降序,升序asc
sortBy: "desc",
},
},
// 表单参数
form: {},
// 表单校验
rules: {
wagaId: [
{ required: true, message: "请选择关联水闸", trigger: "blur" },
],
powerType: [
{ required: true, message: "请选择备用电源种类", trigger: "blur" },
],
},
prowerTypeId: "",
};
},
created() {
this.getList();
listJbxx({ data: {} }).then((res) => {
this.wagaNameOptions = res.records;
});
this.getDicts("type_of_power").then((response) => {
this.powerTypeOptions = response.data;
});
},
methods: {
close() {
this.activeName = "powerList";
},
addPowerList(row) {
this.prowerTypeId = row.id;
this.addTitle = "管理备用电源信息";
this.addOpen = true;
},
/** 查询水闸备用电源主列表 */
getList() {
this.loading = true;
listBydyzb(this.queryParams).then((response) => {
this.bydyzbList = response.records;
this.total = response.total;
this.loading = false;
});
},
wageIdFormat(row) {
const id = row.wagaId;
let data = this.wagaNameOptions.find((res) => res.id == id);
if (data) return data.wagaName;
},
// 电源种类字典翻译
powerTypeFormat(row, column) {
return this.selectDictLabel(this.powerTypeOptions, row.powerType);
},
// 取消按钮
cancel() {
this.open = false;
this.reset();
},
// 表单重置
reset() {
this.form = {
id: null,
wagaId: null,
powerType: null,
powerModel: null,
wagaName: null,
createUid: null,
updateUid: null,
createTime: null,
updateTime: null,
owerDept: null,
remark: null,
relation: null,
};
this.resetForm("form");
},
// 查询表单重置
resetQueryForm() {
this.queryParams = {
pageNum: 1,
pageSize: 10,
data: {
id: null,
wagaId: null,
powerType: null,
powerModel: null,
wagaName: null,
createUid: null,
updateUid: null,
createTime: null,
updateTime: null,
owerDept: null,
remark: null,
relation: null,
},
// 排序方式
params: {
// 按哪个字段排序
orderBy: "create_time",
// desc降序,升序asc
sortBy: "desc",
},
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetQueryForm();
this.handleQuery();
},
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map((item) => item.id);
this.single = selection.length !== 1;
this.multiple = !selection.length;
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "添加水闸备用电源主";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const id = row.id || this.ids;
getBydyzb(id).then((response) => {
this.form = response.data;
this.open = true;
this.title = "修改水闸备用电源主";
});
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate((valid) => {
if (valid) {
if (this.form.id != null) {
updateBydyzb(this.form).then((response) => {
if (response.code === 200) {
this.msgSuccess("修改成功");
this.open = false;
this.getList();
}
});
} else {
addBydyzb(this.form).then((response) => {
if (response.code === 200) {
this.msgSuccess("新增成功");
this.open = false;
this.getList();
}
});
}
}
});
},
/** 删除按钮操作 */
handleDelete(row) {
const ids = row.id || this.ids;
if (ids) {
this.$confirm("是否删除选中的数据?", "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
})
.then(function () {
return delBydyzb(ids);
})
.then(() => {
this.getList();
this.msgSuccess("删除成功");
})
.catch(function () {});
} else {
this.$message.warning("请选择要删除的数据!!");
}
},
},
};
</script>
<style lang="scss" scoped>
@import "@/assets/css/dialog.scss";
::v-deep {
// .el-dialog {
// margin-top: 2vh !important;
// }
.el-tabs__content {
height: 500px;
overflow: auto;
}
}
</style>