feat 撤回原因 data-contracts.ts 重构

This commit is contained in:
Asoka 2025-06-12 18:35:23 +08:00
parent eb3307594a
commit 49cb6bb23d
9 changed files with 225 additions and 212 deletions

View File

@ -8430,116 +8430,6 @@ export interface ResultOutputBagDtoGetOutput {
data?: BagDto
}
/** 撤销原因分页查询输入 */
export interface PageInputRevokeReasonGetPageInput {
dynamicFilter?: DynamicFilterInfo
/** 排序列表 */
sortList?: SortInput[] | null
/**
*
* @format int32
*/
currentPage?: number
/**
*
* @format int32
*/
pageSize?: number
/** 分页请求 */
filter?: RevokeReasonGetPageInput
}
/** 撤销原因分页查询过滤条件 */
export interface RevokeReasonGetPageInput {
/** 原因描述 */
revokeReason?: string | null
/** 类型 */
revokeType?: string | null
/** 是否下发 */
isDown?: boolean
}
/** 撤销原因分页查询输出 */
export interface RevokeReasonGetPageOutput {
/**
*
* @format int64
*/
id?: number
/** 原因描述 */
revokeReason?: string | null
/** 类型 */
revokeType?: string | null
/** 是否下发 */
isDown?: boolean
/** 创建者 */
createdUserName?: string | null
/**
*
* @format date-time
*/
createdTime?: string | null
/**
*
* @format date-time
*/
modifiedTime?: string | null
}
export interface ResultOutputPageOutputRevokeReasonGetPageOutput {
success?: boolean
code?: string | null
message?: string | null
data?: PageOutputBagDtoGetPageOutput
}
export interface PageOutputRevokeReasonGetPageOutput {
list?: RevokeReasonGetPageOutput[] | null
total?: number
}
/** 撤销原因详情输出 */
export interface RevokeReasonGetOutput {
/** 原因描述 */
revokeReason?: string | null
/** 类型 */
revokeType?: string | null
/** 是否下发 */
isDown?: boolean
/**
* Id
* @format int64
*/
id: number
}
/** 撤销原因新增/更新输入 */
export interface RevokeReasonDto {
/** 原因描述 */
keyWord?: string | null
revokeReason?: string | null
/** 类型 */
revokeType?: string | null
/** 是否下发 */
isDown?: boolean
/**
* Id
* @format int64
*/
id?: number
}
/** 撤回类型枚举项 */
export interface RevokeTypeEnumItem {
/** 枚举值 */
value: number
/** 枚举名称 */
name: string
/** 显示名称/描述 */
label: string
}
/** 撤回类型枚举列表输出 */
export interface RevokeTypeEnumListOutput {
success?: boolean

View File

@ -9,7 +9,7 @@
* ---------------------------------------------------------------
*/
import { PageInputRevokeReasonGetPageInput, RevokeReasonDto, RevokeReasonGetOutput,ResultOutputPageOutputRevokeReasonGetPageOutput, RevokeTypeEnumListOutput } from './data-contracts'
import { RevokeReasonPageInput, RevokeReasonPageResponse, RevokeReasonOutput, RevokeReasonAddInput, RevokeReasonUpdateInput, RevokeTypeEnumListOutput } from '/@/api/types/RevokeType'
import { RequestParams } from './http-client'
import { ContentType, HttpClient } from './http-client'
@ -17,8 +17,8 @@ export class RevokeReasonApi extends HttpClient {
/**
*
*/
getPage = (data: PageInputRevokeReasonGetPageInput, params: RequestParams = {}) =>
this.request<ResultOutputPageOutputRevokeReasonGetPageOutput>({
getPage = (data: RevokeReasonPageInput, params: RequestParams = {}) =>
this.request<RevokeReasonPageResponse>({
path: `/api/admin/revoke-reason/get-page`,
method: 'POST',
body: data,
@ -30,7 +30,7 @@ export class RevokeReasonApi extends HttpClient {
*
*/
get = (params: { id: number }, requestParams: RequestParams = {}) =>
this.request<RevokeReasonGetOutput>({
this.request<RevokeReasonOutput>({
path: `/api/admin/revoke-reason/get`,
method: 'GET',
query: params,
@ -40,7 +40,7 @@ export class RevokeReasonApi extends HttpClient {
/**
*
*/
add = (data: RevokeReasonDto, params: RequestParams = {}) =>
add = (data: RevokeReasonAddInput, params: RequestParams = {}) =>
this.request<any>({
path: `/api/admin/revoke-reason/add`,
method: 'POST',
@ -52,7 +52,7 @@ export class RevokeReasonApi extends HttpClient {
/**
*
*/
update = (data: RevokeReasonDto, params: RequestParams = {}) =>
update = (data: RevokeReasonUpdateInput, params: RequestParams = {}) =>
this.request<any>({
path: `/api/admin/revoke-reason/update`,
method: 'PUT',

13
src/api/types/medium.ts Normal file
View File

@ -0,0 +1,13 @@
import { ServiceResponse } from './response';
export interface BasicMediumDto {
mediumName: string;
status: boolean;
id: number;
createdTime: string;
modifiedTime: string;
isDeleted: boolean;
}
export type BasicMediumDtoListServiceResponse = ServiceResponse<BasicMediumDto[]>;
export type BasicMediumDtoServiceResponse = ServiceResponse<BasicMediumDto>;

View File

@ -0,0 +1,34 @@
export interface ServiceRequstPage<T> {
dynamicFilter?: DynamicFilterInfo;
/** 排序列表 */
sortList?: SortInput[] | null;
/**
*
* @format int32
*/
currentPage?: number;
/**
*
* @format int32
*/
pageSize?: number;
/** 分页请求 */
filter?: T | null;
}
/** 排序 */
export interface SortInput {
/** 属性名称 */
propName?: string | null
/** 排序方式:Asc=0,Desc=1 */
order?: SortOrder
/** 是否升序 */
isAscending?: boolean | null
}
/**
* 排序方式:Asc=0,Desc=1
* @format int32
*/
export type SortOrder = 0 | 1

View File

@ -0,0 +1,4 @@
export interface PageResponse<T> {
list?: T[] | null;
total?: number;
}

View File

@ -0,0 +1,6 @@
export interface ServiceResponse<T> {
data?: T | null;
success?: boolean;
code?: string | null;
message?: string | null;
}

104
src/api/types/revokeType.ts Normal file
View File

@ -0,0 +1,104 @@
import { ServiceResponse } from './response';
import { ServiceRequstPage } from './pageInput'
import { PageResponse } from './pageResponse'
// 过滤
export interface RevokeReasonFilter {
/** 原因描述 */
keyWord?: string | null
/** 类型 */
revokeType?: string | null
/** 是否下发 */
isDown?: boolean
startTime?: string | null
endTime?: string | null
}
export interface RevokeReasonDto {
/**
*
* @format int64
*/
id?: number
/** 原因描述 */
revokeReason?: string | null
/** 类型 */
revokeType?: string | null
/** 是否下发 */
isDown?: boolean
/** 创建者 */
createdUserName?: string | null
/**
*
* @format date-time
*/
createdTime?: string | null
/**
*
* @format date-time
*/
modifiedTime?: string | null
}
export interface RevokeReasonPageDto {
/**
*
* @format int64
*/
id?: number
/** 原因描述 */
revokeReason?: string | null
/** 类型 */
revokeType?: string | null
/** 是否下发 */
isDown?: boolean
/** 创建者 */
createdUserName?: string | null
/**
*
* @format date-time
*/
createdTime?: string | null
/**
*
* @format date-time
*/
modifiedTime?: string | null
}
export interface RevokeReasonDto {
/**
*
* @format int64
*/
id?: number
/** 原因描述 */
revokeReason?: string | null
/** 类型 */
revokeType?: string | null
/** 是否下发 */
isDown?: boolean
}
/** 撤回类型枚举项 */
export interface RevokeTypeEnumItem {
/** 枚举值 */
value: number
/** 枚举名称 */
name: string
/** 显示名称/描述 */
label: string
}
export type RevokeReasonPageInput = ServiceRequstPage<RevokeReasonFilter>;
export type RevokeReasonPageResponse = ServiceResponse<PageResponse<RevokeReasonPageDto>>;
export type RevokeReasonOutput = ServiceResponse<RevokeReasonDto[]>;
export type RevokeReasonAddInput = RevokeReasonDto;
export type RevokeReasonUpdateInput = RevokeReasonDto;
export type RevokeTypeEnumListOutput = ServiceResponse<RevokeTypeEnumItem[]>;

View File

@ -52,7 +52,13 @@
<script setup lang="ts">
import { ref, reactive, defineProps, defineExpose, onMounted } from 'vue'
import { RevokeReasonApi } from '/@/api/admin/revoke-reason'
import type { RevokeReasonDto, RevokeTypeEnumItem } from '/@/api/admin/data-contracts'
import type {
RevokeReasonPageInput,
RevokeReasonOutput,
RevokeReasonPageDto,
RevokeTypeEnumItem,
RevokeReasonDto
} from '/@/api/types/RevokeType'
import eventBus from '/@/utils/mitt'
const props = defineProps<{ title: string }>()

View File

@ -1,44 +1,34 @@
<template>
<my-layout>
<el-card class="my-query-box mt8" shadow="never" :body-style="{ paddingBottom: '0' }">
<el-form ref="queryForm" :model="queryParams" :inline="true" label-width="auto" :label-position="'left'" @submit.stop.prevent>
<el-form :inline="true" label-width="auto" :label-position="'left'" @submit.stop.prevent>
<el-form-item label="原因描述" prop="revokeReason">
<el-input v-model="queryParams.filter.keyWord" placeholder="请输入原因描述" clearable @keyup.enter="handleQuery" />
<el-input v-model="state.filter.keyWord" placeholder="请输入原因描述" clearable @keyup.enter="handleQuery" />
</el-form-item>
<el-form-item label="原因类型" prop="revokeType">
<el-select v-model="queryParams.filter.revokeType" placeholder="请选择原因类型" clearable style="width: 200px">
<el-option v-for="item in revokeTypeOptions" :key="item.value" :label="item.label" :value="item.value" />
<el-select v-model="state.filter.revokeType" placeholder="请选择原因类型" clearable style="width: 200px">
<el-option v-for="item in state.revokeTypeOptions" :key="item.value" :label="item.label"
:value="item.value" />
</el-select>
</el-form-item>
<el-form-item label="开始时间">
<el-date-picker
v-model="queryParams.filter.startTime"
type="datetime"
placeholder="选择开始时间"
format="YYYY-MM-DD HH:mm:ss"
value-format="YYYY-MM-DD HH:mm:ss"
style="width: 180px"
/>
<el-date-picker v-model="state.filter.startTime" type="datetime" placeholder="选择开始时间"
format="YYYY-MM-DD HH:mm:ss" value-format="YYYY-MM-DD HH:mm:ss" style="width: 180px" />
</el-form-item>
<el-form-item label="结束时间">
<el-date-picker
v-model="queryParams.filter.endTime"
type="datetime"
placeholder="选择结束时间"
format="YYYY-MM-DD HH:mm:ss"
value-format="YYYY-MM-DD HH:mm:ss"
style="width: 180px"
/>
<el-date-picker v-model="state.filter.endTime" type="datetime" placeholder="选择结束时间"
format="YYYY-MM-DD HH:mm:ss" value-format="YYYY-MM-DD HH:mm:ss" style="width: 180px" />
</el-form-item>
<el-form-item>
<el-button type="primary" icon="ele-Search" @click="handleQuery">查询</el-button>
<el-button v-auth="'api:admin:revoke-reason:add'" type="primary" icon="ele-Plus" @click="handleAdd">新增</el-button>
<el-button v-auth="'api:admin:revoke-reason:add'" type="primary" icon="ele-Plus"
@click="handleAdd">新增</el-button>
</el-form-item>
</el-form>
</el-card>
<el-card class="my-fill mt8" shadow="never">
<el-table v-loading="loading" :data="revokeReasonList" row-key="id" style="width: 100%" border>
<el-table v-loading="loading" :data="state.revokeReasonList" row-key="id" style="width: 100%" border>
<el-table-column label="原因类型" min-width="120" show-overflow-tooltip>
<template #default="{ row }">
{{ getRevokeTypeName(row.revokeType) }}
@ -47,23 +37,17 @@
<el-table-column prop="revokeReason" label="原因描述" min-width="150" show-overflow-tooltip />
<el-table-column label="操作" width="180" fixed="right" header-align="center" align="center">
<template #default="{ row }">
<el-button v-auth="'api:admin:revoke-reason:update'" icon="ele-EditPen" size="small" text type="primary" @click="handleEdit(row)">编辑</el-button>
<el-button v-auth="'api:admin:revoke-reason:soft-delete'" icon="ele-Delete" size="small" text type="danger" @click="handleDelete(row)">删除</el-button>
<el-button v-auth="'api:admin:revoke-reason:update'" icon="ele-EditPen" size="small" text type="primary"
@click="handleEdit(row)">编辑</el-button>
<el-button v-auth="'api:admin:revoke-reason:soft-delete'" icon="ele-Delete" size="small" text type="danger"
@click="handleDelete(row)">删除</el-button>
</template>
</el-table-column>
</el-table>
<div class="my-flex my-flex-end" style="margin-top: 10px">
<el-pagination
v-model:currentPage="queryParams.currentPage"
v-model:page-size="queryParams.pageSize"
:total="total"
:page-sizes="[10, 20, 50, 100]"
size="small"
background
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
layout="total, sizes, prev, pager, next, jumper"
/>
<el-pagination v-model:current-page="state.pageInput.currentPage" v-model:page-size="state.pageInput.pageSize"
:total="state.total" :page-sizes="[10, 20, 50, 100]" size="small" background @size-change="handleSizeChange"
@current-change="handleCurrentChange" layout="total, sizes, prev, pager, next, jumper" />
</div>
</el-card>
@ -77,48 +61,44 @@ import { ElMessage, ElMessageBox } from 'element-plus'
import { RevokeReasonApi } from '/@/api/admin/revoke-reason'
import eventBus from '/@/utils/mitt'
import type {
RevokeReasonGetPageOutput,
RevokeTypeEnumItem,
RevokeTypeEnumListOutput,
PageOutputRevokeReasonGetPageOutput
} from '/@/api/admin/data-contracts'
RevokeReasonPageInput,
RevokeReasonOutput,
RevokeReasonPageDto,
RevokeTypeEnumItem
} from '/@/api/types/RevokeType'
import UspreasonForm from './components/uspreason-form.vue'
import { number } from 'echarts'
const loading = ref(false)
const showSearch = ref(true)
const total = ref(0)
const revokeReasonList = ref<RevokeReasonGetPageOutput[]>([])
const revokeTypeOptions = ref<RevokeTypeEnumItem[]>([])
const formRef = ref()
const dateRange = ref<[string, string] | null>(null)
const state = reactive({
loading: false,
formTitle: ''
})
const queryParams = reactive({
currentPage: 1,
pageSize: 10,
formTitle: '',
total: 0,
filter: {
keyWord: '',
revokeType: '',
keyWord: "",
revokeType: "",
isDown: false,
startTime: '',
endTime: ''
}
startTime: "",
endTime: ""
},
pageInput: {
currentPage: 1,
pageSize: 20,
} as RevokeReasonPageInput,
revokeReasonList: [] as Array<RevokeReasonPageDto>,
revokeTypeOptions: [] as RevokeTypeEnumItem[]
})
/** 查询列表 */
const getList = async () => {
loading.value = true
state.pageInput.filter = state.filter
try {
const res = await new RevokeReasonApi().getPage(queryParams)
console.log(res)
revokeReasonList.value = res.data?.list || []
total.value = res.data?.total || 0
const res = await new RevokeReasonApi().getPage(state.pageInput)
state.revokeReasonList = res.data?.list || []
state.total = res.data?.total || 0
} catch (error) {
console.error('获取列表失败:', error)
} finally {
@ -130,46 +110,24 @@ const getList = async () => {
const getRevokeTypeOptions = async () => {
try {
const res = await new RevokeReasonApi().getRevokeTypeEnumList()
revokeTypeOptions.value = res.data ?? []
state.revokeTypeOptions = res.data ?? []
} catch (error) {
console.error('获取撤销类型枚举列表失败:', error)
}
}
const getRevokeTypeName = (revokeType: string) => {
const item = revokeTypeOptions.value.find(item => item.value === Number(revokeType))
const item = state.revokeTypeOptions.find(item => item.value === Number(revokeType))
return item?.label || ''
}
/** 处理日期范围变化 */
const handleDateRangeChange = (val: [string, string] | null) => {
if (val) {
queryParams.filter.startTime = val[0]
queryParams.filter.endTime = val[1]
} else {
queryParams.filter.startTime = ''
queryParams.filter.endTime = ''
}
}
/** 搜索按钮操作 */
const handleQuery = () => {
queryParams.currentPage = 1
state.pageInput.currentPage = 1
getList()
}
/** 重置按钮操作 */
const resetQuery = () => {
queryParams.filter = {
keyWord: '',
revokeType: '',
isDown: false,
startTime: '',
endTime: ''
}
handleQuery()
}
/** 新增按钮操作 */
const handleAdd = () => {
state.formTitle = '新增原因'
@ -177,20 +135,20 @@ const handleAdd = () => {
}
/** 修改按钮操作 */
const handleEdit = (row: RevokeReasonGetPageOutput) => {
const handleEdit = (row: RevokeReasonOutput) => {
state.formTitle = '编辑原因'
formRef.value?.open(row)
}
/** 删除按钮操作 */
const handleDelete = (row: RevokeReasonGetPageOutput) => {
const handleDelete = (id: number) => {
ElMessageBox.confirm('确认要删除该记录吗?', '警告', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(async () => {
try {
const res = await new RevokeReasonApi().softDelete({ id: row.id! })
const res = await new RevokeReasonApi().softDelete({ id: id })
if (res.success) {
ElMessage.success('删除成功')
getList()
@ -203,13 +161,13 @@ const handleDelete = (row: RevokeReasonGetPageOutput) => {
/** 每页条数改变 */
const handleSizeChange = (val: number) => {
queryParams.pageSize = val
state.pageInput.pageSize = val
getList()
}
/** 当前页改变 */
const handleCurrentChange = (val: number) => {
queryParams.currentPage = val
state.pageInput.currentPage = val
getList()
}
@ -253,5 +211,3 @@ onBeforeMount(() => {
margin-bottom: 8px;
}
</style>