mod 更新巡检人字段名称为ownerUserId,调整相关表单和展示逻辑

pull/853/head
wersd 2025-12-05 08:57:35 +08:00
parent 4cd6de36c2
commit a5fe3d15e3
4 changed files with 159 additions and 49 deletions

View File

@ -5,7 +5,7 @@ export interface ProjectInspectionRecordVO {
id: number // 主键ID id: number // 主键ID
projectId: number // 项目ID projectId: number // 项目ID
inspectionDate: Date // 巡检日期时间 inspectionDate: Date // 巡检日期时间
inspector: number // 巡检人 ownerUserId: number // 巡检人
overallStatus: number // 总体状态 overallStatus: number // 总体状态
summary: string // 巡检总结 summary: string // 巡检总结
remark: string // 备注 remark: string // 备注

View File

@ -41,9 +41,9 @@
</el-row> </el-row>
<el-row :gutter="20"> <el-row :gutter="20">
<el-col :span="12"> <el-col :span="12">
<el-form-item label="巡检人" prop="inspector"> <el-form-item label="巡检人" prop="ownerUserId">
<el-select <el-select
v-model="formData.inspector" v-model="formData.ownerUserId"
placeholder="请选择巡检人" placeholder="请选择巡检人"
clearable clearable
filterable filterable
@ -141,7 +141,7 @@ const formData = ref({
id: undefined, id: undefined,
projectId: undefined, projectId: undefined,
inspectionDate: undefined, inspectionDate: undefined,
inspector: undefined, ownerUserId: undefined,
overallStatus: undefined, overallStatus: undefined,
summary: undefined, summary: undefined,
remark: undefined, remark: undefined,
@ -150,7 +150,7 @@ const formData = ref({
const formRules = reactive({ const formRules = reactive({
projectId: [{ required: true, message: '项目名称不能为空', trigger: 'change' }], projectId: [{ required: true, message: '项目名称不能为空', trigger: 'change' }],
inspectionDate: [{ required: true, message: '巡检日期不能为空', trigger: 'blur' }], inspectionDate: [{ required: true, message: '巡检日期不能为空', trigger: 'blur' }],
inspector: [{ required: true, message: '巡检人不能为空', trigger: 'change' }], ownerUserId: [{ required: true, message: '巡检人不能为空', trigger: 'change' }],
status: [{ required: true, message: '状态不能为空', trigger: 'blur' }], status: [{ required: true, message: '状态不能为空', trigger: 'blur' }],
}) })
const formRef = ref() // Ref const formRef = ref() // Ref
@ -215,7 +215,7 @@ const resetForm = () => {
id: undefined, id: undefined,
projectId: undefined, projectId: undefined,
inspectionDate: undefined, inspectionDate: undefined,
inspector: undefined, ownerUserId: undefined,
overallStatus: undefined, overallStatus: undefined,
summary: undefined, summary: undefined,
remark: undefined, remark: undefined,

View File

@ -13,8 +13,8 @@
<el-form-item label="巡检日期" prop="inspectionDate"> <el-form-item label="巡检日期" prop="inspectionDate">
<el-input v-model="inspectionDate" disabled /> <el-input v-model="inspectionDate" disabled />
</el-form-item> </el-form-item>
<el-form-item label="巡检人" prop="inspector"> <el-form-item label="巡检人" prop="ownerUserId">
<el-input v-model="inspectorName" disabled /> <el-input v-model="ownerUserIdName" disabled />
</el-form-item> </el-form-item>
<!-- 按配置类型分组显示巡检内容字段 --> <!-- 按配置类型分组显示巡检内容字段 -->
@ -135,7 +135,22 @@
</el-radio> </el-radio>
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
</el-form> <!-- 备注 -->
<el-divider>
<span style="font-weight: bold; font-size: 16px;">备注</span>
</el-divider>
<el-form-item label="备注" prop="remark">
<el-input
v-model="formData.remark"
type="textarea"
:rows="4"
placeholder="请输入备注信息"
maxlength="500"
show-word-limit
clearable
/>
</el-form-item>
</el-form>
<template #footer> <template #footer>
<el-button @click="submitForm" type="primary" :disabled="formLoading"> </el-button> <el-button @click="submitForm" type="primary" :disabled="formLoading"> </el-button>
<el-button @click="dialogVisible = false"> </el-button> <el-button @click="dialogVisible = false"> </el-button>
@ -169,7 +184,7 @@ const projectList = ref<ProjectApi.ProjectVO[]>([]) // 项目列表
const userList = ref<UserApi.UserVO[]>([]) // const userList = ref<UserApi.UserVO[]>([]) //
const projectName = ref('') // const projectName = ref('') //
const inspectionDate = ref('') // const inspectionDate = ref('') //
const inspectorName = ref('') // const ownerUserIdName = ref('') //
const recordId = ref<number | undefined>(undefined) // ID const recordId = ref<number | undefined>(undefined) // ID
const originalRecord = ref<ProjectInspectionRecordApi.ProjectInspectionRecordVO | null>(null) // const originalRecord = ref<ProjectInspectionRecordApi.ProjectInspectionRecordVO | null>(null) //
@ -311,7 +326,7 @@ const open = async (record: ProjectInspectionRecordApi.ProjectInspectionRecordVO
projectName.value = project?.name || '' projectName.value = project?.name || ''
// //
inspectorName.value = userStore.user.nickname || '当前用户' ownerUserIdName.value = userStore.user.nickname || '当前用户'
// //
if (record.inspectionDate) { if (record.inspectionDate) {
@ -332,7 +347,10 @@ const open = async (record: ProjectInspectionRecordApi.ProjectInspectionRecordVO
inspectionDataList.value = inspectionDataListResult inspectionDataList.value = inspectionDataListResult
// //
formData.value = {} formData.value = {
remark: originalRecord.value?.remark || '', //
overallStatus: originalRecord.value?.overallStatus //
}
formRules.value = {} formRules.value = {}
inspectionDataList.value.forEach((item) => { inspectionDataList.value.forEach((item) => {
@ -362,7 +380,44 @@ defineExpose({ open }) // 提供 open 方法,用于打开弹窗
const emit = defineEmits(['success']) // success const emit = defineEmits(['success']) // success
const submitForm = async () => { const submitForm = async () => {
// //
await formRef.value.validate() try {
await formRef.value.validate()
} catch (error: any) {
//
const invalidFields: string[] = []
inspectionDataList.value.forEach((item) => {
if (item.isRequired) {
const fieldKey = `data_${item.id}`
const value = formData.value[fieldKey]
//
const isEmpty = value === undefined ||
value === null ||
value === '' ||
(Array.isArray(value) && value.length === 0)
if (isEmpty) {
invalidFields.push(item.name)
}
}
})
//
if (invalidFields.length > 0) {
const fieldNames = invalidFields.join('、')
message.warning(`请填写以下必填项:${fieldNames}`)
//
const firstInvalidField = inspectionDataList.value.find(item =>
item.isRequired && invalidFields.includes(item.name)
)
if (firstInvalidField) {
const fieldKey = `data_${firstInvalidField.id}`
await formRef.value.validateField(fieldKey)
}
} else {
//
message.warning('请检查表单填写是否完整')
}
return
}
// //
formLoading.value = true formLoading.value = true
@ -375,13 +430,13 @@ const submitForm = async () => {
// 使ID // 使ID
const summaryData: Record<number, Record<number, any>> = {} const summaryData: Record<number, Record<number, any>> = {}
// 使 // 使
const readableSummaryData: Record<string, Array<{ name: string; value: any; type: number }>> = {} const readableSummaryData: Record<string, Array<{ name: string; value: any; type: number; remark?: string }>> = {}
// //
groupedInspectionData.value.forEach((group) => { groupedInspectionData.value.forEach((group) => {
const groupData: Record<number, any> = {} const groupData: Record<number, any> = {}
const readableGroupData: Array<{ name: string; value: any; type: number }> = [] const readableGroupData: Array<{ name: string; value: any; type: number; remark?: string }> = []
const configTypeName = getConfigTypeName(group.configType) const configTypeName = getConfigTypeName(group.configType)
group.items.forEach((item) => { group.items.forEach((item) => {
@ -396,7 +451,8 @@ const submitForm = async () => {
readableGroupData.push({ readableGroupData.push({
name: item.name, name: item.name,
value: value.join('、'), // 使 value: value.join('、'), // 使
type: item.type type: item.type,
remark: item.remark //
}) })
} }
} else if (value !== undefined && value !== null && value !== '') { } else if (value !== undefined && value !== null && value !== '') {
@ -405,7 +461,8 @@ const submitForm = async () => {
readableGroupData.push({ readableGroupData.push({
name: item.name, name: item.name,
value: value, value: value,
type: item.type type: item.type,
remark: item.remark //
}) })
} }
}) })
@ -443,10 +500,10 @@ const submitForm = async () => {
id: recordId.value, id: recordId.value,
projectId: originalRecord.value.projectId, projectId: originalRecord.value.projectId,
inspectionDate: originalRecord.value.inspectionDate, inspectionDate: originalRecord.value.inspectionDate,
inspector: originalRecord.value.inspector, ownerUserId: originalRecord.value.ownerUserId,
overallStatus: formData.value.overallStatus, // 使 overallStatus: formData.value.overallStatus, // 使
summary: summaryJson || JSON.stringify(summaryData), // 使JSON summary: summaryJson || JSON.stringify(summaryData), // 使JSON
remark: originalRecord.value.remark || '', remark: formData.value.remark || '', // 使
status: recordStatus // recordStatusstatus status: recordStatus // recordStatusstatus
} }

View File

@ -36,9 +36,9 @@
class="!w-220px" class="!w-220px"
/> />
</el-form-item> </el-form-item>
<el-form-item label="巡检人" prop="inspector"> <el-form-item label="巡检人" prop="ownerUserId">
<el-select <el-select
v-model="queryParams.inspector" v-model="queryParams.ownerUserId"
placeholder="请选择巡检人" placeholder="请选择巡检人"
clearable clearable
filterable filterable
@ -119,7 +119,7 @@
<div class="card-info"> <div class="card-info">
<div class="info-item"> <div class="info-item">
<span class="info-label">巡检人</span> <span class="info-label">巡检人</span>
<span class="info-value">{{ getUserName(item.inspector) }}</span> <span class="info-value">{{ getUserName(item.ownerUserId) }}</span>
</div> </div>
<div v-if="item.inspectionDate" class="info-item"> <div v-if="item.inspectionDate" class="info-item">
<span class="info-label">计划完成时间</span> <span class="info-label">计划完成时间</span>
@ -185,8 +185,13 @@
class="summary-field" class="summary-field"
> >
<div class="field-question"> <div class="field-question">
<span class="field-question-label">题目</span> <div class="field-question-header">
<span class="field-question-text">{{ field.name }}</span> <span class="field-question-label">题目</span>
<span class="field-question-text">{{ field.name }}</span>
</div>
<div v-if="field.remark" class="field-question-remark">
{{ field.remark }}
</div>
</div> </div>
<div class="field-answer"> <div class="field-answer">
<span class="field-answer-label">答案</span> <span class="field-answer-label">答案</span>
@ -231,8 +236,10 @@
/> />
</div> </div>
<div v-if="item.remark" class="card-remark"> <div v-if="item.remark" class="card-remark">
<span class="remark-label">备注</span> <div class="remark-wrapper">
<span class="remark-content">{{ item.remark }}</span> <span class="remark-label">备注</span>
<span class="remark-content">{{ item.remark }}</span>
</div>
</div> </div>
</div> </div>
</el-card> </el-card>
@ -266,9 +273,9 @@
:formatter="dateFormatter" :formatter="dateFormatter"
width="180" width="180"
/> />
<el-table-column label="巡检人" align="center" prop="inspector"> <el-table-column label="巡检人" align="center" prop="ownerUserId">
<template #default="scope"> <template #default="scope">
{{ getUserName(scope.row.inspector) }} {{ getUserName(scope.row.ownerUserId) }}
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="配置类型" align="center" prop="configType" width="180"> <el-table-column label="配置类型" align="center" prop="configType" width="180">
@ -350,9 +357,9 @@
:formatter="dateFormatter" :formatter="dateFormatter"
width="180" width="180"
/> />
<el-table-column label="巡检人" align="center" prop="inspector"> <el-table-column label="巡检人" align="center" prop="ownerUserId">
<template #default="scope"> <template #default="scope">
{{ getUserName(scope.row.inspector) }} {{ getUserName(scope.row.ownerUserId) }}
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="配置类型" align="center" prop="configType" width="180"> <el-table-column label="配置类型" align="center" prop="configType" width="180">
@ -433,9 +440,9 @@
:formatter="dateFormatter" :formatter="dateFormatter"
width="180" width="180"
/> />
<el-table-column label="巡检人" align="center" prop="inspector"> <el-table-column label="巡检人" align="center" prop="ownerUserId">
<template #default="scope"> <template #default="scope">
{{ getUserName(scope.row.inspector) }} {{ getUserName(scope.row.ownerUserId) }}
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="配置类型" align="center" prop="configType" width="180"> <el-table-column label="配置类型" align="center" prop="configType" width="180">
@ -537,7 +544,7 @@ const queryParams = reactive({
pageSize: 10, pageSize: 10,
projectId: undefined, projectId: undefined,
inspectionDate: [], inspectionDate: [],
inspector: undefined, ownerUserId: undefined,
overallStatus: undefined, overallStatus: undefined,
}) })
const queryFormRef = ref() // const queryFormRef = ref() //
@ -701,7 +708,7 @@ const getProjectName = (projectId: number | undefined) => {
/** 获取用户名称 */ /** 获取用户名称 */
const getUserName = (userId: number | string | undefined) => { const getUserName = (userId: number | string | undefined) => {
if (!userId && userId !== 0) return '' if (!userId && userId !== 0) return ''
// inspector // ownerUserId
const userIdNum = typeof userId === 'string' ? Number(userId) : userId const userIdNum = typeof userId === 'string' ? Number(userId) : userId
// NaN // NaN
if (isNaN(userIdNum as number)) return String(userId) if (isNaN(userIdNum as number)) return String(userId)
@ -750,11 +757,11 @@ const canShowUploadButton = (row: ProjectInspectionRecordApi.ProjectInspectionRe
} }
// 3. // 3.
const inspectorIdNum = typeof row.inspector === 'string' ? Number(row.inspector) : row.inspector const ownerUserIdIdNum = typeof row.ownerUserId === 'string' ? Number(row.ownerUserId) : row.ownerUserId
const currentUserId = userStore.user.id const currentUserId = userStore.user.id
// //
if (currentUserId === inspectorIdNum) { if (currentUserId === ownerUserIdIdNum) {
return true return true
} }
@ -795,7 +802,7 @@ const parseSummaryData = (summary: string) => {
// JSONtype // JSONtype
if (typeof data === 'object' && !Array.isArray(data) && data !== null) { if (typeof data === 'object' && !Array.isArray(data) && data !== null) {
const result: Record<string, Array<{ name: string; value: any; type: number }>> = {} const result: Record<string, Array<{ name: string; value: any; type: number; remark?: string }>> = {}
Object.keys(data).forEach((key) => { Object.keys(data).forEach((key) => {
const value = data[key] const value = data[key]
// type // type
@ -1158,17 +1165,43 @@ watch(list, (newList) => {
padding-bottom: 8px; padding-bottom: 8px;
border-bottom: 1px dashed #dcdfe6; border-bottom: 1px dashed #dcdfe6;
.field-question-label { .field-question-header {
font-weight: 600; display: flex;
color: #409EFF; align-items: flex-start;
margin-right: 6px; gap: 6px;
font-size: 13px; margin-bottom: 6px;
.field-question-label {
font-weight: 600;
color: #409EFF;
flex-shrink: 0;
font-size: 13px;
}
.field-question-text {
font-weight: 500;
color: #303133;
word-break: break-word;
flex: 1;
}
} }
.field-question-text { .field-question-remark {
font-weight: 500; font-size: 12px;
color: #303133; color: #909399;
line-height: 1.5;
word-break: break-word; word-break: break-word;
padding: 6px 10px;
background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
border-radius: 4px;
border-left: 3px solid #409EFF;
margin-top: 6px;
&::before {
content: '💡';
margin-right: 6px;
font-size: 12px;
}
} }
} }
@ -1241,9 +1274,29 @@ watch(list, (newList) => {
} }
} }
.remark-content { .remark-wrapper {
color: #606266; display: flex;
line-height: 1.6; align-items: flex-start;
gap: 8px;
padding: 10px 12px;
background-color: #f8f9fa;
border-radius: 6px;
border-left: 3px solid #909399;
.remark-label {
color: #909399;
font-weight: 500;
flex-shrink: 0;
margin-right: 0;
}
.remark-content {
color: #606266;
line-height: 1.6;
word-break: break-word;
flex: 1;
white-space: pre-wrap;
}
} }
} }
} }