2025-07-19 20:00:08 +08:00

191 lines
4.3 KiB
Vue

<template>
<view class="detail-container">
<common-header title="酒厂详情" theme="distiller" @back="goBack" />
<view class="detail-content">
<view class="detail-card">
<view class="detail-header">
<text class="detail-title">{{ distillerData.name || '酒厂名称' }}</text>
<view class="status-badge" :class="{
'active': distillerData.status === 1,
'inactive': distillerData.status === 0
}">
{{ distillerData.status === 1 ? '正常' : '停用' }}
</view>
</view>
<view class="detail-body">
<view class="detail-item">
<text class="item-label">酒厂地址</text>
<text class="item-value">{{ distillerData.address || '暂无地址' }}</text>
</view>
<view class="detail-item">
<text class="item-label">联系人</text>
<text class="item-value">{{ distillerData.contact || '暂无联系人' }}</text>
</view>
<view class="detail-item">
<text class="item-label">联系电话</text>
<text class="item-value">{{ distillerData.phone || '暂无电话' }}</text>
</view>
<view class="detail-item">
<text class="item-label">酒厂描述</text>
<text class="item-value">{{ distillerData.description || '暂无描述' }}</text>
</view>
<view class="detail-item">
<text class="item-label">创建时间</text>
<text class="item-value">{{ formatTime(distillerData.createTime) }}</text>
</view>
</view>
<view class="detail-actions">
<uni-button type="default" size="small" @click="editDistiller">编辑</uni-button>
<uni-button type="warn" size="small" @click="transferDistiller">转让</uni-button>
</view>
</view>
</view>
</view>
</template>
<script>
import CommonHeader from '@/components/common-header/common-header.vue'
export default {
name: 'DistillerDetail',
components: {
CommonHeader
},
data() {
return {
distillerData: {},
loading: false
}
},
onLoad(option) {
const { id } = option
if (id) {
this.getDistillerDetail(id)
}
},
methods: {
async getDistillerDetail(id) {
this.loading = true
try {
// TODO: Replace with actual API call
const response = await this.$http.get(`/brewery/distiller/${id}`)
this.distillerData = response.data || {}
} catch (error) {
console.error('获取酒厂详情失败:', error)
this.$modal.showToast('获取酒厂详情失败')
} finally {
this.loading = false
}
},
formatTime(time) {
if (!time) return ''
return time.substring(0, 16)
},
editDistiller() {
uni.navigateTo({
url: `/subpages/distiller/edit?id=${this.distillerData.id}`
})
},
transferDistiller() {
uni.navigateTo({
url: `/subpages/distiller/transfer?id=${this.distillerData.id}`
})
},
goBack() {
uni.navigateBack()
}
}
}
</script>
<style lang="scss" scoped>
.detail-container {
min-height: 100vh;
background: #f5f7fa;
}
.detail-content {
padding: 20rpx;
}
.detail-card {
background: #fff;
border-radius: 16rpx;
padding: 30rpx;
margin-bottom: 20rpx;
box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.08);
}
.detail-header {
display: flex;
justify-content: space-between;
align-items: flex-start;
margin-bottom: 30rpx;
padding-bottom: 20rpx;
border-bottom: 1px solid #f0f0f0;
}
.detail-title {
font-size: 32rpx;
font-weight: bold;
color: #333;
flex: 1;
}
.status-badge {
padding: 8rpx 16rpx;
border-radius: 20rpx;
font-size: 24rpx;
&.active {
background: #e8f5e8;
color: #52c41a;
}
&.inactive {
background: #f0f0f0;
color: #999;
}
}
.detail-body {
.detail-item {
margin-bottom: 24rpx;
.item-label {
display: block;
font-size: 28rpx;
color: #666;
margin-bottom: 8rpx;
}
.item-value {
font-size: 30rpx;
color: #333;
line-height: 1.5;
}
}
}
.detail-actions {
display: flex;
gap: 20rpx;
margin-top: 30rpx;
padding-top: 20rpx;
border-top: 1px solid #f0f0f0;
}
</style>