feat: 分配客户
parent
cccd9ae856
commit
af4f7f9630
|
@ -17,6 +17,10 @@ import { useDescription } from '#/components/description';
|
||||||
|
|
||||||
import { useDetailSchema } from '../data';
|
import { useDetailSchema } from '../data';
|
||||||
|
|
||||||
|
const BusinessList = defineAsyncComponent(
|
||||||
|
() => import('#/views/crm/business/modules/detail-list.vue'),
|
||||||
|
);
|
||||||
|
|
||||||
const CustomerDetailsInfo = defineAsyncComponent(
|
const CustomerDetailsInfo = defineAsyncComponent(
|
||||||
() => import('./detail-info.vue'),
|
() => import('./detail-info.vue'),
|
||||||
);
|
);
|
||||||
|
@ -33,8 +37,8 @@ const CustomerForm = defineAsyncComponent(
|
||||||
() => import('#/views/crm/customer/modules/form.vue'),
|
() => import('#/views/crm/customer/modules/form.vue'),
|
||||||
);
|
);
|
||||||
|
|
||||||
const BusinessList = defineAsyncComponent(
|
const DistributeForm = defineAsyncComponent(
|
||||||
() => import('#/views/crm/business/modules/detail-list.vue'),
|
() => import('#/views/crm/customer/poolConfig/distribute-form.vue'),
|
||||||
);
|
);
|
||||||
|
|
||||||
const FollowUp = defineAsyncComponent(
|
const FollowUp = defineAsyncComponent(
|
||||||
|
@ -84,6 +88,11 @@ const [TransferModal, transferModalApi] = useVbenModal({
|
||||||
destroyOnClose: true,
|
destroyOnClose: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const [DistributeModal, distributeModalApi] = useVbenModal({
|
||||||
|
connectedComponent: DistributeForm,
|
||||||
|
destroyOnClose: true,
|
||||||
|
});
|
||||||
|
|
||||||
/** 加载详情 */
|
/** 加载详情 */
|
||||||
async function loadCustomerDetail() {
|
async function loadCustomerDetail() {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
|
@ -131,7 +140,7 @@ function handleReceive() {
|
||||||
|
|
||||||
/** 分配客户 */
|
/** 分配客户 */
|
||||||
function handleDistributeForm() {
|
function handleDistributeForm() {
|
||||||
transferModalApi.setData({ id: customerId.value }).open();
|
distributeModalApi.setData({ id: customerId.value }).open();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 客户放入公海 */
|
/** 客户放入公海 */
|
||||||
|
@ -175,6 +184,7 @@ onMounted(async () => {
|
||||||
<Page auto-content-height :title="customer?.name" :loading="loading">
|
<Page auto-content-height :title="customer?.name" :loading="loading">
|
||||||
<FormModal @success="loadCustomerDetail" />
|
<FormModal @success="loadCustomerDetail" />
|
||||||
<TransferModal @success="loadCustomerDetail" />
|
<TransferModal @success="loadCustomerDetail" />
|
||||||
|
<DistributeModal @success="loadCustomerDetail" />
|
||||||
<template #extra>
|
<template #extra>
|
||||||
<div class="flex items-center gap-2">
|
<div class="flex items-center gap-2">
|
||||||
<Button
|
<Button
|
||||||
|
@ -210,10 +220,18 @@ onMounted(async () => {
|
||||||
>
|
>
|
||||||
锁定
|
锁定
|
||||||
</Button>
|
</Button>
|
||||||
<Button v-if="!customer.ownerUserId" @click="handleReceive">
|
<Button
|
||||||
|
v-if="!customer.ownerUserId"
|
||||||
|
type="primary"
|
||||||
|
@click="handleReceive"
|
||||||
|
>
|
||||||
领取
|
领取
|
||||||
</Button>
|
</Button>
|
||||||
<Button v-if="!customer.ownerUserId" @click="handleDistributeForm">
|
<Button
|
||||||
|
v-if="!customer.ownerUserId"
|
||||||
|
type="primary"
|
||||||
|
@click="handleDistributeForm"
|
||||||
|
>
|
||||||
分配
|
分配
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
|
|
|
@ -0,0 +1,90 @@
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { useVbenModal } from '@vben/common-ui';
|
||||||
|
|
||||||
|
import { message } from 'ant-design-vue';
|
||||||
|
|
||||||
|
import { useVbenForm } from '#/adapter/form';
|
||||||
|
import { distributeCustomer } from '#/api/crm/customer';
|
||||||
|
import { getSimpleUserList } from '#/api/system/user';
|
||||||
|
import { $t } from '#/locales';
|
||||||
|
|
||||||
|
const emit = defineEmits(['success']);
|
||||||
|
|
||||||
|
const [Form, formApi] = useVbenForm({
|
||||||
|
commonConfig: {
|
||||||
|
componentProps: {
|
||||||
|
class: 'w-full',
|
||||||
|
},
|
||||||
|
formItemClass: 'col-span-2',
|
||||||
|
labelWidth: 120,
|
||||||
|
},
|
||||||
|
layout: 'horizontal',
|
||||||
|
schema: [
|
||||||
|
{
|
||||||
|
component: 'Input',
|
||||||
|
fieldName: 'id',
|
||||||
|
dependencies: {
|
||||||
|
triggerFields: [''],
|
||||||
|
show: () => false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'ownerUserId',
|
||||||
|
label: '负责人',
|
||||||
|
component: 'ApiSelect',
|
||||||
|
componentProps: {
|
||||||
|
api: () => getSimpleUserList(),
|
||||||
|
fieldNames: {
|
||||||
|
label: 'nickname',
|
||||||
|
value: 'id',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
rules: 'required',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
showDefaultActions: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
const [Modal, modalApi] = useVbenModal({
|
||||||
|
async onConfirm() {
|
||||||
|
const { valid } = await formApi.validate();
|
||||||
|
if (!valid) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
modalApi.lock();
|
||||||
|
// 提交表单
|
||||||
|
const data = await formApi.getValues();
|
||||||
|
try {
|
||||||
|
await distributeCustomer([data.id], data.ownerUserId);
|
||||||
|
// 关闭并提示
|
||||||
|
await modalApi.close();
|
||||||
|
emit('success');
|
||||||
|
message.success($t('ui.actionMessage.operationSuccess'));
|
||||||
|
} finally {
|
||||||
|
modalApi.unlock();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async onOpenChange(isOpen: boolean) {
|
||||||
|
if (!isOpen) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 加载数据
|
||||||
|
const data = modalApi.getData();
|
||||||
|
if (!data || !data.id) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
modalApi.lock();
|
||||||
|
try {
|
||||||
|
await formApi.setValues(data);
|
||||||
|
} finally {
|
||||||
|
modalApi.unlock();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Modal title="分配客户" class="w-[40%]">
|
||||||
|
<Form class="mx-4" />
|
||||||
|
</Modal>
|
||||||
|
</template>
|
Loading…
Reference in New Issue