gaoluyang
2026-06-24 712aa51536236d43e87273e4ce45ac5691dffad8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<script lang="ts" setup>
import type { CrmCustomerPoolConfigApi } from '#/api/crm/customer/poolConfig';
 
import { onMounted } from 'vue';
 
import { Page } from '..\..\..\..\packages\effects\common-ui\src';
 
import { Card, message } from 'ant-design-vue';
 
import { useVbenForm } from '#/adapter/form';
import {
  getCustomerPoolConfig,
  saveCustomerPoolConfig,
} from '#/api/crm/customer/poolConfig';
import { $t } from '#/locales';
 
import { schema } from './data';
 
const [Form, formApi] = useVbenForm({
  commonConfig: {
    labelWidth: 120,
  },
  layout: 'horizontal',
  schema,
  handleSubmit,
});
 
/** 提交表单 */
async function handleSubmit() {
  const { valid } = await formApi.validate();
  if (!valid) {
    return;
  }
  // 提交表单
  const data =
    (await formApi.getValues()) as CrmCustomerPoolConfigApi.CustomerPoolConfig;
  if (!data.enabled) {
    data.contactExpireDays = undefined;
    data.dealExpireDays = undefined;
    data.notifyEnabled = false;
  }
  if (!data.notifyEnabled) {
    data.notifyDays = undefined;
  }
  await saveCustomerPoolConfig(data);
  // 关闭并提示
  await formApi.setValues(data);
  message.success($t('ui.actionMessage.operationSuccess'));
}
 
/** 获取配置 */
async function getConfigInfo() {
  const res = await getCustomerPoolConfig();
  await formApi.setValues(res);
}
 
/** 初始化 */
onMounted(() => {
  getConfigInfo();
});
</script>
 
<template>
  <Page auto-content-height>
    <Card title="客户公海规则设置">
      <Form class="w-1/4" />
    </Card>
  </Page>
</template>