v1.2.1版本,优化调整了很多,整改验收阶段新加字段
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
<template>
|
||||
<view class="padding page">
|
||||
<view class="padding bg-white radius margin-bottom card-item" v-for="(item,index) in hazardList" :key="index">
|
||||
<view class="padding bg-white radius margin-bottom card-item" v-for="item in hazardList" :key="item.hazardId || item.id">
|
||||
<view class="flex justify-between margin-bottom">
|
||||
<view class="text-bold text-black" style="flex: 1; margin-right: 16rpx;">{{item.hazardTitle}}</view>
|
||||
<view class="status-tag" :class="getStatusClass(item.verifyResultName)">{{item.verifyResultName || '未知'}}</view>
|
||||
<view class="status-tag" :class="getStatusClass(item)">{{item.verifyResultName || '未知'}}</view>
|
||||
</view>
|
||||
<view class="flex margin-bottom">
|
||||
<view class="text-gray">隐患日期:</view>
|
||||
@@ -24,7 +24,7 @@
|
||||
</view>
|
||||
<view class="flex justify-between">
|
||||
<view></view>
|
||||
<view><button class="bg-blue round cu-btn lg" @click="editor()">查看详情</button></view>
|
||||
<view><button class="bg-blue round cu-btn lg" @click="editor(item)">查看详情</button></view>
|
||||
</view>
|
||||
</view>
|
||||
<button class="cuIcon-add bg-blue round margin-top" @click="openAddPopup">新增</button>
|
||||
@@ -54,30 +54,17 @@
|
||||
<view class="flex margin-bottom margin-top">
|
||||
<view>整改时限</view>
|
||||
</view>
|
||||
<view class="picker-input" @click="showDatePicker = true">
|
||||
<text :class="formData.rectifyDeadline ? '' : 'text-gray'">{{ formData.rectifyDeadline || '请选择整改时限' }}</text>
|
||||
<view class="picker-input readonly">
|
||||
<text :class="formData.rectifyDeadline ? '' : 'text-gray'">{{ formData.rectifyDeadline || '请先选择隐患' }}</text>
|
||||
</view>
|
||||
<up-datetime-picker
|
||||
v-if="false" :show="showDatePicker"
|
||||
v-model="dateValue"
|
||||
mode="datetime"
|
||||
@confirm="onDateConfirm"
|
||||
@cancel="showDatePicker = false"
|
||||
@close="showDatePicker = false"
|
||||
></up-datetime-picker>
|
||||
<view class="margin-bottom margin-top">隐患治理责任单位</view>
|
||||
<view class="picker-input" @click="showDeptPicker = true">
|
||||
<text :class="selectedDeptName ? '' : 'text-gray'">{{ selectedDeptName || '请选择隐患治理责任单位' }}</text>
|
||||
<view class="picker-input readonly">
|
||||
<text :class="selectedDeptName ? '' : 'text-gray'">{{ selectedDeptName || '请先选择隐患' }}</text>
|
||||
</view>
|
||||
<up-picker
|
||||
v-if="false" :show="showDeptPicker"
|
||||
:columns="deptColumns"
|
||||
@confirm="onDeptConfirm"
|
||||
@cancel="showDeptPicker = false"
|
||||
@close="showDeptPicker = false"
|
||||
></up-picker>
|
||||
<view class="margin-bottom margin-top">主要负责人</view>
|
||||
<up-input v-model="formData.responsiblePerson" placeholder="请输入主要负责人"></up-input>
|
||||
<view class="picker-input readonly">
|
||||
<text :class="formData.responsiblePerson ? '' : 'text-gray'">{{ formData.responsiblePerson || '请先选择隐患' }}</text>
|
||||
</view>
|
||||
<view class="ai-btn-wrapper margin-top margin-bottom">
|
||||
<button class="ai-analyze-btn" :loading="aiGenerating" :disabled="aiGenerating" @click="handleAiGenerate">
|
||||
<text v-if="!aiGenerating" class="cuIcon-magic ai-btn-icon"></text>
|
||||
@@ -107,34 +94,16 @@
|
||||
@close="showHazardPicker = false"
|
||||
></up-picker>
|
||||
|
||||
<up-datetime-picker
|
||||
:show="showDatePicker"
|
||||
v-model="dateValue"
|
||||
mode="datetime"
|
||||
@confirm="onDateConfirm"
|
||||
@cancel="showDatePicker = false"
|
||||
@close="showDatePicker = false"
|
||||
></up-datetime-picker>
|
||||
|
||||
<up-picker
|
||||
:show="showDeptPicker"
|
||||
:columns="deptColumns"
|
||||
@confirm="onDeptConfirm"
|
||||
@cancel="showDeptPicker = false"
|
||||
@close="showDeptPicker = false"
|
||||
></up-picker>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, reactive, onMounted } from 'vue'
|
||||
import { getMyWriteOffList, applyDelete, getAcceptanceList, getDepartmentPersonUsers, getHiddenDangerDetail, getRectifyDetail, generateWriteoffContent } from '@/request/api.js';
|
||||
import { getMyWriteOffList, applyDelete, getAcceptanceList, getHiddenDangerDetail, getRectifyDetail, generateWriteoffContent } from '@/request/api.js';
|
||||
|
||||
// 弹窗控制
|
||||
const showAddPopup = ref(false);
|
||||
const showHazardPicker = ref(false);
|
||||
const showDatePicker = ref(false);
|
||||
const showDeptPicker = ref(false);
|
||||
|
||||
// 隐患选择
|
||||
const selectedHazard = ref('');
|
||||
@@ -143,14 +112,8 @@
|
||||
const acceptanceHazardList = ref([]); // 存储可申请销号的隐患数据
|
||||
const hazardList = ref([]); // 存储销号申请列表
|
||||
|
||||
// 部门选择
|
||||
// 隐患关联的只读展示字段
|
||||
const selectedDeptName = ref('');
|
||||
const selectedDeptId = ref('');
|
||||
const deptColumns = ref([['暂无数据']]);
|
||||
const deptList = ref([]); // 存储部门列表
|
||||
|
||||
// 日期选择
|
||||
const dateValue = ref(Date.now());
|
||||
|
||||
// AI生成状态
|
||||
const aiGenerating = ref(false);
|
||||
@@ -198,94 +161,41 @@
|
||||
}
|
||||
};
|
||||
|
||||
// 获取部门列表
|
||||
const fetchDeptList = async () => {
|
||||
try {
|
||||
const res = await getDepartmentPersonUsers();
|
||||
if (res.code === 0 && res.data) {
|
||||
const users = [];
|
||||
res.data.forEach(dept => {
|
||||
if (dept.users && dept.users.length > 0) {
|
||||
dept.users.forEach(user => {
|
||||
users.push({
|
||||
userId: user.userId,
|
||||
deptId: dept.deptId,
|
||||
name: `${user.nickName}(${dept.deptName})`
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
deptList.value = users;
|
||||
// 转换为 picker 需要的格式
|
||||
if (users.length > 0) {
|
||||
deptColumns.value = [users.map(item => item.name)];
|
||||
} else {
|
||||
deptColumns.value = [['暂无人员数据']];
|
||||
}
|
||||
console.log('部门人员列表:', users);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取部门人员列表失败:', error);
|
||||
}
|
||||
};
|
||||
|
||||
// 部门选择确认
|
||||
const onDeptConfirm = (e) => {
|
||||
console.log('选择的人员:', e);
|
||||
if (e.value && e.value.length > 0) {
|
||||
selectedDeptName.value = e.value[0];
|
||||
// 找到对应的用户ID和部门ID
|
||||
const index = e.indexs[0];
|
||||
if (deptList.value[index]) {
|
||||
selectedDeptId.value = deptList.value[index].deptId;
|
||||
formData.responsibleDeptId = deptList.value[index].deptId;
|
||||
}
|
||||
}
|
||||
showDeptPicker.value = false;
|
||||
};
|
||||
|
||||
// 打开新增弹窗
|
||||
const openAddPopup = () => {
|
||||
resetForm();
|
||||
fetchAcceptanceList(); // 获取可申请销号的隐患列表
|
||||
fetchDeptList(); // 获取部门列表
|
||||
showAddPopup.value = true;
|
||||
};
|
||||
|
||||
// 根据选中的隐患回显只读字段
|
||||
const fillHazardRelatedFields = (hazard) => {
|
||||
formData.rectifyDeadline = hazard.deadline || '';
|
||||
selectedDeptName.value = hazard.deptName || '';
|
||||
formData.responsiblePerson = hazard.rectifierName || '';
|
||||
formData.responsibleDeptId = hazard.deptId || '';
|
||||
};
|
||||
|
||||
// 隐患选择确认
|
||||
const onHazardConfirm = (e) => {
|
||||
console.log('选择的隐患:', e);
|
||||
if (e.value && e.value.length > 0) {
|
||||
selectedHazard.value = e.value[0];
|
||||
// 找到对应的隐患ID
|
||||
const index = e.indexs[0];
|
||||
if (acceptanceHazardList.value[index]) {
|
||||
selectedHazardId.value = acceptanceHazardList.value[index].hazardId;
|
||||
const hazard = acceptanceHazardList.value[index];
|
||||
if (hazard) {
|
||||
selectedHazardId.value = hazard.hazardId;
|
||||
fillHazardRelatedFields(hazard);
|
||||
}
|
||||
}
|
||||
showHazardPicker.value = false;
|
||||
};
|
||||
|
||||
// 日期时间选择确认
|
||||
const onDateConfirm = (e) => {
|
||||
console.log('选择的日期时间:', e);
|
||||
const date = new Date(e.value);
|
||||
const year = date.getFullYear();
|
||||
const month = String(date.getMonth() + 1).padStart(2, '0');
|
||||
const day = String(date.getDate()).padStart(2, '0');
|
||||
const hours = String(date.getHours()).padStart(2, '0');
|
||||
const minutes = String(date.getMinutes()).padStart(2, '0');
|
||||
const seconds = String(date.getSeconds()).padStart(2, '0');
|
||||
formData.rectifyDeadline = `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
|
||||
showDatePicker.value = false;
|
||||
};
|
||||
|
||||
// 重置表单
|
||||
const resetForm = () => {
|
||||
selectedHazard.value = '';
|
||||
selectedHazardId.value = '';
|
||||
selectedDeptName.value = '';
|
||||
selectedDeptId.value = '';
|
||||
formData.rectifyDeadline = '';
|
||||
formData.responsibleDeptId = '';
|
||||
formData.responsiblePerson = '';
|
||||
@@ -386,20 +296,26 @@
|
||||
}
|
||||
};
|
||||
|
||||
const editor = () => {
|
||||
const editor = (item) => {
|
||||
if (!item?.id) {
|
||||
uni.showToast({ title: '缺少申请ID', icon: 'none' });
|
||||
return;
|
||||
}
|
||||
uni.navigateTo({
|
||||
url: '/pages/closeout/editor'
|
||||
})
|
||||
url: `/pages/closeout/editor?applyId=${item.id}`
|
||||
});
|
||||
};
|
||||
|
||||
// 根据审核状态返回对应样式类
|
||||
const getStatusClass = (status) => {
|
||||
switch (status) {
|
||||
case '待审核': return 'status-pending';
|
||||
case '已通过': return 'status-passed';
|
||||
case '已驳回': return 'status-rejected';
|
||||
default: return 'status-pending';
|
||||
}
|
||||
const getStatusClass = (item) => {
|
||||
const statusName = item?.verifyResultName || '';
|
||||
if (statusName === '待审核') return 'status-pending';
|
||||
if (statusName === '审核通过' || statusName === '已通过') return 'status-passed';
|
||||
if (statusName === '审核驳回' || statusName === '已驳回') return 'status-rejected';
|
||||
if (statusName === '已重新申请') return 'status-reapply';
|
||||
if (item?.verifyResult === 1) return 'status-passed';
|
||||
if (item?.verifyResult === 2) return 'status-rejected';
|
||||
return 'status-default';
|
||||
};
|
||||
|
||||
// 页面加载时获取销号申请列表
|
||||
@@ -441,6 +357,16 @@
|
||||
color: #F5222D;
|
||||
}
|
||||
|
||||
.status-reapply {
|
||||
background: #E6F7FF;
|
||||
color: #1890FF;
|
||||
}
|
||||
|
||||
.status-default {
|
||||
background: #F5F5F5;
|
||||
color: #8C8C8C;
|
||||
}
|
||||
|
||||
.popup-content {
|
||||
width: 600rpx;
|
||||
background: #fff;
|
||||
@@ -534,12 +460,15 @@
|
||||
border-radius: 8rpx;
|
||||
padding: 24rpx 20rpx;
|
||||
margin-bottom: 20rpx;
|
||||
// border: 1rpx solid #F6F6F6;
|
||||
border: 1rpx solid #eee;
|
||||
|
||||
text {
|
||||
font-size: 28rpx;
|
||||
// color: #333;
|
||||
}
|
||||
|
||||
&.readonly {
|
||||
background: #f5f5f5;
|
||||
color: #666;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -1,132 +1,138 @@
|
||||
<template>
|
||||
<view class="padding page">
|
||||
<view class="padding bg-white radius">
|
||||
<view class="flex margin-bottom">
|
||||
<view class="text-gray">隐患</view>
|
||||
</view>
|
||||
<up-input v-model="formData.hazardTitle" placeholder="" disabled></up-input>
|
||||
<view class="text-gray margin-bottom margin-top">隐患日期</view>
|
||||
<up-input v-model="formData.hazardCreatedAt" placeholder="" disabled></up-input>
|
||||
<view class="text-gray margin-bottom">隐患名称</view>
|
||||
<up-input v-model="formData.hazardName" placeholder="暂无" disabled></up-input>
|
||||
|
||||
<view class="text-gray margin-bottom margin-top">整改时限</view>
|
||||
<up-input v-model="formData.deadline" placeholder="暂无" disabled></up-input>
|
||||
|
||||
<view class="text-gray margin-bottom margin-top">隐患治理责任单位</view>
|
||||
<up-input v-model="formData.responsibleDeptName" placeholder="请输入" :disabled="!canEdit"></up-input>
|
||||
<up-input v-model="formData.responsibilityUnit" placeholder="暂无" disabled></up-input>
|
||||
|
||||
<view class="text-gray margin-bottom margin-top">主要负责人</view>
|
||||
<up-input v-model="formData.responsiblePerson" placeholder="请输入" :disabled="!canEdit"></up-input>
|
||||
<view class="text-gray margin-bottom margin-top">创建时间</view>
|
||||
<up-input v-model="formData.createdAt" placeholder="" disabled></up-input>
|
||||
<up-input v-model="formData.mainPerson" placeholder="暂无" disabled></up-input>
|
||||
|
||||
<view class="text-gray margin-bottom margin-top">主要治理内容</view>
|
||||
<up-textarea v-model="formData.mainGovernanceContent" placeholder="暂无" disabled autoHeight></up-textarea>
|
||||
|
||||
<view class="text-gray margin-bottom margin-top">隐患治理完成内容</view>
|
||||
<up-textarea v-model="formData.governanceCompleteContent" placeholder="暂无" disabled autoHeight></up-textarea>
|
||||
|
||||
<view class="text-gray margin-bottom margin-top">状态</view>
|
||||
<up-input v-model="formData.statusName" placeholder="" disabled></up-input>
|
||||
<view class="flex justify-center margin-top-xl" style="gap: 30rpx;">
|
||||
<up-input :modelValue="statusText" placeholder="暂无" disabled></up-input>
|
||||
|
||||
<template v-if="hasRejectReason">
|
||||
<view class="text-gray margin-bottom margin-top">驳回理由</view>
|
||||
<up-textarea v-model="formData.rejectReason" placeholder="暂无" disabled autoHeight></up-textarea>
|
||||
</template>
|
||||
|
||||
<template v-if="hasSignature">
|
||||
<view class="text-gray margin-bottom margin-top">电子签名</view>
|
||||
<view class="signature-box">
|
||||
<image
|
||||
:src="signatureUrl"
|
||||
class="signature-img"
|
||||
mode="aspectFit"
|
||||
@click="previewSignature"
|
||||
@error="onSignatureImageError"
|
||||
></image>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<view class="flex justify-center margin-top-xl">
|
||||
<button class="round cu-btn lg" @click="handleCancel">返回</button>
|
||||
<!-- <button v-if="canEdit" class="bg-blue round cu-btn lg" @click="handleSubmit">保存</button> -->
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, reactive, onMounted } from 'vue'
|
||||
import { ref, reactive, computed } from 'vue'
|
||||
import { onLoad } from '@dcloudio/uni-app'
|
||||
import {getMyWriteOffList } from '@/request/api.js';
|
||||
|
||||
// 获取页面参数的方法
|
||||
const getPageOptions = () => {
|
||||
const pages = getCurrentPages();
|
||||
const currentPage = pages[pages.length - 1];
|
||||
return currentPage?.options || {};
|
||||
};
|
||||
|
||||
// 页面参数
|
||||
const pageId = ref('');
|
||||
const canEdit = ref(false); // 是否可编辑(待审核状态可编辑)
|
||||
|
||||
// 表单数据
|
||||
import { getWriteOffApplyDetail } from '@/request/api.js'
|
||||
import { toSubmitFileUrl } from '@/utils/upload.js'
|
||||
|
||||
const applyId = ref('')
|
||||
const signatureUrl = ref('')
|
||||
|
||||
const formData = reactive({
|
||||
id: '',
|
||||
hazardId: '',
|
||||
hazardTitle: '', // 隐患标题
|
||||
hazardCreatedAt: '', // 隐患日期
|
||||
responsibleDeptName: '', // 隐患治理责任单位
|
||||
responsiblePerson: '', // 主要负责人
|
||||
createdAt: '', // 创建时间
|
||||
statusName: '' // 状态
|
||||
hazardName: '',
|
||||
deadline: '',
|
||||
responsibilityUnit: '',
|
||||
mainPerson: '',
|
||||
mainGovernanceContent: '',
|
||||
governanceCompleteContent: '',
|
||||
status: '',
|
||||
rejectReason: ''
|
||||
})
|
||||
|
||||
const statusText = computed(() => {
|
||||
const val = Number(formData.status);
|
||||
if (val === 1) return '通过';
|
||||
if (val === 2) return '不通过';
|
||||
return '';
|
||||
});
|
||||
|
||||
// 获取详情
|
||||
|
||||
const hasRejectReason = computed(() => Boolean(String(formData.rejectReason || '').trim()));
|
||||
const hasSignature = computed(() => Boolean(signatureUrl.value));
|
||||
|
||||
const applySignature = (signPath) => {
|
||||
signatureUrl.value = signPath ? toSubmitFileUrl(signPath) : ''
|
||||
}
|
||||
|
||||
const previewSignature = () => {
|
||||
if (!signatureUrl.value) return
|
||||
uni.previewImage({
|
||||
urls: [signatureUrl.value],
|
||||
current: signatureUrl.value
|
||||
})
|
||||
}
|
||||
|
||||
const onSignatureImageError = () => {
|
||||
console.error('签名图片加载失败:', signatureUrl.value)
|
||||
}
|
||||
|
||||
const fetchDetail = async (id) => {
|
||||
console.log('=== fetchDetail 被调用 ===, id:', id);
|
||||
if (!id) {
|
||||
uni.showToast({ title: '缺少申请ID', icon: 'none' })
|
||||
return
|
||||
}
|
||||
try {
|
||||
const res = await getMyWriteOffList();
|
||||
console.log('接口返回:', res);
|
||||
if (res.code === 0 && res.data && res.data.length > 0) {
|
||||
const list = res.data;
|
||||
// 如果有 id 就按 id 找,否则取第一条
|
||||
let data = null;
|
||||
if (id) {
|
||||
data = list.find(item => item.id == id);
|
||||
}
|
||||
// 如果没找到,取第一条
|
||||
if (!data) {
|
||||
data = list[0];
|
||||
}
|
||||
|
||||
console.log('绑定数据:', data);
|
||||
// 绑定数据
|
||||
formData.id = data.id;
|
||||
formData.hazardId = data.hazardId;
|
||||
formData.hazardTitle = data.hazardTitle || '';
|
||||
formData.hazardCreatedAt = data.hazardCreatedAt || '';
|
||||
formData.responsibleDeptName = data.responsibleDeptName || '';
|
||||
formData.responsiblePerson = data.responsiblePerson || '';
|
||||
formData.createdAt = data.createdAt || '';
|
||||
formData.statusName = data.statusName || '';
|
||||
|
||||
// 根据返回数据的状态判断是否可编辑(待审核 status=1 可编辑)
|
||||
if (data.status == 1 || data.statusName === '待审核') {
|
||||
canEdit.value = true;
|
||||
console.log('状态为待审核,可以编辑');
|
||||
} else {
|
||||
canEdit.value = false;
|
||||
console.log('状态为已审核,不可编辑');
|
||||
}
|
||||
uni.showLoading({ title: '加载中...' })
|
||||
const res = await getWriteOffApplyDetail(id)
|
||||
if (res.code === 0 && res.data) {
|
||||
const data = res.data
|
||||
formData.hazardId = data.hazardId || ''
|
||||
formData.hazardName = data.hazardName || ''
|
||||
formData.deadline = data.deadline || ''
|
||||
formData.responsibilityUnit = data.responsibilityUnit || ''
|
||||
formData.mainPerson = data.mainPerson || ''
|
||||
formData.mainGovernanceContent = data.mainGovernanceContent || ''
|
||||
formData.governanceCompleteContent = data.governanceCompleteContent || ''
|
||||
formData.status = data.status ?? ''
|
||||
formData.rejectReason = data.rejectReason || ''
|
||||
applySignature(data.signPath)
|
||||
} else {
|
||||
uni.showToast({ title: res.msg || '获取详情失败', icon: 'none' })
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取详情失败:', error);
|
||||
console.error('获取销号申请详情失败:', error)
|
||||
uni.showToast({ title: '获取详情失败', icon: 'none' })
|
||||
} finally {
|
||||
uni.hideLoading()
|
||||
}
|
||||
};
|
||||
|
||||
// 返回
|
||||
}
|
||||
|
||||
const handleCancel = () => {
|
||||
uni.navigateBack();
|
||||
};
|
||||
|
||||
// 保存
|
||||
const handleSubmit = async () => {
|
||||
console.log('保存数据:', formData);
|
||||
// TODO: 调用更新接口
|
||||
uni.showToast({ title: '保存成功', icon: 'success' });
|
||||
setTimeout(() => {
|
||||
uni.navigateBack();
|
||||
}, 1500);
|
||||
};
|
||||
|
||||
// 页面加载
|
||||
uni.navigateBack()
|
||||
}
|
||||
|
||||
onLoad((options) => {
|
||||
console.log('=== onLoad 触发 ===');
|
||||
console.log('options:', options);
|
||||
pageId.value = options?.id || '';
|
||||
fetchDetail(pageId.value);
|
||||
});
|
||||
|
||||
// 备用:onMounted
|
||||
onMounted(() => {
|
||||
console.log('=== onMounted 触发 ===');
|
||||
if (!pageId.value) {
|
||||
const options = getPageOptions();
|
||||
console.log('备用获取参数:', options);
|
||||
pageId.value = options?.id || '';
|
||||
fetchDetail(pageId.value);
|
||||
}
|
||||
});
|
||||
applyId.value = options?.applyId || ''
|
||||
fetchDetail(applyId.value)
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@@ -134,5 +140,18 @@
|
||||
min-height: 100vh;
|
||||
background: #EBF2FC;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
.signature-box {
|
||||
width: 100%;
|
||||
height: 240rpx;
|
||||
background: #f8f8f8;
|
||||
border: 1rpx dashed #dcdfe6;
|
||||
border-radius: 8rpx;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.signature-img {
|
||||
width: 100%;
|
||||
height: 240rpx;
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user