Commit 076f5041 authored by daniel's avatar daniel

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

parent 33d20340
...@@ -140,15 +140,9 @@ ...@@ -140,15 +140,9 @@
</n-button> </n-button>
</div> </div>
<div v-for="(item,index) in gunRules" :key="item.value" class="flex rounded-sm cursor-pointer flex-row items-center gap-x-1"> <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> -->
<n-tag class="flex-1" round :bordered="false" @click="changeGunRule(index)" :type="ruleIndex===index?'success':''"> <n-tag class="flex-1" round :bordered="false" @click="changeGunRule(index)" :type="ruleIndex===index?'success':''">
{{item.roadName}} {{item.roadName}}
</n-tag> </n-tag>
<n-tag type="success" size="small" round>
{{item.totalApply}}/{{item.totalPlayer}}
</n-tag>
</div> </div>
</div> </div>
<div class="flex-1 flex flex-col gap-y-3"> <div class="flex-1 flex flex-col gap-y-3">
...@@ -181,10 +175,29 @@ ...@@ -181,10 +175,29 @@
</n-button> </n-button>
</div> </div>
</n-card> </n-card>
<n-card v-if="gunRules.length>0" :bordered="false">
<n-descriptions :column="gunRules.length+1" label-align="center"
content-class="text-center" label-placement="top" title="预约统计(预约/总)">
<n-descriptions-item v-for="item in gunRules" :key="item.id" :label="item.roadName">
<div class="flex mx-auto flex-row items-center w-full justify-center font-bold">
<n-gradient-text :size="24" type="success">
<n-number-animation
:active="true"
:from="0" :to="item?.totalApply??0" />
</n-gradient-text>
<span class="text-xl mx-1">/</span>
<n-gradient-text :size="24" type="warning">
<n-number-animation
:active="true"
ref="numberAnimationInstRef" :from="0" :to="item.totalPlayer" />
</n-gradient-text>
</div>
</n-descriptions-item>
</n-descriptions>
</n-card>
<n-card v-if="gunRuleValue.details.length>0" :bordered="false"> <n-card v-if="gunRuleValue.details.length>0" :bordered="false">
<n-descriptions :column="gunRuleValue.details.length" label-align="center" <n-descriptions :column="gunRuleValue.details.length" label-align="center"
content-class="text-center" label-placement="top" title="预约统计(预约/总)"> content-class="text-center" label-placement="top" title="分枪预约统计(预约/总)">
<n-descriptions-item v-for="item in gunRuleValue.details" :key="item.value" :label="item.waveName"> <n-descriptions-item v-for="item in gunRuleValue.details" :key="item.value" :label="item.waveName">
<div class="flex mx-auto flex-row items-center w-full justify-center font-bold"> <div class="flex mx-auto flex-row items-center w-full justify-center font-bold">
<n-gradient-text :size="24" type="success"> <n-gradient-text :size="24" type="success">
...@@ -958,25 +971,27 @@ ...@@ -958,25 +971,27 @@
if (res.code !== 200) return message.error(res.message) if (res.code !== 200) return message.error(res.message)
// 获取所有分组的名单总数 // 获取所有分组的名单总数
const totalApplies = res.data.map(v => v.details.reduce((detailPre, detailCur) => detailPre + detailCur.totalReservations ?? 0, 0)) const totalApplies = res.data.map(v => v.details.reduce((detailPre, detailCur) => detailPre + detailCur.totalReservations ?? 0, 0))
// 获取所有分组的名单总数
const request = res.data.map(v => {
const playerParams = { const playerParams = {
cmptId: getCId(), cmptId: getCId(),
roadName: gunRuleValue.value.roadName, roadName: v.roadName,
current: pagination.page, current: 1,
size: pagination.pageSize, size: 1,
} }
// 获取所有分组的名单总数 return fetch(ENROLL_PAGE, {
const request = res.data.map(v => fetch(ENROLL_PAGE, {
method: "POST", method: "POST",
headers: { headers: {
'Content-Type': 'application/json' 'Content-Type': 'application/json'
}, },
body: JSON.stringify(params) body: JSON.stringify(playerParams)
}).then(res => res.json())) }).then(res => res.json())
})
let allPlayersTotals = [] let allPlayersTotals = []
await Promise.all(request).then(list => { await Promise.all(request).then(list => {
allPlayersTotals = list.map(v => v.data.total) allPlayersTotals = list.map(v => v.data.total)
}) })
console.log({ allPlayersTotals, totalApplies })
// 统计数据组装 // 统计数据组装
gunRules.value = res.data.map((v, index) => ({ gunRules.value = res.data.map((v, index) => ({
...v, ...v,
......
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