建制项中的货币单位都改为“元”,捐款人数的暂无数据改为招募中
This commit is contained in:
parent
55883c67b9
commit
4716301b44
|
|
@ -2,8 +2,8 @@
|
|||
<view class="data">
|
||||
<!-- 标题和状态行 -->
|
||||
<view class="header-row">
|
||||
<view class="project-title">{{ item.topLeft || '暂无数据' }}</view>
|
||||
<view class="status">{{ item.topRight || '暂无数据' }}</view>
|
||||
<view class="project-title">{{ item.topLeft || "暂无数据" }}</view>
|
||||
<view class="status">{{ item.topRight || "暂无数据" }}</view>
|
||||
</view>
|
||||
|
||||
<!-- 详细信息表格 -->
|
||||
|
|
@ -15,154 +15,158 @@
|
|||
<text class="label detail-col">捐赠名单</text>
|
||||
</view>
|
||||
<view class="table-row">
|
||||
<text class="value year-col">{{ item.year || '暂无数据' }}</text>
|
||||
<text class="value amount-col">{{ item.amount || '暂无数据' }}</text>
|
||||
<text class="value donor-col">{{ item.donorCount || '暂无数据' }}</text>
|
||||
<text class="view-details detail-col" @click="onViewDetail">查看详情</text>
|
||||
<text class="value year-col">{{ item.year || "暂无数据" }}</text>
|
||||
<text class="value amount-col">{{ item.amount || "暂无数据" }}</text>
|
||||
<text class="value donor-col">{{
|
||||
item.donorCount || "持续招募中"
|
||||
}}</text>
|
||||
<text class="view-details detail-col" @click="onViewDetail"
|
||||
>查看详情</text
|
||||
>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'InstitutionalItem',
|
||||
props: {
|
||||
// 数据项
|
||||
item: {
|
||||
type: Object,
|
||||
required: true,
|
||||
default: () => ({
|
||||
topLeft: '',
|
||||
topRight: '',
|
||||
bottomLeft: '',
|
||||
bottomRight: '',
|
||||
}),
|
||||
},
|
||||
// 数据索引
|
||||
index: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
export default {
|
||||
name: "InstitutionalItem",
|
||||
props: {
|
||||
// 数据项
|
||||
item: {
|
||||
type: Object,
|
||||
required: true,
|
||||
default: () => ({
|
||||
topLeft: "",
|
||||
topRight: "",
|
||||
bottomLeft: "",
|
||||
bottomRight: "",
|
||||
}),
|
||||
},
|
||||
methods: {
|
||||
// 查看详细
|
||||
onViewDetail() {
|
||||
// 触发父组件的事件
|
||||
this.$emit('view-detail', {
|
||||
item: this.item,
|
||||
index: this.index,
|
||||
})
|
||||
},
|
||||
// 数据索引
|
||||
index: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
// 查看详细
|
||||
onViewDetail() {
|
||||
// 触发父组件的事件
|
||||
this.$emit("view-detail", {
|
||||
item: this.item,
|
||||
index: this.index,
|
||||
});
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.data {
|
||||
background-color: #fffbf5;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
width: 720rpx;
|
||||
box-sizing: border-box;
|
||||
min-height: 180rpx;
|
||||
border-radius: 11px;
|
||||
border: 1px solid #c7a26d;
|
||||
margin: 15rpx auto;
|
||||
padding: 12rpx;
|
||||
}
|
||||
.data {
|
||||
background-color: #fffbf5;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
width: 720rpx;
|
||||
box-sizing: border-box;
|
||||
min-height: 180rpx;
|
||||
border-radius: 11px;
|
||||
border: 1px solid #c7a26d;
|
||||
margin: 15rpx auto;
|
||||
padding: 12rpx;
|
||||
}
|
||||
|
||||
.header-row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 15rpx;
|
||||
padding-bottom: 12rpx;
|
||||
}
|
||||
.header-row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 15rpx;
|
||||
padding-bottom: 12rpx;
|
||||
}
|
||||
|
||||
.project-title {
|
||||
font-size: 32rpx;
|
||||
font-weight: 500;
|
||||
color: #522510;
|
||||
flex: 1;
|
||||
}
|
||||
.project-title {
|
||||
font-size: 32rpx;
|
||||
font-weight: 500;
|
||||
color: #522510;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.status {
|
||||
font-size: 28rpx;
|
||||
color: #7f7f7f;
|
||||
padding: 8rpx 16rpx;
|
||||
border-radius: 20rpx;
|
||||
}
|
||||
.status {
|
||||
font-size: 28rpx;
|
||||
color: #7f7f7f;
|
||||
padding: 8rpx 16rpx;
|
||||
border-radius: 20rpx;
|
||||
}
|
||||
|
||||
.details-table {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10rpx;
|
||||
}
|
||||
.details-table {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10rpx;
|
||||
}
|
||||
|
||||
.table-row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
gap: 10rpx;
|
||||
width: 100%;
|
||||
}
|
||||
.table-row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
gap: 10rpx;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.label {
|
||||
font-size: 26rpx;
|
||||
color: #7c736e;
|
||||
font-weight: 500;
|
||||
flex: 1;
|
||||
text-align: left;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
.label {
|
||||
font-size: 26rpx;
|
||||
color: #7c736e;
|
||||
font-weight: 500;
|
||||
flex: 1;
|
||||
text-align: left;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.value {
|
||||
font-size: 26rpx;
|
||||
color: #695347;
|
||||
font-weight: 600;
|
||||
flex: 1;
|
||||
text-align: left;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
.value {
|
||||
font-size: 26rpx;
|
||||
color: #695347;
|
||||
font-weight: 600;
|
||||
flex: 1;
|
||||
text-align: left;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.view-details {
|
||||
font-size: 28rpx;
|
||||
color: #522510;
|
||||
font-weight: 500;
|
||||
.view-details {
|
||||
font-size: 28rpx;
|
||||
color: #522510;
|
||||
font-weight: 500;
|
||||
|
||||
cursor: pointer;
|
||||
flex: 1;
|
||||
text-align: left;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
cursor: pointer;
|
||||
flex: 1;
|
||||
text-align: left;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.view-details:active {
|
||||
opacity: 0.7;
|
||||
}
|
||||
.view-details:active {
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
/* 不同列的弹性比例 */
|
||||
.year-col {
|
||||
flex: 1;
|
||||
}
|
||||
/* 不同列的弹性比例 */
|
||||
.year-col {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.amount-col {
|
||||
flex: 1.5;
|
||||
}
|
||||
.amount-col {
|
||||
flex: 1.5;
|
||||
}
|
||||
|
||||
.donor-col {
|
||||
flex: 1;
|
||||
}
|
||||
.donor-col {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.detail-col {
|
||||
flex: 0 0 auto;
|
||||
margin-left: auto;
|
||||
min-width: 80rpx;
|
||||
}
|
||||
.detail-col {
|
||||
flex: 0 0 auto;
|
||||
margin-left: auto;
|
||||
min-width: 80rpx;
|
||||
}
|
||||
</style>
|
||||
|
|
|
|||
|
|
@ -8,15 +8,15 @@ export class InstitutionalDataFormatter {
|
|||
* @returns {string} 格式化后的金额字符串
|
||||
*/
|
||||
static formatAmount(amount) {
|
||||
if (!amount) return '不详'
|
||||
if (!amount) return "不详";
|
||||
|
||||
// 超过一亿以亿为单位
|
||||
if (amount >= 100000000) {
|
||||
return `约${(amount / 100000000).toFixed(1)}亿`
|
||||
return `约${(amount / 100000000).toFixed(1)}亿`;
|
||||
} else if (amount >= 10000) {
|
||||
return `约${(amount / 10000).toFixed(1)}万`
|
||||
return `约${(amount / 10000).toFixed(1)}万`;
|
||||
} else {
|
||||
return `约${amount.toLocaleString()}元`
|
||||
return `约${amount.toLocaleString()}元`;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -26,16 +26,16 @@ export class InstitutionalDataFormatter {
|
|||
* @param {string} currency 货币单位
|
||||
* @returns {string} 格式化后的金额字符串
|
||||
*/
|
||||
static formatHistoricalAmount(amount, currency = '银元') {
|
||||
if (!amount) return '不详'
|
||||
static formatHistoricalAmount(amount, currency = "银元") {
|
||||
if (!amount) return "不详";
|
||||
|
||||
// 超过一亿以亿为单位
|
||||
if (amount >= 100000000) {
|
||||
return `约${currency}${(amount / 100000000).toFixed(1)}亿`
|
||||
return `约${currency}${(amount / 100000000).toFixed(1)}亿`;
|
||||
} else if (amount >= 10000) {
|
||||
return `约${currency}${(amount / 10000).toFixed(0)}万`
|
||||
return `约${currency}${(amount / 10000).toFixed(0)}万`;
|
||||
} else {
|
||||
return `约${currency}${amount.toLocaleString()}`
|
||||
return `约${currency}${amount.toLocaleString()}`;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -46,8 +46,8 @@ export class InstitutionalDataFormatter {
|
|||
*/
|
||||
static formatTopLeft(projectName) {
|
||||
// 如果年份和项目名称都为空,返回暂无数据
|
||||
if (!projectName) return '暂无数据'
|
||||
return projectName
|
||||
if (!projectName) return "暂无数据";
|
||||
return projectName;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -57,15 +57,15 @@ export class InstitutionalDataFormatter {
|
|||
* @returns {string} 格式化后的项目名称
|
||||
*/
|
||||
static formatProjectName(projectName, isHistorical = false) {
|
||||
if (!projectName) return '暂无数据'
|
||||
if (!projectName) return "暂无数据";
|
||||
|
||||
// 如果是历史项目,可能需要特殊处理
|
||||
if (isHistorical && projectName.includes('寺')) {
|
||||
if (isHistorical && projectName.includes("寺")) {
|
||||
// 对于寺庙项目,保持原有格式
|
||||
return projectName
|
||||
return projectName;
|
||||
}
|
||||
|
||||
return projectName
|
||||
return projectName;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -74,14 +74,14 @@ export class InstitutionalDataFormatter {
|
|||
* @returns {string} 格式化后的年份
|
||||
*/
|
||||
static formatYear(year) {
|
||||
if (!year) return '暂无数据'
|
||||
if (!year) return "暂无数据";
|
||||
|
||||
// 如果已经是格式化过的字符串(包含"年"字),直接返回
|
||||
if (typeof year === 'string' && year.includes('年')) {
|
||||
return year
|
||||
if (typeof year === "string" && year.includes("年")) {
|
||||
return year;
|
||||
}
|
||||
|
||||
return `${year}年`
|
||||
return `${year}年`;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -90,30 +90,30 @@ export class InstitutionalDataFormatter {
|
|||
* @returns {string} 格式化后的年份
|
||||
*/
|
||||
static formatHistoricalYear(year) {
|
||||
if (!year) return '暂无数据'
|
||||
if (!year) return "暂无数据";
|
||||
|
||||
// 如果已经是格式化过的字符串,直接返回
|
||||
if (typeof year === 'string') {
|
||||
if (year.includes('年')) {
|
||||
return year
|
||||
if (typeof year === "string") {
|
||||
if (year.includes("年")) {
|
||||
return year;
|
||||
}
|
||||
if (year.includes('时期') || year.includes('朝代')) {
|
||||
return year
|
||||
if (year.includes("时期") || year.includes("朝代")) {
|
||||
return year;
|
||||
}
|
||||
}
|
||||
|
||||
// 如果是公元前的年份
|
||||
if (year < 0) {
|
||||
return `公元前${Math.abs(year)}年`
|
||||
return `公元前${Math.abs(year)}年`;
|
||||
}
|
||||
|
||||
// 如果是公元后的年份,但小于1000年
|
||||
if (year < 1000) {
|
||||
return `${year}年`
|
||||
return `${year}年`;
|
||||
}
|
||||
|
||||
// 正常年份
|
||||
return `${year}年`
|
||||
return `${year}年`;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -123,16 +123,16 @@ export class InstitutionalDataFormatter {
|
|||
*/
|
||||
static getStatusText(state) {
|
||||
switch (state) {
|
||||
case '1':
|
||||
return '规划'
|
||||
case '2':
|
||||
return '进行中'
|
||||
case '3':
|
||||
return '已完成'
|
||||
case '4':
|
||||
return '已取消'
|
||||
case "1":
|
||||
return "规划";
|
||||
case "2":
|
||||
return "进行中";
|
||||
case "3":
|
||||
return "已完成";
|
||||
case "4":
|
||||
return "已取消";
|
||||
default:
|
||||
return '未知状态'
|
||||
return "未知状态";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -142,31 +142,35 @@ export class InstitutionalDataFormatter {
|
|||
* @returns {boolean} 是否为历史项目
|
||||
*/
|
||||
static isHistoricalProject(year) {
|
||||
if (!year) return false
|
||||
if (!year) return false;
|
||||
|
||||
// 处理字符串格式的年份(如"916年"、"明末时期")
|
||||
if (typeof year === 'string') {
|
||||
if (typeof year === "string") {
|
||||
// 如果包含"年"字,提取数字部分
|
||||
if (year.includes('年')) {
|
||||
const yearNum = parseInt(year.replace('年', ''))
|
||||
return yearNum < 1900
|
||||
if (year.includes("年")) {
|
||||
const yearNum = parseInt(year.replace("年", ""));
|
||||
return yearNum < 1900;
|
||||
}
|
||||
|
||||
// 如果包含历史时期描述,认为是历史项目
|
||||
if (year.includes('时期') || year.includes('朝代') || year.includes('古代')) {
|
||||
return true
|
||||
if (
|
||||
year.includes("时期") ||
|
||||
year.includes("朝代") ||
|
||||
year.includes("古代")
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// 尝试解析纯数字
|
||||
const yearNum = parseInt(year)
|
||||
const yearNum = parseInt(year);
|
||||
if (!isNaN(yearNum)) {
|
||||
return yearNum < 1900
|
||||
return yearNum < 1900;
|
||||
}
|
||||
}
|
||||
|
||||
// 处理数字格式的年份
|
||||
const yearNum = parseInt(year)
|
||||
return yearNum < 1900
|
||||
const yearNum = parseInt(year);
|
||||
return yearNum < 1900;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -176,12 +180,12 @@ export class InstitutionalDataFormatter {
|
|||
* @returns {string} 格式化后的人数
|
||||
*/
|
||||
static formatDonorCount(count, isHistorical = false) {
|
||||
if (!count || count === 0) return '暂无数据'
|
||||
if (!count || count === 0) return "持续招募中";
|
||||
|
||||
if (isHistorical) {
|
||||
return `约${count}人`
|
||||
return `约${count}人`;
|
||||
} else {
|
||||
return `${count}人`
|
||||
return `${count}人`;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -191,36 +195,45 @@ export class InstitutionalDataFormatter {
|
|||
* @returns {Array} 转换后的数据
|
||||
*/
|
||||
static transformData(rows) {
|
||||
console.log('原始数据:', rows) // 添加调试日志
|
||||
console.log("原始数据:", rows); // 添加调试日志
|
||||
|
||||
return rows.map(item => {
|
||||
console.log('处理项目:', item) // 添加调试日志
|
||||
return rows.map((item) => {
|
||||
console.log("处理项目:", item); // 添加调试日志
|
||||
|
||||
const year = item.formedYear || item.startYear || item.start_year || item.year
|
||||
const isHistorical = InstitutionalDataFormatter.isHistoricalProject(year)
|
||||
const year =
|
||||
item.formedYear || item.startYear || item.start_year || item.year;
|
||||
const isHistorical = InstitutionalDataFormatter.isHistoricalProject(year);
|
||||
|
||||
const projectName = item.proName || item.pro_name || item.projectName
|
||||
const projectName = item.proName || item.pro_name || item.projectName;
|
||||
|
||||
return {
|
||||
topLeft: InstitutionalDataFormatter.formatTopLeft(
|
||||
InstitutionalDataFormatter.formatProjectName(projectName, isHistorical)
|
||||
InstitutionalDataFormatter.formatProjectName(
|
||||
projectName,
|
||||
isHistorical,
|
||||
),
|
||||
),
|
||||
topRight: InstitutionalDataFormatter.getStatusText(item.state),
|
||||
year: isHistorical
|
||||
? InstitutionalDataFormatter.formatHistoricalYear(year)
|
||||
: InstitutionalDataFormatter.formatYear(year),
|
||||
amount: isHistorical
|
||||
? InstitutionalDataFormatter.formatHistoricalAmount(item.totalAmount || item.total_amount)
|
||||
: InstitutionalDataFormatter.formatAmount(item.totalAmount || item.total_amount),
|
||||
? // ? InstitutionalDataFormatter.formatHistoricalAmount(
|
||||
InstitutionalDataFormatter.formatAmount(
|
||||
item.totalAmount || item.total_amount,
|
||||
)
|
||||
: InstitutionalDataFormatter.formatAmount(
|
||||
item.totalAmount || item.total_amount,
|
||||
),
|
||||
donorCount: InstitutionalDataFormatter.formatDonorCount(
|
||||
item.donorCount || item.donor_count || 0,
|
||||
isHistorical
|
||||
isHistorical,
|
||||
),
|
||||
// 保存原始数据,用于跳转
|
||||
formedId: item.id,
|
||||
// 保存项目类型信息
|
||||
isHistorical: isHistorical,
|
||||
}
|
||||
})
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user