refactor: 更新API接口与数据结构,统一分页返回格式
This commit is contained in:
@@ -156,7 +156,7 @@
|
||||
<script setup lang="ts">
|
||||
import type { TagProps } from "element-plus";
|
||||
import DictAPI from "@/api/system/dict";
|
||||
import type { DictItemPageQuery, DictItemPageVo, DictItemForm } from "@/types/api";
|
||||
import type { DictItemQueryParams, DictItem, DictItemForm } from "@/types/api";
|
||||
|
||||
const route = useRoute();
|
||||
|
||||
@@ -169,12 +169,12 @@ const loading = ref(false);
|
||||
const ids = ref<number[]>([]);
|
||||
const total = ref(0);
|
||||
|
||||
const queryParams = reactive<DictItemPageQuery>({
|
||||
const queryParams = reactive<DictItemQueryParams>({
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
});
|
||||
|
||||
const tableData = ref<DictItemPageVo[]>();
|
||||
const tableData = ref<DictItem[]>();
|
||||
|
||||
const dialog = reactive({
|
||||
title: "",
|
||||
@@ -199,9 +199,9 @@ const computedRules = computed(() => {
|
||||
function fetchData() {
|
||||
loading.value = true;
|
||||
DictAPI.getDictItemPage(dictCode.value, queryParams)
|
||||
.then((data) => {
|
||||
tableData.value = data.list;
|
||||
total.value = data.total;
|
||||
.then((res) => {
|
||||
tableData.value = res.data;
|
||||
total.value = res.page?.total ?? 0;
|
||||
})
|
||||
.finally(() => {
|
||||
loading.value = false;
|
||||
@@ -227,7 +227,7 @@ function handleSelectionChange(selection: any) {
|
||||
}
|
||||
|
||||
// 打开弹窗
|
||||
function handleOpenDialog(row?: DictItemPageVo) {
|
||||
function handleOpenDialog(row?: DictItem) {
|
||||
dialog.visible = true;
|
||||
dialog.title = row ? "编辑字典值" : "新增字典值";
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<!-- 字典 -->
|
||||
<!-- 字典 -->
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<!-- 搜索区域 -->
|
||||
@@ -139,7 +139,7 @@ defineOptions({
|
||||
|
||||
import { ref, reactive } from "vue";
|
||||
import DictAPI from "@/api/system/dict";
|
||||
import type { DictPageQuery, DictPageVo, DictForm } from "@/types/api";
|
||||
import type { DictTypeQueryParams, DictTypeItem, DictTypeForm } from "@/types/api";
|
||||
|
||||
import router from "@/router";
|
||||
|
||||
@@ -150,19 +150,19 @@ const loading = ref(false);
|
||||
const ids = ref<number[]>([]);
|
||||
const total = ref(0);
|
||||
|
||||
const queryParams = reactive<DictPageQuery>({
|
||||
const queryParams = reactive<DictTypeQueryParams>({
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
});
|
||||
|
||||
const tableData = ref<DictPageVo[]>();
|
||||
const tableData = ref<DictTypeItem[]>();
|
||||
|
||||
const dialog = reactive({
|
||||
title: "",
|
||||
visible: false,
|
||||
});
|
||||
|
||||
const formData = reactive<DictForm>({});
|
||||
const formData = reactive<DictTypeForm>({});
|
||||
|
||||
const computedRules = computed(() => {
|
||||
const rules: Partial<Record<string, any>> = {
|
||||
@@ -176,9 +176,9 @@ const computedRules = computed(() => {
|
||||
function fetchData() {
|
||||
loading.value = true;
|
||||
DictAPI.getPage(queryParams)
|
||||
.then((data) => {
|
||||
tableData.value = data.list;
|
||||
total.value = data.total;
|
||||
.then((res) => {
|
||||
tableData.value = res.data;
|
||||
total.value = res.page?.total ?? 0;
|
||||
})
|
||||
.finally(() => {
|
||||
loading.value = false;
|
||||
@@ -287,7 +287,7 @@ function handleDelete(id?: number) {
|
||||
}
|
||||
|
||||
// 打开字典值"
|
||||
function handleOpenDictData(row: DictPageVo) {
|
||||
function handleOpenDictData(row: DictTypeItem) {
|
||||
router.push({
|
||||
path: "/system/dict-item",
|
||||
query: { dictCode: row.dictCode, title: `【${row.name}】字典数据` },
|
||||
|
||||
Reference in New Issue
Block a user