spring
8 天以前 ea6ad9ddc3d5b33897e93276282245f7023836ff
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
<template>
  <el-dialog
    :model-value="dialogViewVisible"
    @update:model-value="$emit('update:dialogViewVisible', $event)"
    :title="title"
    width="900px"
    :close-on-click-modal="false"
  >
    <div class="view-container">
      <!-- 基本信息 -->
      <el-card class="info-card" shadow="never">
        <template #header>
          <div class="card-header">
            <span>基本信息</span>
          </div>
        </template>
        <el-descriptions :column="2" border>
          <el-descriptions-item label="退货单号">
            {{ form.returnNo || '-' }}
          </el-descriptions-item>
          <el-descriptions-item label="供应商">
            {{ form.supplierName || '-' }}
          </el-descriptions-item>
          <el-descriptions-item label="单据日期">
            {{ form.returnDate || '-' }}
          </el-descriptions-item>
          <el-descriptions-item label="操作员">
            {{ form.operatorName || '-' }}
          </el-descriptions-item>
          <el-descriptions-item label="退货原因">
            {{ form.returnReason || '-' }}
          </el-descriptions-item>
          <el-descriptions-item label="状态">
            <el-tag :type="getStatusType(form.status)">
              {{ getStatusText(form.status) }}
            </el-tag>
          </el-descriptions-item>
          <el-descriptions-item label="退货数量">
            {{ form.returnQuantity || 0 }} 吨
          </el-descriptions-item>
          <el-descriptions-item label="退货金额">
            {{ form.returnAmount || 0 }} 元
          </el-descriptions-item>
          <el-descriptions-item label="创建时间" :span="2">
            {{ form.createTime || '-' }}
          </el-descriptions-item>
          <el-descriptions-item label="备注" :span="2">
            {{ form.remark || '-' }}
          </el-descriptions-item>
        </el-descriptions>
      </el-card>
 
      <!-- 退货商品明细 -->
      <el-card class="info-card" shadow="never">
        <template #header>
          <div class="card-header">
            <span>退货商品明细</span>
          </div>
        </template>
        <el-table :data="form.returnItems || []" border style="width: 100%">
          <el-table-column label="序号" type="index" width="60" />
          <el-table-column label="商品名称" prop="coalName" width="150" />
          <el-table-column label="规格型号" prop="specification" width="150" />
          <el-table-column label="数量" prop="quantity" width="100">
            <template #default="scope">
              {{ scope.row.quantity || 0 }} 吨
            </template>
          </el-table-column>
          <el-table-column label="单价" prop="unitPrice" width="120">
            <template #default="scope">
              {{ scope.row.unitPrice || 0 }} 元/吨
            </template>
          </el-table-column>
          <el-table-column label="小计" width="120">
            <template #default="scope">
              {{ ((scope.row.quantity || 0) * (scope.row.unitPrice || 0)).toFixed(2) }} 元
            </template>
          </el-table-column>
        </el-table>
        <div class="table-summary">
          <span class="summary-item">
            总数量:<strong>{{ getTotalQuantity() }} 吨</strong>
          </span>
          <span class="summary-item">
            总金额:<strong>{{ getTotalAmount() }} 元</strong>
          </span>
        </div>
      </el-card>
 
      <!-- 审批流程 -->
      <el-card class="info-card" shadow="never">
        <template #header>
          <div class="card-header">
            <span>审批流程</span>
          </div>
        </template>
        <el-timeline>
          <el-timeline-item
            v-for="(activity, index) in approvalFlow"
            :key="index"
            :timestamp="activity.timestamp"
            :type="activity.type"
          >
            <h4>{{ activity.title }}</h4>
            <p>{{ activity.content }}</p>
            <p v-if="activity.operator">操作人:{{ activity.operator }}</p>
          </el-timeline-item>
        </el-timeline>
      </el-card>
    </div>
 
    <template #footer>
      <div class="dialog-footer">
        <el-button @click="handleClose">关闭</el-button>
      </div>
    </template>
  </el-dialog>
</template>
 
<script setup>
import { computed } from "vue";
 
// Props
const props = defineProps({
  dialogViewVisible: {
    type: Boolean,
    default: false
  },
  form: {
    type: Object,
    default: () => ({})
  },
  title: {
    type: String,
    default: "退货单详情"
  }
});
 
