warehouse-pending.vue
2.69 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
<template>
<workbench-card title="仓库待配送" subtitle="待领取统计" icon="el-icon-truck" tone="cyan" :loading="loading">
<template #extra>
<el-button type="text" size="mini" @click="goMore">更多</el-button>
</template>
<div v-if="list.length" class="wb-list">
<div
v-for="(item, idx) in list"
:key="item.Warehouse || item.warehouse || idx"
class="wb-list-item"
@click="goMore"
>
<div class="wb-list-item__left">
<span class="wb-list-item__dot" style="background:#06b6d4" />
<span class="wb-list-item__title">{{ item.Warehouse || item.warehouse || '无' }}</span>
</div>
<span class="wb-list-item__meta">门店 {{ storeCount(item) }} · ¥{{ formatMoney(amountOf(item)) }}</span>
</div>
</div>
<div v-else class="wb-empty">
<div class="wb-empty__circle" style="background:#ecfeff;color:#06b6d4"><i class="el-icon-truck" /></div>
<div class="wb-empty__title">暂无待配送</div>
<div class="wb-empty__desc">仓库待领取数据会显示在这里</div>
</div>
</workbench-card>
</template>
<script>
import { getWarehousePendingDelivery } from '@/api/extend/lqInventory'
import WorkbenchCard from '../workbench-card.vue'
import { formatMoney } from '../utils'
export default {
name: 'WidgetWarehousePending',
components: { WorkbenchCard },
data() {
return { loading: false, list: [] }
},
mounted() {
this.load()
},
methods: {
formatMoney,
storeCount(item) {
const stores = item.Stores || item.stores || []
return Array.isArray(stores) ? stores.length : 0
},
amountOf(item) {
const stores = item.Stores || item.stores || []
if (!Array.isArray(stores)) return Number(item.TotalAmount || item.totalAmount || 0)
return stores.reduce((sum, s) => sum + Number(s.TotalAmount || s.totalAmount || 0), 0)
},
async load() {
this.loading = true
try {
const res = await getWarehousePendingDelivery({})
// res.data 可能是 { success, data, total }
const payload = res.data || {}
let rows = []
if (payload && payload.success != null) {
rows = payload.data || []
} else if (Array.isArray(payload)) {
rows = payload
} else {
rows = payload.list || payload.data || []
}
this.list = (Array.isArray(rows) ? rows : []).slice(0, 5)
} catch (e) {
this.list = []
} finally {
this.loading = false
}
},
goMore() {
this.$router.push('/lqInventory/warehouse-pending-delivery').catch(() => {})
}
}
}
</script>
<style lang="scss" scoped>
@import '../widget-common.scss';
</style>