CRM 客户管理 权限优化

pull/853/head
wersd 2025-06-12 22:42:04 +08:00
parent d9fe53ca5b
commit 7bd962b740
12 changed files with 44 additions and 1041 deletions

View File

@ -26,6 +26,7 @@ export interface FollowUpRecordVO {
}[] // 关联的联系人数组
creator: string
creatorName?: string
createTime: Date // 创建时间
}
// 跟进记录 API

View File

@ -9,7 +9,7 @@ const props = defineProps({
modelValue: propTypes.bool.def(false),
title: propTypes.string.def('Dialog'),
fullscreen: propTypes.bool.def(true),
width: propTypes.oneOfType([String, Number]).def('40%'),
width: propTypes.oneOfType([String, Number]).def('60%'),
scroll: propTypes.bool.def(false), // maxHeight
maxHeight: propTypes.oneOfType([String, Number]).def('400px')
})

View File

@ -1,26 +1,12 @@
<template>
<!-- 操作栏 -->
<el-row justify="end">
<el-button @click="openForm">
<el-button
v-hasPermi="['crm:contact:create']"
@click="openForm">
<Icon class="mr-5px" icon="system-uicons:contacts" />
创建联系人
</el-button>
<el-button
v-if="queryParams.businessId"
v-hasPermi="['crm:contact:create-business']"
@click="openBusinessModal"
>
<Icon class="mr-5px" icon="ep:circle-plus" />
关联
</el-button>
<el-button
v-if="queryParams.businessId"
v-hasPermi="['crm:contact:delete-business']"
@click="deleteContactBusinessList"
>
<Icon class="mr-5px" icon="ep:remove" />
解除关联
</el-button>
</el-row>
<!-- 列表 -->
@ -50,8 +36,8 @@
</el-table-column>
<el-table-column align="center" label="操作" fixed="right" min-width="120">
<template #default="scope">
<el-button link type="primary" @click="openFormEdit(scope.row.id)"></el-button>
<el-button link type="danger" @click="handleDelete(scope.row.id)"></el-button>
<el-button v-hasPermi="['crm:contact:update']" link type="primary" @click="openFormEdit(scope.row.id)"></el-button>
<el-button v-hasPermi="['crm:contact:delete']" link type="danger" @click="handleDelete(scope.row.id)"></el-button>
</template>
</el-table-column>
</el-table>
@ -66,13 +52,6 @@
<!-- 表单弹窗添加 -->
<ContactForm ref="formRef" @success="getList" />
<!-- 关联商机选择弹框 -->
<ContactListModal
v-if="customerId"
ref="contactModalRef"
:customer-id="customerId"
@success="createContactBusinessList"
/>
</template>
<script lang="ts" setup>
import * as ContactApi from '@/api/crm/contact'

View File

@ -1,6 +1,6 @@
<template>
<ContactDetailsHeader v-loading="loading" :contact="contact">
<el-button v-if="permissionListRef?.validateWrite" @click="openForm('update', contact.id)">
<el-button @click="openForm('update', contact.id)">
编辑
</el-button>
<!-- <el-button v-if="permissionListRef?.validateOwnerUser" type="primary" @click="transfer">
@ -18,7 +18,7 @@
<el-tab-pane label="操作日志">
<OperateLogV2 :log-list="logList" />
</el-tab-pane>
<el-tab-pane label="团队成员">
<!-- <el-tab-pane label="团队成员">
<PermissionList
ref="permissionListRef"
:biz-id="contact.id!"
@ -26,7 +26,7 @@
:show-action="true"
@quit-team="close"
/>
</el-tab-pane>
</el-tab-pane> -->
</el-tabs>
</el-col>
<!-- 表单弹窗添加/修改 -->

View File

@ -18,10 +18,10 @@
<ContentWrap class="mt-10px">
<el-descriptions :column="4" direction="horizontal" class="mb-10px">
<el-descriptions-item label="成交状态:">
<dict-tag :type="DICT_TYPE.CRM_CUSTOMER_DEAL_STATUS" :value="customer.dealStatus" />
<dict-tag :type="DICT_TYPE.CRM_CUSTOMER_DEAL_STATUS" :value="customer.dealStatus ?? ''" />
</el-descriptions-item>
<el-descriptions-item label="客户类别:">
<dict-tag :type="DICT_TYPE.CRM_CUSTOMER_INDUSTRY" :value="customer.industryId" />
<dict-tag :type="DICT_TYPE.CRM_CUSTOMER_INDUSTRY" :value="customer.industryId ?? ''" />
</el-descriptions-item>
<el-descriptions-item label="负责人:">{{ customer.ownerUserName }}</el-descriptions-item>

