<template>
|
<view class="repair-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">{{ detail.deviceName || '-' }}</text>
|
</view>
|
<view class="info-item">
|
<text class="info-label">规格型号</text>
|
<text class="info-value">{{ detail.deviceModel || '-' }}</text>
|
</view>
|
<view class="info-item">
|
<text class="info-label">报修日期</text>
|
<text class="info-value">{{ formatDate(detail.repairTime) || '-' }}</text>
|
</view>
|
<view class="info-item">
|
<text class="info-label">报修人</text>
|
<text class="info-value">{{ detail.repairName || '-' }}</text>
|
</view>
|
<view class="info-item">
|
<text class="info-label">维修人</text>
|
<text class="info-value">{{ detail.maintenanceName || '-' }}</text>
|
</view>
|
<view class="info-item">
|
<text class="info-label">维修项目</text>
|
<text class="info-value">{{ detail.machineryCategory || '-' }}</text>
|
</view>
|
<view class="info-item">
|
<text class="info-label">故障现象</text>
|
<text class="info-value multi-line">{{ detail.remark || '-' }}</text>
|
</view>
|
<view class="info-item">
|
<text class="info-label">维修结果</text>
|
<text class="info-value multi-line">{{ detail.maintenanceResult || '-' }}</text>
|
</view>
|
<view class="info-item">
|
<text class="info-label">维修日期</text>
|
<text class="info-value">{{ formatDateTime(detail.maintenanceTime) || '-' }}</text>
|
</view>
|
</view>
|
<!-- 验收表单 -->
|
<u-form ref="formRef"
|
:model="form"
|
label-width="110">
|
<u-cell-group title="验收信息">
|
<u-form-item label="验收人"
|
prop="acceptanceName"
|
required
|
border-bottom>
|
<u-input v-model="form.acceptanceName"
|
disabled
|
placeholder="验收人" />
|
</u-form-item>
|
<u-form-item label="验收时间"
|
prop="acceptanceTime"
|
required
|
border-bottom>
|
<u-input v-model="form.acceptanceTime"
|
placeholder="请选择验收时间"
|
readonly
|
@click="showDatePicker = true" />
|
<template #right>
|
<u-icon name="arrow-right"
|
@click="showDatePicker = true"></u-icon>
|
</template>
|
</u-form-item>
|
<u-form-item label="验收备注"
|
prop="acceptanceRemark"
|
required
|
border-bottom>
|
<u-textarea v-model="form.acceptanceRemark"
|
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="save-btn"
|
type="primary"
|
@click="handleSubmit"
|
:loading="loading">验收确认</u-button>
|
</view>
|
</u-form>
|
<up-datetime-picker :show="showDatePicker"
|
v-model="pickerDateValue"
|
mode="datetime"
|
title="选择验收时间"
|
@confirm="onDateConfirm"
|
@cancel="showDatePicker = false" />
|
</view>
|
</template>
|
|
<script setup>
|
import { ref, onMounted } from "vue";
|
import { onLoad } from "@dcloudio/uni-app";
|
import PageHeader from "@/components/PageHeader.vue";
|
import { repairAcceptance, getRepairById } from "@/api/equipmentManagement/repair";
|
import useUserStore from "@/store/modules/user";
|
import dayjs from "dayjs";
|
|
defineOptions({ name: "repair-acceptance" });
|
|
const showToast = message => {
|
uni.showToast({ title: message, icon: "none" });
|
};
|
|
const userStore = useUserStore();
|
const loading = ref(false);
|
const showDatePicker = ref(false);
|
const pickerDateValue = ref(Date.now());
|
const repairId = ref("");
|
const detail = ref({});
|
|
const form = ref({
|
id: "",
|
acceptanceName: "",
|
acceptanceTime: dayjs().format("YYYY-MM-DD HH:mm:ss"),
|
acceptanceRemark: "",
|
});
|
|
const formatDate = dateStr => {
|
if (!dateStr) return "";
|
return dayjs(dateStr).format("YYYY-MM-DD");
|
};
|
|
const formatDateTime = dateStr => {
|
if (!dateStr) return "";
|
return dayjs(dateStr).format("YYYY-MM-DD HH:mm:ss");
|
};
|
|
const canAccept = item => {
|
const currentName = userStore.nickName || userStore.name || "";
|
return currentName && item.acceptanceName === currentName;
|
};
|
|
const loadDetail = async id => {
|
try {
|
const cached = uni.getStorageSync("repairDetail");
|
if (cached) {
|
detail.value = typeof cached === "string" ? JSON.parse(cached) : cached;
|
}
|
if (id && (!detail.value?.id || detail.value.id != id)) {
|
const { code, data } = await getRepairById(id);
|
if (code == 200) {
|
detail.value = data;
|
}
|
}
|
if (!canAccept(detail.value)) {
|
showToast("仅指定验收人可进行验收");
|
setTimeout(() => uni.navigateBack(), 1500);
|
return;
|
}
|
form.value.id = detail.value.id;
|
form.value.acceptanceName = detail.value.acceptanceName || "";
|
} catch (e) {
|
showToast("获取报修信息失败");
|
}
|
};
|
|
const onDateConfirm = e => {
|
form.value.acceptanceTime = dayjs(e.value).format("YYYY-MM-DD HH:mm:ss");
|
pickerDateValue.value = e.value;
|
showDatePicker.value = false;
|
};
|
|
const handleSubmit = async () => {
|
if (!form.value.acceptanceTime?.trim()) {
|
showToast("请选择验收时间");
|
return;
|
}
|
if (!form.value.acceptanceRemark?.trim()) {
|
showToast("请输入验收备注");
|
return;
|
}
|
try {
|
loading.value = true;
|
const { code } = await repairAcceptance({
|
id: form.value.id,
|
acceptanceTime: form.value.acceptanceTime,
|
acceptanceRemark: form.value.acceptanceRemark,
|
});
|
if (code == 200) {
|
showToast("验收成功");
|
uni.removeStorageSync("repairDetail");
|
setTimeout(() => uni.navigateBack(), 500);
|
} else {
|
loading.value = false;
|
}
|
} catch (e) {
|
loading.value = false;
|
showToast("验收提交失败");
|
}
|
};
|
|
const goBack = () => {
|
uni.removeStorageSync("repairDetail");
|
uni.navigateBack();
|
};
|
|
onLoad(options => {
|
if (options.id) {
|
repairId.value = options.id;
|
}
|
});
|
|
onMounted(async () => {
|
if (!userStore.nickName) {
|
await userStore.getInfo().catch(() => {});
|
}
|
if (repairId.value) {
|
loadDetail(repairId.value);
|
}
|
});
|
</script>
|
|
<style scoped lang="scss">
|
@import "@/static/scss/form-common.scss";
|
|
.repair-acceptance {
|
min-height: 100vh;
|
background-color: #f8f9fa;
|
padding-bottom: 160rpx;
|
}
|
|
.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;
|
}
|
|
.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;
|
}
|
|
.save-btn {
|
font-weight: 500;
|
font-size: 1rem;
|
color: #fff;
|
background: linear-gradient(140deg, #00baff 0%, #006cfb 100%);
|
border: none;
|
width: 45%;
|
height: 2.5rem;
|
border-radius: 2.5rem;
|
}
|
</style>
|