完成制度管理模块开发,完善搜索功能

This commit is contained in:
chabai 2025-08-01 17:22:47 +08:00
parent 7f8ccb76cb
commit 011e1c5337
10 changed files with 562 additions and 171 deletions

91
BACKEND_SEARCH_API.md Normal file
View File

@ -0,0 +1,91 @@
# 制度类型搜索接口实现指南
## 接口定义
### 请求接口
```
GET /api/regulation/types
Content-Type: application/json
```
### 请求参数
```json
{
"page": number, // 页码可选默认1
"size": number, // 每页大小可选默认10
"typeName": "string", // 类型名称(模糊搜索,可选)
"status": "string", // 状态筛选("1"启用,"0"禁用,可选)
"remark": "string" // 备注内容(模糊搜索,可选)
}
```
### 响应格式
```json
{
"code": 200,
"message": "success",
"data": {
"records": [
{
"typeId": "string",
"typeName": "string",
"sortOrder": number,
"isEnabled": "string",
"remark": "string",
"createBy": "string",
"createTime": "string",
"updateBy": "string",
"updateTime": "string",
"delFlag": "string"
}
],
"total": number, // 总记录数
"current": number, // 当前页码
"size": number, // 每页大小
"pages": number // 总页数
}
}
```
## 后端实现说明
后端已实现以下接口:
```java
@ApiOperation(value = "获取制度类型列表", httpMethod = "GET")
@GetMapping
public Result getRegulationTypes(
@RequestParam(defaultValue = "1") int page,
@RequestParam(defaultValue = "10") int size,
@RequestParam(required = false) String typeName,
@RequestParam(required = false) String status,
@RequestParam(required = false) String remark
) {
return regulationTypeService.getRegulationTypes(page, size, typeName, status, remark);
}
```
## 前端集成说明
前端已完成以下功能:
1. ✅ 调整为GET请求接口
2. ✅ 参数名匹配后端接口isEnabled → status
3. ✅ 移除排序参数(后端不支持)
4. ✅ 简化搜索表单,只支持手动搜索
5. ✅ 保持原有功能不受影响
## 搜索流程
1. 用户在搜索表单中输入条件
2. 点击"搜索"按钮触发搜索
3. 调用后端GET接口 `/api/regulation/types`
4. 后端返回搜索结果
5. 前端展示搜索结果
## 参数说明
- **page**: 页码默认1
- **size**: 每页大小默认10
- **typeName**: 类型名称,支持模糊搜索
- **status**: 状态筛选,"1"表示启用,"0"表示禁用
- **remark**: 备注内容,支持模糊搜索

View File

