feat(customer): support birthdate followup reminder
This commit is contained in:
@@ -0,0 +1,56 @@
|
|||||||
|
import { axios } from "timi-web-api";
|
||||||
|
|
||||||
|
/** 门店配置项。 */
|
||||||
|
export type StoreSetting = {
|
||||||
|
bizType?: string;
|
||||||
|
bizId?: string;
|
||||||
|
code?: string;
|
||||||
|
description?: string;
|
||||||
|
value?: string;
|
||||||
|
valueType?: string;
|
||||||
|
valueArgs?: unknown;
|
||||||
|
};
|
||||||
|
|
||||||
|
/** 门店配置保存项。 */
|
||||||
|
export type StoreSettingPayload = {
|
||||||
|
code: string;
|
||||||
|
value: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
const BASE_URI = "/gao/store/setting";
|
||||||
|
|
||||||
|
/** 客户生日提醒开关。 */
|
||||||
|
export const BIRTHDAY_REMINDER_ENABLED = "CUSTOMER_BIRTHDAY_REMINDER_ENABLED";
|
||||||
|
|
||||||
|
/** 客户生日提醒负责人。 */
|
||||||
|
export const BIRTHDAY_REMINDER_RESPONSIBLE_USER_ID = "CUSTOMER_BIRTHDAY_REMINDER_RESPONSIBLE_USER_ID";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 门店配置接口
|
||||||
|
*
|
||||||
|
* 门店由后端按登录用户所属门店决定,前端不传 storeId
|
||||||
|
*/
|
||||||
|
const StoreSettingAPI = {
|
||||||
|
/**
|
||||||
|
* 查询当前门店配置
|
||||||
|
*
|
||||||
|
* @param codeList 配置代码列表,为空返回全部
|
||||||
|
* @returns 配置代码与配置的映射
|
||||||
|
*/
|
||||||
|
async map(codeList?: string[]): Promise<Record<string, StoreSetting>> {
|
||||||
|
return await axios.post(`${BASE_URI}/map`, codeList ?? []);
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存当前门店配置
|
||||||
|
*
|
||||||
|
* 合并写入,未提交的配置项保留
|
||||||
|
*
|
||||||
|
* @param settingList 配置列表
|
||||||
|
*/
|
||||||
|
async update(settingList: StoreSettingPayload[]): Promise<void> {
|
||||||
|
await axios.post(`${BASE_URI}/update`, settingList);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export default StoreSettingAPI;
|
||||||
@@ -0,0 +1,169 @@
|
|||||||
|
<template>
|
||||||
|
<div class="tui-page-layout tui-navbar birthday-reminder-setting">
|
||||||
|
<t-navbar
|
||||||
|
fixed
|
||||||
|
:z-index="20"
|
||||||
|
title="生日提醒设置"
|
||||||
|
left-arrow
|
||||||
|
@left-click="exit()"
|
||||||
|
>
|
||||||
|
<template #right>
|
||||||
|
<t-button
|
||||||
|
theme="primary"
|
||||||
|
variant="text"
|
||||||
|
size="small"
|
||||||
|
content="保存"
|
||||||
|
:loading="isSaving"
|
||||||
|
:disabled="isLoading"
|
||||||
|
@click="save"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</t-navbar>
|
||||||
|
<main v-can="corePermissionCodes.setting.update" class="tui-page-content scroll column">
|
||||||
|
<t-cell-group theme="card">
|
||||||
|
<t-cell title="启用生日提醒" description="提前 7 天生成客户生日跟进提醒">
|
||||||
|
<template #rightIcon>
|
||||||
|
<t-switch v-model="formModel.enabled" :disabled="isLoading || isSaving" />
|
||||||
|
</template>
|
||||||
|
</t-cell>
|
||||||
|
<t-cell
|
||||||
|
title="跟进负责人"
|
||||||
|
:note="responsibleName"
|
||||||
|
arrow
|
||||||
|
@click="responsibleSelectorVisible = true"
|
||||||
|
/>
|
||||||
|
</t-cell-group>
|
||||||
|
<div class="tips red">
|
||||||
|
启用后每天 7:00 提前 7 天生成客户生日提醒,站内信与短信在生日当天 8:00 发给负责人。农历生日按农历月日计算。
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
<managed-user-selector
|
||||||
|
v-model="formModel.responsibleUserId"
|
||||||
|
v-model:visible="responsibleSelectorVisible"
|
||||||
|
title="选择生日提醒负责人"
|
||||||
|
:store-id="currentStoreStore.currentStoreId"
|
||||||
|
@change="handleResponsibleSelected"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { useExpandToMaster, usePane } from "timi-tdesign-mobile";
|
||||||
|
import ManagedUserSelector from "@/pages/followUpReminder/component/ManagedUserSelector.vue";
|
||||||
|
import StoreSettingAPI, {
|
||||||
|
BIRTHDAY_REMINDER_ENABLED,
|
||||||
|
BIRTHDAY_REMINDER_RESPONSIBLE_USER_ID
|
||||||
|
} from "@/api/StoreSettingAPI";
|
||||||
|
import ManagedUserAPI from "@/api/ManagedUserAPI";
|
||||||
|
import { Message } from "@/utils/message";
|
||||||
|
import { getErrorMessage } from "@/utils/error";
|
||||||
|
import { corePermissionCodes } from "@/utils/permission";
|
||||||
|
import { useCurrentStoreStore } from "@/store/currentStoreStore";
|
||||||
|
import type { ManagedUser } from "@/types/ManagedUser";
|
||||||
|
|
||||||
|
defineOptions({
|
||||||
|
name: "BirthdayReminderSetting"
|
||||||
|
});
|
||||||
|
|
||||||
|
const router = useRouter();
|
||||||
|
const pane = usePane();
|
||||||
|
useExpandToMaster({
|
||||||
|
path: "/management/customer-follow-up-reminders",
|
||||||
|
id: () => "__birthday_setting__"
|
||||||
|
});
|
||||||
|
const currentStoreStore = useCurrentStoreStore();
|
||||||
|
|
||||||
|
const isLoading = ref(false);
|
||||||
|
const isSaving = ref(false);
|
||||||
|
const responsibleSelectorVisible = ref(false);
|
||||||
|
const responsibleName = ref("未选择");
|
||||||
|
const formModel = reactive({
|
||||||
|
enabled: false,
|
||||||
|
responsibleUserId: ""
|
||||||
|
});
|
||||||
|
|
||||||
|
function exit(): void {
|
||||||
|
if (pane) {
|
||||||
|
pane.close();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
router.back();
|
||||||
|
}
|
||||||
|
|
||||||
|
async function load(): Promise<void> {
|
||||||
|
isLoading.value = true;
|
||||||
|
try {
|
||||||
|
const settingMap = await StoreSettingAPI.map([
|
||||||
|
BIRTHDAY_REMINDER_ENABLED,
|
||||||
|
BIRTHDAY_REMINDER_RESPONSIBLE_USER_ID
|
||||||
|
]);
|
||||||
|
formModel.enabled = settingMap[BIRTHDAY_REMINDER_ENABLED]?.value === "true";
|
||||||
|
const responsibleUserId = settingMap[BIRTHDAY_REMINDER_RESPONSIBLE_USER_ID]?.value || "";
|
||||||
|
formModel.responsibleUserId = responsibleUserId;
|
||||||
|
responsibleName.value = responsibleUserId ? "加载中…" : "未选择";
|
||||||
|
if (responsibleUserId) {
|
||||||
|
await fillResponsibleName(responsibleUserId);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
Message.error(getErrorMessage(error, "生日提醒设置加载失败"));
|
||||||
|
} finally {
|
||||||
|
isLoading.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function fillResponsibleName(userId: string): Promise<void> {
|
||||||
|
try {
|
||||||
|
const storeId = currentStoreStore.currentStoreId || undefined;
|
||||||
|
const result = await ManagedUserAPI.list({
|
||||||
|
index: 0,
|
||||||
|
size: 1,
|
||||||
|
equalsExample: { userId, storeId }
|
||||||
|
}, { storeId });
|
||||||
|
const managedUser = result.list?.[0];
|
||||||
|
responsibleName.value = managedUser ? getManagedUserName(managedUser) : "负责人已不在本门店";
|
||||||
|
} catch {
|
||||||
|
responsibleName.value = "未知负责人";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getManagedUserName(item: ManagedUser): string {
|
||||||
|
return item.user?.nick || item.user?.name || item.userId || "未命名负责人";
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleResponsibleSelected(user: ManagedUser): void {
|
||||||
|
formModel.responsibleUserId = user.userId || "";
|
||||||
|
responsibleName.value = getManagedUserName(user);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function save(): Promise<void> {
|
||||||
|
if (formModel.enabled && !formModel.responsibleUserId) {
|
||||||
|
Message.warning("启用生日提醒前请先选择跟进负责人");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
isSaving.value = true;
|
||||||
|
try {
|
||||||
|
await StoreSettingAPI.update([
|
||||||
|
{ code: BIRTHDAY_REMINDER_ENABLED, value: formModel.enabled ? "true" : "false" },
|
||||||
|
{ code: BIRTHDAY_REMINDER_RESPONSIBLE_USER_ID, value: formModel.responsibleUserId }
|
||||||
|
]);
|
||||||
|
Message.success("已保存");
|
||||||
|
exit();
|
||||||
|
} catch (error) {
|
||||||
|
Message.error(getErrorMessage(error, "保存失败"));
|
||||||
|
} finally {
|
||||||
|
isSaving.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(load);
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped lang="less">
|
||||||
|
.birthday-reminder-setting {
|
||||||
|
|
||||||
|
.tips {
|
||||||
|
font-size: .875rem;
|
||||||
|
padding: 0 1rem 0 2rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -54,8 +54,8 @@
|
|||||||
<t-tag
|
<t-tag
|
||||||
size="small"
|
size="small"
|
||||||
variant="outline"
|
variant="outline"
|
||||||
:theme="internalNotifyStatus ? getNotifyStatusTheme(internalNotifyStatus.status) : 'primary'"
|
:theme="internalNotifyStatus ? getNotifyStatusTheme(internalNotifyStatus.status) : (isNotifyPending ? 'warning' : 'primary')"
|
||||||
:content="internalNotifyStatus ? getNotifyStatusText(internalNotifyStatus.status) : '已配置'"
|
:content="internalNotifyStatus ? getNotifyStatusText(internalNotifyStatus.status) : (isNotifyPending ? '待发送' : '已配置')"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
</t-cell>
|
</t-cell>
|
||||||
@@ -162,6 +162,8 @@ const isLoading = ref(false);
|
|||||||
const isCompleting = ref(false);
|
const isCompleting = ref(false);
|
||||||
const isDeleting = ref(false);
|
const isDeleting = ref(false);
|
||||||
const internalNotifyStatus = ref<NotifyDetail>();
|
const internalNotifyStatus = ref<NotifyDetail>();
|
||||||
|
// 站内通知在提醒时间之后才对接收人可见,未到时间时后端按未发送处理
|
||||||
|
const isNotifyPending = computed(() => Boolean(detail.value?.remindAt && Time.now() < detail.value.remindAt));
|
||||||
let loadToken = 0;
|
let loadToken = 0;
|
||||||
|
|
||||||
const canUpdate = computed(() => detail.value?.status === "PENDING"
|
const canUpdate = computed(() => detail.value?.status === "PENDING"
|
||||||
@@ -258,6 +260,10 @@ async function loadInternalNotifyStatus(item: FollowUpReminder, token: number):
|
|||||||
if (!item.internalNotifyDetailId || !userStore.hasPermissions(corePermissionCodes.notify.read)) {
|
if (!item.internalNotifyDetailId || !userStore.hasPermissions(corePermissionCodes.notify.read)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// 未到提醒时间时后端按未发送处理,直接跳过避免必然失败的请求
|
||||||
|
if (item.remindAt && Time.now() < item.remindAt) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
const result = await NotifyAPI.internalDetail(item.internalNotifyDetailId);
|
const result = await NotifyAPI.internalDetail(item.internalNotifyDetailId);
|
||||||
if (token === loadToken) {
|
if (token === loadToken) {
|
||||||
|
|||||||
@@ -166,8 +166,10 @@ const route = useRoute();
|
|||||||
const props = withDefaults(defineProps<{
|
const props = withDefaults(defineProps<{
|
||||||
/** 内联到主从分栏时由列表页传入,优先于路由参数 */
|
/** 内联到主从分栏时由列表页传入,优先于路由参数 */
|
||||||
reminderId?: string;
|
reminderId?: string;
|
||||||
|
customerId?: string;
|
||||||
}>(), {
|
}>(), {
|
||||||
reminderId: ""
|
reminderId: "",
|
||||||
|
customerId: ""
|
||||||
});
|
});
|
||||||
|
|
||||||
/** 非空说明当前被内联在右栏里,退出走 close 而不是路由 */
|
/** 非空说明当前被内联在右栏里,退出走 close 而不是路由 */
|
||||||
@@ -177,8 +179,8 @@ const routeId = computed(() => props.reminderId || String(route.params.id || "")
|
|||||||
// 竖屏整页编辑转横屏:回到分栏,并用 view=edit 让列表页把右栏还原成编辑
|
// 竖屏整页编辑转横屏:回到分栏,并用 view=edit 让列表页把右栏还原成编辑
|
||||||
useExpandToMaster({
|
useExpandToMaster({
|
||||||
path: "/management/customer-follow-up-reminders",
|
path: "/management/customer-follow-up-reminders",
|
||||||
id: () => routeId.value,
|
id: () => routeId.value || "__create__",
|
||||||
query: { view: "edit" }
|
query: { view: "edit", ...(route.query.customerId ? { customerId: String(route.query.customerId) } : {}) }
|
||||||
});
|
});
|
||||||
|
|
||||||
/** 退出编辑:分栏时交回列表页,整页时回路由 */
|
/** 退出编辑:分栏时交回列表页,整页时回路由 */
|
||||||
@@ -199,7 +201,7 @@ const routeNavBarTitle = computed(() => {
|
|||||||
return "编辑跟进提醒";
|
return "编辑跟进提醒";
|
||||||
default:
|
default:
|
||||||
// 内联在右栏时路由仍是列表页,标题不能只看 route.name
|
// 内联在右栏时路由仍是列表页,标题不能只看 route.name
|
||||||
return pane ? "编辑跟进提醒" : "";
|
return pane ? (routeId.value ? "编辑跟进提醒" : "新增跟进提醒") : "";
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
@@ -510,7 +512,7 @@ async function loadForm(): Promise<void> {
|
|||||||
await loadStoreScope();
|
await loadStoreScope();
|
||||||
if (!routeId.value) {
|
if (!routeId.value) {
|
||||||
formModel.notifyChannelList = ["INTERNAL"];
|
formModel.notifyChannelList = ["INTERNAL"];
|
||||||
const queryCustomerId = String(route.query.customerId || "");
|
const queryCustomerId = String(props.customerId || route.query.customerId || "");
|
||||||
if (queryCustomerId) {
|
if (queryCustomerId) {
|
||||||
await handleCustomerChange(queryCustomerId);
|
await handleCustomerChange(queryCustomerId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,14 +8,7 @@
|
|||||||
@left-click="$router.back()"
|
@left-click="$router.back()"
|
||||||
>
|
>
|
||||||
<template #right>
|
<template #right>
|
||||||
<t-button
|
<navbar-actions :actions="actionList" />
|
||||||
v-if="canCreate"
|
|
||||||
theme="primary"
|
|
||||||
variant="text"
|
|
||||||
size="small"
|
|
||||||
content="新增"
|
|
||||||
@click="toCreate"
|
|
||||||
/>
|
|
||||||
</template>
|
</template>
|
||||||
</t-navbar>
|
</t-navbar>
|
||||||
<master-detail-page
|
<master-detail-page
|
||||||
@@ -80,93 +73,30 @@
|
|||||||
<t-cell v-if="dateFilterType !== 'all'" title="提醒时间" :note="dateFilterLabel" />
|
<t-cell v-if="dateFilterType !== 'all'" title="提醒时间" :note="dateFilterLabel" />
|
||||||
<t-cell v-if="selectedResponsibleId" title="负责人" :note="selectedResponsibleName" />
|
<t-cell v-if="selectedResponsibleId" title="负责人" :note="selectedResponsibleName" />
|
||||||
</t-cell-group>
|
</t-cell-group>
|
||||||
<t-cell-group v-if="pageResult.list.length" class="items fix-last-cell-line empty-cell-title-margin" theme="card">
|
<div v-if="pageResult.list.length" class="items">
|
||||||
<t-swipe-cell
|
<follow-up-reminder-list-cell
|
||||||
v-for="(item, index) in pageResult.list"
|
v-for="(item, index) in pageResult.list"
|
||||||
:key="item.id || index"
|
:key="item.id || index"
|
||||||
class="item"
|
v-entrance-transition="{ step: 30 }"
|
||||||
>
|
:item="item"
|
||||||
<t-cell
|
:can-complete="canComplete"
|
||||||
v-entrance-transition="{ step: 30 }"
|
:can-delete="canDelete"
|
||||||
class="cell"
|
@complete="item.status = 'COMPLETED'"
|
||||||
arrow
|
@delete="removeFromList(item)"
|
||||||
@click="toDetail(item)"
|
@detail="toDetail(item)"
|
||||||
>
|
/>
|
||||||
<template #leftIcon>
|
</div>
|
||||||
<t-image
|
|
||||||
v-if="getCustomerPhotoURL(item.customer, 64)"
|
|
||||||
:src="getCustomerPhotoURL(item.customer, 64)"
|
|
||||||
:alt="getCustomerName(item)"
|
|
||||||
fit="cover"
|
|
||||||
class="avatar"
|
|
||||||
/>
|
|
||||||
<div v-else class="avatar fallback" v-text="getCustomerName(item).slice(0, 1)" />
|
|
||||||
</template>
|
|
||||||
<template #title>
|
|
||||||
<div class="title">
|
|
||||||
<div class="name-channel">
|
|
||||||
<span class="text-bold" v-text="getCustomerName(item)" />
|
|
||||||
<t-tag
|
|
||||||
v-if="item.notifyChannelList?.includes('INTERNAL')"
|
|
||||||
size="small"
|
|
||||||
theme="primary"
|
|
||||||
variant="outline"
|
|
||||||
content="站内信"
|
|
||||||
/>
|
|
||||||
<t-tag
|
|
||||||
v-if="item.notifyChannelList?.includes('SMS')"
|
|
||||||
size="small"
|
|
||||||
theme="warning"
|
|
||||||
variant="outline"
|
|
||||||
content="短信"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<t-tag size="small" :theme="getStatusTheme(item.status)" :content="getStatusText(item.status)" />
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
<template #description>
|
|
||||||
<div class="description">
|
|
||||||
<div class="content clip-text" v-text="getContentSummary(item.content)" />
|
|
||||||
<div class="time-responsible">
|
|
||||||
<span
|
|
||||||
class="remind-time"
|
|
||||||
:class="getReminderTimeClass(item)"
|
|
||||||
v-text="getReminderTimeText(item.remindAt)"
|
|
||||||
/>
|
|
||||||
<span v-text="`负责人:${getResponsibleName(item)}`" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
</t-cell>
|
|
||||||
<template #right>
|
|
||||||
<div class="swipe-actions">
|
|
||||||
<t-button
|
|
||||||
v-if="canComplete && item.status === 'PENDING'"
|
|
||||||
class="complete swipe-cell-button"
|
|
||||||
variant="text"
|
|
||||||
:loading="operatingId === item.id && operatingType === 'complete'"
|
|
||||||
@click.stop="confirmComplete(item)"
|
|
||||||
>完成</t-button>
|
|
||||||
<t-button
|
|
||||||
v-if="canDelete"
|
|
||||||
class="delete swipe-cell-button"
|
|
||||||
variant="text"
|
|
||||||
:loading="operatingId === item.id && operatingType === 'delete'"
|
|
||||||
@click.stop="confirmDelete(item)"
|
|
||||||
>删除</t-button>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
</t-swipe-cell>
|
|
||||||
</t-cell-group>
|
|
||||||
<center-tips :content="isLoading ? '正在加载提醒' : pageResult.list.length ? (isNoMore ? '已经到底了' : '上拉加载更多') : '暂无跟进提醒'" />
|
<center-tips :content="isLoading ? '正在加载提醒' : pageResult.list.length ? (isNoMore ? '已经到底了' : '上拉加载更多') : '暂无跟进提醒'" />
|
||||||
</div>
|
</div>
|
||||||
</t-pull-down-refresh>
|
</t-pull-down-refresh>
|
||||||
</template>
|
</template>
|
||||||
<template #detail>
|
<template #detail>
|
||||||
|
<birthday-reminder-setting v-if="selectedId === birthdayPaneId" />
|
||||||
<follow-up-reminder-edit
|
<follow-up-reminder-edit
|
||||||
v-if="editing"
|
v-else-if="editing || selectedId === createPaneId"
|
||||||
:key="`edit-${selectedId}`"
|
:key="`edit-${selectedId}`"
|
||||||
:reminder-id="selectedId"
|
:reminder-id="selectedId === createPaneId ? '' : selectedId"
|
||||||
|
:customer-id="selectedCustomerId"
|
||||||
/>
|
/>
|
||||||
<follow-up-reminder-detail
|
<follow-up-reminder-detail
|
||||||
v-else
|
v-else
|
||||||
@@ -176,50 +106,50 @@
|
|||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
</master-detail-page>
|
</master-detail-page>
|
||||||
|
<customer-selector
|
||||||
<customer-selector
|
v-model="selectedCustomerId"
|
||||||
v-model="selectedCustomerId"
|
v-model:visible="customerSelectorVisible"
|
||||||
v-model:visible="customerSelectorVisible"
|
:initial-keyword="customerSearchKeyword"
|
||||||
:initial-keyword="customerSearchKeyword"
|
:store-id="currentStoreStore.currentStoreId"
|
||||||
:store-id="currentStoreStore.currentStoreId"
|
:enable-scan="true"
|
||||||
:enable-scan="true"
|
@change="handleCustomerSelected"
|
||||||
@change="handleCustomerSelected"
|
/>
|
||||||
|
<managed-user-selector
|
||||||
|
v-model="selectedResponsibleId"
|
||||||
|
v-model:visible="responsibleSelectorVisible"
|
||||||
|
:store-id="currentStoreStore.currentStoreId"
|
||||||
|
@change="handleResponsibleSelected"
|
||||||
|
/>
|
||||||
|
<t-popup v-model="startVisible" placement="bottom">
|
||||||
|
<t-date-time-picker
|
||||||
|
v-if="startVisible"
|
||||||
|
v-model="startDraft"
|
||||||
|
format="YYYY-MM-DD HH:mm"
|
||||||
|
:mode="['date', 'minute']"
|
||||||
|
title="提醒开始时间"
|
||||||
|
@cancel="startVisible = false"
|
||||||
|
@confirm="confirmStart"
|
||||||
/>
|
/>
|
||||||
<managed-user-selector
|
</t-popup>
|
||||||
v-model="selectedResponsibleId"
|
<t-popup v-model="endVisible" placement="bottom">
|
||||||
v-model:visible="responsibleSelectorVisible"
|
<t-date-time-picker
|
||||||
:store-id="currentStoreStore.currentStoreId"
|
v-if="endVisible"
|
||||||
@change="handleResponsibleSelected"
|
v-model="endDraft"
|
||||||
|
format="YYYY-MM-DD HH:mm"
|
||||||
|
:mode="['date', 'minute']"
|
||||||
|
title="提醒结束时间"
|
||||||
|
@cancel="endVisible = false"
|
||||||
|
@confirm="confirmEnd"
|
||||||
/>
|
/>
|
||||||
<t-popup v-model="startVisible" placement="bottom">
|
</t-popup>
|
||||||
<t-date-time-picker
|
|
||||||
v-if="startVisible"
|
|
||||||
v-model="startDraft"
|
|
||||||
format="YYYY-MM-DD HH:mm"
|
|
||||||
:mode="['date', 'minute']"
|
|
||||||
title="提醒开始时间"
|
|
||||||
@cancel="startVisible = false"
|
|
||||||
@confirm="confirmStart"
|
|
||||||
/>
|
|
||||||
</t-popup>
|
|
||||||
<t-popup v-model="endVisible" placement="bottom">
|
|
||||||
<t-date-time-picker
|
|
||||||
v-if="endVisible"
|
|
||||||
v-model="endDraft"
|
|
||||||
format="YYYY-MM-DD HH:mm"
|
|
||||||
:mode="['date', 'minute']"
|
|
||||||
title="提醒结束时间"
|
|
||||||
@cancel="endVisible = false"
|
|
||||||
@confirm="confirmEnd"
|
|
||||||
/>
|
|
||||||
</t-popup>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { MasterDetailPage, useMasterDetailPane } from "timi-tdesign-mobile";
|
import { MasterDetailPage, useMasterDetailPane } from "timi-tdesign-mobile";
|
||||||
import { DialogPlugin, type DropdownValue } from "tdesign-mobile-vue";
|
import { type DropdownValue } from "tdesign-mobile-vue";
|
||||||
|
import FollowUpReminderListCell from "@/pages/followUpReminder/component/FollowUpReminderListCell.vue";
|
||||||
|
import BirthdayReminderSetting from "@/pages/followUpReminder/BirthdayReminderSetting.vue";
|
||||||
import FollowUpReminderDetail from "@/pages/followUpReminder/FollowUpReminderDetail.vue";
|
import FollowUpReminderDetail from "@/pages/followUpReminder/FollowUpReminderDetail.vue";
|
||||||
import FollowUpReminderEdit from "@/pages/followUpReminder/FollowUpReminderEdit.vue";
|
import FollowUpReminderEdit from "@/pages/followUpReminder/FollowUpReminderEdit.vue";
|
||||||
import { Time } from "timi-web";
|
import { Time } from "timi-web";
|
||||||
@@ -229,13 +159,14 @@ import { getErrorMessage } from "@/utils/error";
|
|||||||
import FollowUpReminderAPI from "@/api/FollowUpReminderAPI";
|
import FollowUpReminderAPI from "@/api/FollowUpReminderAPI";
|
||||||
import CustomerAPI from "@/api/CustomerAPI";
|
import CustomerAPI from "@/api/CustomerAPI";
|
||||||
import CustomerSelector from "@/components/CustomerSelector.vue";
|
import CustomerSelector from "@/components/CustomerSelector.vue";
|
||||||
|
import NavbarActions from "@/components/NavbarActions.vue";
|
||||||
import ManagedUserSelector from "@/pages/followUpReminder/component/ManagedUserSelector.vue";
|
import ManagedUserSelector from "@/pages/followUpReminder/component/ManagedUserSelector.vue";
|
||||||
|
import type { NavbarAction } from "@/types/NavbarAction.ts";
|
||||||
import { useCurrentStoreStore } from "@/store/currentStoreStore";
|
import { useCurrentStoreStore } from "@/store/currentStoreStore";
|
||||||
import type { ManagedUser } from "@/types/ManagedUser";
|
import type { ManagedUser } from "@/types/ManagedUser";
|
||||||
import type { FollowUpReminder, FollowUpReminderPage, FollowUpReminderStatus } from "@/types/FollowUpReminder";
|
import type { FollowUpReminder, FollowUpReminderPage, FollowUpReminderStatus } from "@/types/FollowUpReminder";
|
||||||
import { getCustomerPhotoURL } from "@/utils/customer";
|
|
||||||
import { parseDateTime } from "@/utils/date";
|
import { parseDateTime } from "@/utils/date";
|
||||||
import { gaoRoleCodes, permissionCodes } from "@/utils/permission";
|
import { corePermissionCodes, gaoRoleCodes, permissionCodes } from "@/utils/permission";
|
||||||
|
|
||||||
import type { Customer } from "@/types/Customer";
|
import type { Customer } from "@/types/Customer";
|
||||||
|
|
||||||
@@ -248,12 +179,21 @@ defineOptions({
|
|||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
|
|
||||||
|
const createPaneId = "__create__";
|
||||||
|
const birthdayPaneId = "__birthday_setting__";
|
||||||
|
|
||||||
// 选中项、编辑态、切换方向、关闭逻辑、转屏、query 同步都在这里
|
// 选中项、编辑态、切换方向、关闭逻辑、转屏、query 同步都在这里
|
||||||
const { selectedId, editing, detailVersion, paneDirection, isWide, openDetail, openEdit } =
|
const { selectedId, editing, detailVersion, paneDirection, isWide, openDetail, openEdit } =
|
||||||
useMasterDetailPane({
|
useMasterDetailPane({
|
||||||
path: "/management/customer-follow-up-reminders",
|
path: "/management/customer-follow-up-reminders",
|
||||||
detail: id => `/management/customer-follow-up-reminders/${id}`,
|
detail: id => id === birthdayPaneId
|
||||||
edit: id => `/management/customer-follow-up-reminders/${id}/edit`
|
? "/management/customer-birthday-reminder-setting"
|
||||||
|
: id === createPaneId
|
||||||
|
? `/management/customer-follow-up-reminders/create${selectedCustomerId.value ? `?customerId=${encodeURIComponent(selectedCustomerId.value)}` : ""}`
|
||||||
|
: `/management/customer-follow-up-reminders/${id}`,
|
||||||
|
edit: id => id === createPaneId
|
||||||
|
? `/management/customer-follow-up-reminders/create${selectedCustomerId.value ? `?customerId=${encodeURIComponent(selectedCustomerId.value)}` : ""}`
|
||||||
|
: `/management/customer-follow-up-reminders/${id}/edit`
|
||||||
});
|
});
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
const currentStoreStore = useCurrentStoreStore();
|
const currentStoreStore = useCurrentStoreStore();
|
||||||
@@ -262,6 +202,7 @@ const isGlobalManager = computed(() => userStore.hasRoles(gaoRoleCodes.globalMan
|
|||||||
const canCreate = computed(() => userStore.hasPermissions(permissionCodes.customerFollowUpReminder.create));
|
const canCreate = computed(() => userStore.hasPermissions(permissionCodes.customerFollowUpReminder.create));
|
||||||
const canComplete = computed(() => userStore.hasPermissions(permissionCodes.customerFollowUpReminder.complete));
|
const canComplete = computed(() => userStore.hasPermissions(permissionCodes.customerFollowUpReminder.complete));
|
||||||
const canDelete = computed(() => userStore.hasPermissions(permissionCodes.customerFollowUpReminder.delete));
|
const canDelete = computed(() => userStore.hasPermissions(permissionCodes.customerFollowUpReminder.delete));
|
||||||
|
const canStoreSetting = computed(() => userStore.hasPermissions(corePermissionCodes.setting.update));
|
||||||
|
|
||||||
// ---------- 筛选 ----------
|
// ---------- 筛选 ----------
|
||||||
|
|
||||||
@@ -520,139 +461,71 @@ async function loadStoreScope(): Promise<void> {
|
|||||||
|
|
||||||
// ---------- 展示 ----------
|
// ---------- 展示 ----------
|
||||||
|
|
||||||
function getCustomerName(item: FollowUpReminder): string {
|
|
||||||
return item.customer?.name || item.customer?.code || item.customerId || "未命名客户";
|
|
||||||
}
|
|
||||||
|
|
||||||
function getManagedUserName(item: ManagedUser): string {
|
function getManagedUserName(item: ManagedUser): string {
|
||||||
return item.user?.nick || item.user?.name || item.userId || "未命名负责人";
|
return item.user?.nick || item.user?.name || item.userId || "未命名负责人";
|
||||||
}
|
}
|
||||||
|
|
||||||
function getResponsibleName(item: FollowUpReminder): string {
|
|
||||||
return item.responsibleUser?.nick || item.responsibleUser?.name || item.responsibleUserId || "未命名负责人";
|
|
||||||
}
|
|
||||||
|
|
||||||
function getReminderTimeText(remindAt?: number): string {
|
|
||||||
return remindAt ? Time.toDateTime(remindAt) : "-";
|
|
||||||
}
|
|
||||||
|
|
||||||
function getReminderTimeClass(item: FollowUpReminder): "near" | "soon" | "later" | "normal" {
|
|
||||||
if (item.status === "COMPLETED" || !item.remindAt) {
|
|
||||||
return "normal";
|
|
||||||
}
|
|
||||||
const distance = item.remindAt - Time.now();
|
|
||||||
if (distance < 24 * 60 * 60 * 1000) {
|
|
||||||
return "near";
|
|
||||||
}
|
|
||||||
if (distance < 3 * 24 * 60 * 60 * 1000) {
|
|
||||||
return "soon";
|
|
||||||
}
|
|
||||||
return "later";
|
|
||||||
}
|
|
||||||
|
|
||||||
function getContentSummary(content?: string): string {
|
|
||||||
const text = content?.trim() || "未填写跟进内容";
|
|
||||||
return 60 < text.length ? `${text.slice(0, 60)}...` : text;
|
|
||||||
}
|
|
||||||
|
|
||||||
function getStatusText(status?: FollowUpReminderStatus): string {
|
|
||||||
return status === "COMPLETED" ? "已完成" : "待完成";
|
|
||||||
}
|
|
||||||
|
|
||||||
function getStatusTheme(status?: FollowUpReminderStatus): "success" | "warning" {
|
|
||||||
return status === "COMPLETED" ? "success" : "warning";
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------- 操作 ----------
|
// ---------- 操作 ----------
|
||||||
|
|
||||||
const operatingId = ref("");
|
function removeFromList(item: FollowUpReminder): void {
|
||||||
const operatingType = ref<"complete" | "delete">();
|
pageResult.list = pageResult.list.filter(current => current.id !== item.id);
|
||||||
|
pageResult.total = Math.max(0, pageResult.total - 1);
|
||||||
function confirmComplete(item: FollowUpReminder): void {
|
|
||||||
if (!item.id || !canComplete.value || item.status !== "PENDING" || operatingId.value) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const dialog = DialogPlugin.confirm({
|
|
||||||
title: "完成跟进提醒",
|
|
||||||
content: "完成后不能重新打开,确定完成此跟进提醒吗?",
|
|
||||||
cancelBtn: "取消",
|
|
||||||
confirmBtn: "完成",
|
|
||||||
onCancel() {
|
|
||||||
dialog.destroy();
|
|
||||||
},
|
|
||||||
onConfirm: async () => {
|
|
||||||
dialog.destroy();
|
|
||||||
await complete(item.id || "");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
async function complete(id: string): Promise<void> {
|
|
||||||
operatingId.value = id;
|
|
||||||
operatingType.value = "complete";
|
|
||||||
try {
|
|
||||||
await FollowUpReminderAPI.complete(id);
|
|
||||||
const item = pageResult.list.find(current => current.id === id);
|
|
||||||
if (item) {
|
|
||||||
item.status = "COMPLETED";
|
|
||||||
}
|
|
||||||
Message.success("跟进提醒已完成");
|
|
||||||
} catch (error) {
|
|
||||||
Message.error(getErrorMessage(error, "跟进提醒完成失败"));
|
|
||||||
} finally {
|
|
||||||
operatingId.value = "";
|
|
||||||
operatingType.value = undefined;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function confirmDelete(item: FollowUpReminder): void {
|
|
||||||
if (!item.id || !canDelete.value || operatingId.value) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const dialog = DialogPlugin.confirm({
|
|
||||||
title: "删除跟进提醒",
|
|
||||||
content: "删除后列表中将不再显示,确定删除这条跟进提醒吗?",
|
|
||||||
cancelBtn: "取消",
|
|
||||||
confirmBtn: "删除",
|
|
||||||
onCancel() {
|
|
||||||
dialog.destroy();
|
|
||||||
},
|
|
||||||
onConfirm: async () => {
|
|
||||||
dialog.destroy();
|
|
||||||
await remove(item.id || "");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
async function remove(id: string): Promise<void> {
|
|
||||||
operatingId.value = id;
|
|
||||||
operatingType.value = "delete";
|
|
||||||
try {
|
|
||||||
await FollowUpReminderAPI.remove(id);
|
|
||||||
pageResult.list = pageResult.list.filter(item => item.id !== id);
|
|
||||||
pageResult.total = Math.max(0, pageResult.total - 1);
|
|
||||||
Message.success("跟进提醒已删除");
|
|
||||||
} catch (error) {
|
|
||||||
Message.error(getErrorMessage(error, "跟进提醒删除失败"));
|
|
||||||
} finally {
|
|
||||||
operatingId.value = "";
|
|
||||||
operatingType.value = undefined;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------- 导航和生命周期 ----------
|
// ---------- 导航和生命周期 ----------
|
||||||
|
|
||||||
async function toCreate(): Promise<void> {
|
async function toCreate(): Promise<void> {
|
||||||
|
if (isWide.value) {
|
||||||
|
openDetail(createPaneId);
|
||||||
|
return;
|
||||||
|
}
|
||||||
await router.push({
|
await router.push({
|
||||||
name: "CustomerFollowUpReminderCreate",
|
name: "CustomerFollowUpReminderCreate",
|
||||||
query: selectedCustomerId.value ? { customerId: selectedCustomerId.value } : undefined
|
query: selectedCustomerId.value ? { customerId: selectedCustomerId.value } : undefined
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function toBirthdaySetting(): Promise<void> {
|
||||||
|
if (isWide.value) {
|
||||||
|
openDetail(birthdayPaneId);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
await router.push({ name: "CustomerBirthdayReminderSetting" });
|
||||||
|
}
|
||||||
|
|
||||||
|
const actionList = computed<NavbarAction[]>(() => {
|
||||||
|
const list: NavbarAction[] = [];
|
||||||
|
if (canCreate.value) {
|
||||||
|
list.push({
|
||||||
|
action: toCreate,
|
||||||
|
theme: "primary",
|
||||||
|
icon: "add",
|
||||||
|
key: "create",
|
||||||
|
text: "新增"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (canStoreSetting.value) {
|
||||||
|
list.push({
|
||||||
|
action: toBirthdaySetting,
|
||||||
|
theme: "primary",
|
||||||
|
icon: "setting",
|
||||||
|
key: "birthday-setting",
|
||||||
|
text: "生日提醒设置"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
});
|
||||||
|
|
||||||
async function toDetail(item: FollowUpReminder): Promise<void> {
|
async function toDetail(item: FollowUpReminder): Promise<void> {
|
||||||
openDetail(item.id || "");
|
openDetail(item.id || "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
watch([selectedId, detailVersion], async ([id, version], [previousId, previousVersion]) => {
|
||||||
|
if ((!id && previousId) || version !== previousVersion) {
|
||||||
|
await refresh();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -714,107 +587,14 @@ watch(() => route.query.customerId, async value => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.items {
|
.items {
|
||||||
|
gap: .5rem;
|
||||||
|
margin: 0 1rem;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
|
||||||
.item {
|
}
|
||||||
|
|
||||||
.cell {
|
|
||||||
padding: 10px;
|
|
||||||
min-width: 0;
|
|
||||||
|
|
||||||
:deep(.t-cell__title),
|
|
||||||
:deep(.t-cell__title-text) {
|
|
||||||
min-width: 0;
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
.avatar {
|
|
||||||
width: 3.5rem;
|
|
||||||
height: 3.5rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.title {
|
|
||||||
gap: .5rem;
|
|
||||||
width: 100%;
|
|
||||||
display: flex;
|
|
||||||
min-width: 0;
|
|
||||||
font-size: .875rem;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: space-between;
|
|
||||||
|
|
||||||
.name-channel {
|
|
||||||
gap: .5rem;
|
|
||||||
display: flex;
|
|
||||||
min-width: 0;
|
|
||||||
overflow: hidden;
|
|
||||||
align-items: center;
|
|
||||||
|
|
||||||
> .text-bold {
|
|
||||||
min-width: 0;
|
|
||||||
overflow: hidden;
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.description {
|
|
||||||
font-size: .75rem;
|
|
||||||
width: 100%;
|
|
||||||
min-width: 0;
|
|
||||||
max-width: 100%;
|
|
||||||
overflow: hidden;
|
|
||||||
line-height: 1.25;
|
|
||||||
|
|
||||||
.remind-time {
|
|
||||||
font-weight: 600;
|
|
||||||
|
|
||||||
&.near {
|
|
||||||
color: var(--td-error-color);
|
|
||||||
}
|
|
||||||
|
|
||||||
&.soon {
|
|
||||||
color: var(--td-warning-color);
|
|
||||||
}
|
|
||||||
|
|
||||||
&.later {
|
|
||||||
color: var(--td-success-color);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.content {
|
|
||||||
color: var(--td-text-color-secondary);
|
|
||||||
width: 100%;
|
|
||||||
min-width: 0;
|
|
||||||
max-width: 100%;
|
|
||||||
overflow: hidden;
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
|
||||||
|
|
||||||
.time-responsible {
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.swipe-actions {
|
|
||||||
--td-button-border-radius: 0;
|
|
||||||
|
|
||||||
.complete {
|
|
||||||
color: #fff;
|
|
||||||
background: var(--td-success-color);
|
|
||||||
}
|
|
||||||
|
|
||||||
.delete {
|
|
||||||
color: #fff;
|
|
||||||
background: var(--td-error-color);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
:global(html.theme-dark) {
|
:global(html.theme-dark) {
|
||||||
.follow-up-reminder-list {
|
.follow-up-reminder-list {
|
||||||
@@ -823,17 +603,12 @@ watch(() => route.query.customerId, async value => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
.summary,
|
.summary {
|
||||||
.items .item,
|
|
||||||
.items .cell {
|
|
||||||
color: #e2e8f0;
|
color: #e2e8f0;
|
||||||
background: rgba(30, 41, 59, .9);
|
background: rgba(30, 41, 59, .9);
|
||||||
border-color: rgba(148, 163, 184, .16);
|
border-color: rgba(148, 163, 184, .16);
|
||||||
}
|
}
|
||||||
|
|
||||||
.description .content {
|
|
||||||
color: #94a3b8;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,295 @@
|
|||||||
|
<template>
|
||||||
|
<div class="item">
|
||||||
|
<div class="header">
|
||||||
|
<t-image v-if="getCustomerPhotoURL(item.customer, 64)" :src="getCustomerPhotoURL(item.customer, 64)"
|
||||||
|
:alt="customerName" fit="cover" class="avatar" />
|
||||||
|
<div v-else class="avatar fallback" v-text="customerName.slice(0, 1)" />
|
||||||
|
<div class="main">
|
||||||
|
<div class="customer-status">
|
||||||
|
<strong class="customer clip-text" v-text="customerName" />
|
||||||
|
<div class="tags">
|
||||||
|
<t-tag
|
||||||
|
v-if="item.metadata?.bizType === 'BIRTHDAY'"
|
||||||
|
size="small"
|
||||||
|
theme="success"
|
||||||
|
variant="outline"
|
||||||
|
content="生日"
|
||||||
|
/>
|
||||||
|
<t-tag
|
||||||
|
v-if="item.source === 'SYSTEM'"
|
||||||
|
size="small"
|
||||||
|
theme="warning"
|
||||||
|
variant="outline"
|
||||||
|
content="系统"
|
||||||
|
/>
|
||||||
|
<t-tag
|
||||||
|
size="small"
|
||||||
|
variant="light-outline"
|
||||||
|
:theme="item.status === 'COMPLETED' ? 'success' : 'warning'"
|
||||||
|
:content="item.status === 'COMPLETED' ? '已完成' : '待完成'"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="record-line">
|
||||||
|
<span
|
||||||
|
class="time"
|
||||||
|
:class="timeClass"
|
||||||
|
v-text="item.remindAt ? Time.toDateTime(item.remindAt) : '-'"
|
||||||
|
/>
|
||||||
|
<div class="tags">
|
||||||
|
<t-tag
|
||||||
|
v-if="item.notifyChannelList?.includes('INTERNAL')"
|
||||||
|
size="small"
|
||||||
|
theme="primary"
|
||||||
|
variant="outline"
|
||||||
|
content="站内信"
|
||||||
|
/>
|
||||||
|
<t-tag
|
||||||
|
v-if="item.notifyChannelList?.includes('SMS')"
|
||||||
|
size="small"
|
||||||
|
theme="warning"
|
||||||
|
variant="outline"
|
||||||
|
content="短信"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<t-divider />
|
||||||
|
<div class="content" v-text="item.content?.trim() || '未填写跟进内容'" />
|
||||||
|
<t-divider />
|
||||||
|
<div class="people-actions">
|
||||||
|
<div class="person"><span class="label">负责人</span><strong v-text="responsibleName" /></div>
|
||||||
|
<div class="actions">
|
||||||
|
<t-button
|
||||||
|
v-if="canDelete"
|
||||||
|
theme="danger"
|
||||||
|
variant="text"
|
||||||
|
size="extra-small"
|
||||||
|
content="删除"
|
||||||
|
:loading="operating === 'delete'"
|
||||||
|
:disabled="!!operating"
|
||||||
|
@click.stop="confirmDelete"
|
||||||
|
/>
|
||||||
|
<t-button
|
||||||
|
v-if="canComplete && item.status === 'PENDING'"
|
||||||
|
theme="primary"
|
||||||
|
variant="outline"
|
||||||
|
size="extra-small"
|
||||||
|
content="完成"
|
||||||
|
:loading="operating === 'complete'"
|
||||||
|
:disabled="!!operating"
|
||||||
|
@click.stop="confirmComplete"
|
||||||
|
/>
|
||||||
|
<t-button theme="primary" size="extra-small" content="详情" @click.stop="emit('detail')" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { Time } from "timi-web";
|
||||||
|
import { DialogPlugin } from "tdesign-mobile-vue";
|
||||||
|
import FollowUpReminderAPI from "@/api/FollowUpReminderAPI";
|
||||||
|
import { Message } from "@/utils/message";
|
||||||
|
import { getErrorMessage } from "@/utils/error";
|
||||||
|
import type { FollowUpReminder } from "@/types/FollowUpReminder";
|
||||||
|
import { getCustomerPhotoURL } from "@/utils/customer";
|
||||||
|
|
||||||
|
defineOptions({ name: "FollowUpReminderListCell" });
|
||||||
|
const props = defineProps<{
|
||||||
|
item: FollowUpReminder;
|
||||||
|
canComplete: boolean;
|
||||||
|
canDelete: boolean;
|
||||||
|
}>();
|
||||||
|
const emit = defineEmits<{ detail: []; complete: []; delete: [] }>();
|
||||||
|
|
||||||
|
const operating = ref<"complete" | "delete">();
|
||||||
|
|
||||||
|
const customerName = computed(() => props.item.customer?.name || props.item.customer?.code || props.item.customerId || "未命名客户");
|
||||||
|
const responsibleName = computed(() => props.item.responsibleUser?.nick || props.item.responsibleUser?.name || props.item.responsibleUserId || "未命名负责人");
|
||||||
|
const timeClass = computed(() => {
|
||||||
|
if (props.item.status === "COMPLETED" || !props.item.remindAt) return "normal";
|
||||||
|
const distance = props.item.remindAt - Time.now();
|
||||||
|
if (distance < 24 * 60 * 60 * 1000) return "near";
|
||||||
|
if (distance < 3 * 24 * 60 * 60 * 1000) return "soon";
|
||||||
|
return "later";
|
||||||
|
});
|
||||||
|
|
||||||
|
function confirmComplete(): void {
|
||||||
|
if (!props.item.id || !props.canComplete || props.item.status !== "PENDING" || operating.value) return;
|
||||||
|
const dialog = DialogPlugin.confirm({
|
||||||
|
title: "完成跟进提醒",
|
||||||
|
content: "完成后不能重新打开,确定完成此跟进提醒吗?",
|
||||||
|
cancelBtn: "取消",
|
||||||
|
confirmBtn: "完成",
|
||||||
|
onCancel() { dialog.destroy(); },
|
||||||
|
onConfirm: async () => {
|
||||||
|
dialog.destroy();
|
||||||
|
await operate("complete");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function confirmDelete(): void {
|
||||||
|
if (!props.item.id || !props.canDelete || operating.value) return;
|
||||||
|
const dialog = DialogPlugin.confirm({
|
||||||
|
title: "删除跟进提醒",
|
||||||
|
content: "删除后列表中将不再显示,确定删除这条跟进提醒吗?",
|
||||||
|
cancelBtn: "取消",
|
||||||
|
confirmBtn: "删除",
|
||||||
|
onCancel() { dialog.destroy(); },
|
||||||
|
onConfirm: async () => {
|
||||||
|
dialog.destroy();
|
||||||
|
await operate("delete");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async function operate(action: "complete" | "delete"): Promise<void> {
|
||||||
|
const id = props.item.id;
|
||||||
|
if (!id || operating.value) return;
|
||||||
|
operating.value = action;
|
||||||
|
try {
|
||||||
|
if (action === "complete") {
|
||||||
|
await FollowUpReminderAPI.complete(id);
|
||||||
|
Message.success("跟进提醒已完成");
|
||||||
|
emit("complete");
|
||||||
|
} else {
|
||||||
|
await FollowUpReminderAPI.remove(id);
|
||||||
|
Message.success("跟进提醒已删除");
|
||||||
|
emit("delete");
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
Message.error(getErrorMessage(error, action === "complete" ? "跟进提醒完成失败" : "跟进提醒删除失败"));
|
||||||
|
} finally {
|
||||||
|
operating.value = undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped lang="less">
|
||||||
|
.item {
|
||||||
|
gap: .5rem;
|
||||||
|
padding: .625rem;
|
||||||
|
display: flex;
|
||||||
|
background: var(--td-bg-color-container);
|
||||||
|
flex-direction: column;
|
||||||
|
border-radius: 1rem;
|
||||||
|
|
||||||
|
.header {
|
||||||
|
gap: .5rem;
|
||||||
|
display: flex;
|
||||||
|
|
||||||
|
.avatar {
|
||||||
|
width: 3.5rem;
|
||||||
|
height: 3.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.main {
|
||||||
|
gap: .5rem;
|
||||||
|
flex: 1;
|
||||||
|
display: flex;
|
||||||
|
min-width: 0;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
|
.customer-status, .record-line {
|
||||||
|
gap: .5rem;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
}
|
||||||
|
|
||||||
|
.customer {
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tags {
|
||||||
|
gap: .5rem;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.record-line {
|
||||||
|
|
||||||
|
.time {
|
||||||
|
font-size: .875rem;
|
||||||
|
|
||||||
|
&.near {
|
||||||
|
color: var(--td-error-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
&.soon {
|
||||||
|
color: var(--td-warning-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
&.later {
|
||||||
|
color: var(--td-success-color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.tags {
|
||||||
|
flex-wrap: wrap;
|
||||||
|
justify-content: flex-end;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.content {
|
||||||
|
width: 100%;
|
||||||
|
min-width: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
font-size: .75rem;
|
||||||
|
white-space: nowrap;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
||||||
|
|
||||||
|
.people-actions {
|
||||||
|
gap: .75rem;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
|
||||||
|
.person {
|
||||||
|
gap: .25rem;
|
||||||
|
display: flex;
|
||||||
|
min-width: 0;
|
||||||
|
font-size: .75rem;
|
||||||
|
align-items: baseline;
|
||||||
|
|
||||||
|
.label {
|
||||||
|
color: var(--td-text-color-secondary);
|
||||||
|
flex: 0 0 auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
strong {
|
||||||
|
max-width: 10rem;
|
||||||
|
overflow: hidden;
|
||||||
|
white-space: nowrap;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.actions {
|
||||||
|
--td-button-border-radius: .5rem;
|
||||||
|
gap: .5rem;
|
||||||
|
display: flex;
|
||||||
|
justify-content: end;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(.avatar .t-image__img) {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
object-fit: cover;
|
||||||
|
border-radius: inherit;
|
||||||
|
}
|
||||||
|
|
||||||
|
:global(html.theme-dark) .item .fallback {
|
||||||
|
background: #115e59;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -23,6 +23,17 @@ const followUpReminderRoutes: RouteRecordRaw[] = [
|
|||||||
darkBodyBackground: "#10161f"
|
darkBodyBackground: "#10161f"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: "/management/customer-birthday-reminder-setting",
|
||||||
|
name: "CustomerBirthdayReminderSetting",
|
||||||
|
component: () => import("@/pages/followUpReminder/BirthdayReminderSetting.vue"),
|
||||||
|
meta: {
|
||||||
|
depth: 4,
|
||||||
|
tabBarVisible: false,
|
||||||
|
bodyBackground: "#F5F5F8",
|
||||||
|
darkBodyBackground: "#10161f"
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
path: "/management/customer-follow-up-reminders/:id",
|
path: "/management/customer-follow-up-reminders/:id",
|
||||||
name: "CustomerFollowUpReminderDetail",
|
name: "CustomerFollowUpReminderDetail",
|
||||||
|
|||||||
@@ -4,9 +4,24 @@ import type { Customer } from "@/types/Customer";
|
|||||||
/** 客户跟进提醒业务状态。 */
|
/** 客户跟进提醒业务状态。 */
|
||||||
export type FollowUpReminderStatus = "PENDING" | "COMPLETED";
|
export type FollowUpReminderStatus = "PENDING" | "COMPLETED";
|
||||||
|
|
||||||
|
/** 客户跟进提醒来源。 */
|
||||||
|
export type FollowUpReminderSource = "MANUAL" | "SYSTEM";
|
||||||
|
|
||||||
/** 客户跟进提醒通知方式。 */
|
/** 客户跟进提醒通知方式。 */
|
||||||
export type FollowUpReminderNotifyChannel = "INTERNAL" | "SMS";
|
export type FollowUpReminderNotifyChannel = "INTERNAL" | "SMS";
|
||||||
|
|
||||||
|
/** 系统创建提醒的扩展信息快照。 */
|
||||||
|
export type FollowUpReminderMetadata = {
|
||||||
|
/** 业务类型,BIRTHDAY 为客户生日提醒 */
|
||||||
|
bizType?: string;
|
||||||
|
/** 生日对应的公历日期 */
|
||||||
|
birthdaySolar?: string;
|
||||||
|
/** 生日对应的农历月日,仅农历生日有值 */
|
||||||
|
birthdayLunar?: string;
|
||||||
|
/** true 为闰月,仅农历生日有值 */
|
||||||
|
leapMonth?: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
/** 跟进提醒附件请求项。 */
|
/** 跟进提醒附件请求项。 */
|
||||||
export type FollowUpReminderAttachment = Partial<Attachment> & {
|
export type FollowUpReminderAttachment = Partial<Attachment> & {
|
||||||
name?: string;
|
name?: string;
|
||||||
@@ -21,6 +36,10 @@ export type FollowUpReminder = {
|
|||||||
content?: string;
|
content?: string;
|
||||||
remindAt?: number;
|
remindAt?: number;
|
||||||
status?: FollowUpReminderStatus;
|
status?: FollowUpReminderStatus;
|
||||||
|
source?: FollowUpReminderSource;
|
||||||
|
/** 系统创建的幂等键,手动创建为空 */
|
||||||
|
sourceKey?: string;
|
||||||
|
metadata?: FollowUpReminderMetadata;
|
||||||
internalNotifyEnabled?: boolean;
|
internalNotifyEnabled?: boolean;
|
||||||
smsNotifyEnabled?: boolean;
|
smsNotifyEnabled?: boolean;
|
||||||
internalNotifyDetailId?: string;
|
internalNotifyDetailId?: string;
|
||||||
|
|||||||
@@ -188,6 +188,10 @@ export const corePermissionCodes = {
|
|||||||
read: "CORE:NOTIFY:READ",
|
read: "CORE:NOTIFY:READ",
|
||||||
delete: "CORE:NOTIFY:DELETE",
|
delete: "CORE:NOTIFY:DELETE",
|
||||||
cancel: "CORE:NOTIFY:CANCEL"
|
cancel: "CORE:NOTIFY:CANCEL"
|
||||||
|
},
|
||||||
|
setting: {
|
||||||
|
read: "CORE:SETTING:READ",
|
||||||
|
update: "CORE:SETTING:UPDATE"
|
||||||
}
|
}
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user