// Emits
const emit = defineEmits(['update:dialogViewVisible']);
 
// 获取状态类型
const getStatusType = (status) => {
  const statusMap = {
    draft: "",
    pending: "warning",
    approved: "success",
    rejected: "danger",
    completed: "info"
  };
  return statusMap[status] || "";
};
 
// 获取状态文本
const getStatusText = (status) => {
  const statusMap = {
    draft: "草稿",
    pending: "待审核",
    approved: "已审核",
    rejected: "已拒绝",
    completed: "已完成"
  };
  return statusMap[status] || status;
};
 
// 计算总数量
const getTotalQuantity = () => {
  if (!props.form.returnItems || props.form.returnItems.length === 0) {
    return 0;
  }
  return props.form.returnItems.reduce((total, item) => total + (item.quantity || 0), 0);
};
 
// 计算总金额
const getTotalAmount = () => {
  if (!props.form.returnItems || props.form.returnItems.length === 0) {
    return 0;
  }
  return props.form.returnItems.reduce((total, item) => {
    return total + ((item.quantity || 0) * (item.unitPrice || 0));
  }, 0).toFixed(2);
};
 
// 审批流程数据
const approvalFlow = computed(() => {
  const flow = [];
  
  // 创建
  flow.push({
    title: "创建退货单",
    content: "退货单已创建,等待提交审核",
    timestamp: props.form.createTime || new Date().toLocaleString(),
    operator: props.form.operatorName || "系统",
    type: "primary"
  });
  
  // 根据状态添加审批流程
  if (props.form.status === "pending") {
    flow.push({
      title: "提交审核",
      content: "退货单已提交,等待审核",
      timestamp: new Date().toLocaleString(),
      operator: props.form.operatorName || "系统",
      type: "warning"
    });
  } else if (props.form.status === "approved") {
    flow.push({
      title: "提交审核",
      content: "退货单已提交,等待审核",
      timestamp: new Date().toLocaleString(),
      operator: props.form.operatorName || "系统",
      type: "warning"
    });
    flow.push({
      title: "审核通过",
      content: "退货单审核通过",
      timestamp: new Date().toLocaleString(),
      operator: "审核员",
      type: "success"
    });
  } else if (props.form.status === "rejected") {
    flow.push({
      title: "提交审核",
      content: "退货单已提交,等待审核",
      timestamp: new Date().toLocaleString(),
      operator: props.form.operatorName || "系统",
      type: "warning"
    });
    flow.push({
      title: "审核拒绝",
      content: "退货单审核被拒绝",
      timestamp: new Date().toLocaleString(),
      operator: "审核员",
      type: "danger"
    });
  } else if (props.form.status === "completed") {
    flow.push({
      title: "提交审核",
      content: "退货单已提交,等待审核",
      timestamp: new Date().toLocaleString(),
      operator: props.form.operatorName || "系统",
      type: "warning"
    });
    flow.push({
      title: "审核通过",
      content: "退货单审核通过",
      timestamp: new Date().toLocaleString(),
      operator: "审核员",
      type: "success"
    });
    flow.push({
      title: "退货完成",
      content: "退货流程已完成",
      timestamp: new Date().toLocaleString(),
      operator: "系统",
      type: "info"
    });
  }
  
  return flow;
});
 
// 关闭对话框
const handleClose = () => {
  emit('update:dialogViewVisible', false);
};
</script>
 
<style scoped>
.view-container {
  padding: 0;
}
 
.info-card {
  margin-bottom: 20px;
}
 
.info-card:last-child {
  margin-bottom: 0;
}
 
.card-header {
  font-weight: bold;
  font-size: 16px;
}
 
.table-summary {
  margin-top: 15px;
  text-align: right;
  padding: 10px;
  background-color: #f5f7fa;
  border-radius: 4px;
}
 
.summary-item {
  margin-left: 20px;
  font-size: 14px;
}
 
.summary-item strong {
  color: #409eff;
  font-size: 16px;
}
 
.dialog-footer {
  text-align: right;
}
 
.el-timeline {
  padding: 20px;
}
 
.el-timeline-item h4 {
  margin: 0 0 8px 0;
  font-size: 14px;
  color: #303133;
}
 
.el-timeline-item p {
  margin: 4px 0;
  font-size: 12px;
  color: #606266;
}
</style>