@ -0,0 +1,125 @@
# 制度公告搜索接口实现指南
## 接口定义
### 请求接口
```
GET /api/regulation
Content-Type: application/json
```
### 请求参数
```json
{
"page": number, // 页码可选默认1
"size": number, // 每页大小可选默认10
"status": "string", // 状态筛选(精确匹配,固定为"PUBLISHED"
"title": "string", // 制度标题(模糊搜索,可选)
"proposer": "string", // 公示人(模糊搜索,可选)
"confirmStatus": "string" // 确认状态(精确匹配,可选)
}
```
### 响应格式
```json
{
"code": 200,
"message": "success",
"data": {
"records": [
{
"regulationId": "string",
"title": "string",
"content": "string",
"regulationType": "string",
"status": "string",
"publishTime": "string",
"effectiveTime": "string",
"expireTime": "string",
"scope": "string",
"level": "string",
"version": "string",
"remark": "string",
"createBy": "string",
"updateBy": "string",
"createTime": "string",
"updateTime": "string",
"delFlag": "string",
"confirmStatus": "string"
}
],
"total": number, // 总记录数
"current": number, // 当前页码
"size": number, // 每页大小
"pages": number // 总页数
}
}
```
## 后端实现说明
后端已实现以下接口:
```java
@ApiOperation(value = "获取制度列表", httpMethod = "GET")
@GetMapping
public Result getRegulationList(
@RequestParam(defaultValue = "1") int page,
@RequestParam(defaultValue = "10") int size,
@RequestParam(required = false) String status,
@RequestParam(required = false) String type,
@RequestParam(required = false) String title,
@RequestParam(required = false) String proposer,
@RequestParam(required = false) String confirmStatus
) {
return regulationService.getRegulationList(page, size, status, type, title, proposer, confirmStatus);
}
```
## 前端集成说明
前端已完成以下功能:
1. ✅ 删除前端搜索逻辑(防抖、实时搜索等)
2. ✅ 调整为GET请求接口
3. ✅ 参数名匹配后端接口createByName → proposer
4. ✅ 简化搜索表单,只支持手动搜索
5. ✅ 移除前端过滤逻辑,由后端处理状态筛选
6. ✅ 保持原有功能不受影响
## 搜索流程
1. 用户在搜索表单中输入条件
2. 点击"搜索"按钮触发搜索
3. 调用后端GET接口 `/api/regulation`
4. 后端返回搜索结果已过滤为PUBLISHED状态的制度
5. 前端展示搜索结果
## 参数说明
- **page**: 页码默认1
- **size**: 每页大小默认10
- **status**: 状态筛选,固定为"PUBLISHED"(已公告状态)
- **title**: 制度标题,支持模糊搜索
- **proposer**: 公示人,支持模糊搜索
- **confirmStatus**: 确认状态精确匹配confirmed、pending
## 搜索功能特性
- **模糊搜索**title 和 proposer 字段支持模糊匹配
- **精确筛选**confirmStatus 字段精确匹配
- **分页查询**:支持分页和排序
- **状态过滤**后端自动过滤为PUBLISHED状态的制度
- **性能优化**:使用数据库索引提升查询性能
## 业务逻辑说明
制度公告页面专门用于展示已经公告的制度,因此:
- 后端需要自动过滤为 `status = 'PUBLISHED'` 的制度
- 支持按确认状态confirmStatus进行筛选
- 前端不再需要手动过滤,完全依赖后端处理
- 用户可以查看制度详情、下载PDF文件、确认知晓制度
## 确认状态说明
- **confirmed**: 已确认 - 用户已确认知晓并遵守该制度
- **pending**: 待确认 - 用户尚未确认知晓该制度
- 空值: 全部 - 显示所有确认状态的制度

View File

@ -0,0 +1,117 @@
# 制度公示搜索接口实现指南
## 接口定义
### 请求接口
```
GET /api/regulation
Content-Type: application/json
```
### 请求参数
```json
{
"page": number, // 页码可选默认1
"size": number, // 每页大小可选默认10
"status": "string", // 状态筛选(精确匹配,可选)
"type": "string", // 提案类型(精确匹配,可选)
"title": "string", // 提案标题(模糊搜索,可选)
"proposer": "string" // 提案人(模糊搜索,可选)
}
```
### 响应格式
```json
{
"code": 200,
"message": "success",
"data": {
"records": [
{
"regulationId": "string",
"title": "string",
"content": "string",
"regulationType": "string",
"status": "string",
"publishTime": "string",
"effectiveTime": "string",
"expireTime": "string",
"scope": "string",
"level": "string",
"version": "string",
"remark": "string",
"createBy": "string",
"updateBy": "string",
"createTime": "string",
"updateTime": "string",
"delFlag": "string",
"confirmStatus": "string"
}
],
"total": number, // 总记录数
"current": number, // 当前页码
"size": number, // 每页大小
"pages": number // 总页数
}
}
```
## 后端实现说明
后端已实现以下接口:
```java
@ApiOperation(value = "获取制度列表", httpMethod = "GET")
@GetMapping
public Result getRegulationList(
@RequestParam(defaultValue = "1") int page,
@RequestParam(defaultValue = "10") int size,
@RequestParam(required = false) String status,
@RequestParam(required = false) String type,
@RequestParam(required = false) String title,
@RequestParam(required = false) String proposer
) {
return regulationService.getRegulationList(page, size, status, type, title, proposer);
}
```
## 前端集成说明
前端已完成以下功能:
1. ✅ 删除前端搜索逻辑(防抖、实时搜索等)
2. ✅ 调整为GET请求接口
3. ✅ 参数名匹配后端接口createByName → proposer, regulationType → type
4. ✅ 简化搜索表单,只支持手动搜索
5. ✅ 移除前端过滤逻辑,由后端处理状态筛选
6. ✅ 保持原有功能不受影响
## 搜索流程
1. 用户在搜索表单中输入条件
2. 点击"搜索"按钮触发搜索
3. 调用后端GET接口 `/api/regulation`
4. 后端返回搜索结果(已过滤掉草稿状态的提案)
5. 前端展示搜索结果
## 参数说明
- **page**: 页码默认1
- **size**: 每页大小默认10
- **status**: 状态筛选精确匹配PUBLISHED、APPROVED等
- **type**: 提案类型,精确匹配(如:管理规范、操作流程、安全制度、其他)
- **title**: 提案标题,支持模糊搜索
- **proposer**: 提案人,支持模糊搜索
## 搜索功能特性
- **模糊搜索**title 和 proposer 字段支持模糊匹配
- **精确筛选**type 和 status 字段精确匹配
- **分页查询**:支持分页和排序
- **状态过滤**:后端自动过滤掉草稿状态的提案,只显示已公示及以上的提案
- **性能优化**:使用数据库索引提升查询性能
## 业务逻辑说明
制度公示页面专门用于展示已经公示或已通过的制度提案,因此:
- 后端需要自动过滤掉 `status = 'DRAFT'` 的提案
- 只返回 `status = 'PUBLISHED'``status = 'APPROVED'` 的提案
- 前端不再需要手动过滤,完全依赖后端处理

