v1.2.1版本,优化调整了很多,整改验收阶段新加字段

This commit is contained in:
王利强
2026-06-13 08:50:51 +08:00
parent 2af9f1fd59
commit 1fe87ec438
591 changed files with 5072 additions and 2706 deletions

View File

@@ -1,9 +1,9 @@
<template>
<view class="padding page">
<view class="padding bg-white radius margin-bottom card-item" v-for="(item,index) in hazardList" :key="index">
<view class="padding bg-white radius margin-bottom card-item" v-for="item in hazardList" :key="item.hazardId || item.id">
<view class="flex justify-between margin-bottom">
<view class="text-bold text-black" style="flex: 1; margin-right: 16rpx;">{{item.hazardTitle}}</view>
<view class="status-tag" :class="getStatusClass(item.verifyResultName)">{{item.verifyResultName || '未知'}}</view>
<view class="status-tag" :class="getStatusClass(item)">{{item.verifyResultName || '未知'}}</view>
</view>
<view class="flex margin-bottom">
<view class="text-gray">隐患日期</view>
@@ -24,7 +24,7 @@
</view>
<view class="flex justify-between">
<view></view>
<view><button class="bg-blue round cu-btn lg" @click="editor()">查看详情</button></view>
<view><button class="bg-blue round cu-btn lg" @click="editor(item)">查看详情</button></view>
</view>
</view>
<button class="cuIcon-add bg-blue round margin-top" @click="openAddPopup">新增</button>
@@ -54,30 +54,17 @@
<view class="flex margin-bottom margin-top">
<view>整改时限</view>
</view>
<view class="picker-input" @click="showDatePicker = true">
<text :class="formData.rectifyDeadline ? '' : 'text-gray'">{{ formData.rectifyDeadline || '请选择整改时限' }}</text>
<view class="picker-input readonly">
<text :class="formData.rectifyDeadline ? '' : 'text-gray'">{{ formData.rectifyDeadline || '请选择隐患' }}</text>
</view>
<up-datetime-picker
v-if="false" :show="showDatePicker"
v-model="dateValue"
mode="datetime"
@confirm="onDateConfirm"
@cancel="showDatePicker = false"
@close="showDatePicker = false"
></up-datetime-picker>
<view class="margin-bottom margin-top">隐患治理责任单位</view>
<view class="picker-input" @click="showDeptPicker = true">
<text :class="selectedDeptName ? '' : 'text-gray'">{{ selectedDeptName || '请选择隐患治理责任单位' }}</text>
<view class="picker-input readonly">
<text :class="selectedDeptName ? '' : 'text-gray'">{{ selectedDeptName || '请选择隐患' }}</text>
</view>
<up-picker
v-if="false" :show="showDeptPicker"
:columns="deptColumns"
@confirm="onDeptConfirm"
@cancel="showDeptPicker = false"
@close="showDeptPicker = false"
></up-picker>
<view class="margin-bottom margin-top">主要负责人</view>
<up-input v-model="formData.responsiblePerson" placeholder="请输入主要负责人"></up-input>
<view class="picker-input readonly">
<text :class="formData.responsiblePerson ? '' : 'text-gray'">{{ formData.responsiblePerson || '请先选择隐患' }}</text>
</view>
<view class="ai-btn-wrapper margin-top margin-bottom">
<button class="ai-analyze-btn" :loading="aiGenerating" :disabled="aiGenerating" @click="handleAiGenerate">
<text v-if="!aiGenerating" class="cuIcon-magic ai-btn-icon"></text>
@@ -107,34 +94,16 @@
@close="showHazardPicker = false"
></up-picker>
<up-datetime-picker
:show="showDatePicker"
v-model="dateValue"
mode="datetime"
@confirm="onDateConfirm"
@cancel="showDatePicker = false"
@close="showDatePicker = false"
></up-datetime-picker>
<up-picker
:show="showDeptPicker"
:columns="deptColumns"
@confirm="onDeptConfirm"
@cancel="showDeptPicker = false"
@close="showDeptPicker = false"
></up-picker>
</view>
</template>
<script setup>
import { ref, reactive, onMounted } from 'vue'
import { getMyWriteOffList, applyDelete, getAcceptanceList, getDepartmentPersonUsers, getHiddenDangerDetail, getRectifyDetail, generateWriteoffContent } from '@/request/api.js';
import { getMyWriteOffList, applyDelete, getAcceptanceList, getHiddenDangerDetail, getRectifyDetail, generateWriteoffContent } from '@/request/api.js';
// 弹窗控制
const showAddPopup = ref(false);
const showHazardPicker = ref(false);
const showDatePicker = ref(false);
const showDeptPicker = ref(false);
// 隐患选择
const selectedHazard = ref('');
@@ -143,14 +112,8 @@
const acceptanceHazardList = ref([]); // 存储可申请销号的隐患数据
const hazardList = ref([]); // 存储销号申请列表
// 部门选择
// 隐患关联的只读展示字段
const selectedDeptName = ref('');
const selectedDeptId = ref('');
const deptColumns = ref([['暂无数据']]);
const deptList = ref([]); // 存储部门列表
// 日期选择
const dateValue = ref(Date.now());
// AI生成状态
const aiGenerating = ref(false);
@@ -198,94 +161,41 @@
}
};
// 获取部门列表
const fetchDeptList = async () => {
try {
const res = await getDepartmentPersonUsers();
if (res.code === 0 && res.data) {
const users = [];
res.data.forEach(dept => {
if (dept.users && dept.users.length > 0) {
dept.users.forEach(user => {
users.push({
userId: user.userId,
deptId: dept.deptId,
name: `${user.nickName}${dept.deptName}`
});
});
}
});
deptList.value = users;
// 转换为 picker 需要的格式
if (users.length > 0) {
deptColumns.value = [users.map(item => item.name)];
} else {
deptColumns.value = [['暂无人员数据']];
}
console.log('部门人员列表:', users);
}
} catch (error) {
console.error('获取部门人员列表失败:', error);
}
};
// 部门选择确认
const onDeptConfirm = (e) => {
console.log('选择的人员:', e);
if (e.value && e.value.length > 0) {
selectedDeptName.value = e.value[0];
// 找到对应的用户ID和部门ID
const index = e.indexs[0];
if (deptList.value[index]) {
selectedDeptId.value = deptList.value[index].deptId;
formData.responsibleDeptId = deptList.value[index].deptId;
}
}
showDeptPicker.value = false;
};
// 打开新增弹窗
const openAddPopup = () => {
resetForm();
fetchAcceptanceList(); // 获取可申请销号的隐患列表
fetchDeptList(); // 获取部门列表
showAddPopup.value = true;
};
// 根据选中的隐患回显只读字段
const fillHazardRelatedFields = (hazard) => {
formData.rectifyDeadline = hazard.deadline || '';
selectedDeptName.value = hazard.deptName || '';
formData.responsiblePerson = hazard.rectifierName || '';
formData.responsibleDeptId = hazard.deptId || '';
};
// 隐患选择确认
const onHazardConfirm = (e) => {
console.log('选择的隐患:', e);
if (e.value && e.value.length > 0) {
selectedHazard.value = e.value[0];
// 找到对应的隐患ID
const index = e.indexs[0];
if (acceptanceHazardList.value[index]) {
selectedHazardId.value = acceptanceHazardList.value[index].hazardId;
const hazard = acceptanceHazardList.value[index];
if (hazard) {
selectedHazardId.value = hazard.hazardId;
fillHazardRelatedFields(hazard);
}
}
showHazardPicker.value = false;
};
// 日期时间选择确认
const onDateConfirm = (e) => {
console.log('选择的日期时间:', e);
const date = new Date(e.value);
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, '0');
const day = String(date.getDate()).padStart(2, '0');
const hours = String(date.getHours()).padStart(2, '0');
const minutes = String(date.getMinutes()).padStart(2, '0');
const seconds = String(date.getSeconds()).padStart(2, '0');
formData.rectifyDeadline = `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
showDatePicker.value = false;
};
// 重置表单
const resetForm = () => {
selectedHazard.value = '';
selectedHazardId.value = '';
selectedDeptName.value = '';
selectedDeptId.value = '';
formData.rectifyDeadline = '';
formData.responsibleDeptId = '';
formData.responsiblePerson = '';
@@ -386,20 +296,26 @@
}
};
const editor = () => {
const editor = (item) => {
if (!item?.id) {
uni.showToast({ title: '缺少申请ID', icon: 'none' });
return;
}
uni.navigateTo({
url: '/pages/closeout/editor'
})
url: `/pages/closeout/editor?applyId=${item.id}`
});
};
// 根据审核状态返回对应样式类
const getStatusClass = (status) => {
switch (status) {
case '待审核': return 'status-pending';
case '通过': return 'status-passed';
case '驳回': return 'status-rejected';
default: return 'status-pending';
}
const getStatusClass = (item) => {
const statusName = item?.verifyResultName || '';
if (statusName === '待审核') return 'status-pending';
if (statusName === '审核通过' || statusName === '已通过') return 'status-passed';
if (statusName === '审核驳回' || statusName === '已驳回') return 'status-rejected';
if (statusName === '已重新申请') return 'status-reapply';
if (item?.verifyResult === 1) return 'status-passed';
if (item?.verifyResult === 2) return 'status-rejected';
return 'status-default';
};
// 页面加载时获取销号申请列表
@@ -441,6 +357,16 @@
color: #F5222D;
}
.status-reapply {
background: #E6F7FF;
color: #1890FF;
}
.status-default {
background: #F5F5F5;
color: #8C8C8C;
}
.popup-content {
width: 600rpx;
background: #fff;
@@ -534,12 +460,15 @@
border-radius: 8rpx;
padding: 24rpx 20rpx;
margin-bottom: 20rpx;
// border: 1rpx solid #F6F6F6;
border: 1rpx solid #eee;
text {
font-size: 28rpx;
// color: #333;
}
&.readonly {
background: #f5f5f5;
color: #666;
}
}
</style>