View File

@ -32,14 +32,14 @@
</CustomerDetailsHeader>
<el-col>
<el-tabs>
<el-tab-pane label="跟进记录">
<el-tab-pane v-if="checkPermi(['crm:follow-up-record:query'])" label="跟进记录">
<FollowUpList :biz-id="customerId" :biz-type="BizTypeEnum.CRM_CUSTOMER" />
</el-tab-pane>
<!-- <el-tab-pane label="基本信息">
<CustomerDetailsInfo :customer="customer" />
</el-tab-pane> -->
<el-tab-pane label="联系人" lazy>
<ContactList :biz-id="customer.id!" :biz-type="BizTypeEnum.CRM_CUSTOMER" :customer-id="customerId"/>
<el-tab-pane v-if="checkPermi(['crm:contact:query'])" label="联系人" lazy>
<ContactList :biz-id="customerId" :biz-type="BizTypeEnum.CRM_CUSTOMER" />
</el-tab-pane>
<!-- <el-tab-pane label="团队成员">
<PermissionList
@ -50,11 +50,10 @@
@quit-team="close"
/>
</el-tab-pane> -->
<el-tab-pane label="合同" lazy>
<ContractList :biz-id="customer.id!" :biz-type="BizTypeEnum.CRM_CUSTOMER" />
<el-tab-pane v-if="checkPermi(['crm:contract:query'])" label="合同" lazy>
<ContractList :biz-id="customerId!" :biz-type="BizTypeEnum.CRM_CUSTOMER" />
</el-tab-pane>
<el-tab-pane v-hasPermi="['crm:customer:file:query']" label="附件">
<el-tab-pane v-if="checkPermi(['crm:customer:file:query'])" label="附件">
<FileList v-if="customerId" :customerId="customerId" />
</el-tab-pane>
<el-tab-pane label="操作日志">
@ -80,15 +79,17 @@ import ReceivableList from '@/views/crm/receivable/components/ReceivableList.vue
import ReceivablePlanList from '@/views/crm/receivable/plan/components/ReceivablePlanList.vue' //
import PermissionList from '@/views/crm/permission/components/PermissionList.vue' //
import CrmTransferForm from '@/views/crm/permission/components/TransferForm.vue'
import FollowUpList from '@/views/crm/followup/index.vue'
import FollowUpList from '@/views/crm/followup/components/FollowUpList.vue'
import { BizTypeEnum } from '@/api/crm/permission'
import type { OperateLogVO } from '@/api/system/operatelog'
import { getOperateLogPage } from '@/api/crm/operateLog'
import CustomerDistributeForm from '@/views/crm/customer/pool/CustomerDistributeForm.vue'
import FileList from '../components/FileList.vue'
import { checkPermi } from "@/utils/permission"; //
defineOptions({ name: 'CrmCustomerDetail' })
const customerId = ref(0) //
const loading = ref(true) //
const message = useMessage() //
@ -210,4 +211,6 @@ onMounted(() => {
customerId.value = Number(params.id)
getCustomer()
})
</script>

View File

