<template>
|
<view class="line-inspection">
|
<PageHeader title="线路巡检"
|
@back="goBack" />
|
<view class="search-section">
|
<view class="search-bar">
|
<view class="search-input">
|
<up-input class="search-text"
|
placeholder="请输入巡检编号/巡检名称/线路名称"
|
v-model="keyword"
|
@change="handleQuery"
|
clearable />
|
</view>
|
<view class="filter-button"
|
@click="handleQuery">
|
<up-icon name="search"
|
size="24"
|
color="#999"></up-icon>
|
</view>
|
</view>
|
</view>
|
<scroll-view scroll-y
|
class="list-scroll ledger-list"
|
@scrolltolower="loadMore"
|
v-if="list.length > 0">
|
<view v-for="row in list"
|
: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.inspectionCode || "-" }}</text>
|
</view>
|
<view class="item-right">
|
<up-tag :text="row.status || '-'"
|
:type="statusType(row.status)"
|
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.inspectionName || "-" }}</text>
|
</view>
|
<view class="detail-row">
|
<text class="detail-label">线路名称</text>
|
<text class="detail-value">{{ row.lineName || "-" }}</text>
|
</view>
|
<view class="detail-row">
|
<text class="detail-label">巡检类型</text>
|
<text class="detail-value">{{ row.inspectionType || "-" }}</text>
|
</view>
|
<view class="detail-row">
|
<text class="detail-label">计划巡检时间</text>
|
<text class="detail-value">{{ row.planTime || "-" }}</text>
|
</view>
|
<view class="detail-row">
|
<text class="detail-label">巡检人</text>
|
<text class="detail-value">{{ row.inspectorName || "-" }}</text>
|
</view>
|
</view>
|
<view class="action-buttons action-buttons-bottom">
|
<u-button size="small"
|
class="action-btn fixed-btn"
|
:disabled="!canEdit(row)"
|
@click.stop="goEdit(row)">编辑</u-button>
|
<u-button size="small"
|
class="action-btn fixed-btn"
|
type="primary"
|
@click.stop="goRecords(row)">巡检记录</u-button>
|
<u-button size="small"
|
class="action-btn fixed-btn"
|
type="primary"
|
@click.stop="goHazards(row)">隐患管理</u-button>
|
<u-button v-if="String(row.status) === '巡检中'"
|
size="small"
|
class="action-btn fixed-btn"
|
type="success"
|
@click.stop="handleComplete(row)">
|
完成巡检
|
</u-button>
|
<u-button size="small"
|
class="action-btn fixed-btn"
|
type="error"
|
:disabled="!canDelete(row)"
|
@click.stop="handleDelete(row)">删除</u-button>
|
</view>
|
</view>
|
<up-loadmore :status="loadStatus" />
|
</scroll-view>
|
<view v-else
|
class="no-data">
|
<up-empty mode="data"
|
text="暂无数据"></up-empty>
|
</view>
|
<view class="fab-button"
|
@click="goAdd">
|
<up-icon name="plus"
|
size="24"
|
color="#ffffff"></up-icon>
|
</view>
|
</view>
|
</template>
|
|
<script setup>
|
import { onMounted, reactive, ref } from "vue";
|
import { onShow } from "@dcloudio/uni-app";
|
import PageHeader from "@/components/PageHeader.vue";
|
import {
|
completeLineInspection,
|
deleteLineInspection,
|
getLineInspectionList,
|
} from "@/api/safeProduction/lineInspection";
|
|
const keyword = ref("");
|
|
const page = reactive({ current: 1, size: 20, total: 0 });
|
const list = ref([]);
|
const loadStatus = ref("loadmore");
|
const loading = ref(false);
|
|
const goBack = () => {
|
uni.navigateBack();
|
};
|
|
const statusType = status => {
|
const map = {
|
待巡检: "info",
|
巡检中: "warning",
|
已完成: "success",
|
};
|
return map[status] || "info";
|
};
|
|
const canEdit = row => String(row?.status) === "待巡检";
|
const canDelete = row => String(row?.status) === "待巡检";
|
|
const fetchList = () => {
|
if (loading.value) return;
|
loading.value = true;
|
loadStatus.value = "loading";
|
const kw = String(keyword.value || "").trim();
|
getLineInspectionList({
|
inspectionCode: kw,
|
inspectionName: kw,
|
lineName: kw,
|
...page,
|
})
|
.then(res => {
|
const records = res?.data?.records || [];
|
const total = Number(res?.data?.total || 0);
|
page.total = total;
|
list.value = page.current === 1 ? records : [...list.value, ...records];
|
loadStatus.value =
|
list.value.length >= page.total ? "nomore" : "loadmore";
|
})
|
.catch(() => {
|
loadStatus.value = "loadmore";
|
uni.showToast({ title: "加载失败", icon: "none" });
|
})
|
.finally(() => {
|
loading.value = false;
|
});
|
};
|
|
const handleQuery = () => {
|
page.current = 1;
|
list.value = [];
|
fetchList();
|
};
|
|
const loadMore = () => {
|
if (loadStatus.value !== "loadmore") return;
|
page.current++;
|
fetchList();
|
};
|
|
const goAdd = () => {
|
uni.navigateTo({ url: "/pages/safeProduction/lineInspection/edit" });
|
};
|
|
const goEdit = row => {
|
const data = encodeURIComponent(JSON.stringify(row || {}));
|
uni.navigateTo({
|
url: `/pages/safeProduction/lineInspection/edit?data=${data}`,
|
});
|
};
|
|
const goRecords = row => {
|
const params = encodeURIComponent(
|
JSON.stringify({ inspectionId: row.id, inspectionStatus: row.status || "" })
|
);
|
uni.navigateTo({
|
url: `/pages/safeProduction/lineInspection/recordList?data=${params}`,
|
});
|
};
|
|
const goHazards = row => {
|
const params = encodeURIComponent(
|
JSON.stringify({ inspectionId: row.id, inspectionStatus: row.status || "" })
|
);
|
uni.navigateTo({
|
url: `/pages/safeProduction/lineInspection/hazardList?data=${params}`,
|
});
|
};
|
|
const handleDelete = row => {
|
if (!row?.id) return;
|
uni.showModal({
|
title: "删除",
|
content: "确认删除该巡检任务吗?",
|
success: res => {
|
if (!res.confirm) return;
|
uni.showLoading({ title: "删除中...", mask: true });
|
deleteLineInspection([row.id])
|
.then(() => {
|
uni.showToast({ title: "删除成功", icon: "success" });
|
handleQuery();
|
})
|
.catch(() => {
|
uni.showToast({ title: "删除失败", icon: "none" });
|
})
|
.finally(() => {
|
uni.hideLoading();
|
});
|
},
|
});
|
};
|
|
const handleComplete = row => {
|
if (!row?.id) return;
|
uni.showModal({
|
title: "完成巡检",
|
content: "确认完成该巡检任务吗?",
|
success: res => {
|
if (!res.confirm) return;
|
uni.showLoading({ title: "提交中...", mask: true });
|
completeLineInspection(row.id)
|
.then(() => {
|
uni.showToast({ title: "巡检已完成", icon: "success" });
|
handleQuery();
|
})
|
.catch(() => {
|
uni.showToast({ title: "操作失败", icon: "none" });
|
})
|
.finally(() => {
|
uni.hideLoading();
|
});
|
},
|
});
|
};
|
|
onMounted(() => {
|
handleQuery();
|
});
|
|
onShow(() => {
|
handleQuery();
|
});
|
</script>
|
|
<style scoped lang="scss">
|
@import "../../../styles/sales-common.scss";
|
|
.line-inspection {
|
min-height: 100vh;
|
background: #f8f9fa;
|
position: relative;
|
padding-bottom: 140rpx;
|
}
|
|
.list-scroll {
|
flex: 1;
|
min-height: 0;
|
}
|
|
.action-buttons {
|
display: flex;
|
flex-wrap: wrap;
|
justify-content: flex-end;
|
gap: 20rpx;
|
padding-bottom: 30rpx;
|
}
|
|
.fixed-btn {
|
width: 160rpx;
|
margin: 0 !important;
|
}
|
|
.fab-button {
|
position: fixed;
|
right: 30rpx;
|
bottom: 140rpx;
|
width: 96rpx;
|
height: 96rpx;
|
background: #3c9cff;
|
border-radius: 48rpx;
|
display: flex;
|
align-items: center;
|
justify-content: center;
|
box-shadow: 0 8rpx 24rpx rgba(60, 156, 255, 0.3);
|
z-index: 1001;
|
}
|
|
.no-data {
|
padding-top: 200rpx;
|
}
|
</style>
|