detail.vue
8.73 KB
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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
<template>
<el-dialog
title="购买记录详情"
:visible.sync="visible"
:close-on-click-modal="false"
class="NCC-dialog NCC-dialog_center"
width="1200px"
@close="handleClose">
<div class="detail-content" v-loading="loading">
<!-- 基本信息卡片 -->
<el-card class="info-card" shadow="hover">
<div slot="header" class="card-header">
<i class="el-icon-shopping-cart-full"></i>
<span class="card-title">基本信息</span>
</div>
<el-row :gutter="20">
<el-col :span="8">
<div class="info-item">
<label class="info-label">记录编号:</label>
<span class="info-value">{{ dataForm.id || '无' }}</span>
</div>
</el-col>
<el-col :span="8">
<div class="info-item">
<label class="info-label">购买物品编号:</label>
<span class="info-value">{{ dataForm.reimbursementCategoryId || '无' }}</span>
</div>
</el-col>
<el-col :span="8">
<div class="info-item">
<label class="info-label">购买物品名称:</label>
<span class="info-value">{{ dataForm.reimbursementCategoryName || '无' }}</span>
</div>
</el-col>
<el-col :span="8">
<div class="info-item">
<label class="info-label">单价:</label>
<span class="info-value">{{ dataForm.unitPrice || '无' }}</span>
</div>
</el-col>
<el-col :span="8">
<div class="info-item">
<label class="info-label">数量:</label>
<span class="info-value">{{ dataForm.quantity || '无' }}</span>
</div>
</el-col>
<el-col :span="8">
<div class="info-item">
<label class="info-label">总金额:</label>
<span class="info-value amount">{{ dataForm.amount || '无' }}</span>
</div>
</el-col>
<el-col :span="24">
<div class="info-item">
<label class="info-label">备注说明:</label>
<span class="info-value">{{ dataForm.memo || '无' }}</span>
</div>
</el-col>
<el-col :span="8">
<div class="info-item">
<label class="info-label">购买时间:</label>
<span class="info-value">{{ formatDate(dataForm.purchaseTime) || '无' }}</span>
</div>
</el-col>
</el-row>
</el-card>
<!-- 附件信息卡片 -->
<el-card class="info-card" shadow="hover" v-if="dataForm.attachment && dataForm.attachment.length > 0">
<div slot="header" class="card-header">
<i class="el-icon-paperclip"></i>
<span class="card-title">附件</span>
</div>
<div class="attachment-list">
<div v-for="(file, index) in dataForm.attachment" :key="index" class="attachment-item">
<i class="el-icon-document"></i>
<a :href="file.url || file" target="_blank" class="attachment-link">{{ file.name || file }}</a>
</div>
</div>
</el-card>
<!-- 创建信息卡片 -->
<el-card class="info-card" shadow="hover">
<div slot="header" class="card-header">
<i class="el-icon-user"></i>
<span class="card-title">创建信息</span>
</div>
<el-row :gutter="20">
<el-col :span="8">
<div class="info-item">
<label class="info-label">创建时间:</label>
<span class="info-value">{{ formatDate(dataForm.createTime) || '无' }}</span>
</div>
</el-col>
<el-col :span="8">
<div class="info-item">
<label class="info-label">创建人:</label>
<span class="info-value">{{ getUserName(dataForm.createUser) || '无' }}</span>
</div>
</el-col>
<el-col :span="8">
<div class="info-item">
<label class="info-label">创建人门店:</label>
<span class="info-value">{{ getStoreName(dataForm.createUserStoreId) || '无' }}</span>
</div>
</el-col>
</el-row>
</el-card>
<!-- 审批信息卡片 -->
<el-card class="info-card" shadow="hover">
<div slot="header" class="card-header">
<i class="el-icon-check"></i>
<span class="card-title">审批信息</span>
</div>
<el-row :gutter="20">
<el-col :span="8">
<div class="info-item">
<label class="info-label">审批状态:</label>
<span class="info-value" :class="{'status-approved': dataForm.approveStatus === '已审批', 'status-pending': dataForm.approveStatus === '未审批'}">
{{ dataForm.approveStatus || '无' }}
</span>
</div>
</el-col>
<el-col :span="8">
<div class="info-item">
<label class="info-label">审批人:</label>
<span class="info-value">{{ getUserName(dataForm.approveUser) || '无' }}</span>
</div>
</el-col>
<el-col :span="8">
<div class="info-item">
<label class="info-label">审批时间:</label>
<span class="info-value">{{ formatDate(dataForm.approveTime) || '无' }}</span>
</div>
</el-col>
<el-col :span="8">
<div class="info-item">
<label class="info-label">审批单编号:</label>
<span class="info-value">{{ dataForm.applicationId || '无' }}</span>
</div>
</el-col>
</el-row>
</el-card>
</div>
<span slot="footer" class="dialog-footer">
<el-button @click="visible = false">关 闭</el-button>
</span>
</el-dialog>
</template>
<script>
import request from '@/utils/request'
export default {
name: 'PurchaseRecordDetail',
data() {
return {
visible: false,
loading: false,
dataForm: {},
storeOptions: [],
userMap: {} // 用户ID到用户名的映射
}
},
methods: {
init(id) {
this.visible = true;
this.loading = true;
this.dataForm = {};
// 加载门店列表
this.loadStoreOptions();
// 加载详情数据
request({
url: '/api/Extend/LqPurchaseRecords/' + id,
method: 'GET'
}).then(res => {
this.dataForm = res.data || {};
if (!this.dataForm.attachment) {
this.dataForm.attachment = [];
}
// 加载用户信息
this.loadUserInfo();
this.loading = false;
}).catch(() => {
this.loading = false;
this.$message.error('加载详情失败');
});
},
// 加载门店列表
loadStoreOptions() {
request({
url: '/api/Extend/LqMdxx',
method: 'GET',
data: {
currentPage: 1,
pageSize: 1000
}
}).then(res => {
if (res.data && res.data.list) {
this.storeOptions = res.data.list;
}
}).catch(() => {
this.storeOptions = [];
});
},
// 格式化日期
formatDate(timestamp) {
if (!timestamp) return '';
const date = new Date(timestamp);
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}`;
},
// 获取门店名称
getStoreName(storeId) {
if (!storeId) return '';
const store = this.storeOptions.find(item => item.id === storeId);
return store ? store.dm : '';
},
// 加载用户信息
loadUserInfo() {
const userIds = [];
if (this.dataForm.createUser) {
userIds.push(this.dataForm.createUser);
}
if (this.dataForm.approveUser) {
userIds.push(this.dataForm.approveUser);
}
// 去重
const uniqueUserIds = [...new Set(userIds)];
// 批量加载用户信息
Promise.all(uniqueUserIds.map(userId => {
return request({
url: '/api/permission/Users/' + userId,
method: 'GET'
}).then(res => {
if (res.data) {
this.userMap[userId] = res.data.realName || res.data.account || userId;
}
}).catch(() => {
this.userMap[userId] = userId;
});
}));
},
// 获取用户名称
getUserName(userId) {
if (!userId) return '';
return this.userMap[userId] || userId;
},
handleClose() {
this.visible = false;
this.dataForm = {};
}
}
}
</script>
<style lang="scss" scoped>
.detail-content {
padding: 10px 0;
}
.info-card {
margin-bottom: 20px;
&:last-child {
margin-bottom: 0;
}
}
.card-header {
display: flex;
align-items: center;
i {
margin-right: 8px;
font-size: 16px;
color: #409EFF;
}
.card-title {
font-size: 16px;
font-weight: 600;
color: #303133;
}
}
.info-item {
margin-bottom: 16px;
display: flex;
align-items: flex-start;
.info-label {
min-width: 120px;
color: #909399;
font-size: 14px;
flex-shrink: 0;
}
.info-value {
color: #303133;
font-size: 14px;
word-break: break-all;
&.amount {
color: #F56C6C;
font-weight: 600;
}
&.status-approved {
color: #67C23A;
font-weight: 600;
}
&.status-pending {
color: #E6A23C;
font-weight: 600;
}
}
}
.attachment-list {
display: flex;
flex-wrap: wrap;
gap: 12px;
}
.attachment-item {
display: flex;
align-items: center;
padding: 8px 12px;
background: #f5f7fa;
border-radius: 4px;
i {
margin-right: 8px;
color: #409EFF;
}
}
.attachment-link {
color: #409EFF;
text-decoration: none;
&:hover {
text-decoration: underline;
}
}
</style>