| | |
| | | <script lang="ts" setup> |
| | | import type { Ref } from 'vue'; |
| | | |
| | | import { computed, onActivated, onMounted, ref, watch } from 'vue'; |
| | | |
| | | import { Page } from '@vben/common-ui'; |
| | |
| | | leftMenu.value = item.menu; |
| | | } |
| | | |
| | | /** 获取数量 */ |
| | | async function getCount() { |
| | | customerTodayContactCount.value = await getTodayContactCustomerCount(); |
| | | customerPutPoolRemindCount.value = await getPutPoolRemindCustomerCount(); |
| | | customerFollowCount.value = await getFollowCustomerCount(); |
| | | clueFollowCount.value = await getFollowClueCount(); |
| | | if (!automaticApproval.value) contractAuditCount.value = await getAuditContractCount(); |
| | | contractRemindCount.value = await getRemindContractCount(); |
| | | if (!automaticApproval.value) receivableAuditCount.value = await getAuditReceivableCount(); |
| | | receivablePlanRemindCount.value = await getReceivablePlanRemindCount(); |
| | | /** 独立加载各类数量,单个接口失败不阻断其他待办。 */ |
| | | let countRequest: Promise<void> | undefined; |
| | | function getCount() { |
| | | if (countRequest) return countRequest; |
| | | const requests: [Ref<number>, () => Promise<number>][] = [ |
| | | [customerTodayContactCount, getTodayContactCustomerCount], |
| | | [customerPutPoolRemindCount, getPutPoolRemindCustomerCount], |
| | | [customerFollowCount, getFollowCustomerCount], |
| | | [clueFollowCount, getFollowClueCount], |
| | | [contractRemindCount, getRemindContractCount], |
| | | [receivablePlanRemindCount, getReceivablePlanRemindCount], |
| | | ]; |
| | | if (!automaticApproval.value) { |
| | | requests.push( |
| | | [contractAuditCount, getAuditContractCount], |
| | | [receivableAuditCount, getAuditReceivableCount], |
| | | ); |
| | | } |
| | | countRequest = Promise.allSettled( |
| | | requests.map(async ([count, request]) => { |
| | | count.value = await request(); |
| | | }), |
| | | ).then(() => undefined).finally(() => { |
| | | countRequest = undefined; |
| | | }); |
| | | return countRequest; |
| | | } |
| | | |
| | | /** 激活时 */ |
| | |
| | | </template> |
| | | </List> |
| | | </Card> |
| | | <component class="ml-4 w-4/5" :is="currentComponent" /> |
| | | <component class="ml-4 w-4/5" :is="currentComponent" @refresh="getCount" /> |
| | | </div> |
| | | </Page> |
| | | </template> |