@ -1,209 +0,0 @@
<!-- 跟进记录的添加表单 -->
<template>
<Dialog v-model="dialogVisible" title="添加跟进记录" width="50%">
<el-form
ref="formRef"
v-loading="formLoading"
:model="formData"
:rules="formRules"
label-width="120px"
>
<el-row>
<el-col :span="12">
<el-form-item label="跟进方式" prop="type">
<el-select v-model="formData.type" placeholder="请选择跟进">
<el-option
v-for="dict in getIntDictOptions(DICT_TYPE.CRM_FOLLOW_UP_TYPE)"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12" v-if="formData.bizType == BizTypeEnum.CRM_CUSTOMER">
<el-form-item label="选择联系人" prop="contactIds">
<el-select v-model="formData.contactIds" filterable placeholder="请选择联系人">
<el-option v-for="item in contactOptions" :key="item.id" :label="item.name" :value="item.id" />
</el-select>
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="跟进内容" prop="content">
<Editor v-model="formData.content" height="150px" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="附件" prop="fileUrls">
<UploadFile v-model="formData.fileUrls" class="min-w-80px" />
</el-form-item>
</el-col>
</el-row>
</el-form>
<template #footer>
<el-button :disabled="formLoading" type="primary" @click="submitForm"> </el-button>
<el-button @click="dialogVisible = false"> </el-button>
</template>
</Dialog>
</template>
<script lang="ts" setup>
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
import { FollowUpRecordApi, FollowUpRecordVO } from '@/api/crm/followup'
import { BizTypeEnum } from '@/api/crm/permission'
import FollowUpRecordBusinessForm from './components/FollowUpRecordBusinessForm.vue'
import FollowUpRecordContactForm from './components/FollowUpRecordContactForm.vue'
import BusinessListModal from '@/views/crm/business/components/BusinessListModal.vue'
import * as BusinessApi from '@/api/crm/business'
import ContactListModal from '@/views/crm/contact/components/ContactListModal.vue'
import * as ContactApi from '@/api/crm/contact'
defineOptions({ name: 'FollowUpRecordForm' })
const { t } = useI18n() //
const message = useMessage() //
const dialogVisible = ref(false) //
const dialogTitle = ref('') //
const formLoading = ref(false) // 12
//
interface FollowUpFormData {
bizType?: number;
bizId?: number;
type?: number;
content?: string;
nextTime?: any;
picUrls?: string[];
fileUrls?: string[];
businesses?: any[];
contacts?: any[];
contactIds?: number[];
}
const formData = ref<FollowUpFormData>({
bizType: undefined,
bizId: undefined,
type: undefined,
content: '',
nextTime: undefined,
picUrls: [],
fileUrls: [],
businesses: [],
contacts: [],
contactIds: []
})
const formRules = reactive({
type: [{ required: true, message: '跟进类型不能为空', trigger: 'change' }],
content: [{ required: true, message: '跟进内容不能为空', trigger: 'blur' }],
contactIds: [{ required: true, message: '联系人不能为空', trigger: 'change' }]
})
const formRef = ref() // Ref
const contactOptions = ref<ContactApi.ContactVO[]>([])
const formType = ref('') // create - update -
watch(
() => formData.value.bizId,
async (val) => {
if (formData.value.bizType === BizTypeEnum.CRM_CUSTOMER && val) {
//
const res = await ContactApi.getContactPageByCustomer({ customerId: val, pageSize: 100 })
contactOptions.value = res.list || []
//
if (contactOptions.value.length > 0) {
formData.value.contactIds = [contactOptions.value[0].id]
} else {
formData.value.contactIds = []
}
} else {
contactOptions.value = []
formData.value.contactIds = []
}
},
{ immediate: true }
)
/** 打开弹窗 */
const open = async (bizType: number, bizId: number, id?: number) => {
dialogVisible.value = true
resetForm()
formData.value.bizType = bizType
formData.value.bizId = bizId
if (id) {
formType.value = 'update'
formLoading.value = true
try {
const data = await FollowUpRecordApi.getFollowUpRecord(id)
Object.assign(formData.value, data)
} finally {
formLoading.value = false
}
} else {
formType.value = 'create'
}
}
defineExpose({ open }) // open
/** 提交表单 */
const emit = defineEmits(['success']) // success
// contactIds
const submitForm = async () => {
await formRef.value.validate()
formLoading.value = true
try {
// contactIds
let contactIds = formData.value.contactIds
if (!Array.isArray(contactIds)) {
contactIds = contactIds !== undefined && contactIds !== null ? [contactIds] : []
}
const data = {
...formData.value,
contactIds,
businessIds: (formData.value.businesses || []).map((item: any) => item.id)
} as unknown as FollowUpRecordVO
if (formType.value === 'create') {
await FollowUpRecordApi.createFollowUpRecord(data)
message.success(t('common.createSuccess'))
} else {
await FollowUpRecordApi.updateFollowUpRecord(data)
message.success(t('common.updateSuccess'))
}
message.success(t('common.createSuccess'))
dialogVisible.value = false
emit('success')
} finally {
formLoading.value = false
}
}
/** 关联商机 */
const businessTableSelectRef = ref<InstanceType<typeof BusinessListModal>>()
const handleOpenBusiness = () => {
businessTableSelectRef.value?.open()
}
const handleAddBusiness = (businessId: [], newBusinesses: BusinessApi.BusinessVO[]) => {
newBusinesses.forEach((business) => {
if (!formData.value.businesses.some((item) => item.id === business.id)) {
formData.value.businesses.push(business)
}
})
}
/** 重置表单 */
const resetForm = () => {
formRef.value?.resetFields()
formData.value = {
bizId: undefined,
bizType: undefined,
type: undefined,
content: '',
nextTime: undefined,
picUrls: [],
fileUrls: [],
businesses: [],
contacts: [],
contactIds: []
}
}
</script>