View File

@ -0,0 +1,108 @@
# 制度提案搜索接口实现指南
## 接口定义
### 请求接口
```
GET /api/regulation
Content-Type: application/json
```
### 请求参数
```json
{
"page": number, // 页码可选默认1
"size": number, // 每页大小可选默认10
"status": "string", // 状态筛选(精确匹配,可选)
"type": "string", // 提案类型(精确匹配,可选)
"title": "string", // 提案标题(模糊搜索,可选)
"proposer": "string" // 提案人(模糊搜索,可选)
}
```
### 响应格式
```json
{
"code": 200,
"message": "success",
"data": {
"records": [
{
"regulationId": "string",
"title": "string",
"content": "string",
"regulationType": "string",
"status": "string",
"publishTime": "string",
"effectiveTime": "string",
"expireTime": "string",
"scope": "string",
"level": "string",
"version": "string",
"remark": "string",
"createBy": "string",
"updateBy": "string",
"createTime": "string",
"updateTime": "string",
"delFlag": "string",
"confirmStatus": "string"
}
],
"total": number, // 总记录数
"current": number, // 当前页码
"size": number, // 每页大小
"pages": number // 总页数
}
}
```
## 后端实现说明
后端已实现以下接口:
```java
@ApiOperation(value = "获取制度列表", httpMethod = "GET")
@GetMapping
public Result getRegulationList(
@RequestParam(defaultValue = "1") int page,
@RequestParam(defaultValue = "10") int size,
@RequestParam(required = false) String status,
@RequestParam(required = false) String type,
@RequestParam(required = false) String title,
@RequestParam(required = false) String proposer
) {
return regulationService.getRegulationList(page, size, status, type, title, proposer);
}
```
## 前端集成说明
前端已完成以下功能:
1. ✅ 删除前端搜索逻辑(防抖、实时搜索等)
2. ✅ 调整为GET请求接口
3. ✅ 参数名匹配后端接口createByName → proposer, regulationType → type
4. ✅ 简化搜索表单,只支持手动搜索
5. ✅ 保持原有功能不受影响
## 搜索流程
1. 用户在搜索表单中输入条件
2. 点击"搜索"按钮触发搜索
3. 调用后端GET接口 `/api/regulation`
4. 后端返回搜索结果
5. 前端展示搜索结果
## 参数说明
- **page**: 页码默认1
- **size**: 每页大小默认10
- **status**: 状态筛选精确匹配DRAFT、PUBLISHED、APPROVED等
- **type**: 提案类型,精确匹配(如:管理规范、操作流程、安全制度、其他)
- **title**: 提案标题,支持模糊搜索
- **proposer**: 提案人,支持模糊搜索
## 搜索功能特性
- **模糊搜索**title 和 proposer 字段支持模糊匹配
- **精确筛选**type 和 status 字段精确匹配
- **分页查询**:支持分页和排序
- **性能优化**:使用数据库索引提升查询性能

