- Replace individual page background images with global page background in App.vue - Update pages.json global styles to use transparent colors for navigation and backgrounds - Remove redundant bg-image elements and styles from all page components - Set global page background with login_bg.png image, cover sizing, and fixed attachment - Simplify individual page styling by removing duplicate background color declarations - Consolidate background management to single source of truth in App.vue for consistent theming
249 lines
5.1 KiB
Vue
249 lines
5.1 KiB
Vue
<template>
|
|
<view class="fault-list-page">
|
|
<view class="content">
|
|
<!-- 顶部导航栏 -->
|
|
<view class="nav-bar" :style="{ paddingTop: statusBarHeight + 'px' }">
|
|
<view class="nav-bar-inner">
|
|
<image
|
|
class="nav-icon"
|
|
src="/static/images/ic_back.png"
|
|
mode="aspectFit"
|
|
@click="goBack"
|
|
/>
|
|
<text class="nav-title">干线</text>
|
|
<view class="nav-icon-placeholder" />
|
|
</view>
|
|
</view>
|
|
|
|
<!-- 小标题 -->
|
|
<text class="section-title">故障列表</text>
|
|
|
|
<!-- 故障列表 -->
|
|
<view class="fault-list">
|
|
<view
|
|
class="fault-card"
|
|
v-for="item in faultList"
|
|
:key="item.id"
|
|
@click="goFaultDetail(item)"
|
|
>
|
|
<view class="fault-row">
|
|
<text class="fault-label">故障时间:</text>
|
|
<text class="fault-value">{{ item.faultTime }}</text>
|
|
</view>
|
|
<view class="fault-row">
|
|
<text class="fault-label">故障原因:</text>
|
|
<text class="fault-value">{{ item.faultReason }}</text>
|
|
</view>
|
|
<view class="fault-row">
|
|
<text class="fault-label">表显故障里程:</text>
|
|
<text class="fault-value">{{ calcDisplayMileage(item.mileage, item.mileageCorrection) }}</text>
|
|
</view>
|
|
<view class="fault-row last-row">
|
|
<text class="fault-label">所属光缆:</text>
|
|
<text class="fault-value">{{ item.cableName }}</text>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
|
|
<!-- 底部固定按钮 -->
|
|
<view class="bottom-bar">
|
|
<view class="add-fault-btn" @click="goFaultAdd">
|
|
<text class="add-fault-btn-text">新增故障</text>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
|
|
<script setup>
|
|
import { ref } from 'vue'
|
|
import { onLoad, onShow, onReachBottom } from '@dcloudio/uni-app'
|
|
import { getFaultList } from '@/services/trunk'
|
|
|
|
const statusBarHeight = uni.getSystemInfoSync().statusBarHeight || 0
|
|
const faultList = ref([])
|
|
const cableId = ref('')
|
|
const cableName = ref('')
|
|
const pageNum = ref(1)
|
|
const pageSize = ref(20)
|
|
const totalPage = ref(1)
|
|
const loading = ref(false)
|
|
|
|
function calcDisplayMileage(mileage, mileageCorrection) {
|
|
const m = parseFloat(mileage)
|
|
const c = parseFloat(mileageCorrection)
|
|
if (!isNaN(m) && !isNaN(c)) {
|
|
return String(Math.round((m + c) * 10000) / 10000)
|
|
}
|
|
return mileage || ''
|
|
}
|
|
|
|
async function loadFaultList(isLoadMore = false) {
|
|
if (loading.value) return
|
|
loading.value = true
|
|
|
|
try {
|
|
const res = await getFaultList(cableId.value, pageNum.value, pageSize.value)
|
|
if (res.code === 200) {
|
|
const data = res.data || {}
|
|
const list = data.result || []
|
|
if (isLoadMore) {
|
|
faultList.value = [...faultList.value, ...list]
|
|
} else {
|
|
faultList.value = list
|
|
}
|
|
totalPage.value = data.totalPage || 1
|
|
}
|
|
} catch (err) {
|
|
uni.showToast({ title: '加载失败', icon: 'none' })
|
|
} finally {
|
|
loading.value = false
|
|
}
|
|
}
|
|
|
|
function goBack() {
|
|
uni.navigateBack()
|
|
}
|
|
|
|
function goFaultDetail(item) {
|
|
uni.navigateTo({ url: '/pages/fault-detail/index?faultId=' + item.id })
|
|
}
|
|
|
|
function goFaultAdd() {
|
|
uni.navigateTo({
|
|
url: '/pages/fault-add/index?cableId=' + cableId.value + '&cableName=' + encodeURIComponent(cableName.value)
|
|
})
|
|
}
|
|
|
|
onLoad((options) => {
|
|
if (options.cableId) {
|
|
cableId.value = options.cableId
|
|
}
|
|
if (options.cableName) {
|
|
cableName.value = decodeURIComponent(options.cableName)
|
|
}
|
|
})
|
|
|
|
onShow(() => {
|
|
pageNum.value = 1
|
|
loadFaultList()
|
|
})
|
|
|
|
onReachBottom(() => {
|
|
if (pageNum.value < totalPage.value) {
|
|
pageNum.value++
|
|
loadFaultList(true)
|
|
}
|
|
})
|
|
</script>
|
|
|
|
<style scoped>
|
|
.fault-list-page {
|
|
position: relative;
|
|
min-height: 100vh;
|
|
background-color: transparent;
|
|
padding-bottom: 120rpx;
|
|
}
|
|
|
|
.content {
|
|
position: relative;
|
|
z-index: 1;
|
|
}
|
|
|
|
.nav-bar {
|
|
width: 100%;
|
|
}
|
|
|
|
.nav-bar-inner {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
height: 88rpx;
|
|
padding: 0 24rpx;
|
|
}
|
|
|
|
.nav-icon {
|
|
width: 44rpx;
|
|
height: 44rpx;
|
|
}
|
|
|
|
.nav-icon-placeholder {
|
|
width: 44rpx;
|
|
height: 44rpx;
|
|
}
|
|
|
|
.nav-title {
|
|
font-size: 34rpx;
|
|
font-weight: 600;
|
|
color: #fff;
|
|
}
|
|
|
|
.section-title {
|
|
font-size: 30rpx;
|
|
font-weight: 600;
|
|
color: #333;
|
|
padding: 16rpx 24rpx 8rpx;
|
|
display: block;
|
|
}
|
|
|
|
.fault-list {
|
|
padding: 0 0 24rpx;
|
|
}
|
|
|
|
.fault-card {
|
|
background-color: #fff;
|
|
border-radius: 12rpx;
|
|
border: 1rpx solid #E8E8E8;
|
|
padding: 24rpx;
|
|
margin: 0 24rpx 20rpx;
|
|
}
|
|
|
|
.fault-row {
|
|
display: flex;
|
|
align-items: flex-start;
|
|
margin-bottom: 12rpx;
|
|
}
|
|
|
|
.fault-row.last-row {
|
|
margin-bottom: 0;
|
|
}
|
|
|
|
.fault-label {
|
|
font-size: 26rpx;
|
|
color: #999;
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
.fault-value {
|
|
font-size: 26rpx;
|
|
color: #333;
|
|
flex: 1;
|
|
}
|
|
|
|
.bottom-bar {
|
|
position: fixed;
|
|
bottom: 0;
|
|
left: 0;
|
|
width: 100%;
|
|
padding: 24rpx;
|
|
background: #fff;
|
|
box-sizing: border-box;
|
|
z-index: 99;
|
|
}
|
|
|
|
.add-fault-btn {
|
|
width: 100%;
|
|
height: 88rpx;
|
|
background: #1A73EC;
|
|
border-radius: 20rpx;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
}
|
|
|
|
.add-fault-btn-text {
|
|
color: #fff;
|
|
font-size: 32rpx;
|
|
}
|
|
</style>
|