feat(shop): 新增客户跟进记录功能
- 在经销商申请模块中添加客户跟进记录的增删改查接口 - 新增 ShopDealerRecord 数据模型定义 - 更新经销商申请编辑页面,支持客户信息和报备人信息的录入- 添加收益基数字段 rate,用于设置分销比例 - 修改审核状态为跟进状态,包括跟进中、已签约、已取消三种状态 - 增加跟进情况列表展示和编辑功能,支持添加最多10条跟进记录 - 调整页面字段标签和提示文案,使表述更准确 -优化表单验证规则,适配新的业务逻辑 -修复时间格式化问题,统一使用 YYYY-MM-DD HH:mm:ss 格式- 移除旧的审核时间和驳回原因字段,替换为取消原因 - 更新
This commit is contained in:
@@ -10,14 +10,20 @@ export interface ShopDealerApply {
|
|||||||
type?: number;
|
type?: number;
|
||||||
// 用户ID
|
// 用户ID
|
||||||
userId?: number;
|
userId?: number;
|
||||||
|
// 昵称
|
||||||
|
nickName?: string;
|
||||||
// 姓名
|
// 姓名
|
||||||
realName?: string;
|
realName?: string;
|
||||||
// 经销商名称
|
// 经销商名称
|
||||||
dealerName?: string;
|
dealerName?: string;
|
||||||
// 手机号
|
// 手机号
|
||||||
mobile?: string;
|
mobile?: string;
|
||||||
|
// 分销比例
|
||||||
|
rate?: number;
|
||||||
// 推荐人用户ID
|
// 推荐人用户ID
|
||||||
refereeId?: number;
|
refereeId?: number;
|
||||||
|
// 推荐人姓名
|
||||||
|
refereeName?: string;
|
||||||
// 申请方式(10需后台审核 20无需审核)
|
// 申请方式(10需后台审核 20无需审核)
|
||||||
applyType?: number;
|
applyType?: number;
|
||||||
// 申请时间
|
// 申请时间
|
||||||
|
|||||||
106
src/api/shop/shopDealerRecord/index.ts
Normal file
106
src/api/shop/shopDealerRecord/index.ts
Normal file
@@ -0,0 +1,106 @@
|
|||||||
|
import request from '@/utils/request';
|
||||||
|
import type { ApiResult, PageResult } from '@/api';
|
||||||
|
import type { ShopDealerRecord, ShopDealerRecordParam } from './model';
|
||||||
|
import { MODULES_API_URL } from '@/config/setting';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询客户跟进情况
|
||||||
|
*/
|
||||||
|
export async function pageShopDealerRecord(params: ShopDealerRecordParam) {
|
||||||
|
const res = await request.get<ApiResult<PageResult<ShopDealerRecord>>>(
|
||||||
|
MODULES_API_URL + '/shop/shop-dealer-record/page',
|
||||||
|
{
|
||||||
|
params
|
||||||
|
}
|
||||||
|
);
|
||||||
|
if (res.data.code === 0) {
|
||||||
|
return res.data.data;
|
||||||
|
}
|
||||||
|
return Promise.reject(new Error(res.data.message));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询客户跟进情况列表
|
||||||
|
*/
|
||||||
|
export async function listShopDealerRecord(params?: ShopDealerRecordParam) {
|
||||||
|
const res = await request.get<ApiResult<ShopDealerRecord[]>>(
|
||||||
|
MODULES_API_URL + '/shop/shop-dealer-record',
|
||||||
|
{
|
||||||
|
params
|
||||||
|
}
|
||||||
|
);
|
||||||
|
if (res.data.code === 0 && res.data.data) {
|
||||||
|
return res.data.data;
|
||||||
|
}
|
||||||
|
return Promise.reject(new Error(res.data.message));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加客户跟进情况
|
||||||
|
*/
|
||||||
|
export async function addShopDealerRecord(data: ShopDealerRecord) {
|
||||||
|
const res = await request.post<ApiResult<unknown>>(
|
||||||
|
MODULES_API_URL + '/shop/shop-dealer-record',
|
||||||
|
data
|
||||||
|
);
|
||||||
|
if (res.data.code === 0) {
|
||||||
|
return res.data.message;
|
||||||
|
}
|
||||||
|
return Promise.reject(new Error(res.data.message));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改客户跟进情况
|
||||||
|
*/
|
||||||
|
export async function updateShopDealerRecord(data: ShopDealerRecord) {
|
||||||
|
const res = await request.put<ApiResult<unknown>>(
|
||||||
|
MODULES_API_URL + '/shop/shop-dealer-record',
|
||||||
|
data
|
||||||
|
);
|
||||||
|
if (res.data.code === 0) {
|
||||||
|
return res.data.message;
|
||||||
|
}
|
||||||
|
return Promise.reject(new Error(res.data.message));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除客户跟进情况
|
||||||
|
*/
|
||||||
|
export async function removeShopDealerRecord(id?: number) {
|
||||||
|
const res = await request.delete<ApiResult<unknown>>(
|
||||||
|
MODULES_API_URL + '/shop/shop-dealer-record/' + id
|
||||||
|
);
|
||||||
|
if (res.data.code === 0) {
|
||||||
|
return res.data.message;
|
||||||
|
}
|
||||||
|
return Promise.reject(new Error(res.data.message));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除客户跟进情况
|
||||||
|
*/
|
||||||
|
export async function removeBatchShopDealerRecord(data: (number | undefined)[]) {
|
||||||
|
const res = await request.delete<ApiResult<unknown>>(
|
||||||
|
MODULES_API_URL + '/shop/shop-dealer-record/batch',
|
||||||
|
{
|
||||||
|
data
|
||||||
|
}
|
||||||
|
);
|
||||||
|
if (res.data.code === 0) {
|
||||||
|
return res.data.message;
|
||||||
|
}
|
||||||
|
return Promise.reject(new Error(res.data.message));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据id查询客户跟进情况
|
||||||
|
*/
|
||||||
|
export async function getShopDealerRecord(id: number) {
|
||||||
|
const res = await request.get<ApiResult<ShopDealerRecord>>(
|
||||||
|
MODULES_API_URL + '/shop/shop-dealer-record/' + id
|
||||||
|
);
|
||||||
|
if (res.data.code === 0 && res.data.data) {
|
||||||
|
return res.data.data;
|
||||||
|
}
|
||||||
|
return Promise.reject(new Error(res.data.message));
|
||||||
|
}
|
||||||
39
src/api/shop/shopDealerRecord/model/index.ts
Normal file
39
src/api/shop/shopDealerRecord/model/index.ts
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
import type { PageParam } from '@/api';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 客户跟进情况
|
||||||
|
*/
|
||||||
|
export interface ShopDealerRecord {
|
||||||
|
// ID
|
||||||
|
id?: number;
|
||||||
|
// 上级id, 0是顶级
|
||||||
|
parentId?: number;
|
||||||
|
// 客户ID
|
||||||
|
dealerId?: number;
|
||||||
|
// 内容
|
||||||
|
content?: string;
|
||||||
|
// 用户ID
|
||||||
|
userId?: number;
|
||||||
|
// 排序(数字越小越靠前)
|
||||||
|
sortNumber?: number;
|
||||||
|
// 备注
|
||||||
|
comments?: string;
|
||||||
|
// 状态, 0待处理, 1已完成
|
||||||
|
status?: number;
|
||||||
|
// 是否删除, 0否, 1是
|
||||||
|
deleted?: number;
|
||||||
|
// 租户id
|
||||||
|
tenantId?: number;
|
||||||
|
// 创建时间
|
||||||
|
createTime?: string;
|
||||||
|
// 修改时间
|
||||||
|
updateTime?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 客户跟进情况搜索条件
|
||||||
|
*/
|
||||||
|
export interface ShopDealerRecordParam extends PageParam {
|
||||||
|
id?: number;
|
||||||
|
keywords?: string;
|
||||||
|
}
|
||||||
@@ -17,10 +17,10 @@
|
|||||||
/>
|
/>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
|
|
||||||
<a-form-item label="手机号码">
|
<a-form-item label="联系电话">
|
||||||
<a-input
|
<a-input
|
||||||
v-model:value="searchForm.mobile"
|
v-model:value="searchForm.mobile"
|
||||||
placeholder="请输入手机号码"
|
placeholder="客户联系电话"
|
||||||
allow-clear
|
allow-clear
|
||||||
style="width: 160px"
|
style="width: 160px"
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
:visible="visible"
|
:visible="visible"
|
||||||
:maskClosable="false"
|
:maskClosable="false"
|
||||||
:maxable="maxable"
|
:maxable="maxable"
|
||||||
:title="isUpdate ? '编辑分销商申请' : '新增分销商申请'"
|
:title="isUpdate ? '编辑客户' : '新增客户'"
|
||||||
:body-style="{ paddingBottom: '28px' }"
|
:body-style="{ paddingBottom: '28px' }"
|
||||||
@update:visible="updateVisible"
|
@update:visible="updateVisible"
|
||||||
@ok="save"
|
@ok="save"
|
||||||
@@ -17,17 +17,65 @@
|
|||||||
:label-col="{ span: 6 }"
|
:label-col="{ span: 6 }"
|
||||||
:wrapper-col="{ span: 18 }"
|
:wrapper-col="{ span: 18 }"
|
||||||
>
|
>
|
||||||
<!-- 申请人信息 -->
|
|
||||||
|
<!-- 客户信息 -->
|
||||||
<a-divider orientation="left">
|
<a-divider orientation="left">
|
||||||
<span style="color: #1890ff; font-weight: 600;">申请人信息</span>
|
<span style="color: #1890ff; font-weight: 600;">客户信息</span>
|
||||||
</a-divider>
|
</a-divider>
|
||||||
|
|
||||||
<a-row :gutter="16">
|
<a-row :gutter="16">
|
||||||
<a-col :span="12">
|
<a-col :span="12">
|
||||||
<a-form-item label="用户ID" name="userId">
|
<a-form-item label="客户名称" name="dealerName">
|
||||||
|
<a-input
|
||||||
|
placeholder="请输入客户名称"
|
||||||
|
v-model:value="form.dealerName"
|
||||||
|
:disabled="form.applyStatus == 20"
|
||||||
|
/>
|
||||||
|
</a-form-item>
|
||||||
|
</a-col>
|
||||||
|
<a-col :span="12">
|
||||||
|
<a-form-item label="联系人" name="realName">
|
||||||
|
<a-input
|
||||||
|
placeholder="请输入联系人"
|
||||||
|
v-model:value="form.realName"
|
||||||
|
:disabled="form.applyStatus == 20"
|
||||||
|
/>
|
||||||
|
</a-form-item>
|
||||||
|
</a-col>
|
||||||
|
<a-col :span="12">
|
||||||
|
<a-form-item label="手机号码" name="mobile">
|
||||||
|
<a-input
|
||||||
|
placeholder="请输入手机号码"
|
||||||
|
:disabled="form.applyStatus == 20"
|
||||||
|
v-model:value="form.mobile"
|
||||||
|
/>
|
||||||
|
</a-form-item>
|
||||||
|
</a-col>
|
||||||
|
<a-col :span="12">
|
||||||
|
<a-form-item label="收益基数" name="rate">
|
||||||
|
<a-input-number
|
||||||
|
placeholder="0.007"
|
||||||
|
:min="0"
|
||||||
|
:max="1"
|
||||||
|
step="0.01"
|
||||||
|
:disabled="!hasRole('superAdmin')"
|
||||||
|
v-model:value="form.rate"
|
||||||
|
/>
|
||||||
|
</a-form-item>
|
||||||
|
</a-col>
|
||||||
|
</a-row>
|
||||||
|
|
||||||
|
<!-- 报备人信息 -->
|
||||||
|
<a-divider orientation="left">
|
||||||
|
<span style="color: #1890ff; font-weight: 600;">报备人信息</span>
|
||||||
|
</a-divider>
|
||||||
|
|
||||||
|
<a-row :gutter="16">
|
||||||
|
<a-col :span="12">
|
||||||
|
<a-form-item label="报备人ID" name="userId">
|
||||||
<a-input-number
|
<a-input-number
|
||||||
:min="1"
|
:min="1"
|
||||||
placeholder="请输入用户ID"
|
placeholder="请输入报备人ID"
|
||||||
:disabled="isUpdate"
|
:disabled="isUpdate"
|
||||||
v-model:value="form.userId"
|
v-model:value="form.userId"
|
||||||
style="width: 100%"
|
style="width: 100%"
|
||||||
@@ -35,23 +83,13 @@
|
|||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-col>
|
</a-col>
|
||||||
<a-col :span="12">
|
<a-col :span="12">
|
||||||
<a-form-item label="真实姓名" name="realName">
|
<a-form-item label="报备人" name="nickName">
|
||||||
<a-input
|
<a-input-number
|
||||||
placeholder="请输入真实姓名"
|
:min="1"
|
||||||
v-model:value="form.realName"
|
placeholder="请输入报备人名称"
|
||||||
:disabled="isUpdate"
|
:disabled="isUpdate"
|
||||||
/>
|
v-model:value="form.nickName"
|
||||||
</a-form-item>
|
style="width: 100%"
|
||||||
</a-col>
|
|
||||||
</a-row>
|
|
||||||
|
|
||||||
<a-row :gutter="16">
|
|
||||||
<a-col :span="12">
|
|
||||||
<a-form-item label="手机号码" name="mobile">
|
|
||||||
<a-input
|
|
||||||
placeholder="请输入手机号码"
|
|
||||||
:disabled="isUpdate"
|
|
||||||
v-model:value="form.mobile"
|
|
||||||
/>
|
/>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-col>
|
</a-col>
|
||||||
@@ -66,11 +104,22 @@
|
|||||||
/>
|
/>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-col>
|
</a-col>
|
||||||
|
<a-col :span="12">
|
||||||
|
<a-form-item label="推荐人名称" name="refereeName">
|
||||||
|
<a-input-number
|
||||||
|
:min="1"
|
||||||
|
placeholder="请输入推荐人名称"
|
||||||
|
:disabled="isUpdate"
|
||||||
|
v-model:value="form.refereeName"
|
||||||
|
style="width: 100%"
|
||||||
|
/>
|
||||||
|
</a-form-item>
|
||||||
|
</a-col>
|
||||||
</a-row>
|
</a-row>
|
||||||
|
|
||||||
<!-- 审核信息 -->
|
<!-- 审核信息 -->
|
||||||
<a-divider orientation="left">
|
<a-divider orientation="left">
|
||||||
<span style="color: #1890ff; font-weight: 600;">审核信息</span>
|
<span style="color: #1890ff; font-weight: 600;">审核状态</span>
|
||||||
</a-divider>
|
</a-divider>
|
||||||
|
|
||||||
<a-row :gutter="16">
|
<a-row :gutter="16">
|
||||||
@@ -78,39 +127,25 @@
|
|||||||
<a-form-item label="审核状态" name="applyStatus">
|
<a-form-item label="审核状态" name="applyStatus">
|
||||||
<a-select v-model:value="form.applyStatus" placeholder="请选择审核状态" @change="handleStatusChange">
|
<a-select v-model:value="form.applyStatus" placeholder="请选择审核状态" @change="handleStatusChange">
|
||||||
<a-select-option :value="10">
|
<a-select-option :value="10">
|
||||||
<a-tag color="processing">待审核</a-tag>
|
<a-tag color="orange">跟进中</a-tag>
|
||||||
<span style="margin-left: 8px;">等待审核</span>
|
<span style="margin-left: 8px;">正在跟进中</span>
|
||||||
</a-select-option>
|
</a-select-option>
|
||||||
<a-select-option :value="20">
|
<a-select-option :value="20">
|
||||||
<a-tag color="success">审核通过</a-tag>
|
<a-tag color="success">已签约</a-tag>
|
||||||
<span style="margin-left: 8px;">申请通过</span>
|
<span style="margin-left: 8px;">客户已签约</span>
|
||||||
</a-select-option>
|
</a-select-option>
|
||||||
<a-select-option :value="30">
|
<a-select-option :value="30">
|
||||||
<a-tag color="error">审核驳回</a-tag>
|
<a-tag color="error">已取消</a-tag>
|
||||||
<span style="margin-left: 8px;">申请驳回</span>
|
<span style="margin-left: 8px;">客户已取消</span>
|
||||||
</a-select-option>
|
</a-select-option>
|
||||||
</a-select>
|
</a-select>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-col>
|
</a-col>
|
||||||
<!-- <a-col :span="12">-->
|
<a-col :span="12" v-if="form.applyStatus === 30">
|
||||||
<!-- <a-form-item label="审核时间" name="auditTime" v-if="form.applyStatus === 20 || form.applyStatus === 30">-->
|
<a-form-item label="取消原因" name="rejectReason">
|
||||||
<!-- <a-date-picker-->
|
|
||||||
<!-- v-model:value="form.auditTime"-->
|
|
||||||
<!-- show-time-->
|
|
||||||
<!-- format="YYYY-MM-DD HH:mm:ss"-->
|
|
||||||
<!-- placeholder="请选择审核时间"-->
|
|
||||||
<!-- style="width: 100%"-->
|
|
||||||
<!-- />-->
|
|
||||||
<!-- </a-form-item>-->
|
|
||||||
<!-- </a-col>-->
|
|
||||||
</a-row>
|
|
||||||
|
|
||||||
<a-row :gutter="16" v-if="form.applyStatus === 30">
|
|
||||||
<a-col :span="24">
|
|
||||||
<a-form-item label="驳回原因" name="rejectReason">
|
|
||||||
<a-textarea
|
<a-textarea
|
||||||
v-model:value="form.rejectReason"
|
v-model:value="form.rejectReason"
|
||||||
placeholder="请输入驳回原因"
|
placeholder="请输入取消原因"
|
||||||
style="width: 100%"
|
style="width: 100%"
|
||||||
:rows="3"
|
:rows="3"
|
||||||
:maxlength="200"
|
:maxlength="200"
|
||||||
@@ -119,57 +154,123 @@
|
|||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-col>
|
</a-col>
|
||||||
</a-row>
|
</a-row>
|
||||||
|
|
||||||
|
<!-- 跟进情况 -->
|
||||||
|
<a-divider orientation="left" v-if="form.applyStatus == 10">
|
||||||
|
<span style="color: #1890ff; font-weight: 600;">跟进情况</span>
|
||||||
|
</a-divider>
|
||||||
|
|
||||||
|
<!-- 跟进情况列表 -->
|
||||||
|
<div v-if="form.applyStatus == 10">
|
||||||
|
<a-row :gutter="16" style="margin-bottom: 16px;">
|
||||||
|
<a-col :span="24">
|
||||||
|
<a-button
|
||||||
|
type="primary"
|
||||||
|
@click="addFollowUp"
|
||||||
|
:disabled="followUpList.length >= 10"
|
||||||
|
size="small"
|
||||||
|
>
|
||||||
|
新增
|
||||||
|
</a-button>
|
||||||
|
<span style="margin-left: 12px; color: #999; font-size: 12px;">
|
||||||
|
最多可添加10条跟进信息,当前已添加{{ followUpList.length }}条
|
||||||
|
</span>
|
||||||
|
</a-col>
|
||||||
|
</a-row>
|
||||||
|
|
||||||
|
<div v-for="(item, index) in followUpList" :key="index"
|
||||||
|
style="margin-bottom: 16px; border: 1px solid #f0f0f0; padding: 12px; border-radius: 4px;">
|
||||||
|
<a-row :gutter="16">
|
||||||
|
<a-col :span="20">
|
||||||
|
<a-form-item
|
||||||
|
:label="`跟进内容${index + 1}`"
|
||||||
|
:name="['followUpList', index, 'content']"
|
||||||
|
>
|
||||||
|
<div v-if="item.status == 1" v-html="item.content"></div>
|
||||||
|
<a-textarea
|
||||||
|
v-else
|
||||||
|
v-model:value="item.content"
|
||||||
|
:disabled="!isUpdate"
|
||||||
|
placeholder="请输入跟进内容"
|
||||||
|
:rows="2"
|
||||||
|
:maxlength="500"
|
||||||
|
show-count
|
||||||
|
/>
|
||||||
|
</a-form-item>
|
||||||
|
</a-col>
|
||||||
|
<a-col :span="4" style="text-align: right;">
|
||||||
|
<a-button
|
||||||
|
type="link"
|
||||||
|
danger
|
||||||
|
@click="removeFollowUp(index)"
|
||||||
|
:disabled="followUpList.length <= 1"
|
||||||
|
>
|
||||||
|
删除
|
||||||
|
</a-button>
|
||||||
|
</a-col>
|
||||||
|
</a-row>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
</a-form>
|
</a-form>
|
||||||
</ele-modal>
|
</ele-modal>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { ref, reactive, watch } from 'vue';
|
import {ref, reactive, watch} from 'vue';
|
||||||
import { Form, message } from 'ant-design-vue';
|
import {Form, message} from 'ant-design-vue';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
import { assignObject, uuid } from 'ele-admin-pro';
|
import {assignObject} from 'ele-admin-pro';
|
||||||
import { addShopDealerApply, updateShopDealerApply } from '@/api/shop/shopDealerApply';
|
import {addShopDealerApply, updateShopDealerApply} from '@/api/shop/shopDealerApply';
|
||||||
import { ShopDealerApply } from '@/api/shop/shopDealerApply/model';
|
import {listShopDealerRecord, addShopDealerRecord} from '@/api/shop/shopDealerRecord';
|
||||||
import { useThemeStore } from '@/store/modules/theme';
|
import {ShopDealerApply} from '@/api/shop/shopDealerApply/model';
|
||||||
import { storeToRefs } from 'pinia';
|
import {ShopDealerRecord} from '@/api/shop/shopDealerRecord/model';
|
||||||
import { ItemType } from 'ele-admin-pro/es/ele-image-upload/types';
|
import {FormInstance, RuleObject} from 'ant-design-vue/es/form';
|
||||||
import { FormInstance } from 'ant-design-vue/es/form';
|
import {hasRole} from "@/utils/permission";
|
||||||
import { FileRecord } from '@/api/system/file/model';
|
|
||||||
|
|
||||||
// 是否是修改
|
// 是否是修改
|
||||||
const isUpdate = ref(false);
|
const isUpdate = ref(false);
|
||||||
const useForm = Form.useForm;
|
const useForm = Form.useForm;
|
||||||
// 是否开启响应式布局
|
|
||||||
const themeStore = useThemeStore();
|
|
||||||
const { styleResponsive } = storeToRefs(themeStore);
|
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
// 弹窗是否打开
|
// 弹窗是否打开
|
||||||
visible: boolean;
|
visible: boolean;
|
||||||
// 修改回显的数据
|
// 修改回显的数据
|
||||||
data?: ShopDealerApply | null;
|
data?: ShopDealerApply | null;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
(e: 'done'): void;
|
(e: 'done'): void;
|
||||||
(e: 'update:visible', visible: boolean): void;
|
(e: 'update:visible', visible: boolean): void;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
// 提交状态
|
// 提交状态
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
// 是否显示最大化切换按钮
|
// 是否显示最大化切换按钮
|
||||||
const maxable = ref(true);
|
const maxable = ref(true);
|
||||||
// 表格选中数据
|
// 表格选中数据
|
||||||
const formRef = ref<FormInstance | null>(null);
|
const formRef = ref<FormInstance | null>(null);
|
||||||
const images = ref<ItemType[]>([]);
|
|
||||||
|
|
||||||
// 表单数据
|
// 跟进情况列表
|
||||||
const form = reactive<ShopDealerApply>({
|
const followUpList = ref<ShopDealerRecord[]>([
|
||||||
|
{
|
||||||
|
content: '',
|
||||||
|
status: 0,
|
||||||
|
sortNumber: 0
|
||||||
|
}
|
||||||
|
]);
|
||||||
|
|
||||||
|
// 表单数据
|
||||||
|
const form = reactive<ShopDealerApply>({
|
||||||
applyId: undefined,
|
applyId: undefined,
|
||||||
userId: undefined,
|
userId: undefined,
|
||||||
|
nickName: undefined,
|
||||||
realName: '',
|
realName: '',
|
||||||
mobile: '',
|
mobile: '',
|
||||||
|
dealerName: '',
|
||||||
|
rate: 0.007,
|
||||||
refereeId: undefined,
|
refereeId: undefined,
|
||||||
|
refereeName: undefined,
|
||||||
applyType: 10,
|
applyType: 10,
|
||||||
applyTime: undefined,
|
applyTime: undefined,
|
||||||
applyStatus: 10,
|
applyStatus: 10,
|
||||||
@@ -178,96 +279,192 @@
|
|||||||
tenantId: undefined,
|
tenantId: undefined,
|
||||||
createTime: undefined,
|
createTime: undefined,
|
||||||
updateTime: undefined
|
updateTime: undefined
|
||||||
});
|
});
|
||||||
|
|
||||||
/* 更新visible */
|
/* 更新visible */
|
||||||
const updateVisible = (value: boolean) => {
|
const updateVisible = (value: boolean) => {
|
||||||
emit('update:visible', value);
|
emit('update:visible', value);
|
||||||
};
|
};
|
||||||
|
|
||||||
// 表单验证规则
|
// 表单验证规则
|
||||||
const rules = reactive({
|
const rules = reactive({
|
||||||
userId: [
|
userId: [
|
||||||
{
|
{
|
||||||
required: true,
|
required: true,
|
||||||
message: '请输入用户ID',
|
message: '请输入用户ID',
|
||||||
trigger: 'blur'
|
trigger: 'blur'
|
||||||
}
|
} as RuleObject
|
||||||
],
|
],
|
||||||
realName: [
|
realName: [
|
||||||
{
|
{
|
||||||
required: true,
|
required: true,
|
||||||
message: '请输入真实姓名',
|
message: '请输入客户名称',
|
||||||
trigger: 'blur'
|
trigger: 'blur'
|
||||||
},
|
} as RuleObject,
|
||||||
{
|
{
|
||||||
min: 2,
|
min: 2,
|
||||||
max: 20,
|
max: 20,
|
||||||
message: '姓名长度应在2-20个字符之间',
|
message: '姓名长度应在2-20个字符之间',
|
||||||
trigger: 'blur'
|
trigger: 'blur'
|
||||||
}
|
} as RuleObject
|
||||||
|
],
|
||||||
|
rate: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入收益基数',
|
||||||
|
trigger: 'blur'
|
||||||
|
} as RuleObject
|
||||||
],
|
],
|
||||||
mobile: [
|
mobile: [
|
||||||
{
|
{
|
||||||
required: true,
|
required: true,
|
||||||
message: '请输入手机号码',
|
message: '请输入手机号码',
|
||||||
trigger: 'blur'
|
trigger: 'blur'
|
||||||
},
|
} as RuleObject,
|
||||||
{
|
{
|
||||||
pattern: /^1[3-9]\d{9}$/,
|
pattern: /^1[3-9]\d{9}$/,
|
||||||
message: '请输入正确的手机号码',
|
message: '请输入正确的手机号码',
|
||||||
trigger: 'blur'
|
trigger: 'blur'
|
||||||
}
|
} as RuleObject
|
||||||
],
|
],
|
||||||
applyType: [
|
applyType: [
|
||||||
{
|
{
|
||||||
required: true,
|
required: true,
|
||||||
message: '请选择申请方式',
|
message: '请选择申请方式',
|
||||||
trigger: 'change'
|
trigger: 'change'
|
||||||
}
|
} as RuleObject
|
||||||
],
|
],
|
||||||
applyStatus: [
|
applyStatus: [
|
||||||
{
|
{
|
||||||
required: true,
|
required: true,
|
||||||
message: '请选择审核状态',
|
message: '请选择审核状态',
|
||||||
trigger: 'change'
|
trigger: 'change'
|
||||||
}
|
} as RuleObject
|
||||||
],
|
],
|
||||||
rejectReason: [
|
rejectReason: [
|
||||||
{
|
{
|
||||||
required: true,
|
required: true,
|
||||||
message: '驳回时必须填写驳回原因',
|
message: '驳回时必须填写驳回原因',
|
||||||
trigger: 'blur'
|
trigger: 'blur'
|
||||||
}
|
} as RuleObject
|
||||||
],
|
],
|
||||||
auditTime: [
|
auditTime: [
|
||||||
{
|
{
|
||||||
required: true,
|
required: true,
|
||||||
message: '审核时请选择审核时间',
|
message: '审核时请选择审核时间',
|
||||||
trigger: 'change'
|
trigger: 'change'
|
||||||
}
|
} as RuleObject
|
||||||
]
|
]
|
||||||
|
});
|
||||||
|
|
||||||
|
/* 添加跟进 */
|
||||||
|
const addFollowUp = () => {
|
||||||
|
if (followUpList.value.length >= 10) {
|
||||||
|
message.warning('最多只能添加10条跟进信息');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
followUpList.value.push({
|
||||||
|
content: '',
|
||||||
|
status: 0,
|
||||||
|
sortNumber: followUpList.value.length
|
||||||
});
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/* 删除跟进 */
|
||||||
|
const removeFollowUp = (index: number) => {
|
||||||
|
if (followUpList.value.length <= 1) {
|
||||||
|
message.warning('至少保留一条跟进信息');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
followUpList.value.splice(index, 1);
|
||||||
|
};
|
||||||
|
|
||||||
const { resetFields } = useForm(form, rules);
|
/* 获取跟进记录 */
|
||||||
|
const fetchFollowUpRecords = async (dealerId: number) => {
|
||||||
|
try {
|
||||||
|
// 先通过list接口获取所有记录,然后过滤
|
||||||
|
const allRecords = await listShopDealerRecord({});
|
||||||
|
const records = allRecords.filter(record => record.dealerId === dealerId);
|
||||||
|
|
||||||
/* 处理审核状态变化 */
|
if (records && records.length > 0) {
|
||||||
const handleStatusChange = (value: number) => {
|
followUpList.value = records.map(record => ({
|
||||||
|
...record,
|
||||||
|
status: record.status || 0,
|
||||||
|
sortNumber: record.sortNumber || 0
|
||||||
|
}));
|
||||||
|
} else {
|
||||||
|
// 如果没有记录,初始化一条空记录
|
||||||
|
followUpList.value = [
|
||||||
|
{
|
||||||
|
content: '',
|
||||||
|
status: 0,
|
||||||
|
sortNumber: 0
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('获取跟进记录失败:', error);
|
||||||
|
message.error('获取跟进记录失败');
|
||||||
|
// 初始化一条空记录
|
||||||
|
followUpList.value = [
|
||||||
|
{
|
||||||
|
content: '',
|
||||||
|
status: 0,
|
||||||
|
sortNumber: 0
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/* 保存跟进记录 */
|
||||||
|
const saveFollowUpRecords = async (dealerId: number) => {
|
||||||
|
try {
|
||||||
|
// 保存每条跟进记录
|
||||||
|
for (const record of followUpList.value) {
|
||||||
|
const recordData: any = {
|
||||||
|
...record,
|
||||||
|
dealerId: dealerId,
|
||||||
|
userId: form.userId,
|
||||||
|
status: 1
|
||||||
|
};
|
||||||
|
|
||||||
|
// 如果有ID则更新,否则新增
|
||||||
|
if (record.id) {
|
||||||
|
// 更新逻辑(如果API支持)
|
||||||
|
await addShopDealerRecord(recordData);
|
||||||
|
} else {
|
||||||
|
// 新增逻辑
|
||||||
|
await addShopDealerRecord(recordData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// message.success('跟进记录保存成功');
|
||||||
|
} catch (error) {
|
||||||
|
console.error('保存跟进记录失败:', error);
|
||||||
|
message.error('保存跟进记录失败');
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const {resetFields} = useForm(form, rules);
|
||||||
|
|
||||||
|
/* 处理审核状态变化 */
|
||||||
|
const handleStatusChange = (value: number) => {
|
||||||
// 当状态改为审核通过或驳回时,自动设置审核时间为当前时间
|
// 当状态改为审核通过或驳回时,自动设置审核时间为当前时间
|
||||||
if ((value === 20 || value === 30) && !form.auditTime) {
|
if ((value === 20 || value === 30) && !form.auditTime) {
|
||||||
form.auditTime = dayjs();
|
form.auditTime = dayjs().format('YYYY-MM-DD HH:mm:ss');
|
||||||
}
|
}
|
||||||
// 当状态改为待审核时,清空审核时间和驳回原因
|
// 当状态改为待审核时,清空审核时间和驳回原因
|
||||||
if (value === 10) {
|
if (value === 10) {
|
||||||
form.auditTime = undefined;
|
form.auditTime = undefined;
|
||||||
form.rejectReason = '';
|
form.rejectReason = '';
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/* 保存编辑 */
|
/* 保存编辑 */
|
||||||
const save = () => {
|
const save = () => {
|
||||||
if (!formRef.value) {
|
if (!formRef.value) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -285,9 +482,19 @@
|
|||||||
validateFields.push('auditTime');
|
validateFields.push('auditTime');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 如果是跟进中状态,需要验证跟进内容
|
||||||
|
if (form.applyStatus === 10) {
|
||||||
|
// 构造跟进内容的验证字段
|
||||||
|
const followUpFields: string[] = [];
|
||||||
|
followUpList.value.forEach((_, index) => {
|
||||||
|
followUpFields.push(`followUpList.${index}.content`);
|
||||||
|
});
|
||||||
|
validateFields.push(...followUpFields);
|
||||||
|
}
|
||||||
|
|
||||||
formRef.value
|
formRef.value
|
||||||
.validate(validateFields)
|
.validate(validateFields)
|
||||||
.then(() => {
|
.then(async () => {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
const formData = {
|
const formData = {
|
||||||
...form
|
...form
|
||||||
@@ -321,35 +528,40 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
const saveOrUpdate = isUpdate.value ? updateShopDealerApply : addShopDealerApply;
|
const saveOrUpdate = isUpdate.value ? updateShopDealerApply : addShopDealerApply;
|
||||||
saveOrUpdate(formData)
|
try {
|
||||||
.then((msg) => {
|
const msg = await saveOrUpdate(formData);
|
||||||
loading.value = false;
|
|
||||||
message.success(msg);
|
message.success(msg);
|
||||||
|
|
||||||
|
// 如果是跟进中状态,保存跟进记录
|
||||||
|
if (formData.applyStatus === 10 && formData.applyId) {
|
||||||
|
await saveFollowUpRecords(formData.applyId);
|
||||||
|
}
|
||||||
|
|
||||||
updateVisible(false);
|
updateVisible(false);
|
||||||
emit('done');
|
emit('done');
|
||||||
})
|
} catch (e: any) {
|
||||||
.catch((e) => {
|
|
||||||
loading.value = false;
|
|
||||||
message.error(e.message);
|
message.error(e.message);
|
||||||
});
|
} finally {
|
||||||
|
loading.value = false;
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.catch(() => {});
|
.catch(() => {
|
||||||
};
|
loading.value = false;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => props.visible,
|
() => props.visible,
|
||||||
(visible) => {
|
async (visible) => {
|
||||||
if (visible) {
|
if (visible) {
|
||||||
if (props.data) {
|
if (props.data) {
|
||||||
assignObject(form, props.data);
|
assignObject(form, props.data);
|
||||||
// 处理时间字段 - 确保转换为dayjs对象
|
|
||||||
if (props.data.applyTime) {
|
|
||||||
form.applyTime = dayjs(props.data.applyTime);
|
|
||||||
}
|
|
||||||
if (props.data.auditTime) {
|
|
||||||
form.auditTime = dayjs(props.data.auditTime);
|
|
||||||
}
|
|
||||||
isUpdate.value = true;
|
isUpdate.value = true;
|
||||||
|
|
||||||
|
// 如果是修改且状态为跟进中,获取跟进记录
|
||||||
|
if (props.data.applyId && props.data.applyStatus === 10) {
|
||||||
|
await fetchFollowUpRecords(props.data.applyId);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// 重置为默认值
|
// 重置为默认值
|
||||||
Object.assign(form, {
|
Object.assign(form, {
|
||||||
@@ -359,7 +571,7 @@
|
|||||||
mobile: '',
|
mobile: '',
|
||||||
refereeId: undefined,
|
refereeId: undefined,
|
||||||
applyType: 10,
|
applyType: 10,
|
||||||
applyTime: dayjs(),
|
applyTime: dayjs().format('YYYY-MM-DD HH:mm:ss'),
|
||||||
applyStatus: 10,
|
applyStatus: 10,
|
||||||
auditTime: undefined,
|
auditTime: undefined,
|
||||||
rejectReason: '',
|
rejectReason: '',
|
||||||
@@ -368,13 +580,22 @@
|
|||||||
updateTime: undefined
|
updateTime: undefined
|
||||||
});
|
});
|
||||||
isUpdate.value = false;
|
isUpdate.value = false;
|
||||||
|
|
||||||
|
// 重置跟进列表
|
||||||
|
followUpList.value = [
|
||||||
|
{
|
||||||
|
content: '',
|
||||||
|
status: 0,
|
||||||
|
sortNumber: 0
|
||||||
|
}
|
||||||
|
];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
resetFields();
|
resetFields();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ immediate: true }
|
{immediate: true}
|
||||||
);
|
);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="less" scoped>
|
<style lang="less" scoped>
|
||||||
|
|||||||
@@ -28,10 +28,17 @@
|
|||||||
<template v-if="column.key === 'customer'">
|
<template v-if="column.key === 'customer'">
|
||||||
<div class="flex flex-col">
|
<div class="flex flex-col">
|
||||||
<span class="font-medium">{{ record.dealerName }}</span>
|
<span class="font-medium">{{ record.dealerName }}</span>
|
||||||
<span>联系人:{{ record.realName }}</span>
|
<span class="text-gray-400">联系人:{{ record.realName }}</span>
|
||||||
<span>联系电话:{{ record.mobile }}</span>
|
<span class="text-gray-400">联系电话:{{ record.mobile }}</span>
|
||||||
|
<span class="text-gray-400">户号:{{ record.dealerCode }}</span>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
<template v-if="column.key === 'applicantInfo'">
|
||||||
|
<div class="text-gray-600">{{ record.nickName }}</div>
|
||||||
|
<div class="text-gray-400">{{ record.phone }}</div>
|
||||||
|
<div class="text-gray-400">{{ record.rate }}</div>
|
||||||
|
|
||||||
|
</template>
|
||||||
<template v-if="column.key === 'createTime'">
|
<template v-if="column.key === 'createTime'">
|
||||||
<div class="flex flex-col">
|
<div class="flex flex-col">
|
||||||
<span>{{ record.createTime }}</span>
|
<span>{{ record.createTime }}</span>
|
||||||
@@ -149,15 +156,7 @@ const columns = ref<ColumnItem[]>([
|
|||||||
{
|
{
|
||||||
title: '客户名称',
|
title: '客户名称',
|
||||||
dataIndex: 'customer',
|
dataIndex: 'customer',
|
||||||
key: 'customer',
|
key: 'customer'
|
||||||
customRender: ({text}) => {
|
|
||||||
const typeMap = {
|
|
||||||
10: {text: '需审核', color: 'orange'},
|
|
||||||
20: {text: '免审核', color: 'green'}
|
|
||||||
};
|
|
||||||
const type = typeMap[text] || {text: '未知', color: 'default'};
|
|
||||||
return {type: 'tag', props: {color: type.color}, children: type.text};
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '跟进情况',
|
title: '跟进情况',
|
||||||
@@ -165,17 +164,15 @@ const columns = ref<ColumnItem[]>([
|
|||||||
key: 'comments',
|
key: 'comments',
|
||||||
align: 'left'
|
align: 'left'
|
||||||
},
|
},
|
||||||
{
|
// {
|
||||||
title: '收益基数',
|
// title: '收益基数',
|
||||||
dataIndex: 'rate',
|
// dataIndex: 'rate',
|
||||||
key: 'rate',
|
// key: 'rate',
|
||||||
align: 'left',
|
// align: 'left'
|
||||||
customRender: () => {
|
// },
|
||||||
return `0.007`;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
title: '报备人信息',
|
title: '报备人信息',
|
||||||
|
dataIndex: 'applicantInfo',
|
||||||
key: 'applicantInfo',
|
key: 'applicantInfo',
|
||||||
align: 'left',
|
align: 'left',
|
||||||
fixed: 'left',
|
fixed: 'left',
|
||||||
|
|||||||
Reference in New Issue
Block a user