crm:完善数据权限的界面

This commit is contained in:
YunaiV 2023-11-30 13:42:49 +08:00
parent 7de0e93d5a
commit 5f26c4afe9
15 changed files with 264 additions and 245 deletions

View File

@ -61,8 +61,7 @@ export const exportContact = async (params) => {
return await request.download({ url: `/crm/contact/export-excel`, params }) return await request.download({ url: `/crm/contact/export-excel`, params })
} }
export const simpleAllList = async () => { // 获得 CRM 联系人列表(精简)
export const getSimpleContactList = async () => {
return await request.get({ url: `/crm/contact/simple-all-list` }) return await request.get({ url: `/crm/contact/simple-all-list` })
} }
//

View File

@ -12,6 +12,11 @@ export interface PermissionVO {
createTime?: Date createTime?: Date
} }
/**
* CRM
*
* @author HUIHUI
*/
export enum BizTypeEnum { export enum BizTypeEnum {
CRM_LEADS = 1, // 线索 CRM_LEADS = 1, // 线索
CRM_CUSTOMER = 2, // 客户 CRM_CUSTOMER = 2, // 客户
@ -20,36 +25,47 @@ export enum BizTypeEnum {
CRM_CONTRACT = 6 // 合同 CRM_CONTRACT = 6 // 合同
} }
// 查询团队成员列表 /**
* CRM
*/
export enum PermissionLevelEnum {
OWNER = 1, // 负责人
READ = 2, // 只读
WRITE = 3 // 读写
}
// 获得数据权限列表(查询团队成员列表)
export const getPermissionList = async (params) => { export const getPermissionList = async (params) => {
return await request.get({ url: `/crm/permission/list`, params }) return await request.get({ url: `/crm/permission/list`, params })
} }
// 新增团队成员 // 创建数据权限(新增团队成员
export const createPermission = async (data: PermissionVO) => { export const createPermission = async (data: PermissionVO) => {
return await request.post({ url: `/crm/permission/create`, data }) return await request.post({ url: `/crm/permission/create`, data })
} }
// 修改团队成员权限级别 // 编辑数据权限(修改团队成员权限级别
export const updatePermission = async (data) => { export const updatePermission = async (data) => {
return await request.put({ url: `/crm/permission/update`, data }) return await request.put({ url: `/crm/permission/update`, data })
} }
// 删除团队成员 // 删除数据权限(删除团队成员
export const deletePermission = async (params) => { export const deletePermissionBatch = async (params) => {
return await request.delete({ url: '/crm/permission/delete', params }) return await request.delete({ url: '/crm/permission/delete', params })
} }
// 退出团队 // 删除自己的数据权限(退出团队
export const quitTeam = async (id) => { export const deleteSelfPermission = async (id) => {
return await request.delete({ url: '/crm/permission/quit-team?id=' + id }) return await request.delete({ url: '/crm/permission/quit-team?id=' + id })
} }
// TODO @puhui999调整下位置
// 领取公海数据 // 领取公海数据
export const receive = async (data: { bizType: number; bizId: number }) => { export const receive = async (data: { bizType: number; bizId: number }) => {
return await request.put({ url: `/crm/permission/receive`, data }) return await request.put({ url: `/crm/permission/receive`, data })
} }
// TODO @puhui999调整下位置
// 数据放入公海 // 数据放入公海
export const putPool = async (data: { bizType: number; bizId: number }) => { export const putPool = async (data: { bizType: number; bizId: number }) => {
return await request.put({ url: `/crm/permission/put-pool`, data }) return await request.put({ url: `/crm/permission/put-pool`, data })

View File

@ -198,6 +198,6 @@ export enum DICT_TYPE {
CRM_PRODUCT_STATUS = 'crm_product_status', CRM_PRODUCT_STATUS = 'crm_product_status',
// ========== CRM - 数据权限模块 ========== // ========== CRM - 数据权限模块 ==========
CRM_BIZ_TYPE = 'crm_biz_type', // 数据模块类型 CRM_BIZ_TYPE = 'crm_biz_type', // CRM 业务类型
CRM_PERMISSION_LEVEL = 'crm_permission_level' // 用户数据权限类型 CRM_PERMISSION_LEVEL = 'crm_permission_level' // CRM 数据权限的级别
} }

View File

@ -1,16 +0,0 @@
import CrmPermissionList from './CrmPermissionList.vue'
// TODO @puhui999迁移到 api/permission/index.ts 里;我已经迁移了一部分哈
enum CrmBizTypeEnum {
CRM_LEADS = 1, // 线索
CRM_CUSTOMER = 2, // 客户
CRM_CONTACTS = 3, // 联系人
CRM_BUSINESS = 5, // 商机
CRM_CONTRACT = 6 // 合同
}
enum CrmPermissionLevelEnum {
OWNER = 1 // 负责人
}
export { CrmPermissionList, CrmBizTypeEnum, CrmPermissionLevelEnum }

View File

@ -235,7 +235,7 @@ const open = async (type: string, id?: number) => {
dialogTitle.value = t('action.' + type) dialogTitle.value = t('action.' + type)
formType.value = type formType.value = type
resetForm() resetForm()
allContactList.value = await ContactApi.simpleAllList() allContactList.value = await ContactApi.getSimpleContactList()
userList.value = await UserApi.getSimpleUserList() userList.value = await UserApi.getSimpleUserList()
customerList.value = await CustomerApi.queryAllList() customerList.value = await CustomerApi.queryAllList()
areaList.value = await AreaApi.getAreaTree() areaList.value = await AreaApi.getAreaTree()

View File

@ -1,14 +1,14 @@
<template> <template>
<!-- 操作栏 --> <!-- 操作栏 -->
<el-row justify="end"> <el-row justify="end">
<el-button class="mb-10px"> <el-button>
<Icon class="mr-5px" icon="system-uicons:contacts" /> <Icon class="mr-5px" icon="system-uicons:contacts" />
创建联系人 创建联系人
</el-button> </el-button>
</el-row> </el-row>
<!-- 列表 --> <!-- 列表 -->
<ContentWrap> <ContentWrap class="mt-10px">
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true"> <el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
<el-table-column label="姓名" fixed="left" align="center" prop="name"> <el-table-column label="姓名" fixed="left" align="center" prop="name">
<template #default="scope"> <template #default="scope">
@ -136,6 +136,7 @@ const openDetail = (id: number) => {
push({ name: 'CrmContactDetail', params: { id } }) push({ name: 'CrmContactDetail', params: { id } })
} }
/** 监听打开的 bizId + bizType从而加载最新的列表 */
watch( watch(
() => [props.bizId, props.bizType], () => [props.bizId, props.bizType],
() => { () => {

View File

@ -90,10 +90,10 @@ import ContactBasicInfo from '@/views/crm/contact/detail/ContactBasicInfo.vue'
import ContactDetails from '@/views/crm/contact/detail/ContactDetails.vue' import ContactDetails from '@/views/crm/contact/detail/ContactDetails.vue'
import ContactForm from '@/views/crm/contact/ContactForm.vue' import ContactForm from '@/views/crm/contact/ContactForm.vue'
import { formatDate } from '@/utils/formatTime' import { formatDate } from '@/utils/formatTime'
import * as CustomerApi from '@/api/crm/customer'
// TODO review // TODO review
defineOptions({ name: 'ContactDetail' }) defineOptions({ name: 'CrmContactDetail' })
const { delView } = useTagsViewStore() // const { delView } = useTagsViewStore() //
const route = useRoute() const route = useRoute()
const { currentRoute } = useRouter() // const { currentRoute } = useRouter() //

View File

@ -1,54 +1,98 @@
<template> <template>
<ContentWrap> <ContentWrap>
<!-- 搜索工作栏 --> <!-- 搜索工作栏 -->
<el-form class="-mb-15px" :model="queryParams" ref="queryFormRef" :inline="true" label-width="68px"> <el-form
class="-mb-15px"
:model="queryParams"
ref="queryFormRef"
:inline="true"
label-width="68px"
>
<el-form-item label="客户" prop="customerId"> <el-form-item label="客户" prop="customerId">
<el-select <el-select
v-model="queryParams.customerId" placeholder="请选择客户" value-key="id" lable-key="name" v-model="queryParams.customerId"
@keyup.enter="handleQuery" clearable> placeholder="请选择客户"
<el-option v-for="item in customerList" :key="item.id" :label="item.name" :value="item.id" /> value-key="id"
lable-key="name"
@keyup.enter="handleQuery"
clearable
>
<el-option
v-for="item in customerList"
:key="item.id"
:label="item.name"
:value="item.id"
/>
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="姓名" prop="name"> <el-form-item label="姓名" prop="name">
<el-input v-model="queryParams.name" placeholder="请输入姓名" clearable @keyup.enter="handleQuery" class="!w-240px" /> <el-input
v-model="queryParams.name"
placeholder="请输入姓名"
clearable
@keyup.enter="handleQuery"
class="!w-240px"
/>
</el-form-item> </el-form-item>
<el-form-item label="手机号" prop="mobile"> <el-form-item label="手机号" prop="mobile">
<el-input <el-input
v-model="queryParams.mobile" placeholder="请输入手机号" clearable @keyup.enter="handleQuery" v-model="queryParams.mobile"
class="!w-240px" /> placeholder="请输入手机号"
clearable
@keyup.enter="handleQuery"
class="!w-240px"
/>
</el-form-item> </el-form-item>
<el-form-item label="座机" prop="telephone"> <el-form-item label="座机" prop="telephone">
<el-input <el-input
v-model="queryParams.telephone" placeholder="请输入电话" clearable @keyup.enter="handleQuery" v-model="queryParams.telephone"
class="!w-240px" /> placeholder="请输入电话"
clearable
@keyup.enter="handleQuery"
class="!w-240px"
/>
</el-form-item> </el-form-item>
<el-form-item label="QQ" prop="qq"> <el-form-item label="QQ" prop="qq">
<el-input v-model="queryParams.qq" placeholder="请输入QQ" clearable @keyup.enter="handleQuery" class="!w-240px" /> <el-input
v-model="queryParams.qq"
placeholder="请输入QQ"
clearable
@keyup.enter="handleQuery"
class="!w-240px"
/>
</el-form-item> </el-form-item>
<el-form-item label="微信" prop="wechat"> <el-form-item label="微信" prop="wechat">
<el-input <el-input
v-model="queryParams.wechat" placeholder="请输入微信" clearable @keyup.enter="handleQuery" v-model="queryParams.wechat"
class="!w-240px" /> placeholder="请输入微信"
clearable
@keyup.enter="handleQuery"
class="!w-240px"
/>
</el-form-item> </el-form-item>
<el-form-item label="电子邮箱" prop="email"> <el-form-item label="电子邮箱" prop="email">
<el-input <el-input
v-model="queryParams.email" placeholder="请输入电子邮箱" clearable @keyup.enter="handleQuery" v-model="queryParams.email"
class="!w-240px" /> placeholder="请输入电子邮箱"
clearable
@keyup.enter="handleQuery"
class="!w-240px"
/>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-button @click="handleQuery"> <el-button @click="handleQuery"> <Icon icon="ep:search" class="mr-5px" /> 搜索 </el-button>
<Icon icon="ep:search" class="mr-5px" /> 搜索 <el-button @click="resetQuery"> <Icon icon="ep:refresh" class="mr-5px" /> 重置 </el-button>
</el-button>
<el-button @click="resetQuery">
<Icon icon="ep:refresh" class="mr-5px" /> 重置
</el-button>
<el-button type="primary" @click="openForm('create')" v-hasPermi="['crm:contact:create']"> <el-button type="primary" @click="openForm('create')" v-hasPermi="['crm:contact:create']">
<Icon icon="ep:plus" class="mr-5px" /> 新增 <Icon icon="ep:plus" class="mr-5px" /> 新增
</el-button> </el-button>
<el-button <el-button
type="success" plain @click="handleExport" :loading="exportLoading" type="success"
v-hasPermi="['crm:contact:export']"> plain
@click="handleExport"
:loading="exportLoading"
v-hasPermi="['crm:contact:export']"
>
<Icon icon="ep:download" class="mr-5px" /> 导出 <Icon icon="ep:download" class="mr-5px" /> 导出
</el-button> </el-button>
</el-form-item> </el-form-item>
@ -60,9 +104,9 @@ type="success" plain @click="handleExport" :loading="exportLoading"
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true"> <el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
<el-table-column label="姓名" fixed="left" align="center" prop="name"> <el-table-column label="姓名" fixed="left" align="center" prop="name">
<template #default="scope"> <template #default="scope">
<el-link type="primary" :underline="false" @click="openDetail(scope.row.id)">{{ <el-link type="primary" :underline="false" @click="openDetail(scope.row.id)">
scope.row.name {{ scope.row.name }}
}}</el-link> </el-link>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="客户" fixed="left" align="center" prop="customerName" /> <el-table-column label="客户" fixed="left" align="center" prop="customerName" />
@ -84,17 +128,41 @@ type="success" plain @click="handleExport" :loading="exportLoading"
<el-table-column label="微信" align="center" prop="wechat" /> <el-table-column label="微信" align="center" prop="wechat" />
<el-table-column label="邮箱" align="center" prop="email" /> <el-table-column label="邮箱" align="center" prop="email" />
<el-table-column label="地址" align="center" prop="address" /> <el-table-column label="地址" align="center" prop="address" />
<el-table-column label="下次联系时间" align="center" prop="nextTime" width="180px" :formatter="dateFormatter" /> <el-table-column
label="下次联系时间"
align="center"
prop="nextTime"
width="180px"
:formatter="dateFormatter"
/>
<el-table-column label="备注" align="center" prop="remark" /> <el-table-column label="备注" align="center" prop="remark" />
<el-table-column label="最后跟进时间" align="center" prop="lastTime" :formatter="dateFormatter" width="180px" /> <el-table-column
label="最后跟进时间"
align="center"
prop="lastTime"
:formatter="dateFormatter"
width="180px"
/>
<el-table-column label="负责人" align="center" prop="ownerUserId"> <el-table-column label="负责人" align="center" prop="ownerUserId">
<template #default="scope"> <template #default="scope">
{{ scope.row.ownerUserName }} {{ scope.row.ownerUserName }}
</template> </template>
</el-table-column> </el-table-column>
<!-- <el-table-column label="所属部门" align="center" prop="ownerUserId" /> --> <!-- <el-table-column label="所属部门" align="center" prop="ownerUserId" /> -->
<el-table-column label="更新时间" align="center" prop="updateTime" :formatter="dateFormatter" width="180px" /> <el-table-column
<el-table-column label="创建时间" align="center" prop="createTime" :formatter="dateFormatter" width="180px" /> label="更新时间"
align="center"
prop="updateTime"
:formatter="dateFormatter"
width="180px"
/>
<el-table-column
label="创建时间"
align="center"
prop="createTime"
:formatter="dateFormatter"
width="180px"
/>
<!-- <el-table-column <!-- <el-table-column
label="创建人" label="创建人"
align="center" align="center"
@ -108,10 +176,20 @@ type="success" plain @click="handleExport" :loading="exportLoading"
</el-table-column> --> </el-table-column> -->
<el-table-column label="操作" align="center" fixed="right" width="200"> <el-table-column label="操作" align="center" fixed="right" width="200">
<template #default="scope"> <template #default="scope">
<el-button plain type="primary" @click="openForm('update', scope.row.id)" v-hasPermi="['crm:contact:update']"> <el-button
plain
type="primary"
@click="openForm('update', scope.row.id)"
v-hasPermi="['crm:contact:update']"
>
编辑 编辑
</el-button> </el-button>
<el-button plain type="danger" @click="handleDelete(scope.row.id)" v-hasPermi="['crm:contact:delete']"> <el-button
plain
type="danger"
@click="handleDelete(scope.row.id)"
v-hasPermi="['crm:contact:delete']"
>
删除 删除
</el-button> </el-button>
</template> </template>
@ -119,8 +197,11 @@ type="success" plain @click="handleExport" :loading="exportLoading"
</el-table> </el-table>
<!-- 分页 --> <!-- 分页 -->
<Pagination <Pagination
:total="total" v-model:page="queryParams.pageNo" v-model:limit="queryParams.pageSize" :total="total"
@pagination="getList" /> v-model:page="queryParams.pageNo"
v-model:limit="queryParams.pageSize"
@pagination="getList"
/>
</ContentWrap> </ContentWrap>
<!-- 表单弹窗添加/修改 --> <!-- 表单弹窗添加/修改 -->
@ -208,7 +289,7 @@ const handleDelete = async (id: number) => {
message.success(t('common.delSuccess')) message.success(t('common.delSuccess'))
// //
await getList() await getList()
} catch { } } catch {}
} }
/** 导出按钮操作 */ /** 导出按钮操作 */
@ -232,7 +313,6 @@ const openDetail = (id: number) => {
push({ name: 'CrmContactDetail', params: { id } }) push({ name: 'CrmContactDetail', params: { id } })
} }
/** 初始化 **/ /** 初始化 **/
onMounted(async () => { onMounted(async () => {
await getList() await getList()

View File

@ -1,18 +0,0 @@
<template>
<el-col>
<el-row>
<span class="text-xl font-bold">{{ customer.name }}</span>
</el-row>
</el-col>
<el-col class="mt-10px">
<!-- TODO 标签 -->
<!-- <Icon icon="ant-design:tag-filled" />-->
</el-col>
</template>
<script setup lang="ts">
import * as CustomerApi from '@/api/crm/customer'
const { customer } = defineProps<{
customer: CustomerApi.CustomerVO
}>()
</script>

View File

@ -3,7 +3,11 @@
<div class="flex items-start justify-between"> <div class="flex items-start justify-between">
<div> <div>
<!-- 左上客户基本信息 --> <!-- 左上客户基本信息 -->
<CustomerBasicInfo :customer="customer" /> <el-col>
<el-row>
<span class="text-xl font-bold">{{ customer.name }}</span>
</el-row>
</el-col>
</div> </div>
<div> <div>
<!-- 右上按钮 --> <!-- 右上按钮 -->
@ -15,29 +19,13 @@
</div> </div>
<!-- TODO 芋艿 --> <!-- TODO 芋艿 -->
<el-row class="mt-10px"> <el-row class="mt-10px">
<el-button> <Icon class="mr-5px" icon="ph:calendar-fill" /> 创建任务 </el-button>
<el-button> <Icon class="mr-5px" icon="carbon:email" /> 发送邮件 </el-button>
<el-button> <Icon class="mr-5px" icon="ep:opportunity" /> 创建商机 </el-button>
<el-button> <Icon class="mr-5px" icon="clarity:contract-line" />创建合同 </el-button>
<el-button> <Icon class="mr-5px" icon="icon-park:income-one" />创建回款 </el-button>
<el-button> <el-button>
<Icon class="mr-5px" icon="ph:calendar-fill" /> <Icon class="mr-5px" icon="fluent:people-team-add-20-filled" /> 添加团队成员
创建任务
</el-button>
<el-button>
<Icon class="mr-5px" icon="carbon:email" />
发送邮件
</el-button>
<el-button>
<Icon class="mr-5px" icon="ep:opportunity" />
创建商机
</el-button>
<el-button>
<Icon class="mr-5px" icon="clarity:contract-line" />
创建合同
</el-button>
<el-button>
<Icon class="mr-5px" icon="icon-park:income-one" />
创建回款
</el-button>
<el-button>
<Icon class="mr-5px" icon="fluent:people-team-add-20-filled" />
添加团队成员
</el-button> </el-button>
</el-row> </el-row>
</div> </div>
@ -49,15 +37,11 @@
<el-descriptions-item label="成交状态"> <el-descriptions-item label="成交状态">
{{ customer.dealStatus ? '已成交' : '未成交' }} {{ customer.dealStatus ? '已成交' : '未成交' }}
</el-descriptions-item> </el-descriptions-item>
<el-descriptions-item label="负责人"> <el-descriptions-item label="负责人">{{ customer.ownerUserName }} </el-descriptions-item>
{{ customer.ownerUserName }}
</el-descriptions-item>
<!-- TODO wanwan 首要联系人? --> <!-- TODO wanwan 首要联系人? -->
<el-descriptions-item label="首要联系人" /> <el-descriptions-item label="首要联系人" />
<!-- TODO wanwan 首要联系人电话? --> <!-- TODO wanwan 首要联系人电话? -->
<el-descriptions-item label="首要联系人电话"> <el-descriptions-item label="首要联系人电话">{{ customer.mobile }} </el-descriptions-item>
{{ customer.mobile }}
</el-descriptions-item>
</el-descriptions> </el-descriptions>
</ContentWrap> </ContentWrap>
@ -65,15 +49,13 @@
<CustomerForm ref="formRef" @success="emit('refresh')" /> <CustomerForm ref="formRef" @success="emit('refresh')" />
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import * as CustomerApi from '@/api/crm/customer'
import { DICT_TYPE } from '@/utils/dict' import { DICT_TYPE } from '@/utils/dict'
// TODO @wanwan CustomerBasicInfo import * as CustomerApi from '@/api/crm/customer'
import CustomerBasicInfo from '@/views/crm/customer/detail/CustomerBasicInfo.vue' import CustomerForm from '../CustomerForm.vue'
import CustomerForm from '@/views/crm/customer/CustomerForm.vue'
const { customer, loading } = defineProps<{ const { customer, loading } = defineProps<{
customer: CustomerApi.CustomerVO customer: CustomerApi.CustomerVO //
loading: boolean loading: boolean //
}>() }>()
/** 修改操作 */ /** 修改操作 */

View File

@ -18,29 +18,15 @@
<el-descriptions-item label="客户等级"> <el-descriptions-item label="客户等级">
<dict-tag :type="DICT_TYPE.CRM_CUSTOMER_LEVEL" :value="customer.level" /> <dict-tag :type="DICT_TYPE.CRM_CUSTOMER_LEVEL" :value="customer.level" />
</el-descriptions-item> </el-descriptions-item>
<el-descriptions-item label="手机"> <el-descriptions-item label="手机">{{ customer.mobile }}</el-descriptions-item>
{{ customer.mobile }} <el-descriptions-item label="电话">{{ customer.telephone }}</el-descriptions-item>
</el-descriptions-item> <el-descriptions-item label="邮箱">{{ customer.email }} </el-descriptions-item>
<el-descriptions-item label="电话"> <el-descriptions-item label="QQ">{{ customer.qq }} </el-descriptions-item>
{{ customer.telephone }} <el-descriptions-item label="微信">{{ customer.wechat }} </el-descriptions-item>
</el-descriptions-item> <el-descriptions-item label="网址">{{ customer.website }} </el-descriptions-item>
<el-descriptions-item label="邮箱"> <el-descriptions-item label="所在地">{{ customer.areaName }} </el-descriptions-item>
{{ customer.email }} <el-descriptions-item label="详细地址"
</el-descriptions-item> >{{ customer.detailAddress }}
<el-descriptions-item label="QQ">
{{ customer.qq }}
</el-descriptions-item>
<el-descriptions-item label="微信">
{{ customer.wechat }}
</el-descriptions-item>
<el-descriptions-item label="网址">
{{ customer.website }}
</el-descriptions-item>
<el-descriptions-item label="所在地">
{{ customer.areaName }}
</el-descriptions-item>
<el-descriptions-item label="详细地址">
{{ customer.detailAddress }}
</el-descriptions-item> </el-descriptions-item>
<el-descriptions-item label="下次联系时间"> <el-descriptions-item label="下次联系时间">
{{ {{
@ -52,12 +38,8 @@
</el-descriptions-item> </el-descriptions-item>
</el-descriptions> </el-descriptions>
<el-descriptions :column="1"> <el-descriptions :column="1">
<el-descriptions-item label="客户描述"> <el-descriptions-item label="客户描述">{{ customer.description }} </el-descriptions-item>
{{ customer.description }} <el-descriptions-item label="备注">{{ customer.remark }} </el-descriptions-item>
</el-descriptions-item>
<el-descriptions-item label="备注">
{{ customer.remark }}
</el-descriptions-item>
</el-descriptions> </el-descriptions>
</el-collapse-item> </el-collapse-item>
<el-collapse-item name="systemInfo"> <el-collapse-item name="systemInfo">
@ -65,12 +47,8 @@
<span class="text-base font-bold">系统信息</span> <span class="text-base font-bold">系统信息</span>
</template> </template>
<el-descriptions :column="2"> <el-descriptions :column="2">
<el-descriptions-item label="负责人"> <el-descriptions-item label="负责人">{{ customer.ownerUserName }} </el-descriptions-item>
{{ customer.ownerUserName }} <el-descriptions-item label="创建人">{{ customer.creatorName }} </el-descriptions-item>
</el-descriptions-item>
<el-descriptions-item label="创建人">
{{ customer.creatorName }}
</el-descriptions-item>
<el-descriptions-item label="创建时间"> <el-descriptions-item label="创建时间">
{{ customer.createTime ? formatDate(customer.createTime) : '空' }} {{ customer.createTime ? formatDate(customer.createTime) : '空' }}
</el-descriptions-item> </el-descriptions-item>
@ -88,10 +66,9 @@ import { DICT_TYPE } from '@/utils/dict'
import { formatDate } from '@/utils/formatTime' import { formatDate } from '@/utils/formatTime'
const { customer } = defineProps<{ const { customer } = defineProps<{
customer: CustomerApi.CustomerVO customer: CustomerApi.CustomerVO //
}>() }>()
// const activeNames = ref(['basicInfo', 'systemInfo']) //
const activeNames = ref(['basicInfo', 'systemInfo'])
</script> </script>
<style scoped lang="scss"></style> <style scoped lang="scss"></style>

View File

@ -1,16 +1,16 @@
<template> <template>
<CustomerDetailsHeader :customer="customer" :loading="loading" @refresh="getCustomerData(id)" /> <CustomerDetailsHeader :customer="customer" :loading="loading" @refresh="getCustomer(id)" />
<el-col> <el-col>
<el-tabs> <el-tabs>
<el-tab-pane label="详细资料"> <el-tab-pane label="详细资料">
<CustomerDetails :customer="customer" /> <CustomerDetailsInfo :customer="customer" />
</el-tab-pane> </el-tab-pane>
<el-tab-pane label="操作日志" lazy>TODO 待开发</el-tab-pane> <el-tab-pane label="操作日志" lazy>TODO 待开发</el-tab-pane>
<el-tab-pane label="联系人" lazy> <el-tab-pane label="联系人" lazy>
<ContactList :biz-id="customer.id!" :biz-type="BizTypeEnum.CRM_CUSTOMER" /> <ContactList :biz-id="customer.id!" :biz-type="BizTypeEnum.CRM_CUSTOMER" />
</el-tab-pane> </el-tab-pane>
<el-tab-pane label="团队成员" lazy> <el-tab-pane label="团队成员" lazy>
<CrmPermissionList :biz-id="customer.id!" :biz-type="BizTypeEnum.CRM_CUSTOMER" /> <PermissionList :biz-id="customer.id!" :biz-type="BizTypeEnum.CRM_CUSTOMER" />
</el-tab-pane> </el-tab-pane>
<el-tab-pane label="商机" lazy> 商机</el-tab-pane> <el-tab-pane label="商机" lazy> 商机</el-tab-pane>
<el-tab-pane label="合同" lazy>TODO 待开发</el-tab-pane> <el-tab-pane label="合同" lazy>TODO 待开发</el-tab-pane>
@ -20,31 +20,24 @@
</el-tabs> </el-tabs>
</el-col> </el-col>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { useTagsViewStore } from '@/store/modules/tagsView' import { useTagsViewStore } from '@/store/modules/tagsView'
import * as CustomerApi from '@/api/crm/customer' import * as CustomerApi from '@/api/crm/customer'
import CustomerDetails from '@/views/crm/customer/detail/CustomerDetails.vue' import CustomerDetailsInfo from './CustomerDetailsInfo.vue' // -
import { CrmPermissionList } from '@/views/crm/components' import CustomerDetailsHeader from './CustomerDetailsHeader.vue' // -
import ContactList from '@/views/crm/contact/components/ContactList.vue' import ContactList from '@/views/crm/contact/components/ContactList.vue' //
import CustomerDetailsHeader from './CustomerDetailsHeader.vue' import PermissionList from '@/views/crm/permission/components/PermissionList.vue' //
import { BizTypeEnum } from '@/api/crm/permission' import { BizTypeEnum } from '@/api/crm/permission'
defineOptions({ name: 'CustomerDetail' }) defineOptions({ name: 'CrmCustomerDetail' })
const { delView } = useTagsViewStore() //
const route = useRoute() const route = useRoute()
const { currentRoute } = useRouter() // const id = Number(route.params.id) //
const id = Number(route.params.id)
const loading = ref(true) // const loading = ref(true) //
/** /** 获取详情 */
* 获取详情
*
* @param id 客户编号
*/
const customer = ref<CustomerApi.CustomerVO>({} as CustomerApi.CustomerVO) // const customer = ref<CustomerApi.CustomerVO>({} as CustomerApi.CustomerVO) //
const getCustomerData = async (id: number) => { const getCustomer = async (id: number) => {
loading.value = true loading.value = true
try { try {
customer.value = await CustomerApi.getCustomer(id) customer.value = await CustomerApi.getCustomer(id)
@ -53,15 +46,15 @@ const getCustomerData = async (id: number) => {
} }
} }
/** /** 初始化 */
* 初始化 const { delView } = useTagsViewStore() //
*/ const { currentRoute } = useRouter() //
onMounted(() => { onMounted(() => {
if (!id) { if (!id) {
ElMessage.warning('参数错误,客户不能为空!') ElMessage.warning('参数错误,客户不能为空!')
delView(unref(currentRoute)) delView(unref(currentRoute))
return return
} }
getCustomerData(id) getCustomer(id)
}) })
</script> </script>

View File

@ -72,17 +72,10 @@
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-button @click="handleQuery"> <el-button @click="handleQuery"> <Icon class="mr-5px" icon="ep:search" /> 搜索 </el-button>
<Icon class="mr-5px" icon="ep:search" /> <el-button @click="resetQuery"> <Icon class="mr-5px" icon="ep:refresh" />重置 </el-button>
搜索
</el-button>
<el-button @click="resetQuery">
<Icon class="mr-5px" icon="ep:refresh" />
重置
</el-button>
<el-button v-hasPermi="['crm:customer:create']" type="primary" @click="openForm('create')"> <el-button v-hasPermi="['crm:customer:create']" type="primary" @click="openForm('create')">
<Icon class="mr-5px" icon="ep:plus" /> <Icon class="mr-5px" icon="ep:plus" /> 新增
新增
</el-button> </el-button>
<el-button <el-button
v-hasPermi="['crm:customer:export']" v-hasPermi="['crm:customer:export']"
@ -91,8 +84,7 @@
type="success" type="success"
@click="handleExport" @click="handleExport"
> >
<Icon class="mr-5px" icon="ep:download" /> <Icon class="mr-5px" icon="ep:download" /> 导出
导出
</el-button> </el-button>
</el-form-item> </el-form-item>
</el-form> </el-form>
@ -102,7 +94,13 @@
<ContentWrap> <ContentWrap>
<el-table v-loading="loading" :data="list" :show-overflow-tooltip="true" :stripe="true"> <el-table v-loading="loading" :data="list" :show-overflow-tooltip="true" :stripe="true">
<el-table-column align="center" label="编号" prop="id" /> <el-table-column align="center" label="编号" prop="id" />
<el-table-column align="center" label="客户名称" prop="name" width="160" /> <el-table-column align="center" label="客户名称" prop="name" width="160">
<template #default="scope">
<el-link type="primary" :underline="false" @click="openDetail(scope.row.id)">
{{ scope.row.name }}
</el-link>
</template>
</el-table-column>
<el-table-column align="center" label="所属行业" prop="industryId" width="120"> <el-table-column align="center" label="所属行业" prop="industryId" width="120">
<template #default="scope"> <template #default="scope">
<dict-tag :type="DICT_TYPE.CRM_CUSTOMER_INDUSTRY" :value="scope.row.industryId" /> <dict-tag :type="DICT_TYPE.CRM_CUSTOMER_INDUSTRY" :value="scope.row.industryId" />
@ -157,7 +155,6 @@
<!-- TODO @wanwan 距进入公海天数 --> <!-- TODO @wanwan 距进入公海天数 -->
<el-table-column align="center" fixed="right" label="操作" min-width="150"> <el-table-column align="center" fixed="right" label="操作" min-width="150">
<template #default="scope"> <template #default="scope">
<el-button link type="primary" @click="openDetail(scope.row.id)">详情</el-button>
<el-button <el-button
v-hasPermi="['crm:customer:update']" v-hasPermi="['crm:customer:update']"
link link

View File

@ -23,12 +23,13 @@
v-for="dict in getIntDictOptions(DICT_TYPE.CRM_PERMISSION_LEVEL)" v-for="dict in getIntDictOptions(DICT_TYPE.CRM_PERMISSION_LEVEL)"
:key="dict.value" :key="dict.value"
> >
<el-radio v-if="dict.value != CrmPermissionLevelEnum.OWNER" :label="dict.value"> <el-radio v-if="dict.value != PermissionLevelEnum.OWNER" :label="dict.value">
{{ dict.label }} {{ dict.label }}
</el-radio> </el-radio>
</template> </template>
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
<!-- TODO @puhui999同时添加至 -->
</el-form> </el-form>
<template #footer> <template #footer>
<el-button :disabled="formLoading" type="primary" @click="submitForm"> </el-button> <el-button :disabled="formLoading" type="primary" @click="submitForm"> </el-button>
@ -39,8 +40,8 @@
<script lang="ts" setup> <script lang="ts" setup>
import * as UserApi from '@/api/system/user' import * as UserApi from '@/api/system/user'
import * as PermissionApi from '@/api/crm/permission' import * as PermissionApi from '@/api/crm/permission'
import { PermissionLevelEnum } from '@/api/crm/permission'
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict' import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
import { CrmPermissionLevelEnum } from '@/views/crm/components/index'
defineOptions({ name: 'CrmPermissionForm' }) defineOptions({ name: 'CrmPermissionForm' })
@ -54,8 +55,8 @@ const formType = ref('') // 表单的类型create - 新增update - 修改
const userOptions = ref<UserApi.UserVO[]>([]) // const userOptions = ref<UserApi.UserVO[]>([]) //
const formData = ref<PermissionApi.PermissionVO & { ids?: number[] }>({ const formData = ref<PermissionApi.PermissionVO & { ids?: number[] }>({
userId: undefined, // userId: undefined, //
bizType: undefined, // Crm bizType: undefined, // CRM
bizId: undefined, // Crm bizId: undefined, // CRM
level: undefined // level: undefined //
}) })
const formRules = reactive({ const formRules = reactive({

View File

@ -1,9 +1,8 @@
<template> <template>
<!-- 操作栏 --> <!-- 操作栏 -->
<el-row justify="end"> <el-row justify="end">
<el-button type="primary" @click="openForm"> <el-button @click="openForm">
<Icon class="mr-5px" icon="ep:plus" /> <Icon class="mr-5px" icon="fluent:people-team-add-20-filled" /> 添加团队成员
新增
</el-button> </el-button>
<el-button @click="handleUpdate"> <el-button @click="handleUpdate">
<Icon class="mr-5px" icon="ep:edit" /> <Icon class="mr-5px" icon="ep:edit" />
@ -16,47 +15,51 @@
<el-button type="danger" @click="handleQuit"> 退出团队</el-button> <el-button type="danger" @click="handleQuit"> 退出团队</el-button>
</el-row> </el-row>
<!-- 团队成员展示 --> <!-- 列表 -->
<el-table <ContentWrap class="mt-10px">
v-loading="loading" <el-table
:data="list" v-loading="loading"
:show-overflow-tooltip="true" :data="list"
:stripe="true" :show-overflow-tooltip="true"
class="mt-20px" :stripe="true"
@selection-change="handleSelectionChange" @selection-change="handleSelectionChange"
> >
<el-table-column type="selection" width="55" /> <el-table-column type="selection" width="55" />
<el-table-column align="center" label="姓名" prop="nickname" /> <el-table-column align="center" label="姓名" prop="nickname" />
<el-table-column align="center" label="部门" prop="deptName" /> <el-table-column align="center" label="部门" prop="deptName" />
<el-table-column align="center" label="岗位" prop="postNames" /> <el-table-column align="center" label="岗位" prop="postNames" />
<el-table-column align="center" label="权限级别" prop="level"> <el-table-column align="center" label="权限" prop="level">
<template #default="{ row }"> <template #default="{ row }">
<dict-tag :type="DICT_TYPE.CRM_PERMISSION_LEVEL" :value="row.level" /> <dict-tag :type="DICT_TYPE.CRM_PERMISSION_LEVEL" :value="row.level" />
</template> </template>
</el-table-column> </el-table-column>
<el-table-column :formatter="dateFormatter" align="center" label="加入时间" prop="createTime" /> <el-table-column
</el-table> :formatter="dateFormatter"
align="center"
label="加入时间"
prop="createTime"
/>
</el-table>
</ContentWrap>
<!-- 表单弹窗添加/修改 --> <!-- 表单弹窗添加/修改 -->
<CrmPermissionForm ref="formRef" @success="getList" /> <CrmPermissionForm ref="formRef" @success="getList" />
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { dateFormatter } from '@/utils/formatTime' import { dateFormatter } from '@/utils/formatTime'
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'
import { DICT_TYPE } from '@/utils/dict' import { DICT_TYPE } from '@/utils/dict'
import * as PermissionApi from '@/api/crm/permission'
import { PermissionLevelEnum } from '@/api/crm/permission'
import { useUserStoreWithOut } from '@/store/modules/user'
import CrmPermissionForm from './PermissionForm.vue'
defineOptions({ name: 'CrmPermissionList' }) defineOptions({ name: 'CrmPermissionList' })
const props = defineProps<{
bizType: number //
bizId: number //
}>()
const message = useMessage() // const message = useMessage() //
const props = defineProps<{
bizType: number //
bizId: number //
}>()
const loading = ref(true) // const loading = ref(true) //
const list = ref<PermissionApi.PermissionVO[]>([]) // const list = ref<PermissionApi.PermissionVO[]>([]) //
@ -64,28 +67,34 @@ const list = ref<PermissionApi.PermissionVO[]>([]) // 列表的数据
const getList = async () => { const getList = async () => {
loading.value = true loading.value = true
try { try {
const data = await PermissionApi.getPermissionList({ list.value = await PermissionApi.getPermissionList({
bizType: props.bizType, bizType: props.bizType,
bizId: props.bizId bizId: props.bizId
}) })
list.value = data
} finally { } finally {
loading.value = false loading.value = false
} }
} }
/** 选中团队成员 */
const multipleSelection = ref<PermissionApi.PermissionVO[]>([]) // const multipleSelection = ref<PermissionApi.PermissionVO[]>([]) //
const handleSelectionChange = (val: PermissionApi.PermissionVO[]) => { const handleSelectionChange = (val: PermissionApi.PermissionVO[]) => {
multipleSelection.value = val multipleSelection.value = val
} }
/** 编辑团队成员 */ /** 添加团队成员 */
const formRef = ref<InstanceType<typeof CrmPermissionForm>>() // Ref const formRef = ref<InstanceType<typeof CrmPermissionForm>>() // Ref
const openForm = () => {
formRef.value?.open('create', props.bizType, props.bizId)
}
/** 编辑团队成员 */
const handleUpdate = () => { const handleUpdate = () => {
if (multipleSelection.value?.length === 0) { if (multipleSelection.value?.length === 0) {
message.warning('请先选择团队成员后操作!') message.warning('请先选择团队成员后操作!')
return return
} }
const ids = multipleSelection.value?.map((item) => item.id) const ids = multipleSelection.value?.map((item) => item.id) as number[]
formRef.value?.open('update', props.bizType, props.bizId, ids) formRef.value?.open('update', props.bizType, props.bizId, ids)
} }
@ -95,36 +104,34 @@ const handleDelete = async () => {
message.warning('请先选择团队成员后操作!') message.warning('请先选择团队成员后操作!')
return return
} }
// TODO @puhui999
await message.delConfirm() await message.delConfirm()
const ids = multipleSelection.value?.map((item) => item.id) const ids = multipleSelection.value?.map((item) => item.id)
await PermissionApi.deletePermission({ await PermissionApi.deletePermissionBatch({
bizType: props.bizType, bizType: props.bizType,
bizId: props.bizId, bizId: props.bizId,
ids ids
}) })
} }
/** 添加团队成员 */
const openForm = () => {
formRef.value?.open('create', props.bizType, props.bizId)
}
/** 退出团队 */ /** 退出团队 */
const userStore = useUserStoreWithOut() // const userStore = useUserStoreWithOut() //
const handleQuit = async () => { const handleQuit = async () => {
const permission = list.value.find( const permission = list.value.find(
(item) => item.userId === userStore.getUser.id && item.level === CrmPermissionLevelEnum.OWNER (item) => item.userId === userStore.getUser.id && item.level === PermissionLevelEnum.OWNER
) )
if (permission) { if (permission) {
message.warning('负责人不能退出团队!') message.warning('负责人不能退出团队!')
return return
} }
// TODO @puhui999
const userPermission = list.value.find((item) => item.userId === userStore.getUser.id) const userPermission = list.value.find((item) => item.userId === userStore.getUser.id)
await PermissionApi.quitTeam(userPermission?.id) await PermissionApi.deleteSelfPermission(userPermission?.id)
} }
/** 监听打开的 bizId + bizType从而加载最新的列表 */
watch( watch(
() => props.bizId, () => [props.bizId, props.bizType],
() => { () => {
getList() getList()
}, },