云
2 天以前 a241b66efcc41e973290a6722fb7a4d79b833ea1
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
<script lang="ts" setup>
import { computed, onActivated, onMounted, ref, watch } from 'vue';
 
import { Page } from '@vben/common-ui';
 
import { Badge, Card, List } from 'ant-design-vue';
import { automaticApproval } from '#/store/audit-policy';
 
import { getFollowClueCount } from '#/api/crm/clue';
import {
  getAuditContractCount,
  getRemindContractCount,
} from '#/api/crm/contract';
import {
  getFollowCustomerCount,
  getPutPoolRemindCustomerCount,
  getTodayContactCustomerCount,
} from '#/api/crm/customer';
import { getAuditReceivableCount } from '#/api/crm/receivable';
import { getReceivablePlanRemindCount } from '#/api/crm/receivable/plan';
 
import { useLeftSides } from './data';
import ClueFollowList from './modules/clue-follow-list.vue';
import ContractAuditList from './modules/contract-audit-list.vue';
import ContractRemindList from './modules/contract-remind-list.vue';
import CustomerFollowList from './modules/customer-follow-list.vue';
import CustomerPutPoolRemindList from './modules/customer-put-pool-remind-list.vue';
import CustomerTodayContactList from './modules/customer-today-contact-list.vue';
import ReceivableAuditList from './modules/receivable-audit-list.vue';
import ReceivablePlanRemindList from './modules/receivable-plan-remind-list.vue';
 
const leftMenu = ref('customerTodayContact');
 
const clueFollowCount = ref(0);
const customerFollowCount = ref(0);
const customerPutPoolRemindCount = ref(0);
const customerTodayContactCount = ref(0);
const contractAuditCount = ref(0);
const contractRemindCount = ref(0);
const receivableAuditCount = ref(0);
const receivablePlanRemindCount = ref(0);
 
const leftSides = useLeftSides(
  customerTodayContactCount,
  clueFollowCount,
  customerFollowCount,
  customerPutPoolRemindCount,
  contractAuditCount,
  contractRemindCount,
  receivableAuditCount,
  receivablePlanRemindCount,
);
const visibleLeftSides = computed(() => leftSides.filter((item) =>
  !automaticApproval.value || !['contractAudit', 'receivableAudit'].includes(item.menu),
));
watch(automaticApproval, (automatic) => {
  if (automatic && ['contractAudit', 'receivableAudit'].includes(leftMenu.value)) {
    leftMenu.value = 'customerTodayContact';
  }
});
 
const currentComponent = computed(() => {
  const components = {
    customerTodayContact: CustomerTodayContactList,
    clueFollow: ClueFollowList,
    contractAudit: ContractAuditList,
    receivableAudit: ReceivableAuditList,
    contractRemind: ContractRemindList,
    customerFollow: CustomerFollowList,
    customerPutPoolRemind: CustomerPutPoolRemindList,
    receivablePlanRemind: ReceivablePlanRemindList,
  } as const;
  return components[leftMenu.value as keyof typeof components];
});
 
/** 侧边点击 */
function sideClick(item: { menu: string }) {
  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();
}
 
/** 激活时 */
onActivated(() => {
  getCount();
});
 
/** 初始化 */
onMounted(() => {
  getCount();
});
</script>
<template>
  <Page auto-content-height>
    <div class="flex h-full w-full">
      <Card class="w-1/5">
        <List item-layout="horizontal" :data-source="visibleLeftSides">
          <template #renderItem="{ item }">
            <List.Item
              @click="sideClick(item)"
              class="cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-700"
            >
              <List.Item.Meta>
                <template #title>
                  {{ item.name }}
                </template>
              </List.Item.Meta>
              <template #extra>
                <Badge
                  v-if="item.count.value > 0"
                  :color="item.menu === leftMenu ? 'blue' : 'red'"
                  :count="item.count.value"
                />
              </template>
            </List.Item>
          </template>
        </List>
      </Card>
      <component class="ml-4 w-4/5" :is="currentComponent" />
    </div>
  </Page>
</template>