feat(frontend): 增强问卷模块功能,优化囚犯选择器

This commit is contained in:
tangweijie 2026-02-03 17:46:24 +08:00
parent ec0ff8dc90
commit 11e3ef148b
5 changed files with 100 additions and 49 deletions

View File

@ -89,10 +89,18 @@ export const PrisonerApi = {
getPage: (params: PageParam) => {
return request.get({ url: '/prison/prisoner/page', params })
},
// 分页查询(别名,用于选择犯人弹窗)
getPrisonerPage: (params: PageParam) => {
return request.get({ url: '/prison/prisoner/page', params })
},
// 获取详情
get: (id: number) => {
return request.get({ url: '/prison/prisoner/get', params: { id } })
},
// 获取详情(别名,与其他模块保持一致)
getPrisoner: (id: number) => {
return request.get({ url: '/prison/prisoner/get', params: { id } })
},
// 创建
create: (data: PrisonerCreateVO) => {
return request.post({ url: '/prison/prisoner/create', data })

View File

@ -271,7 +271,7 @@
{{ scope.row.finishTime ? formatDateTime(scope.row.finishTime) : '-' }}
</template>
</el-table-column>
<el-table-column label="操作" align="center" width="320" fixed="right">
<el-table-column label="操作" align="center" width="400" fixed="right">
<template #default="scope">
<el-button
v-if="scope.row.status === 3"
@ -310,6 +310,15 @@
>
重置
</el-button>
<el-button
link
type="primary"
size="small"
@click="handleViewPrisoner(scope.row)"
v-hasPermi="['prison:prisoner:query']"
>
详情
</el-button>
</template>
</el-table-column>
</el-table>
@ -328,6 +337,9 @@
<!-- 代填弹窗 -->
<AgentFillDialog ref="agentFillDialogRef" @success="loadPrisonerProgress" />
<!-- 服刑人员详情弹窗 -->
<PrisonerDetail ref="prisonerDetailRef" />
</template>
<script setup lang="ts">
@ -336,6 +348,7 @@ import { ElMessage, ElMessageBox } from 'element-plus'
import { formatDateTime } from '@/utils/formatTime'
import AnswerDetailDialog from '@/views/prison/questionnairerecord/AnswerDetailDialog.vue'
import AgentFillDialog from './AgentFillDialog.vue'
import PrisonerDetail from '@/views/prison/prisoner/PrisonerDetail.vue'
import { QuestionnaireTaskApi } from '@/api/prison/questionnaire-task'
defineOptions({ name: 'TaskDetailDialog' })
@ -353,6 +366,9 @@ const answerDetailDialogRef = ref()
//
const agentFillDialogRef = ref()
//
const prisonerDetailRef = ref()
//
const taskDetail = ref<any>(null)
@ -573,6 +589,11 @@ const handleAgentFill = (row: any) => {
agentFillDialogRef.value?.open(row)
}
/** 查看服刑人员详情 */
const handleViewPrisoner = (row: any) => {
prisonerDetailRef.value?.open(row.prisonerId)
}
/** 提醒未完成人员 */
const handleRemind = async () => {
if (!taskId.value) return

View File

@ -117,29 +117,35 @@ const open = async (type: string, id?: number) => {
}
defineExpose({ open }) // open
/** 提交表单 */
const emit = defineEmits(['success']) // success
const submitForm = async () => {
//
await formRef.value.validate()
//
formLoading.value = true
try {
const data = formData.value as unknown as Questionnaire
if (formType.value === 'create') {
await QuestionnaireApi.createQuestionnaire(data)
message.success(t('common.createSuccess'))
} else {
await QuestionnaireApi.updateQuestionnaire(data)
message.success(t('common.updateSuccess'))
/** 提交表单 */
const emit = defineEmits(['success']) // success
const submitForm = async () => {
//
await formRef.value.validate()
// coverImage null
formLoading.value = true
try {
const data = { ...formData.value } as unknown as Questionnaire
// coverImage
if (Array.isArray(data.coverImage) && data.coverImage.length > 0) {
data.coverImage = data.coverImage[0] as unknown as string
} else {
data.coverImage = undefined as unknown as string
}
if (formType.value === 'create') {
await QuestionnaireApi.createQuestionnaire(data)
message.success(t('common.createSuccess'))
} else {
await QuestionnaireApi.updateQuestionnaire(data)
message.success(t('common.updateSuccess'))
}
dialogVisible.value = false
//
emit('success')
} finally {
formLoading.value = false
}
dialogVisible.value = false
//
emit('success')
} finally {
formLoading.value = false
}
}
/** 重置表单 */
const resetForm = () => {

View File

@ -192,13 +192,10 @@
</div>
</div>
</el-form-item>
<el-form-item>
<el-button type="primary" plain :icon="Plus" @click="addPartition" v-hasPermi="['prison:question:create', 'prison:questionnaire:update']">添加分区</el-button>
</el-form-item>
</el-form>
<template #footer>
<el-button @click="savePartitions" type="primary" v-hasPermi="['prison:question:update', 'prison:questionnaire:update']">保存设置</el-button>
<el-button @click="partDialogVisible = false">取消</el-button>
<el-button @click="partDialogVisible = false">关闭</el-button>
</template>
</Dialog>
</template>
@ -486,26 +483,39 @@ const savePartitions = async () => {
return
}
//
//
const updates: Array<{ id: number; partName?: string; partSort?: number; sort?: number }> = []
for (let i = 0; i < allPartList.value.length; i++) {
const part = allPartList.value[i]
if (!part.isDefault && part.name) {
for (const p of partitions.value) {
if (p.name === part.name) {
p.questions.forEach((q, sortIndex) => {
updates.push({
id: q.id!,
partName: part.name,
partSort: i,
sort: sortIndex
})
for (const p of partitions.value) {
// name
if ((p.name === part.name) || (p.name === '' && part.name === '')) {
p.questions.forEach((q, sortIndex) => {
updates.push({
id: q.id!,
partName: part.name || undefined,
partSort: i,
sort: sortIndex
})
}
})
}
}
}
//
if (updates.length === 0) {
//
const hasNewPartition = allPartList.value.some(p => !p.isDefault && p.id?.toString().startsWith('part_'))
if (hasNewPartition) {
message.error('请先在该分区下添加问题后再保存')
return
}
//
partDialogVisible.value = false
message.success('保存成功')
return
}
//
await QuestionApi.batchUpdate({ questions: updates })
await getList()
@ -518,20 +528,22 @@ const savePartitions = async () => {
/** 分区拖拽排序完成 */
const onPartitionDragEnd = async () => {
//
//
const updates: Array<{ id: number; partName?: string; partSort?: number; sort?: number }> = []
for (let i = 0; i < partitions.value.length; i++) {
const part = partitions.value[i]
if (part.name) {
part.questions.forEach((q, sortIndex) => {
updates.push({
id: q.id!,
partName: part.name,
partSort: i,
sort: sortIndex
})
part.questions.forEach((q, sortIndex) => {
updates.push({
id: q.id!,
partName: part.name || undefined,
partSort: i,
sort: sortIndex
})
}
})
}
//
if (updates.length === 0) {
return
}
//
await QuestionApi.batchUpdate({ questions: updates })

View File

@ -101,7 +101,11 @@
<dict-tag :type="DICT_TYPE.PRISON_QUESTIONNAIRE_TYPE" :value="scope.row.type" />
</template>
</el-table-column>
<el-table-column label="问卷说明" align="center" prop="description" width="200" />
<el-table-column label="问卷说明" align="center" prop="description" width="200">
<template #default="scope">
<div v-html="scope.row.description"></div>
</template>
</el-table-column>
<el-table-column label="总分" align="center" prop="totalScore" width="80" />
<el-table-column label="及格分" align="center" prop="passScore" width="80" />
<el-table-column label="状态" align="center" prop="status" width="100">