一单四制优化及加入工作流
This commit is contained in:
@@ -345,7 +345,7 @@ const viewHazardDetail = (item) => {
|
||||
return;
|
||||
}
|
||||
uni.navigateTo({
|
||||
url: `/pages/hiddendanger/detail2?hazardId=${item.hazardId}&assignId=${item.assignId || ''}`
|
||||
url: `/pages/hiddendanger/process-chain?hazardId=${item.hazardId}`
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
</view>
|
||||
|
||||
<!-- 新增按钮 -->
|
||||
<button class="add-btn bg-blue round" @click="openAddPopup">新增公司区域</button>
|
||||
<button class="add-btn bg-blue round" @click="openAddPopup">新增区域</button>
|
||||
|
||||
<!-- 新增/编辑弹窗组件 -->
|
||||
<AreaFormPopup
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
</view>
|
||||
<view class="flex margin-bottom">
|
||||
<view class="text-gray">创建时间:</view>
|
||||
|
||||
<view class="text-black">{{item.createdAt}}</view>
|
||||
</view>
|
||||
<view class="flex justify-between">
|
||||
@@ -27,306 +26,32 @@
|
||||
<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>
|
||||
<!-- 弹出框 -->
|
||||
<u-popup :show="showAddPopup" mode="center" round="20" :safeAreaInsetBottom="false" @close="showAddPopup = false">
|
||||
<view class="popup-content">
|
||||
<view class="popup-header">
|
||||
<view class="popup-title text-bold">新增销号申请</view>
|
||||
<view class="popup-close" @click="showAddPopup = false">×</view>
|
||||
</view>
|
||||
<scroll-view class="popup-body" scroll-y :style="{ height: '60vh' }">
|
||||
<view class="flex margin-bottom">
|
||||
<view>隐患</view>
|
||||
<view class="text-red">*</view>
|
||||
</view>
|
||||
<view class="picker-input" @click="showHazardPicker = true">
|
||||
<text :class="selectedHazard ? '' : 'text-gray'">{{ selectedHazard || '请选择隐患' }}</text>
|
||||
</view>
|
||||
<up-picker
|
||||
v-if="false" :show="showHazardPicker"
|
||||
:columns="hazardColumns"
|
||||
@confirm="onHazardConfirm"
|
||||
@cancel="showHazardPicker = false"
|
||||
@close="showHazardPicker = false"
|
||||
></up-picker>
|
||||
|
||||
<view class="flex margin-bottom margin-top">
|
||||
<view>整改时限</view>
|
||||
</view>
|
||||
<view class="picker-input readonly">
|
||||
<text :class="formData.rectifyDeadline ? '' : 'text-gray'">{{ formData.rectifyDeadline || '请先选择隐患' }}</text>
|
||||
</view>
|
||||
<view class="margin-bottom margin-top">隐患治理责任单位</view>
|
||||
<view class="picker-input readonly">
|
||||
<text :class="selectedDeptName ? '' : 'text-gray'">{{ selectedDeptName || '请先选择隐患' }}</text>
|
||||
</view>
|
||||
<view class="margin-bottom margin-top">主要负责人</view>
|
||||
<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>
|
||||
{{ aiGenerating ? 'AI生成中...' : 'AI 生成销号方案' }}
|
||||
</button>
|
||||
</view>
|
||||
<view class="margin-bottom margin-top">主要治理内容</view>
|
||||
<up-textarea v-model="formData.mainTreatmentContent" placeholder="请输入主要治理内容"></up-textarea>
|
||||
<view class="margin-bottom margin-top">隐患治理完成内容</view>
|
||||
<up-textarea v-model="formData.treatmentResult" placeholder="请输入隐患治理完成情况"></up-textarea>
|
||||
<view class="margin-bottom margin-top">隐患治理责任单位自行验收的情况</view>
|
||||
<up-textarea v-model="formData.selfVerifyContent" placeholder="请输入隐患治理责任单位自行验收的情况"></up-textarea>
|
||||
|
||||
<view class="flex margin-bottom margin-top">
|
||||
<view class="text-gray">下一步流程</view>
|
||||
<view class="text-red">*</view>
|
||||
</view>
|
||||
<view class="static-field">隐患销号审批</view>
|
||||
|
||||
<view class="flex margin-bottom margin-top">
|
||||
<view class="text-gray">下一步处理人</view>
|
||||
<view class="text-red">*</view>
|
||||
</view>
|
||||
<view class="static-field">部门、企业管理员</view>
|
||||
|
||||
<view class="flex margin-bottom margin-top">
|
||||
<view class="text-gray">短信提醒</view>
|
||||
<view class="text-red">*</view>
|
||||
</view>
|
||||
<up-radio-group v-model="sendMsgFlagRadio" placement="row" activeColor="#2667e9">
|
||||
<up-radio
|
||||
label="是"
|
||||
name="yes"
|
||||
:customStyle="{ marginRight: '48rpx' }"
|
||||
></up-radio>
|
||||
<up-radio label="否" name="no"></up-radio>
|
||||
</up-radio-group>
|
||||
</scroll-view>
|
||||
<view class="popup-footer">
|
||||
<button class="btn-cancel" @click="showAddPopup = false">取消</button>
|
||||
<button class="btn-confirm bg-blue" @click="handleAdd">确定</button>
|
||||
</view>
|
||||
</view>
|
||||
</u-popup>
|
||||
|
||||
<!-- 移出到外层的选择器组件,防止其定位样式被 scroll-view 剪裁并导致暗色遮罩溢出异常 -->
|
||||
<up-picker
|
||||
:show="showHazardPicker"
|
||||
:columns="hazardColumns"
|
||||
@confirm="onHazardConfirm"
|
||||
@cancel="showHazardPicker = false"
|
||||
@close="showHazardPicker = false"
|
||||
></up-picker>
|
||||
|
||||
<button class="cuIcon-add bg-blue round margin-top" @click="goAddApply">新增</button>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, reactive, computed, onMounted } from 'vue'
|
||||
import { getMyWriteOffList, applyDelete, getAcceptanceList, getHiddenDangerDetail, getRectifyDetail, generateWriteoffContent } from '@/request/api.js';
|
||||
import { ref } from 'vue';
|
||||
import { onShow } from '@dcloudio/uni-app';
|
||||
import { getMyWriteOffList } from '@/request/api.js';
|
||||
|
||||
// 弹窗控制
|
||||
const showAddPopup = ref(false);
|
||||
const showHazardPicker = ref(false);
|
||||
|
||||
// 隐患选择
|
||||
const selectedHazard = ref('');
|
||||
const selectedHazardId = ref('');
|
||||
const hazardColumns = ref([['暂无数据']]);
|
||||
const acceptanceHazardList = ref([]); // 存储可申请销号的隐患数据
|
||||
const hazardList = ref([]); // 存储销号申请列表
|
||||
|
||||
// 隐患关联的只读展示字段
|
||||
const selectedDeptName = ref('');
|
||||
|
||||
// AI生成状态
|
||||
const aiGenerating = ref(false);
|
||||
const hazardList = ref([]);
|
||||
|
||||
// 短信提醒
|
||||
const sendMsgFlagRadio = ref('yes');
|
||||
const sendMsgFlag = computed(() => sendMsgFlagRadio.value === 'yes');
|
||||
|
||||
// 表单数据
|
||||
const formData = reactive({
|
||||
rectifyDeadline: '', // 整改时限
|
||||
responsibleDeptId: '', // 隐患治理责任单位ID
|
||||
responsiblePerson: '', // 主要负责人
|
||||
mainTreatmentContent: '', // 主要治理内容
|
||||
treatmentResult: '', // 隐患治理完成内容
|
||||
selfVerifyContent: '' // 责任单位自行验收情况
|
||||
});
|
||||
|
||||
// 获取销号申请列表(页面显示用)
|
||||
const fetchWriteOffList = async () => {
|
||||
try {
|
||||
const res = await getMyWriteOffList();
|
||||
if (res.code === 0 && res.data) {
|
||||
hazardList.value = res.data;
|
||||
console.log('销号申请列表:', res.data);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取销号申请列表失败:', error);
|
||||
}
|
||||
};
|
||||
|
||||
// 获取可申请销号的隐患列表(弹窗选择用)
|
||||
const fetchAcceptanceList = async () => {
|
||||
try {
|
||||
const res = await getAcceptanceList();
|
||||
if (res.code === 0 && res.data) {
|
||||
const list = res.data.records || res.data || [];
|
||||
acceptanceHazardList.value = list;
|
||||
// 转换为 picker 需要的格式
|
||||
if (list.length > 0) {
|
||||
hazardColumns.value = [list.map(item => item.title || item.hazardTitle || `隐患${item.hazardId}`)];
|
||||
} else {
|
||||
hazardColumns.value = [['暂无可申请销号的隐患']];
|
||||
}
|
||||
console.log('可申请销号的隐患列表:', list);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取可申请销号隐患列表失败:', error);
|
||||
}
|
||||
|
||||
const goAddApply = () => {
|
||||
uni.navigateTo({ url: '/pages/closeout/apply' });
|
||||
};
|
||||
|
||||
// 打开新增弹窗
|
||||
const openAddPopup = () => {
|
||||
resetForm();
|
||||
fetchAcceptanceList(); // 获取可申请销号的隐患列表
|
||||
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];
|
||||
const index = e.indexs[0];
|
||||
const hazard = acceptanceHazardList.value[index];
|
||||
if (hazard) {
|
||||
selectedHazardId.value = hazard.hazardId;
|
||||
fillHazardRelatedFields(hazard);
|
||||
}
|
||||
}
|
||||
showHazardPicker.value = false;
|
||||
};
|
||||
|
||||
// 重置表单
|
||||
const resetForm = () => {
|
||||
selectedHazard.value = '';
|
||||
selectedHazardId.value = '';
|
||||
selectedDeptName.value = '';
|
||||
formData.rectifyDeadline = '';
|
||||
formData.responsibleDeptId = '';
|
||||
formData.responsiblePerson = '';
|
||||
formData.mainTreatmentContent = '';
|
||||
formData.treatmentResult = '';
|
||||
formData.selfVerifyContent = '';
|
||||
sendMsgFlagRadio.value = 'yes';
|
||||
};
|
||||
|
||||
// AI生成销号方案
|
||||
const handleAiGenerate = async () => {
|
||||
if (!selectedHazardId.value) {
|
||||
uni.showToast({ title: '请先选择隐患', icon: 'none' });
|
||||
return;
|
||||
}
|
||||
|
||||
aiGenerating.value = true;
|
||||
try {
|
||||
// 1. 获取隐患详情
|
||||
const hazardRes = await getHiddenDangerDetail({ hazardId: selectedHazardId.value });
|
||||
if (hazardRes.code !== 0 || !hazardRes.data) {
|
||||
uni.showToast({ title: '获取隐患详情失败', icon: 'none' });
|
||||
return;
|
||||
}
|
||||
|
||||
// 2. 从 assigns 中获取 rectifyId
|
||||
const assigns = hazardRes.data.assigns;
|
||||
if (!assigns || assigns.length === 0 || !assigns[0].rectify) {
|
||||
uni.showToast({ title: '该隐患暂无整改记录', icon: 'none' });
|
||||
return;
|
||||
}
|
||||
const rectifyId = assigns[0].rectify.rectifyId;
|
||||
|
||||
// 3. 获取整改详情
|
||||
const rectifyRes = await getRectifyDetail({ rectifyId });
|
||||
if (rectifyRes.code !== 0 || !rectifyRes.data) {
|
||||
uni.showToast({ title: '获取整改详情失败', icon: 'none' });
|
||||
return;
|
||||
}
|
||||
|
||||
const rectifyPlan = rectifyRes.data.rectifyPlan;
|
||||
if (!rectifyPlan) {
|
||||
uni.showToast({ title: '整改方案内容为空', icon: 'none' });
|
||||
return;
|
||||
}
|
||||
|
||||
// 4. 调用AI生成销号方案
|
||||
const aiRes = await generateWriteoffContent({ rectifyContent: rectifyPlan });
|
||||
if (aiRes.code === 0 && aiRes.data) {
|
||||
formData.mainTreatmentContent = aiRes.data.mainContent || '';
|
||||
formData.treatmentResult = aiRes.data.completionContent || '';
|
||||
formData.selfVerifyContent = aiRes.data.selfInspection || '';
|
||||
uni.showToast({ title: 'AI生成成功', icon: 'success' });
|
||||
} else {
|
||||
uni.showToast({ title: aiRes.msg || 'AI生成失败', icon: 'none' });
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('AI生成销号方案失败:', error);
|
||||
uni.showToast({ title: 'AI生成失败,请重试', icon: 'none' });
|
||||
} finally {
|
||||
aiGenerating.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
// 确定新增
|
||||
const handleAdd = async () => {
|
||||
if (!selectedHazardId.value) {
|
||||
uni.showToast({ title: '请选择隐患', icon: 'none' });
|
||||
return;
|
||||
}
|
||||
|
||||
// 构建请求参数(与接口文档对应)
|
||||
const params = {
|
||||
hazardId: Number(selectedHazardId.value), // 隐患ID(必需)
|
||||
rectifyDeadline: formData.rectifyDeadline || '', // 整改时限
|
||||
responsibleDeptId: Number(formData.responsibleDeptId) || 0, // 隐患治理责任单位ID
|
||||
responsiblePerson: formData.responsiblePerson || '', // 主要负责人
|
||||
mainTreatmentContent: formData.mainTreatmentContent || '', // 主要治理内容
|
||||
treatmentResult: formData.treatmentResult || '', // 隐患治理完成内容
|
||||
selfVerifyContent: formData.selfVerifyContent || '', // 责任单位自行验收情况
|
||||
sendMsgFlag: sendMsgFlag.value // 是否短信提醒
|
||||
};
|
||||
|
||||
console.log('提交数据:', params);
|
||||
|
||||
try {
|
||||
const res = await applyDelete(params);
|
||||
if (res.code === 0) {
|
||||
uni.showToast({ title: '申请成功', icon: 'success' });
|
||||
showAddPopup.value = false;
|
||||
resetForm();
|
||||
// 刷新销号申请列表
|
||||
fetchWriteOffList();
|
||||
} else {
|
||||
uni.showToast({ title: res.msg || '申请失败', icon: 'none' });
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('申请失败:', error);
|
||||
uni.showToast({ title: '请求失败', icon: 'none' });
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
const editor = (item) => {
|
||||
if (!item?.id) {
|
||||
uni.showToast({ title: '缺少申请ID', icon: 'none' });
|
||||
@@ -336,8 +61,7 @@
|
||||
url: `/pages/closeout/editor?applyId=${item.id}`
|
||||
});
|
||||
};
|
||||
|
||||
// 根据审核状态返回对应样式类
|
||||
|
||||
const getStatusClass = (item) => {
|
||||
const statusName = item?.verifyResultName || '';
|
||||
if (statusName === '待审核') return 'status-pending';
|
||||
@@ -348,9 +72,8 @@
|
||||
if (item?.verifyResult === 2) return 'status-rejected';
|
||||
return 'status-default';
|
||||
};
|
||||
|
||||
// 页面加载时获取销号申请列表
|
||||
onMounted(() => {
|
||||
|
||||
onShow(() => {
|
||||
fetchWriteOffList();
|
||||
});
|
||||
</script>
|
||||
@@ -397,120 +120,4 @@
|
||||
background: #F5F5F5;
|
||||
color: #8C8C8C;
|
||||
}
|
||||
|
||||
.popup-content {
|
||||
width: 600rpx;
|
||||
background: #fff;
|
||||
border-radius: 20rpx;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.popup-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 30rpx;
|
||||
border-bottom: 1rpx solid #eee;
|
||||
|
||||
.popup-title {
|
||||
font-size: 32rpx;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.popup-close {
|
||||
font-size: 40rpx;
|
||||
color: #999;
|
||||
line-height: 1;
|
||||
}
|
||||
}
|
||||
|
||||
.popup-body {
|
||||
padding: 30rpx;
|
||||
}
|
||||
|
||||
.popup-footer {
|
||||
display: flex;
|
||||
border-top: 1rpx solid #eee;
|
||||
|
||||
button {
|
||||
flex: 1;
|
||||
height: 90rpx;
|
||||
line-height: 90rpx;
|
||||
border-radius: 0;
|
||||
margin: 0 !important;
|
||||
padding: 0 !important;
|
||||
font-size: 30rpx;
|
||||
|
||||
&::after {
|
||||
border: none;
|
||||
}
|
||||
}
|
||||
|
||||
.btn-cancel {
|
||||
background: #fff;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.btn-confirm {
|
||||
color: #fff;
|
||||
}
|
||||
}
|
||||
.ai-btn-wrapper {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.ai-analyze-btn {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
height: 72rpx;
|
||||
padding: 0 32rpx;
|
||||
font-size: 28rpx;
|
||||
color: #fff;
|
||||
background: linear-gradient(135deg, #4facfe 0%, #2668EA 100%);
|
||||
border-radius: 36rpx;
|
||||
border: none;
|
||||
|
||||
&::after {
|
||||
border: none;
|
||||
}
|
||||
|
||||
.ai-btn-icon {
|
||||
margin-right: 8rpx;
|
||||
font-size: 30rpx;
|
||||
}
|
||||
|
||||
&[disabled] {
|
||||
opacity: 0.7;
|
||||
}
|
||||
}
|
||||
|
||||
.picker-input {
|
||||
background: #fff;
|
||||
border-radius: 8rpx;
|
||||
padding: 24rpx 20rpx;
|
||||
margin-bottom: 20rpx;
|
||||
border: 1rpx solid #eee;
|
||||
|
||||
text {
|
||||
font-size: 28rpx;
|
||||
}
|
||||
|
||||
&.readonly {
|
||||
background: #f5f5f5;
|
||||
color: #666;
|
||||
}
|
||||
}
|
||||
|
||||
.static-field {
|
||||
background: #fff;
|
||||
border: 1rpx solid #dcdfe6;
|
||||
border-radius: 8rpx;
|
||||
padding: 20rpx 24rpx;
|
||||
margin-bottom: 20rpx;
|
||||
font-size: 28rpx;
|
||||
color: #333;
|
||||
line-height: 1.5;
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
|
||||
778
pages/closeout/apply.vue
Normal file
778
pages/closeout/apply.vue
Normal file
@@ -0,0 +1,778 @@
|
||||
<template>
|
||||
<view class="padding page">
|
||||
<view class="padding bg-white radius">
|
||||
<view class="flex margin-bottom">
|
||||
<view>隐患</view>
|
||||
<view class="text-red">*</view>
|
||||
</view>
|
||||
<view class="picker-input readonly" v-if="hazardLocked">
|
||||
<text :class="selectedHazard ? '' : 'text-gray'">{{ selectedHazard || '加载中...' }}</text>
|
||||
</view>
|
||||
<view class="picker-input" v-else @click="showHazardPicker = true">
|
||||
<text :class="selectedHazard ? '' : 'text-gray'">{{ selectedHazard || '请选择隐患' }}</text>
|
||||
</view>
|
||||
|
||||
<view class="flex margin-bottom margin-top">
|
||||
<view>整改时限</view>
|
||||
</view>
|
||||
<view class="picker-input readonly">
|
||||
<text :class="formData.rectifyDeadline ? '' : 'text-gray'">{{ formData.rectifyDeadline || '请先选择隐患' }}</text>
|
||||
</view>
|
||||
|
||||
<view class="margin-bottom margin-top">隐患治理责任单位</view>
|
||||
<view class="picker-input readonly">
|
||||
<text :class="selectedDeptName ? '' : 'text-gray'">{{ selectedDeptName || '请先选择隐患' }}</text>
|
||||
</view>
|
||||
|
||||
<view class="margin-bottom margin-top">主要负责人</view>
|
||||
<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>
|
||||
{{ aiGenerating ? 'AI生成中...' : 'AI 生成销号方案' }}
|
||||
</button>
|
||||
</view>
|
||||
|
||||
<view class="margin-bottom margin-top">主要治理内容</view>
|
||||
<up-textarea v-model="formData.mainTreatmentContent" placeholder="请输入主要治理内容"></up-textarea>
|
||||
|
||||
<view class="margin-bottom margin-top">隐患治理完成内容</view>
|
||||
<up-textarea v-model="formData.treatmentResult" placeholder="请输入隐患治理完成情况"></up-textarea>
|
||||
|
||||
<view class="margin-bottom margin-top">隐患治理责任单位自行验收的情况</view>
|
||||
<up-textarea v-model="formData.selfVerifyContent" placeholder="请输入隐患治理责任单位自行验收的情况"></up-textarea>
|
||||
|
||||
<view class="flex margin-bottom margin-top">
|
||||
<view class="text-gray">下一步流程</view>
|
||||
<view class="text-red">*</view>
|
||||
</view>
|
||||
<view class="static-field">{{ nextStepDisplay }}</view>
|
||||
|
||||
<view class="flex margin-bottom margin-top">
|
||||
<view class="text-gray">下一步处理人</view>
|
||||
<view class="text-red">*</view>
|
||||
</view>
|
||||
<view class="select-trigger" @click="openAssigneePopup">
|
||||
<view class="select-content" :class="{ 'text-gray': !selectedAssigneeName }">
|
||||
{{ selectedAssigneeName || '请选择下一步处理人' }}
|
||||
</view>
|
||||
<text class="cuIcon-unfold"></text>
|
||||
</view>
|
||||
|
||||
<view class="flex margin-bottom margin-top">
|
||||
<view class="text-gray">短信提醒</view>
|
||||
<view class="text-red">*</view>
|
||||
</view>
|
||||
<up-radio-group v-model="sendMsgFlagRadio" placement="row" activeColor="#2667e9">
|
||||
<up-radio
|
||||
label="是"
|
||||
name="yes"
|
||||
:customStyle="{ marginRight: '48rpx' }"
|
||||
></up-radio>
|
||||
<up-radio label="否" name="no"></up-radio>
|
||||
</up-radio-group>
|
||||
|
||||
<view class="flex margin-top-xl" style="gap: 20rpx;">
|
||||
<button class="round flex-sub" @click="handleCancel">取消</button>
|
||||
<button class="bg-blue round flex-sub" @click="handleSubmit">提交申请</button>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<up-picker
|
||||
v-if="!hazardLocked"
|
||||
:show="showHazardPicker"
|
||||
:columns="hazardColumns"
|
||||
@confirm="onHazardConfirm"
|
||||
@cancel="showHazardPicker = false"
|
||||
@close="showHazardPicker = false"
|
||||
></up-picker>
|
||||
|
||||
<u-popup :show="showAssigneePopup" mode="bottom" round="20" @close="cancelAssigneeSelect">
|
||||
<view class="user-popup">
|
||||
<view class="popup-header">
|
||||
<view class="popup-title text-bold">选择下一步处理人</view>
|
||||
<view class="popup-close" @click="cancelAssigneeSelect">×</view>
|
||||
</view>
|
||||
<scroll-view class="user-list-scroll" scroll-y>
|
||||
<view v-if="assigneeLoading" class="empty-tip">加载中...</view>
|
||||
<view v-else-if="assigneeList.length === 0" class="empty-tip">暂无人员数据</view>
|
||||
<template v-else>
|
||||
<view
|
||||
v-for="user in assigneeList"
|
||||
:key="getAssigneeItemKey(user)"
|
||||
class="user-item"
|
||||
:class="{ active: String(pickerAssigneeIdentityId) === String(resolveAssigneeIdentityId(user)) }"
|
||||
@click="onAssigneeItemClick(user)"
|
||||
>
|
||||
<text class="user-item-text">{{ formatAssigneeDisplayName(user) }}</text>
|
||||
<text v-if="String(pickerAssigneeIdentityId) === String(resolveAssigneeIdentityId(user))" class="cuIcon-check text-blue"></text>
|
||||
</view>
|
||||
</template>
|
||||
</scroll-view>
|
||||
<view class="popup-footer">
|
||||
<button class="btn-cancel" @click="cancelAssigneeSelect">取消</button>
|
||||
<button class="btn-confirm bg-blue" @click="confirmAssigneeSelect">确定</button>
|
||||
</view>
|
||||
</view>
|
||||
</u-popup>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, reactive, computed } from 'vue';
|
||||
import { onLoad } from '@dcloudio/uni-app';
|
||||
import {
|
||||
applyDelete,
|
||||
getHiddenDangerDetail,
|
||||
getHiddenDangerList,
|
||||
getRectifyDetail,
|
||||
generateWriteoffContent,
|
||||
getFlowNextNodes,
|
||||
getDeptUsers
|
||||
} from '@/request/api.js';
|
||||
import { buildWriteoffHazardFromOptions } from '@/utils/hazardNav.js';
|
||||
|
||||
const showHazardPicker = ref(false);
|
||||
const hazardLocked = ref(false);
|
||||
const selectedHazard = ref('');
|
||||
const selectedHazardId = ref('');
|
||||
const assignId = ref('');
|
||||
const taskId = ref('');
|
||||
const hazardColumns = ref([['暂无数据']]);
|
||||
const selectableHazardList = ref([]);
|
||||
const selectedDeptName = ref('');
|
||||
const aiGenerating = ref(false);
|
||||
const sendMsgFlagRadio = ref('yes');
|
||||
const sendMsgFlag = computed(() => sendMsgFlagRadio.value === 'yes');
|
||||
|
||||
const nextStepName = ref('');
|
||||
const nextStepLoading = ref(false);
|
||||
const nextStepDisplay = computed(() => {
|
||||
if (nextStepLoading.value) return '加载中...';
|
||||
return nextStepName.value || '暂无下一步流程';
|
||||
});
|
||||
|
||||
const selectedAssigneeIdentityId = ref('');
|
||||
const selectedAssigneeName = ref('');
|
||||
const pickerAssigneeIdentityId = ref('');
|
||||
const pickerAssigneeName = ref('');
|
||||
const showAssigneePopup = ref(false);
|
||||
const assigneeList = ref([]);
|
||||
const assigneeLoading = ref(false);
|
||||
|
||||
const formData = reactive({
|
||||
rectifyDeadline: '',
|
||||
responsibleDeptId: '',
|
||||
responsiblePerson: '',
|
||||
mainTreatmentContent: '',
|
||||
treatmentResult: '',
|
||||
selfVerifyContent: ''
|
||||
});
|
||||
|
||||
const findHazardInList = (hazardId) => {
|
||||
return selectableHazardList.value.find(
|
||||
(item) => String(item.hazardId) === String(hazardId) || String(item.id) === String(hazardId)
|
||||
);
|
||||
};
|
||||
|
||||
const fillHazardRelatedFields = (hazard) => {
|
||||
formData.rectifyDeadline = hazard.deadline || '';
|
||||
selectedDeptName.value = hazard.deptName || '';
|
||||
formData.responsiblePerson = hazard.rectifierName || '';
|
||||
formData.responsibleDeptId = hazard.deptId || '';
|
||||
};
|
||||
|
||||
const resolveTaskIdFromHazard = (hazard) => {
|
||||
if (!hazard) return '';
|
||||
const candidates = [
|
||||
hazard.taskId,
|
||||
hazard.flowTaskId,
|
||||
hazard.currentTaskId,
|
||||
hazard.flowTask?.taskId,
|
||||
hazard.currentTask?.taskId
|
||||
];
|
||||
for (const id of candidates) {
|
||||
if (id != null && id !== '') return String(id);
|
||||
}
|
||||
return '';
|
||||
};
|
||||
|
||||
const resolveTaskIdFromAssign = (assign) => {
|
||||
if (!assign) return '';
|
||||
const candidates = [
|
||||
assign.taskId,
|
||||
assign.flowTaskId,
|
||||
assign.currentTaskId,
|
||||
assign.rectify?.taskId,
|
||||
assign.rectify?.flowTaskId,
|
||||
assign.rectify?.currentTaskId,
|
||||
assign.flow?.taskId,
|
||||
assign.currentTask?.taskId
|
||||
];
|
||||
for (const id of candidates) {
|
||||
if (id != null && id !== '') return String(id);
|
||||
}
|
||||
return '';
|
||||
};
|
||||
|
||||
const resolveAssignWithRectify = (assigns, currentAssignId) => {
|
||||
if (!assigns?.length) return null;
|
||||
if (currentAssignId) {
|
||||
const byAssignId = assigns.find(
|
||||
(item) => String(item.assignId) === String(currentAssignId) && item.rectify
|
||||
);
|
||||
if (byAssignId) return byAssignId;
|
||||
}
|
||||
return assigns.find((item) => item.rectify) || assigns[0] || null;
|
||||
};
|
||||
|
||||
const resolveTaskIdFromDetail = (data) => {
|
||||
if (!data) return '';
|
||||
if (data.taskId) return String(data.taskId);
|
||||
if (data.flowTaskId) return String(data.flowTaskId);
|
||||
if (data.currentTaskId) return String(data.currentTaskId);
|
||||
|
||||
const assigns = data.assigns || [];
|
||||
const matchedAssign = resolveAssignWithRectify(assigns, assignId.value);
|
||||
const fromMatched = resolveTaskIdFromAssign(matchedAssign);
|
||||
if (fromMatched) return fromMatched;
|
||||
|
||||
for (const assign of assigns) {
|
||||
const id = resolveTaskIdFromAssign(assign);
|
||||
if (id) return id;
|
||||
}
|
||||
return '';
|
||||
};
|
||||
|
||||
const resolveNextTaskName = (data) => {
|
||||
if (!data) return '';
|
||||
const branches = data.branches || [];
|
||||
const matchedBranch = branches.find((item) => item.matched) || branches[0];
|
||||
return matchedBranch?.nextNode?.taskName || '';
|
||||
};
|
||||
|
||||
const buildPreviewVariables = () => ({
|
||||
quickApprove: true
|
||||
});
|
||||
|
||||
const getStoredUserInfo = () => {
|
||||
try {
|
||||
const stored = uni.getStorageSync('userInfo');
|
||||
if (!stored) return {};
|
||||
return typeof stored === 'string' ? JSON.parse(stored) : stored;
|
||||
} catch (error) {
|
||||
return {};
|
||||
}
|
||||
};
|
||||
|
||||
const getCurrentDeptId = () => {
|
||||
const userInfo = getStoredUserInfo();
|
||||
const identity = userInfo.userIdentity;
|
||||
if (identity?.deptId != null && identity.deptId !== '') {
|
||||
return String(identity.deptId);
|
||||
}
|
||||
if (userInfo.deptId != null && userInfo.deptId !== '') {
|
||||
return String(userInfo.deptId);
|
||||
}
|
||||
return '';
|
||||
};
|
||||
|
||||
const resolveAssigneeIdentityId = (user) => {
|
||||
if (!user) return '';
|
||||
const id = user.identityId ?? user.userIdentityId ?? user.userId ?? '';
|
||||
return id === '' || id == null ? '' : String(id);
|
||||
};
|
||||
|
||||
const getAssigneeItemKey = (user) => {
|
||||
const identityId = resolveAssigneeIdentityId(user);
|
||||
if (identityId) return `identity-${identityId}`;
|
||||
return `user-${user.userId || user.nickName || ''}`;
|
||||
};
|
||||
|
||||
const formatAssigneeDisplayName = (user) => {
|
||||
if (!user) return '';
|
||||
const name = user.nickName || user.userName || user.name || '';
|
||||
const identityName = user.identityName || '';
|
||||
if (name && identityName) return `${name}(${identityName})`;
|
||||
return name || identityName || '未知人员';
|
||||
};
|
||||
|
||||
const resolveAssigneeDeptUserType = () => 2;
|
||||
|
||||
const fetchAssigneeList = async () => {
|
||||
const deptId = getCurrentDeptId();
|
||||
if (!deptId) {
|
||||
assigneeList.value = [];
|
||||
return;
|
||||
}
|
||||
assigneeLoading.value = true;
|
||||
try {
|
||||
const res = await getDeptUsers(deptId, { type: resolveAssigneeDeptUserType() });
|
||||
if (res.code === 0) {
|
||||
assigneeList.value = res.data || [];
|
||||
} else {
|
||||
assigneeList.value = [];
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取部门人员失败:', error);
|
||||
assigneeList.value = [];
|
||||
} finally {
|
||||
assigneeLoading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
const openAssigneePopup = async () => {
|
||||
pickerAssigneeIdentityId.value = selectedAssigneeIdentityId.value;
|
||||
pickerAssigneeName.value = selectedAssigneeName.value;
|
||||
showAssigneePopup.value = true;
|
||||
await fetchAssigneeList();
|
||||
};
|
||||
|
||||
const onAssigneeItemClick = (user) => {
|
||||
const identityId = resolveAssigneeIdentityId(user);
|
||||
if (!identityId) return;
|
||||
pickerAssigneeIdentityId.value = String(identityId);
|
||||
pickerAssigneeName.value = formatAssigneeDisplayName(user);
|
||||
};
|
||||
|
||||
const confirmAssigneeSelect = () => {
|
||||
if (!pickerAssigneeIdentityId.value) {
|
||||
uni.showToast({ title: '请选择下一步处理人', icon: 'none' });
|
||||
return;
|
||||
}
|
||||
selectedAssigneeIdentityId.value = pickerAssigneeIdentityId.value;
|
||||
selectedAssigneeName.value = pickerAssigneeName.value;
|
||||
showAssigneePopup.value = false;
|
||||
};
|
||||
|
||||
const cancelAssigneeSelect = () => {
|
||||
showAssigneePopup.value = false;
|
||||
};
|
||||
|
||||
const fetchNextStep = async () => {
|
||||
nextStepLoading.value = true;
|
||||
try {
|
||||
const currentTaskId = taskId.value;
|
||||
if (!currentTaskId) {
|
||||
nextStepName.value = '';
|
||||
return;
|
||||
}
|
||||
const res = await getFlowNextNodes({
|
||||
taskId: currentTaskId,
|
||||
previewVariables: buildPreviewVariables(),
|
||||
includeSubProcess: true
|
||||
});
|
||||
if (res.code === 0) {
|
||||
const payload = res.data && typeof res.data === 'object' ? res.data : res;
|
||||
nextStepName.value = resolveNextTaskName(payload);
|
||||
} else {
|
||||
nextStepName.value = '';
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取下一步流程失败:', error);
|
||||
nextStepName.value = '';
|
||||
} finally {
|
||||
nextStepLoading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
const resolveTaskIdForHazard = async (hazard) => {
|
||||
const presetTaskId = taskId.value;
|
||||
const fromHazard = resolveTaskIdFromHazard(hazard);
|
||||
if (fromHazard) {
|
||||
taskId.value = fromHazard;
|
||||
}
|
||||
|
||||
if (!hazard?.hazardId) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!assignId.value && hazard.assignId) {
|
||||
assignId.value = String(hazard.assignId);
|
||||
}
|
||||
|
||||
if (taskId.value) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const params = { hazardId: hazard.hazardId };
|
||||
if (assignId.value) {
|
||||
params.assignId = assignId.value;
|
||||
}
|
||||
const res = await getHiddenDangerDetail(params);
|
||||
if (res.code === 0 && res.data) {
|
||||
taskId.value = resolveTaskIdFromDetail(res.data) || presetTaskId;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取隐患任务信息失败:', error);
|
||||
}
|
||||
|
||||
if (!taskId.value && presetTaskId) {
|
||||
taskId.value = presetTaskId;
|
||||
}
|
||||
};
|
||||
|
||||
const resetFlowSelection = () => {
|
||||
selectedAssigneeIdentityId.value = '';
|
||||
selectedAssigneeName.value = '';
|
||||
nextStepName.value = '';
|
||||
};
|
||||
|
||||
const applySelectedHazard = async (hazard) => {
|
||||
if (!hazard) return;
|
||||
selectedHazard.value = hazard.title || hazard.hazardTitle || `隐患${hazard.hazardId}`;
|
||||
selectedHazardId.value = hazard.hazardId;
|
||||
assignId.value = hazard.assignId ? String(hazard.assignId) : '';
|
||||
if (hazard.taskId) {
|
||||
taskId.value = String(hazard.taskId);
|
||||
}
|
||||
fillHazardRelatedFields(hazard);
|
||||
resetFlowSelection();
|
||||
await resolveTaskIdForHazard(hazard);
|
||||
await fetchNextStep();
|
||||
};
|
||||
|
||||
const resolveSelectableRecords = (data) => {
|
||||
if (!data) return [];
|
||||
if (Array.isArray(data)) return data;
|
||||
if (Array.isArray(data.records)) return data.records;
|
||||
return [];
|
||||
};
|
||||
|
||||
const canApplyWriteoff = (item) => (
|
||||
item?.statusName === '待销号' && (item?.applyFlag === true || item?.applyFlag === 1 || item?.applyFlag === '1')
|
||||
);
|
||||
|
||||
/** 非锁定入口:从隐患列表拉取可申请销号的隐患(替代 verified/list) */
|
||||
const fetchSelectableHazardList = async () => {
|
||||
try {
|
||||
const res = await getHiddenDangerList({ pageNum: 1, pageSize: 100, status: 4 });
|
||||
if (res.code === 0 && res.data) {
|
||||
const list = resolveSelectableRecords(res.data).filter(canApplyWriteoff);
|
||||
selectableHazardList.value = list;
|
||||
if (list.length > 0) {
|
||||
hazardColumns.value = [list.map((item) => item.title || item.hazardTitle || `隐患${item.hazardId}`)];
|
||||
} else {
|
||||
hazardColumns.value = [['暂无可申请销号的隐患']];
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取可申请销号隐患列表失败:', error);
|
||||
}
|
||||
};
|
||||
|
||||
const preselectHazardById = async (hazardId) => {
|
||||
const hazard = findHazardInList(hazardId);
|
||||
if (!hazard) return false;
|
||||
await applySelectedHazard(hazard);
|
||||
return true;
|
||||
};
|
||||
|
||||
const onHazardConfirm = async (e) => {
|
||||
if (e.value && e.value.length > 0) {
|
||||
const index = e.indexs[0];
|
||||
const hazard = selectableHazardList.value[index];
|
||||
if (hazard) {
|
||||
await applySelectedHazard(hazard);
|
||||
}
|
||||
}
|
||||
showHazardPicker.value = false;
|
||||
};
|
||||
|
||||
const handleAiGenerate = async () => {
|
||||
if (!selectedHazardId.value) {
|
||||
uni.showToast({ title: '请先选择隐患', icon: 'none' });
|
||||
return;
|
||||
}
|
||||
|
||||
aiGenerating.value = true;
|
||||
try {
|
||||
const hazardRes = await getHiddenDangerDetail({ hazardId: selectedHazardId.value });
|
||||
if (hazardRes.code !== 0 || !hazardRes.data) {
|
||||
uni.showToast({ title: '获取隐患详情失败', icon: 'none' });
|
||||
return;
|
||||
}
|
||||
|
||||
const assigns = hazardRes.data.assigns;
|
||||
if (!assigns || assigns.length === 0 || !assigns[0].rectify) {
|
||||
uni.showToast({ title: '该隐患暂无整改记录', icon: 'none' });
|
||||
return;
|
||||
}
|
||||
const rectifyId = assigns[0].rectify.rectifyId;
|
||||
|
||||
const rectifyRes = await getRectifyDetail({ rectifyId });
|
||||
if (rectifyRes.code !== 0 || !rectifyRes.data) {
|
||||
uni.showToast({ title: '获取整改详情失败', icon: 'none' });
|
||||
return;
|
||||
}
|
||||
|
||||
const rectifyPlan = rectifyRes.data.rectifyPlan;
|
||||
if (!rectifyPlan) {
|
||||
uni.showToast({ title: '整改方案内容为空', icon: 'none' });
|
||||
return;
|
||||
}
|
||||
|
||||
const aiRes = await generateWriteoffContent({ rectifyContent: rectifyPlan });
|
||||
if (aiRes.code === 0 && aiRes.data) {
|
||||
formData.mainTreatmentContent = aiRes.data.mainContent || '';
|
||||
formData.treatmentResult = aiRes.data.completionContent || '';
|
||||
formData.selfVerifyContent = aiRes.data.selfInspection || '';
|
||||
uni.showToast({ title: 'AI生成成功', icon: 'success' });
|
||||
} else {
|
||||
uni.showToast({ title: aiRes.msg || 'AI生成失败', icon: 'none' });
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('AI生成销号方案失败:', error);
|
||||
uni.showToast({ title: 'AI生成失败,请重试', icon: 'none' });
|
||||
} finally {
|
||||
aiGenerating.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
const handleCancel = () => {
|
||||
uni.navigateBack();
|
||||
};
|
||||
|
||||
const handleSubmit = async () => {
|
||||
if (!selectedHazardId.value) {
|
||||
uni.showToast({ title: '请选择隐患', icon: 'none' });
|
||||
return;
|
||||
}
|
||||
if (!selectedAssigneeIdentityId.value) {
|
||||
uni.showToast({ title: '请选择下一步处理人', icon: 'none' });
|
||||
return;
|
||||
}
|
||||
|
||||
const params = {
|
||||
hazardId: Number(selectedHazardId.value),
|
||||
rectifyDeadline: formData.rectifyDeadline || '',
|
||||
responsibleDeptId: Number(formData.responsibleDeptId) || 0,
|
||||
responsiblePerson: formData.responsiblePerson || '',
|
||||
mainTreatmentContent: formData.mainTreatmentContent || '',
|
||||
treatmentResult: formData.treatmentResult || '',
|
||||
selfVerifyContent: formData.selfVerifyContent || '',
|
||||
assigneeIdentityId: selectedAssigneeIdentityId.value,
|
||||
sendMsgFlag: sendMsgFlag.value
|
||||
};
|
||||
|
||||
try {
|
||||
const res = await applyDelete(params);
|
||||
if (res.code === 0) {
|
||||
uni.showToast({ title: '申请成功', icon: 'success' });
|
||||
setTimeout(() => {
|
||||
uni.navigateBack();
|
||||
}, 1500);
|
||||
} else {
|
||||
uni.showToast({ title: res.msg || '申请失败', icon: 'none' });
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('申请失败:', error);
|
||||
uni.showToast({ title: '请求失败', icon: 'none' });
|
||||
}
|
||||
};
|
||||
|
||||
onLoad(async (options) => {
|
||||
hazardLocked.value = options?.locked === '1';
|
||||
if (options?.assignId) {
|
||||
assignId.value = String(options.assignId);
|
||||
}
|
||||
if (options?.taskId) {
|
||||
taskId.value = String(options.taskId);
|
||||
}
|
||||
|
||||
const hazardFromOptions = buildWriteoffHazardFromOptions(options);
|
||||
if (hazardFromOptions?.hazardId) {
|
||||
await applySelectedHazard(hazardFromOptions);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!hazardLocked.value) {
|
||||
await fetchSelectableHazardList();
|
||||
}
|
||||
|
||||
if (taskId.value) {
|
||||
await fetchNextStep();
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.page {
|
||||
min-height: 100vh;
|
||||
background: #EBF2FC;
|
||||
}
|
||||
|
||||
.ai-btn-wrapper {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.ai-analyze-btn {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
height: 72rpx;
|
||||
padding: 0 32rpx;
|
||||
font-size: 28rpx;
|
||||
color: #fff;
|
||||
background: linear-gradient(135deg, #4facfe 0%, #2668EA 100%);
|
||||
border-radius: 36rpx;
|
||||
border: none;
|
||||
|
||||
&::after {
|
||||
border: none;
|
||||
}
|
||||
|
||||
.ai-btn-icon {
|
||||
margin-right: 8rpx;
|
||||
font-size: 30rpx;
|
||||
}
|
||||
|
||||
&[disabled] {
|
||||
opacity: 0.7;
|
||||
}
|
||||
}
|
||||
|
||||
.picker-input {
|
||||
background: #fff;
|
||||
border-radius: 8rpx;
|
||||
padding: 24rpx 20rpx;
|
||||
margin-bottom: 20rpx;
|
||||
border: 1rpx solid #eee;
|
||||
|
||||
text {
|
||||
font-size: 28rpx;
|
||||
}
|
||||
|
||||
&.readonly {
|
||||
background: #f5f5f5;
|
||||
color: #666;
|
||||
}
|
||||
}
|
||||
|
||||
.static-field {
|
||||
background: #fff;
|
||||
border: 1rpx solid #dcdfe6;
|
||||
border-radius: 8rpx;
|
||||
padding: 20rpx 24rpx;
|
||||
margin-bottom: 20rpx;
|
||||
font-size: 28rpx;
|
||||
color: #333;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.select-trigger {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
background: #fff;
|
||||
border: 1rpx solid #dcdfe6;
|
||||
border-radius: 8rpx;
|
||||
padding: 20rpx 24rpx;
|
||||
margin-bottom: 20rpx;
|
||||
|
||||
.select-content {
|
||||
flex: 1;
|
||||
font-size: 28rpx;
|
||||
color: #333;
|
||||
}
|
||||
}
|
||||
|
||||
.user-popup {
|
||||
background: #fff;
|
||||
|
||||
.popup-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 30rpx;
|
||||
border-bottom: 1rpx solid #eee;
|
||||
|
||||
.popup-title {
|
||||
font-size: 32rpx;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.popup-close {
|
||||
font-size: 40rpx;
|
||||
color: #999;
|
||||
line-height: 1;
|
||||
}
|
||||
}
|
||||
|
||||
.user-list-scroll {
|
||||
max-height: 600rpx;
|
||||
padding: 0 30rpx;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.empty-tip {
|
||||
padding: 80rpx 20rpx;
|
||||
text-align: center;
|
||||
color: #909399;
|
||||
font-size: 26rpx;
|
||||
}
|
||||
|
||||
.user-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 24rpx 0;
|
||||
border-bottom: 1rpx solid #f5f5f5;
|
||||
|
||||
&:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
&.active {
|
||||
.user-item-text {
|
||||
color: #2667E9;
|
||||
font-weight: 600;
|
||||
}
|
||||
}
|
||||
|
||||
.user-item-text {
|
||||
flex: 1;
|
||||
font-size: 28rpx;
|
||||
color: #333;
|
||||
}
|
||||
}
|
||||
|
||||
.popup-footer {
|
||||
display: flex;
|
||||
gap: 24rpx;
|
||||
padding: 24rpx 30rpx;
|
||||
padding-bottom: calc(24rpx + env(safe-area-inset-bottom));
|
||||
background: #fff;
|
||||
|
||||
button {
|
||||
flex: 1;
|
||||
height: 80rpx;
|
||||
line-height: 80rpx;
|
||||
border-radius: 40rpx;
|
||||
font-size: 30rpx;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
|
||||
&::after {
|
||||
border: none;
|
||||
}
|
||||
}
|
||||
|
||||
.btn-cancel {
|
||||
background: #fff;
|
||||
color: #2667E9;
|
||||
border: 2rpx solid #2667E9;
|
||||
}
|
||||
|
||||
.btn-confirm {
|
||||
color: #fff;
|
||||
border: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
1232
pages/closeout/approval.vue
Normal file
1232
pages/closeout/approval.vue
Normal file
File diff suppressed because it is too large
Load Diff
1218
pages/closeout/leader-approval.vue
Normal file
1218
pages/closeout/leader-approval.vue
Normal file
File diff suppressed because it is too large
Load Diff
@@ -16,21 +16,12 @@
|
||||
<text>分派单位</text>
|
||||
<text class="required">*</text>
|
||||
</view>
|
||||
<view class="picker-input" @click="showDeptPicker = true">
|
||||
<view class="picker-input" @click="openDeptPopup">
|
||||
<text :class="formData.deptName ? 'picker-value' : 'picker-placeholder'">
|
||||
{{ formData.deptName || '请选择分派单位' }}
|
||||
</text>
|
||||
<text class="cuIcon-unfold picker-arrow"></text>
|
||||
</view>
|
||||
<up-picker
|
||||
:show="showDeptPicker"
|
||||
:columns="deptCascaderColumns"
|
||||
:defaultIndex="deptCascaderIndexs"
|
||||
@confirm="onDeptConfirm"
|
||||
@change="onDeptCascaderChange"
|
||||
@cancel="showDeptPicker = false"
|
||||
@close="showDeptPicker = false"
|
||||
></up-picker>
|
||||
</view>
|
||||
|
||||
<!-- 补充说明 -->
|
||||
@@ -377,6 +368,42 @@
|
||||
</view>
|
||||
</u-popup>
|
||||
|
||||
<!-- 分派单位选择弹窗 -->
|
||||
<u-popup :show="showDeptPicker" mode="center" round="20" :safeAreaInsetBottom="false" @close="cancelDeptSelect">
|
||||
<view class="dept-popup">
|
||||
<view class="popup-header">
|
||||
<view class="popup-title">选择分派单位</view>
|
||||
<view class="popup-close" @click="cancelDeptSelect">×</view>
|
||||
</view>
|
||||
|
||||
<view v-if="showDeptPicker" class="dept-tree-body">
|
||||
<xq-tree
|
||||
v-if="deptTree.length"
|
||||
ref="deptTreeRef"
|
||||
:data="deptTree"
|
||||
node-key="deptId"
|
||||
label-key="deptName"
|
||||
children-key="children"
|
||||
show-checkbox
|
||||
check-strictly
|
||||
default-expand-all
|
||||
:height="500"
|
||||
:width="560"
|
||||
:default-checked-keys="deptDefaultCheckedKeys"
|
||||
empty-text="暂无部门数据"
|
||||
@check="onDeptCheck"
|
||||
@node-click="onDeptNodeClick"
|
||||
/>
|
||||
<view v-else class="empty-tip">暂无部门数据</view>
|
||||
</view>
|
||||
|
||||
<view class="popup-footer">
|
||||
<button class="btn-cancel" @click="cancelDeptSelect">取消</button>
|
||||
<button class="btn-confirm" @click="confirmDeptSelect">确定</button>
|
||||
</view>
|
||||
</view>
|
||||
</u-popup>
|
||||
|
||||
<!-- 执行人员选择弹窗 -->
|
||||
<u-popup :show="showExecutorPopup" mode="center" round="20" @close="showExecutorPopup = false">
|
||||
<view class="executor-popup">
|
||||
@@ -413,9 +440,8 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, reactive, computed } from 'vue';
|
||||
import { ref, reactive, computed, onMounted, nextTick } from 'vue';
|
||||
import { getRegulationList, addCheckPoint, detailcheckPoint, deleteCheckPoint, getCheckItemList, getCheckItemListDetail, getDeptUsers, getDeptChildren, addCheckTable } from '@/request/api.js';
|
||||
import { onMounted } from 'vue';
|
||||
|
||||
// 表单数据
|
||||
const formData = reactive({
|
||||
@@ -560,13 +586,11 @@ const endDateValue = ref(getTodayTimestamp());
|
||||
const showDeptPicker = ref(false);
|
||||
const showTypePicker = ref(false);
|
||||
const showModePicker = ref(false);
|
||||
const showDeptSelectPicker = ref(false);
|
||||
const showCyclePicker = ref(false);
|
||||
const showStartDatePicker = ref(false);
|
||||
const showEndDatePicker = ref(false);
|
||||
|
||||
// 选择器数据
|
||||
const deptColumns = ref([['湘西自治州和谐网络科技有限公司', '湘西自治州和谐云大数据科技有限公司', '湘西网络有限公司']]);
|
||||
const typeColumns = ref([['日常检查', '专项检查', '设备检查']]);
|
||||
const modeColumns = ref([['单人完成', '全员']]);
|
||||
const cycleColumns = ref([['每天一次', '每周一次', '每月一次', '每季度一次']]);
|
||||
@@ -576,23 +600,84 @@ const showExecutorPopup = ref(false);
|
||||
const executorList = ref([]);
|
||||
const selectedExecutorId = ref(null);
|
||||
|
||||
// 分派单位级联选择器
|
||||
// 分派单位树形选择器
|
||||
const deptTree = ref([]);
|
||||
const deptCascaderColumns = ref([]);
|
||||
const deptCascaderIndexs = ref([0]);
|
||||
const selectedDeptPath = ref([]); // 选中的路径
|
||||
const deptTreeRef = ref(null);
|
||||
const selectedDeptId = ref(null);
|
||||
const deptDefaultCheckedKeys = ref([]);
|
||||
|
||||
// 选择器确认回调
|
||||
const onDeptConfirm = () => {
|
||||
const lastSelected = selectedDeptPath.value[selectedDeptPath.value.length - 1]
|
||||
if (lastSelected) {
|
||||
formData.deptId = lastSelected.deptId
|
||||
formData.deptName = selectedDeptPath.value.map(d => d.deptName).join(' / ')
|
||||
clearExecutorSelection()
|
||||
fetchDeptUsers(lastSelected.deptId)
|
||||
const getDeptNodeId = (node) => node?.deptId ?? node?.raw?.deptId ?? null;
|
||||
|
||||
const syncDeptTreeChecked = (deptId) => {
|
||||
nextTick(() => {
|
||||
if (deptId) {
|
||||
deptTreeRef.value?.setCheckedKeys?.([deptId]);
|
||||
} else {
|
||||
deptTreeRef.value?.clearChecked?.();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const findDeptPath = (tree, targetId, path = []) => {
|
||||
for (const node of tree) {
|
||||
const currentPath = [...path, node];
|
||||
if (String(node.deptId) === String(targetId)) {
|
||||
return currentPath;
|
||||
}
|
||||
if (node.children?.length) {
|
||||
const found = findDeptPath(node.children, targetId, currentPath);
|
||||
if (found) return found;
|
||||
}
|
||||
}
|
||||
showDeptPicker.value = false
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
const openDeptPopup = () => {
|
||||
selectedDeptId.value = formData.deptId || null;
|
||||
deptDefaultCheckedKeys.value = formData.deptId ? [formData.deptId] : [];
|
||||
showDeptPicker.value = true;
|
||||
syncDeptTreeChecked(formData.deptId);
|
||||
};
|
||||
|
||||
const onDeptNodeClick = (node) => {
|
||||
const deptId = getDeptNodeId(node);
|
||||
selectedDeptId.value = deptId;
|
||||
syncDeptTreeChecked(deptId);
|
||||
};
|
||||
|
||||
const onDeptCheck = (node, { checkedKeys = [] } = {}) => {
|
||||
const deptId = getDeptNodeId(node);
|
||||
const isChecked = checkedKeys.some((key) => String(key) === String(deptId));
|
||||
if (isChecked) {
|
||||
selectedDeptId.value = deptId;
|
||||
syncDeptTreeChecked(deptId);
|
||||
return;
|
||||
}
|
||||
selectedDeptId.value = null;
|
||||
syncDeptTreeChecked(null);
|
||||
};
|
||||
|
||||
const cancelDeptSelect = () => {
|
||||
showDeptPicker.value = false;
|
||||
};
|
||||
|
||||
const confirmDeptSelect = () => {
|
||||
if (!selectedDeptId.value) {
|
||||
uni.showToast({ title: '请选择分派单位', icon: 'none' });
|
||||
return;
|
||||
}
|
||||
const path = findDeptPath(deptTree.value, selectedDeptId.value);
|
||||
if (!path?.length) {
|
||||
uni.showToast({ title: '请选择分派单位', icon: 'none' });
|
||||
return;
|
||||
}
|
||||
const selected = path[path.length - 1];
|
||||
formData.deptId = selected.deptId;
|
||||
formData.deptName = path.map((d) => d.deptName).join(' / ');
|
||||
clearExecutorSelection();
|
||||
fetchDeptUsers(selected.deptId);
|
||||
showDeptPicker.value = false;
|
||||
};
|
||||
|
||||
// 检查表类型映射:日常检查->1, 专项检查->2, 设备检查->3
|
||||
const typeMap = {
|
||||
@@ -674,72 +759,12 @@ const fetchDeptChildren = async () => {
|
||||
if (res.code === 0 && res.data) {
|
||||
const list = Array.isArray(res.data) ? res.data : []
|
||||
deptTree.value = handleTree(list, 'deptId')
|
||||
initDeptCascader(deptTree.value)
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取部门树失败:', error)
|
||||
}
|
||||
}
|
||||
|
||||
// 初始化部门级联选择器
|
||||
const initDeptCascader = (treeData) => {
|
||||
const roots = Array.isArray(treeData) ? treeData : (treeData ? [treeData] : [])
|
||||
if (roots.length === 0) return
|
||||
|
||||
const firstColumn = roots.map(item => ({ text: item.deptName, ...item }))
|
||||
deptCascaderColumns.value = [firstColumn]
|
||||
deptCascaderIndexs.value = [0]
|
||||
selectedDeptPath.value = [roots[0]]
|
||||
|
||||
let current = roots[0]
|
||||
while (current.children && current.children.length > 0) {
|
||||
const nextColumn = current.children.map(item => ({ text: item.deptName, ...item }))
|
||||
deptCascaderColumns.value.push(nextColumn)
|
||||
deptCascaderIndexs.value.push(0)
|
||||
selectedDeptPath.value.push(current.children[0])
|
||||
current = current.children[0]
|
||||
}
|
||||
}
|
||||
|
||||
// 部门级联选择器列改变
|
||||
const onDeptCascaderChange = (e) => {
|
||||
const { columnIndex, index, value } = e;
|
||||
|
||||
// 更新当前列的选中索引
|
||||
deptCascaderIndexs.value[columnIndex] = index;
|
||||
|
||||
// 更新选中路径
|
||||
selectedDeptPath.value[columnIndex] = value;
|
||||
|
||||
// 删除后续列
|
||||
deptCascaderColumns.value = deptCascaderColumns.value.slice(0, columnIndex + 1);
|
||||
deptCascaderIndexs.value = deptCascaderIndexs.value.slice(0, columnIndex + 1);
|
||||
selectedDeptPath.value = selectedDeptPath.value.slice(0, columnIndex + 1);
|
||||
|
||||
// 如果有子级,添加新列
|
||||
if (value.children && value.children.length > 0) {
|
||||
const nextColumn = value.children.map(item => ({ text: item.deptName, ...item }));
|
||||
deptCascaderColumns.value.push(nextColumn);
|
||||
deptCascaderIndexs.value.push(0);
|
||||
selectedDeptPath.value.push(value.children[0]);
|
||||
|
||||
// 继续检查是否有下下级
|
||||
if (value.children[0].children && value.children[0].children.length > 0) {
|
||||
const thirdColumn = value.children[0].children.map(item => ({ text: item.deptName, ...item }));
|
||||
deptCascaderColumns.value.push(thirdColumn);
|
||||
deptCascaderIndexs.value.push(0);
|
||||
selectedDeptPath.value.push(value.children[0].children[0]);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const onDeptSelectConfirm = (e) => {
|
||||
if (e.value && e.value.length > 0) {
|
||||
formData.selectDeptName = e.value[0];
|
||||
}
|
||||
showDeptSelectPicker.value = false;
|
||||
};
|
||||
|
||||
const onCycleConfirm = (e) => {
|
||||
if (e.value && e.value.length > 0) {
|
||||
formData.cycleName = e.value[0];
|
||||
@@ -1857,6 +1882,31 @@ onMounted(() => {
|
||||
}
|
||||
}
|
||||
|
||||
// 分派单位弹窗样式
|
||||
.dept-popup {
|
||||
width: 600rpx;
|
||||
background: #fff;
|
||||
border-radius: 20rpx;
|
||||
overflow: hidden;
|
||||
|
||||
.popup-footer {
|
||||
button {
|
||||
margin: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.dept-tree-body {
|
||||
height: 500rpx;
|
||||
overflow: hidden;
|
||||
|
||||
:deep(.checkbox-custom.checked),
|
||||
:deep(.checkbox-custom.indeterminate) {
|
||||
background-color: #2667E9;
|
||||
border-color: #2667E9;
|
||||
}
|
||||
}
|
||||
|
||||
// 执行人员弹窗样式
|
||||
.executor-popup {
|
||||
width: 600rpx;
|
||||
|
||||
@@ -4,16 +4,16 @@
|
||||
<scroll-view class="status-tabs" scroll-x :show-scrollbar="false">
|
||||
<view class="status-tabs-inner">
|
||||
<view v-for="(tab, index) in statusTabs" :key="index" class="status-tab-item"
|
||||
:class="{ 'status-tab-active': activeTab === index }" @click="activeTab = index">
|
||||
:class="{ 'status-tab-active': activeTab === index }" @click="switchStatusTab(index)">
|
||||
<text class="status-tab-text">{{ tab.label }}</text>
|
||||
<view v-if="activeTab === index" class="status-tab-bar"></view>
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
|
||||
<view v-if="filteredList.length === 0" class="empty-tip text-gray text-center padding">暂无数据</view>
|
||||
<view v-if="hiddenDangerList.length === 0 && !listLoading" class="empty-tip text-gray text-center padding">暂无数据</view>
|
||||
|
||||
<view class="padding radius bg-white list-list margin-bottom" v-for="item in filteredList"
|
||||
<view class="padding radius bg-white list-list margin-bottom" v-for="item in hiddenDangerList"
|
||||
:key="item.hazardId">
|
||||
<view class="flex justify-between margin-bottom">
|
||||
<view class="text-bold text-black" style="word-break: break-all; flex: 1;">{{item.title}}</view>
|
||||
@@ -43,12 +43,22 @@
|
||||
class="round cu-btn bg-blue" @click="Rectification(item)">立即整改</button>
|
||||
<button v-if="item.statusName === '待验收' && item.canEdit"
|
||||
class="round cu-btn light bg-blue" @click="editRectification(item)">编辑整改信息</button>
|
||||
<button v-if="item.statusName === '待验收' && canAcceptance"
|
||||
<button v-if="canShowAcceptanceButton(item, userRole)"
|
||||
class="round cu-btn bg-blue" @click="acceptance(item)">立即验收</button>
|
||||
<button v-if="item.statusName === '待交办'"
|
||||
class="round cu-btn bg-blue" @click="assignHazard(item)">隐患交办</button>
|
||||
<button v-if="canShowWriteoffApplyButton(item)"
|
||||
class="round cu-btn bg-blue" @click="goWriteoffApply(item)">销号申请</button>
|
||||
<button v-if="canShowWriteoffApprovalButton(item, userRole)"
|
||||
class="round cu-btn bg-blue" @click="goWriteoffApproval(item)">销号审批</button>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<u-loadmore
|
||||
v-if="hiddenDangerList.length > 0"
|
||||
:status="loadStatus"
|
||||
style="margin-top: 20rpx; margin-bottom: 140rpx;"
|
||||
/>
|
||||
|
||||
<view class="fixed-add-btn" @click="goToAdd">
|
||||
<text class="cuIcon-add"></text>
|
||||
@@ -58,35 +68,42 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, computed } from 'vue'
|
||||
import { onLoad, onShow } from '@dcloudio/uni-app'
|
||||
import { ref } from 'vue'
|
||||
import { onLoad, onShow, onReachBottom } from '@dcloudio/uni-app'
|
||||
import {
|
||||
enterCheckPlan,
|
||||
getCheckTaskDetail,
|
||||
getMyHiddenDangerList
|
||||
} from '@/request/api.js'
|
||||
import {
|
||||
buildRectificationUrl,
|
||||
buildEditRectificationUrl,
|
||||
buildAssignmentUrl,
|
||||
buildAcceptanceUrl,
|
||||
buildWriteoffApplyUrl,
|
||||
buildWriteoffApprovalUrl,
|
||||
canShowAcceptanceButton,
|
||||
canShowWriteoffApplyButton,
|
||||
canShowWriteoffApprovalButton
|
||||
} from '@/utils/hazardNav.js'
|
||||
import { resolveUserRoleKey } from '@/utils/userInfo.js'
|
||||
|
||||
const taskId = ref('')
|
||||
const checkPointId = ref('')
|
||||
const oneTableId = ref('')
|
||||
|
||||
const userRole = ref('')
|
||||
const canAcceptance = computed(() => {
|
||||
return userRole.value === 'admin' || userRole.value === 'manage'
|
||||
})
|
||||
|
||||
const getUserRole = () => {
|
||||
try {
|
||||
const userInfoStr = uni.getStorageSync('userInfo')
|
||||
if (userInfoStr) {
|
||||
const userInfo = JSON.parse(userInfoStr)
|
||||
userRole.value = userInfo.role || ''
|
||||
userRole.value = resolveUserRoleKey(JSON.parse(userInfoStr))
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取用户信息失败:', error)
|
||||
}
|
||||
}
|
||||
getUserRole()
|
||||
|
||||
const fetchTaskInfo = async (oneTableId) => {
|
||||
try {
|
||||
@@ -105,19 +122,82 @@
|
||||
}
|
||||
|
||||
onLoad((options) => {
|
||||
getUserRole()
|
||||
if (options.id) {
|
||||
oneTableId.value = options.id
|
||||
fetchTaskInfo(options.id)
|
||||
}
|
||||
})
|
||||
|
||||
const HAZARD_PAGE_SIZE = 10
|
||||
const hiddenDangerList = ref([])
|
||||
const pageNum = ref(1)
|
||||
const listLoading = ref(false)
|
||||
const loadStatus = ref('loadmore')
|
||||
|
||||
const statusTabs = ref([
|
||||
{ label: '全部', value: null },
|
||||
{ label: '待交办', value: 1 },
|
||||
{ label: '待整改', value: 2 },
|
||||
{ label: '待验收', value: 3 },
|
||||
{ label: '待销号', value: 4 },
|
||||
{ label: '已完成', value: 5 }
|
||||
])
|
||||
const activeTab = ref(0)
|
||||
|
||||
const buildListParams = () => {
|
||||
const params = {
|
||||
pageNum: pageNum.value,
|
||||
pageSize: HAZARD_PAGE_SIZE
|
||||
}
|
||||
const currentTab = statusTabs.value[activeTab.value]
|
||||
if (currentTab?.value != null) {
|
||||
params.status = currentTab.value
|
||||
}
|
||||
return params
|
||||
}
|
||||
|
||||
const resetHiddenDangerList = () => {
|
||||
pageNum.value = 1
|
||||
hiddenDangerList.value = []
|
||||
loadStatus.value = 'loadmore'
|
||||
}
|
||||
|
||||
const switchStatusTab = (index) => {
|
||||
if (activeTab.value === index) return
|
||||
activeTab.value = index
|
||||
resetHiddenDangerList()
|
||||
fetchHiddenDangerList()
|
||||
}
|
||||
|
||||
const fetchHiddenDangerList = async () => {
|
||||
if (listLoading.value) return
|
||||
if (pageNum.value > 1 && loadStatus.value === 'nomore') return
|
||||
|
||||
listLoading.value = true
|
||||
if (pageNum.value > 1) {
|
||||
loadStatus.value = 'loading'
|
||||
}
|
||||
try {
|
||||
const res = await getMyHiddenDangerList()
|
||||
const res = await getMyHiddenDangerList(buildListParams())
|
||||
if (res.code === 0) {
|
||||
hiddenDangerList.value = res.data.records
|
||||
const records = res.data?.records || []
|
||||
const total = Number(res.data?.total ?? 0)
|
||||
if (pageNum.value === 1) {
|
||||
hiddenDangerList.value = records
|
||||
} else {
|
||||
hiddenDangerList.value = [...hiddenDangerList.value, ...records]
|
||||
}
|
||||
if (hiddenDangerList.value.length >= total || records.length < HAZARD_PAGE_SIZE) {
|
||||
loadStatus.value = 'nomore'
|
||||
} else {
|
||||
loadStatus.value = 'loadmore'
|
||||
}
|
||||
} else {
|
||||
if (pageNum.value === 1) {
|
||||
hiddenDangerList.value = []
|
||||
}
|
||||
loadStatus.value = 'nomore'
|
||||
uni.showToast({
|
||||
title: res.msg || '获取隐患列表失败',
|
||||
icon: 'none'
|
||||
@@ -125,15 +205,33 @@
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
if (pageNum.value > 1) {
|
||||
pageNum.value--
|
||||
}
|
||||
loadStatus.value = 'loadmore'
|
||||
uni.showToast({
|
||||
title: '请求失败',
|
||||
icon: 'none'
|
||||
})
|
||||
} finally {
|
||||
listLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
onShow(() => {
|
||||
const loadMoreHiddenDangerList = () => {
|
||||
if (loadStatus.value !== 'loadmore' || listLoading.value) return
|
||||
pageNum.value++
|
||||
fetchHiddenDangerList()
|
||||
}
|
||||
|
||||
onShow(() => {
|
||||
getUserRole()
|
||||
resetHiddenDangerList()
|
||||
fetchHiddenDangerList()
|
||||
})
|
||||
|
||||
onReachBottom(() => {
|
||||
loadMoreHiddenDangerList()
|
||||
})
|
||||
|
||||
const goToAdd = () => {
|
||||
@@ -156,59 +254,33 @@
|
||||
|
||||
const details = (item) => {
|
||||
uni.navigateTo({
|
||||
url: `/pages/hiddendanger/detail2?hazardId=${item.hazardId}&assignId=${item.assignId || ''}`
|
||||
url: `/pages/hiddendanger/process-chain?hazardId=${item.hazardId}`
|
||||
})
|
||||
}
|
||||
|
||||
const Rectification = (item) => {
|
||||
let url = `/pages/hiddendanger/rectification?hazardId=${item.hazardId}&assignId=${item.assignId}`
|
||||
if (item.deadline) {
|
||||
url += `&deadline=${encodeURIComponent(item.deadline)}`
|
||||
}
|
||||
if (item.assigneeId) {
|
||||
url += `&assigneeId=${item.assigneeId}`
|
||||
}
|
||||
if (item.assigneeName) {
|
||||
url += `&assigneeName=${encodeURIComponent(item.assigneeName)}`
|
||||
}
|
||||
uni.navigateTo({ url })
|
||||
uni.navigateTo({ url: buildRectificationUrl(item) });
|
||||
}
|
||||
|
||||
const editRectification = (item) => {
|
||||
uni.navigateTo({
|
||||
url: `/pages/hiddendanger/rectification?rectifyId=${item.rectifyId}&isEdit=1`
|
||||
})
|
||||
uni.navigateTo({ url: buildEditRectificationUrl(item) });
|
||||
}
|
||||
|
||||
const acceptance = (item) => {
|
||||
uni.navigateTo({
|
||||
url: `/pages/hiddendanger/acceptance?hazardId=${item.hazardId}&assignId=${item.assignId}&rectifyId=${item.rectifyId}`
|
||||
})
|
||||
uni.navigateTo({ url: buildAcceptanceUrl(item) });
|
||||
}
|
||||
|
||||
const assignHazard = (item) => {
|
||||
uni.navigateTo({
|
||||
url: `/pages/hiddendanger/assignment?hazardId=${item.hazardId}&assignId=${item.assignId}`
|
||||
})
|
||||
uni.navigateTo({ url: buildAssignmentUrl(item) });
|
||||
}
|
||||
|
||||
const statusTabs = ref([
|
||||
{ label: '全部', value: null },
|
||||
{ label: '待交办', value: 1 },
|
||||
{ label: '待整改', value: 2 },
|
||||
{ label: '待验收', value: 3 },
|
||||
{ label: '待销号', value: 4 },
|
||||
{ label: '已完成', value: 5 }
|
||||
])
|
||||
const activeTab = ref(0)
|
||||
const goWriteoffApply = (item) => {
|
||||
uni.navigateTo({ url: buildWriteoffApplyUrl(item) });
|
||||
}
|
||||
|
||||
const filteredList = computed(() => {
|
||||
const currentTab = statusTabs.value[activeTab.value]
|
||||
if (!currentTab || currentTab.value === null) {
|
||||
return hiddenDangerList.value
|
||||
}
|
||||
return hiddenDangerList.value.filter(item => item.status === currentTab.value)
|
||||
})
|
||||
const goWriteoffApproval = (item) => {
|
||||
uni.navigateTo({ url: buildWriteoffApprovalUrl(item) });
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
1339
pages/hiddendanger/acceptance-approval.vue
Normal file
1339
pages/hiddendanger/acceptance-approval.vue
Normal file
File diff suppressed because it is too large
Load Diff
312
pages/hiddendanger/acceptance-逻辑说明.md
Normal file
312
pages/hiddendanger/acceptance-逻辑说明.md
Normal file
@@ -0,0 +1,312 @@
|
||||
# 隐患验收页逻辑说明
|
||||
|
||||
> 对应文件:`pages/hiddendanger/acceptance.vue`
|
||||
> 最后整理:2026-07-15
|
||||
|
||||
---
|
||||
|
||||
## 1. 页面职责
|
||||
|
||||
验收页用于对**已提交的整改记录**进行验收,主要能力:
|
||||
|
||||
1. 只读展示整改记录(方案、措施、人员、附件等)
|
||||
2. 填写验收表单(结果、备注、验收附件、签名)
|
||||
3. 根据验收选择**预览下一步流程**
|
||||
4. 选择或通过只读展示**下一步处理人**
|
||||
5. 提交到 `POST /frontend/hazard/verify`
|
||||
|
||||
---
|
||||
|
||||
## 2. 页面入参(URL Query)
|
||||
|
||||
从首页 / 巡检列表跳转,由 `utils/hazardNav.js` → `buildAcceptanceUrl` 构建:
|
||||
|
||||
| 参数 | 是否必需 | 说明 |
|
||||
|------|----------|------|
|
||||
| `rectifyId` | **推荐必带** | 整改记录 ID,有则只调整改详情接口 |
|
||||
| `hazardId` | 列表通常会带 | 隐患 ID,无 `rectifyId` 时用于兜底拉取 |
|
||||
| `assignId` | 可选 | 指派 ID,用于从隐患详情中定位正确 assign |
|
||||
| `taskId` | **流程预览依赖** | 工作流任务 ID,用于「下一步流程」接口 |
|
||||
|
||||
示例:
|
||||
|
||||
```
|
||||
/pages/hiddendanger/acceptance?hazardId=184&assignId=158&rectifyId=150&taskId=xxx
|
||||
```
|
||||
|
||||
> **注意**:`rectify/detail` 响应里通常**没有** `taskId`,下一步流程主要依赖 URL 传入的 `taskId`。若列表未带且详情也解析不到,「下一步流程」会显示「暂无下一步流程」。
|
||||
|
||||
---
|
||||
|
||||
## 3. 页面加载流程
|
||||
|
||||
```
|
||||
onLoad
|
||||
├─ 解析 URL 参数(rectifyId / hazardId / assignId / taskId)
|
||||
├─ loadPageData()
|
||||
│ ├─ 有 rectifyId → fetchRectifyDetail() // 只调一次
|
||||
│ ├─ 无 rectifyId、有 hazardId → fetchDetail()
|
||||
│ └─ fetchNextStep()
|
||||
└─ restoreDraft() // 恢复本地草稿(若有)
|
||||
```
|
||||
|
||||
### 3.1 数据接口选择(重要)
|
||||
|
||||
**不要两个详情接口都调**,当前规则:
|
||||
|
||||
| 条件 | 调用接口 | 说明 |
|
||||
|------|----------|------|
|
||||
| 有 `rectifyId` | `GET /frontend/hazard/rectify/detail` | **唯一数据源** |
|
||||
| 无 `rectifyId`、有 `hazardId` | `GET /frontend/hazard/detail` | 从 `assigns[].rectify` 取整改记录 |
|
||||
|
||||
### 3.2 两个详情接口的区别
|
||||
|
||||
| 对比项 | `rectify/detail` | `hazard/detail` 内嵌 `rectify` |
|
||||
|--------|------------------|-------------------------------|
|
||||
| 数据范围 | 单条整改记录 | 整条隐患 + 指派 + 整改 |
|
||||
| 人员结构 | `members` / `managers` 对象数组 | `memberNames` / `managerNames` 字符串数组 |
|
||||
| 整改人 | 有 `rectifierName` | 有 `rectifierName` |
|
||||
| 状态字段 | `statusName` | `rectifyStatusName` |
|
||||
| 适用场景 | 有 `rectifyId` 时优先 | 仅无 `rectifyId` 时兜底 |
|
||||
|
||||
---
|
||||
|
||||
## 4. 整改记录字段映射(`applyRectifyData`)
|
||||
|
||||
接口返回结构不统一,统一在 `applyRectifyData` 中做映射:
|
||||
|
||||
| 页面展示字段 | 映射规则 |
|
||||
|--------------|----------|
|
||||
| 整改方案/措施/管控/完成情况/费用 | 同名字段直取 |
|
||||
| 安全管理人员 | 有 `managers[]` → 取 `nickName` 去重;否则用 `managerNames` |
|
||||
| 整改责任人 | 有 `members[]` → 取 `nickName` 去重;否则用 `memberNames` |
|
||||
| 完成情况 | `rectifyStatusName` 或 `statusName` |
|
||||
| 整改附件 | `attachments` |
|
||||
| 整改人(不通过时展示) | `rectifierName` |
|
||||
|
||||
### 人员名显示规则(易踩坑)
|
||||
|
||||
`rectify/detail` **同时可能返回**:
|
||||
|
||||
- `memberNames` / `managerNames`(身份名,如:阎勇、user1)
|
||||
- `members` / `managers`(对象,含 `nickName`,如:xiaomi、duoduo)
|
||||
|
||||
**当前规则:有 `members` / `managers` 数组时,优先用其中的 `nickName`,不用 `memberNames`。**
|
||||
|
||||
---
|
||||
|
||||
## 5. 验收表单交互
|
||||
|
||||
### 5.1 验收结果 `formData.result`
|
||||
|
||||
| 值 | 含义 |
|
||||
|----|------|
|
||||
| `1` | 通过(默认) |
|
||||
| `2` | 不通过 |
|
||||
|
||||
切换时触发 `onResultChange` → 重新请求下一步流程 `fetchNextStep()`。
|
||||
|
||||
- 切到「不通过」:清空已选下一步处理人
|
||||
- 切到「通过」:若未选快速审批,默认 `quickApproveRadio = 'yes'`
|
||||
|
||||
### 5.2 是否快速审批 `formData.quickApproveRadio`
|
||||
|
||||
- **仅验收通过时显示**,必选
|
||||
- `yes` = 快速审批;`no` = 不快速审批
|
||||
- 切换时触发 `onQuickApproveChange` → `fetchNextStep()`
|
||||
|
||||
### 5.3 下一步流程(只读预览)
|
||||
|
||||
接口:`POST /flow/task/next-nodes`
|
||||
|
||||
**三种情况都必须传:**
|
||||
|
||||
```json
|
||||
{
|
||||
"taskId": "当前任务ID",
|
||||
"includeSubProcess": true,
|
||||
"previewVariables": { ... }
|
||||
}
|
||||
```
|
||||
|
||||
`previewVariables` 按验收选择变化:
|
||||
|
||||
| 场景 | previewVariables |
|
||||
|------|------------------|
|
||||
| 不通过 | `{ "pass": false }` |
|
||||
| 通过 + 快速审批 | `{ "pass": true, "quickApprove": true }` |
|
||||
| 通过 + 不快速审批 | `{ "pass": true, "quickApprove": false }` |
|
||||
|
||||
展示逻辑:取返回 `branches` 中 `matched === true` 的分支(没有则取第一个)的 `nextNode.taskName`。
|
||||
|
||||
### 5.4 下一步处理人
|
||||
|
||||
| 验收结果 | UI | 数据来源 |
|
||||
|----------|-----|----------|
|
||||
| 不通过 | 只读文本 | `rectify/detail` 的 **`rectifierName`**(整改人) |
|
||||
| 通过 | 底部弹窗单选 | `GET /admin/user/dept/users/{deptId}` |
|
||||
|
||||
通过时选人说明:
|
||||
|
||||
- `deptId` 来自本地 `userInfo.userIdentity.deptId`(无则取 `userInfo.deptId`)
|
||||
- 部门人员接口返回 `{ userId, nickName }`,可能没有 `identityId`
|
||||
- 选人 ID 解析:`identityId` → `userIdentityId` → `userId`(兜底)
|
||||
- 提交字段名是 `assigneeIdentityId`,无 `identityId` 时实际传的是 `userId`
|
||||
|
||||
### 5.5 电子签名
|
||||
|
||||
- 必填,提交前先上传云端得到 `signPath`
|
||||
- 打开「选择下一步处理人」弹窗时,**卸载签名 Canvas**(`v-if="showCanvas && !showAssigneePopup"`),避免微信小程序原生 canvas 层级穿透盖住弹窗
|
||||
|
||||
### 5.6 验收图片/视频
|
||||
|
||||
- 使用 `up-upload` + 水印 canvas
|
||||
- 提交时只取 `status === 'success'` 的文件,经 `buildAttachmentItem` 转成附件对象
|
||||
|
||||
---
|
||||
|
||||
## 6. 提交验收
|
||||
|
||||
接口:`POST /frontend/hazard/verify`(`acceptanceRectification`)
|
||||
|
||||
### 6.1 提交前校验
|
||||
|
||||
1. 必须有 `rectifyId`
|
||||
2. 通过时:必须选「是否快速审批」
|
||||
3. 通过 + 不快速审批:必须选下一步处理人
|
||||
4. 必须有电子签名
|
||||
|
||||
### 6.2 请求体
|
||||
|
||||
**通用字段(通过/不通过都传):**
|
||||
|
||||
| 字段 | 类型 | 说明 |
|
||||
|------|------|------|
|
||||
| `rectifyId` | number | 整改记录 ID |
|
||||
| `result` | number | `1` 通过 / `2` 不通过 |
|
||||
| `verifyRemark` | string | 验收备注,可为空 |
|
||||
| `attachments` | array | 验收附件 `[{ fileName, filePath, fileType, fileSize }]` |
|
||||
| `signPath` | string | 电子签名服务器路径 |
|
||||
|
||||
**仅通过时额外传:**
|
||||
|
||||
| 字段 | 条件 | 说明 |
|
||||
|------|------|------|
|
||||
| `quickApprove` | `result === 1` | boolean |
|
||||
| `assigneeIdentityId` | `quickApprove === false` | 下一步处理人 ID |
|
||||
|
||||
**不提交的内容:**
|
||||
|
||||
- 整改记录只读区所有字段
|
||||
- 下一步流程名称(仅预览)
|
||||
- 不通过时的 `rectifierName`(仅展示,后端按流程自行处理)
|
||||
- 快速审批为「是」时的下一步处理人
|
||||
|
||||
### 6.3 提交示例
|
||||
|
||||
**不通过:**
|
||||
```json
|
||||
{
|
||||
"rectifyId": 150,
|
||||
"result": 2,
|
||||
"verifyRemark": "整改不到位",
|
||||
"attachments": [],
|
||||
"signPath": "https://oss.../sign.png"
|
||||
}
|
||||
```
|
||||
|
||||
**通过 + 快速审批:**
|
||||
```json
|
||||
{
|
||||
"rectifyId": 150,
|
||||
"result": 1,
|
||||
"verifyRemark": "",
|
||||
"attachments": [],
|
||||
"signPath": "https://oss.../sign.png",
|
||||
"quickApprove": true
|
||||
}
|
||||
```
|
||||
|
||||
**通过 + 不快速审批:**
|
||||
```json
|
||||
{
|
||||
"rectifyId": 150,
|
||||
"result": 1,
|
||||
"verifyRemark": "",
|
||||
"attachments": [],
|
||||
"signPath": "https://oss.../sign.png",
|
||||
"quickApprove": false,
|
||||
"assigneeIdentityId": "44"
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 7. 草稿缓存
|
||||
|
||||
使用 `useDraftCache`,命名空间 `DRAFT_NS.ACCEPT`,key 基于 `rectifyId`。
|
||||
|
||||
**会缓存:**
|
||||
|
||||
- 验收结果、备注、快速审批选择
|
||||
- 下一步处理人选择
|
||||
- 验收上传附件列表
|
||||
- 签名相关状态
|
||||
|
||||
**不会缓存:**
|
||||
|
||||
- 整改记录只读区(每次进页重新拉接口)
|
||||
|
||||
恢复草稿后会再次调用 `fetchNextStep()`,保证下一步流程与当前验收选择一致。
|
||||
|
||||
---
|
||||
|
||||
## 8. 关键函数索引
|
||||
|
||||
| 函数 | 作用 |
|
||||
|------|------|
|
||||
| `loadPageData` | 页面数据加载入口 |
|
||||
| `fetchRectifyDetail` | 调整改详情,有 `rectifyId` 时用 |
|
||||
| `fetchDetail` | 调隐患详情,无 `rectifyId` 时兜底 |
|
||||
| `applyRectifyData` | 统一映射整改记录到页面 |
|
||||
| `resolveManagerNames` / `resolveMemberNames` | 人员名映射(优先 members/managers 的 nickName) |
|
||||
| `buildPreviewVariables` | 构建下一步流程预览变量 |
|
||||
| `fetchNextStep` | 请求下一步流程名称 |
|
||||
| `onResultChange` / `onQuickApproveChange` | 切换验收选项后刷新流程预览 |
|
||||
| `openAssigneePopup` / `fetchAssigneeList` | 通过时选择下一步处理人 |
|
||||
| `validateFormBeforeSubmit` | 提交前表单校验 |
|
||||
| `handleSubmit` / `executeSubmit` | 签名处理 + 提交验收 |
|
||||
|
||||
---
|
||||
|
||||
## 9. 关联文件
|
||||
|
||||
| 文件 | 关系 |
|
||||
|------|------|
|
||||
| `utils/hazardNav.js` | 构建跳转 URL(含 taskId) |
|
||||
| `request/api.js` | 接口定义 |
|
||||
| `utils/upload.js` | 附件上传与 `buildAttachmentItem` |
|
||||
| `utils/draftCache.js` / `utils/useDraftCache.js` | 草稿 |
|
||||
| `pages/hiddendanger/rectification.vue` | 签名 canvas 穿透弹窗的同类处理参考 |
|
||||
|
||||
---
|
||||
|
||||
## 10. 常见问题速查
|
||||
|
||||
| 现象 | 可能原因 |
|
||||
|------|----------|
|
||||
| 下一步流程显示「暂无」 | URL 未带 `taskId`,且详情接口也解析不到 |
|
||||
| 人员显示身份名而非 nickName | `members` 数组为空,走了 `memberNames` 兜底 |
|
||||
| 不通过时处理人不对 | 应检查 `rectify/detail` 的 `rectifierName` 是否有值 |
|
||||
| 选人弹窗被白块挡住 | 签名 canvas 未在弹窗打开时卸载 |
|
||||
| 选人列表为空 | `userInfo.userIdentity.deptId` 缺失,或部门无人员 |
|
||||
| 提交了但后端报处理人错误 | `assigneeIdentityId` 传的是 `userId`,需确认后端是否接受 |
|
||||
|
||||
---
|
||||
|
||||
## 11. 维护建议
|
||||
|
||||
1. **有 `rectifyId` 就不要再调 `hazard/detail` 做展示**,避免重复请求和数据覆盖混乱。
|
||||
2. 改人员展示逻辑时,优先看 `resolveManagerNames` / `resolveMemberNames`,不要直接改模板。
|
||||
3. 改流程预览时,确认 `taskId`、`previewVariables`、`includeSubProcess: true` 三者始终齐全。
|
||||
4. 新增提交字段时,同步更新本文档第 6 节。
|
||||
@@ -52,8 +52,8 @@
|
||||
<view class="text-red">*</view>
|
||||
</view>
|
||||
<view class="flex" style="gap: 20rpx;">
|
||||
<button :class="['result-btn', formData.result === 1 ? 'active' : '']" @click="formData.result = 1">通过</button>
|
||||
<button :class="['result-btn', formData.result === 2 ? 'active' : '']" @click="formData.result = 2">不通过</button>
|
||||
<button :class="['result-btn', formData.result === 1 ? 'active' : '']" @click="onResultChange(1)">通过</button>
|
||||
<button :class="['result-btn', formData.result === 2 ? 'active' : '']" @click="onResultChange(2)">不通过</button>
|
||||
</view>
|
||||
<view class="flex margin-bottom margin-top">
|
||||
<view class="text-gray">验收备注</view>
|
||||
@@ -63,6 +63,15 @@
|
||||
<view class="text-gray">验收图片/视频</view>
|
||||
</view>
|
||||
<up-upload :fileList="fileList1" @afterRead="afterRead" @delete="deletePic" name="1" multiple imageMode="aspectFill" :maxCount="10"></up-upload>
|
||||
|
||||
<view v-if="formData.result === 1" class="flex margin-bottom margin-top">
|
||||
<view class="text-gray">是否快速审批</view>
|
||||
<view class="text-red">*</view>
|
||||
</view>
|
||||
<view v-if="formData.result === 1" class="flex" style="gap: 20rpx;">
|
||||
<button :class="['result-btn', formData.quickApproveRadio === 'yes' ? 'active' : '']" @click="onQuickApproveChange('yes')">是</button>
|
||||
<button :class="['result-btn', formData.quickApproveRadio === 'no' ? 'active' : '']" @click="onQuickApproveChange('no')">否</button>
|
||||
</view>
|
||||
|
||||
<!-- 隐藏的 Canvas,用于渲染防作弊时间戳水印 -->
|
||||
<canvas canvas-id="watermarkCanvas" :width="canvasWidth" :height="canvasHeight" :style="{ width: canvasWidth + 'px', height: canvasHeight + 'px', position: 'fixed', left: '-9999px', top: '-9999px' }"></canvas>
|
||||
@@ -71,13 +80,48 @@
|
||||
<view class="text-gray">下一步流程</view>
|
||||
<view class="text-red">*</view>
|
||||
</view>
|
||||
<view class="static-field">申请隐患销号</view>
|
||||
<view class="static-field">{{ nextStepDisplay }}</view>
|
||||
|
||||
<view class="flex margin-bottom margin-top">
|
||||
<view class="text-gray">下一步处理人</view>
|
||||
<view class="text-red">*</view>
|
||||
</view>
|
||||
<view class="static-field">部门、企业管理员</view>
|
||||
<view v-if="formData.result === 2" class="static-field">{{ rectifierDisplayName }}</view>
|
||||
<view v-else class="select-trigger" @click="openAssigneePopup">
|
||||
<view class="select-content" :class="{ 'text-gray': !selectedAssigneeName }">
|
||||
{{ selectedAssigneeName || '请选择下一步处理人' }}
|
||||
</view>
|
||||
<text class="cuIcon-unfold"></text>
|
||||
</view>
|
||||
|
||||
<u-popup :show="showAssigneePopup" mode="bottom" round="20" @close="cancelAssigneeSelect">
|
||||
<view class="user-popup">
|
||||
<view class="popup-header">
|
||||
<view class="popup-title text-bold">选择下一步处理人</view>
|
||||
<view class="popup-close" @click="cancelAssigneeSelect">×</view>
|
||||
</view>
|
||||
<scroll-view class="user-list-scroll" scroll-y>
|
||||
<view v-if="assigneeLoading" class="empty-tip">加载中...</view>
|
||||
<view v-else-if="assigneeList.length === 0" class="empty-tip">暂无人员数据</view>
|
||||
<template v-else>
|
||||
<view
|
||||
v-for="user in assigneeList"
|
||||
:key="getAssigneeItemKey(user)"
|
||||
class="user-item"
|
||||
:class="{ active: String(pickerAssigneeIdentityId) === String(resolveAssigneeIdentityId(user)) }"
|
||||
@click="onAssigneeItemClick(user)"
|
||||
>
|
||||
<text class="user-item-text">{{ formatAssigneeDisplayName(user) }}</text>
|
||||
<text v-if="String(pickerAssigneeIdentityId) === String(resolveAssigneeIdentityId(user))" class="cuIcon-check text-blue"></text>
|
||||
</view>
|
||||
</template>
|
||||
</scroll-view>
|
||||
<view class="popup-footer">
|
||||
<button class="btn-cancel" @click="cancelAssigneeSelect">取消</button>
|
||||
<button class="btn-confirm bg-blue" @click="confirmAssigneeSelect">确定</button>
|
||||
</view>
|
||||
</view>
|
||||
</u-popup>
|
||||
|
||||
<!-- 短信提醒(暂不使用)
|
||||
<view class="flex margin-bottom margin-top">
|
||||
@@ -115,7 +159,8 @@
|
||||
<text v-else class="signature-placeholder">暂无签名,请点击重新签名</text>
|
||||
</view>
|
||||
<!-- 改为 v-if 解决小程序原生 canvas 真机渲染与生命周期挂载残留问题 -->
|
||||
<view v-if="showCanvas" class="signature-pad-wrap" style="border: 1px dashed #dcdfe6; border-radius: 8rpx; overflow: hidden; background-color: #f8f8f8;">
|
||||
<!-- 弹窗打开时卸载 Canvas,解决微信原生 canvas 真机穿透盖住弹层的问题 -->
|
||||
<view v-if="showCanvas && !showAssigneePopup" class="signature-pad-wrap" style="border: 1px dashed #dcdfe6; border-radius: 8rpx; overflow: hidden; background-color: #f8f8f8;">
|
||||
<wd-signature
|
||||
ref="signatureRef"
|
||||
:width="signatureWidth"
|
||||
@@ -144,9 +189,9 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, reactive, nextTick, getCurrentInstance } from 'vue';
|
||||
import { ref, reactive, computed, nextTick, getCurrentInstance } from 'vue';
|
||||
import { onLoad, onHide } from '@dcloudio/uni-app';
|
||||
import { acceptanceRectification, getHiddenDangerDetail } from '@/request/api.js';
|
||||
import { acceptanceRectification, getHiddenDangerDetail, getRectifyDetail, getFlowNextNodes, getDeptUsers } from '@/request/api.js';
|
||||
import { toImageUrl } from '@/request/request.js';
|
||||
import { buildDraftKey, buildDraftKeyCompact, DRAFT_NS } from '@/utils/draftCache.js';
|
||||
import { useDraftCache } from '@/utils/useDraftCache.js';
|
||||
@@ -161,6 +206,228 @@
|
||||
const rectifyId = ref('');
|
||||
const hazardId = ref('');
|
||||
const assignId = ref('');
|
||||
const taskId = ref('');
|
||||
|
||||
// 下一步流程
|
||||
const nextStepName = ref('');
|
||||
const nextStepLoading = ref(false);
|
||||
|
||||
const nextStepDisplay = computed(() => {
|
||||
if (nextStepLoading.value) return '加载中...';
|
||||
return nextStepName.value || '暂无下一步流程';
|
||||
});
|
||||
|
||||
const resolveTaskIdFromAssign = (assign) => {
|
||||
if (!assign) return '';
|
||||
if (assign.taskId) return String(assign.taskId);
|
||||
if (assign.flowTaskId) return String(assign.flowTaskId);
|
||||
if (assign.currentTaskId) return String(assign.currentTaskId);
|
||||
return '';
|
||||
};
|
||||
|
||||
// 从 assigns 中找到包含整改记录的那一项
|
||||
const resolveAssignWithRectify = (assigns) => {
|
||||
if (!assigns?.length) return null;
|
||||
if (rectifyId.value) {
|
||||
const byRectifyId = assigns.find(
|
||||
(item) => item.rectify && String(item.rectify.rectifyId) === String(rectifyId.value)
|
||||
);
|
||||
if (byRectifyId) return byRectifyId;
|
||||
}
|
||||
if (assignId.value) {
|
||||
const byAssignId = assigns.find(
|
||||
(item) => String(item.assignId) === String(assignId.value) && item.rectify
|
||||
);
|
||||
if (byAssignId) return byAssignId;
|
||||
}
|
||||
return assigns.find((item) => item.rectify) || null;
|
||||
};
|
||||
|
||||
const resolveTaskIdFromDetail = (data) => {
|
||||
if (!data) return '';
|
||||
if (data.taskId) return String(data.taskId);
|
||||
if (data.flowTaskId) return String(data.flowTaskId);
|
||||
if (data.currentTaskId) return String(data.currentTaskId);
|
||||
|
||||
const assigns = data.assigns || [];
|
||||
const matchedAssign = resolveAssignWithRectify(assigns);
|
||||
const fromMatched = resolveTaskIdFromAssign(matchedAssign);
|
||||
if (fromMatched) return fromMatched;
|
||||
|
||||
for (const assign of assigns) {
|
||||
const id = resolveTaskIdFromAssign(assign);
|
||||
if (id) return id;
|
||||
}
|
||||
return '';
|
||||
};
|
||||
|
||||
const resolveNextTaskName = (data) => {
|
||||
if (!data) return '';
|
||||
const branches = data.branches || [];
|
||||
const matchedBranch = branches.find((item) => item.matched) || branches[0];
|
||||
return matchedBranch?.nextNode?.taskName || '';
|
||||
};
|
||||
|
||||
const buildPreviewVariables = () => {
|
||||
if (formData.result === 2) {
|
||||
return { pass: false };
|
||||
}
|
||||
return {
|
||||
pass: true,
|
||||
quickApprove: formData.quickApproveRadio === 'yes'
|
||||
};
|
||||
};
|
||||
|
||||
const getStoredUserInfo = () => {
|
||||
try {
|
||||
const stored = uni.getStorageSync('userInfo');
|
||||
if (!stored) return {};
|
||||
return typeof stored === 'string' ? JSON.parse(stored) : stored;
|
||||
} catch (error) {
|
||||
return {};
|
||||
}
|
||||
};
|
||||
|
||||
const getCurrentDeptId = () => {
|
||||
const userInfo = getStoredUserInfo();
|
||||
const identity = userInfo.userIdentity;
|
||||
if (identity?.deptId != null && identity.deptId !== '') {
|
||||
return String(identity.deptId);
|
||||
}
|
||||
if (userInfo.deptId != null && userInfo.deptId !== '') {
|
||||
return String(userInfo.deptId);
|
||||
}
|
||||
return '';
|
||||
};
|
||||
|
||||
const rectifierDisplayName = computed(() => rectifyData.rectifierName?.trim() || '暂无');
|
||||
|
||||
const selectedAssigneeIdentityId = ref('');
|
||||
const selectedAssigneeName = ref('');
|
||||
const pickerAssigneeIdentityId = ref('');
|
||||
const pickerAssigneeName = ref('');
|
||||
const showAssigneePopup = ref(false);
|
||||
const assigneeList = ref([]);
|
||||
const assigneeLoading = ref(false);
|
||||
|
||||
const resolveAssigneeIdentityId = (user) => {
|
||||
if (!user) return '';
|
||||
const id = user.identityId ?? user.userIdentityId ?? user.userId ?? '';
|
||||
return id === '' || id == null ? '' : String(id);
|
||||
};
|
||||
|
||||
const getAssigneeItemKey = (user) => {
|
||||
const identityId = resolveAssigneeIdentityId(user);
|
||||
if (identityId) return `identity-${identityId}`;
|
||||
return `user-${user.userId || user.nickName || ''}`;
|
||||
};
|
||||
|
||||
const formatAssigneeDisplayName = (user) => {
|
||||
if (!user) return '';
|
||||
const name = user.nickName || user.userName || user.name || '';
|
||||
const identityName = user.identityName || '';
|
||||
if (name && identityName) return `${name}(${identityName})`;
|
||||
return name || identityName || '未知人员';
|
||||
};
|
||||
|
||||
const resolveAssigneeDeptUserType = () => (
|
||||
formData.quickApproveRadio === 'yes' ? 2 : 3
|
||||
);
|
||||
|
||||
const fetchAssigneeList = async () => {
|
||||
const deptId = getCurrentDeptId();
|
||||
if (!deptId) {
|
||||
assigneeList.value = [];
|
||||
return;
|
||||
}
|
||||
assigneeLoading.value = true;
|
||||
try {
|
||||
const res = await getDeptUsers(deptId, { type: resolveAssigneeDeptUserType() });
|
||||
if (res.code === 0) {
|
||||
assigneeList.value = res.data || [];
|
||||
} else {
|
||||
assigneeList.value = [];
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取部门人员失败:', error);
|
||||
assigneeList.value = [];
|
||||
} finally {
|
||||
assigneeLoading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
const openAssigneePopup = async () => {
|
||||
pickerAssigneeIdentityId.value = selectedAssigneeIdentityId.value;
|
||||
pickerAssigneeName.value = selectedAssigneeName.value;
|
||||
showAssigneePopup.value = true;
|
||||
await fetchAssigneeList();
|
||||
};
|
||||
|
||||
const onAssigneeItemClick = (user) => {
|
||||
const identityId = resolveAssigneeIdentityId(user);
|
||||
if (!identityId) return;
|
||||
pickerAssigneeIdentityId.value = String(identityId);
|
||||
pickerAssigneeName.value = formatAssigneeDisplayName(user);
|
||||
};
|
||||
|
||||
const confirmAssigneeSelect = () => {
|
||||
if (!pickerAssigneeIdentityId.value) {
|
||||
uni.showToast({ title: '请选择下一步处理人', icon: 'none' });
|
||||
return;
|
||||
}
|
||||
selectedAssigneeIdentityId.value = pickerAssigneeIdentityId.value;
|
||||
selectedAssigneeName.value = pickerAssigneeName.value;
|
||||
showAssigneePopup.value = false;
|
||||
};
|
||||
|
||||
const cancelAssigneeSelect = () => {
|
||||
showAssigneePopup.value = false;
|
||||
};
|
||||
|
||||
const onResultChange = (result) => {
|
||||
formData.result = result;
|
||||
if (result === 2) {
|
||||
selectedAssigneeIdentityId.value = '';
|
||||
selectedAssigneeName.value = '';
|
||||
} else if (!formData.quickApproveRadio) {
|
||||
formData.quickApproveRadio = 'yes';
|
||||
}
|
||||
fetchNextStep();
|
||||
};
|
||||
|
||||
const onQuickApproveChange = (value) => {
|
||||
formData.quickApproveRadio = value;
|
||||
selectedAssigneeIdentityId.value = '';
|
||||
selectedAssigneeName.value = '';
|
||||
fetchNextStep();
|
||||
};
|
||||
|
||||
const fetchNextStep = async () => {
|
||||
nextStepLoading.value = true;
|
||||
try {
|
||||
const currentTaskId = taskId.value;
|
||||
if (!currentTaskId) {
|
||||
nextStepName.value = '';
|
||||
return;
|
||||
}
|
||||
const res = await getFlowNextNodes({
|
||||
taskId: currentTaskId,
|
||||
previewVariables: buildPreviewVariables(),
|
||||
includeSubProcess: true
|
||||
});
|
||||
if (res.code === 0) {
|
||||
const payload = res.data && typeof res.data === 'object' ? res.data : res;
|
||||
nextStepName.value = resolveNextTaskName(payload);
|
||||
} else {
|
||||
nextStepName.value = '';
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取下一步流程失败:', error);
|
||||
nextStepName.value = '';
|
||||
} finally {
|
||||
nextStepLoading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
// 整改记录数据
|
||||
const rectifyData = reactive({
|
||||
@@ -172,6 +439,7 @@
|
||||
actualCost: null,
|
||||
managerNames: [],
|
||||
memberNames: [],
|
||||
rectifierName: '',
|
||||
rectifyStatusName: ''
|
||||
});
|
||||
|
||||
@@ -204,7 +472,8 @@
|
||||
// 表单数据
|
||||
const formData = reactive({
|
||||
result: 1, // 验收结果 1.通过 2.不通过
|
||||
verifyRemark: '' // 验收备注
|
||||
verifyRemark: '', // 验收备注
|
||||
quickApproveRadio: 'yes' // 是否快速审批 yes/no,仅通过时有效
|
||||
});
|
||||
|
||||
const fileList1 = ref([]);
|
||||
@@ -285,8 +554,11 @@
|
||||
getPayload: () => ({
|
||||
formData: {
|
||||
result: formData.result,
|
||||
verifyRemark: formData.verifyRemark
|
||||
verifyRemark: formData.verifyRemark,
|
||||
quickApproveRadio: formData.quickApproveRadio
|
||||
},
|
||||
selectedAssigneeIdentityId: selectedAssigneeIdentityId.value,
|
||||
selectedAssigneeName: selectedAssigneeName.value,
|
||||
fileList1: fileList1.value,
|
||||
signatureServerPath: signatureServerPath.value,
|
||||
signatureUrl: signatureUrl.value,
|
||||
@@ -300,6 +572,9 @@
|
||||
const form = data.formData || {};
|
||||
formData.result = form.result !== undefined ? form.result : 1;
|
||||
formData.verifyRemark = form.verifyRemark || '';
|
||||
formData.quickApproveRadio = form.quickApproveRadio === 'no' ? 'no' : 'yes';
|
||||
selectedAssigneeIdentityId.value = data.selectedAssigneeIdentityId || '';
|
||||
selectedAssigneeName.value = data.selectedAssigneeName || '';
|
||||
fileList1.value = data.fileList1 || [];
|
||||
signaturePaths.value = data.signaturePaths || [];
|
||||
if (data.signatureServerPath || data.signatureUrl) {
|
||||
@@ -318,6 +593,9 @@
|
||||
clearForm: () => {
|
||||
formData.result = 1;
|
||||
formData.verifyRemark = '';
|
||||
formData.quickApproveRadio = 'yes';
|
||||
selectedAssigneeIdentityId.value = '';
|
||||
selectedAssigneeName.value = '';
|
||||
fileList1.value = [];
|
||||
signatureServerPath.value = '';
|
||||
signatureUrl.value = '';
|
||||
@@ -332,6 +610,7 @@
|
||||
canSave: () => !!rectifyId.value,
|
||||
requireInitialized: true,
|
||||
onAfterRestore: (data) => {
|
||||
fetchNextStep();
|
||||
if (data.signatureServerPath || data.signatureUrl || data.signatureLocalPath) {
|
||||
return;
|
||||
}
|
||||
@@ -348,6 +627,9 @@
|
||||
bindAutoSave(() => [
|
||||
formData.result,
|
||||
formData.verifyRemark,
|
||||
formData.quickApproveRadio,
|
||||
selectedAssigneeIdentityId.value,
|
||||
selectedAssigneeName.value,
|
||||
fileList1.value,
|
||||
signatureServerPath.value,
|
||||
signatureUrl.value,
|
||||
@@ -375,22 +657,26 @@
|
||||
});
|
||||
};
|
||||
|
||||
// 从 assigns 中找到包含整改记录的那一项
|
||||
const resolveAssignWithRectify = (assigns) => {
|
||||
if (!assigns?.length) return null;
|
||||
if (rectifyId.value) {
|
||||
const byRectifyId = assigns.find(
|
||||
(item) => item.rectify && String(item.rectify.rectifyId) === String(rectifyId.value)
|
||||
);
|
||||
if (byRectifyId) return byRectifyId;
|
||||
const mapPersonListToNickNames = (people) => {
|
||||
if (!Array.isArray(people) || people.length === 0) return [];
|
||||
const names = people
|
||||
.map((person) => person.nickName || person.userName || person.name || '')
|
||||
.filter(Boolean);
|
||||
return [...new Set(names)];
|
||||
};
|
||||
|
||||
const resolveManagerNames = (rectify) => {
|
||||
if (Array.isArray(rectify.managers) && rectify.managers.length > 0) {
|
||||
return mapPersonListToNickNames(rectify.managers);
|
||||
}
|
||||
if (assignId.value) {
|
||||
const byAssignId = assigns.find(
|
||||
(item) => String(item.assignId) === String(assignId.value) && item.rectify
|
||||
);
|
||||
if (byAssignId) return byAssignId;
|
||||
return rectify.managerNames || [];
|
||||
};
|
||||
|
||||
const resolveMemberNames = (rectify) => {
|
||||
if (Array.isArray(rectify.members) && rectify.members.length > 0) {
|
||||
return mapPersonListToNickNames(rectify.members);
|
||||
}
|
||||
return assigns.find((item) => item.rectify) || null;
|
||||
return rectify.memberNames || [];
|
||||
};
|
||||
|
||||
const applyRectifyData = (rectify) => {
|
||||
@@ -401,13 +687,41 @@
|
||||
rectifyData.rectifyResult = rectify.rectifyResult || '';
|
||||
rectifyData.planCost = rectify.planCost ?? null;
|
||||
rectifyData.actualCost = rectify.actualCost ?? null;
|
||||
rectifyData.managerNames = rectify.managerNames || [];
|
||||
rectifyData.memberNames = rectify.memberNames || [];
|
||||
rectifyData.rectifyStatusName = rectify.rectifyStatusName || '';
|
||||
rectifyData.managerNames = resolveManagerNames(rectify);
|
||||
rectifyData.memberNames = resolveMemberNames(rectify);
|
||||
rectifyData.rectifierName = rectify.rectifierName || '';
|
||||
rectifyData.rectifyStatusName = rectify.rectifyStatusName || rectify.statusName || '';
|
||||
rectifyAttachments.value = rectify.attachments || [];
|
||||
};
|
||||
|
||||
// 获取隐患详情
|
||||
// 获取整改详情(有 rectifyId 时作为唯一数据源)
|
||||
const fetchRectifyDetail = async () => {
|
||||
if (!rectifyId.value) return;
|
||||
|
||||
try {
|
||||
const res = await getRectifyDetail({ rectifyId: rectifyId.value });
|
||||
if (res.code === 0 && res.data) {
|
||||
applyRectifyData(res.data);
|
||||
if (!hazardId.value && res.data.hazardId) {
|
||||
hazardId.value = String(res.data.hazardId);
|
||||
}
|
||||
if (!assignId.value && res.data.assignId) {
|
||||
assignId.value = String(res.data.assignId);
|
||||
}
|
||||
const resolvedTaskId = resolveTaskIdFromDetail(res.data);
|
||||
if (resolvedTaskId) {
|
||||
taskId.value = resolvedTaskId;
|
||||
}
|
||||
} else {
|
||||
uni.showToast({ title: res.msg || '获取整改详情失败', icon: 'none' });
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取整改详情失败:', error);
|
||||
uni.showToast({ title: '获取整改详情失败', icon: 'none' });
|
||||
}
|
||||
};
|
||||
|
||||
// 获取隐患详情(无 rectifyId 时,从 assigns[].rectify 取整改记录)
|
||||
const fetchDetail = async () => {
|
||||
if (!hazardId.value) return;
|
||||
|
||||
@@ -420,8 +734,15 @@
|
||||
const assign = resolveAssignWithRectify(res.data.assigns);
|
||||
if (assign?.rectify) {
|
||||
applyRectifyData(assign.rectify);
|
||||
console.log('整改记录:', rectifyData);
|
||||
console.log('整改附件:', rectifyAttachments.value);
|
||||
if (!rectifyId.value && assign.rectify.rectifyId) {
|
||||
rectifyId.value = String(assign.rectify.rectifyId);
|
||||
}
|
||||
} else {
|
||||
uni.showToast({ title: '该隐患暂无整改记录', icon: 'none' });
|
||||
}
|
||||
const resolvedTaskId = resolveTaskIdFromAssign(assign) || resolveTaskIdFromDetail(res.data);
|
||||
if (resolvedTaskId) {
|
||||
taskId.value = resolvedTaskId;
|
||||
}
|
||||
} else {
|
||||
uni.showToast({ title: res.msg || '获取详情失败', icon: 'none' });
|
||||
@@ -432,6 +753,27 @@
|
||||
}
|
||||
};
|
||||
|
||||
const loadPageData = async () => {
|
||||
if (rectifyId.value) {
|
||||
await fetchRectifyDetail();
|
||||
} else if (hazardId.value) {
|
||||
await fetchDetail();
|
||||
}
|
||||
await fetchNextStep();
|
||||
};
|
||||
|
||||
const validateFormBeforeSubmit = () => {
|
||||
if (formData.result === 1 && !formData.quickApproveRadio) {
|
||||
uni.showToast({ title: '请选择是否快速审批', icon: 'none' });
|
||||
return false;
|
||||
}
|
||||
if (formData.result === 1 && formData.quickApproveRadio === 'no' && !selectedAssigneeIdentityId.value) {
|
||||
uni.showToast({ title: '请选择下一步处理人', icon: 'none' });
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
// 取消
|
||||
const handleCancel = () => {
|
||||
uni.navigateBack();
|
||||
@@ -447,6 +789,10 @@
|
||||
return;
|
||||
}
|
||||
|
||||
if (!validateFormBeforeSubmit()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 电子签名验证与处理
|
||||
if (showCanvas.value) {
|
||||
if (!signatureRef.value || isSignatureEmpty.value) {
|
||||
@@ -502,6 +848,13 @@
|
||||
signPath: signatureServerPath.value || '' // 电子签名路径
|
||||
// sendMsgFlag: sendMsgFlag.value
|
||||
};
|
||||
|
||||
if (formData.result === 1) {
|
||||
params.quickApprove = formData.quickApproveRadio === 'yes';
|
||||
if (formData.quickApproveRadio === 'no') {
|
||||
params.assigneeIdentityId = selectedAssigneeIdentityId.value;
|
||||
}
|
||||
}
|
||||
|
||||
console.log('提交验收参数:', params);
|
||||
|
||||
@@ -664,10 +1017,12 @@
|
||||
if (options.assignId) {
|
||||
assignId.value = options.assignId;
|
||||
}
|
||||
console.log('验收页面参数:', { rectifyId: rectifyId.value, hazardId: hazardId.value, assignId: assignId.value });
|
||||
if (options.taskId) {
|
||||
taskId.value = options.taskId;
|
||||
}
|
||||
console.log('验收页面参数:', { rectifyId: rectifyId.value, hazardId: hazardId.value, assignId: assignId.value, taskId: taskId.value });
|
||||
|
||||
// 获取隐患详情
|
||||
fetchDetail();
|
||||
loadPageData();
|
||||
|
||||
// 页面打开时自动恢复草稿
|
||||
restoreDraft();
|
||||
@@ -710,6 +1065,117 @@
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.select-trigger {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
background: #fff;
|
||||
border: 1rpx solid #dcdfe6;
|
||||
border-radius: 8rpx;
|
||||
padding: 20rpx 24rpx;
|
||||
margin-bottom: 20rpx;
|
||||
|
||||
.select-content {
|
||||
flex: 1;
|
||||
font-size: 28rpx;
|
||||
color: #333;
|
||||
}
|
||||
}
|
||||
|
||||
.user-popup {
|
||||
background: #fff;
|
||||
|
||||
.popup-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 30rpx;
|
||||
border-bottom: 1rpx solid #eee;
|
||||
|
||||
.popup-title {
|
||||
font-size: 32rpx;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.popup-close {
|
||||
font-size: 40rpx;
|
||||
color: #999;
|
||||
line-height: 1;
|
||||
}
|
||||
}
|
||||
|
||||
.user-list-scroll {
|
||||
max-height: 600rpx;
|
||||
padding: 0 30rpx;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.empty-tip {
|
||||
padding: 80rpx 20rpx;
|
||||
text-align: center;
|
||||
color: #909399;
|
||||
font-size: 26rpx;
|
||||
}
|
||||
|
||||
.user-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 24rpx 0;
|
||||
border-bottom: 1rpx solid #f5f5f5;
|
||||
|
||||
&:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
&.active {
|
||||
.user-item-text {
|
||||
color: #2667E9;
|
||||
font-weight: 600;
|
||||
}
|
||||
}
|
||||
|
||||
.user-item-text {
|
||||
flex: 1;
|
||||
font-size: 28rpx;
|
||||
color: #333;
|
||||
}
|
||||
}
|
||||
|
||||
.popup-footer {
|
||||
display: flex;
|
||||
gap: 24rpx;
|
||||
padding: 24rpx 30rpx;
|
||||
padding-bottom: calc(24rpx + env(safe-area-inset-bottom));
|
||||
background: #fff;
|
||||
|
||||
button {
|
||||
flex: 1;
|
||||
height: 80rpx;
|
||||
line-height: 80rpx;
|
||||
border-radius: 40rpx;
|
||||
font-size: 30rpx;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
|
||||
&::after {
|
||||
border: none;
|
||||
}
|
||||
}
|
||||
|
||||
.btn-cancel {
|
||||
background: #fff;
|
||||
color: #2667E9;
|
||||
border: 2rpx solid #2667E9;
|
||||
}
|
||||
|
||||
.btn-confirm {
|
||||
color: #fff;
|
||||
border: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 签名相关样式
|
||||
.signature-box {
|
||||
width: 100%;
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<view class="text-gray">下一步流程</view>
|
||||
<view class="text-red">*</view>
|
||||
</view>
|
||||
<view class="static-field">隐患整改</view>
|
||||
<view class="static-field">{{ nextStepDisplay }}</view>
|
||||
|
||||
<view class="flex margin-bottom margin-top">
|
||||
<view class="text-gray">整改责任人</view>
|
||||
@@ -33,7 +33,7 @@
|
||||
<view class="popup-title text-bold">选择整改责任人</view>
|
||||
<view class="popup-close" @click="cancelUserSelect">×</view>
|
||||
</view>
|
||||
<view v-if="userPickerSelectedId" class="selected-summary">
|
||||
<view v-if="userPickerSelectedIdentityId" class="selected-summary">
|
||||
<text class="summary-label">已选:</text>
|
||||
<text class="summary-text">{{ userPickerSelectedText }}</text>
|
||||
</view>
|
||||
@@ -55,12 +55,12 @@
|
||||
<view
|
||||
class="user-item"
|
||||
v-for="user in currentDeptUsers"
|
||||
:key="'user-' + user.userId"
|
||||
:class="{ active: String(userPickerSelectedId) === String(user.userId) }"
|
||||
@click="onUserItemClick(user.userId)"
|
||||
:key="'identity-' + user.identityId"
|
||||
:class="{ active: String(userPickerSelectedIdentityId) === String(user.identityId) }"
|
||||
@click="onUserItemClick(user.identityId)"
|
||||
>
|
||||
<text class="user-item-text">{{ formatUserDisplayName(user) }}</text>
|
||||
<text v-if="String(userPickerSelectedId) === String(user.userId)" class="cuIcon-check text-blue"></text>
|
||||
<text v-if="String(userPickerSelectedIdentityId) === String(user.identityId)" class="cuIcon-check text-blue"></text>
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
@@ -120,16 +120,32 @@
|
||||
// 页面参数
|
||||
const hazardId = ref('');
|
||||
const assignId = ref('');
|
||||
|
||||
// 整改人员选择
|
||||
const taskId = ref('');
|
||||
|
||||
// 下一步流程(固定为隐患整改)
|
||||
const nextStepDisplay = '隐患整改';
|
||||
// 整改人员选择(按身份 identityId 单选)
|
||||
const showUserPopup = ref(false);
|
||||
const selectedUser = ref('');
|
||||
const selectedIdentityId = ref('');
|
||||
const selectedUserId = ref('');
|
||||
const deptList = ref([]);
|
||||
const activeDeptIndex = ref(0);
|
||||
const userPickerSelectedId = ref('');
|
||||
const userPickerSelectedIdentityId = ref('');
|
||||
|
||||
const findUserByIdentityId = (identityId) => {
|
||||
if (!identityId) return null;
|
||||
for (const dept of deptList.value) {
|
||||
const user = (dept.users || []).find((u) => String(u.identityId) === String(identityId));
|
||||
if (user) return user;
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
const formatUserDisplayName = (user) => {
|
||||
if (user.identityName) {
|
||||
return `${user.nickName}_${user.identityName}`;
|
||||
}
|
||||
if (user.postName) {
|
||||
return `${user.nickName}_${user.postName}`;
|
||||
}
|
||||
@@ -142,27 +158,32 @@
|
||||
});
|
||||
|
||||
const userPickerSelectedText = computed(() => {
|
||||
if (!userPickerSelectedId.value) return '';
|
||||
for (const dept of deptList.value) {
|
||||
const user = (dept.users || []).find((u) => String(u.userId) === String(userPickerSelectedId.value));
|
||||
if (user) return formatUserDisplayName(user);
|
||||
}
|
||||
return '';
|
||||
const user = findUserByIdentityId(userPickerSelectedIdentityId.value);
|
||||
return user ? formatUserDisplayName(user) : '';
|
||||
});
|
||||
|
||||
const deptHasSelectedUser = (dept) => {
|
||||
if (!userPickerSelectedId.value || !dept.users?.length) return false;
|
||||
return dept.users.some((user) => String(user.userId) === String(userPickerSelectedId.value));
|
||||
if (!userPickerSelectedIdentityId.value || !dept.users?.length) return false;
|
||||
return dept.users.some((user) => String(user.identityId) === String(userPickerSelectedIdentityId.value));
|
||||
};
|
||||
|
||||
const onUserItemClick = (userId) => {
|
||||
userPickerSelectedId.value = String(userId);
|
||||
const onUserItemClick = (identityId) => {
|
||||
userPickerSelectedIdentityId.value = String(identityId);
|
||||
};
|
||||
|
||||
const openUserPopup = () => {
|
||||
userPickerSelectedId.value = selectedUserId.value;
|
||||
const firstDeptWithUsers = deptList.value.findIndex((dept) => dept.users?.length > 0);
|
||||
activeDeptIndex.value = firstDeptWithUsers >= 0 ? firstDeptWithUsers : 0;
|
||||
userPickerSelectedIdentityId.value = selectedIdentityId.value;
|
||||
let targetDeptIndex = 0;
|
||||
if (selectedIdentityId.value) {
|
||||
const deptIndex = deptList.value.findIndex((dept) =>
|
||||
(dept.users || []).some((user) => String(user.identityId) === String(selectedIdentityId.value))
|
||||
);
|
||||
if (deptIndex >= 0) targetDeptIndex = deptIndex;
|
||||
} else {
|
||||
const firstDeptWithUsers = deptList.value.findIndex((dept) => dept.users?.length > 0);
|
||||
if (firstDeptWithUsers >= 0) targetDeptIndex = firstDeptWithUsers;
|
||||
}
|
||||
activeDeptIndex.value = targetDeptIndex;
|
||||
showUserPopup.value = true;
|
||||
};
|
||||
|
||||
@@ -171,12 +192,18 @@
|
||||
};
|
||||
|
||||
const confirmUserSelect = () => {
|
||||
if (!userPickerSelectedId.value) {
|
||||
if (!userPickerSelectedIdentityId.value) {
|
||||
uni.showToast({ title: '请选择整改责任人', icon: 'none' });
|
||||
return;
|
||||
}
|
||||
selectedUserId.value = String(userPickerSelectedId.value);
|
||||
selectedUser.value = userPickerSelectedText.value;
|
||||
const user = findUserByIdentityId(userPickerSelectedIdentityId.value);
|
||||
if (!user) {
|
||||
uni.showToast({ title: '所选身份无效,请重新选择', icon: 'none' });
|
||||
return;
|
||||
}
|
||||
selectedIdentityId.value = String(user.identityId);
|
||||
selectedUserId.value = String(user.userId);
|
||||
selectedUser.value = formatUserDisplayName(user);
|
||||
showUserPopup.value = false;
|
||||
};
|
||||
|
||||
@@ -251,7 +278,7 @@
|
||||
|
||||
// 确认提交
|
||||
const handleSubmit = async () => {
|
||||
if (!selectedUserId.value) {
|
||||
if (!selectedIdentityId.value) {
|
||||
uni.showToast({ title: '请选择整改人员', icon: 'none' });
|
||||
return;
|
||||
}
|
||||
@@ -259,11 +286,17 @@
|
||||
uni.showToast({ title: '请选择整改期限', icon: 'none' });
|
||||
return;
|
||||
}
|
||||
if (!taskId.value) {
|
||||
uni.showToast({ title: '缺少任务ID', icon: 'none' });
|
||||
return;
|
||||
}
|
||||
|
||||
// 构建请求参数
|
||||
const params = {
|
||||
hazardId: Number(hazardId.value), // 隐患ID
|
||||
assigneeId: Number(selectedUserId.value), // 被指派人ID
|
||||
taskId: taskId.value, // 流程任务ID(列表传入)
|
||||
assigneeId: Number(selectedUserId.value), // 被指派人用户ID
|
||||
assigneeIdentityId: Number(selectedIdentityId.value), // 被指派人身份ID
|
||||
deadline: selectedDate.value, // 处理期限
|
||||
assignRemark: '', // 交办备注(可选)
|
||||
sendMsgFlag: sendMsgFlag.value // 是否短信提醒
|
||||
@@ -291,6 +324,7 @@
|
||||
onLoad((options) => {
|
||||
if (options.hazardId) hazardId.value = options.hazardId;
|
||||
if (options.assignId) assignId.value = options.assignId;
|
||||
if (options.taskId) taskId.value = options.taskId;
|
||||
fetchDeptUsers();
|
||||
|
||||
// 恢复草稿 (不恢复任何人员选择器数据)
|
||||
|
||||
247
pages/hiddendanger/process-chain.vue
Normal file
247
pages/hiddendanger/process-chain.vue
Normal file
@@ -0,0 +1,247 @@
|
||||
<template>
|
||||
<view class="page">
|
||||
<view class="top-gradient-wrap">
|
||||
<u-navbar
|
||||
title="查看隐患"
|
||||
:placeholder="true"
|
||||
:safeAreaInsetTop="true"
|
||||
bgColor="transparent"
|
||||
titleColor="#ffffff"
|
||||
leftIconColor="#ffffff"
|
||||
:autoBack="true"
|
||||
:border="false"
|
||||
/>
|
||||
|
||||
<view class="summary-card">
|
||||
<view class="summary-side summary-side--left">
|
||||
<image class="summary-icon" src="/static/yinhuan_detail/status.png" mode="aspectFit" />
|
||||
<view class="summary-icon-gap">
|
||||
<view class="summary-text">
|
||||
<view class="summary-label">隐患状态</view>
|
||||
<view class="summary-status">{{ summary.statusName }}</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="summary-divider"></view>
|
||||
<view class="summary-side summary-side--right">
|
||||
<image class="summary-icon" src="/static/yinhuan_detail/date.png" mode="aspectFit" />
|
||||
<view class="summary-text">
|
||||
<view class="summary-label">提交日期</view>
|
||||
<view class="summary-date">{{ summary.createdAt }}</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="panel-wrap">
|
||||
<HazardProcessChainPanel
|
||||
:chain-data="chainData"
|
||||
:loading="loading"
|
||||
:body-height="panelBodyHeight"
|
||||
/>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, computed, watch, nextTick, getCurrentInstance } from 'vue';
|
||||
import { onLoad, onReady } from '@dcloudio/uni-app';
|
||||
import HazardProcessChainPanel from '@/components/hazardDetail/HazardProcessChainPanel.vue';
|
||||
import { getHazardProcessChain } from '@/request/api.js';
|
||||
import { resolveProcessChainSummary } from '@/components/hazardDetail/processChain.js';
|
||||
|
||||
const instance = getCurrentInstance();
|
||||
const queryScope = instance?.proxy || instance;
|
||||
|
||||
const chainData = ref({});
|
||||
const loading = ref(false);
|
||||
const panelBodyHeight = ref(0);
|
||||
|
||||
const summary = computed(() => resolveProcessChainSummary(chainData.value));
|
||||
|
||||
const calcPanelBodyHeight = () => {
|
||||
nextTick(() => {
|
||||
const query = uni.createSelectorQuery().in(queryScope);
|
||||
query.select('.panel-wrap').boundingClientRect();
|
||||
query.exec((res) => {
|
||||
const rect = res?.[0];
|
||||
if (rect?.height > 0) {
|
||||
panelBodyHeight.value = Math.floor(rect.height);
|
||||
return;
|
||||
}
|
||||
const sys = uni.getSystemInfoSync();
|
||||
panelBodyHeight.value = Math.floor(sys.windowHeight * 0.55);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
const loadProcessChain = async (hazardId) => {
|
||||
loading.value = true;
|
||||
try {
|
||||
const res = await getHazardProcessChain(hazardId);
|
||||
if (res.code === 0 && res.data) {
|
||||
chainData.value = res.data;
|
||||
} else {
|
||||
chainData.value = {};
|
||||
uni.showToast({ title: res.msg || '获取流程链失败', icon: 'none' });
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取隐患流程链失败:', error);
|
||||
chainData.value = {};
|
||||
uni.showToast({ title: '获取流程链失败', icon: 'none' });
|
||||
} finally {
|
||||
loading.value = false;
|
||||
calcPanelBodyHeight();
|
||||
setTimeout(calcPanelBodyHeight, 100);
|
||||
setTimeout(calcPanelBodyHeight, 400);
|
||||
}
|
||||
};
|
||||
|
||||
onReady(() => {
|
||||
calcPanelBodyHeight();
|
||||
setTimeout(calcPanelBodyHeight, 100);
|
||||
setTimeout(calcPanelBodyHeight, 400);
|
||||
});
|
||||
|
||||
watch(loading, (isLoading) => {
|
||||
if (!isLoading) {
|
||||
calcPanelBodyHeight();
|
||||
setTimeout(calcPanelBodyHeight, 100);
|
||||
setTimeout(calcPanelBodyHeight, 400);
|
||||
}
|
||||
});
|
||||
|
||||
onLoad((options) => {
|
||||
if (options.hazardId) {
|
||||
loadProcessChain(options.hazardId);
|
||||
return;
|
||||
}
|
||||
|
||||
uni.showToast({ title: '缺少隐患ID', icon: 'none' });
|
||||
setTimeout(() => {
|
||||
uni.navigateBack();
|
||||
}, 1500);
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.page {
|
||||
height: 100vh;
|
||||
overflow: hidden;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
box-sizing: border-box;
|
||||
background: #f5f7fa;
|
||||
}
|
||||
|
||||
.top-gradient-wrap {
|
||||
flex-shrink: 0;
|
||||
background: linear-gradient(180deg, #046CEA 0%, #2158C8 28.44%, rgba(4, 107, 234, 0) 100%);
|
||||
}
|
||||
|
||||
.summary-card {
|
||||
margin: 32rpx 30rpx 0;
|
||||
padding: 28rpx 30rpx 32rpx;
|
||||
background: #fff;
|
||||
border-radius: 20rpx;
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.summary-side {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
.summary-side--left {
|
||||
flex-shrink: 0;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.summary-side--left .summary-text {
|
||||
padding-top: 0;
|
||||
padding-bottom: 0;
|
||||
}
|
||||
|
||||
.summary-side--right {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.summary-side--right .summary-icon {
|
||||
margin-right: 22rpx;
|
||||
}
|
||||
|
||||
.summary-side--right .summary-text {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
padding-top: 0;
|
||||
padding-bottom: 0;
|
||||
}
|
||||
|
||||
.summary-icon-gap {
|
||||
width: 149rpx;
|
||||
flex-shrink: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.summary-icon {
|
||||
width: 55rpx;
|
||||
height: 65rpx;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.summary-side--left .summary-icon {
|
||||
margin-right: 22rpx;
|
||||
}
|
||||
|
||||
.summary-text {
|
||||
flex-shrink: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.summary-label {
|
||||
font-size: 24rpx;
|
||||
color: #8f9ca2;
|
||||
line-height: 34rpx;
|
||||
}
|
||||
|
||||
.summary-status {
|
||||
margin-top: 8rpx;
|
||||
font-size: 28rpx;
|
||||
font-weight: 400;
|
||||
color: #333333;
|
||||
line-height: 40rpx;
|
||||
}
|
||||
|
||||
.summary-date {
|
||||
margin-top: 8rpx;
|
||||
font-size: 28rpx;
|
||||
font-weight: 400;
|
||||
color: #333333;
|
||||
line-height: 40rpx;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.summary-divider {
|
||||
width: 2rpx;
|
||||
height: 72rpx;
|
||||
flex-shrink: 0;
|
||||
background: #eee;
|
||||
margin-right: 40rpx;
|
||||
}
|
||||
|
||||
.panel-wrap {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
height: 0;
|
||||
margin-top: 12rpx;
|
||||
padding: 0 30rpx 30rpx;
|
||||
box-sizing: border-box;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
}
|
||||
</style>
|
||||
@@ -100,8 +100,8 @@
|
||||
<view class="popup-title text-bold">选择安全管理人员</view>
|
||||
<view class="popup-close" @click="cancelManagerSelect">×</view>
|
||||
</view>
|
||||
<view v-if="managerPickerSelectedIds.length > 0" class="selected-summary">
|
||||
<text class="summary-label">已选 {{ managerPickerSelectedIds.length }} 人:</text>
|
||||
<view v-if="managerPickerSelectedIdentityIds.length > 0" class="selected-summary">
|
||||
<text class="summary-label">已选 {{ managerPickerSelectedIdentityIds.length }} 人:</text>
|
||||
<text class="summary-text">{{ managerPickerSelectedText }}</text>
|
||||
</view>
|
||||
<view class="cascader-body">
|
||||
@@ -119,14 +119,14 @@
|
||||
<scroll-view class="cascader-col user-col" scroll-y :key="'manager-dept-users-' + activeManagerDeptIndex">
|
||||
<view v-if="currentManagerDeptUsers.length === 0" class="empty-tip">该部门暂无人员</view>
|
||||
<view v-else>
|
||||
<view class="user-item" v-for="user in currentManagerDeptUsers" :key="'manager-user-' + user.userId">
|
||||
<view class="user-item" v-for="user in currentManagerDeptUsers" :key="'manager-identity-' + user.identityId">
|
||||
<up-checkbox
|
||||
usedAlone
|
||||
:checked="managerPickerSelectedSet.has(String(user.userId))"
|
||||
:label="formatUserDisplayName(user)"
|
||||
:checked="managerPickerSelectedSet.has(String(user.identityId))"
|
||||
:label="formatMemberDisplayName(user)"
|
||||
activeColor="#2667E9"
|
||||
shape="square"
|
||||
@change="(checked) => onManagerCheckChange(user.userId, checked)"
|
||||
@change="(checked) => onManagerCheckChange(user.identityId, checked)"
|
||||
></up-checkbox>
|
||||
</view>
|
||||
</view>
|
||||
@@ -146,8 +146,8 @@
|
||||
<view class="popup-title text-bold">选择整改责任人</view>
|
||||
<view class="popup-close" @click="cancelUserSelect">×</view>
|
||||
</view>
|
||||
<view v-if="userPickerSelectedIds.length > 0" class="selected-summary">
|
||||
<text class="summary-label">已选 {{ userPickerSelectedIds.length }} 人:</text>
|
||||
<view v-if="userPickerSelectedIdentityIds.length > 0" class="selected-summary">
|
||||
<text class="summary-label">已选 {{ userPickerSelectedIdentityIds.length }} 人:</text>
|
||||
<text class="summary-text">{{ userPickerSelectedText }}</text>
|
||||
</view>
|
||||
<view class="cascader-body">
|
||||
@@ -165,15 +165,15 @@
|
||||
<scroll-view class="cascader-col user-col" scroll-y :key="'dept-users-' + activeDeptIndex">
|
||||
<view v-if="currentDeptUsers.length === 0" class="empty-tip">该部门暂无人员</view>
|
||||
<view v-else>
|
||||
<view class="user-item" v-for="user in currentDeptUsers" :key="'user-' + user.userId" :class="{ 'user-item-locked': isLockedUser(user.userId) }">
|
||||
<view class="user-item" v-for="user in currentDeptUsers" :key="'identity-' + user.identityId" :class="{ 'user-item-locked': isLockedIdentity(user.identityId) }">
|
||||
<up-checkbox
|
||||
usedAlone
|
||||
:checked="userPickerSelectedSet.has(String(user.userId))"
|
||||
:checked="userPickerSelectedSet.has(String(user.identityId))"
|
||||
:label="formatUserPickerLabel(user)"
|
||||
:disabled="isLockedUser(user.userId)"
|
||||
:disabled="isLockedIdentity(user.identityId)"
|
||||
activeColor="#2667E9"
|
||||
shape="square"
|
||||
@change="(checked) => onUserCheckChange(user.userId, checked)"
|
||||
@change="(checked) => onUserCheckChange(user.identityId, checked)"
|
||||
></up-checkbox>
|
||||
</view>
|
||||
</view>
|
||||
@@ -212,13 +212,13 @@
|
||||
<view class="text-gray">下一步流程</view>
|
||||
<view class="text-red">*</view>
|
||||
</view>
|
||||
<view class="static-field">隐患验收</view>
|
||||
<view class="static-field">{{ nextStepDisplay }}</view>
|
||||
|
||||
<view class="form-label margin-bottom margin-top">
|
||||
<view class="text-gray">下一步处理人</view>
|
||||
<view class="text-red">*</view>
|
||||
</view>
|
||||
<view class="static-field">企业管理员</view>
|
||||
<view class="static-field">管理人员</view>
|
||||
|
||||
<view class="form-label margin-bottom margin-top">
|
||||
<view class="text-gray">短信提醒</view>
|
||||
@@ -289,11 +289,13 @@
|
||||
import {onLoad, onHide} from '@dcloudio/uni-app'
|
||||
import {
|
||||
submitRectification,
|
||||
updateRectification,
|
||||
// getDepartmentPersonUsers,
|
||||
// getDeptUsersWithSubordinates,
|
||||
getRelatedDeptUsers,
|
||||
getRectifyDetail,
|
||||
getHiddenDangerDetail,
|
||||
getFlowNextNodes,
|
||||
generateRectifyPlan
|
||||
} from '@/request/api.js'
|
||||
import { buildDraftKey, buildDraftKeyCompact, DRAFT_NS } from '@/utils/draftCache.js';
|
||||
@@ -309,9 +311,91 @@
|
||||
// 从页面参数获取的ID
|
||||
const hazardId = ref('');
|
||||
const assignId = ref('');
|
||||
const taskId = ref('');
|
||||
const rectifyId = ref(''); // 整改ID(编辑模式时使用)
|
||||
const isEdit = ref(false); // 是否为编辑模式
|
||||
|
||||
// 下一步流程(编辑模式写死展示,新建整改走接口)
|
||||
const EDIT_NEXT_STEP_NAME = '隐患验收';
|
||||
const nextStepName = ref('');
|
||||
const nextStepLoading = ref(false);
|
||||
|
||||
const nextStepDisplay = computed(() => {
|
||||
if (isEdit.value) return EDIT_NEXT_STEP_NAME;
|
||||
if (nextStepLoading.value) return '加载中...';
|
||||
return nextStepName.value || '暂无下一步流程';
|
||||
});
|
||||
|
||||
const resolveTaskIdFromDetail = (data) => {
|
||||
if (!data) return '';
|
||||
if (data.taskId) return String(data.taskId);
|
||||
if (data.flowTaskId) return String(data.flowTaskId);
|
||||
if (data.currentTaskId) return String(data.currentTaskId);
|
||||
const assigns = data.assigns || [];
|
||||
for (const assign of assigns) {
|
||||
if (assign?.taskId) return String(assign.taskId);
|
||||
}
|
||||
return '';
|
||||
};
|
||||
|
||||
const resolveNextTaskName = (data) => {
|
||||
if (!data) return '';
|
||||
const branches = data.branches || [];
|
||||
const matchedBranch = branches.find((item) => item.matched) || branches[0];
|
||||
return matchedBranch?.nextNode?.taskName || '';
|
||||
};
|
||||
|
||||
const fetchNextStep = async () => {
|
||||
nextStepLoading.value = true;
|
||||
try {
|
||||
let currentTaskId = taskId.value;
|
||||
if (!currentTaskId && rectifyId.value) {
|
||||
const rectifyRes = await getRectifyDetail({ rectifyId: rectifyId.value });
|
||||
if (rectifyRes.code === 0 && rectifyRes.data) {
|
||||
const rectifyData = rectifyRes.data;
|
||||
currentTaskId = resolveTaskIdFromDetail(rectifyData);
|
||||
if (!hazardId.value && rectifyData.hazardId) {
|
||||
hazardId.value = rectifyData.hazardId;
|
||||
}
|
||||
if (!assignId.value && rectifyData.assignId) {
|
||||
assignId.value = rectifyData.assignId;
|
||||
}
|
||||
if (currentTaskId) {
|
||||
taskId.value = currentTaskId;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!currentTaskId && hazardId.value) {
|
||||
const detailRes = await getHiddenDangerDetail({
|
||||
hazardId: hazardId.value,
|
||||
assignId: assignId.value
|
||||
});
|
||||
if (detailRes.code === 0 && detailRes.data) {
|
||||
currentTaskId = resolveTaskIdFromDetail(detailRes.data);
|
||||
if (currentTaskId) {
|
||||
taskId.value = currentTaskId;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!currentTaskId) {
|
||||
nextStepName.value = '';
|
||||
return;
|
||||
}
|
||||
const res = await getFlowNextNodes({ taskId: currentTaskId });
|
||||
if (res.code === 0) {
|
||||
const payload = res.data && typeof res.data === 'object' ? res.data : res;
|
||||
nextStepName.value = resolveNextTaskName(payload);
|
||||
} else {
|
||||
nextStepName.value = '';
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取下一步流程失败:', error);
|
||||
nextStepName.value = '';
|
||||
} finally {
|
||||
nextStepLoading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
// 防作弊时间戳水印 Canvas 大小配置
|
||||
const canvasWidth = ref(300);
|
||||
const canvasHeight = ref(300);
|
||||
@@ -492,31 +576,32 @@
|
||||
}
|
||||
};
|
||||
|
||||
const applyAssigneeFromOptions = (assigneeId, assigneeName) => {
|
||||
if (!assigneeId) return;
|
||||
const id = String(assigneeId);
|
||||
const applyAssigneeFromOptions = (assigneeId, assigneeName, assigneeIdentityId) => {
|
||||
if (!assigneeIdentityId) return;
|
||||
const identityId = String(assigneeIdentityId);
|
||||
const name = assigneeName ? decodeURIComponent(String(assigneeName)).trim() : '';
|
||||
const exists = detailPersonPool.value.some((user) => String(user.userId) === id);
|
||||
const exists = detailPersonPool.value.some((user) => String(user.identityId) === identityId);
|
||||
if (!exists) {
|
||||
detailPersonPool.value.push({
|
||||
userId: assigneeId,
|
||||
userId: assigneeId || '',
|
||||
identityId: assigneeIdentityId,
|
||||
nickName: name,
|
||||
deptName: ''
|
||||
});
|
||||
}
|
||||
if (!lockedUserIds.value.includes(id)) {
|
||||
lockedUserIds.value = [...lockedUserIds.value, id];
|
||||
if (!lockedIdentityIds.value.includes(identityId)) {
|
||||
lockedIdentityIds.value = [...lockedIdentityIds.value, identityId];
|
||||
}
|
||||
selectedUserIds.value = mergeLockedUserIds([id]);
|
||||
syncSelectedUsersFromIds(selectedUserIds.value);
|
||||
selectedIdentityIds.value = mergeLockedIdentityIds([identityId]);
|
||||
syncSelectedMembersFromIdentityIds(selectedIdentityIds.value);
|
||||
};
|
||||
|
||||
const setLockedDefaultUsers = (ids) => {
|
||||
const setLockedDefaultIdentities = (ids) => {
|
||||
const normalized = parseIdList(ids);
|
||||
if (!normalized.length) return;
|
||||
lockedUserIds.value = normalized;
|
||||
selectedUserIds.value = mergeLockedUserIds(selectedUserIds.value);
|
||||
syncSelectedUsersFromIds(selectedUserIds.value);
|
||||
lockedIdentityIds.value = normalized;
|
||||
selectedIdentityIds.value = mergeLockedIdentityIds(selectedIdentityIds.value);
|
||||
syncSelectedMembersFromIdentityIds(selectedIdentityIds.value);
|
||||
};
|
||||
|
||||
const parseIdList = (raw) => {
|
||||
@@ -527,42 +612,40 @@
|
||||
return String(raw).split(',').map((id) => String(id).trim()).filter(Boolean);
|
||||
};
|
||||
|
||||
const resolveManagerIdsFromDetail = (data) => {
|
||||
const ids = parseIdList(data.manageIds ?? data.managerIds);
|
||||
const resolveManagerIdentityIdsFromDetail = (data) => {
|
||||
const ids = parseIdList(data.managerIds ?? data.manageIds ?? data.manageIdentityIds ?? data.managerIdentityIds);
|
||||
if (ids.length > 0) return ids;
|
||||
if (Array.isArray(data.managers) && data.managers.length > 0) {
|
||||
return data.managers.map((item) => String(item.userId)).filter(Boolean);
|
||||
return data.managers
|
||||
.map((item) => String(item.identityId ?? item.userId))
|
||||
.filter(Boolean);
|
||||
}
|
||||
return [];
|
||||
};
|
||||
|
||||
const buildUserItemFromDetail = (user) => ({
|
||||
id: String(user.userId),
|
||||
name: formatUserDisplayName(user),
|
||||
deptName: user.deptName || ''
|
||||
});
|
||||
|
||||
const getUsersByIdsFromTree = (ids, tree) => {
|
||||
const userMap = new Map();
|
||||
const getMembersByIdentityIdsFromTree = (ids, tree) => {
|
||||
const memberMap = new Map();
|
||||
(tree || []).forEach((dept) => {
|
||||
(dept.users || []).forEach((user) => {
|
||||
userMap.set(String(user.userId), buildUserItem(user, dept));
|
||||
if (user.identityId != null && user.identityId !== '') {
|
||||
memberMap.set(String(user.identityId), buildMemberItem(user, dept));
|
||||
}
|
||||
});
|
||||
});
|
||||
return ids.map((id) => userMap.get(String(id))).filter(Boolean);
|
||||
return ids.map((id) => memberMap.get(String(id))).filter(Boolean);
|
||||
};
|
||||
|
||||
const mergeUsersFromDetailPool = (ids, resolvedUsers) => {
|
||||
const userMap = new Map(resolvedUsers.map((user) => [user.id, user]));
|
||||
const mergeMembersFromDetailPool = (ids, resolvedMembers) => {
|
||||
const memberMap = new Map(resolvedMembers.map((member) => [member.id, member]));
|
||||
ids.forEach((id) => {
|
||||
const key = String(id);
|
||||
if (userMap.has(key)) return;
|
||||
const found = detailPersonPool.value.find((user) => String(user.userId) === key);
|
||||
if (memberMap.has(key)) return;
|
||||
const found = detailPersonPool.value.find((user) => String(user.identityId) === key);
|
||||
if (found) {
|
||||
userMap.set(key, buildUserItemFromDetail(found));
|
||||
memberMap.set(key, buildMemberItemFromDetail(found));
|
||||
}
|
||||
});
|
||||
return ids.map((id) => userMap.get(String(id))).filter(Boolean);
|
||||
return ids.map((id) => memberMap.get(String(id))).filter(Boolean);
|
||||
};
|
||||
|
||||
const applyRectifyTimeValue = (timeStr) => {
|
||||
@@ -591,45 +674,55 @@
|
||||
const deptList = ref([])
|
||||
const detailPersonPool = ref([])
|
||||
const showManagerPopup = ref(false)
|
||||
const selectedManagerIds = ref([])
|
||||
const selectedManagerIdentityIds = ref([])
|
||||
const selectedManagers = ref([])
|
||||
const activeManagerDeptIndex = ref(0)
|
||||
const managerPickerSelectedIds = ref([])
|
||||
const managerPickerSelectedIdentityIds = ref([])
|
||||
const showUserPopup = ref(false)
|
||||
const selectedUserIds = ref([])
|
||||
const selectedIdentityIds = ref([])
|
||||
const selectedUsers = ref([])
|
||||
const lockedUserIds = ref([])
|
||||
const lockedIdentityIds = ref([])
|
||||
const activeDeptIndex = ref(0)
|
||||
const userPickerSelectedIds = ref([])
|
||||
const userPickerSelectedIdentityIds = ref([])
|
||||
|
||||
const isLockedUser = (userId) => lockedUserIds.value.includes(String(userId));
|
||||
const isLockedIdentity = (identityId) => lockedIdentityIds.value.includes(String(identityId));
|
||||
|
||||
const mergeLockedUserIds = (ids) => {
|
||||
const mergeLockedIdentityIds = (ids) => {
|
||||
const merged = new Set([
|
||||
...(ids || []).map((id) => String(id)),
|
||||
...lockedUserIds.value.map((id) => String(id))
|
||||
...lockedIdentityIds.value.map((id) => String(id))
|
||||
]);
|
||||
return [...merged];
|
||||
};
|
||||
|
||||
const formatUserPickerLabel = (user) => {
|
||||
const name = formatUserDisplayName(user);
|
||||
return isLockedUser(user.userId) ? `${name}(默认)` : name;
|
||||
};
|
||||
|
||||
const formatUserDisplayName = (user) => {
|
||||
const formatMemberDisplayName = (user) => {
|
||||
if (user.identityName) {
|
||||
return `${user.nickName}_${user.identityName}`;
|
||||
}
|
||||
if (user.postName) {
|
||||
return `${user.nickName}_${user.postName}`;
|
||||
}
|
||||
return user.nickName || '';
|
||||
};
|
||||
|
||||
const buildUserItem = (user, dept) => ({
|
||||
id: String(user.userId),
|
||||
name: formatUserDisplayName(user),
|
||||
const formatUserPickerLabel = (user) => {
|
||||
const name = formatMemberDisplayName(user);
|
||||
return isLockedIdentity(user.identityId) ? `${name}(默认)` : name;
|
||||
};
|
||||
|
||||
const buildMemberItem = (user, dept) => ({
|
||||
id: String(user.identityId),
|
||||
userId: user.userId,
|
||||
name: formatMemberDisplayName(user),
|
||||
deptName: dept.deptName
|
||||
});
|
||||
|
||||
const buildMemberItemFromDetail = (user) => ({
|
||||
id: String(user.identityId || user.userId),
|
||||
name: formatMemberDisplayName(user),
|
||||
deptName: user.deptName || ''
|
||||
});
|
||||
|
||||
const buildSelectedPersonText = (users) => {
|
||||
if (users.length === 0) return '';
|
||||
if (users.length <= 2) {
|
||||
@@ -647,12 +740,12 @@
|
||||
});
|
||||
|
||||
const managerPickerSelectedText = computed(() => {
|
||||
const users = getManagerUsersByIds(managerPickerSelectedIds.value);
|
||||
const users = getManagersByIdentityIds(managerPickerSelectedIdentityIds.value);
|
||||
return buildSelectedPersonText(users);
|
||||
});
|
||||
|
||||
const managerPickerSelectedSet = computed(() => {
|
||||
return new Set(managerPickerSelectedIds.value.map((id) => String(id)));
|
||||
return new Set(managerPickerSelectedIdentityIds.value.map((id) => String(id)));
|
||||
});
|
||||
|
||||
const currentDeptUsers = computed(() => {
|
||||
@@ -661,80 +754,80 @@
|
||||
});
|
||||
|
||||
const userPickerSelectedText = computed(() => {
|
||||
const users = getUsersByIds(userPickerSelectedIds.value);
|
||||
const users = getMembersByIdentityIds(userPickerSelectedIdentityIds.value);
|
||||
return buildSelectedPersonText(users);
|
||||
});
|
||||
|
||||
const userPickerSelectedSet = computed(() => {
|
||||
return new Set(userPickerSelectedIds.value.map((id) => String(id)));
|
||||
return new Set(userPickerSelectedIdentityIds.value.map((id) => String(id)));
|
||||
});
|
||||
|
||||
const getManagerUsersByIds = (ids) => {
|
||||
let users = getUsersByIdsFromTree(ids, managerDeptList.value);
|
||||
if (users.length < ids.length) {
|
||||
const userDeptUsers = getUsersByIdsFromTree(ids, deptList.value);
|
||||
const userMap = new Map(users.map((user) => [user.id, user]));
|
||||
userDeptUsers.forEach((user) => {
|
||||
if (!userMap.has(user.id)) userMap.set(user.id, user);
|
||||
const getManagersByIdentityIds = (ids) => {
|
||||
let members = getMembersByIdentityIdsFromTree(ids, managerDeptList.value);
|
||||
if (members.length < ids.length) {
|
||||
const deptMembers = getMembersByIdentityIdsFromTree(ids, deptList.value);
|
||||
const memberMap = new Map(members.map((member) => [member.id, member]));
|
||||
deptMembers.forEach((member) => {
|
||||
if (!memberMap.has(member.id)) memberMap.set(member.id, member);
|
||||
});
|
||||
users = ids.map((id) => userMap.get(String(id))).filter(Boolean);
|
||||
members = ids.map((id) => memberMap.get(String(id))).filter(Boolean);
|
||||
}
|
||||
return mergeUsersFromDetailPool(ids, users);
|
||||
return mergeMembersFromDetailPool(ids, members);
|
||||
};
|
||||
|
||||
const getUsersByIds = (ids) => {
|
||||
let users = getUsersByIdsFromTree(ids, deptList.value);
|
||||
return mergeUsersFromDetailPool(ids, users);
|
||||
const getMembersByIdentityIds = (ids) => {
|
||||
let members = getMembersByIdentityIdsFromTree(ids, deptList.value);
|
||||
return mergeMembersFromDetailPool(ids, members);
|
||||
};
|
||||
|
||||
const syncSelectedManagersFromIds = (ids) => {
|
||||
selectedManagers.value = getManagerUsersByIds(ids);
|
||||
const syncSelectedManagersFromIdentityIds = (ids) => {
|
||||
selectedManagers.value = getManagersByIdentityIds(ids);
|
||||
};
|
||||
|
||||
const syncSelectedUsersFromIds = (ids) => {
|
||||
selectedUsers.value = getUsersByIds(ids);
|
||||
const syncSelectedMembersFromIdentityIds = (ids) => {
|
||||
selectedUsers.value = getMembersByIdentityIds(ids);
|
||||
};
|
||||
|
||||
const getManagerDeptSelectedCount = (dept) => {
|
||||
if (!dept.users?.length) return 0;
|
||||
const selectedSet = new Set(managerPickerSelectedIds.value.map(String));
|
||||
return dept.users.filter((user) => selectedSet.has(String(user.userId))).length;
|
||||
const selectedSet = new Set(managerPickerSelectedIdentityIds.value.map(String));
|
||||
return dept.users.filter((user) => selectedSet.has(String(user.identityId))).length;
|
||||
};
|
||||
|
||||
const getDeptSelectedCount = (dept) => {
|
||||
if (!dept.users?.length) return 0;
|
||||
const selectedSet = new Set(userPickerSelectedIds.value.map(String));
|
||||
return dept.users.filter((user) => selectedSet.has(String(user.userId))).length;
|
||||
const selectedSet = new Set(userPickerSelectedIdentityIds.value.map(String));
|
||||
return dept.users.filter((user) => selectedSet.has(String(user.identityId))).length;
|
||||
};
|
||||
|
||||
function onManagerCheckChange(userId, checked) {
|
||||
const id = String(userId);
|
||||
function onManagerCheckChange(identityId, checked) {
|
||||
const id = String(identityId);
|
||||
if (checked) {
|
||||
if (!managerPickerSelectedSet.value.has(id)) {
|
||||
managerPickerSelectedIds.value = [...managerPickerSelectedIds.value, id];
|
||||
managerPickerSelectedIdentityIds.value = [...managerPickerSelectedIdentityIds.value, id];
|
||||
}
|
||||
return;
|
||||
}
|
||||
managerPickerSelectedIds.value = managerPickerSelectedIds.value.filter((item) => String(item) !== id);
|
||||
managerPickerSelectedIdentityIds.value = managerPickerSelectedIdentityIds.value.filter((item) => String(item) !== id);
|
||||
}
|
||||
|
||||
function onUserCheckChange(userId, checked) {
|
||||
const id = String(userId);
|
||||
if (!checked && isLockedUser(id)) {
|
||||
function onUserCheckChange(identityId, checked) {
|
||||
const id = String(identityId);
|
||||
if (!checked && isLockedIdentity(id)) {
|
||||
uni.showToast({ title: '默认整改责任人不可取消', icon: 'none' });
|
||||
return;
|
||||
}
|
||||
if (checked) {
|
||||
if (!userPickerSelectedSet.value.has(id)) {
|
||||
userPickerSelectedIds.value = [...userPickerSelectedIds.value, id];
|
||||
userPickerSelectedIdentityIds.value = [...userPickerSelectedIdentityIds.value, id];
|
||||
}
|
||||
return;
|
||||
}
|
||||
userPickerSelectedIds.value = userPickerSelectedIds.value.filter((item) => String(item) !== id);
|
||||
userPickerSelectedIdentityIds.value = userPickerSelectedIdentityIds.value.filter((item) => String(item) !== id);
|
||||
}
|
||||
|
||||
const openManagerPopup = () => {
|
||||
managerPickerSelectedIds.value = [...selectedManagerIds.value];
|
||||
managerPickerSelectedIdentityIds.value = [...selectedManagerIdentityIds.value];
|
||||
const firstDeptWithUsers = managerDeptList.value.findIndex((dept) => dept.users?.length > 0);
|
||||
activeManagerDeptIndex.value = firstDeptWithUsers >= 0 ? firstDeptWithUsers : 0;
|
||||
showManagerPopup.value = true;
|
||||
@@ -745,7 +838,7 @@
|
||||
};
|
||||
|
||||
const openUserPopup = () => {
|
||||
userPickerSelectedIds.value = mergeLockedUserIds(selectedUserIds.value);
|
||||
userPickerSelectedIdentityIds.value = mergeLockedIdentityIds(selectedIdentityIds.value);
|
||||
const firstDeptWithUsers = deptList.value.findIndex((dept) => dept.users?.length > 0);
|
||||
activeDeptIndex.value = firstDeptWithUsers >= 0 ? firstDeptWithUsers : 0;
|
||||
showUserPopup.value = true;
|
||||
@@ -757,16 +850,16 @@
|
||||
|
||||
// 确认选择安全管理人员
|
||||
const confirmManagerSelect = () => {
|
||||
selectedManagerIds.value = managerPickerSelectedIds.value.map((id) => String(id));
|
||||
syncSelectedManagersFromIds(selectedManagerIds.value);
|
||||
selectedManagerIdentityIds.value = managerPickerSelectedIdentityIds.value.map((id) => String(id));
|
||||
syncSelectedManagersFromIdentityIds(selectedManagerIdentityIds.value);
|
||||
showManagerPopup.value = false;
|
||||
};
|
||||
|
||||
// 确认选择整改责任人
|
||||
const confirmUserSelect = () => {
|
||||
userPickerSelectedIds.value = mergeLockedUserIds(userPickerSelectedIds.value);
|
||||
selectedUserIds.value = userPickerSelectedIds.value.map((id) => String(id));
|
||||
syncSelectedUsersFromIds(selectedUserIds.value);
|
||||
userPickerSelectedIdentityIds.value = mergeLockedIdentityIds(userPickerSelectedIdentityIds.value);
|
||||
selectedIdentityIds.value = userPickerSelectedIdentityIds.value.map((id) => String(id));
|
||||
syncSelectedMembersFromIdentityIds(selectedIdentityIds.value);
|
||||
showUserPopup.value = false;
|
||||
};
|
||||
|
||||
@@ -777,11 +870,11 @@
|
||||
if (res.code === 0 && res.data) {
|
||||
managerDeptList.value = res.data;
|
||||
deptList.value = res.data;
|
||||
if (selectedManagerIds.value.length > 0) {
|
||||
syncSelectedManagersFromIds(selectedManagerIds.value);
|
||||
if (selectedManagerIdentityIds.value.length > 0) {
|
||||
syncSelectedManagersFromIdentityIds(selectedManagerIdentityIds.value);
|
||||
}
|
||||
if (selectedUserIds.value.length > 0) {
|
||||
syncSelectedUsersFromIds(selectedUserIds.value);
|
||||
if (selectedIdentityIds.value.length > 0) {
|
||||
syncSelectedMembersFromIdentityIds(selectedIdentityIds.value);
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
@@ -823,8 +916,8 @@
|
||||
|
||||
const fetchPersonnelLists = async () => {
|
||||
await fetchRelatedDeptUsers();
|
||||
if (selectedManagerIds.value.length > 0) {
|
||||
syncSelectedManagersFromIds(selectedManagerIds.value);
|
||||
if (selectedManagerIdentityIds.value.length > 0) {
|
||||
syncSelectedManagersFromIdentityIds(selectedManagerIdentityIds.value);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -839,38 +932,53 @@
|
||||
}
|
||||
});
|
||||
|
||||
// 提交整改
|
||||
// 真正的提交接口请求
|
||||
const executeSubmit = async () => {
|
||||
// 构建附件列表
|
||||
const attachments = fileList1.value
|
||||
.filter((f) => f.status === 'success')
|
||||
.map((file) => buildAttachmentItem(file));
|
||||
|
||||
// 构建提交/保存共用的整改业务字段
|
||||
const buildSharedRectifyParams = (attachments) => {
|
||||
const params = {
|
||||
hazardId: hazardId.value,
|
||||
assignId: assignId.value,
|
||||
rectifyPlan: formData.rectifyPlan,
|
||||
rectificationMeasures: formData.rectificationMeasures,
|
||||
controlMeasures: formData.controlMeasures,
|
||||
rectifyResult: formData.rectifyResult,
|
||||
planCost: Number(formData.planCost) || 0,
|
||||
actualCost: Number(formData.actualCost) || 0,
|
||||
attachments: attachments,
|
||||
manageIds: selectedManagerIds.value.map((id) => Number(id)),
|
||||
memberIds: selectedUserIds.value.map((id) => Number(id)),
|
||||
attachments,
|
||||
managerIds: selectedManagerIdentityIds.value.map((id) => Number(id)),
|
||||
memberIds: selectedIdentityIds.value.map((id) => Number(id)),
|
||||
rectifyTime: selectedRectifyTime.value || formatDateValue(rectifyTimeValue.value),
|
||||
signPath: signatureServerPath.value || '',
|
||||
sendMsgFlag: sendMsgFlag.value
|
||||
};
|
||||
|
||||
// 编辑模式需要传递rectifyId
|
||||
if (rectifyId.value) {
|
||||
params.rectifyId = rectifyId.value;
|
||||
if (selectedDeadlineDate.value) {
|
||||
params.deadline = selectedDeadlineDate.value;
|
||||
}
|
||||
return params;
|
||||
};
|
||||
|
||||
// 真正的提交/保存接口请求
|
||||
const executeSubmit = async () => {
|
||||
const attachments = fileList1.value
|
||||
.filter((f) => f.status === 'success')
|
||||
.map((file) => buildAttachmentItem(file));
|
||||
|
||||
try {
|
||||
const res = await submitRectification(params);
|
||||
let res;
|
||||
if (isEdit.value) {
|
||||
const updateParams = {
|
||||
rectifyId: Number(rectifyId.value),
|
||||
hazardId: hazardId.value,
|
||||
assignId: assignId.value,
|
||||
...buildSharedRectifyParams(attachments)
|
||||
};
|
||||
res = await updateRectification(updateParams);
|
||||
} else {
|
||||
const params = {
|
||||
hazardId: hazardId.value,
|
||||
assignId: assignId.value,
|
||||
...buildSharedRectifyParams(attachments)
|
||||
};
|
||||
res = await submitRectification(params);
|
||||
}
|
||||
|
||||
uni.hideLoading();
|
||||
if (res.code === 0) {
|
||||
clearDraft(false);
|
||||
@@ -889,7 +997,7 @@
|
||||
}
|
||||
} catch (error) {
|
||||
uni.hideLoading();
|
||||
console.error('提交整改失败:', error);
|
||||
console.error(isEdit.value ? '保存整改失败:' : '提交整改失败:', error);
|
||||
uni.showToast({
|
||||
title: '操作失败',
|
||||
icon: 'none'
|
||||
@@ -1051,7 +1159,7 @@
|
||||
planCost: Number(formData.planCost) || 0,
|
||||
actualCost: Number(formData.actualCost) || 0,
|
||||
attachments: attachments,
|
||||
memberIds: selectedUserIds.value.map(id => Number(id))
|
||||
memberIds: selectedIdentityIds.value.map(id => Number(id))
|
||||
};
|
||||
|
||||
// 编辑模式需要传递rectifyId
|
||||
@@ -1119,26 +1227,30 @@
|
||||
// 保存hazardId和assignId
|
||||
hazardId.value = data.hazardId || '';
|
||||
assignId.value = data.assignId || '';
|
||||
const resolvedTaskId = resolveTaskIdFromDetail(data);
|
||||
if (resolvedTaskId) {
|
||||
taskId.value = resolvedTaskId;
|
||||
}
|
||||
detailPersonPool.value = [
|
||||
...(Array.isArray(data.managers) ? data.managers : []),
|
||||
...(Array.isArray(data.members) ? data.members : [])
|
||||
];
|
||||
|
||||
// 先解析人员 ID,再拉取候选列表并回显
|
||||
const managerIdArr = resolveManagerIdsFromDetail(data);
|
||||
const memberIdArr = parseIdList(data.memberIds);
|
||||
if (managerIdArr.length > 0) {
|
||||
selectedManagerIds.value = managerIdArr;
|
||||
const managerIdentityIdArr = resolveManagerIdentityIdsFromDetail(data);
|
||||
if (managerIdentityIdArr.length > 0) {
|
||||
selectedManagerIdentityIds.value = managerIdentityIdArr;
|
||||
}
|
||||
if (memberIdArr.length > 0) {
|
||||
selectedUserIds.value = memberIdArr;
|
||||
} else if (data.rectifierId) {
|
||||
selectedUserIds.value = [String(data.rectifierId)];
|
||||
const memberIdentityIdArr = parseIdList(data.memberIds ?? data.memberIdentityIds);
|
||||
if (memberIdentityIdArr.length > 0) {
|
||||
selectedIdentityIds.value = memberIdentityIdArr;
|
||||
} else if (data.rectifierIdentityId) {
|
||||
selectedIdentityIds.value = [String(data.rectifierIdentityId)];
|
||||
}
|
||||
if (data.assigneeId) {
|
||||
setLockedDefaultUsers(data.assigneeId);
|
||||
} else if (data.rectifierId) {
|
||||
setLockedDefaultUsers(data.rectifierId);
|
||||
if (data.assigneeIdentityId) {
|
||||
setLockedDefaultIdentities(data.assigneeIdentityId);
|
||||
} else if (data.rectifierIdentityId) {
|
||||
setLockedDefaultIdentities(data.rectifierIdentityId);
|
||||
}
|
||||
await fetchPersonnelLists();
|
||||
|
||||
@@ -1335,9 +1447,12 @@
|
||||
if (options.assignId) {
|
||||
assignId.value = options.assignId;
|
||||
}
|
||||
if (options.taskId) {
|
||||
taskId.value = options.taskId;
|
||||
}
|
||||
|
||||
if (!options.rectifyId && options.assigneeId) {
|
||||
applyAssigneeFromOptions(options.assigneeId, options.assigneeName);
|
||||
if (!options.rectifyId && options.assigneeIdentityId) {
|
||||
applyAssigneeFromOptions(options.assigneeId, options.assigneeName, options.assigneeIdentityId);
|
||||
}
|
||||
|
||||
// 在hazardId赋值后调用,确保有值
|
||||
@@ -1358,6 +1473,10 @@
|
||||
if (options.deadline) {
|
||||
applyDeadlineFromOptions(options.deadline);
|
||||
}
|
||||
|
||||
if (!options.rectifyId) {
|
||||
fetchNextStep();
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
@@ -25,17 +25,18 @@
|
||||
<view class="user-info">
|
||||
<view class="user-dept text-bold">{{ userInfo.deptName || '未知部门' }}</view>
|
||||
<view class="user-phone">手机号:{{ userInfo.phone || '未绑定' }}</view>
|
||||
<view v-if="displayIdentityName" class="user-identity">当前身份:{{ displayIdentityName }}</view>
|
||||
</view>
|
||||
<!-- <view class="switch-btn">
|
||||
<view class="switch-btn" @click="goSwitchIdentity">
|
||||
<text>切换</text>
|
||||
<u-icon name="list" color="#285CE9" size="14"></u-icon>
|
||||
</view> -->
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="padding page-content">
|
||||
<!-- 功能菜单 -->
|
||||
<view class="menu-card">
|
||||
<!-- 功能菜单(approval 角色不展示) -->
|
||||
<view v-if="!isApprovalRole" class="menu-card">
|
||||
<view class="menu-grid">
|
||||
<view class="menu-item" v-for="(item, index) in infoList" :key="index" @click="handleMenuClick(item)">
|
||||
<image class="menu-icon" :src="item.src"></image>
|
||||
@@ -44,7 +45,7 @@
|
||||
</view>
|
||||
</view>
|
||||
<!-- 我的检查计划 -->
|
||||
<view class="bg-white margin-top radius" style="padding: 40rpx; margin-left: -30rpx; margin-right: -30rpx;">
|
||||
<view v-if="!isApprovalRole" class="bg-white margin-top radius" style="padding: 40rpx; margin-left: -30rpx; margin-right: -30rpx;">
|
||||
<view class="flex margin-bottom-xl align-center justify-between">
|
||||
<view class="text-bold margin-left-xs" style="font-size: 32rpx;">我的检查计划</view>
|
||||
<!-- <button class="cu-btn round sm line-blue inspect-list-btn" @click="goInspectList">检查列表</button> -->
|
||||
@@ -121,8 +122,8 @@
|
||||
加载更多
|
||||
</view>
|
||||
</view>
|
||||
<!-- 我的隐患 -->
|
||||
<view class="bg-white margin-top radius" style="padding: 40rpx; margin-left: -40rpx; margin-right: -40rpx;">
|
||||
<!-- 我的隐患排查 -->
|
||||
<view v-if="!isApprovalRole" class="bg-white margin-top radius" style="padding: 40rpx; margin-left: -40rpx; margin-right: -40rpx;">
|
||||
<view class="flex margin-bottom">
|
||||
<!-- <view class="border-tite"></view> -->
|
||||
<view class="text-bold margin-left-xs" style="font-size: 32rpx;">我的隐患排查</view>
|
||||
@@ -140,11 +141,11 @@
|
||||
</view>
|
||||
</scroll-view>
|
||||
<!-- 无数据提示 -->
|
||||
<view v-if="filteredDangerData.length === 0" class="text-center text-gray padding">
|
||||
<view v-if="hiddenDangerData.length === 0 && !hiddenDangerLoading" class="text-center text-gray padding">
|
||||
暂无隐患数据
|
||||
</view>
|
||||
<!-- 隐患卡片列表 -->
|
||||
<view class="danger-card margin-top" v-for="(item, index) in filteredDangerData" :key="item.hazardId">
|
||||
<view class="danger-card margin-top" v-for="(item, index) in hiddenDangerData" :key="item.hazardId">
|
||||
<!-- 标题行:图标+标题 + 等级标签 -->
|
||||
<view class="flex justify-between align-center">
|
||||
<view class="flex align-center" style="flex: 1; min-width: 0; margin-right: 24rpx;">
|
||||
@@ -183,10 +184,74 @@
|
||||
class="round cu-btn bg-blue" @click.stop="goRectification(item)">立即整改</button>
|
||||
<button v-if="item.statusName === '待验收' && item.canEdit"
|
||||
class="round cu-btn light bg-blue" @click.stop="editRectification(item)">编辑整改信息</button>
|
||||
<button v-if="item.statusName === '待验收' && canAcceptance"
|
||||
<button v-if="canShowAcceptanceButton(item, currentRoleKey)"
|
||||
class="round cu-btn bg-blue" @click.stop="goAcceptance(item)">立即验收</button>
|
||||
<button v-if="item.statusName === '待交办'"
|
||||
class="round cu-btn bg-blue" @click.stop="assignHazard(item)">隐患交办</button>
|
||||
<button v-if="canShowWriteoffApplyButton(item)"
|
||||
class="round cu-btn bg-blue" @click.stop="goWriteoffApply(item)">销号申请</button>
|
||||
<button v-if="canShowWriteoffApprovalButton(item, currentRoleKey)"
|
||||
class="round cu-btn bg-blue" @click.stop="goWriteoffApproval(item)">销号审批</button>
|
||||
</view>
|
||||
</view>
|
||||
<u-loadmore
|
||||
v-if="hiddenDangerData.length > 0"
|
||||
:status="hiddenDangerLoadStatus"
|
||||
style="margin-top: 20rpx; margin-bottom: 20rpx;"
|
||||
/>
|
||||
</view>
|
||||
|
||||
<!-- 我的工作台(approval 角色专属) -->
|
||||
<view v-if="isApprovalRole" class="bg-white margin-top radius" style="padding: 40rpx; margin-left: -40rpx; margin-right: -40rpx;">
|
||||
<view class="flex margin-bottom">
|
||||
<view class="text-bold margin-left-xs" style="font-size: 32rpx;">我的工作台</view>
|
||||
</view>
|
||||
<view class="danger-tab-list workbench-tab-list">
|
||||
<view
|
||||
class="danger-tab-item"
|
||||
:class="{ 'danger-tab-active': activeWorkbenchTab === index }"
|
||||
v-for="(tab, index) in workbenchTabs"
|
||||
:key="tab.value"
|
||||
@click="switchWorkbenchTab(index)"
|
||||
>{{ tab.label }}</view>
|
||||
</view>
|
||||
<view v-if="workbenchLoading" class="text-center text-gray padding">加载中...</view>
|
||||
<view v-else-if="workbenchList.length === 0" class="text-center text-gray padding">
|
||||
暂无数据
|
||||
</view>
|
||||
<view class="danger-card margin-top" v-for="item in workbenchList" :key="getWorkbenchItemKey(item)">
|
||||
<view class="flex justify-between align-center">
|
||||
<view class="flex align-center" style="flex: 1; min-width: 0; margin-right: 24rpx;">
|
||||
<text class="cuIcon-infofill text-blue" style="font-size: 36rpx; margin-right: 12rpx; flex-shrink: 0;"></text>
|
||||
<view class="text-bold" style="font-size: 30rpx; word-break: break-all; flex: 1;">{{ item.title }}</view>
|
||||
</view>
|
||||
<view class="level-tag" :class="{
|
||||
'level-minor': item.levelName === '轻微隐患',
|
||||
'level-normal': item.levelName === '一般隐患',
|
||||
'level-major': item.levelName === '重大隐患'
|
||||
}">{{ item.levelName }}</view>
|
||||
</view>
|
||||
<view class="text-gray margin-top-sm" style="font-size: 26rpx; padding-left: 48rpx;">{{ item.address }}</view>
|
||||
<view style="height: 1rpx; background: #EEEEEE; margin: 20rpx 0;"></view>
|
||||
<view class="danger-info-row">
|
||||
<text class="text-gray">隐患来源:</text>
|
||||
<text style="color: #333333;">{{ item.source }}</text>
|
||||
</view>
|
||||
<view class="danger-info-row">
|
||||
<text class="text-gray">隐患状态:</text>
|
||||
<text style="color: #333333;">{{ item.statusName }}</text>
|
||||
</view>
|
||||
<view class="danger-info-row">
|
||||
<text class="text-gray">发现时间:</text>
|
||||
<text style="color: #333333;">{{ item.createdAt }}</text>
|
||||
</view>
|
||||
<view class="flex justify-end danger-card-actions">
|
||||
<button class="round cu-btn light bg-blue" @click.stop="viewHazardDetail(item)">查看详情</button>
|
||||
<button
|
||||
v-if="activeWorkbenchTab === 0"
|
||||
class="round cu-btn bg-blue"
|
||||
@click.stop="goLeaderApproval(item)"
|
||||
>领导批示</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -197,10 +262,24 @@
|
||||
<script setup>
|
||||
import { ref, reactive, computed } from 'vue';
|
||||
// import { onLoad } from '@dcloudio/uni-app';
|
||||
import {getCheckPlanList, getHiddenDangerList} from '@/request/api.js'
|
||||
import {getCheckPlanList, getHiddenDangerList, getFlowTodoList, getFlowDoneList} from '@/request/api.js'
|
||||
import { getProfileDetail } from '@/request/three_one_api/info.js';
|
||||
import { onLoad, onShow } from '@dcloudio/uni-app';
|
||||
import { onLoad, onShow, onReachBottom } from '@dcloudio/uni-app';
|
||||
import { toImageUrl } from '@/request/request.js';
|
||||
import { applyProfileToUserInfo, applyStoredUserInfo, resolveIdentityName, resolveUserRoleKey } from '@/utils/userInfo.js';
|
||||
import {
|
||||
buildRectificationUrl,
|
||||
buildEditRectificationUrl,
|
||||
buildAssignmentUrl,
|
||||
buildAcceptanceUrl,
|
||||
buildAcceptanceApprovalUrl,
|
||||
buildWriteoffApplyUrl,
|
||||
buildWriteoffApprovalUrl,
|
||||
buildLeaderWriteoffApprovalUrl,
|
||||
canShowAcceptanceButton,
|
||||
canShowWriteoffApplyButton,
|
||||
canShowWriteoffApprovalButton
|
||||
} from '@/utils/hazardNav.js';
|
||||
const loading = ref(true);
|
||||
|
||||
const defaultAvatar = '/static/my/default_avater.png';
|
||||
@@ -214,13 +293,31 @@
|
||||
deptName: '',
|
||||
role: '',
|
||||
avatar: '',
|
||||
phone: ''
|
||||
phone: '',
|
||||
identityName: '',
|
||||
userIdentity: null
|
||||
});
|
||||
|
||||
// 获取用户角色,判断是否有验收权限(admin或manage才能验收)
|
||||
const canAcceptance = computed(() => {
|
||||
return userInfo.role === 'admin' || userInfo.role === 'manage';
|
||||
// 当前身份角色(优先 userIdentity.roleKey)
|
||||
const currentRoleKey = computed(() => resolveUserRoleKey(userInfo));
|
||||
|
||||
const isApprovalRole = computed(() => currentRoleKey.value === 'approval');
|
||||
|
||||
// 展示用身份名称(兼容接口字段与本地缓存)
|
||||
const displayIdentityName = computed(() => {
|
||||
return resolveIdentityName(userInfo, userInfo.userIdentity);
|
||||
});
|
||||
|
||||
const loadUserInfoFromStorage = () => {
|
||||
try {
|
||||
const storedUserInfo = uni.getStorageSync('userInfo');
|
||||
if (storedUserInfo) {
|
||||
applyStoredUserInfo(userInfo, JSON.parse(storedUserInfo));
|
||||
}
|
||||
} catch (storageError) {
|
||||
console.error('从本地存储获取用户信息失败:', storageError);
|
||||
}
|
||||
};
|
||||
|
||||
// 获取图片完整URL(用于显示)
|
||||
const getImageUrl = (path) => {
|
||||
@@ -233,37 +330,11 @@
|
||||
try {
|
||||
const res = await getProfileDetail();
|
||||
if (res.code === 0 && res.data) {
|
||||
userInfo.userId = res.data.userId || '';
|
||||
userInfo.username = res.data.userName || '';
|
||||
userInfo.nickName = res.data.nickName || '';
|
||||
userInfo.deptId = res.data.deptId || '';
|
||||
userInfo.deptName = res.data.deptName || '';
|
||||
userInfo.avatar = res.data.avatar || '';
|
||||
userInfo.phone = res.data.phonenumber || res.data.phone || '';
|
||||
// 获取角色信息
|
||||
if (res.data.roles && res.data.roles.length > 0) {
|
||||
userInfo.role = res.data.roles[0].roleKey || '';
|
||||
}
|
||||
applyProfileToUserInfo(userInfo, res.data);
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('获取用户信息失败:', e);
|
||||
// 如果接口失败,尝试从本地存储获取
|
||||
try {
|
||||
const storedUserInfo = uni.getStorageSync('userInfo');
|
||||
if (storedUserInfo) {
|
||||
const info = JSON.parse(storedUserInfo);
|
||||
userInfo.userId = info.userId || '';
|
||||
userInfo.username = info.username || '';
|
||||
userInfo.nickName = info.nickName || '';
|
||||
userInfo.deptId = info.deptId || '';
|
||||
userInfo.deptName = info.deptName || '';
|
||||
userInfo.role = info.role || '';
|
||||
userInfo.avatar = info.avatar || '';
|
||||
userInfo.phone = info.phone || '';
|
||||
}
|
||||
} catch (storageError) {
|
||||
console.error('从本地存储获取用户信息失败:', storageError);
|
||||
}
|
||||
loadUserInfoFromStorage();
|
||||
}
|
||||
};
|
||||
// 全部菜单项
|
||||
@@ -307,7 +378,10 @@
|
||||
|
||||
// 根据角色动态展示菜单
|
||||
const infoList = computed(() => {
|
||||
if (userInfo.role === 'common') {
|
||||
if (currentRoleKey.value === 'approval') {
|
||||
return [];
|
||||
}
|
||||
if (currentRoleKey.value === 'common') {
|
||||
return allMenuList.filter(item => commonMenuNames.includes(item.name));
|
||||
}
|
||||
// admin、manage 及其他角色展示全部菜单
|
||||
@@ -473,16 +547,22 @@
|
||||
// });
|
||||
// 页面每次显示时都会加载数据
|
||||
onShow(() => {
|
||||
getUserInfo();
|
||||
getCheckPlanLists();
|
||||
getHiddenDangerLists();
|
||||
loadUserInfoFromStorage();
|
||||
getUserInfo().then(() => {
|
||||
if (isApprovalRole.value) {
|
||||
fetchWorkbenchList();
|
||||
} else {
|
||||
getCheckPlanLists();
|
||||
resetHiddenDangerList();
|
||||
fetchHiddenDangerList();
|
||||
}
|
||||
});
|
||||
});
|
||||
//我的隐患排查
|
||||
const hiddenDangerParams = ref({
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
name: ''
|
||||
});
|
||||
const HAZARD_PAGE_SIZE = 10;
|
||||
const hiddenDangerPageNum = ref(1);
|
||||
const hiddenDangerLoading = ref(false);
|
||||
const hiddenDangerLoadStatus = ref('loadmore');
|
||||
const hiddenDangerData = ref([]);
|
||||
|
||||
// 隐患排查 Tab 筛选
|
||||
@@ -496,92 +576,224 @@
|
||||
]);
|
||||
const activeDangerTab = ref(0);
|
||||
|
||||
// 切换 Tab
|
||||
const buildHiddenDangerListParams = () => {
|
||||
const params = {
|
||||
pageNum: hiddenDangerPageNum.value,
|
||||
pageSize: HAZARD_PAGE_SIZE
|
||||
};
|
||||
const activeTab = dangerTabs.value[activeDangerTab.value];
|
||||
if (activeTab?.value != null) {
|
||||
params.status = activeTab.value;
|
||||
}
|
||||
return params;
|
||||
};
|
||||
|
||||
const resetHiddenDangerList = () => {
|
||||
hiddenDangerPageNum.value = 1;
|
||||
hiddenDangerData.value = [];
|
||||
hiddenDangerLoadStatus.value = 'loadmore';
|
||||
};
|
||||
|
||||
// 切换 Tab:带 status 重新请求接口
|
||||
const switchDangerTab = (index) => {
|
||||
if (activeDangerTab.value === index) return;
|
||||
activeDangerTab.value = index;
|
||||
resetHiddenDangerList();
|
||||
fetchHiddenDangerList();
|
||||
};
|
||||
|
||||
// 根据 Tab 过滤隐患数据
|
||||
const filteredDangerData = computed(() => {
|
||||
const activeTab = dangerTabs.value[activeDangerTab.value];
|
||||
if (!activeTab || activeTab.value === null) {
|
||||
return hiddenDangerData.value;
|
||||
const fetchHiddenDangerList = async () => {
|
||||
if (hiddenDangerLoading.value) return;
|
||||
if (hiddenDangerPageNum.value > 1 && hiddenDangerLoadStatus.value === 'nomore') return;
|
||||
|
||||
hiddenDangerLoading.value = true;
|
||||
if (hiddenDangerPageNum.value > 1) {
|
||||
hiddenDangerLoadStatus.value = 'loading';
|
||||
}
|
||||
return hiddenDangerData.value.filter(item => item.status === activeTab.value);
|
||||
});
|
||||
|
||||
const getHiddenDangerLists = async () => {
|
||||
try {
|
||||
const res = await getHiddenDangerList(hiddenDangerParams.value);
|
||||
console.log(res);
|
||||
const res = await getHiddenDangerList(buildHiddenDangerListParams());
|
||||
if (res.code === 0) {
|
||||
hiddenDangerData.value = res.data.records;
|
||||
console.log(hiddenDangerData.value,1111);
|
||||
const records = res.data?.records || [];
|
||||
const total = Number(res.data?.total ?? 0);
|
||||
if (hiddenDangerPageNum.value === 1) {
|
||||
hiddenDangerData.value = records;
|
||||
} else {
|
||||
hiddenDangerData.value = [...hiddenDangerData.value, ...records];
|
||||
}
|
||||
if (hiddenDangerData.value.length >= total || records.length < HAZARD_PAGE_SIZE) {
|
||||
hiddenDangerLoadStatus.value = 'nomore';
|
||||
} else {
|
||||
hiddenDangerLoadStatus.value = 'loadmore';
|
||||
}
|
||||
} else {
|
||||
if (hiddenDangerPageNum.value === 1) {
|
||||
hiddenDangerData.value = [];
|
||||
}
|
||||
hiddenDangerLoadStatus.value = 'nomore';
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
if (hiddenDangerPageNum.value > 1) {
|
||||
hiddenDangerPageNum.value--;
|
||||
}
|
||||
hiddenDangerLoadStatus.value = 'loadmore';
|
||||
} finally {
|
||||
hiddenDangerLoading.value = false;
|
||||
loading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
const loadMoreHiddenDangerList = () => {
|
||||
if (hiddenDangerLoadStatus.value !== 'loadmore' || hiddenDangerLoading.value) return;
|
||||
hiddenDangerPageNum.value++;
|
||||
fetchHiddenDangerList();
|
||||
};
|
||||
|
||||
// 页面加载时调用接口
|
||||
onLoad(() => {
|
||||
getHiddenDangerLists();
|
||||
|
||||
if (!isApprovalRole.value) {
|
||||
resetHiddenDangerList();
|
||||
fetchHiddenDangerList();
|
||||
}
|
||||
});
|
||||
|
||||
onReachBottom(() => {
|
||||
if (isApprovalRole.value) return;
|
||||
loadMoreHiddenDangerList();
|
||||
});
|
||||
|
||||
// ========== 我的工作台(approval 角色) ==========
|
||||
const workbenchTabs = [
|
||||
{ label: '待办', value: 'todo' },
|
||||
{ label: '已办', value: 'done' }
|
||||
];
|
||||
const activeWorkbenchTab = ref(0);
|
||||
const workbenchList = ref([]);
|
||||
const workbenchLoading = ref(false);
|
||||
|
||||
const normalizeWorkbenchItem = (item) => {
|
||||
if (!item) return {};
|
||||
const hazard = item.hazard || item.hazardInfo || {};
|
||||
return {
|
||||
...item,
|
||||
hazardId: item.hazardId ?? hazard.hazardId ?? '',
|
||||
assignId: item.assignId ?? hazard.assignId ?? '',
|
||||
rectifyId: item.rectifyId ?? hazard.rectifyId ?? '',
|
||||
taskId: item.taskId ?? item.flowTaskId ?? item.currentTaskId ?? '',
|
||||
taskKey: item.taskKey ?? item.flowTaskKey ?? item.currentTaskKey ?? '',
|
||||
title: item.title ?? hazard.title ?? item.hazardTitle ?? '',
|
||||
address: item.address ?? hazard.address ?? '',
|
||||
source: item.source ?? hazard.source ?? item.hazardSourceName ?? '',
|
||||
statusName: item.statusName ?? hazard.statusName ?? item.hazardStatusName ?? hazard.hazardStatusName ?? item.taskName ?? '',
|
||||
hazardStatus: item.hazardStatus ?? hazard.hazardStatus ?? item.status ?? hazard.status ?? '',
|
||||
createdAt: item.discoveredAt ?? hazard.discoveredAt ?? '',
|
||||
levelName: item.levelName ?? hazard.levelName ?? ''
|
||||
};
|
||||
};
|
||||
|
||||
const resolveWorkbenchRecords = (data) => {
|
||||
if (!data) return [];
|
||||
if (Array.isArray(data)) return data;
|
||||
if (Array.isArray(data.records)) return data.records;
|
||||
if (Array.isArray(data.list)) return data.list;
|
||||
return [];
|
||||
};
|
||||
|
||||
const getWorkbenchItemKey = (item) => {
|
||||
const taskId = item.taskId || item.flowTaskId || '';
|
||||
const hazardId = item.hazardId || '';
|
||||
if (taskId && hazardId) return `${taskId}-${hazardId}`;
|
||||
return taskId || hazardId || item.rectifyId || JSON.stringify(item);
|
||||
};
|
||||
|
||||
const switchWorkbenchTab = (index) => {
|
||||
if (activeWorkbenchTab.value === index) return;
|
||||
activeWorkbenchTab.value = index;
|
||||
fetchWorkbenchList();
|
||||
};
|
||||
|
||||
const fetchWorkbenchList = async () => {
|
||||
workbenchLoading.value = true;
|
||||
try {
|
||||
const isTodo = activeWorkbenchTab.value === 0;
|
||||
const res = isTodo ? await getFlowTodoList() : await getFlowDoneList();
|
||||
if (res.code === 0) {
|
||||
workbenchList.value = resolveWorkbenchRecords(res.data).map(normalizeWorkbenchItem);
|
||||
} else {
|
||||
workbenchList.value = [];
|
||||
uni.showToast({ title: res.msg || '获取工作台数据失败', icon: 'none' });
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取工作台数据失败:', error);
|
||||
workbenchList.value = [];
|
||||
uni.showToast({ title: '获取工作台数据失败', icon: 'none' });
|
||||
} finally {
|
||||
workbenchLoading.value = false;
|
||||
loading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
const goLeaderApproval = (item) => {
|
||||
const hazardStatus = Number(item.hazardStatus);
|
||||
const statusName = item.statusName || item.hazardStatusName || '';
|
||||
|
||||
if (hazardStatus === 4 || statusName === '待销号') {
|
||||
uni.navigateTo({ url: buildLeaderWriteoffApprovalUrl(item) });
|
||||
return;
|
||||
}
|
||||
|
||||
if (hazardStatus === 3 || statusName === '待验收') {
|
||||
uni.navigateTo({ url: buildAcceptanceApprovalUrl(item) });
|
||||
return;
|
||||
}
|
||||
|
||||
uni.showToast({ title: '当前状态不支持领导审批', icon: 'none' });
|
||||
};
|
||||
|
||||
// ========== 隐患排查相关跳转函数 ==========
|
||||
// 查看隐患详情
|
||||
// 查看隐患详情(流程链)
|
||||
const viewHazardDetail = (item) => {
|
||||
uni.navigateTo({
|
||||
url: `/pages/hiddendanger/detail2?hazardId=${item.hazardId}&assignId=${item.assignId || ''}`
|
||||
url: `/pages/hiddendanger/process-chain?hazardId=${item.hazardId}`
|
||||
})
|
||||
}
|
||||
|
||||
// 立即整改(待整改状态)
|
||||
const goRectification = (item) => {
|
||||
let url = `/pages/hiddendanger/rectification?hazardId=${item.hazardId}&assignId=${item.assignId}`
|
||||
if (item.deadline) {
|
||||
url += `&deadline=${encodeURIComponent(item.deadline)}`
|
||||
}
|
||||
if (item.assigneeId) {
|
||||
url += `&assigneeId=${item.assigneeId}`
|
||||
}
|
||||
if (item.assigneeName) {
|
||||
url += `&assigneeName=${encodeURIComponent(item.assigneeName)}`
|
||||
}
|
||||
uni.navigateTo({ url })
|
||||
uni.navigateTo({ url: buildRectificationUrl(item) });
|
||||
}
|
||||
|
||||
// 编辑整改信息(待验收状态)
|
||||
const editRectification = (item) => {
|
||||
uni.navigateTo({
|
||||
url: `/pages/hiddendanger/rectification?rectifyId=${item.rectifyId}&isEdit=1`
|
||||
})
|
||||
uni.navigateTo({ url: buildEditRectificationUrl(item) });
|
||||
}
|
||||
|
||||
// 立即验收
|
||||
const goAcceptance = (item) => {
|
||||
uni.navigateTo({
|
||||
url: `/pages/hiddendanger/acceptance?hazardId=${item.hazardId}&assignId=${item.assignId}&rectifyId=${item.rectifyId}`
|
||||
})
|
||||
uni.navigateTo({ url: buildAcceptanceUrl(item) });
|
||||
}
|
||||
|
||||
// 隐患交办
|
||||
const assignHazard = (item) => {
|
||||
uni.navigateTo({
|
||||
url: `/pages/hiddendanger/assignment?hazardId=${item.hazardId}&assignId=${item.assignId}`
|
||||
})
|
||||
uni.navigateTo({ url: buildAssignmentUrl(item) });
|
||||
}
|
||||
|
||||
// 销号申请
|
||||
const goWriteoffApply = (item) => {
|
||||
uni.navigateTo({ url: buildWriteoffApplyUrl(item) });
|
||||
};
|
||||
|
||||
// 销号审批
|
||||
const goWriteoffApproval = (item) => {
|
||||
uni.navigateTo({ url: buildWriteoffApprovalUrl(item) });
|
||||
};
|
||||
|
||||
// 切换账户
|
||||
const switchAccount = () => {
|
||||
uni.showToast({
|
||||
title: '切换账户功能开发中',
|
||||
icon: 'none'
|
||||
// 跳转身份切换页
|
||||
const goSwitchIdentity = () => {
|
||||
uni.navigateTo({
|
||||
url: '/pages/personalcenter/identity'
|
||||
});
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@@ -642,13 +854,22 @@
|
||||
color: rgba(255, 255, 255, 0.9);
|
||||
margin-top: 10rpx;
|
||||
}
|
||||
|
||||
.user-identity {
|
||||
font-size: 24rpx;
|
||||
color: rgba(255, 255, 255, 0.85);
|
||||
margin-top: 8rpx;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
}
|
||||
|
||||
.switch-btn {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
background: #fff;
|
||||
padding: 16rpx 24rpx;
|
||||
padding: 8rpx 24rpx;
|
||||
border-radius: 30rpx;
|
||||
color: #285CE9;
|
||||
font-size: 26rpx;
|
||||
@@ -896,6 +1117,10 @@
|
||||
margin-left: 10rpx;
|
||||
}
|
||||
|
||||
.workbench-tab-list {
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.danger-tab-item {
|
||||
font-size: 28rpx;
|
||||
color: #666;
|
||||
|
||||
@@ -31,9 +31,9 @@
|
||||
<text>手机:{{ item.phonenumber || '未设置' }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<button class="btn-lock bg-blue" @click="Lock(item)">
|
||||
<!-- <button class="btn-lock bg-blue" @click="Lock(item)">
|
||||
{{ item.status === '1' ? '解锁' : '锁定' }}
|
||||
</button>
|
||||
</button> -->
|
||||
</view>
|
||||
</view>
|
||||
|
||||
|
||||
321
pages/personalcenter/identity.vue
Normal file
321
pages/personalcenter/identity.vue
Normal file
@@ -0,0 +1,321 @@
|
||||
<template>
|
||||
<view class="page">
|
||||
<!-- 当前生效身份 -->
|
||||
<view v-if="currentIdentity" class="current-banner">
|
||||
<view class="banner-label">当前生效身份</view>
|
||||
<view class="banner-name">{{ getIdentityTitle(currentIdentity) }}</view>
|
||||
<view class="banner-sub">{{ getIdentitySubtitle(currentIdentity) }}</view>
|
||||
</view>
|
||||
|
||||
<!-- 加载中 -->
|
||||
<view v-if="loading" class="state-box">
|
||||
<u-loading-icon mode="circle" color="#007aff"></u-loading-icon>
|
||||
<text class="state-text">加载中...</text>
|
||||
</view>
|
||||
|
||||
<!-- 空状态 -->
|
||||
<view v-else-if="!identityList.length" class="state-box">
|
||||
<text class="state-text">暂无可用身份</text>
|
||||
</view>
|
||||
|
||||
<!-- 身份列表 -->
|
||||
<view v-else class="identity-list">
|
||||
<view
|
||||
v-for="item in identityList"
|
||||
:key="item.identityId"
|
||||
class="identity-card"
|
||||
:class="{
|
||||
'is-current': isCurrentIdentity(item),
|
||||
'is-default': item.isDefault
|
||||
}"
|
||||
>
|
||||
<view class="card-header">
|
||||
<view class="card-title">{{ getIdentityTitle(item) }}</view>
|
||||
<view class="card-tags">
|
||||
<view v-if="isCurrentIdentity(item)" class="tag tag-current">当前使用</view>
|
||||
<view v-if="item.isDefault" class="tag tag-default">默认</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="info-list">
|
||||
<view class="info-row">
|
||||
<text class="info-label">所属部门</text>
|
||||
<text class="info-value">{{ item.deptName || '-' }}</text>
|
||||
</view>
|
||||
<view class="info-row">
|
||||
<text class="info-label">所属角色</text>
|
||||
<text class="info-value">{{ item.roleName || '-' }}</text>
|
||||
</view>
|
||||
<view class="info-row">
|
||||
<text class="info-label">角色标识</text>
|
||||
<text class="info-value">{{ item.roleKey || '-' }}</text>
|
||||
</view>
|
||||
<view v-if="item.postName" class="info-row">
|
||||
<text class="info-label">所属岗位</text>
|
||||
<text class="info-value">{{ item.postName }}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<button
|
||||
class="switch-btn"
|
||||
:class="{ 'switch-btn--disabled': isCurrentIdentity(item) }"
|
||||
:loading="switchingId === item.identityId"
|
||||
:disabled="isCurrentIdentity(item) || !!switchingId"
|
||||
@click="handleSwitch(item)"
|
||||
>
|
||||
{{ isCurrentIdentity(item) ? '当前使用中' : '切换到此身份' }}
|
||||
</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue';
|
||||
import { onShow } from '@dcloudio/uni-app';
|
||||
import { getMyIdentity } from '@/request/identity.js';
|
||||
import { performIdentitySwitch, reLaunchAfterSwitch } from '@/utils/identitySwitch.js';
|
||||
|
||||
const loading = ref(false);
|
||||
const switchingId = ref(null);
|
||||
const identityList = ref([]);
|
||||
const currentIdentity = ref(null);
|
||||
|
||||
function unwrapIdentityData(res) {
|
||||
if (!res) return { identities: [], currentIdentity: null };
|
||||
const data = res.data && typeof res.data === 'object' ? res.data : res;
|
||||
return {
|
||||
identities: data.identities || [],
|
||||
currentIdentity: data.currentIdentity || null
|
||||
};
|
||||
}
|
||||
|
||||
function getIdentityTitle(item) {
|
||||
return item.identityName || item.roleName || '未命名身份';
|
||||
}
|
||||
|
||||
function getIdentitySubtitle(item) {
|
||||
const parts = [];
|
||||
if (item.deptName) parts.push(item.deptName);
|
||||
if (item.roleName && item.roleName !== item.identityName) parts.push(item.roleName);
|
||||
return parts.join(' · ') || '-';
|
||||
}
|
||||
|
||||
function isCurrentIdentity(item) {
|
||||
if (item.current) return true;
|
||||
return currentIdentity.value && currentIdentity.value.identityId === item.identityId;
|
||||
}
|
||||
|
||||
async function fetchIdentityList() {
|
||||
loading.value = true;
|
||||
try {
|
||||
const res = await getMyIdentity();
|
||||
if (res.code === 0 || res.code === 200) {
|
||||
const { identities, currentIdentity: current } = unwrapIdentityData(res);
|
||||
identityList.value = identities;
|
||||
currentIdentity.value = current;
|
||||
} else {
|
||||
identityList.value = [];
|
||||
currentIdentity.value = null;
|
||||
uni.showToast({ title: res.msg || '获取身份列表失败', icon: 'none' });
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('获取身份列表失败:', e);
|
||||
identityList.value = [];
|
||||
currentIdentity.value = null;
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function handleSwitch(item) {
|
||||
if (isCurrentIdentity(item) || switchingId.value) return;
|
||||
|
||||
const identityName = getIdentityTitle(item);
|
||||
const confirmMsg = `确认切换到「${identityName}」吗?切换后数据将按新身份刷新。`;
|
||||
|
||||
uni.showModal({
|
||||
title: '切换身份',
|
||||
content: confirmMsg,
|
||||
confirmText: '确认切换',
|
||||
success: async (modalRes) => {
|
||||
if (!modalRes.confirm) return;
|
||||
|
||||
switchingId.value = item.identityId;
|
||||
try {
|
||||
await performIdentitySwitch(item.identityId);
|
||||
reLaunchAfterSwitch();
|
||||
} catch (e) {
|
||||
console.error('身份切换失败:', e);
|
||||
} finally {
|
||||
switchingId.value = null;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
onShow(() => {
|
||||
fetchIdentityList();
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.page {
|
||||
min-height: 100vh;
|
||||
background: #f4f7fb;
|
||||
padding: 24rpx;
|
||||
padding-bottom: 48rpx;
|
||||
}
|
||||
|
||||
.current-banner {
|
||||
background: linear-gradient(135deg, #3e95f1 0%, #4269f5 100%);
|
||||
border-radius: 20rpx;
|
||||
padding: 32rpx;
|
||||
margin-bottom: 24rpx;
|
||||
color: #fff;
|
||||
|
||||
.banner-label {
|
||||
font-size: 24rpx;
|
||||
opacity: 0.85;
|
||||
}
|
||||
|
||||
.banner-name {
|
||||
font-size: 34rpx;
|
||||
font-weight: bold;
|
||||
margin-top: 12rpx;
|
||||
}
|
||||
|
||||
.banner-sub {
|
||||
font-size: 26rpx;
|
||||
opacity: 0.9;
|
||||
margin-top: 8rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.state-box {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 120rpx 0;
|
||||
|
||||
.state-text {
|
||||
margin-top: 24rpx;
|
||||
font-size: 28rpx;
|
||||
color: #999;
|
||||
}
|
||||
}
|
||||
|
||||
.identity-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 24rpx;
|
||||
}
|
||||
|
||||
.identity-card {
|
||||
background: #fff;
|
||||
border-radius: 20rpx;
|
||||
padding: 32rpx;
|
||||
border: 2rpx solid transparent;
|
||||
box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.04);
|
||||
|
||||
&.is-current {
|
||||
border-color: #67c23a;
|
||||
}
|
||||
|
||||
&.is-default {
|
||||
border-color: #e6a23c;
|
||||
}
|
||||
|
||||
&.is-current.is-default {
|
||||
border-color: #67c23a;
|
||||
}
|
||||
}
|
||||
|
||||
.card-header {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
gap: 16rpx;
|
||||
margin-bottom: 24rpx;
|
||||
}
|
||||
|
||||
.card-title {
|
||||
flex: 1;
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.card-tags {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8rpx;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.tag {
|
||||
font-size: 22rpx;
|
||||
padding: 4rpx 12rpx;
|
||||
border-radius: 8rpx;
|
||||
}
|
||||
|
||||
.tag-current {
|
||||
background: #e8f8ef;
|
||||
color: #67c23a;
|
||||
}
|
||||
|
||||
.tag-default {
|
||||
background: #fdf6ec;
|
||||
color: #e6a23c;
|
||||
}
|
||||
|
||||
.info-list {
|
||||
margin-bottom: 28rpx;
|
||||
}
|
||||
|
||||
.info-row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: flex-start;
|
||||
padding: 16rpx 0;
|
||||
border-bottom: 1rpx dashed #eee;
|
||||
font-size: 28rpx;
|
||||
|
||||
&:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
}
|
||||
|
||||
.info-label {
|
||||
color: #999;
|
||||
flex-shrink: 0;
|
||||
margin-right: 24rpx;
|
||||
}
|
||||
|
||||
.info-value {
|
||||
color: #333;
|
||||
text-align: right;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.switch-btn {
|
||||
width: 100%;
|
||||
height: 80rpx;
|
||||
line-height: 80rpx;
|
||||
background: linear-gradient(90deg, #3e95f1 0%, #4269f5 100%);
|
||||
color: #fff;
|
||||
font-size: 30rpx;
|
||||
border-radius: 40rpx;
|
||||
border: none;
|
||||
|
||||
&::after {
|
||||
border: none;
|
||||
}
|
||||
|
||||
&--disabled {
|
||||
background: #e8e8e8;
|
||||
color: #999;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user