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

perf: 优化模块管理

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