88 lines
1.6 KiB
Vue
88 lines
1.6 KiB
Vue
<script setup lang="ts">
|
|
import type { WarningRecord } from '@/service/warningRecord'
|
|
import { onMounted } from 'vue'
|
|
import { useDbStore } from '@/store/modules/db'
|
|
|
|
const db = useDbStore()
|
|
|
|
/** 首页只展示最近几条 */
|
|
const list = computed(() => (db.warning_record || []).slice(0, 3))
|
|
|
|
onMounted(async () => {
|
|
if (!db.warning_record?.length)
|
|
await db.loadAll()
|
|
})
|
|
|
|
function goToWarningList() {
|
|
uni.navigateTo({
|
|
url: '/pages/warning/index',
|
|
})
|
|
}
|
|
|
|
function goToDetail(item: WarningRecord) {
|
|
if (!item.id)
|
|
return
|
|
uni.navigateTo({
|
|
url: `/pages/warning/detail/index?id=${item.id}`,
|
|
})
|
|
}
|
|
</script>
|
|
|
|
<template>
|
|
<view class="card">
|
|
<view class="card-header">
|
|
<text class="card-title">
|
|
异常警告
|
|
</text>
|
|
<wd-button variant="text" @tap="goToWarningList">
|
|
查看全部
|
|
</wd-button>
|
|
</view>
|
|
<view class="card-body">
|
|
<view v-if="!list.length" class="empty-tip">
|
|
暂无异常警告
|
|
</view>
|
|
<home-warning_list
|
|
v-for="item in list"
|
|
:key="item.id"
|
|
:item="item"
|
|
@tap="goToDetail(item)"
|
|
/>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
|
|
<style scoped>
|
|
.card {
|
|
background-color: #ffffff;
|
|
border-radius: 12px;
|
|
margin-bottom: 12px;
|
|
overflow: hidden;
|
|
}
|
|
|
|
.card-header {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
padding: 12px 16px;
|
|
border-bottom: 1px solid #f5f5f5;
|
|
}
|
|
|
|
.card-title {
|
|
font-size: 22px;
|
|
font-weight: bold;
|
|
color: #333333;
|
|
}
|
|
|
|
.card-body {
|
|
padding: 12px 16px;
|
|
}
|
|
|
|
.empty-tip {
|
|
font-size: 14px;
|
|
color: #999999;
|
|
text-align: center;
|
|
padding: 16px 0;
|
|
}
|
|
</style>
|