<template>
|
<view class="record-list">
|
<PageHeader title="巡检记录"
|
@back="goBack" />
|
<view class="top-actions">
|
<u-button type="primary"
|
size="small"
|
:disabled="isCompleted"
|
@click="goAdd">新增记录</u-button>
|
</view>
|
<scroll-view scroll-y
|
class="list-scroll ledger-list"
|
v-if="records.length > 0">
|
<view v-for="row in records"
|
:key="row.id"
|
class="ledger-item">
|
<view class="item-header">
|
<view class="item-left">
|
<view class="document-icon">
|
<up-icon name="file-text"
|
size="16"
|
color="#ffffff"></up-icon>
|
</view>
|
<text class="item-id">{{ row.checkPoint || "-" }}</text>
|
</view>
|
<view class="item-right">
|
<up-tag :text="row.checkResult || '-'"
|
:type="row.checkResult === '正常' ? 'success' : 'error'"
|
size="mini" />
|
</view>
|
</view>
|
<up-divider></up-divider>
|
<view class="item-details">
|
<view class="detail-row">
|
<text class="detail-label">检查内容</text>
|
<text class="detail-value">{{ row.checkContent || "-" }}</text>
|
</view>
|
<view class="detail-row">
|
<text class="detail-label">检查说明</text>
|
<text class="detail-value">{{ row.checkDesc || "-" }}</text>
|
</view>
|
<view class="detail-row">
|
<text class="detail-label">检查时间</text>
|
<text class="detail-value">{{ row.checkTime || "-" }}</text>
|
</view>
|
</view>
|
<view class="action-buttons">
|
<u-button size="small"
|
class="action-btn fixed-btn"
|
:disabled="isCompleted"
|
@click.stop="goEdit(row)">编辑</u-button>
|
<u-button size="small"
|
class="action-btn fixed-btn"
|
type="error"
|
:disabled="isCompleted"
|
@click.stop="handleDelete(row)">删除</u-button>
|
</view>
|
</view>
|
</scroll-view>
|
<view v-else
|
class="no-data">
|
<up-empty mode="data"
|
text="暂无记录"></up-empty>
|
</view>
|
</view>
|
</template>
|
|
<script setup>
|
import { computed, onMounted, ref } from "vue";
|
import { onLoad, onShow } from "@dcloudio/uni-app";
|
import PageHeader from "@/components/PageHeader.vue";
|
import {
|
deleteInspectionRecord,
|
getInspectionRecords,
|
} from "@/api/safeProduction/lineInspection";
|
|
const inspectionId = ref(null);
|
const inspectionStatus = ref("");
|
const records = ref([]);
|
|
const isCompleted = computed(() => String(inspectionStatus.value) === "已完成");
|
|
const goBack = () => {
|
uni.navigateBack();
|
};
|
|
const fetchRecords = () => {
|
if (!inspectionId.value) return;
|
uni.showLoading({ title: "加载中...", mask: true });
|
getInspectionRecords(inspectionId.value)
|
.then(res => {
|
records.value = res?.data || [];
|
})
|
.catch(() => {
|
uni.showToast({ title: "加载失败", icon: "none" });
|
})
|
.finally(() => {
|
uni.hideLoading();
|
});
|
};
|
|
const goAdd = () => {
|
const data = encodeURIComponent(
|
JSON.stringify({ inspectionId: inspectionId.value })
|
);
|
uni.navigateTo({
|
url: `/pages/safeProduction/lineInspection/recordEdit?data=${data}`,
|
});
|
};
|
|
const goEdit = row => {
|
const data = encodeURIComponent(
|
JSON.stringify({ inspectionId: inspectionId.value, row })
|
);
|
uni.navigateTo({
|
url: `/pages/safeProduction/lineInspection/recordEdit?data=${data}`,
|
});
|
};
|
|
const handleDelete = row => {
|
if (!row?.id) return;
|
uni.showModal({
|
title: "删除",
|
content: "确认删除该巡检记录吗?",
|
success: res => {
|
if (!res.confirm) return;
|
uni.showLoading({ title: "删除中...", mask: true });
|
deleteInspectionRecord([row.id])
|
.then(() => {
|
uni.showToast({ title: "删除成功", icon: "success" });
|
fetchRecords();
|
})
|
.catch(() => {
|
uni.showToast({ title: "删除失败", icon: "none" });
|
})
|
.finally(() => {
|
uni.hideLoading();
|
});
|
},
|
});
|
};
|
|
onMounted(() => {
|
uni.$on("lineInspection:recordsRefresh", fetchRecords);
|
});
|
|
onLoad(options => {
|
if (options?.data) {
|
try {
|
const obj = JSON.parse(decodeURIComponent(options.data));
|
inspectionId.value = obj.inspectionId;
|
inspectionStatus.value = obj.inspectionStatus || "";
|
} catch (e) {}
|
}
|
});
|
|
onShow(() => {
|
fetchRecords();
|
});
|
</script>
|
|
<style scoped lang="scss">
|
@import "../../../styles/sales-common.scss";
|
|
.record-list {
|
min-height: 100vh;
|
background: #f8f9fa;
|
padding-bottom: 40rpx;
|
}
|
|
.top-actions {
|
padding: 20rpx;
|
display: flex;
|
justify-content: flex-end;
|
}
|
|
.list-scroll {
|
flex: 1;
|
min-height: 0;
|
}
|
|
.action-buttons {
|
display: flex;
|
justify-content: flex-end;
|
gap: 20rpx;
|
padding-bottom: 30rpx;
|
}
|
|
.fixed-btn {
|
width: 160rpx;
|
margin: 0 !important;
|
}
|
|
.no-data {
|
padding-top: 200rpx;
|
}
|
</style>
|