From 2385cd9b9a88f7b1f0de303a1c7b473ec203f544 Mon Sep 17 00:00:00 2001 From: puhui999 Date: Mon, 13 Nov 2023 15:48:21 +0800 Subject: [PATCH 1/4] =?UTF-8?q?fix=EF=BC=9A=E5=A6=82=E6=9E=9C=E5=B7=B2?= =?UTF-8?q?=E7=BB=8F=E5=88=B0=E9=87=8D=E6=96=B0=E7=99=BB=E5=BD=95=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E5=88=99=E4=B8=8D=E8=BF=9B=E8=A1=8C=E5=BC=B9=E7=AA=97?= =?UTF-8?q?=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/config/axios/service.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/config/axios/service.ts b/src/config/axios/service.ts index 1a4741b6..6413e945 100644 --- a/src/config/axios/service.ts +++ b/src/config/axios/service.ts @@ -217,6 +217,10 @@ const refreshToken = async () => { const handleAuthorized = () => { const { t } = useI18n() if (!isRelogin.show) { + // 如果已经到重新登录页面则不进行弹窗提示 + if (window.location.href.includes('login?redirect=')) { + return + } isRelogin.show = true ElMessageBox.confirm(t('sys.api.timeoutMessage'), t('common.confirmTitle'), { showCancelButton: false, From 27c9a0f32deee6e69b81348aae08ba114a5a0797 Mon Sep 17 00:00:00 2001 From: puhui999 Date: Mon, 13 Nov 2023 17:49:27 +0800 Subject: [PATCH 2/4] =?UTF-8?q?crm-=E5=9B=A2=E9=98=9F=E6=88=90=E5=91=98?= =?UTF-8?q?=EF=BC=9A=20=E5=85=88=E6=8F=90=E4=BA=A4=E4=B8=80=E6=B3=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/crm/permission/index.ts | 32 +++++ .../crm/components/CrmPermissionForm.vue | 106 ++++++++++++++++ src/views/crm/components/CrmTeamList.vue | 116 ++++++++++++++++++ src/views/crm/components/index.ts | 11 ++ src/views/crm/customer/index.vue | 115 +++++++++-------- 5 files changed, 328 insertions(+), 52 deletions(-) create mode 100644 src/api/crm/permission/index.ts create mode 100644 src/views/crm/components/CrmPermissionForm.vue create mode 100644 src/views/crm/components/CrmTeamList.vue create mode 100644 src/views/crm/components/index.ts diff --git a/src/api/crm/permission/index.ts b/src/api/crm/permission/index.ts new file mode 100644 index 00000000..f71e2bfc --- /dev/null +++ b/src/api/crm/permission/index.ts @@ -0,0 +1,32 @@ +import request from '@/config/axios' + +export interface PermissionVO { + id: number // 数据权限编号 + userId: number // 用户编号 + bizType: number // Crm 类型 + bizId: number // Crm 类型数据编号 + level: number // 权限级别 + deptName: string // 部门名称 + nickname: string // 用户昵称 + postNames: string // 岗位名称数组 +} + +// 查询团队成员列表 +export const getPermissionList = async (params) => { + return await request.get({ url: `/crm/permission/list`, params }) +} + +// 新增团队成员 +export const createPermission = async (data: PermissionVO) => { + return await request.post({ url: `/crm/permission/add`, data }) +} + +// 修改团队成员 +export const updatePermission = async (data: PermissionVO) => { + return await request.put({ url: `/crm/permission/update`, data }) +} + +// 删除团队成员 +export const deletePermission = async (params) => { + return await request.delete({ url: '/crm/permission/delete', params }) +} diff --git a/src/views/crm/components/CrmPermissionForm.vue b/src/views/crm/components/CrmPermissionForm.vue new file mode 100644 index 00000000..1d217323 --- /dev/null +++ b/src/views/crm/components/CrmPermissionForm.vue @@ -0,0 +1,106 @@ + + diff --git a/src/views/crm/components/CrmTeamList.vue b/src/views/crm/components/CrmTeamList.vue new file mode 100644 index 00000000..824409b8 --- /dev/null +++ b/src/views/crm/components/CrmTeamList.vue @@ -0,0 +1,116 @@ + + + diff --git a/src/views/crm/components/index.ts b/src/views/crm/components/index.ts new file mode 100644 index 00000000..b0bf3e42 --- /dev/null +++ b/src/views/crm/components/index.ts @@ -0,0 +1,11 @@ +import CrmTeam from './CrmTeamList.vue' + +enum CrmBizTypeEnum { + CRM_LEADS = 1, // 线索 + CRM_CUSTOMER = 2, // 客户 + CRM_CONTACTS = 3, // 联系人 + CRM_BUSINESS = 5, // 商机 + CRM_CONTRACT = 6 // 合同 +} + +export { CrmTeam, CrmBizTypeEnum } diff --git a/src/views/crm/customer/index.vue b/src/views/crm/customer/index.vue index 073bf8cb..b214d7c1 100644 --- a/src/views/crm/customer/index.vue +++ b/src/views/crm/customer/index.vue @@ -2,36 +2,36 @@ - 搜索 - 重置 - - 新增 + + + 搜索 + + + + 重置 + + + + 新增 - 导出 + + 导出 @@ -92,77 +100,77 @@ - - - - + + + + - + - + - - - - - + + + + + - + - + - + - diff --git a/src/views/crm/components/CrmTeamList.vue b/src/views/crm/components/CrmTeamList.vue index 824409b8..6a1c14bc 100644 --- a/src/views/crm/components/CrmTeamList.vue +++ b/src/views/crm/components/CrmTeamList.vue @@ -25,10 +25,10 @@ @selection-change="handleSelectionChange" > - - - - + + + + @@ -39,6 +39,7 @@ import { ElTable } from 'element-plus' import * as PermissionApi from '@/api/crm/permission' import { useUserStoreWithOut } from '@/store/modules/user' import CrmPermissionForm from './CrmPermissionForm.vue' +import { CrmPermissionLevelEnum } from './index' defineOptions({ name: 'CrmTeam' }) const props = defineProps<{ @@ -65,14 +66,14 @@ const handleSelectionChange = (val: PermissionApi.PermissionVO[]) => { multipleSelection.value = val } const message = useMessage() -const crmPermissionFormRef = ref>(null) +const crmPermissionFormRef = ref>() const handleEdit = () => { if (multipleSelection.value?.length === 0) { message.warning('请先选择团队成员后操作!') return } const ids = multipleSelection.value?.map((item) => item.id) - crmPermissionFormRef.value?.open('update', props.bizType, props.bizId, ids[0]) + crmPermissionFormRef.value?.open('update', props.bizType, props.bizId, ids) } const handleRemove = async () => { if (multipleSelection.value?.length === 0) { @@ -81,13 +82,10 @@ const handleRemove = async () => { } await message.delConfirm() const ids = multipleSelection.value?.map((item) => item.id) - ids?.forEach((id) => { - // TODO 还不确定要不要搞个批量删除,还是一次只能删除一个,先用循环弄一下 - PermissionApi.deletePermission({ - bizType: props.bizType, - bizId: props.bizId, - id - }) + await PermissionApi.deletePermission({ + bizType: props.bizType, + bizId: props.bizId, + ids }) } const handleAdd = () => { @@ -95,14 +93,16 @@ const handleAdd = () => { } const userStore = useUserStoreWithOut() -const handleQuit = () => { +const handleQuit = async () => { const permission = list.value.find( - (item) => item.userId === userStore.getUser.id && item.level === 1 + (item) => item.userId === userStore.getUser.id && item.level === CrmPermissionLevelEnum.OWNER ) if (permission) { message.warning('负责人不能退出团队!') return } + const userPermission = list.value.find((item) => item.userId === userStore.getUser.id) + await PermissionApi.quitTeam(userPermission?.id) } watch( @@ -113,4 +113,3 @@ watch( { immediate: true, deep: true } ) - diff --git a/src/views/crm/components/index.ts b/src/views/crm/components/index.ts index b0bf3e42..c25feef3 100644 --- a/src/views/crm/components/index.ts +++ b/src/views/crm/components/index.ts @@ -8,4 +8,10 @@ enum CrmBizTypeEnum { CRM_CONTRACT = 6 // 合同 } -export { CrmTeam, CrmBizTypeEnum } +enum CrmPermissionLevelEnum { + OWNER = 1, // 负责人 + READ = 2, // 读 + WRITE = 3 // 写 +} + +export { CrmTeam, CrmBizTypeEnum, CrmPermissionLevelEnum } From 8e0cf5c1e54afd114a41fd40f838614a68bbb4d0 Mon Sep 17 00:00:00 2001 From: puhui999 Date: Tue, 14 Nov 2023 12:06:42 +0800 Subject: [PATCH 4/4] =?UTF-8?q?crm-=E5=9B=A2=E9=98=9F=E6=88=90=E5=91=98?= =?UTF-8?q?=EF=BC=9A=E6=96=B0=E5=A2=9E=E8=8E=B7=E5=BE=97=E6=9D=83=E9=99=90?= =?UTF-8?q?=E7=BA=A7=E5=88=AB=E5=90=8D=E7=A7=B0=E5=87=BD=E6=95=B0=20getLev?= =?UTF-8?q?elName?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/crm/permission/index.ts | 1 + src/views/crm/components/CrmTeamList.vue | 38 ++++++++++++++++++++++-- 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/src/api/crm/permission/index.ts b/src/api/crm/permission/index.ts index c592bb23..e790c334 100644 --- a/src/api/crm/permission/index.ts +++ b/src/api/crm/permission/index.ts @@ -9,6 +9,7 @@ export interface PermissionVO { deptName?: string // 部门名称 nickname?: string // 用户昵称 postNames?: string // 岗位名称数组 + createTime?: Date } // 查询团队成员列表 diff --git a/src/views/crm/components/CrmTeamList.vue b/src/views/crm/components/CrmTeamList.vue index 6a1c14bc..f7591f6a 100644 --- a/src/views/crm/components/CrmTeamList.vue +++ b/src/views/crm/components/CrmTeamList.vue @@ -28,7 +28,11 @@ - + + + @@ -47,7 +51,20 @@ const props = defineProps<{ bizId: number }>() const loading = ref(true) // 列表的加载中 -const list = ref([]) // 列表的数据 +const list = ref([ + // TODO 测试数据 + { + id: 1, // 数据权限编号 + userId: 1, // 用户编号 + bizType: 1, // Crm 类型 + bizId: 1, // Crm 类型数据编号 + level: 1, // 权限级别 + deptName: '研发部门', // 部门名称 + nickname: '芋道源码', // 用户昵称 + postNames: '全栈开发工程师', // 岗位名称数组 + createTime: new Date() + } +]) // 列表的数据 const getList = async () => { loading.value = true try { @@ -60,7 +77,22 @@ const getList = async () => { loading.value = false } } - +/** + * 获得权限级别名称 + * @param level 权限级别 + */ +const getLevelName = computed(() => (level: number) => { + switch (level) { + case CrmPermissionLevelEnum.OWNER: + return '负责人' + case CrmPermissionLevelEnum.READ: + return '只读' + case CrmPermissionLevelEnum.WRITE: + return '读写' + default: + break + } +}) const multipleSelection = ref([]) const handleSelectionChange = (val: PermissionApi.PermissionVO[]) => { multipleSelection.value = val