feat:【antd】【crm】客户限制配置的重构与修复部分缺陷
This commit is contained in:
@@ -3,6 +3,7 @@ import type { VbenFormSchema } from '@vben/common-ui';
|
|||||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||||
|
|
||||||
import { DICT_TYPE } from '@vben/constants';
|
import { DICT_TYPE } from '@vben/constants';
|
||||||
|
import { getDictOptions } from '@vben/hooks';
|
||||||
import { handleTree } from '@vben/utils';
|
import { handleTree } from '@vben/utils';
|
||||||
|
|
||||||
import { LimitConfType } from '#/api/crm/customer/limitConfig';
|
import { LimitConfType } from '#/api/crm/customer/limitConfig';
|
||||||
@@ -20,6 +21,14 @@ export function useFormSchema(confType: LimitConfType): VbenFormSchema[] {
|
|||||||
show: () => false,
|
show: () => false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'type',
|
||||||
|
component: 'Input',
|
||||||
|
dependencies: {
|
||||||
|
triggerFields: [''],
|
||||||
|
show: () => false,
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
fieldName: 'userIds',
|
fieldName: 'userIds',
|
||||||
label: '规则适用人群',
|
label: '规则适用人群',
|
||||||
@@ -30,10 +39,10 @@ export function useFormSchema(confType: LimitConfType): VbenFormSchema[] {
|
|||||||
label: 'nickname',
|
label: 'nickname',
|
||||||
value: 'id',
|
value: 'id',
|
||||||
},
|
},
|
||||||
mode: 'tags',
|
mode: 'multiple',
|
||||||
allowClear: true,
|
allowClear: true,
|
||||||
|
placeholder: '请选择规则适用人群',
|
||||||
},
|
},
|
||||||
rules: 'required',
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
fieldName: 'deptIds',
|
fieldName: 'deptIds',
|
||||||
@@ -49,7 +58,6 @@ export function useFormSchema(confType: LimitConfType): VbenFormSchema[] {
|
|||||||
placeholder: '请选择规则适用部门',
|
placeholder: '请选择规则适用部门',
|
||||||
treeDefaultExpandAll: true,
|
treeDefaultExpandAll: true,
|
||||||
},
|
},
|
||||||
rules: 'required',
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
fieldName: 'maxCount',
|
fieldName: 'maxCount',
|
||||||
@@ -58,21 +66,29 @@ export function useFormSchema(confType: LimitConfType): VbenFormSchema[] {
|
|||||||
? '拥有客户数上限'
|
? '拥有客户数上限'
|
||||||
: '锁定客户数上限',
|
: '锁定客户数上限',
|
||||||
component: 'InputNumber',
|
component: 'InputNumber',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: `请输入${
|
||||||
|
LimitConfType.CUSTOMER_QUANTITY_LIMIT === confType
|
||||||
|
? '拥有客户数上限'
|
||||||
|
: '锁定客户数上限'
|
||||||
|
}`,
|
||||||
|
},
|
||||||
|
rules: 'required',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
fieldName: 'dealCountEnabled',
|
fieldName: 'dealCountEnabled',
|
||||||
label: '成交客户是否占用拥有客户数',
|
label: '成交客户是否占用拥有客户数',
|
||||||
component: 'RadioGroup',
|
component: 'RadioGroup',
|
||||||
componentProps: {
|
componentProps: {
|
||||||
options: [
|
options: getDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING, 'boolean'),
|
||||||
{ label: '是', value: true },
|
buttonStyle: 'solid',
|
||||||
{ label: '否', value: false },
|
optionType: 'button',
|
||||||
],
|
|
||||||
},
|
},
|
||||||
dependencies: {
|
dependencies: {
|
||||||
triggerFields: [''],
|
triggerFields: [''],
|
||||||
show: () => confType === LimitConfType.CUSTOMER_QUANTITY_LIMIT,
|
show: () => confType === LimitConfType.CUSTOMER_QUANTITY_LIMIT,
|
||||||
},
|
},
|
||||||
|
defaultValue: false,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,16 +21,25 @@ import Form from './modules/form.vue';
|
|||||||
|
|
||||||
const configType = ref(LimitConfType.CUSTOMER_QUANTITY_LIMIT);
|
const configType = ref(LimitConfType.CUSTOMER_QUANTITY_LIMIT);
|
||||||
|
|
||||||
/** 刷新表格 */
|
|
||||||
function onRefresh() {
|
|
||||||
gridApi.query();
|
|
||||||
}
|
|
||||||
|
|
||||||
const [FormModal, formModalApi] = useVbenModal({
|
const [FormModal, formModalApi] = useVbenModal({
|
||||||
connectedComponent: Form,
|
connectedComponent: Form,
|
||||||
destroyOnClose: true,
|
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) {
|
function handleCreate(type: LimitConfType) {
|
||||||
formModalApi.setData({ type }).open();
|
formModalApi.setData({ type }).open();
|
||||||
@@ -54,10 +63,8 @@ async function handleDelete(
|
|||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
await deleteCustomerLimitConfig(row.id as number);
|
await deleteCustomerLimitConfig(row.id as number);
|
||||||
message.success({
|
message.success($t('ui.actionMessage.deleteSuccess', [row.id]));
|
||||||
content: $t('ui.actionMessage.deleteSuccess', [row.id]),
|
handleRefresh();
|
||||||
});
|
|
||||||
onRefresh();
|
|
||||||
} finally {
|
} finally {
|
||||||
hideLoading();
|
hideLoading();
|
||||||
}
|
}
|
||||||
@@ -82,6 +89,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
|||||||
},
|
},
|
||||||
rowConfig: {
|
rowConfig: {
|
||||||
keyField: 'id',
|
keyField: 'id',
|
||||||
|
isHover: true,
|
||||||
},
|
},
|
||||||
toolbarConfig: {
|
toolbarConfig: {
|
||||||
refresh: true,
|
refresh: true,
|
||||||
@@ -89,14 +97,6 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
|||||||
},
|
},
|
||||||
} as VxeTableGridOptions<CrmCustomerLimitConfigApi.CustomerLimitConfig>,
|
} as VxeTableGridOptions<CrmCustomerLimitConfigApi.CustomerLimitConfig>,
|
||||||
});
|
});
|
||||||
|
|
||||||
function onChangeConfigType(key: number | string) {
|
|
||||||
configType.value = key as LimitConfType;
|
|
||||||
gridApi.setGridOptions({
|
|
||||||
columns: useGridColumns(configType.value),
|
|
||||||
});
|
|
||||||
onRefresh();
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -112,10 +112,10 @@ function onChangeConfigType(key: number | string) {
|
|||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<FormModal />
|
<FormModal @success="handleRefresh" />
|
||||||
<Grid>
|
<Grid>
|
||||||
<template #top>
|
<template #top>
|
||||||
<Tabs class="border-none" @change="onChangeConfigType">
|
<Tabs class="-mt-11" @change="handleChangeConfigType">
|
||||||
<Tabs.TabPane
|
<Tabs.TabPane
|
||||||
tab="拥有客户数限制"
|
tab="拥有客户数限制"
|
||||||
:key="LimitConfType.CUSTOMER_QUANTITY_LIMIT"
|
:key="LimitConfType.CUSTOMER_QUANTITY_LIMIT"
|
||||||
@@ -166,3 +166,8 @@ function onChangeConfigType(key: number | string) {
|
|||||||
</Grid>
|
</Grid>
|
||||||
</Page>
|
</Page>
|
||||||
</template>
|
</template>
|
||||||
|
<style scoped>
|
||||||
|
:deep(.vxe-toolbar div) {
|
||||||
|
z-index: 1;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ const [Form, formApi] = useVbenForm({
|
|||||||
class: 'w-full',
|
class: 'w-full',
|
||||||
},
|
},
|
||||||
formItemClass: 'col-span-2',
|
formItemClass: 'col-span-2',
|
||||||
labelWidth: 120,
|
labelWidth: 200,
|
||||||
},
|
},
|
||||||
layout: 'horizontal',
|
layout: 'horizontal',
|
||||||
schema: useFormSchema(confType.value),
|
schema: useFormSchema(confType.value),
|
||||||
|
|||||||
Reference in New Issue
Block a user