Template
1
0
mirror of https://github.com/un-pany/v3-admin-vite.git synced 2025-04-21 11:29:20 +08:00

types: 优化表格数据类型

This commit is contained in:
pany 2023-02-28 14:13:45 +08:00
parent 5d641ace1f
commit 4a58eb8e03
3 changed files with 20 additions and 16 deletions

View File

@ -14,20 +14,23 @@ export interface IGetTableRequestData {
currentPage: number
/** 查询条数 */
size: number
/** 查询参数 */
/** 查询参数:用户名 */
username?: string
/** 查询参数:手机号 */
phone?: string
}
export interface IGetTableData {
createTime: string
email: string
id: string
phone: string
roles: string
status: boolean
username: string
}
export type GetTableResponseData = IApiResponseData<{
list: {
createTime: string
email: string
id: string
phone: string
roles: string
status: boolean
username: string
}[]
list: IGetTableData[]
total: number
}>

View File

@ -1,6 +1,7 @@
<script lang="ts" setup>
import { reactive, ref, watch } from "vue"
import { createTableDataApi, deleteTableDataApi, updateTableDataApi, getTableDataApi } from "@/api/table"
import { type IGetTableData } from "@/api/table/types/table"
import { type FormInstance, type FormRules, ElMessage, ElMessageBox } from "element-plus"
import { Search, Refresh, CirclePlus, Delete, Download, RefreshRight } from "@element-plus/icons-vue"
import { usePagination } from "@/hooks/usePagination"
@ -58,7 +59,7 @@ const resetForm = () => {
//#endregion
//#region
const handleDelete = (row: any) => {
const handleDelete = (row: IGetTableData) => {
ElMessageBox.confirm(`正在删除用户:${row.username},确认删除?`, "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
@ -74,16 +75,15 @@ const handleDelete = (row: any) => {
//#region
const currentUpdateId = ref<undefined | string>(undefined)
const handleUpdate = (row: any) => {
const handleUpdate = (row: IGetTableData) => {
currentUpdateId.value = row.id
formData.username = row.username
formData.password = row.password
dialogVisible.value = true
}
//#endregion
//#region
const tableData = ref<any[]>([])
const tableData = ref<IGetTableData[]>([])
const searchFormRef = ref<FormInstance | null>(null)
const searchData = reactive({
username: "",
@ -212,7 +212,7 @@ watch([() => paginationData.currentPage, () => paginationData.pageSize], getTabl
<el-form-item prop="username" label="用户名">
<el-input v-model="formData.username" placeholder="请输入" />
</el-form-item>
<el-form-item prop="password" label="密码">
<el-form-item prop="password" label="密码" v-if="currentUpdateId === undefined">
<el-input v-model="formData.password" placeholder="请输入" />
</el-form-item>
</el-form>

View File

@ -2,6 +2,7 @@
import { nextTick, reactive, ref } from "vue"
import { type ElMessageBoxOptions, ElMessageBox, ElMessage } from "element-plus"
import { deleteTableDataApi, getTableDataApi } from "@/api/table"
import { type GetTableResponseData } from "@/api/table/types/table"
import RoleColumnSolts from "./tsx/RoleColumnSolts"
import StatusColumnSolts from "./tsx/StatusColumnSolts"
import {
@ -142,7 +143,7 @@ const xGridOpt: VxeGridProps = reactive({
let total = 0
let result: IRowMeta[] = []
/** 加载数据 */
const callback = (res: any) => {
const callback = (res: GetTableResponseData) => {
if (res && res.data) {
const resData = res.data
//