tangweijie fdc6bf58e0 fix: 代码审查修复 - 前端TypeScript类型和UI优化
前端修复:
- 完善TypeScript类型定义(QuestionnairePageParams, QuestionPageParams等)
- 移除未使用的导入(Dayjs等)
- 日期格式化统一使用dateFormatter替代自定义函数
- 问题类型选项使用字典替代硬编码
- 优化API参数传递方式

Co-Authored-By: Claude <noreply@anthropic.com>
2026-01-15 20:16:10 +08:00

92 lines
2.7 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import request from '@/config/axios'
/** 问卷问题信息 */
export interface Question {
id?: number // 问题ID创建时不需要
questionnaireId?: number // 所属问卷ID
title?: string // 问题标题
type?: number // 问题类型1-单选 2-多选 3-填空 4-评分 5-日期 6-数字
options?: string // 选项JSON
score?: number // 分值
sort?: number // 排序
isRequired?: boolean // 是否必答
// 新增字段
partName?: string // 分区名称
partSort?: number // 分区排序
helpText?: string // 帮助说明
placeholder?: string // 占位提示
defaultValue?: string // 默认值
autoFillType?: string // 自动填充类型NONE/AUTO/MANUAL
autoFillSource?: string // 自动填充来源
displayCondition?: string // 显示条件JSON
minValue?: number // 最小值
maxValue?: number // 最大值
createTime?: string // 创建时间
}
/** 问卷问题分页参数 */
export interface QuestionPageParams {
pageNo: number
pageSize: number
questionnaireId?: number
title?: string
type?: number
partName?: string
}
/** 批量更新参数 */
export interface BatchUpdateQuestion {
id: number
partName?: string
partSort?: number
sort?: number
}
/** 批量更新请求 */
export interface BatchUpdateReq {
questions: BatchUpdateQuestion[]
}
// 问卷问题 API
export const QuestionApi = {
// 查询问卷问题分页
getQuestionPage: async (params: QuestionPageParams) => {
return await request.get({ url: `/prison/question/page`, params })
},
// 查询问卷问题详情
getQuestion: async (id: number) => {
return await request.get<Question>({ url: `/prison/question/get`, params: { id } })
},
// 新增问卷问题
createQuestion: async (data: Question) => {
return await request.post<number>({ url: `/prison/question/create`, data })
},
// 修改问卷问题
updateQuestion: async (data: Question) => {
return await request.put<boolean>({ url: `/prison/question/update`, data })
},
// 删除问卷问题
deleteQuestion: async (id: number) => {
return await request.delete<boolean>({ url: `/prison/question/delete`, params: { id } })
},
/** 批量删除问卷问题 */
deleteQuestionList: async (ids: number[]) => {
return await request.delete<boolean>({ url: `/prison/question/delete-list`, params: { ids: ids.join(',') } })
},
// 导出问卷问题 Excel
exportQuestion: async (params: QuestionPageParams) => {
return await request.download({ url: `/prison/question/export-excel`, params })
},
// 批量更新问卷问题(仅排序和分区字段)
batchUpdate: async (data: BatchUpdateReq) => {
return await request.post<boolean>({ url: `/prison/question/batch-update`, data })
}
}