feat: add permission comps
parent
861ec5281d
commit
0cdd05991d
|
@ -0,0 +1,2 @@
|
||||||
|
export { default as PermissionList } from './modules/permission-list.vue';
|
||||||
|
export { default as TransferForm } from './modules/transfer-form.vue';
|
|
@ -0,0 +1,162 @@
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import type { CrmPermissionApi } from '#/api/crm/permission';
|
||||||
|
|
||||||
|
import { computed, ref } from 'vue';
|
||||||
|
|
||||||
|
import { useVbenModal } from '@vben/common-ui';
|
||||||
|
|
||||||
|
import { message } from 'ant-design-vue';
|
||||||
|
|
||||||
|
import { useVbenForm } from '#/adapter/form';
|
||||||
|
import {
|
||||||
|
BizTypeEnum,
|
||||||
|
createPermission,
|
||||||
|
PermissionLevelEnum,
|
||||||
|
updatePermission,
|
||||||
|
} from '#/api/crm/permission';
|
||||||
|
import { getSimpleUserList } from '#/api/system/user';
|
||||||
|
import { $t } from '#/locales';
|
||||||
|
import { DICT_TYPE, getDictOptions } from '#/utils';
|
||||||
|
|
||||||
|
const emit = defineEmits(['success']);
|
||||||
|
const formData = ref<CrmPermissionApi.Permission>();
|
||||||
|
const getTitle = computed(() => {
|
||||||
|
return formData.value?.ids
|
||||||
|
? $t('ui.actionTitle.edit', ['团队成员'])
|
||||||
|
: $t('ui.actionTitle.create', ['团队成员']);
|
||||||
|
});
|
||||||
|
|
||||||
|
const [Form, formApi] = useVbenForm({
|
||||||
|
commonConfig: {
|
||||||
|
componentProps: {
|
||||||
|
class: 'w-full',
|
||||||
|
},
|
||||||
|
formItemClass: 'col-span-2',
|
||||||
|
labelWidth: 80,
|
||||||
|
},
|
||||||
|
layout: 'horizontal',
|
||||||
|
schema: [
|
||||||
|
{
|
||||||
|
fieldName: 'ids',
|
||||||
|
component: 'Input',
|
||||||
|
dependencies: {
|
||||||
|
triggerFields: [''],
|
||||||
|
show: () => false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'userId',
|
||||||
|
label: '选择人员',
|
||||||
|
component: 'ApiSelect',
|
||||||
|
componentProps: {
|
||||||
|
api: getSimpleUserList,
|
||||||
|
labelField: 'nickname',
|
||||||
|
valueField: 'id',
|
||||||
|
},
|
||||||
|
dependencies: {
|
||||||
|
triggerFields: ['ids'],
|
||||||
|
show: (values) => {
|
||||||
|
return values.ids === undefined;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'level',
|
||||||
|
label: '权限级别',
|
||||||
|
component: 'RadioGroup',
|
||||||
|
componentProps: {
|
||||||
|
options: getDictOptions(
|
||||||
|
DICT_TYPE.CRM_PERMISSION_LEVEL,
|
||||||
|
'number',
|
||||||
|
).filter((dict) => dict.value !== PermissionLevelEnum.OWNER),
|
||||||
|
},
|
||||||
|
rules: 'required',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'toBizTypes',
|
||||||
|
label: '同时添加至',
|
||||||
|
component: 'CheckboxGroup',
|
||||||
|
componentProps: {
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
label: '联系人',
|
||||||
|
value: BizTypeEnum.CRM_CONTACT,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '商机',
|
||||||
|
value: BizTypeEnum.CRM_BUSINESS,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '合同',
|
||||||
|
value: BizTypeEnum.CRM_CONTRACT,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
dependencies: {
|
||||||
|
triggerFields: ['ids', 'bizType'],
|
||||||
|
show: (values) => {
|
||||||
|
return (
|
||||||
|
values.ids === undefined &&
|
||||||
|
formData.value?.bizType === BizTypeEnum.CRM_CUSTOMER
|
||||||
|
);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
showDefaultActions: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
const [Modal, modalApi] = useVbenModal({
|
||||||
|
async onConfirm() {
|
||||||
|
const { valid } = await formApi.validate();
|
||||||
|
if (!valid) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
modalApi.lock();
|
||||||
|
// 提交表单
|
||||||
|
const data = (await formApi.getValues()) as CrmPermissionApi.Permission;
|
||||||
|
try {
|
||||||
|
await (formData.value?.ids
|
||||||
|
? updatePermission(data)
|
||||||
|
: createPermission(data));
|
||||||
|
// 关闭并提示
|
||||||
|
await modalApi.close();
|
||||||
|
emit('success');
|
||||||
|
message.success($t('ui.actionMessage.operationSuccess'));
|
||||||
|
} finally {
|
||||||
|
modalApi.unlock();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async onOpenChange(isOpen: boolean) {
|
||||||
|
if (!isOpen) {
|
||||||
|
formData.value = undefined;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 加载数据
|
||||||
|
const data = modalApi.getData();
|
||||||
|
if (!data || !data.bizType || !data.bizId) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
modalApi.lock();
|
||||||
|
try {
|
||||||
|
formData.value = {
|
||||||
|
ids: data.ids || [data.id] || undefined,
|
||||||
|
userId: undefined,
|
||||||
|
bizType: data.bizType,
|
||||||
|
bizId: data.bizId,
|
||||||
|
level: data.level,
|
||||||
|
};
|
||||||
|
// 设置到 values
|
||||||
|
await formApi.setValues(formData.value);
|
||||||
|
} finally {
|
||||||
|
modalApi.unlock();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Modal class="w-[600px]" :title="getTitle">
|
||||||
|
<Form class="mx-4" />
|
||||||
|
</Modal>
|
||||||
|
</template>
|
|
@ -0,0 +1,277 @@
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||||
|
import type { CrmPermissionApi } from '#/api/crm/permission';
|
||||||
|
|
||||||
|
import { ref, watch } from 'vue';
|
||||||
|
|
||||||
|
import { confirm, useVbenModal } from '@vben/common-ui';
|
||||||
|
import { useUserStore } from '@vben/stores';
|
||||||
|
|
||||||
|
import { message } from 'ant-design-vue';
|
||||||
|
|
||||||
|
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||||
|
import {
|
||||||
|
deletePermissionBatch,
|
||||||
|
deleteSelfPermission,
|
||||||
|
getPermissionList,
|
||||||
|
PermissionLevelEnum,
|
||||||
|
} from '#/api/crm/permission';
|
||||||
|
import { $t } from '#/locales';
|
||||||
|
import { DICT_TYPE } from '#/utils';
|
||||||
|
|
||||||
|
import Form from './permission-form.vue';
|
||||||
|
|
||||||
|
defineOptions({ name: 'CrmPermissionList' });
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
bizId: number; // 模块数据编号
|
||||||
|
bizType: number; // 模块类型
|
||||||
|
showAction: boolean; // 是否展示操作按钮
|
||||||
|
}>();
|
||||||
|
|
||||||
|
const emits = defineEmits<{
|
||||||
|
(e: 'quitTeam'): void;
|
||||||
|
}>();
|
||||||
|
|
||||||
|
const [FormModal, formModalApi] = useVbenModal({
|
||||||
|
connectedComponent: Form,
|
||||||
|
destroyOnClose: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
// 校验负责人权限和编辑权限
|
||||||
|
const validateOwnerUser = ref(false);
|
||||||
|
const validateWrite = ref(false);
|
||||||
|
const isPool = ref(false);
|
||||||
|
|
||||||
|
/** 刷新表格 */
|
||||||
|
function onRefresh() {
|
||||||
|
gridApi.query();
|
||||||
|
}
|
||||||
|
|
||||||
|
const checkedIds = ref<CrmPermissionApi.Permission[]>([]);
|
||||||
|
function setCheckedIds({
|
||||||
|
records,
|
||||||
|
}: {
|
||||||
|
records: CrmPermissionApi.Permission[];
|
||||||
|
}) {
|
||||||
|
checkedIds.value = records;
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleCreate() {
|
||||||
|
formModalApi
|
||||||
|
.setData({
|
||||||
|
bizType: props.bizType,
|
||||||
|
bizId: props.bizId,
|
||||||
|
})
|
||||||
|
.open();
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleEdit() {
|
||||||
|
formModalApi
|
||||||
|
.setData({
|
||||||
|
bizType: props.bizType,
|
||||||
|
bizId: props.bizId,
|
||||||
|
id: checkedIds.value[0]?.id,
|
||||||
|
level: checkedIds.value[0]?.level,
|
||||||
|
})
|
||||||
|
.open();
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleDelete() {
|
||||||
|
if (checkedIds.value.length === 0) {
|
||||||
|
message.error('请先选择团队成员后操作!');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
confirm({
|
||||||
|
content: `你要将${checkedIds.value.map((item) => item.nickname).join(',')}移出团队吗?`,
|
||||||
|
})
|
||||||
|
.then(async () => {
|
||||||
|
// 更新用户状态
|
||||||
|
const res = await deletePermissionBatch(
|
||||||
|
checkedIds.value.map((item) => item.id as number),
|
||||||
|
);
|
||||||
|
if (res) {
|
||||||
|
// 提示并返回成功
|
||||||
|
message.success($t('ui.actionMessage.operationSuccess'));
|
||||||
|
resolve(true);
|
||||||
|
} else {
|
||||||
|
reject(new Error('移出失败'));
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
reject(new Error('取消操作'));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const userStore = useUserStore();
|
||||||
|
|
||||||
|
async function handleQuit() {
|
||||||
|
const permission = gridApi.grid
|
||||||
|
.getData()
|
||||||
|
.find(
|
||||||
|
(item) =>
|
||||||
|
item.id === userStore.userInfo?.userId &&
|
||||||
|
item.level === PermissionLevelEnum.OWNER,
|
||||||
|
);
|
||||||
|
if (permission) {
|
||||||
|
message.warning('负责人不能退出团队!');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const userPermission = gridApi.grid
|
||||||
|
.getData()
|
||||||
|
.find((item) => item.id === userStore.userInfo?.userId);
|
||||||
|
if (!userPermission) {
|
||||||
|
message.warning('你不是团队成员!');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
await deleteSelfPermission(userPermission.id);
|
||||||
|
message.success('退出团队成员成功!');
|
||||||
|
emits('quitTeam');
|
||||||
|
}
|
||||||
|
|
||||||
|
const [Grid, gridApi] = useVbenVxeGrid({
|
||||||
|
gridOptions: {
|
||||||
|
columns: [
|
||||||
|
{
|
||||||
|
type: 'checkbox',
|
||||||
|
width: 50,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'nickname',
|
||||||
|
title: '姓名',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'deptName',
|
||||||
|
title: '部门',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'postNames',
|
||||||
|
title: '岗位',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'level',
|
||||||
|
title: '权限级别',
|
||||||
|
cellRender: {
|
||||||
|
name: 'CellDict',
|
||||||
|
props: { type: DICT_TYPE.CRM_PERMISSION_LEVEL },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'createTime',
|
||||||
|
title: '加入时间',
|
||||||
|
formatter: 'formatDateTime',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
height: 'auto',
|
||||||
|
pagerConfig: {
|
||||||
|
enabled: false,
|
||||||
|
},
|
||||||
|
proxyConfig: {
|
||||||
|
ajax: {
|
||||||
|
query: async (_params) => {
|
||||||
|
const res = await getPermissionList({
|
||||||
|
bizId: props.bizId,
|
||||||
|
bizType: props.bizType,
|
||||||
|
});
|
||||||
|
return res;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
rowConfig: {
|
||||||
|
keyField: 'id',
|
||||||
|
isHover: true,
|
||||||
|
},
|
||||||
|
toolbarConfig: {
|
||||||
|
refresh: { code: 'query' },
|
||||||
|
search: true,
|
||||||
|
},
|
||||||
|
} as VxeTableGridOptions<CrmPermissionApi.Permission>,
|
||||||
|
gridEvents: {
|
||||||
|
checkboxAll: setCheckedIds,
|
||||||
|
checkboxChange: setCheckedIds,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
defineExpose({
|
||||||
|
openForm: handleCreate,
|
||||||
|
validateOwnerUser,
|
||||||
|
validateWrite,
|
||||||
|
isPool,
|
||||||
|
});
|
||||||
|
watch(
|
||||||
|
() => gridApi.grid.getData(),
|
||||||
|
(data) => {
|
||||||
|
isPool.value = false;
|
||||||
|
if (data.length > 0) {
|
||||||
|
isPool.value = gridApi.grid
|
||||||
|
.getData()
|
||||||
|
.some((item) => item.level === PermissionLevelEnum.OWNER);
|
||||||
|
validateOwnerUser.value = false;
|
||||||
|
validateWrite.value = false;
|
||||||
|
const userId = userStore.userInfo?.userId;
|
||||||
|
gridApi.grid
|
||||||
|
.getData()
|
||||||
|
.filter((item) => item.userId === userId)
|
||||||
|
.forEach((item) => {
|
||||||
|
if (item.level === PermissionLevelEnum.OWNER) {
|
||||||
|
validateOwnerUser.value = true;
|
||||||
|
validateWrite.value = true;
|
||||||
|
} else if (item.level === PermissionLevelEnum.WRITE) {
|
||||||
|
validateWrite.value = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
isPool.value = true;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
immediate: true,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<FormModal @success="onRefresh" />
|
||||||
|
<Grid>
|
||||||
|
<template #toolbar-tools>
|
||||||
|
<TableAction
|
||||||
|
:actions="[
|
||||||
|
{
|
||||||
|
label: $t('common.create'),
|
||||||
|
type: 'primary',
|
||||||
|
icon: ACTION_ICON.ADD,
|
||||||
|
ifShow: validateOwnerUser,
|
||||||
|
onClick: handleCreate,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: $t('common.edit'),
|
||||||
|
type: 'primary',
|
||||||
|
icon: ACTION_ICON.EDIT,
|
||||||
|
ifShow: validateOwnerUser,
|
||||||
|
onClick: handleEdit,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: $t('common.delete'),
|
||||||
|
type: 'primary',
|
||||||
|
danger: true,
|
||||||
|
icon: ACTION_ICON.DELETE,
|
||||||
|
ifShow: validateOwnerUser,
|
||||||
|
onClick: handleDelete,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '退出团队',
|
||||||
|
type: 'primary',
|
||||||
|
danger: true,
|
||||||
|
ifShow: !validateOwnerUser,
|
||||||
|
onClick: handleQuit,
|
||||||
|
},
|
||||||
|
]"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</Grid>
|
||||||
|
</div>
|
||||||
|
</template>
|
|
@ -0,0 +1,202 @@
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import type { CrmPermissionApi } from '#/api/crm/permission';
|
||||||
|
|
||||||
|
import { computed } from 'vue';
|
||||||
|
|
||||||
|
import { useVbenModal } from '@vben/common-ui';
|
||||||
|
|
||||||
|
import { message } from 'ant-design-vue';
|
||||||
|
|
||||||
|
import { useVbenForm } from '#/adapter/form';
|
||||||
|
import { transferBusiness } from '#/api/crm/business';
|
||||||
|
import { transferClue } from '#/api/crm/clue';
|
||||||
|
import { transferContact } from '#/api/crm/contact';
|
||||||
|
import { transferContract } from '#/api/crm/contract';
|
||||||
|
import { transferCustomer } from '#/api/crm/customer';
|
||||||
|
import { BizTypeEnum, PermissionLevelEnum } from '#/api/crm/permission';
|
||||||
|
import { getSimpleUserList } from '#/api/system/user';
|
||||||
|
import { $t } from '#/locales';
|
||||||
|
import { DICT_TYPE, getDictOptions } from '#/utils';
|
||||||
|
|
||||||
|
defineOptions({ name: 'CrmTransferForm' });
|
||||||
|
|
||||||
|
const emit = defineEmits(['success']);
|
||||||
|
|
||||||
|
const bizType = defineModel<number>('bizType');
|
||||||
|
|
||||||
|
const getTitle = computed(() => {
|
||||||
|
switch (bizType.value) {
|
||||||
|
case BizTypeEnum.CRM_BUSINESS: {
|
||||||
|
return '商机转移';
|
||||||
|
}
|
||||||
|
case BizTypeEnum.CRM_CLUE: {
|
||||||
|
return '线索转移';
|
||||||
|
}
|
||||||
|
case BizTypeEnum.CRM_CONTACT: {
|
||||||
|
return '联系人转移';
|
||||||
|
}
|
||||||
|
case BizTypeEnum.CRM_CONTRACT: {
|
||||||
|
return '合同转移';
|
||||||
|
}
|
||||||
|
case BizTypeEnum.CRM_CUSTOMER: {
|
||||||
|
return '客户转移';
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
return '转移';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const [Form, formApi] = useVbenForm({
|
||||||
|
commonConfig: {
|
||||||
|
componentProps: {
|
||||||
|
class: 'w-full',
|
||||||
|
},
|
||||||
|
formItemClass: 'col-span-2',
|
||||||
|
labelWidth: 120,
|
||||||
|
},
|
||||||
|
layout: 'horizontal',
|
||||||
|
schema: [
|
||||||
|
{
|
||||||
|
fieldName: 'id',
|
||||||
|
component: 'Input',
|
||||||
|
dependencies: {
|
||||||
|
triggerFields: [''],
|
||||||
|
show: () => false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'ownerUserId',
|
||||||
|
label: '选择新负责人',
|
||||||
|
component: 'ApiSelect',
|
||||||
|
componentProps: {
|
||||||
|
api: getSimpleUserList,
|
||||||
|
labelField: 'nickname',
|
||||||
|
valueField: 'id',
|
||||||
|
},
|
||||||
|
rules: 'required',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'oldOwnerHandler',
|
||||||
|
label: '老负责人',
|
||||||
|
component: 'RadioGroup',
|
||||||
|
componentProps: {
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
label: '加入团队',
|
||||||
|
value: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '移除',
|
||||||
|
value: false,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
rules: 'required',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'oldOwnerPermissionLevel',
|
||||||
|
label: '老负责人权限级别',
|
||||||
|
component: 'RadioGroup',
|
||||||
|
componentProps: {
|
||||||
|
options: getDictOptions(
|
||||||
|
DICT_TYPE.CRM_PERMISSION_LEVEL,
|
||||||
|
'number',
|
||||||
|
).filter((dict) => dict.value !== PermissionLevelEnum.OWNER),
|
||||||
|
},
|
||||||
|
dependencies: {
|
||||||
|
triggerFields: ['oldOwnerHandler'],
|
||||||
|
show: (values) => values.oldOwnerHandler,
|
||||||
|
trigger(values) {
|
||||||
|
if (!values.oldOwnerHandler) {
|
||||||
|
formApi.setFieldValue('oldOwnerPermissionLevel', undefined);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
rules: 'required',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'toBizTypes',
|
||||||
|
label: '同时转移',
|
||||||
|
component: 'CheckboxGroup',
|
||||||
|
componentProps: {
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
label: '联系人',
|
||||||
|
value: BizTypeEnum.CRM_CONTACT,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '商机',
|
||||||
|
value: BizTypeEnum.CRM_BUSINESS,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '合同',
|
||||||
|
value: BizTypeEnum.CRM_CONTRACT,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
showDefaultActions: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
const [Modal, modalApi] = useVbenModal({
|
||||||
|
async onConfirm() {
|
||||||
|
const { valid } = await formApi.validate();
|
||||||
|
if (!valid) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
modalApi.lock();
|
||||||
|
// 提交表单
|
||||||
|
const data = (await formApi.getValues()) as CrmPermissionApi.TransferReq;
|
||||||
|
try {
|
||||||
|
switch (bizType.value) {
|
||||||
|
case BizTypeEnum.CRM_BUSINESS: {
|
||||||
|
return await transferBusiness(data);
|
||||||
|
}
|
||||||
|
case BizTypeEnum.CRM_CLUE: {
|
||||||
|
return await transferClue(data);
|
||||||
|
}
|
||||||
|
case BizTypeEnum.CRM_CONTACT: {
|
||||||
|
return await transferContact(data);
|
||||||
|
}
|
||||||
|
case BizTypeEnum.CRM_CONTRACT: {
|
||||||
|
return await transferContract(data);
|
||||||
|
}
|
||||||
|
case BizTypeEnum.CRM_CUSTOMER: {
|
||||||
|
return await transferCustomer(data);
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
message.error('【转移失败】没有转移接口');
|
||||||
|
throw new Error('【转移失败】没有转移接口');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
// 关闭并提示
|
||||||
|
await modalApi.close();
|
||||||
|
emit('success');
|
||||||
|
message.success($t('ui.actionMessage.operationSuccess'));
|
||||||
|
modalApi.unlock();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async onOpenChange(isOpen: boolean) {
|
||||||
|
if (!isOpen) {
|
||||||
|
formApi.resetForm();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 加载数据
|
||||||
|
const data = modalApi.getData<{ bizType: number }>();
|
||||||
|
if (!data || !data.bizType) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
bizType.value = data.bizType;
|
||||||
|
formApi.setFieldValue('id', data.bizType);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Modal :title="getTitle" class="w-[40%]">
|
||||||
|
<Form class="mx-4" />
|
||||||
|
</Modal>
|
||||||
|
</template>
|
Loading…
Reference in New Issue