2025-07-28 17:52:29 +08:00
|
|
|
<template>
|
2025-07-28 18:52:32 +08:00
|
|
|
<view class="page">
|
2025-07-31 09:27:55 +08:00
|
|
|
<custom-navbar title="建制" />
|
2025-07-31 14:28:29 +08:00
|
|
|
<tile-grid :tile-image="tilesImageEnum.TILE" />
|
2025-07-30 16:14:56 +08:00
|
|
|
<view class="header">
|
2025-07-29 11:07:32 +08:00
|
|
|
<!-- 加载状态 -->
|
|
|
|
|
<view v-if="loading" class="loading">
|
|
|
|
|
<text>加载中...</text>
|
|
|
|
|
</view>
|
|
|
|
|
<!-- 空数据提示 -->
|
|
|
|
|
<view v-else-if="institutionalData.length === 0" class="empty">
|
|
|
|
|
<text>暂无数据</text>
|
2025-07-29 09:53:04 +08:00
|
|
|
</view>
|
2025-07-29 11:07:32 +08:00
|
|
|
<!-- 数据列表 -->
|
|
|
|
|
<view v-else class="data" v-for="(item, index) in institutionalData" :key="index">
|
|
|
|
|
<view class="row">
|
|
|
|
|
<view class="topLeft">{{ item.topLeft || '暂无数据' }}</view>
|
|
|
|
|
<view>{{ item.topRight || '暂无数据' }}</view>
|
|
|
|
|
</view>
|
|
|
|
|
<view class="row">
|
|
|
|
|
<view class="subRow">
|
|
|
|
|
<view>{{ item.bottomLeft || '暂无数据' }}</view>
|
|
|
|
|
<view >{{ item.bottomRight || '暂无数据' }}</view>
|
|
|
|
|
</view>
|
|
|
|
|
<view>
|
|
|
|
|
<view class="bottomRight">查看详细</view>
|
|
|
|
|
</view>
|
2025-07-29 09:53:04 +08:00
|
|
|
|
2025-07-29 11:07:32 +08:00
|
|
|
</view>
|
|
|
|
|
</view>
|
2025-07-29 08:52:55 +08:00
|
|
|
</view>
|
2025-07-29 11:07:32 +08:00
|
|
|
|
2025-07-28 18:52:32 +08:00
|
|
|
</view>
|
2025-07-28 17:52:29 +08:00
|
|
|
</template>
|
|
|
|
|
|
2025-07-28 18:52:32 +08:00
|
|
|
<script>
|
2025-07-29 09:53:04 +08:00
|
|
|
import { tilesImageEnum } from '@/enum/institutionalStructure.js';
|
2025-07-29 11:07:32 +08:00
|
|
|
import { getInstitutionalList } from '@/api/institutionalStructure.js';
|
2025-07-31 09:27:55 +08:00
|
|
|
import CustomNavbar from "../../components/custom-navbar/custom-navbar.vue";
|
2025-07-31 14:28:29 +08:00
|
|
|
import TileGrid from "../../components/tile-grid/tile-grid.vue";
|
2025-07-31 11:34:40 +08:00
|
|
|
import CommonEnum from "../../enum/common";
|
2025-07-29 09:53:04 +08:00
|
|
|
|
2025-07-28 18:52:32 +08:00
|
|
|
export default {
|
2025-07-31 09:27:55 +08:00
|
|
|
components: {
|
2025-07-31 14:28:29 +08:00
|
|
|
CustomNavbar,
|
|
|
|
|
TileGrid
|
2025-07-31 09:27:55 +08:00
|
|
|
},
|
2025-07-28 18:52:32 +08:00
|
|
|
data() {
|
|
|
|
|
return {
|
2025-07-31 11:34:40 +08:00
|
|
|
CommonEnum,
|
2025-07-28 18:52:32 +08:00
|
|
|
bgc: {
|
2025-07-31 11:34:40 +08:00
|
|
|
backgroundColor: CommonEnum.BASE_COLOR,
|
2025-07-28 18:52:32 +08:00
|
|
|
},
|
2025-07-29 11:07:32 +08:00
|
|
|
tilesImageEnum,
|
|
|
|
|
// 动态数据数组
|
|
|
|
|
institutionalData: [],
|
|
|
|
|
// 加载状态
|
|
|
|
|
loading: false,
|
|
|
|
|
pageNum: 1,
|
|
|
|
|
pageSize: 10,
|
|
|
|
|
hasMore: true // 是否还有更多数据
|
2025-07-28 18:52:32 +08:00
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
onLoad() {
|
2025-07-29 11:07:32 +08:00
|
|
|
// 页面加载时获取数据
|
|
|
|
|
this.getInstitutionalData()
|
2025-07-28 18:52:32 +08:00
|
|
|
},
|
|
|
|
|
methods: {
|
2025-07-29 11:07:32 +08:00
|
|
|
// 获取建制数据
|
|
|
|
|
async getInstitutionalData(isLoadMore = false) {
|
|
|
|
|
this.loading = true
|
|
|
|
|
try {
|
|
|
|
|
if (isLoadMore) {
|
|
|
|
|
this.pageNum++
|
|
|
|
|
} else {
|
|
|
|
|
this.pageNum = 1
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 调用API
|
|
|
|
|
const response = await getInstitutionalList({
|
|
|
|
|
pageNum: this.pageNum,
|
|
|
|
|
pageSize: this.pageSize
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
if (response.code === 200) {
|
|
|
|
|
// 将后端数据转换为前端需要的格式
|
|
|
|
|
const newData = response.rows.map(item => ({
|
|
|
|
|
topLeft: this.formatTopLeft(item.startYear, item.proName),
|
|
|
|
|
topRight: this.getStatusText(item.state),
|
|
|
|
|
bottomLeft: `建造金额:${this.formatAmount(item.totalAmount)}`,
|
|
|
|
|
bottomRight: `捐赠人数:${item.donorCount}人`
|
|
|
|
|
})) || []
|
|
|
|
|
|
|
|
|
|
if (isLoadMore) {
|
|
|
|
|
this.institutionalData = [...this.institutionalData, ...newData]
|
|
|
|
|
} else {
|
|
|
|
|
this.institutionalData = newData
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 判断是否还有更多数据
|
|
|
|
|
this.hasMore = response.rows.length === this.pageSize
|
|
|
|
|
} else {
|
|
|
|
|
uni.showToast({
|
|
|
|
|
title: response.msg || '获取数据失败',
|
|
|
|
|
icon: 'none'
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('获取建制数据失败:', error)
|
|
|
|
|
uni.showToast({
|
|
|
|
|
title: '网络错误',
|
|
|
|
|
icon: 'none'
|
|
|
|
|
})
|
|
|
|
|
} finally {
|
|
|
|
|
this.loading = false
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 格式化金额
|
|
|
|
|
formatAmount(amount) {
|
|
|
|
|
if (!amount) return '不详'
|
|
|
|
|
if (amount >= 100000000) {
|
|
|
|
|
return `${(amount / 100000000).toFixed(1)}亿`
|
|
|
|
|
} else if (amount >= 10000) {
|
|
|
|
|
return `${(amount / 10000).toFixed(1)}万`
|
|
|
|
|
} else {
|
|
|
|
|
return `${amount.toLocaleString()}`
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 格式化左上角内容
|
|
|
|
|
formatTopLeft(year, projectName) {
|
|
|
|
|
if (!year || !projectName) return '暂无数据'
|
|
|
|
|
return `${year}年 ${projectName}`
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 获取状态文本
|
|
|
|
|
getStatusText(state) {
|
|
|
|
|
switch (state) {
|
|
|
|
|
case '1':
|
|
|
|
|
return '规划'
|
|
|
|
|
case '2':
|
|
|
|
|
return '进行中'
|
|
|
|
|
case '3':
|
|
|
|
|
return '已完成'
|
|
|
|
|
case '4':
|
|
|
|
|
return '已取消'
|
|
|
|
|
default:
|
|
|
|
|
return '未知状态'
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 刷新数据
|
|
|
|
|
refreshData() {
|
|
|
|
|
this.getInstitutionalData()
|
|
|
|
|
}
|
2025-07-28 18:52:32 +08:00
|
|
|
}
|
|
|
|
|
}
|
2025-07-28 17:52:29 +08:00
|
|
|
</script>
|
|
|
|
|
|
2025-07-28 18:52:32 +08:00
|
|
|
<style lang="scss">
|
|
|
|
|
page {
|
2025-07-31 14:35:08 +08:00
|
|
|
background: #F5F0E7;
|
2025-07-29 08:52:55 +08:00
|
|
|
}
|
2025-07-30 16:14:56 +08:00
|
|
|
.header {
|
2025-07-29 08:52:55 +08:00
|
|
|
width: 100%;
|
2025-07-29 11:07:32 +08:00
|
|
|
min-height: 100vh;
|
2025-07-29 08:52:55 +08:00
|
|
|
display: flex;
|
2025-07-29 09:53:04 +08:00
|
|
|
align-items: flex-start;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
background-color: #FFFBF5;
|
|
|
|
|
padding: 0 11rpx;
|
2025-07-29 11:07:32 +08:00
|
|
|
padding-bottom: 40rpx;
|
2025-07-29 09:53:04 +08:00
|
|
|
}
|
2025-07-31 14:28:29 +08:00
|
|
|
|
2025-07-29 09:53:04 +08:00
|
|
|
.data{
|
2025-07-29 08:52:55 +08:00
|
|
|
background-color: #FFFBF5;
|
2025-07-29 09:53:04 +08:00
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
align-items: center;
|
|
|
|
|
width: 100%;
|
|
|
|
|
box-sizing: border-box;
|
|
|
|
|
height: 180rpx;
|
|
|
|
|
border-radius: 11px;
|
|
|
|
|
border: 1px solid #C7A26D;
|
|
|
|
|
margin: 8rpx 0;
|
|
|
|
|
}
|
|
|
|
|
.row{
|
|
|
|
|
flex: 1;
|
|
|
|
|
width: 100%;
|
|
|
|
|
display: flex;
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
align-items: center;
|
|
|
|
|
padding: 0 20rpx;
|
2025-07-28 18:52:32 +08:00
|
|
|
}
|
2025-07-29 11:07:32 +08:00
|
|
|
.subRow{
|
|
|
|
|
display: flex;
|
|
|
|
|
}
|
|
|
|
|
.subRow view{
|
|
|
|
|
padding-right: 20px;
|
2025-07-30 13:38:33 +08:00
|
|
|
font-size: 16px;
|
2025-07-29 11:07:32 +08:00
|
|
|
}
|
|
|
|
|
.topLeft{
|
|
|
|
|
font-size: 21px;
|
|
|
|
|
font-weight: 1000;
|
|
|
|
|
color: #522510;
|
|
|
|
|
}
|
|
|
|
|
.bottomRight{
|
2025-07-30 13:38:33 +08:00
|
|
|
font-size: 16px;
|
2025-07-29 11:07:32 +08:00
|
|
|
font-weight: 1000;
|
|
|
|
|
color: #522510;
|
|
|
|
|
}
|
|
|
|
|
.loading, .empty {
|
|
|
|
|
display: flex;
|
|
|
|
|
justify-content: center;
|
|
|
|
|
align-items: center;
|
|
|
|
|
color: #999;
|
|
|
|
|
font-size: 28rpx;
|
|
|
|
|
background-color: #FFFBF5;
|
|
|
|
|
}
|
2025-07-28 18:52:32 +08:00
|
|
|
</style>
|