Skip to content

Commit 7e5a29a

Browse files
committed
refact(scrm): user and department and ready to sync user and depatments
1 parent 890807d commit 7e5a29a

File tree

14 files changed

+380
-34
lines changed

14 files changed

+380
-34
lines changed

src/App.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<a-config-provider :locale="locale">
33
<router-view />
44
<global-setting />
5+
<global-loading />
56
</a-config-provider>
67
</template>
78

@@ -10,8 +11,9 @@
1011
import enUS from '@arco-design/web-vue/es/locale/lang/en-us';
1112
import zhCN from '@arco-design/web-vue/es/locale/lang/zh-cn';
1213
import GlobalSetting from '@/components/global-setting/index.vue';
14+
import GlobalLoading from '@/components/global-loading/index.vue';
1315
import useLocale from '@/hooks/locale';
14-
import consola from 'consola';
16+
import { consola } from 'consola';
1517
1618
const { currentLocale } = useLocale();
1719
const locale = computed(() => {

src/api/scrm/base.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export const UriWeCom = '/scrm/wechat/wecom';
2+
export const UriWeComUser = '/scrm/wechat/wecom/organization/users';
3+
export const UriWeComApp = '/scrm/wechat/wecom/app';

src/api/scrm/customer/index.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
* @LastEditTime: 2023-07-16 01:48:33
77
*/
88
import axios from 'axios';
9+
import { PrefixUriAdmin } from '@/api';
10+
import { UriCustomerDomain } from '@/api/crm/customer-domain/customer';
11+
import { UriWeCom, UriWeComUser } from '../base';
912

1013
/**
1114
* customer
@@ -115,14 +118,14 @@ export interface GetWechatGroupReReply {
115118
}
116119
export function wechatGroup(request: any) {
117120
return axios.get<GetWechatGroupReReply>(
118-
'/api/v1/admin/scrm/wechat/wecom/app/group/list',
121+
`${PrefixUriAdmin + UriWeCom}/app/group/list`,
119122
request,
120123
);
121124
}
122125

123-
export function getWechatSync(request: any) {
126+
export function pullSyncWeComDepartmentsAndUsers(request: any) {
124127
return axios.get<GetCustomersReply>(
125-
'/api/v1/admin/scrm/wechat/wecom/organization/users/sync',
128+
`${PrefixUriAdmin + UriWeComUser}/sync`,
126129
request,
127130
);
128131
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<template>
2+
<!-- 使用 Arco Design Pro 的 Spin 组件 -->
3+
<a-spin v-if="loading" class="fullscreenSpin" dot>
4+
<template #tip>
5+
<span class="spinTip">加载中...</span>
6+
</template>
7+
</a-spin>
8+
</template>
9+
10+
<script lang="ts" setup>
11+
import { computed } from 'vue';
12+
import useLoadingStore from '@/store/modules/loading';
13+
14+
const loadingStore = useLoadingStore();
15+
16+
// 从 Pinia 中获取全局 loading 状态
17+
const loading = computed(() => loadingStore.loading);
18+
</script>
19+
20+
<style scoped lang="less">
21+
.fullscreenSpin {
22+
position: fixed;
23+
top: 0;
24+
left: 0;
25+
right: 0;
26+
bottom: 0;
27+
display: flex;
28+
justify-content: center;
29+
align-items: center;
30+
background-color: rgba(255, 255, 255, 0.5);
31+
z-index: 9999;
32+
}
33+
.spinTip {
34+
margin: 12px 0 0 24px; /* 图标与文本的间距 */
35+
font-size: 14px;
36+
//color: #666;
37+
}
38+
</style>

src/store/modules/loading/index.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { defineStore } from 'pinia';
2+
3+
const useLoadingStore = defineStore('loading', {
4+
state: () => ({
5+
loading: false, // 全局 loading 状态
6+
}),
7+
actions: {
8+
setLoading(value: boolean) {
9+
// console.log(value);
10+
this.loading = value;
11+
},
12+
},
13+
});
14+
15+
export default useLoadingStore;

src/store/modules/scrm/wecom/user.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import { defineStore } from 'pinia';
22

3-
// TODO: 替换为实际类型定义
43
type DepartmentTree = any;
54
type TagTree = any;
65
type UserList = any;
76

8-
type ViewType = 'department' | 'tag';
7+
export type ViewType = 'department' | 'tag';
98

109
interface UserState {
1110
departmentTree: DepartmentTree | null;
@@ -16,7 +15,7 @@ interface UserState {
1615
selectedViewType: ViewType;
1716
}
1817

19-
const useWeComUserStore = defineStore('user', {
18+
const useWeComUserStore = defineStore('weComUser', {
2019
state: (): UserState => ({
2120
departmentTree: null,
2221
tagTree: null,
@@ -42,6 +41,7 @@ const useWeComUserStore = defineStore('user', {
4241
this.selectedTag = id;
4342
},
4443
setSelectedViewType(type: ViewType) {
44+
// console.log('setSelectedViewType', type);
4545
this.selectedViewType = type;
4646
},
4747
},

src/views/scrm/wecom/customer-group/group/index.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
<a-button
3737
style="margin: 0 10px"
3838
type="primary"
39-
@click="fetchWechatSync"
39+
@click="fetchPullSyncWeComDepartmentsAndUsers"
4040
>同步群信息</a-button
4141
>
4242
<a-button type="primary" @click="handleSendMsgAll"
@@ -127,7 +127,7 @@
127127
import {
128128
getCustomersGroups,
129129
GetCustomersGroupsRequest,
130-
getWechatSync,
130+
pullSyncWeComDepartmentsAndUsers,
131131
} from '@/api/scrm/customer';
132132
133133
const sender = ref('');
@@ -162,9 +162,9 @@
162162
state.loading = false;
163163
}
164164
}
165-
async function fetchWechatSync() {
165+
async function fetchPullSyncWeComDepartmentsAndUsers() {
166166
state.loading = true;
167-
const res = await getWechatSync({
167+
const res = await pullSyncWeComDepartmentsAndUsers({
168168
sync: 1,
169169
});
170170
try {

src/views/scrm/wecom/organization/user-group/index.vue

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
<a-button
7878
type="text"
7979
status="success"
80-
@click="fetchWechatSync"
80+
@click="fetchPullSyncWeComDepartmentsAndUsers"
8181
>同步群信息</a-button
8282
>
8383
<a-button type="text" @click="handleSendMsg(record)"
@@ -118,7 +118,7 @@
118118
import {
119119
wechatGroup,
120120
GetWechatGroupReReply,
121-
getWechatSync,
121+
pullSyncWeComDepartmentsAndUsers,
122122
} from '@/api/scrm/customer';
123123
import { Message } from '@arco-design/web-vue';
124124
import AddGroup from '@/views/scrm/official-account/group/components/add-group.vue';
@@ -148,9 +148,9 @@
148148
state.loading = false;
149149
}
150150
}
151-
async function fetchWechatSync() {
151+
async function fetchPullSyncWeComDepartmentsAndUsers() {
152152
state.loading = true;
153-
const res = await getWechatSync({
153+
const res = await pullSyncWeComDepartmentsAndUsers({
154154
sync: 1,
155155
});
156156
try {
@@ -187,7 +187,7 @@
187187
};
188188
const handleAddGroupSuccess = () => {
189189
state.addGroudvisible = false;
190-
fetchWechatSync();
190+
fetchPullSyncWeComDepartmentsAndUsers();
191191
};
192192
onMounted(() => {
193193
fetchWechatAppList();
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
.container {
2+
display: flex;
3+
flex-direction: column;
4+
5+
.title {
6+
margin-bottom: 10px;
7+
padding-bottom: 0;
8+
border-bottom: none;
9+
color: #000;
10+
font-size: 18px;
11+
line-height: 28px;
12+
float: left;
13+
width: 480px;
14+
}
15+
16+
.action {
17+
@apply flex flex-row w-full items-center justify-start w-full;
18+
background-color: #E0E9F5;
19+
gap: 10px;
20+
padding: 10px 20px;
21+
22+
.actionBtn {
23+
font-size: 12px !important;
24+
height: 24px !important;
25+
}
26+
27+
.divider {
28+
height: 24px; // Set the height of the vertical divider
29+
margin: 0 8px; // Add some margin for spacing
30+
border-left: 1px solid #d9d9d9;
31+
}
32+
}
33+
}
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
<script setup lang="ts">
2+
import { onMounted, reactive, ref } from 'vue';
3+
import { listUsers, ListUsersReply, ListUsersRequest } from '@/api/scrm/user';
4+
import styles from './index.module.less';
5+
6+
const queryForm = reactive({
7+
WeComMainDepartmentId: null,
8+
} as ListUsersRequest);
9+
const state = reactive({
10+
tableLoading: false,
11+
deleteUserLoading: false,
12+
editUser: {
13+
visible: false,
14+
loading: false,
15+
userId: 0,
16+
},
17+
});
18+
19+
const pageData = ref({} as ListUsersReply);
20+
21+
const queryChange = () => {
22+
if (state.tableLoading) {
23+
return;
24+
}
25+
state.tableLoading = true;
26+
listUsers(queryForm)
27+
.then((res) => {
28+
pageData.value = res.data;
29+
})
30+
.finally(() => {
31+
state.tableLoading = false;
32+
});
33+
};
34+
35+
const rowSelection = reactive({
36+
type: 'checkbox',
37+
showCheckedAll: true,
38+
onlyCurrent: false,
39+
});
40+
41+
const onAddUser = () => {
42+
console.log('add user');
43+
};
44+
const onBatchExportOrImport = () => {
45+
console.log('batch export or import');
46+
};
47+
const onRemoveUser = () => {
48+
console.log('remove');
49+
};
50+
51+
onMounted(() => {
52+
queryChange();
53+
});
54+
</script>
55+
56+
<template>
57+
<div :class="styles.container">
58+
<div :class="styles.title">
59+
<span>Tag名称(0人)</span>
60+
</div>
61+
<div :class="styles.action">
62+
<a-button :class="styles.actionBtn" @click="onAddUser"
63+
>添加部门/成员</a-button
64+
>
65+
<a-button :class="styles.actionBtn" @click="onBatchExportOrImport"
66+
>批量导入/导出</a-button
67+
>
68+
<a-button :class="styles.actionBtn" @click="onRemoveUser">移除</a-button>
69+
</div>
70+
<a-table
71+
:data="pageData.list"
72+
:loading="state.tableLoading"
73+
:row-selection="rowSelection"
74+
column-resizable
75+
scrollbar
76+
:class="styles.userTable"
77+
>
78+
<template #columns>
79+
<a-table-column title="名称" :width="170">
80+
<template #cell="{ record }">
81+
{{ record.name }}
82+
</template>
83+
</a-table-column>
84+
<a-table-column title="部门" data-index="department" ellipsis />
85+
</template>
86+
</a-table>
87+
</div>
88+
</template>
89+
90+
<style scoped></style>
Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,33 @@
1-
.container{
1+
.container {
2+
display: flex;
3+
flex-direction: column;
24

5+
.title {
6+
margin-bottom: 10px;
7+
padding-bottom: 0;
8+
border-bottom: none;
9+
color: #000;
10+
font-size: 18px;
11+
line-height: 28px;
12+
float: left;
13+
width: 480px;
14+
}
15+
16+
.action {
17+
@apply flex flex-row w-full items-center justify-start w-full;
18+
background-color: #E0E9F5;
19+
gap: 10px;
20+
padding: 10px 20px;
21+
22+
.actionBtn {
23+
font-size: 12px !important;
24+
height: 24px !important;
25+
}
26+
27+
.divider {
28+
height: 24px; // Set the height of the vertical divider
29+
margin: 0 8px; // Add some margin for spacing
30+
border-left: 1px solid #d9d9d9;
31+
}
32+
}
333
}

0 commit comments

Comments
 (0)