feat:【antd】【crm】客户限制配置的重构与修复部分缺陷

This commit is contained in:
YunaiV
2025-09-27 17:19:54 +08:00
parent 082fddcb64
commit 45fb4dc3fe
3 changed files with 48 additions and 27 deletions

View File

@@ -3,6 +3,7 @@ import type { VbenFormSchema } from '@vben/common-ui';
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import { DICT_TYPE } from '@vben/constants';
import { getDictOptions } from '@vben/hooks';
import { handleTree } from '@vben/utils';
import { LimitConfType } from '#/api/crm/customer/limitConfig';
@@ -20,6 +21,14 @@ export function useFormSchema(confType: LimitConfType): VbenFormSchema[] {
show: () => false,
},
},
{
fieldName: 'type',
component: 'Input',
dependencies: {
triggerFields: [''],
show: () => false,
},
},
{
fieldName: 'userIds',
label: '规则适用人群',
@@ -30,10 +39,10 @@ export function useFormSchema(confType: LimitConfType): VbenFormSchema[] {
label: 'nickname',
value: 'id',
},
mode: 'tags',
mode: 'multiple',
allowClear: true,
placeholder: '请选择规则适用人群',
},
rules: 'required',
},
{
fieldName: 'deptIds',
@@ -49,7 +58,6 @@ export function useFormSchema(confType: LimitConfType): VbenFormSchema[] {
placeholder: '请选择规则适用部门',
treeDefaultExpandAll: true,
},
rules: 'required',
},
{
fieldName: 'maxCount',
@@ -58,21 +66,29 @@ export function useFormSchema(confType: LimitConfType): VbenFormSchema[] {
? '拥有客户数上限'
: '锁定客户数上限',
component: 'InputNumber',
componentProps: {
placeholder: `请输入${
LimitConfType.CUSTOMER_QUANTITY_LIMIT === confType
? '拥有客户数上限'
: '锁定客户数上限'
}`,
},
rules: 'required',
},
{
fieldName: 'dealCountEnabled',
label: '成交客户是否占用拥有客户数',
component: 'RadioGroup',
componentProps: {
options: [
{ label: '是', value: true },
{ label: '否', value: false },
],
options: getDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING, 'boolean'),
buttonStyle: 'solid',
optionType: 'button',
},
dependencies: {
triggerFields: [''],
show: () => confType === LimitConfType.CUSTOMER_QUANTITY_LIMIT,
},
defaultValue: false,
},
];
}

View File

@@ -21,16 +21,25 @@ import Form from './modules/form.vue';
const configType = ref(LimitConfType.CUSTOMER_QUANTITY_LIMIT);
/** 刷新表格 */
function onRefresh() {
gridApi.query();
}
const [FormModal, formModalApi] = useVbenModal({
connectedComponent: Form,
destroyOnClose: true,
});
/** 刷新表格 */
function handleRefresh() {
gridApi.query();
}
/** 处理配置类型的切换 */
function handleChangeConfigType(key: number | string) {
configType.value = key as LimitConfType;
gridApi.setGridOptions({
columns: useGridColumns(configType.value),
});
handleRefresh();
}
/** 创建规则 */
function handleCreate(type: LimitConfType) {
formModalApi.setData({ type }).open();
@@ -54,10 +63,8 @@ async function handleDelete(
});
try {
await deleteCustomerLimitConfig(row.id as number);
message.success({
content: $t('ui.actionMessage.deleteSuccess', [row.id]),
});
onRefresh();
message.success($t('ui.actionMessage.deleteSuccess', [row.id]));
handleRefresh();
} finally {
hideLoading();
}
@@ -82,6 +89,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
},
rowConfig: {
keyField: 'id',
isHover: true,
},
toolbarConfig: {
refresh: true,
@@ -89,14 +97,6 @@ const [Grid, gridApi] = useVbenVxeGrid({
},
} as VxeTableGridOptions<CrmCustomerLimitConfigApi.CustomerLimitConfig>,
});
function onChangeConfigType(key: number | string) {
configType.value = key as LimitConfType;
gridApi.setGridOptions({
columns: useGridColumns(configType.value),
});
onRefresh();
}
</script>
<template>
@@ -112,10 +112,10 @@ function onChangeConfigType(key: number | string) {
/>
</template>
<FormModal />
<FormModal @success="handleRefresh" />
<Grid>
<template #top>
<Tabs class="border-none" @change="onChangeConfigType">
<Tabs class="-mt-11" @change="handleChangeConfigType">
<Tabs.TabPane
tab="拥有客户数限制"
:key="LimitConfType.CUSTOMER_QUANTITY_LIMIT"
@@ -166,3 +166,8 @@ function onChangeConfigType(key: number | string) {
</Grid>
</Page>
</template>
<style scoped>
:deep(.vxe-toolbar div) {
z-index: 1;
}
</style>

View File

@@ -34,7 +34,7 @@ const [Form, formApi] = useVbenForm({
class: 'w-full',
},
formItemClass: 'col-span-2',
labelWidth: 120,
labelWidth: 200,
},
layout: 'horizontal',
schema: useFormSchema(confType.value),