Files
im-uniapp/pages/workbench/cost/components/Detail.vue
2025-10-14 13:58:33 +08:00

242 lines
5.3 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<view class="cost-detail-container">
<!-- 新增根元素包裹所有内容 -->
<view class="content-wrapper">
<!-- 1. Tab 切换 -->
<view class="tab-header">
<view
class="tab-item"
:class="activeTab === 'material' ? 'tab-active' : ''"
@click="activeTab = 'material'"
>
物料花费详情
</view>
<view
class="tab-item"
:class="activeTab === 'user' ? 'tab-active' : ''"
@click="activeTab = 'user'"
>
人力成本
</view>
</view>
<!-- 2. 加载状态 -->
<view v-if="loading" class="loading-view">
<uni-loading-icon size="24" color="#007aff"></uni-loading-icon>
<text class="loading-text">加载中...</text>
</view>
<!-- 3. 物料花费详情 Tab -->
<view v-else-if="activeTab === 'material'" class="list-container">
<!-- 卡片列表 -->
<view
class="list-card"
v-for="(item, index) in detailData.materialList"
:key="item.id || index"
>
<view class="field-group">
<text class="field-label">出账名称</text>
<text class="field-value">{{ item.detailTitle || '-' }}</text>
</view>
<view class="field-group">
<text class="field-label">金额</text>
<text class="field-value text-red">-{{ item.price || 0 }}</text>
</view>
<view class="field-group">
<text class="field-label">经手人</text>
<text class="field-value">{{ item.financeParties || '-' }}</text>
</view>
<view class="field-group field-remark">
<text class="field-label">备注</text>
<text class="field-value">{{ item.remark || '无备注' }}</text>
</view>
</view>
<!-- 空数据提示 -->
<view v-if="!detailData.materialList.length" class="empty-tip">
<text>暂无物料花费数据</text>
</view>
</view>
<!-- 4. 人力成本 Tab -->
<view v-else-if="activeTab === 'user'" class="list-container">
<!-- 卡片列表 -->
<view
class="list-card"
v-for="(item, index) in detailData.userCostList"
:key="item.id || index"
>
<view class="field-group">
<text class="field-label">人员名称</text>
<text class="field-value">{{ item.nickName || '-' }}</text>
</view>
<view class="field-group">
<text class="field-label">人员成本</text>
<text class="field-value text-blue">{{ item.laborCost || 0 }}</text>
</view>
<view class="field-group">
<text class="field-label">人天计算</text>
<text class="field-value">{{ item.attendanceNum || '-' }}</text>
</view>
</view>
<!-- 空数据提示 -->
<view v-if="!detailData.userCostList.length" class="empty-tip">
<text>暂无人力成本数据</text>
</view>
</view>
</view>
</view>
</template>
<script>
export default {
props: {
detailData: {
required: true,
type: Object,
default: () => ({
materialList: [],
userCostList: []
})
},
loading: {
type: Boolean,
default: false
}
},
data() {
return {
activeTab: 'material'
};
}
};
</script>
<style scoped>
.cost-detail-container {
width: 100vw;
max-height: 90vh;
padding: 12rpx;
overflow-y: scroll;
box-sizing: border-box;
background-color: #f5f5f5;
}
/* 新增的根容器样式(可根据需要调整) */
.content-wrapper {
width: 100%;
}
.tab-header {
display: flex;
flex-direction: row;
margin-bottom: 20rpx;
background-color: #fff;
border-radius: 8rpx;
overflow: hidden;
}
.tab-item {
flex: 1;
text-align: center;
padding: 18rpx 0;
font-size: 26rpx;
color: #666;
cursor: pointer;
}
.tab-active {
color: #007aff;
font-weight: 500;
position: relative;
}
.tab-active::after {
content: '';
position: absolute;
bottom: 0;
left: 0;
width: 100%;
height: 4rpx;
background-color: #007aff;
}
.loading-view {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 150rpx 0;
}
.loading-text {
margin-top: 20rpx;
font-size: 24rpx;
color: #666;
}
.list-container {
width: 100%;
display: flex;
flex-direction: column;
gap: 16rpx;
}
.list-card {
background-color: #fff;
border-radius: 12rpx;
padding: 24rpx;
box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.05);
}
.field-group {
display: flex;
flex-direction: row;
margin-bottom: 18rpx;
align-items: flex-start;
}
.field-group:last-child {
margin-bottom: 0;
}
.field-label {
width: 140rpx;
font-size: 24rpx;
color: #999;
white-space: nowrap;
}
.field-value {
flex: 1;
font-size: 24rpx;
color: #333;
line-height: 36rpx;
}
.text-red {
color: #ff4d4f;
}
.text-blue {
color: #007aff;
}
.field-remark .field-value {
word-wrap: break-word;
word-break: break-all;
}
.empty-tip {
display: flex;
justify-content: center;
align-items: center;
padding: 150rpx 0;
font-size: 24rpx;
color: #999;
background-color: #fff;
border-radius: 12rpx;
margin-top: 16rpx;
}
</style>