捐款动态界面
This commit is contained in:
parent
eca711d745
commit
f8909e10a7
24
api/donor/donor.js
Normal file
24
api/donor/donor.js
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
import { request } from '@/utils/request'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取捐款记录列表
|
||||||
|
* @param {Object} params 查询参数
|
||||||
|
* @param {string} params.formedId 建制id
|
||||||
|
* @param {number} params.pageNum 分页页码
|
||||||
|
* @param {number} params.pageSize 分页大小
|
||||||
|
* @param {number} params.minAmount 最小金额
|
||||||
|
* @param {number} params.maxAmount 最大金额
|
||||||
|
* @param {string} params.sortAmount 根据amount金额排序
|
||||||
|
* @param {string} params.orderAmount asc/desc排序方式
|
||||||
|
* @param {string} params.sortTime 根据time捐款时间排序
|
||||||
|
* @param {string} params.orderTime asc/desc排序方式
|
||||||
|
* @param {string} params.realName 根据姓名模糊搜索
|
||||||
|
* @returns {Promise} 返回捐款记录列表
|
||||||
|
*/
|
||||||
|
export function getDonorList(params) {
|
||||||
|
return request({
|
||||||
|
url: '/app/donor/listDonor',
|
||||||
|
method: 'get',
|
||||||
|
params
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
@ -73,6 +73,7 @@ import TileGrid from "../../components/tile-grid/tile-grid.vue";
|
||||||
import CommonEnum from "../../enum/common";
|
import CommonEnum from "../../enum/common";
|
||||||
import StatusDisplay from "../../components/status-display/status-display.vue";
|
import StatusDisplay from "../../components/status-display/status-display.vue";
|
||||||
import SearchBox from "../../components/search-box/search-box.vue";
|
import SearchBox from "../../components/search-box/search-box.vue";
|
||||||
|
import { getDonorList } from '@/api/donor/donor.js';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
|
|
@ -86,7 +87,12 @@ export default {
|
||||||
CommonEnum,
|
CommonEnum,
|
||||||
loading: false,
|
loading: false,
|
||||||
searchKeyword: '',
|
searchKeyword: '',
|
||||||
donationList: []
|
donationList: [],
|
||||||
|
formedId: '', // 建制ID
|
||||||
|
// 分页参数
|
||||||
|
pageNum: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
hasMore: true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
|
@ -99,7 +105,11 @@ export default {
|
||||||
return this.donationList.length
|
return this.donationList.length
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onLoad() {
|
onLoad(options) {
|
||||||
|
// 获取页面参数
|
||||||
|
if (options.formedId) {
|
||||||
|
this.formedId = options.formedId
|
||||||
|
}
|
||||||
// 页面加载时获取数据
|
// 页面加载时获取数据
|
||||||
this.loadDonationRecords()
|
this.loadDonationRecords()
|
||||||
},
|
},
|
||||||
|
|
@ -107,40 +117,60 @@ export default {
|
||||||
onSearch(val) {
|
onSearch(val) {
|
||||||
// 搜索逻辑
|
// 搜索逻辑
|
||||||
console.log('搜索内容:', val)
|
console.log('搜索内容:', val)
|
||||||
|
this.pageNum = 1 // 重置页码
|
||||||
this.loadDonationRecords(val)
|
this.loadDonationRecords(val)
|
||||||
},
|
},
|
||||||
onFilter() {
|
onFilter() {
|
||||||
// 筛选逻辑
|
// 筛选逻辑
|
||||||
uni.showToast({ title: '筛选功能开发中', icon: 'none' })
|
uni.showToast({ title: '筛选功能开发中', icon: 'none' })
|
||||||
},
|
},
|
||||||
// 模拟获取捐款记录API
|
// 获取捐款记录API
|
||||||
async loadDonationRecords(keyword = '') {
|
async loadDonationRecords(keyword = '') {
|
||||||
this.loading = true
|
this.loading = true
|
||||||
try {
|
try {
|
||||||
// 模拟API调用
|
const params = {
|
||||||
await new Promise(resolve => setTimeout(resolve, 1000))
|
formedId: this.formedId,
|
||||||
|
pageNum: this.pageNum,
|
||||||
|
pageSize: this.pageSize,
|
||||||
|
minAmount: 1,
|
||||||
|
maxAmount: 10000,
|
||||||
|
sortAmount: 'amount',
|
||||||
|
orderAmount: 'asc',
|
||||||
|
sortTime: 'time',
|
||||||
|
orderTime: 'desc'
|
||||||
|
}
|
||||||
|
|
||||||
// 模拟数据
|
// 如果有搜索关键词,添加姓名搜索
|
||||||
const mockData = [
|
|
||||||
{ id: 9, name: '张珊珊', amount: 1000, time: '2025/03/11' },
|
|
||||||
{ id: 8, name: '李小明', amount: 500, time: '2025/03/09' },
|
|
||||||
{ id: 7, name: '王大力', amount: 2000, time: '2025/03/01' },
|
|
||||||
{ id: 6, name: '赵美丽', amount: 800, time: '2025/02/27' },
|
|
||||||
{ id: 5, name: '刘志强', amount: 1500, time: '2025/02/27' },
|
|
||||||
{ id: 4, name: '陈小红', amount: 1200, time: '2025/02/24' },
|
|
||||||
{ id: 3, name: '杨建国', amount: 3000, time: '2025/02/12' },
|
|
||||||
{ id: 2, name: '孙丽华', amount: 600, time: '2025/02/08' },
|
|
||||||
{ id: 1, name: '周志明', amount: 2500, time: '2025/02/01' }
|
|
||||||
]
|
|
||||||
|
|
||||||
// 如果有搜索关键词,过滤数据
|
|
||||||
if (keyword) {
|
if (keyword) {
|
||||||
this.donationList = mockData.filter(item =>
|
params.realName = keyword
|
||||||
item.name.includes(keyword) ||
|
}
|
||||||
item.amount.toString().includes(keyword)
|
|
||||||
)
|
const response = await getDonorList(params)
|
||||||
|
|
||||||
|
if (response.code === 200) {
|
||||||
|
// 转换数据格式
|
||||||
|
const newData = response.data.map(item => ({
|
||||||
|
id: item.id,
|
||||||
|
name: item.realName,
|
||||||
|
amount: item.amount,
|
||||||
|
time: this.formatDate(item.donationDate)
|
||||||
|
}))
|
||||||
|
|
||||||
|
// 如果是第一页,直接替换数据
|
||||||
|
if (this.pageNum === 1) {
|
||||||
|
this.donationList = newData
|
||||||
} else {
|
} else {
|
||||||
this.donationList = mockData
|
// 如果是加载更多,追加数据
|
||||||
|
this.donationList = [...this.donationList, ...newData]
|
||||||
|
}
|
||||||
|
|
||||||
|
// 判断是否还有更多数据
|
||||||
|
this.hasMore = newData.length === this.pageSize
|
||||||
|
} else {
|
||||||
|
uni.showToast({
|
||||||
|
title: response.msg || '获取数据失败',
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
@ -152,6 +182,16 @@ export default {
|
||||||
} finally {
|
} finally {
|
||||||
this.loading = false
|
this.loading = false
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// 格式化日期
|
||||||
|
formatDate(dateStr) {
|
||||||
|
if (!dateStr) return ''
|
||||||
|
const date = new Date(dateStr)
|
||||||
|
const year = date.getFullYear()
|
||||||
|
const month = String(date.getMonth() + 1).padStart(2, '0')
|
||||||
|
const day = String(date.getDate()).padStart(2, '0')
|
||||||
|
return `${year}/${month}/${day}`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -80,10 +80,16 @@ export default {
|
||||||
// 处理查看详细
|
// 处理查看详细
|
||||||
handleViewDetail(data) {
|
handleViewDetail(data) {
|
||||||
console.log('查看详细:', data.item)
|
console.log('查看详细:', data.item)
|
||||||
// 这里可以添加跳转到详情页面的逻辑
|
// 跳转到捐款记录页面,传递建制ID
|
||||||
|
uni.navigateTo({
|
||||||
|
url: `/pages/institutionalStructure/donationRecord?formedId=${data.item.formedId}`,
|
||||||
|
fail: (err) => {
|
||||||
|
console.error('跳转失败:', err);
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: '查看详细功能开发中',
|
title: '页面跳转失败',
|
||||||
icon: 'none'
|
icon: 'none'
|
||||||
|
});
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,16 @@ export class InstitutionalDataFormatter {
|
||||||
* @returns {string} 格式化后的内容
|
* @returns {string} 格式化后的内容
|
||||||
*/
|
*/
|
||||||
static formatTopLeft(year, projectName) {
|
static formatTopLeft(year, projectName) {
|
||||||
if (!year || !projectName) return '暂无数据'
|
// 如果年份和项目名称都为空,返回暂无数据
|
||||||
|
if (!year && !projectName) return '暂无数据'
|
||||||
|
|
||||||
|
// 如果只有年份,只显示年份
|
||||||
|
if (year && !projectName) return `${year}年`
|
||||||
|
|
||||||
|
// 如果只有项目名称,只显示项目名称
|
||||||
|
if (!year && projectName) return projectName
|
||||||
|
|
||||||
|
// 如果都有,显示完整格式
|
||||||
return `${year}年 ${projectName}`
|
return `${year}年 ${projectName}`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -55,11 +64,19 @@ export class InstitutionalDataFormatter {
|
||||||
* @returns {Array} 转换后的数据
|
* @returns {Array} 转换后的数据
|
||||||
*/
|
*/
|
||||||
static transformData(rows) {
|
static transformData(rows) {
|
||||||
return rows.map(item => ({
|
console.log('原始数据:', rows) // 添加调试日志
|
||||||
topLeft: InstitutionalDataFormatter.formatTopLeft(item.startYear, item.proName),
|
|
||||||
|
return rows.map(item => {
|
||||||
|
console.log('处理项目:', item) // 添加调试日志
|
||||||
|
|
||||||
|
return {
|
||||||
|
topLeft: InstitutionalDataFormatter.formatTopLeft(item.startYear || item.start_year || item.year, item.proName || item.pro_name || item.projectName),
|
||||||
topRight: InstitutionalDataFormatter.getStatusText(item.state),
|
topRight: InstitutionalDataFormatter.getStatusText(item.state),
|
||||||
bottomLeft: `建造金额:${InstitutionalDataFormatter.formatAmount(item.totalAmount)}`,
|
bottomLeft: `建造金额:${InstitutionalDataFormatter.formatAmount(item.totalAmount || item.total_amount)}`,
|
||||||
bottomRight: `捐赠人数:${item.donorCount}人`
|
bottomRight: `捐赠人数:${item.donorCount || item.donor_count || 0}人`,
|
||||||
}))
|
// 保存原始数据,用于跳转
|
||||||
|
formedId: item.id
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user