feat: CRM 客户公海配置

(cherry picked from commit 288aa72cdd)
This commit is contained in:
Wanwan 2023-11-09 00:05:10 +08:00 committed by shizhong
parent 2d838325c9
commit c3dc0836c2
2 changed files with 153 additions and 0 deletions

View File

@ -0,0 +1,19 @@
import request from '@/config/axios'
export interface CustomerPoolConfigVO {
enabled?: boolean
contactExpireDays?: number
dealExpireDays?: number
notifyEnabled?: boolean
notifyDays: number
}
// 获取客户公海规则设置
export const getCustomerPoolConfig = async () => {
return await request.get({ url: `/crm/customer-pool-config/get` })
}
// 更新客户公海规则设置
export const updateCustomerPoolConfig = async (data: ConfigVO) => {
return await request.put({ url: `/crm/customer-pool-config/update`, data })
}

View File

@ -0,0 +1,134 @@
<template>
<ContentWrap>
<el-form
ref="formRef"
:model="formData"
:rules="formRules"
label-width="160px"
v-loading="formLoading"
>
<el-card shadow="never">
<template #header>
<div class="flex items-center justify-between">
<CardTitle title="客户公海规则设置" />
<el-button type="primary" @click="onSubmit">保存</el-button>
</div>
</template>
<el-form-item label="客户公海规则设置" prop="enabled">
<el-radio-group v-model="formData.enabled" class="ml-4">
<el-radio :label="false" size="large">不启用</el-radio>
<el-radio :label="true" size="large">启用</el-radio>
</el-radio-group>
</el-form-item>
<div v-if="formData.enabled">
<el-form-item>
<el-input-number class="mr-2" v-model="formData.contactExpireDays" />
天不跟进或
<el-input-number class="mx-2" v-model="formData.dealExpireDays" />
天未成交
</el-form-item>
<el-form-item label="提前提醒设置" prop="notifyEnabled">
<el-radio-group v-model="formData.notifyEnabled" class="ml-4">
<el-radio :label="false" size="large">不提醒</el-radio>
<el-radio :label="true" size="large">提醒</el-radio>
</el-radio-group>
</el-form-item>
<div v-if="formData.notifyEnabled">
<el-form-item>
提前
<el-input-number class="mx-2" v-model="formData.notifyDays" />
天提醒
</el-form-item>
</div>
</div>
</el-card>
</el-form>
</ContentWrap>
</template>
<script setup lang="ts">
import * as CustomerPoolConfApi from '@/api/crm/customerPoolConf'
import { CardTitle } from '@/components/Card'
import { CustomerPoolConfigVO } from '@/api/crm/customerPoolConf'
defineOptions({ name: 'CustomerPoolConf' })
const message = useMessage() //
const { t } = useI18n() //
const formLoading = ref(false)
const formData = ref({
enabled: false,
contactExpireDays: 0,
dealExpireDays: 0,
notifyEnabled: false,
notifyDays: 0
})
const formRules = reactive({
enabled: [{ required: true, message: '是否启用客户公海不能为空', trigger: 'blur' }]
})
const formRef = ref() // Ref
/**
* 获取配置
*/
const getConfig = async () => {
try {
formLoading.value = true
const data = await CustomerPoolConfApi.getCustomerPoolConfig()
if (data === null) {
return
}
formData.value = data
console.log(formData.value)
} finally {
formLoading.value = false
}
}
/**
* 提交配置
*/
const onSubmit = async () => {
//
if (!formRef) return
const valid = await formRef.value.validate()
if (!valid) return
//
formLoading.value = true
try {
const data = formData.value as unknown as CustomerPoolConfApi.CustomerPoolConfigVO
await CustomerPoolConfApi.updateCustomerPoolConfig(data)
message.success(t('common.updateSuccess'))
dialogVisible.value = false
} finally {
formLoading.value = false
}
}
watch(
() => formData.value.enabled,
(val: boolean) => {
if (!val) {
formData.value.contactExpireDays = undefined
formData.value.dealExpireDays = undefined
formData.value.notifyEnabled = false
formData.value.notifyDays = undefined
}
}
)
watch(
() => formData.value.notifyEnabled,
(val: boolean) => {
if (!val) {
formData.value.notifyDays = undefined
}
}
)
onMounted(() => {
getConfig()
})
</script>