spring
6 小时以前 cc3001ab9e0ab8ce673b812a22ebea1edd332f2a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
<template>
  <view class="detail-page">
    <PageHeader title="库存详情" @back="goBack" />
    <view v-if="loading" class="loading-wrap">
      <text class="loading-text">加载中...</text>
    </view>
    <view v-else-if="detail" class="detail-wrap">
      <!-- 基础信息 -->
      <view class="section-card">
        <view class="section-head">
          <view class="section-dot"></view>
          <text class="section-title">基础信息</text>
        </view>
        <view class="section-body">
          <view class="detail-row">
            <text class="label">序号</text>
            <text class="value">{{ detail.index ?? '-' }}</text>
          </view>
          <view class="detail-row">
            <text class="label">产品大类</text>
            <text class="value value-strong">{{ detail.productName || '-' }}</text>
          </view>
          <view class="detail-row">
            <text class="label">规格型号</text>
            <text class="value">{{ detail.model || '-' }}</text>
          </view>
          <view class="detail-row">
            <text class="label">单位</text>
            <text class="value">{{ detail.unit || '-' }}</text>
          </view>
        </view>
      </view>
      <!-- 库存信息 -->
      <view class="section-card">
        <view class="section-head">
          <view class="section-dot"></view>
          <text class="section-title">库存信息</text>
        </view>
        <view class="section-body">
          <view class="detail-row">
            <text class="label">总库存数</text>
            <text class="value value-num">{{ detail.qualitity ?? '-' }}</text>
          </view>
          <view class="detail-row">
            <text class="label">冻结数量</text>
            <text class="value">{{ detail.lockedQuantity ?? 0 }}</text>
          </view>
          <view class="detail-row">
            <text class="label">可用库存</text>
            <text class="value">{{ detail.unLockedQuantity ?? (detail.qualitity - (detail.lockedQuantity || 0)) }}</text>
          </view>
          <view class="detail-row">
            <text class="label">最近更新时间</text>
            <text class="value">{{ detail.updateTime || '-' }}</text>
          </view>
        </view>
      </view>
    </view>
    <view v-else class="empty">
      <text class="empty-text">暂无详情数据</text>
    </view>
  </view>
</template>
 
<script setup>
import { ref } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import PageHeader from '@/components/PageHeader.vue'
 
const detail = ref(null)
const loading = ref(true)
 
function normalizeDetail(raw) {
  if (!raw) return null
  const d = typeof raw === 'object' ? raw : {}
  return {
    index: d.index ?? 1,
    productName: d.productName,
    model: d.model,
    unit: d.unit,
    qualitity: d.qualitity,
    lockedQuantity: d.lockedQuantity,
    unLockedQuantity: d.unLockedQuantity,
    updateTime: d.updateTime
  }
}
 
onLoad(() => {
  const cached = uni.getStorageSync('stockDetailItem')
  if (cached) {
    try {
      const payload = typeof cached === 'string' ? JSON.parse(cached) : cached
      const item = payload && payload.item != null ? payload.item : payload
      detail.value = normalizeDetail({ ...item, index: 1 })
      uni.removeStorageSync('stockDetailItem')
    } catch (e) {
      uni.removeStorageSync('stockDetailItem')
    }
  }
  loading.value = false
})
 
const goBack = () => uni.navigateBack()
</script>
 
<style lang="scss" scoped>
.detail-page {
  min-height: 100vh;
  background: linear-gradient(180deg, #e8eef7 0%, #f2f5fa 100%);
  padding-bottom: 48rpx;
}
.loading-wrap {
  padding: 120rpx 48rpx;
  text-align: center;
}
.loading-text {
  color: #8c9aa8;
  font-size: 28rpx;
}
.empty {
  padding: 120rpx 48rpx;
  text-align: center;
}
.empty-text {
  color: #8c9aa8;
  font-size: 28rpx;
}
.detail-wrap {
  padding: 24rpx 24rpx 32rpx;
}
.section-card {
  background: #fff;
  border-radius: 24rpx;
  overflow: hidden;
  margin-bottom: 28rpx;
  box-shadow: 0 8rpx 32rpx rgba(41, 121, 255, 0.06);
  border: 1rpx solid rgba(41, 121, 255, 0.06);
}
.section-head {
  display: flex;
  align-items: center;
  padding: 28rpx 32rpx;
  background: linear-gradient(135deg, #f8fbff 0%, #f0f6ff 100%);
  border-bottom: 1rpx solid #eef3fa;
}
.section-dot {
  width: 8rpx;
  height: 8rpx;
  border-radius: 50%;
  background: #2979ff;
  margin-right: 16rpx;
}
.section-title {
  font-size: 30rpx;
  font-weight: 600;
  color: #1e3a5f;
  letter-spacing: 0.5rpx;
}
.section-body {
  padding: 8rpx 32rpx 24rpx;
}
.detail-row {
  display: flex;
  align-items: center;
  min-height: 96rpx;
  padding: 0 16rpx;
  border-radius: 12rpx;
  font-size: 28rpx;
  margin-bottom: 4rpx;
}
.detail-row .label {
  width: 220rpx;
  flex-shrink: 0;
  color: #6b7c93;
  font-size: 26rpx;
}
.detail-row .value {
  flex: 1;
  color: #2c3e50;
  text-align: right;
  word-break: break-all;
  font-size: 28rpx;
}
.detail-row .value-strong {
  color: #1e3a5f;
  font-weight: 500;
}
.detail-row .value-num {
  color: #2979ff;
  font-weight: 600;
  font-size: 32rpx;
}
</style>