This commit is contained in:
yziiy
2026-01-31 10:18:36 +08:00
parent 5443a6ccf2
commit ba1d300f4e
2 changed files with 25 additions and 11 deletions

View File

@@ -1,9 +1,17 @@
import { ref, h } from "vue"; import { ref } from "vue";
import { queryUserNobility } from "@/api/modules/nobility"; import { queryUserNobility } from "@/api/modules/nobility";
export function useData() { export function useData() {
const loading = ref(true); const loading = ref(true);
const tableList = ref([]); const tableList = ref([]);
const isShow = ref(false); const isShow = ref(false);
const searchForm = ref({
user_code: "",
user_nick_name: ""
});
const searchLabel = ref([
{ label: "用户ID", prop: "user_code", type: "input" },
{ label: "用户昵称", prop: "user_nick_name", type: "input" }
]);
const pagination = ref({ const pagination = ref({
total: 0, total: 0,
pageSize: 10, pageSize: 10,
@@ -35,7 +43,7 @@ export function useData() {
preview-src-list={Array.of(row.user_avatar)} preview-src-list={Array.of(row.user_avatar)}
class="w-[24px] h-[24px] rounded-full align-middle" class="w-[24px] h-[24px] rounded-full align-middle"
/> />
), )
}, },
{ {
label: "爵位名称", label: "爵位名称",
@@ -44,11 +52,13 @@ export function useData() {
{ {
label: "名称颜色", label: "名称颜色",
prop: "nick_name_color" prop: "nick_name_color"
}, }
]); ]);
const onSearch = async () => { const onSearch = async formData => {
loading.value = true; loading.value = true;
searchForm.value = { ...formData };
const { data, code } = await queryUserNobility({ const { data, code } = await queryUserNobility({
...formData,
page: pagination.value.currentPage, page: pagination.value.currentPage,
page_limit: pagination.value.pageSize page_limit: pagination.value.pageSize
}); });
@@ -61,13 +71,15 @@ export function useData() {
}; };
const handleSizeChange = (val: number) => { const handleSizeChange = (val: number) => {
pagination.value.pageSize = val; pagination.value.pageSize = val;
onSearch(); onSearch(searchForm.value);
}; };
const handleCurrentChange = (val: number) => { const handleCurrentChange = (val: number) => {
pagination.value.currentPage = val; pagination.value.currentPage = val;
onSearch(); onSearch(searchForm.value);
}; };
return { return {
searchForm,
searchLabel,
onSearch, onSearch,
isShow, isShow,
tableList, tableList,

View File

@@ -1,9 +1,12 @@
<script setup lang="ts"> <script setup lang="ts">
import { onMounted } from "vue"; import { onMounted } from "vue";
import { useData } from "./hook"; import { useData } from "./hook";
import SearchForm from "@/components/SearchForm/index.vue";
import { PureTableBar } from "@/components/RePureTableBar"; import { PureTableBar } from "@/components/RePureTableBar";
import { deviceDetection } from "@pureadmin/utils"; import { deviceDetection } from "@pureadmin/utils";
const { const {
searchLabel,
searchForm,
onSearch, onSearch,
isShow, isShow,
tableList, tableList,
@@ -11,19 +14,19 @@ const {
tableLabel, tableLabel,
handleSizeChange, handleSizeChange,
handleCurrentChange, handleCurrentChange,
loading, loading
} = useData(); } = useData();
defineOptions({ defineOptions({
name: "charmGrade" name: "charmGrade"
}); });
onMounted(() => { onMounted(() => {
onSearch(); onSearch(searchForm.value);
}); });
</script> </script>
<template> <template>
<div class="main"> <div class="main">
<SearchForm class="pb-2" :LabelList="searchLabel" :formData="searchForm" @handleSearch="onSearch" />
<div ref="contentRef" :class="['flex', deviceDetection() ? 'flex-wrap' : '']"> <div ref="contentRef" :class="['flex', deviceDetection() ? 'flex-wrap' : '']">
<PureTableBar title="用户爵位列表" :class="[isShow && !deviceDetection() ? '!w-[60vw]' : 'w-full']" <PureTableBar title="用户爵位列表" :class="[isShow && !deviceDetection() ? '!w-[60vw]' : 'w-full']"
:columns="tableLabel" @refresh="onSearch"> :columns="tableLabel" @refresh="onSearch">
@@ -33,8 +36,7 @@ onMounted(() => {
:data="tableList" :columns="dynamicColumns" :pagination="{ ...pagination, size }" :header-cell-style="{ :data="tableList" :columns="dynamicColumns" :pagination="{ ...pagination, size }" :header-cell-style="{
background: 'var(--el-fill-color-light)', background: 'var(--el-fill-color-light)',
color: 'var(--el-text-color-primary)' color: 'var(--el-text-color-primary)'
}" @page-current-change="handleCurrentChange" @page-size-change="handleSizeChange"> }" @page-current-change="handleCurrentChange" @page-size-change="handleSizeChange" />
</pure-table>
</template> </template>
</PureTableBar> </PureTableBar>
</div> </div>