View File

@ -1,42 +0,0 @@
<template>
<el-table :data="formData" :show-overflow-tooltip="true" :stripe="true" height="120">
<el-table-column label="商机名称" fixed="left" align="center" prop="name" />
<el-table-column
label="商机金额"
align="center"
prop="totalPrice"
:formatter="erpPriceTableColumnFormatter"
/>
<el-table-column label="客户名称" align="center" prop="customerName" />
<el-table-column label="商机组" align="center" prop="statusTypeName" />
<el-table-column label="商机阶段" align="center" prop="statusName" />
<el-table-column align="center" fixed="right" label="操作" width="80">
<template #default="{ $index }">
<el-button link type="danger" @click="handleDelete($index)"> </el-button>
</template>
</el-table-column>
</el-table>
</template>
<script lang="ts" setup>
import { erpPriceTableColumnFormatter } from '@/utils'
const props = defineProps<{
businesses: undefined
}>()
const formData = ref([])
/** 初始化商机列表 */
watch(
() => props.businesses,
async (val) => {
formData.value = val
},
{ immediate: true }
)
/** 删除按钮操作 */
const handleDelete = (index: number) => {
formData.value.splice(index, 1)
}
</script>

View File

@ -1,47 +0,0 @@
<template>
<el-table :data="contacts" :show-overflow-tooltip="true" :stripe="true" height="150">
<el-table-column label="姓名" fixed="left" align="center" prop="name">
<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 label="手机号" align="center" prop="mobile" />
<el-table-column label="职位" align="center" prop="post" />
<el-table-column label="直属上级" align="center" prop="parentName" />
<el-table-column label="是否关键决策人" align="center" prop="master" min-width="100">
<template #default="scope">
<dict-tag :type="DICT_TYPE.INFRA_BOOLEAN_STRING" :value="scope.row.master" />
</template>
</el-table-column>
<el-table-column align="center" fixed="right" label="操作" width="130">
<template #default="scope">
<el-button link type="danger" @click="handleDelete(scope.row.id)"> </el-button>
</template>
</el-table-column>
</el-table>
</template>
<script lang="ts" setup>
import { DICT_TYPE } from '@/utils/dict'
const props = defineProps<{
contacts: undefined
}>()
const formData = ref([])
/** 初始化联系人列表 */
watch(
() => props.contacts,
async (val) => {
formData.value = val
},
{ immediate: true }
)
/** 删除按钮操作 */
const handleDelete = (index: number) => {
formData.value.splice(index, 1)
}
</script>

View File

