Commit 33d20340 authored by daniel's avatar daniel

fix(gunRule): 新增组别统计数

parent e774f176
......@@ -140,8 +140,15 @@
</n-button>
</div>
<div v-for="(item,index) in gunRules" :key="item.value" class="flex rounded-sm cursor-pointer flex-row items-center gap-x-1">
<span class="py-1 px-4 rounded-sm line-clamp-1 animate-fade-in" :class="[ruleIndex===index?'bg-primary text-white':'']" class="flex-1" @click="changeGunRule(index)"> {{item.roadName}}
</span>
<!-- <span class="py-1 px-4 rounded-sm line-clamp-1 animate-fade-in" :class="[ruleIndex===index?'bg-primary text-white':'']" class="flex-1" @click="changeGunRule(index)">
{{item.roadName}}
</span> -->
<n-tag class="flex-1" round :bordered="false" @click="changeGunRule(index)" :type="ruleIndex===index?'success':''">
{{item.roadName}}
</n-tag>
<n-tag type="success" size="small" round>
{{item.totalApply}}/{{item.totalPlayer}}
</n-tag>
</div>
</div>
<div class="flex-1 flex flex-col gap-y-3">
......@@ -205,6 +212,7 @@
label-placement="left"
label-width="auto"
size="small"
:disabled="loading"
>
<n-form-item label="组别名称" path="roadName">
<div class="flex flex-col">
......@@ -942,14 +950,39 @@
'Content-Type': 'application/json'
},
}).then(res => res.json()))
loading.value = false
if (err) {
message.error(err.message)
}
if (res.code !== 200) return message.error(res.message)
gunRules.value = res.data.map(v => ({
// 获取所有分组的名单总数
const totalApplies = res.data.map(v => v.details.reduce((detailPre, detailCur) => detailPre + detailCur.totalReservations ?? 0, 0))
const playerParams = {
cmptId: getCId(),
roadName: gunRuleValue.value.roadName,
current: pagination.page,
size: pagination.pageSize,
}
// 获取所有分组的名单总数
const request = res.data.map(v => fetch(ENROLL_PAGE, {
method: "POST",
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(params)
}).then(res => res.json()))
let allPlayersTotals = []
await Promise.all(request).then(list => {
allPlayersTotals = list.map(v => v.data.total)
})
console.log({ allPlayersTotals, totalApplies })
// 统计数据组装
gunRules.value = res.data.map((v, index) => ({
...v,
startTime: v.startTime.slice(0, -2),
totalPlayer: allPlayersTotals[index],
totalApply: totalApplies[index]
}))
if (res.data.length) {
changeGunRule(ruleIndex.value === -1 ? 0 : ruleIndex.value)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment