Commit 0eb9e859 authored by “yiyousong”'s avatar “yiyousong”

perf: 优化模块管理

parent b840f6b9
...@@ -26,54 +26,48 @@ ...@@ -26,54 +26,48 @@
</div> </div>
<!-- 表格 --> <!-- 表格 -->
<div class="table-content"> <div class="table-content">
<a-table <y-table
:columns="columns"
:data="tableData"
:pageSize.sync="size"
:page.sync="page"
:total="total"
:loading="loading"
:scroll="{ y: 600 }"
:row-selection="{ :row-selection="{
selectedRowKeys: selectedRowKeys, selectedRowKeys: selectedRowKeys,
onChange: onSelectChange, onChange: onSelectChange,
}" }"
:loading="loading" @changePagination="getStatementList"
bordered
:scroll="{ y: 460 }"
:columns="columns"
:pagination="{
showTotal: (total) => `共 ${total} 条`,
current: current,
total: total,
pageSize: size,
showSizeChanger: true,
showQuickJumper: true,
pageSizeOptions: pageSizeOptions,
onChange: handleChange,
onShowSizeChange: showSizeChange,
}"
:data-source="tableData"
:rowKey="(record) => record.id"
> >
<!-- 序号 --> <!-- 序号 -->
<span slot="num" slot-scope="text, record, index">{{ <span slot="index" slot-scope="{ index }">{{
(current - 1) * size + index + 1 (page - 1) * size + index + 1
}}</span> }}</span>
<!-- 统计类型 --> <!-- 统计类型 -->
<template slot="censusType" slot-scope="text"> <template slot="censusType" slot-scope="{ record }">
{{ filterDict(text.censusType) }} {{ filterDict(record.censusType) }}
</template> </template>
<!-- 是否开放 --> <!-- 是否开放 -->
<template slot="status" slot-scope="text"> <template slot="status" slot-scope="{ record }">
<a-tag color="blue" v-if="text.status === 1"></a-tag> <a-tag color="blue" v-if="record.status === 1"></a-tag>
<a-tag color="red" v-else></a-tag> <a-tag color="red" v-else></a-tag>
</template> </template>
<!-- 操作 --> <!-- 操作 -->
<template slot="action" slot-scope="text"> <template slot="action" slot-scope="{ record }">
<a-space> <a-space>
<a href="javascript:;" class="edit" @click="handleEdit(text)" <a href="javascript:;" class="edit" @click="handleEdit(record)"
>编辑</a >编辑</a
> >
<a href="javascript:;" class="delete" @click="handleDel(text.id)" <a
href="javascript:;"
class="delete"
@click="handleDel(record.id)"
>删除</a >删除</a
> >
</a-space> </a-space>
</template> </template>
</a-table> </y-table>
</div> </div>
<!-- 新增报表 --> <!-- 新增报表 -->
<AddStatement <AddStatement
...@@ -90,14 +84,14 @@ ...@@ -90,14 +84,14 @@
<script> <script>
import { getStatementList, delStatement } from "@/services/basicsetFun"; import { getStatementList, delStatement } from "@/services/basicsetFun";
import AddStatement from "../modal/AddStatement.vue"; import AddStatement from "../modal/AddStatement.vue";
import { pageSizeOptions } from "@/config/pageConfig.js"; import YTable from "@/components/YTable.vue";
const columns = [ const columns = [
{ {
title: "序号", title: "序号",
dataIndex: "num", dataIndex: "index",
width: "65px", width: "65px",
scopedSlots: { scopedSlots: {
customRender: "num", customRender: "index",
}, },
}, },
{ {
...@@ -132,6 +126,7 @@ export default { ...@@ -132,6 +126,7 @@ export default {
}, },
components: { components: {
AddStatement, AddStatement,
YTable,
}, },
data() { data() {
return { return {
...@@ -140,8 +135,7 @@ export default { ...@@ -140,8 +135,7 @@ export default {
loading: false, loading: false,
total: 0, total: 0,
size: 10, size: 10,
current: 1, page: 1,
pageSizeOptions,
selectedRowKeys: [], selectedRowKeys: [],
tableData: [], tableData: [],
addStatementVisile: false, addStatementVisile: false,
...@@ -170,7 +164,7 @@ export default { ...@@ -170,7 +164,7 @@ export default {
async getStatementList() { async getStatementList() {
this.loading = true; this.loading = true;
let res = await getStatementList({ let res = await getStatementList({
page: this.current, page: this.page,
size: this.size, size: this.size,
modelId: this.modelInfo.id, modelId: this.modelInfo.id,
censusName: `%${this.censusName}%`, censusName: `%${this.censusName}%`,
...@@ -179,8 +173,8 @@ export default { ...@@ -179,8 +173,8 @@ export default {
this.dict = dict; this.dict = dict;
this.loading = false; this.loading = false;
if (code == 1) { if (code == 1) {
if (!data.length && this.current > 1) { if (!data.length && this.page > 1) {
this.current -= 1; this.page -= 1;
this.getStatementList(); this.getStatementList();
} }
this.tableData = data.data; this.tableData = data.data;
...@@ -207,7 +201,8 @@ export default { ...@@ -207,7 +201,8 @@ export default {
}, },
// 搜索 // 搜索
onSearch() { onSearch() {
this.current = 1; this.page = 1;
this.selectedRowKeys = [];
this.getStatementList(); this.getStatementList();
}, },
// 编辑 // 编辑
...@@ -216,17 +211,6 @@ export default { ...@@ -216,17 +211,6 @@ export default {
this.addStatementVisile = true; this.addStatementVisile = true;
this.$refs.AddStatement.onEdit(row, this.modelInfo); this.$refs.AddStatement.onEdit(row, this.modelInfo);
}, },
// 翻页
handleChange(cur) {
this.current = cur;
this.getStatementList();
},
// 改变每页显示数量
showSizeChange(current, size) {
this.current = current;
this.size = size;
this.getStatementList();
},
// 删除 // 删除
handleDel(id) { handleDel(id) {
let _this = this; let _this = this;
...@@ -244,6 +228,7 @@ export default { ...@@ -244,6 +228,7 @@ export default {
let { code, msg } = res.data; let { code, msg } = res.data;
if (code === 1) { if (code === 1) {
_this.$message.success(msg); _this.$message.success(msg);
_this.selectedRowKeys = [];
_this.getStatementList(); _this.getStatementList();
} }
}, },
...@@ -267,5 +252,4 @@ export default { ...@@ -267,5 +252,4 @@ export default {
}; };
</script> </script>
<style lang="less" scoped> <style lang="less" scoped></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