@ -1,314 +1,30 @@
<!-- 某个记录的跟进记录列表目前主要用于 CRM 客户商机等详情界-->
<!-- 跟进记录页-->
<template>
<!-- 操作栏 -->
<el-row class="mb-10px" justify="end">
<el-button @click="openForm">
<Icon class="mr-5px" icon="ep:edit" />
写跟进
</el-button>
</el-row>
<!-- 跟进记录时间线 -->
<el-timeline>
<el-timeline-item
v-for="(item, index) in list"
:key="item.id || index"
:timestamp="formatDate(item.createTime)"
placement="top"
>
<span>跟进人</span>{{ item.creatorName }}
<template #timestamp>
<div style="color:#999;font-size:13px;margin-bottom:2px;">跟进时间</div>
<span>{{ formatDate(item.createTime) }}</span>
</template>
<div class="el-timeline-right-content">
<div class="followup-meta mb-5px">
<template v-if="item.contacts && item.contacts.length">
<span class="meta-label">联系人</span>
<el-link
v-for="contact in item.contacts"
:key="contact.id"
:underline="false"
type="primary"
@click="openContactDetail(contact.id)"
class="ml-5px"
>
{{ contact.name }}
</el-link>
<span style="margin: 0 8px;"> </span>
</template>
<span class="meta-label">跟进方式</span><dict-tag :type="DICT_TYPE.CRM_FOLLOW_UP_TYPE" :value="item.type" class="mr-10px" />
</div>
<!-- 操作按钮统一放右上角 -->
<div class="followup-action-btns">
<el-button link class="followup-action-btn edit" @click="openForm('update', item.id)">
<Icon icon="ep:edit" class="mr-3px" /> 编辑
</el-button>
<el-button link class="followup-action-btn delete" @click="handleDelete(item.id)">
<Icon icon="ep:delete" class="mr-3px" /> 删除
</el-button>
</div>
<span class="follow-row" v-if="!/<[a-z][\s\S]*>/i.test(item.content)">{{ item.content }}</span>
<div class="follow-row" v-else v-html="'跟进内容:' + item.content"></div>
<!-- 图片直接展示 -->
<div v-if="item.picUrls && item.picUrls.length" class="followup-img-list follow-row mt-10px">
<el-image
v-for="url in item.picUrls"
:key="url"
:src="url"
style="width: 120px; height: 120px; object-fit: contain; border: 1px solid #eee; border-radius: 4px; margin-right: 8px;"
:preview-src-list="item.picUrls"
/>
</div>
<!-- 附件链接展示 -->
<div v-if="item.fileUrls && item.fileUrls.length" class="followup-file-list follow-row mt-5px">
<span style="font-weight: bold;">附件:</span>
<el-link
v-for="url in item.fileUrls"
:key="url"
:href="url"
target="_blank"
type="primary"
style="margin-right: 12px;"
>
{{ url.substring(url.lastIndexOf('/')+1) }}
</el-link>
</div>
</div>
<template #dot>
<span style="background-color: #67C23A;" class="dot-node-style">
{{ item.creatorName ? item.creatorName[0] : '' }}
</span>
</template>
</el-timeline-item>
</el-timeline>
<!-- 分页 -->
<Pagination
v-model:limit="queryParams.pageSize"
v-model:page="queryParams.pageNo"
:total="total"
@pagination="getList"
/>
<!-- 表单弹窗添加/修改 -->
<FollowUpRecordForm ref="formRef" @success="getList" />
<div class="followup-page-container">
<FollowUpList :biz-type="bizType" :biz-id="bizId" />
</div>
</template>
<script lang="ts" setup>
import { formatDate } from '@/utils/formatTime'
import { DICT_TYPE } from '@/utils/dict'
import { FollowUpRecordApi, FollowUpRecordVO } from '@/api/crm/followup'
import FollowUpRecordForm from './FollowUpRecordForm.vue'
import { BizTypeEnum } from '@/api/crm/permission'
<script lang="ts">
import { defineComponent } from 'vue'
import FollowUpList from './components/FollowUpList.vue'
/** 跟进记录列表 */
defineOptions({ name: 'FollowUpRecord' })
const props = defineProps<{
bizType: number
bizId: number
}>()
const message = useMessage() //
const { t } = useI18n() //
const loading = ref(true) //
const list = ref<FollowUpRecordVO[]>([]) //
const total = ref(0) //
const queryParams = reactive({
pageNo: 1,
pageSize: 10,
bizType: 0,
bizId: 0
export default defineComponent({
name: 'CrmFollowUpPage',
components: { FollowUpList },
data() {
return {
bizType: 2,
bizId: undefined as number | undefined
}
}
})
/** 查询列表 */
const getList = async () => {
loading.value = true
try {
const data = await FollowUpRecordApi.getFollowUpRecordPage(queryParams)
list.value = data.list
total.value = data.total
} finally {
loading.value = false
}
}
/** 添加/修改操作 */
const formRef = ref<InstanceType<typeof FollowUpRecordForm>>()
//
const openForm = (type: 'create' | 'update' = 'create', id?: number) => {
if (type === 'update' && id) {
formRef.value?.open(props.bizType, props.bizId, id)
} else {
formRef.value?.open(props.bizType, props.bizId)
}
}
/** 删除按钮操作 */
const handleDelete = async (id: number) => {
try {
//
await message.delConfirm()
//
await FollowUpRecordApi.deleteFollowUpRecord(id)
message.success(t('common.delSuccess'))
//
await getList()
} catch {}
}
/** 打开联系人详情 */
const { push } = useRouter()
const openContactDetail = (id: number) => {
push({ name: 'CrmContactDetail', params: { id } })
}
/** 打开商机详情 */
const openBusinessDetail = (id: number) => {
push({ name: 'CrmBusinessDetail', params: { id } })
}
/** 文件查看弹窗 */
const fileDialogVisible = ref(false)
const fileDialogList = ref<string[]>([])
const fileDialogType = ref<'图片' | '附件'>('图片')
const fileDialogTitle = computed(() => fileDialogType.value === '图片' ? '查看图片' : '查看附件')
function openFileDialog(list: string[], type: '图片' | '附件') {
fileDialogList.value = list
fileDialogType.value = type
fileDialogVisible.value = true
}
watch(
() => props.bizId,
() => {
queryParams.bizType = props.bizType
queryParams.bizId = props.bizId
getList()
}
)
</script>
<style lang="scss" scoped>
// 线 OperateLogV2
:deep(.el-timeline) {
margin: 10px 0 0 30px;
}
:deep(.el-timeline-item__wrapper) {
position: relative;
top: 0;
}
:deep(.el-timeline-item__timestamp) {
position: static !important;
display: block;
margin-bottom: 4px;
color: #999;
font-size: 13px;
left: unset;
top: unset;
text-align: left;
}
:deep(.el-timeline-right-content) {
display: flex;
flex-direction: column;
align-items: flex-start;
min-height: 30px;
padding: 10px;
background-color: #fff;
border-radius: 4px;
margin-bottom: 8px;
position: relative;
}
.followup-img-list {
display: flex;
flex-wrap: wrap;
gap: 8px;
}
.followup-file-list {
margin-top: 5px;
}
.followup-meta {
display: flex;
flex-wrap: wrap;
align-items: center;
margin-bottom: 5px;
}
.follow-row {
margin-bottom: 5px;
color: #333;
font-size: 14px;
}
.dot-node-style {
position: absolute;
left: 0px;
display: flex;
width: 20px;
height: 20px;
font-size: 10px;
color: #fff;
border-radius: 50%;
justify-content: center;
align-items: center;
}
.meta-label {
margin-right: 4px;
font-weight: bold;
}
.followup-delete-btn {
color: #f56c6c !important;
font-weight: bold;
font-size: 14px;
transition: background 0.2s, color 0.2s;
border: none;
background: #fef0f0;
border-radius: 4px;
padding: 2px 10px;
margin: 10px 0 0 0;
&:hover {
background: #fef0f0;
color: #c0392b !important;
}
.icon {
font-size: 15px;
vertical-align: middle;
}
}
.followup-action-btns {
position: absolute;
top: 10px;
right: 16px;
display: flex;
gap: 8px;
z-index: 2;
}
.followup-action-btn {
font-weight: bold;
font-size: 14px;
border: none;
background: transparent;
border-radius: 4px;
padding: 2px 10px;
transition: background 0.2s, color 0.2s;
box-shadow: none;
&.edit {
color: #409eff !important;
&:hover {
color: #337ecc !important;
background: #ecf5ff;
}
}
&.delete {
color: #f56c6c !important;
&:hover {
color: #c0392b !important;
background: #fef0f0;
}
}
.icon {
font-size: 15px;
vertical-align: middle;
}
<style scoped>
.followup-page-container {
padding: 24px;
background: #f5f7fa;
min-height: 100vh;
}
</style>

View File

@ -1,158 +0,0 @@
<template>
<Dialog :title="dialogTitle" v-model="dialogVisible">
<el-form
ref="formRef"
:model="formData"
:rules="formRules"
label-width="100px"
v-loading="formLoading"
>
<el-form-item label="数据类型" prop="bizType">
<el-select v-model="formData.bizType" placeholder="请选择数据类型">
<el-option label="请选择字典生成" value="" />
</el-select>
</el-form-item>
<el-form-item label="数据编号" prop="bizId">
<el-input v-model="formData.bizId" placeholder="请输入数据编号" />
</el-form-item>
<el-form-item label="跟进类型" prop="type">
<el-select v-model="formData.type" placeholder="请选择跟进类型">
<el-option label="请选择字典生成" value="" />
</el-select>
</el-form-item>
<el-form-item label="跟进内容" prop="content">
<Editor v-model="formData.content" height="150px" />
</el-form-item>
<el-form-item label="下次联系时间" prop="nextTime">
<el-date-picker
v-model="formData.nextTime"
type="date"
value-format="x"
placeholder="选择下次联系时间"
/>
</el-form-item>
<el-form-item label="创建者" prop="creator">
<el-input v-model="formData.creator" placeholder="请输入创建者" />
</el-form-item>
<el-form-item label="创建时间" prop="createTime">
<el-date-picker
v-model="formData.createTime"
type="date"
value-format="x"
placeholder="选择创建时间"
/>
</el-form-item>
<el-form-item label="更新者" prop="updater">
<el-input v-model="formData.updater" placeholder="请输入更新者" />
</el-form-item>
<el-form-item label="更新时间" prop="updateTime">
<el-date-picker
v-model="formData.updateTime"
type="date"
value-format="x"
placeholder="选择更新时间"
/>
</el-form-item>
<el-form-item label="租户编号" prop="tenantId">
<el-input v-model="formData.tenantId" placeholder="请输入租户编号" />
</el-form-item>
</el-form>
<template #footer>
<el-button @click="submitForm" type="primary" :disabled="formLoading"> </el-button>
<el-button @click="dialogVisible = false"> </el-button>
</template>
</Dialog>
</template>
<script setup lang="ts">
import { FollowUpRecordApi, FollowUpRecordVO } from '@/api/crm/followup'
/** CRM 跟进记录 表单 */
defineOptions({ name: 'FollowUpRecordForm' })
const { t } = useI18n() //
const message = useMessage() //
const dialogVisible = ref(false) //
const dialogTitle = ref('') //
const formLoading = ref(false) // 12
const formType = ref('') // create - update -
const formData = ref({
id: undefined,
bizType: undefined,
bizId: undefined,
type: undefined,
content: undefined,
nextTime: undefined,
creator: undefined,
createTime: undefined,
updater: undefined,
updateTime: undefined,
tenantId: undefined,
})
const formRules = reactive({
createTime: [{ required: true, message: '创建时间不能为空', trigger: 'blur' }],
updateTime: [{ required: true, message: '更新时间不能为空', trigger: 'blur' }],
tenantId: [{ required: true, message: '租户编号不能为空', trigger: 'blur' }],
})
const formRef = ref() // Ref
/** 打开弹窗 */
const open = async (type: string, id?: number) => {
dialogVisible.value = true
dialogTitle.value = t('action.' + type)
formType.value = type
resetForm()
//
if (id) {
formLoading.value = true
try {
formData.value = await FollowUpRecordApi.getFollowUpRecord(id)
} finally {
formLoading.value = false
}
}
}
defineExpose({ open }) // open
/** 提交表单 */
const emit = defineEmits(['success']) // success
const submitForm = async () => {
//
await formRef.value.validate()
//
formLoading.value = true
try {
const data = formData.value as unknown as FollowUpRecordVO
if (formType.value === 'create') {
await FollowUpRecordApi.createFollowUpRecord(data)
message.success(t('common.createSuccess'))
} else {
await FollowUpRecordApi.updateFollowUpRecord(data)
message.success(t('common.updateSuccess'))
}
dialogVisible.value = false
//
emit('success')
} finally {
formLoading.value = false
}
}
/** 重置表单 */
const resetForm = () => {
formData.value = {
id: undefined,
bizType: undefined,
bizId: undefined,
type: undefined,
content: undefined,
nextTime: undefined,
creator: undefined,
createTime: undefined,
updater: undefined,
updateTime: undefined,
tenantId: undefined,
}
formRef.value?.resetFields()
}
</script>

View File

@ -1,240 +0,0 @@
<template>
<ContentWrap>
<!-- 搜索工作栏 -->
<el-form
class="-mb-15px"
:model="queryParams"
ref="queryFormRef"
:inline="true"
label-width="68px"
>
<el-form-item label="跟进类型" prop="type">
<el-select
v-model="queryParams.type"
placeholder="请选择跟进类型"
clearable
class="!w-240px"
>
<el-option
v-for="dict in getIntDictOptions(DICT_TYPE.CRM_FOLLOW_UP_TYPE)"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
<el-form-item label="下次联系时间" prop="nextTime">
<el-date-picker
v-model="queryParams.nextTime"
value-format="YYYY-MM-DD HH:mm:ss"
type="daterange"
start-placeholder="开始日期"
end-placeholder="结束日期"
:default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
class="!w-220px"
/>
</el-form-item>
<el-form-item label="关联的联系人编号数组" prop="contactIds">
<el-input
v-model="queryParams.contactIds"
placeholder="请输入关联的联系人编号数组"
clearable
@keyup.enter="handleQuery"
class="!w-240px"
/>
</el-form-item>
<el-form-item label="创建者" prop="creator">
<el-input
v-model="queryParams.creator"
placeholder="请输入创建者"
clearable
@keyup.enter="handleQuery"
class="!w-240px"
/>
</el-form-item>
<el-form-item label="创建时间" prop="createTime">
<el-date-picker
v-model="queryParams.createTime"
value-format="YYYY-MM-DD HH:mm:ss"
type="daterange"
start-placeholder="开始日期"
end-placeholder="结束日期"
:default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
class="!w-220px"
/>
</el-form-item>
<el-form-item>
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
<el-button
type="primary"
plain
@click="openForm('create')"
v-hasPermi="['crm:follow-up-record:create']"
>
<Icon icon="ep:plus" class="mr-5px" /> 新增
</el-button>
<el-button
type="success"
plain
@click="handleExport"
:loading="exportLoading"
v-hasPermi="['crm:follow-up-record:export']"
>
<Icon icon="ep:download" class="mr-5px" /> 导出
</el-button>
</el-form-item>
</el-form>
</ContentWrap>
<!-- 列表 -->
<ContentWrap>
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
<el-table-column label="编号" align="center" prop="id" />
<el-table-column label="客户名称" align="center" prop="customer.name" />
<el-table-column label="跟进类型" align="center" prop="type">
<template #default="scope">
<dict-tag :type="DICT_TYPE.CRM_FOLLOW_UP_TYPE" :value="scope.row.type" />
</template>
</el-table-column>
<el-table-column label="跟进内容" align="center" prop="content" />
<el-table-column
label="下次联系时间"
align="center"
prop="nextTime"
:formatter="dateFormatter"
width="180px"
/>
<el-table-column label="创建者" align="center" prop="creator" />
<el-table-column
label="创建时间"
align="center"
prop="createTime"
:formatter="dateFormatter"
width="180px"
/>
<el-table-column label="操作" align="center" min-width="120px">
<template #default="scope">
<el-button
link
type="primary"
@click="openForm('update', scope.row.id)"
v-hasPermi="['crm:follow-up-record:update']"
>
编辑
</el-button>
<el-button
link
type="danger"
@click="handleDelete(scope.row.id)"
v-hasPermi="['crm:follow-up-record:delete']"
>
删除
</el-button>
</template>
</el-table-column>
</el-table>
<!-- 分页 -->
<Pagination
:total="total"
v-model:page="queryParams.pageNo"
v-model:limit="queryParams.pageSize"
@pagination="getList"
/>
</ContentWrap>
<!-- 表单弹窗添加/修改 -->
<FollowUpRecordForm ref="formRef" @success="getList" />
</template>
<script setup lang="ts">
import { getIntDictOptions, DICT_TYPE } from '@/utils/dict'
import { dateFormatter } from '@/utils/formatTime'
import download from '@/utils/download'
import { FollowUpRecordApi, FollowUpRecordVO } from '@/api/crm/followup'
import FollowUpRecordForm from '../followup/FollowUpRecordForm.vue'
/** CRM 跟进记录 列表 */
defineOptions({ name: 'FollowUpRecord' })
const message = useMessage() //
const { t } = useI18n() //
const loading = ref(true) //
const list = ref<FollowUpRecordVO[]>([]) //
const total = ref(0) //
const queryParams = reactive({
pageNo: 1,
pageSize: 10,
type: undefined,
nextTime: [],
contactIds: undefined,
creator: undefined,
createTime: [],
})
const queryFormRef = ref() //
const exportLoading = ref(false) //
/** 查询列表 */
const getList = async () => {
loading.value = true
try {
const data = await FollowUpRecordApi.getFollowUpRecordPage(queryParams)
list.value = data.list
total.value = data.total
} finally {
loading.value = false
}
}
/** 搜索按钮操作 */
const handleQuery = () => {
queryParams.pageNo = 1
getList()
}
/** 重置按钮操作 */
const resetQuery = () => {
queryFormRef.value.resetFields()
handleQuery()
}
/** 添加/修改操作 */
const formRef = ref()
const openForm = (type: string, id?: number) => {
formRef.value.open(type, id)
}
/** 删除按钮操作 */
const handleDelete = async (id: number) => {
try {
//
await message.delConfirm()
//
await FollowUpRecordApi.deleteFollowUpRecord(id)
message.success(t('common.delSuccess'))
//
await getList()
} catch {}
}
/** 导出按钮操作 */
const handleExport = async () => {
try {
//
await message.exportConfirm()
//
exportLoading.value = true
const data = await FollowUpRecordApi.exportFollowUpRecord(queryParams)
download.excel(data, 'CRM 跟进记录.xls')
} catch {
} finally {
exportLoading.value = false
}
}
/** 初始化 **/
onMounted(() => {
getList()
})
</script>