<template>
|
<view class="danger-investigation-acceptance">
|
<PageHeader title="隐患验收"
|
@back="goBack" />
|
<view class="section">
|
<view class="section-title">隐患信息</view>
|
<view class="info-item">
|
<text class="info-label">隐患编号</text>
|
<text class="info-value">{{ form.hiddenCode || '-' }}</text>
|
</view>
|
<view class="info-item">
|
<text class="info-label">隐患类型</text>
|
<text class="info-value">{{ hidden_danger_type.find(i => String(i.value) === String(form.type))?.label || '-' }}</text>
|
</view>
|
<view class="info-item">
|
<text class="info-label">风险等级</text>
|
<text class="info-value">{{ form.riskLevel || '-' }}</text>
|
</view>
|
<view class="info-item">
|
<text class="info-label">隐患描述</text>
|
<text class="info-value">{{ form.hiddenDesc || '-' }}</text>
|
</view>
|
<view class="info-item">
|
<text class="info-label">隐患具体位置</text>
|
<text class="info-value">{{ form.location || '-' }}</text>
|
</view>
|
<view class="info-item">
|
<text class="info-label">上报人</text>
|
<text class="info-value">{{ form.createUserName || '-' }}</text>
|
</view>
|
<view class="info-item">
|
<text class="info-label">上报时间</text>
|
<text class="info-value">{{ form.createTime || '-' }}</text>
|
</view>
|
<view class="info-item">
|
<text class="info-label">整改完成期限</text>
|
<text class="info-value">{{ form.rectifyTime || '-' }}</text>
|
</view>
|
<view class="info-item">
|
<text class="info-label">整改责任人</text>
|
<text class="info-value">{{ form.rectifyUserName || '-' }}</text>
|
</view>
|
<view class="info-item">
|
<text class="info-label">整改责任人联系方式</text>
|
<text class="info-value">{{ form.rectifyUserMobile || '-' }}</text>
|
</view>
|
<view class="info-item">
|
<text class="info-label">整改具体措施</text>
|
<text class="info-value">{{ form.rectifyMeasures || '-' }}</text>
|
</view>
|
<view class="info-item">
|
<text class="info-label">实际整改完成时间</text>
|
<text class="info-value">{{ form.rectifyActualTime || '-' }}</text>
|
</view>
|
</view>
|
<u-form @submit="handleSubmit"
|
ref="formRef"
|
label-width="110">
|
<!-- 验收信息 -->
|
<u-cell-group title="验收信息">
|
<u-form-item label="验收时间"
|
prop="verifyTime"
|
border-bottom>
|
<u-input v-model="form.verifyTime"
|
placeholder="请选择验收时间"
|
disabled />
|
</u-form-item>
|
<u-form-item label="验收人"
|
prop="verifyUserName"
|
border-bottom>
|
<u-input v-model="form.verifyUserName"
|
disabled
|
placeholder="请输入验收人" />
|
</u-form-item>
|
<u-form-item label="验收结果"
|
prop="verifyResult"
|
required
|
border-bottom>
|
<u-input v-model="verifyResultName"
|
placeholder="请选择验收结果"
|
@click="showVerifyResultSheet"
|
readonly />
|
<template #right>
|
<up-icon name="arrow-right"
|
@click="showVerifyResultSheet"></up-icon>
|
</template>
|
</u-form-item>
|
<u-form-item label="验收意见"
|
prop="verifyRemark"
|
required
|
border-bottom>
|
<u-textarea v-model="form.verifyRemark"
|
placeholder="请输入验收意见"
|
:maxlength="200"
|
count
|
:autoHeight="true" />
|
</u-form-item>
|
</u-cell-group>
|
<!-- 提交按钮 -->
|
<view class="footer-btns">
|
<u-button class="cancel-btn"
|
@click="goBack">取消</u-button>
|
<u-button class="sign-btn"
|
type="primary"
|
@click="handleSubmit"
|
:loading="loading">提交验收</u-button>
|
</view>
|
</u-form>
|
<!-- 时间选择器 -->
|
<up-datetime-picker :show="showTime"
|
v-model="currentTime"
|
@confirm="onTimeConfirm"
|
@cancel="showTime = false"
|
mode="date" />
|
<!-- 验收结果选择器 -->
|
<up-action-sheet :show="verifyResultSheetVisible"
|
:actions="verifyResultOptions"
|
@select="handleVerifyResultSelect"
|
title="选择验收结果" />
|
</view>
|
</template>
|
|
<script setup>
|
// 替换 toast 方法
|
defineOptions({ name: "danger-investigation-acceptance" });
|
const showToast = message => {
|
uni.showToast({
|
title: message,
|
icon: "none",
|
});
|
};
|
|
import { ref, onMounted } from "vue";
|
import PageHeader from "@/components/PageHeader.vue";
|
import { safeHiddenUpdate } from "@/api/safeProduction/dangerInvestigation";
|
import useUserStore from "@/store/modules/user";
|
import dayjs from "dayjs";
|
import { onLoad } from "@dcloudio/uni-app";
|
import { useDict } from "@/utils/dict";
|
|
const { hidden_danger_type } = useDict("hidden_danger_type");
|
const userStore = useUserStore();
|
|
// 表单数据
|
const form = ref({
|
id: "",
|
hiddenCode: "",
|
hiddenDesc: "",
|
location: "",
|
rectifyTime: "",
|
rectifyActualTime: "",
|
rectifyResult: "",
|
verifyTime: "",
|
verifyRemark: "",
|
verifyResult: "",
|
});
|
|
// 页面状态
|
const loading = ref(false);
|
const formRef = ref(null);
|
|
// 时间相关
|
const currentTime = ref(Date.now());
|
const showTime = ref(false);
|
|
// 验收结果选择器
|
const verifyResultSheetVisible = ref(false);
|
const verifyResultName = ref("");
|
const verifyResultOptions = ref([
|
{ value: "通过", name: "通过" },
|
{ value: "不通过", name: "不通过" },
|
]);
|
const showVerifyResultSheet = () => {
|
verifyResultSheetVisible.value = true;
|
};
|
const handleVerifyResultSelect = item => {
|
form.value.verifyResult = item.value;
|
verifyResultName.value = item.name;
|
verifyResultSheetVisible.value = false;
|
};
|
|
// 返回上一页
|
const goBack = () => {
|
// 返回时清除本地存储的数据
|
uni.removeStorageSync("dangerInvestigation");
|
uni.navigateBack();
|
};
|
|
// 显示时间选择器
|
const showTimePicker = () => {
|
showTime.value = true;
|
};
|
|
// 确认时间选择
|
const onTimeConfirm = e => {
|
form.value.verifyTime = dayjs(e.value).format("YYYY-MM-DD");
|
currentTime.value = e.value;
|
showTime.value = false;
|
};
|
|
// 提交表单
|
const handleSubmit = async () => {
|
if (!form.value.verifyRemark) {
|
showToast("请输入验收意见");
|
return;
|
}
|
|
if (!form.value.verifyResult) {
|
showToast("请选择验收结果");
|
return;
|
}
|
|
try {
|
loading.value = true;
|
|
// 使用安全浅拷贝,避免对象展开在某些运行时抛错
|
const source =
|
form.value && typeof form.value === "object" ? form.value : {};
|
const submitData = {};
|
Object.keys(source).forEach(k => {
|
submitData[k] = source[k];
|
});
|
console.log("submitData", submitData);
|
|
const { code } = await safeHiddenUpdate(submitData);
|
if (code === 200) {
|
showToast("验收提交成功");
|
setTimeout(() => {
|
goBack();
|
}, 500);
|
} else {
|
loading.value = false;
|
showToast("验收提交失败,请重试");
|
}
|
} catch (e) {
|
loading.value = false;
|
console.error("提交失败:", e);
|
showToast("提交失败,请重试");
|
}
|
};
|
|
onLoad(() => {
|
// 从本地存储获取隐患数据
|
const dangerInvestigation = uni.getStorageSync("dangerInvestigation");
|
if (dangerInvestigation && dangerInvestigation.id) {
|
form.value = dangerInvestigation;
|
console.log("form.value", form.value);
|
} else {
|
showToast("暂无隐患数据");
|
}
|
});
|
|
// 初始化页面数据
|
const initPageData = () => {
|
// 设置默认验收时间为当前时间
|
if (!form.value.verifyTime) {
|
form.value.verifyTime = dayjs().format("YYYY-MM-DD");
|
currentTime.value = Date.now();
|
}
|
// 设置已选验收结果的显示文本
|
if (form.value.verifyResult) {
|
verifyResultName.value =
|
verifyResultOptions.value.find(
|
item => item.value === form.value.verifyResult
|
)?.name || "";
|
}
|
// 设置验收人
|
if (!form.value.verifyUserName) {
|
userStore.getInfo().then(res => {
|
form.value.verifyUserId = res.user.userId;
|
form.value.verifyUserName = res.user.nickName;
|
});
|
}
|
console.log("form.value", form.value);
|
};
|
|
onMounted(() => {
|
initPageData();
|
});
|
</script>
|
|
<style scoped lang="scss">
|
@import "@/static/scss/form-common.scss";
|
.danger-investigation-acceptance {
|
min-height: 100vh;
|
background-color: #f8f9fa;
|
padding-bottom: 160rpx;
|
}
|
.footer-btns {
|
position: fixed;
|
left: 0;
|
right: 0;
|
bottom: 0;
|
background: #fff;
|
display: flex;
|
justify-content: space-around;
|
align-items: center;
|
padding: 0.75rem 0;
|
box-shadow: 0 -0.125rem 0.5rem rgba(0, 0, 0, 0.05);
|
z-index: 1000;
|
}
|
|
.cancel-btn {
|
font-weight: 400;
|
font-size: 1rem;
|
color: #666;
|
background: #f5f5f5;
|
border: 1px solid #ddd;
|
width: 45%;
|
height: 2.5rem;
|
border-radius: 2.5rem 2.5rem 2.5rem 2.5rem;
|
}
|
|
.sign-btn {
|
font-weight: 500;
|
font-size: 1rem;
|
color: #fff;
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
border: none;
|
width: 45%;
|
height: 2.5rem;
|
border-radius: 2.5rem 2.5rem 2.5rem 2.5rem;
|
}
|
|
.section {
|
background-color: #ffffff;
|
margin-bottom: 16px;
|
overflow: hidden;
|
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
|
}
|
|
.section-title {
|
font-size: 16px;
|
font-weight: 600;
|
color: #333333;
|
padding: 16px 16px 12px;
|
border-bottom: 1px solid #f0f0f0;
|
}
|
|
.info-item {
|
display: flex;
|
padding: 14px 16px;
|
border-bottom: 1px solid #f8f8f8;
|
align-items: flex-start;
|
}
|
|
.info-item:last-child {
|
border-bottom: none;
|
}
|
|
.info-label {
|
font-size: 14px;
|
color: #666666;
|
min-width: 80px;
|
flex-shrink: 0;
|
line-height: 22px;
|
}
|
|
.info-value {
|
font-size: 14px;
|
color: #333333;
|
flex: 1;
|
line-height: 22px;
|
text-align: right;
|
}
|
|
.multi-line {
|
text-align: left;
|
word-break: break-all;
|
line-height: 1.6;
|
}
|
|
.remark-item {
|
padding-bottom: 16px;
|
}
|
</style>
|