Skip to content

Commit 7da8071

Browse files
committed
feat(scrm): wecom tag list ui
1 parent c0d8351 commit 7da8071

File tree

10 files changed

+121
-59
lines changed

10 files changed

+121
-59
lines changed

src/api/interceptor.ts

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import axios from 'axios';
33
import { Message } from '@arco-design/web-vue';
44
import { getToken } from '@/utils/auth';
55
import qs from 'query-string';
6+
import { consola } from 'consola';
67

78
export interface HttpResponse<T = unknown> {
89
status: number;
@@ -66,38 +67,38 @@ axios.interceptors.response.use(
6667
if (res.status >= 200 && res.status < 300) {
6768
return res;
6869
}
69-
// 如果返回 4xx, 则提示错误
70-
if (res.status >= 400 && res.status < 500) {
71-
Message.error({
72-
content: (res.data as ErrorResponse).msg || '违规请求',
73-
duration: 5 * 1000,
74-
});
75-
return Promise.reject(
76-
new Error((res.data as ErrorResponse).msg || '违规请求'),
77-
);
78-
}
79-
// 如果返回 5xx, 则提示错误
80-
if (res.status >= 500 && res.status < 600) {
81-
Message.error({
82-
content:
83-
(res.data as ErrorResponse).msg ||
84-
'服务器错误, 请稍后重试或联系技术支持',
85-
duration: 5 * 1000,
86-
});
87-
return Promise.reject(
88-
new Error(
89-
(res.data as ErrorResponse).msg ||
90-
'服务器错误, 请稍后重试或联系技术支持',
91-
),
92-
);
93-
}
70+
// // 如果返回 4xx, 则提示错误
71+
// if (res.status >= 400 && res.status < 500) {
72+
// Message.error({
73+
// content: (res.data as ErrorResponse).msg || '违规请求',
74+
// duration: 5 * 1000,
75+
// });
76+
// return Promise.reject(
77+
// new Error((res.data as ErrorResponse).msg || '违规请求'),
78+
// );
79+
// }
80+
// // 如果返回 5xx, 则提示错误
81+
// if (res.status >= 500 && res.status < 600) {
82+
// Message.error({
83+
// content:
84+
// (res.data as ErrorResponse).msg ||
85+
// '服务器错误, 请稍后重试或联系技术支持',
86+
// duration: 5 * 1000,
87+
// });
88+
// return Promise.reject(
89+
// new Error(
90+
// (res.data as ErrorResponse).msg ||
91+
// '服务器错误, 请稍后重试或联系技术支持',
92+
// ),
93+
// );
94+
// }
9495
return res;
9596
},
9697
(error) => {
97-
Message.error({
98-
content: error.response.data.msg || '请求错误',
99-
duration: 5 * 1000,
100-
});
98+
// Message.error({
99+
// content: error.response.data.msg || '请求错误',
100+
// duration: 5 * 1000,
101+
// });
101102
return Promise.reject(error);
102103
},
103104
);

src/api/scrm/wecom/tag/tag.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ import { UriWeComTag } from '@/api/scrm/wecom/base';
1111
import { GetCustomersReply } from '@/api/scrm/wecom/customer';
1212

1313
export type WeComTagType = number;
14-
export const WeComTagTypeTag: WeComTagType = 1;
15-
export const WeComTagTypeCorpTag: WeComTagType = 2;
16-
export const WeComTagTypeStrategy: WeComTagType = 3;
14+
export const WeComTagTypeTag: WeComTagType = 0;
15+
export const WeComTagTypeCorpTag: WeComTagType = 1;
16+
export const WeComTagTypeStrategy: WeComTagType = 2;
1717

