fix: UDM用户数据表格优化

This commit is contained in:
TsMask
2023-11-25 15:26:56 +08:00
parent 9f5f35c79d
commit 03a3899377
7 changed files with 170 additions and 187 deletions

View File

@@ -1,12 +1,12 @@
<script setup lang="ts">
import { reactive, ref, onMounted, toRaw } from 'vue';
import { PageContainer } from '@ant-design-vue/pro-layout';
// import { Container, Draggable } from 'vue3-smooth-dnd';
import { message, Modal, Form, notification } from 'ant-design-vue/lib';
import { SizeType } from 'ant-design-vue/lib/config-provider';
import { MenuInfo } from 'ant-design-vue/lib/menu/src/interface';
import { ColumnsType } from 'ant-design-vue/lib/table';
import UploadModal from '@/components/UploadModal/index.vue';
import TableColumnsDnd from '@/components/TableColumnsDnd/index.vue';
import {
loadSub,
listSub,
@@ -85,21 +85,21 @@ let tableState: TabeStateType = reactive({
});
/**表格字段列 */
let tableColumns = reactive<ColumnsType>([
let tableColumns: ColumnsType = [
{
title: 'IMSI',
dataIndex: 'imsi',
align: 'center',
align: 'left',
fixed: 'left',
width: 5,
width: 3,
sorter: true,
},
{
title: 'MSISDN',
dataIndex: 'msisdn',
align: 'center',
align: 'left',
fixed: 'left',
width: 5,
width: 3,
sorter: true,
},
{
@@ -136,7 +136,7 @@ let tableColumns = reactive<ColumnsType>([
title: 'CN Type Restriction',
dataIndex: 'cn',
align: 'center',
width: 5,
width: 3,
},
{
title: 'Subscribed Data',
@@ -157,23 +157,10 @@ let tableColumns = reactive<ColumnsType>([
fixed: 'right',
width: 2,
},
]);
];
// /**表格字段列 */
// const tableColumnsState = reactive({
// indeterminate: true,
// checkAll: false,
// columnsTitleList: tableColumns.map(s => s.title),
// });
// /**表格紧凑型变更操作 */
// function fnTableColumnsCheckAllChange(e: any) {
// const checked = e.target.checked;
// console.log(checked)
// tableColumnsState.indeterminate = false
// tableColumnsState.columnsTitleList = checked ? tableColumns.map(s => s.title) : []
// }
/**表格字段列排序 */
let tableColumnsDnd = reactive<ColumnsType>([]);
/**表格分页器参数 */
let tablePagination = reactive({
@@ -208,6 +195,11 @@ function fnTableSize({ key }: MenuInfo) {
tableState.size = key as SizeType;
}
/**表格斑马纹 */
function fnTableStriped(_record: unknown, index: number): any {
return tableState.striped && index % 2 === 1 ? 'table-striped' : undefined;
}
/**表格分页、排序、筛选变化时触发操作, 排序方式,取值为 ascend descend */
function fnTableChange(pagination: any, filters: any, sorter: any, extra: any) {
const { field, order } = sorter;
@@ -806,6 +798,7 @@ function fnGetList(pageNum?: number) {
tableState.loading = true;
if (pageNum) {
queryParams.pageNum = pageNum;
tablePagination.current = pageNum;
}
listSub(toRaw(queryParams)).then(res => {
if (res.code === RESULT_CODE_SUCCESS && Array.isArray(res.rows)) {
@@ -873,21 +866,6 @@ function fnModalUploadImportUpload(file: File) {
});
}
// let items = reactive([
// { id: 1, data: 'Princess Mononoke' },
// { id: 2, data: 'Spirited Away' },
// { id: 3, data: 'My Neighbor Totoro' },
// { id: 4, data: "Howl's Moving Castle" },
// ]);
// function onDrop(dropResult: any) {
// const { removedIndex, addedIndex, payload } = dropResult;
// if (removedIndex !== null && addedIndex !== null) {
// let itemToAdd = payload;
// itemToAdd = items.splice(removedIndex, 1)[0];
// items.splice(addedIndex, 0, itemToAdd);
// }
// }
onMounted(() => {
// 获取网元网元列表
useNeInfoStore()
@@ -935,8 +913,7 @@ onMounted(() => {
<a-select
v-model:value="queryParams.neId"
:options="neOtions"
allow-clear
:placeholder="t('views.neUser.sub.neTypePlease')"
:placeholder="t('common.selectPlease')"
/>
</a-form-item>
</a-col>
@@ -1073,48 +1050,10 @@ onMounted(() => {
<template #icon><ReloadOutlined /></template>
</a-button>
</a-tooltip>
<!-- <a-tooltip>
<template #title>
{{ t('common.columnSetText') }}
</template>
<a-popover trigger="click" placement="bottomRight">
<template #title>
<div class="table-column-setting-title">
<a-checkbox
v-model:checked="tableColumnsState.checkAll"
:indeterminate="tableColumnsState.indeterminate"
@change="fnTableColumnsCheckAllChange"
>
列展示/排序
</a-checkbox>
<a-button type="link" size="small"> 重置 </a-button>
</div>
</template>
<template #content>
<Container orientation="vertical" @drop="onDrop">
<a-checkbox-group
v-model:value="tableColumnsState.columnsTitleList"
style="width: 100%"
>
<Draggable
v-for="(item, i) in tableColumnsState.columns"
:key="item.id"
>
<div class="table-column-setting-list-item">
<HolderOutlined class="anticon" />
<a-checkbox :value="item"
>{{ i + 1 }} -> {{ item.title }}</a-checkbox
>
</div>
</Draggable>
</a-checkbox-group>
</Container>
</template>
<a-button type="text">
<template #icon><TableOutlined /></template>
</a-button>
</a-popover>
</a-tooltip> -->
<TableColumnsDnd
:columns="tableColumns"
v-model:columns-dnd="tableColumnsDnd"
></TableColumnsDnd>
<a-tooltip placement="topRight">
<template #title>{{ t('common.sizeText') }}</template>
<a-dropdown placement="bottomRight" trigger="click">
@@ -1146,12 +1085,13 @@ onMounted(() => {
<a-table
class="table"
row-key="imsi"
:columns="tableColumns"
:columns="tableColumnsDnd"
:loading="tableState.loading"
:data-source="tableState.data"
:size="tableState.size"
:row-class-name="fnTableStriped"
:pagination="tablePagination"
:scroll="{ x: 2500, y: 400 }"
:scroll="{ x: tableColumnsDnd.length * 200, y: 450 }"
@change="fnTableChange"
>
<template #bodyCell="{ column, record }">
@@ -2131,28 +2071,7 @@ onMounted(() => {
padding: 0 24px;
}
.table-column-setting-title {
display: flex;
align-items: center;
justify-content: space-between;
height: 32px;
margin-left: 4px;
}
.table-column-setting-list-item {
display: flex;
align-items: center;
width: 100%;
padding: 4px 16px 4px 0;
}
.table-column-setting-list-item > .anticon {
padding-right: 6px;
cursor: move;
}
.table-column-setting-list-item .ant-checkbox-wrapper {
flex: 1;
margin: 0;
.table :deep(.table-striped) td {
background-color: #fafafa;
}
</style>