v1.2.1版本,优化调整了很多,整改验收阶段新加字段
This commit is contained in:
@@ -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