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

230 lines
6.1 KiB
Vue

2 years ago
<template>
<div class="lineInformation">
<div class="lineBox">
<div class="lineBtnGroup">
<el-button type="primary" icon="el-icon-plus" @click="handleAddLine()"
>新增</el-button
>
<!-- <el-button type="primary" @click="handleResive()"></el-button>
<el-button type="primary" @click="handleDelete()"></el-button> -->
</div>
<div class="lineTable">
<el-table
ref="multipleTable"
:data="lineTableData"
tooltip-effect="dark"
style="width: 100%"
height="calc(100% - 40px)"
@selection-change="handleSelectionChange"
@row-click="handleRowClick"
>
<!-- <el-table-column type="selection" width="55"> </el-table-column> -->
<el-table-column label="单位" show-overflow-tooltip>
<template slot-scope="scope">{{
scope.row.bsManufacturer
}}</template>
</el-table-column>
<el-table-column
prop="id"
label="线路编号"
show-overflow-tooltip
min-width="120"
>
</el-table-column>
<el-table-column
prop="name"
label="线路名称"
min-width="120"
show-overflow-tooltip
>
</el-table-column>
<el-table-column
prop="status"
label="线路状态"
min-width="120"
show-overflow-tooltip
>
</el-table-column>
<el-table-column
prop="dyLevelname"
label="电压等级名称"
show-overflow-tooltip
min-width="120"
>
</el-table-column>
<el-table-column fixed="right" label="操作" width="200">
<template slot-scope="scope">
<el-button
@click.native.stop="handleResive(scope.row)"
type="text"
>修改</el-button
>
<el-button
type="text"
class="deleteText"
@click.native.stop="handleDelete(scope.row)"
>删除</el-button
>
</template>
</el-table-column>
</el-table>
<div class="pageNation">
<el-pagination
@current-change="handleCurrentChange"
:current-page="page"
:page-size="pageSize"
layout=" prev, pager, next, jumper,total"
:total="total"
background
>
</el-pagination>
</div>
</div>
</div>
<!-- 新增线路 -->
<add-lineDialog
:lineDialog="lineDialog"
:lineDialogTitle="lineDialogTitle"
:formItem="formLineInfo"
@lineDialogClose="lineDialogClose"
></add-lineDialog>
</div>
2 years ago
</template>
<script>
import { getLineListJoggle, deleteLineJoggle } from "@/utils/api/index";
import addLineDialog from "./components/addLineDialog.vue";
2 years ago
export default {
components: {
addLineDialog,
},
data() {
return {
lineDialogTitle: "", //弹窗标题
lineDialog: false,
formLineInfo: {}, //弹窗传值
lineTableData: [],
//multipleSelection: [], //获取当前选中
//删除数组
deleteArr: [],
page: 1, // 当前页数
pageSize: 10, // 每页数量
total: 0, //总条数
};
},
methods: {
//获取线路列表数据
lineList(page, pageSize) {
getLineListJoggle({
pageindex: page,
pagesize: pageSize,
})
.then((res) => {
console.log(res);
this.lineTableData = res.data.list;
this.total = res.data.total;
})
.catch((err) => {
console.log(err); //代码错误、请求失败捕获
});
},
//点击行选中
handleRowClick(row, column, event) {
this.$refs.multipleTable.toggleRowSelection(row);
// console.log(column, row, event);
},
//获取选中的行
handleSelectionChange(val) {
this.multipleSelection = val;
},
// 新建弹窗
handleAddLine() {
this.lineDialog = true;
this.lineDialogTitle = "新增";
},
//handleResive 修改线路数据
handleResive(data) {
console.log(data);
this.lineDialogTitle = "修改";
this.formLineInfo = Object.assign({}, data);
this.lineDialog = true;
},
//新建弹窗取消按钮 关闭弹窗
lineDialogClose(flag) {
if (flag) {
//更新列表
this.lineList(this.page, this.pageSize);
}
this.lineDialog = false;
this.formLineInfo = {};
2 years ago
},
//删除数据
handleDelete(data) {
console.log(data);
this.deleteArr.push({
id: data.id,
});
console.log(this.deleteArr);
this.$confirm("确定要删除记录吗,同时删除关联关系?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
})
.then(() => {
// 行设置向后台请求删除数据
deleteLineJoggle({ list: this.deleteArr }).then((res) => {
console.log(res);
this.lineList(this.page, this.pageSize);
});
this.$message({
type: "success",
message: "删除成功!",
});
})
.catch(() => {
this.$message({
type: "info",
message: "已取消删除",
});
});
},
//点击分页
handleCurrentChange(val) {
console.log(`当前页: ${val}`);
this.page = val;
this.lineList(val, this.pageSize);
},
},
created() {
this.lineList(this.page, this.pageSize);
},
2 years ago
};
</script>
<style lang="less">
.lineInformation {
width: calc(100% - 16px);
height: calc(100% - 32px);
padding: 16px 8px;
background: @color-white;
.lineBox {
border: 1px solid #dddddd;
height: calc(100% - 32px);
padding: 16px;
border-radius: 4px;
}
.lineBtnGroup {
display: flex;
justify-content: flex-end;
}
.lineTable {
margin-top: 16px;
height: calc(100% - 48px);
}
2 years ago
}
</style>