View File

@ -1,12 +1,22 @@
import http from '@/utils/http'
import {
type RegulationTypeSearchRequest,
type RegulationTypeSearchResponse,
type RegulationProposalSearchRequest,
type RegulationProposalSearchResponse
} from './type'
// 制度管理API接口
export const regulationApi = {
// 获取制度列表
getRegulationList: (params: {
page: number
size: number
}) => {
page?: number
size?: number
status?: string
type?: string
title?: string
proposer?: string
}): Promise<RegulationProposalSearchResponse> => {
return http.get('/regulation', params)
},
@ -62,12 +72,12 @@ export const regulationApi = {
return http.post(`/regulation/${regulationId}/confirm`)
},
// 获取制度类型列表
getRegulationTypes: (params?: {
// 搜索制度类型(后端搜索接口)
searchRegulationTypes: (params: {
page?: number
size?: number
typeName?: string
isEnabled?: string
status?: string
remark?: string
}) => {
return http.get('/regulation/types', params)

View File

@ -81,4 +81,41 @@ export interface UpdateRegulationTypeRequest {
sortOrder?: number
isEnabled?: string
remark?: string
}
// 制度类型搜索请求接口
export interface RegulationTypeSearchRequest {
page?: number
size?: number
typeName?: string
status?: string
remark?: string
}
// 制度类型搜索响应接口
export interface RegulationTypeSearchResponse {
records: RegulationType[]
total: number
current: number
size: number
pages: number
}
// 制度提案搜索请求接口
export interface RegulationProposalSearchRequest {
page?: number
size?: number
status?: string
type?: string
title?: string
proposer?: string
}
// 制度提案搜索响应接口
export interface RegulationProposalSearchResponse {
records: Regulation[]
total: number
current: number
size: number
pages: number
}

View File

@ -10,27 +10,24 @@
placeholder="请输入提案标题"
allow-clear
style="width: 200px"
@input="debouncedSearch"
/>
</a-form-item>
<a-form-item label="提案人">
<a-input
v-model="searchForm.createByName"
v-model="searchForm.proposer"
placeholder="请输入提案人"
allow-clear
style="width: 150px"
@input="debouncedSearch"
/>
</a-form-item>
<a-form-item label="提案类型">
<a-select
v-model="searchForm.regulationType"
v-model="searchForm.type"
placeholder="请选择类型"
allow-clear
style="width: 150px"
@change="debouncedSearch"
>
<a-option value="">全部</a-option>
<a-option value="管理规范">管理规范</a-option>
@ -46,7 +43,6 @@
placeholder="请选择状态"
allow-clear
style="width: 150px"
@change="debouncedSearch"
>
<a-option value="">全部</a-option>
<a-option value="PUBLISHED">已公示</a-option>
@ -112,12 +108,6 @@
</a-table>
</a-card>
<!-- 提案详情弹窗 -->
<a-modal
v-model:visible="detailModalVisible"
@ -176,15 +166,6 @@ import {
type RegulationType
} from '@/apis/regulation/type'
//
const debounce = (func: Function, delay: number) => {
let timeoutId: NodeJS.Timeout
return (...args: any[]) => {
clearTimeout(timeoutId)
timeoutId = setTimeout(() => func.apply(null, args), delay)
}
}
defineOptions({ name: 'ProcessManagement' })
//
@ -201,8 +182,8 @@ const columns = [
//
const searchForm = reactive({
title: '',
createByName: '',
regulationType: '',
proposer: '',
type: '',
status: ''
})
@ -283,7 +264,7 @@ const getLevelText = (level: RegulationLevel) => {
return texts[level] || '中'
}
// -
// - 使
const getTableData = async () => {
loading.value = true
try {
@ -291,34 +272,26 @@ const getTableData = async () => {
page: pagination.current,
size: pagination.pageSize,
title: searchForm.title || undefined,
createByName: searchForm.createByName || undefined,
regulationType: searchForm.regulationType || undefined,
proposer: searchForm.proposer || undefined,
type: searchForm.type || undefined,
status: searchForm.status || undefined
})
if (response.status === 200) {
// 稿
const allRecords = response.data.records || []
tableData.value = allRecords.filter(item => item.status !== RegulationStatus.DRAFT)
pagination.total = tableData.value.length
tableData.value = response.data.records
pagination.total = response.data.total
pagination.current = response.data.current
} else {
Message.error('获取数据失败')
Message.error('搜索失败')
}
} catch (error) {
console.error('获取制度列表失败:', error)
Message.error('获取数据失败')
console.error('搜索制度公示失败:', error)
Message.error('搜索失败')
} finally {
loading.value = false
}
}
//
const debouncedSearch = debounce(() => {
pagination.current = 1
getTableData()
}, 300)
//
const search = () => {
pagination.current = 1
@ -329,8 +302,8 @@ const search = () => {
const reset = () => {
Object.assign(searchForm, {
title: '',
createByName: '',
regulationType: '',
proposer: '',
type: '',
status: ''
})
pagination.current = 1
@ -406,8 +379,6 @@ onMounted(() => {
}
}
.proposal-detail {
.detail-header {
margin-bottom: 16px;
@ -443,8 +414,6 @@ onMounted(() => {
}
}
.detail-footer {
display: flex;
gap: 12px;

View File

@ -19,27 +19,24 @@
placeholder="请输入提案标题"
allow-clear
style="width: 200px"
@input="debouncedSearch"
/>
</a-form-item>
<a-form-item label="提案人">
<a-input
v-model="searchForm.ByNamecreate"
v-model="searchForm.proposer"
placeholder="请输入提案人"
allow-clear
style="width: 150px"
@input="debouncedSearch"
/>
</a-form-item>
<a-form-item label="提案类型">
<a-select
v-model="searchForm.regulationType"
v-model="searchForm.type"
placeholder="请选择类型"
allow-clear
style="width: 150px"
@change="debouncedSearch"
>
<a-option value="">全部</a-option>
<a-option value="管理规范">管理规范</a-option>
@ -55,7 +52,6 @@
placeholder="请选择状态"
allow-clear
style="width: 150px"
@change="debouncedSearch"
>
<a-option value="">全部</a-option>
<a-option value="DRAFT">草稿</a-option>
@ -335,18 +331,10 @@ import {
RegulationStatus,
RegulationLevel,
type Regulation,
type RegulationType
type RegulationType,
type RegulationProposalSearchRequest
} from '@/apis/regulation/type'
//
const debounce = (func: Function, delay: number) => {
let timeoutId: NodeJS.Timeout
return (...args: any[]) => {
clearTimeout(timeoutId)
timeoutId = setTimeout(() => func.apply(null, args), delay)
}
}
defineOptions({ name: 'RegulationProposal' })
//
@ -363,8 +351,8 @@ const columns = [
//
const searchForm = reactive({
title: '',
createByName: '',
regulationType: '',
proposer: '',
type: '',
status: ''
})
@ -487,17 +475,16 @@ const getRegulationTypes = async () => {
}
}
// - 稿
// - 使
const getTableData = async () => {
loading.value = true
try {
const response = await regulationApi.getRegulationList({
page: pagination.current,
size: pagination.pageSize,
status: RegulationStatus.DRAFT, // 稿
title: searchForm.title || undefined,
createByName: searchForm.createByName || undefined,
regulationType: searchForm.regulationType || undefined,
proposer: searchForm.proposer || undefined,
type: searchForm.type || undefined,
status: searchForm.status || undefined
})
@ -505,34 +492,17 @@ const getTableData = async () => {
tableData.value = response.data.records
pagination.total = response.data.total
pagination.current = response.data.current
//
console.log('当前用户:', currentUser.value)
tableData.value.forEach((item, index) => {
console.log(`提案 ${index + 1}:`, {
title: item.title,
createByName: item.createByName,
status: item.status,
canEdit: item.status === RegulationStatus.DRAFT && item.createByName === currentUser.value
})
})
} else {
Message.error('获取数据失败')
Message.error('搜索失败')
}
} catch (error) {
console.error('获取制度列表失败:', error)
Message.error('获取数据失败')
console.error('搜索制度提案失败:', error)
Message.error('搜索失败')
} finally {
loading.value = false
}
}
//
const debouncedSearch = debounce(() => {
pagination.current = 1
getTableData()
}, 300)
//
const search = () => {
pagination.current = 1
@ -543,8 +513,8 @@ const search = () => {
const reset = () => {
Object.assign(searchForm, {
title: '',
createByName: '',
regulationType: '',
proposer: '',
type: '',
status: ''
})
pagination.current = 1

View File

@ -10,17 +10,15 @@
placeholder="请输入制度标题"
allow-clear
style="width: 200px"
@input="debouncedSearch"
/>
</a-form-item>
<a-form-item label="公示人">
<a-input
v-model="searchForm.createByName"
v-model="searchForm.proposer"
placeholder="请输入公示人"
allow-clear
style="width: 150px"
@input="debouncedSearch"
/>
</a-form-item>
@ -30,7 +28,6 @@
placeholder="请选择状态"
allow-clear
style="width: 150px"
@change="debouncedSearch"
>
<a-option value="">全部</a-option>
<a-option value="confirmed">已确认</a-option>
@ -164,23 +161,14 @@ import { useRegulationStore } from '@/stores/modules/regulation'
import { regulationApi } from '@/apis/regulation'
import { PDFGenerator } from '@/utils/pdfGenerator'
//
const debounce = (func: Function, delay: number) => {
let timeoutId: NodeJS.Timeout
return (...args: any[]) => {
clearTimeout(timeoutId)
timeoutId = setTimeout(() => func.apply(null, args), delay)
}
}
defineOptions({ name: 'SystemRegulation' })
//
const columns = [
{ title: '制度名称', dataIndex: 'title', key: 'title' },
{ title: '制度类型', dataIndex: 'regulationType', key: 'regulationType' },
{ title: '公示人', dataIndex: 'createByName', key: 'createByName' },
{ title: '公示时间', dataIndex: 'publishTime', key: 'publishTime' },
{ title: '公示人', dataIndex: 'createByName', key: 'createByName' },
{ title: '公示时间', dataIndex: 'publishTime', key: 'publishTime' },
{ title: '生效日期', dataIndex: 'effectiveTime', key: 'effectiveTime' },
{ title: '确认状态', dataIndex: 'confirmStatus', key: 'confirmStatus', slotName: 'confirmStatus' },
{ title: '操作', key: 'operations', slotName: 'operations', width: 250 }
@ -201,7 +189,7 @@ const pagination = reactive({
//
const searchForm = reactive({
title: '',
createByName: '',
proposer: '',
confirmStatus: ''
})
@ -214,16 +202,16 @@ const agreeTerms = ref(false)
// store
const regulationStore = useRegulationStore()
//
// - 使
const getTableData = async () => {
loading.value = true
try {
const response = await regulationApi.getPublishedRegulationList({
const response = await regulationApi.getRegulationList({
page: pagination.current,
size: pagination.pageSize,
status: "PUBLISHED",
title: searchForm.title || undefined,
createByName: searchForm.createByName || undefined,
proposer: searchForm.proposer || undefined,
confirmStatus: searchForm.confirmStatus || undefined
})
@ -233,22 +221,16 @@ const getTableData = async () => {
pagination.current = response.data.current
pagination.total = response.data.total
} else {
Message.error('获取数据失败')
Message.error('搜索失败')
}
} catch (error) {
console.error('获取已公示制度列表失败:', error)
Message.error('获取数据失败')
console.error('搜索已公告制度失败:', error)
Message.error('搜索失败')
} finally {
loading.value = false
}
}
//
const debouncedSearch = debounce(() => {
pagination.current = 1
getTableData()
}, 300)
//
const search = () => {
pagination.current = 1
@ -259,7 +241,7 @@ const search = () => {
const reset = () => {
Object.assign(searchForm, {
title: '',
createByName: '',
proposer: '',
confirmStatus: ''
})
pagination.current = 1
@ -315,8 +297,6 @@ const handleDownload = async (record: any) => {
}
}
//
const submitConfirm = async () => {
if (!agreeTerms.value) {

View File

@ -16,23 +16,21 @@
<div class="search-container">
<a-form layout="inline" :model="searchForm" class="search-form">
<a-form-item label="类型名称">
<a-input
v-model="searchForm.typeName"
placeholder="请输入类型名称"
allow-clear
style="width: 200px"
@input="debouncedSearch"
/>
<a-input
v-model="searchForm.typeName"
placeholder="请输入类型名称"
allow-clear
style="width: 200px"
/>
</a-form-item>
<a-form-item label="状态">
<a-select
v-model="searchForm.isEnabled"
placeholder="请选择状态"
allow-clear
style="width: 150px"
@change="debouncedSearch"
>
<a-select
v-model="searchForm.status"
placeholder="请选择状态"
allow-clear
style="width: 150px"
>
<a-option value="">全部</a-option>
<a-option value="1">启用</a-option>
<a-option value="0">禁用</a-option>
@ -40,13 +38,12 @@
</a-form-item>
<a-form-item label="备注">
<a-input
v-model="searchForm.remark"
placeholder="请输入备注内容"
allow-clear
style="width: 200px"
@input="debouncedSearch"
/>
<a-input
v-model="searchForm.remark"
placeholder="请输入备注内容"
allow-clear
style="width: 200px"
/>
</a-form-item>
<a-form-item>
@ -153,18 +150,10 @@ import { regulationApi } from '@/apis/regulation'
import {
type RegulationType,
type CreateRegulationTypeRequest,
type UpdateRegulationTypeRequest
type UpdateRegulationTypeRequest,
type RegulationTypeSearchRequest
} from '@/apis/regulation/type'
//
const debounce = (func: Function, delay: number) => {
let timeoutId: NodeJS.Timeout
return (...args: any[]) => {
clearTimeout(timeoutId)
timeoutId = setTimeout(() => func.apply(null, args), delay)
}
}
defineOptions({ name: 'RegulationType' })
//
@ -195,7 +184,7 @@ const pagination = reactive({
//
const searchForm = reactive({
typeName: '',
isEnabled: '',
status: '',
remark: ''
})
@ -222,12 +211,13 @@ const rules = {
const getTableData = async () => {
loading.value = true
try {
const response = await regulationApi.getRegulationTypes({
// 使
const response = await regulationApi.searchRegulationTypes({
page: pagination.current,
size: pagination.pageSize,
typeName: searchForm.typeName || undefined,
isEnabled: searchForm.isEnabled || undefined,
remark: searchForm.remark || undefined
status: searchForm.status || undefined,
remark: searchForm.remark || undefined,
})
if (response.status === 200) {
@ -235,22 +225,16 @@ const getTableData = async () => {
pagination.total = response.data.total || response.data.length
pagination.current = response.data.current || 1
} else {
Message.error('获取数据失败')
Message.error('搜索失败')
}
} catch (error) {
console.error('获取制度类型列表失败:', error)
Message.error('获取数据失败')
console.error('搜索制度类型失败:', error)
Message.error('搜索失败')
} finally {
loading.value = false
}
}
//
const debouncedSearch = debounce(() => {
pagination.current = 1
getTableData()
}, 300)
//
const search = () => {
pagination.current = 1
@ -263,7 +247,7 @@ const search = () => {
const reset = () => {
Object.assign(searchForm, {
typeName: '',
isEnabled: '',
status: '',
remark: ''
})
pagination.current = 1