first commit
This commit is contained in:
100
src/pages/report/detail.vue
Normal file
100
src/pages/report/detail.vue
Normal file
@@ -0,0 +1,100 @@
|
||||
<script setup>
|
||||
import { onLoad } from '@dcloudio/uni-app'
|
||||
import { ref } from 'vue'
|
||||
import { getQueryDetailByOrderId, getQueryDetailByOrderNo } from '@/api'
|
||||
import VehicleReportShell from '@/components/report/VehicleReportShell.vue'
|
||||
import { normalizeVehicleQueryData } from '@/utils/vehicleReportNormalize'
|
||||
|
||||
definePage({
|
||||
style: {
|
||||
navigationBarTitleText: '报告详情',
|
||||
navigationStyle: 'default',
|
||||
navigationBarBackgroundColor: '#ffffff',
|
||||
navigationBarTextStyle: 'black',
|
||||
},
|
||||
})
|
||||
|
||||
const orderNo = ref('')
|
||||
const orderId = ref('')
|
||||
const loading = ref(true)
|
||||
const errText = ref('')
|
||||
const productName = ref('')
|
||||
const queryParams = ref({})
|
||||
const rows = ref(normalizeVehicleQueryData([]))
|
||||
|
||||
onLoad((options) => {
|
||||
orderNo.value = options?.orderNo || ''
|
||||
orderId.value = options?.orderId || ''
|
||||
void load()
|
||||
})
|
||||
|
||||
async function load() {
|
||||
if (!orderNo.value && !orderId.value) {
|
||||
loading.value = false
|
||||
errText.value = '缺少订单信息'
|
||||
return
|
||||
}
|
||||
loading.value = true
|
||||
errText.value = ''
|
||||
try {
|
||||
const res = orderId.value
|
||||
? await getQueryDetailByOrderId(orderId.value)
|
||||
: await getQueryDetailByOrderNo(orderNo.value)
|
||||
if (res?.code === 200 && res.data) {
|
||||
productName.value = res.data.product_name || '查询报告'
|
||||
queryParams.value = res.data.query_params || {}
|
||||
rows.value = normalizeVehicleQueryData(res.data.query_data || [])
|
||||
if (!rows.value.length)
|
||||
errText.value = '暂无报告模块数据'
|
||||
}
|
||||
else {
|
||||
errText.value = res?.msg || '加载失败'
|
||||
}
|
||||
}
|
||||
catch {
|
||||
errText.value = '网络异常或未登录'
|
||||
}
|
||||
finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<view class="page-root">
|
||||
<view v-if="loading" class="state">
|
||||
加载中…
|
||||
</view>
|
||||
<view v-else-if="errText && !rows.length" class="state">
|
||||
{{ errText }}
|
||||
</view>
|
||||
<view v-else class="content">
|
||||
<VehicleReportShell
|
||||
mode="detail"
|
||||
:product-name="productName"
|
||||
:query-params="queryParams"
|
||||
:rows="rows"
|
||||
/>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.page-root {
|
||||
min-height: 100vh;
|
||||
background: #d2dffa;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.state {
|
||||
padding: 100rpx 32rpx;
|
||||
text-align: center;
|
||||
font-size: 28rpx;
|
||||
color: #86909c;
|
||||
}
|
||||
|
||||
.content {
|
||||
padding: 24rpx 24rpx 48rpx;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user