Commit cadb12e9 authored by “yiyousong”'s avatar “yiyousong”

perf: 大厅管理优化

parent 0eb9e859
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
</template> </template>
<script> <script>
import { pageSizeOptions } from "@/config/pageConfig.js";
export default { export default {
props: { props: {
columns: { columns: {
...@@ -90,7 +91,7 @@ export default { ...@@ -90,7 +91,7 @@ export default {
}, },
pageSizeOptions: { pageSizeOptions: {
type: Array, type: Array,
default: () => ["10", "30", "50", "100", "200"], default: () => pageSizeOptions,
}, },
}, },
data() { data() {
......
...@@ -18,56 +18,39 @@ ...@@ -18,56 +18,39 @@
</div> </div>
<!-- 表格 --> <!-- 表格 -->
<div class="table-content"> <div class="table-content">
<a-table <y-table
:columns="columns"
:data="dataList"
:pageSize.sync="size"
:page.sync="page"
:total="total"
:loading="loading"
:scroll="{ y: 580 }"
:row-selection="{ :row-selection="{
selectedRowKeys: selectedRowKeys, selectedRowKeys: selectedRowKeys,
onChange: onSelectChange, onChange: onSelectChange,
}" }"
:loading="loading" @changePagination="getHallList"
bordered
:scroll="{ y: 580 }"
:columns="columns"
:pagination="{
showTotal: (total) => `共 ${total} 条`,
current: current,
total: total,
pageSize: size,
showSizeChanger: true,
showQuickJumper: true,
pageSizeOptions: pageSizeOptions,
onChange: handleChange,
onShowSizeChange: showSizeChange,
}"
:data-source="dataList"
:rowKey="(record) => record.id"
> >
<!-- 序号 --> <span slot="index" slot-scope="{ index }">{{
<span slot="num" slot-scope="text, record, index">{{ (page - 1) * size + index + 1
(current - 1) * size + index + 1
}}</span> }}</span>
<!-- 创建时间 --> <!-- 创建时间 -->
<template slot="createTime" slot-scope="text"> <template slot="createTime" slot-scope="{ record }">
{{ text.createTime | dateFormat }} {{ record.createTime | dateFormat }}
</template> </template>
<!-- 操作 --> <!-- 操作 -->
<template slot="action" slot-scope="text"> <template slot="action" slot-scope="{ record }">
<a-space size="middle"> <a-space size="middle">
<span <span class="primary pointer" @click="handleEdit(record)"
href="javascript:;"
class="primary pointer"
@click="handleEdit(text)"
>编辑</span >编辑</span
> >
<span <span class="delete pointer" @click="handleDel(record.id)"
href="javascript:;"
class="delete pointer"
@click="handleDel(text.id)"
>删除</span >删除</span
> >
</a-space> </a-space>
</template> </template>
</a-table> </y-table>
</div> </div>
<!-- 新增、修改大厅 --> <!-- 新增、修改大厅 -->
<AddHall <AddHall
...@@ -81,21 +64,22 @@ ...@@ -81,21 +64,22 @@
<script> <script>
import { getHallList, delHall } from "@/services/hall"; import { getHallList, delHall } from "@/services/hall";
import { pageSizeOptions } from "@/config/pageConfig.js";
import loacl from "@/utils/local"; import loacl from "@/utils/local";
import AddHall from "./modal/AddHall.vue"; import AddHall from "./modal/AddHall.vue";
import YTable from "@/components/YTable.vue";
export default { export default {
components: { components: {
AddHall, AddHall,
YTable,
}, },
data() { data() {
const columns = [ const columns = [
{ {
title: "序号", title: "序号",
dataIndex: "num", dataIndex: "index",
width: "65px", width: "65px",
scopedSlots: { scopedSlots: {
customRender: "num", customRender: "index",
}, },
}, },
{ {
...@@ -144,11 +128,10 @@ export default { ...@@ -144,11 +128,10 @@ export default {
title: "新增大厅", title: "新增大厅",
visible: false, visible: false,
selectedRowKeys: [], selectedRowKeys: [],
current: 1, page: 1,
size: 10, size: 10,
total: 0, total: 0,
siteId: loacl.getLocal("siteId"), siteId: loacl.getLocal("siteId"),
pageSizeOptions,
searchValue: "", // 搜索 searchValue: "", // 搜索
dataList: [], dataList: [],
}; };
...@@ -161,15 +144,15 @@ export default { ...@@ -161,15 +144,15 @@ export default {
async getHallList() { async getHallList() {
this.loading = true; this.loading = true;
let res = await getHallList({ let res = await getHallList({
page: this.current, page: this.page,
size: this.size, size: this.size,
hallName: `%${this.searchValue}%`, hallName: `%${this.searchValue}%`,
siteId: this.siteId, siteId: this.siteId,
}); });
if (res.data.code == 1) { if (res.data.code == 1) {
let { data, total } = res.data.data; let { data, total } = res.data.data;
if (!data.length && this.current > 1) { if (!data.length && this.page > 1) {
this.current -= 1; this.page -= 1;
this.getHallList(); this.getHallList();
} }
this.total = total; this.total = total;
...@@ -185,7 +168,7 @@ export default { ...@@ -185,7 +168,7 @@ export default {
}, },
// 搜索 // 搜索
onSearch() { onSearch() {
this.current = 1; this.page = 1;
this.selectedRowKeys = []; this.selectedRowKeys = [];
this.getHallList(); this.getHallList();
}, },
...@@ -233,20 +216,8 @@ export default { ...@@ -233,20 +216,8 @@ export default {
}, },
}); });
}, },
// 翻页
handleChange(cur) {
this.current = cur;
this.getHallList();
},
// 改变每页显示数量
showSizeChange(cur, size) {
this.current = cur;
this.size = size;
this.getHallList();
},
}, },
}; };
</script> </script>
<style lang="less" scoped> <style lang="less" scoped></style>
</style>
\ No newline at end of file
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
<a-space> <a-space>
<a-select <a-select
style="min-width: 120px" style="min-width: 120px"
v-model="leftHallSearch" v-model="hallTable.searchForm.hallId"
showSearch showSearch
optionFilterProp="label" optionFilterProp="label"
> >
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
<a-input-search <a-input-search
placeholder="请输入窗口名称搜索" placeholder="请输入窗口名称搜索"
enter-button="搜索" enter-button="搜索"
v-model="leftSearchVal" v-model="hallTable.searchForm.windowName"
@search="onSearchLeft" @search="onSearchLeft"
allowClear allowClear
/> />
...@@ -38,44 +38,31 @@ ...@@ -38,44 +38,31 @@
</div> </div>
<div class="table-content"> <div class="table-content">
<!-- 表格 --> <!-- 表格 -->
<a-table <y-table
bordered :columns="hallTable.columns"
:loading="leftLoading" :data="hallTable.data"
:pageSize.sync="hallTable.size"
:page.sync="hallTable.page"
:total="hallTable.total"
:loading="hallTable.loading"
size="middle" size="middle"
:scroll="{ y: 550 }" :scroll="{ y: 550 }"
:pagination="{ @changePagination="getWindowHallList"
showTotal: (total) => `共 ${total} 条`,
current: leftCurrent,
total: leftTotal,
pageSize: leftSize,
showSizeChanger: true,
showQuickJumper: true,
pageSizeOptions: pageSizeOptions,
onChange: changeLeft,
onShowSizeChange: showSizeChange,
}"
:columns="leftColumns"
:data-source="hallWindowData"
:row-selection="{ :row-selection="{
selectedRowKeys: selectedLeftRowKeys, selectedRowKeys: selectedLeftRowKeys,
onChange: onSelectChange, onChange: onSelectChange,
}" }"
:rowKey="(record) => record.id"
> >
<template slot="num" slot-scope="text, record, index"> <span slot="index" slot-scope="{ index }">{{
<span> (hallTable.page - 1) * hallTable.size + index + 1
{{ (leftCurrent - 1) * leftSize + index + 1 }} }}</span>
</span>
</template> <template slot="action" slot-scope="{ record }">
<template slot="action" slot-scope="text"> <span class="delete pointer" @click="handleDel(record.id)"
<span
href="javascript:;"
class="delete pointer"
@click="handleDel(text.id)"
>移除</span >移除</span
> >
</template> </template>
</a-table> </y-table>
</div> </div>
</div> </div>
<!-- 右 --> <!-- 右 -->
...@@ -90,7 +77,7 @@ ...@@ -90,7 +77,7 @@
<a-space> <a-space>
<a-select <a-select
style="min-width: 120px" style="min-width: 120px"
v-model="deptSearch" v-model="siteWinTable.searchForm.deptId"
showSearch showSearch
optionFilterProp="label" optionFilterProp="label"
> >
...@@ -109,7 +96,7 @@ ...@@ -109,7 +96,7 @@
<a-input-search <a-input-search
placeholder="请输入窗口编号搜索" placeholder="请输入窗口编号搜索"
enter-button="搜索" enter-button="搜索"
v-model="rightSearchVal" v-model="siteWinTable.searchForm.fromnum"
@search="onSearch" @search="onSearch"
allowClear allowClear
/> />
...@@ -118,45 +105,33 @@ ...@@ -118,45 +105,33 @@
</div> </div>
</div> </div>
<div class="table-content"> <div class="table-content">
<!-- 表格 --> <y-table
<a-table :columns="siteWinTable.columns"
bordered :data="siteWinTable.data"
:scroll="{ y: 550 }" :pageSize.sync="siteWinTable.size"
:loading="rightLoading" :page.sync="siteWinTable.page"
:pagination="{ :total="siteWinTable.total"
showTotal: (total) => `共 ${total} 条`, :loading="siteWinTable.loading"
current: rightCurrent,
total: rightTotal,
pageSize: rightSize,
showSizeChanger: true,
showQuickJumper: true,
pageSizeOptions: pageSizeOptions,
onChange: changeRight,
onShowSizeChange: showSizeChangeRight,
}"
size="middle" size="middle"
:scroll="{ y: 550 }"
@changePagination="getSubHalllist"
:row-selection="{ :row-selection="{
selectedRowKeys: selectedRowKeys, selectedRowKeys: selectedRowKeys,
onChange: onRightSelectChange, onChange: onRightSelectChange,
}" }"
:columns="rightColumns"
:data-source="siteWindowData"
:rowKey="(record) => record.id"
> >
<template slot="num" slot-scope="text, record, index"> <span slot="index" slot-scope="{ index }">{{
<span> (hallTable.page - 1) * hallTable.size + index + 1
{{ (rightCurrent - 1) * rightSize + index + 1 }} }}</span>
</span>
</template>
<template slot="action" slot-scope="text"> <template slot="action" slot-scope="{ record }">
<a-space size="middle"> <a-space size="middle">
<span class="primary pointer" @click="handleIn([text])" <span class="primary pointer" @click="handleIn([record])"
>加入大厅</span >加入大厅</span
> >
</a-space> </a-space>
</template> </template>
</a-table> </y-table>
</div> </div>
</div> </div>
<!-- 添加大厅窗口 --> <!-- 添加大厅窗口 -->
...@@ -171,90 +146,96 @@ ...@@ -171,90 +146,96 @@
<script> <script>
import { getHallList, getWindowHallList, delWindowHall } from "@/services/hall"; import { getHallList, getWindowHallList, delWindowHall } from "@/services/hall";
import { pageSizeOptions } from "@/config/pageConfig.js";
import WindowToHall from "./modal/WindowToHall.vue"; import WindowToHall from "./modal/WindowToHall.vue";
import YTable from "@/components/YTable.vue";
import local from "@/utils/local"; import local from "@/utils/local";
import { getDeptList, getSubHalllist } from "@/services/dept"; import { getDeptList, getSubHalllist } from "@/services/dept";
const leftColumns = [
{
title: "序号",
width: "50px",
scopedSlots: { customRender: "num" },
},
{
title: "窗口名称",
dataIndex: "windowName",
},
{
title: "窗口编号",
dataIndex: "fromnum",
},
{
title: "所属大厅",
dataIndex: "hallName",
},
{
title: "操作",
width: "110px",
scopedSlots: {
customRender: "action",
},
},
];
const rightColumns = [
{
title: "序号",
key: "id",
width: "50px",
scopedSlots: { customRender: "num" },
},
{
title: "窗口名称",
dataIndex: "name",
},
{
title: "编号",
dataIndex: "fromnum",
},
{
title: "所属部门",
dataIndex: "deptName",
},
{
title: "操作",
width: "110px",
scopedSlots: {
customRender: "action",
},
},
];
export default { export default {
components: { WindowToHall }, components: { WindowToHall, YTable },
data() { data() {
return { return {
leftColumns,
rightColumns,
hallList: [], // 大厅列表 hallList: [], // 大厅列表
deptList: [], // 部门列表 deptList: [], // 部门列表
leftHallSearch: "", hallTable: {
deptSearch: "", data: [],
leftSearchVal: "", page: 1,
rightSearchVal: "", size: 10,
leftLoading: false, total: 0,
rightLoading: false, searchForm: {
hallId: "",
windowName: "",
},
loading: false,
columns: [
{
title: "序号",
width: "50px",
scopedSlots: { customRender: "index" },
},
{
title: "窗口名称",
dataIndex: "windowName",
},
{
title: "窗口编号",
dataIndex: "fromnum",
},
{
title: "所属大厅",
dataIndex: "hallName",
},
{
title: "操作",
width: "110px",
scopedSlots: {
customRender: "action",
},
},
],
},
siteWinTable: {
data: [],
page: 1,
size: 10,
total: 0,
searchForm: {
fromnum: "",
deptId: "",
},
loading: false,
columns: [
{
title: "序号",
key: "id",
width: "50px",
scopedSlots: { customRender: "index" },
},
{
title: "窗口名称",
dataIndex: "name",
},
{
title: "编号",
dataIndex: "fromnum",
},
{
title: "所属部门",
dataIndex: "deptName",
},
{
title: "操作",
width: "110px",
scopedSlots: {
customRender: "action",
},
},
],
},
selectedLeftRowKeys: [], selectedLeftRowKeys: [],
selectedRowKeys: [], selectedRowKeys: [],
selectedRows: [], selectedRows: [],
visible: false, visible: false,
leftCurrent: 1,
rightCurrent: 1,
leftTotal: 0,
rightTotal: 0,
leftSize: 10,
rightSize: 10,
pageSizeOptions,
siteId: local.getLocal("siteId"), // 站点id siteId: local.getLocal("siteId"), // 站点id
hallWindowData: [], // 大厅窗口数据 hallWindowData: [], // 大厅窗口数据
siteWindowData: [], // 站点窗口数据 siteWindowData: [], // 站点窗口数据
...@@ -293,45 +274,45 @@ export default { ...@@ -293,45 +274,45 @@ export default {
}, },
// 获取大厅窗口列表 // 获取大厅窗口列表
async getWindowHallList() { async getWindowHallList() {
this.leftLoading = true; this.hallTable.loading = true;
let res = await getWindowHallList({ let res = await getWindowHallList({
page: this.leftCurrent, page: this.hallTable.page,
size: this.leftSize, size: this.hallTable.size,
siteId: this.siteId, siteId: this.siteId,
windowName: `%${this.leftSearchVal}%`, windowName: `%${this.hallTable.searchForm.windowName}%`,
hallId: this.leftHallSearch, hallId: this.hallTable.searchForm.hallId,
}); });
if (res.data.code == 1) { if (res.data.code == 1) {
let { data, total } = res.data.data; let { data, total } = res.data.data;
if (!data.length && this.leftCurrent > 1) { if (!data.length && this.hallTable.page > 1) {
this.leftCurrent -= 1; this.hallTable.page -= 1;
this.getWindowHallList(); this.getWindowHallList();
} }
this.hallWindowData = data; this.hallTable.data = data;
this.leftTotal = total; this.hallTable.total = total;
} }
this.leftLoading = false; this.hallTable.loading = false;
}, },
// 获取站点差集窗口列表 // 获取站点差集窗口列表
async getSubHalllist() { async getSubHalllist() {
this.rightLoading = true; this.siteWinTable.loading = true;
let res = await getSubHalllist({ let res = await getSubHalllist({
page: this.rightCurrent, page: this.siteWinTable.page,
size: this.rightSize, size: this.siteWinTable.size,
siteId: this.siteId, siteId: this.siteId,
fromnum: `%${this.rightSearchVal}%`, fromnum: `%${this.siteWinTable.searchForm.fromnum}%`,
deptId: this.deptSearch, deptId: this.siteWinTable.searchForm.deptId,
}); });
if (res.data.code == 1) { if (res.data.code == 1) {
let { data, total } = res.data.data; let { data, total } = res.data.data;
this.siteWindowData = data; this.siteWinTable.data = data;
this.rightTotal = total; this.siteWinTable.total = total;
} }
this.rightLoading = false; this.siteWinTable.loading = false;
}, },
// 左边搜索 // 左边搜索
onSearchLeft() { onSearchLeft() {
this.leftCurrent = 1; this.hallTable.page = 1;
this.selectedLeftRowKeys = []; this.selectedLeftRowKeys = [];
this.getWindowHallList(); this.getWindowHallList();
}, },
...@@ -397,31 +378,9 @@ export default { ...@@ -397,31 +378,9 @@ export default {
this.handleIn(this.selectedRows); this.handleIn(this.selectedRows);
}, },
// 左翻页 // 站点窗口搜索
changeLeft(cur) {
this.leftCurrent = cur;
this.getWindowHallList();
},
// 左边改变每页显示数量
showSizeChange(current, size) {
this.leftCurrent = current;
this.leftSize = size;
this.getWindowHallList();
},
// 右翻页
changeRight(cur) {
this.rightCurrent = cur;
this.getSubHalllist();
},
// 右边改变显示数量
showSizeChangeRight(current, size) {
this.rightCurrent = current;
this.rightSize = size;
this.getSubHalllist();
},
// 搜索
async onSearch() { async onSearch() {
this.rightCurrent = 1; this.siteWinTable.page = 1;
this.getSubHalllist(); this.getSubHalllist();
}, },
// 加入 // 加入
...@@ -485,4 +444,4 @@ export default { ...@@ -485,4 +444,4 @@ export default {
background-color: #04cb8f; background-color: #04cb8f;
color: #fff; color: #fff;
} }
</style> </style>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment