congming_huose-apk/pages/company/panic-detail.vue

227 lines
4.6 KiB
Vue

<template>
<view class="page">
<app-top-push-notice />
<view class="tabback">
<view class="rtjt" @click="back"></view>
<view class="name">{{ $i18n.t('companyPanicDetailTitle') }}</view>
<view class="tabback-placeholder"></view>
</view>
<scroll-view scroll-y class="body-scroll" :show-scrollbar="false">
<view v-if="loading" class="state state--muted">{{ $i18n.t('loading') }}</view>
<template v-else>
<view v-if="detailRows.length === 0" class="state state--muted">{{ $i18n.t('companyEmptyPanic') }}</view>
<view v-else class="card">
<view v-for="(row, index) in detailRows" :key="index" class="row">
<text class="row-label">{{ row.label }}</text>
<text class="row-value">{{ row.value }}</text>
</view>
</view>
</template>
</scroll-view>
<view class="footer-bar">
<view class="footer-btn footer-btn--ghost" @click="back">{{ $i18n.t('back') }}</view>
<view class="footer-btn" @click="acceptPanic">{{ $i18n.t('companyPanicAccept') }}</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
panicId: '',
loading: true,
detail: {}
}
},
computed: {
detailRows() {
const d = this.detail
if (!d || typeof d !== 'object') return []
const rows = []
Object.keys(d).forEach((key) => {
const val = d[key]
if (val === undefined || val === null || val === '') return
let str = val
if (typeof val === 'object') {
try {
str = JSON.stringify(val)
} catch (e) {
str = String(val)
}
} else {
str = String(val)
}
rows.push({ label: key, value: str })
})
return rows
}
},
onLoad(options) {
this.panicId = (options && options.id) ? String(options.id) : ''
if (!this.panicId) {
uni.showToast({ title: this.$i18n.t('requestFailed'), icon: 'none' })
this.loading = false
return
}
this.fetchDetail()
},
methods: {
back() {
uni.navigateBack({ delta: 1 })
},
fetchDetail() {
this.loading = true
this.$http
.get(`/bst/panic/${this.panicId}`)
.then((res) => {
if (res.code == 200) {
this.detail = res.data && typeof res.data === 'object' ? res.data : {}
} else {
uni.showToast({ title: res.msg || this.$i18n.t('requestFailed'), icon: 'none' })
this.detail = {}
}
})
.catch(() => {
uni.showToast({ title: this.$i18n.t('requestFailed'), icon: 'none' })
this.detail = {}
})
.finally(() => {
this.loading = false
})
},
acceptPanic() {
uni.showToast({
title: this.$i18n.t('companyPanicAcceptTodo'),
icon: 'none',
duration: 2500
})
}
}
}
</script>
<style scoped lang="scss">
.page {
min-height: 100vh;
background-color: #f3f5f6;
box-sizing: border-box;
padding-bottom: calc(140rpx + env(safe-area-inset-bottom));
}
.tabback {
display: flex;
align-items: center;
justify-content: space-between;
width: 100%;
height: 160rpx;
padding: 0 20rpx;
padding-top: 80rpx;
box-sizing: border-box;
position: fixed;
top: 0;
left: 0;
z-index: 999;
background-color: #fff;
.rtjt {
font-size: 36rpx;
color: #333;
min-width: 48rpx;
}
.name {
font-size: 32rpx;
font-weight: 600;
color: #333;
}
.tabback-placeholder {
width: 48rpx;
height: 1rpx;
}
}
.body-scroll {
height: calc(100vh - 160rpx - 120rpx - env(safe-area-inset-bottom));
padding: 24rpx;
box-sizing: border-box;
}
.state {
text-align: center;
padding: 48rpx 24rpx;
font-size: 28rpx;
}
.state--muted {
color: #8b9199;
}
.card {
background: #fff;
border-radius: 16rpx;
padding: 8rpx 24rpx;
box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.06);
}
.row {
padding: 20rpx 0;
border-bottom: 1rpx solid #f0f2f5;
&:last-child {
border-bottom: none;
}
}
.row-label {
display: block;
font-size: 24rpx;
color: #9ca3af;
margin-bottom: 8rpx;
}
.row-value {
display: block;
font-size: 28rpx;
color: #1a1a1a;
line-height: 1.45;
word-break: break-all;
}
.footer-bar {
position: fixed;
left: 0;
right: 0;
bottom: 0;
z-index: 998;
display: flex;
gap: 20rpx;
padding: 16rpx 24rpx calc(16rpx + env(safe-area-inset-bottom));
background: #fff;
border-top: 1rpx solid #e8eaed;
box-sizing: border-box;
}
.footer-btn {
flex: 1;
height: 88rpx;
line-height: 88rpx;
text-align: center;
background: #0f0f0f;
color: #fff;
font-size: 30rpx;
font-weight: 600;
border-radius: 44rpx;
}
.footer-btn--ghost {
background: #fff;
color: #0f0f0f;
border: 2rpx solid #0f0f0f;
line-height: 84rpx;
}
</style>