1818
export interface WeComCorpTagGroup {
1919
agentId: number;
@@ -26,7 +26,7 @@ export interface WeComCorpTagGroup {
2626
export interface WeComTag {
2727
type: number;
2828
isSelf: number;
29-
tagId: string;
29+
tagId: number;
3030
groupId: string;
3131
groupName: string;
3232
name: string;

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,12 @@ const useWeComUserStore = defineStore('weComUser', {
7878
this.selectedViewType = type;
7979
},
8080
async loadDepartmentTree(departmentId: number) {
81-
const res = await getWeComDepartment({ departmentId });
82-
if (res.data) {
83-
this.departmentTree = [res.data.department];
84-
} else {
81+
try {
82+
const res = await getWeComDepartment({ departmentId });
83+
if (res.data) {
84+
this.departmentTree = [res.data.department];
85+
}
86+
} catch (err) {
8587
Message.error('获取部门信息失败');
8688
}
8789
},

src/views/scrm/wecom/organization/index.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
getDepartmentTree,
77
} from '@/api/scrm/wecom/department';
88
// import DepartmentSide from '@/views/admin/user/components/department-tree.vue';
9-
import DepartmentSide from '@/views/scrm/wecom/organization/user/components/department-side/index.vue';
109
import styles from './index.module.less';
1110
1211
/**

src/views/scrm/wecom/organization/user/components/department-tree/index.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<script lang="ts" setup>
22
import { computed, onMounted, PropType, ref } from 'vue';
33
import useWeComUserStore from '@/store/modules/scrm/wecom/user';
4-
import { consola } from 'consola';
54
import styles from './index.module.less';
65
76
const prop = defineProps({

src/views/scrm/wecom/organization/user/components/department-user-list/index.vue

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
<script setup lang="ts">
2-
import { onMounted, reactive, ref, watch } from 'vue';
2+
import { reactive, ref, watch } from 'vue';
33
import {
44
listUsersPage,
55
listUsersPageReply,
66
listUsersPageRequest,
77
} from '@/api/scrm/wecom/user';
88
import useWeComUserStore from '@/store/modules/scrm/wecom/user';
9-
import { consola } from 'consola';
109
import styles from './index.module.less';
1110
1211
const useWeComUser = useWeComUserStore();
Lines changed: 48 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,48 @@
1-
.container{
2-
3-
}
1+
.container {
2+
//border: 1px solid red;
3+
width: 100%;
4+
5+
.row {
6+
display: flex;
7+
flex-direction: row;
8+
justify-content: space-between;
9+
width: 100%;
10+
line-height: 30px;
11+
height: 30px;
12+
background: 0 0;
13+
overflow: hidden;
14+
//border: 1px solid green;
15+
cursor: pointer;
16+
transition: background-color 0.3s ease;
17+
&:hover {
18+
background-color: rgb(var(--primary-4));
19+
}
20+
&.selected {
21+
background-color: rgb(var(--primary-4));
22+
color: #fff;
23+
}
24+
.left {
25+
display: flex;
26+
justify-content: flex-start;
27+
align-items: center;
28+
gap: 10px;
29+
//border: 1px solid yellow;
30+
padding: 0 20px;
31+
32+
.icon {
33+
}
34+
35+
.title {
36+
37+
}
38+
}
39+
40+
41+
.action {
42+
padding: 0 6px;
43+
}
44+
45+
46+
}
47+
48+
}

src/views/scrm/wecom/organization/user/components/tag-list/index.vue

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,41 @@
11
<script setup lang="ts">
2-
import { onMounted } from 'vue';
2+
import { onMounted, ref } from 'vue';
33
import useWeComUserStore from '@/store/modules/scrm/wecom/user';
4+
import { consola } from 'consola';
45
import styles from './index.module.less';
56
67
const useWeComUser = useWeComUserStore();
8+
const selectedTag = ref<number | null>(null);
9+
10+
const handleSelectTag = (tagId: number) => {
11+
consola.log(tagId);
12+
selectedTag.value = tagId;
13+
// 这里可以添加其他业务逻辑
14+
};
715
816
onMounted(async () => {
917
// 默认拉取根目录的部门树
1018
await useWeComUser.loadTagList();
1119
// 加载完部部树后,设置默认选中的部门
12-
await useWeComUser.setSelectedTag(1);
20+
selectedTag.value = 1; // 初始化选中状态
21+
22+
await useWeComUser.setSelectedTag(selectedTag.value);
1323
});
1424
</script>
1525

1626
<template>
17-
<div :class="styles.container"></div>
27+
<div :class="styles.container">
28+
<div
29+
v-for="item in useWeComUser.tagList"
30+
:key="item.tagId"
31+
:class="[styles.row, { [styles.selected]: selectedTag === item.tagId }]"
32+
@click="handleSelectTag(item.tagId)"
33+
>
34+
<div :class="styles.left">
35+
<icon-tag :class="styles.icon" />
36+
<span :class="styles.title">{{ item.name }}</span>
37+
</div>
38+
<div :class="styles.action"> <icon-more-vertical /> </div>
39+
</div>
40+
</div>
1841
</template>
19-
20-
<style scoped></style>

src/views/scrm/wecom/organization/user/components/tag-user-list/index.vue

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
<script setup lang="ts">
22
import { onMounted, reactive, ref } from 'vue';
3-
import {
4-
listUsersPage,
5-
listUsersPageReply,
6-
listUsersPageRequest,
7-
} from '@/api/scrm/wecom/user';
3+
import { listUsersPage, listUsersPageReply } from '@/api/scrm/wecom/user';
84
import useWeComUserStore from '@/store/modules/scrm/wecom/user';
5+
import { consola } from 'consola';
96
import styles from './index.module.less';
107
118
const useWeComUser = useWeComUserStore();
@@ -51,13 +48,13 @@
5148
});
5249
5350
const onAddUser = () => {
54-
console.log('add user');
51+
consola.log('add user');
5552
};
5653
const onBatchExportOrImport = () => {
57-
console.log('batch export or import');
54+
consola.log('batch export or import');
5855
};
5956
const onRemoveUser = () => {
60-
console.log('remove');
57+
consola.log('remove');
6158
};
6259
6360
onMounted(() => {

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import { Message } from '@arco-design/web-vue';
66
import useLoadingStore from '@/store/modules/loading';
77
import AddDepartment from '@/views/scrm/wecom/organization/user/components/add-department/index.vue';
8-
import { consola } from 'consola';
98
import DepartmentUserList from '@/views/scrm/wecom/organization/user/components/department-user-list/index.vue';
109
import DepartmentTree from '@/views/scrm/wecom/organization/user/components/department-tree/index.vue';
1110
import TagList from '@/views/scrm/wecom/organization/user/components/tag-list/index.vue';
@@ -106,7 +105,7 @@
106105
<a-doption
107106
v-if="useWeComUser.selectedViewType === 'tag'"
108107
@click="onSyncWeComTags"
109-
><icon-sync /> 从企微同步标签</a-doption
108+
><icon-sync /> 从企微同步员工标签</a-doption
110109
>
111110
</template>
112111
</a-dropdown>

0 commit comments

Comments
 (0)