feat:【antd】【ele】【member 会员】config 迁移 antd
This commit is contained in:
37
apps/web-antd/src/views/crm/contract/config/data.ts
Normal file
37
apps/web-antd/src/views/crm/contract/config/data.ts
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
import type { VbenFormSchema } from '#/adapter/form';
|
||||||
|
|
||||||
|
export const schema: VbenFormSchema[] = [
|
||||||
|
{
|
||||||
|
component: 'RadioGroup',
|
||||||
|
fieldName: 'notifyEnabled',
|
||||||
|
label: '提前提醒设置',
|
||||||
|
componentProps: {
|
||||||
|
options: [
|
||||||
|
{ label: '提醒', value: true },
|
||||||
|
{ label: '不提醒', value: false },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
defaultValue: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
component: 'InputNumber',
|
||||||
|
fieldName: 'notifyDays',
|
||||||
|
componentProps: {
|
||||||
|
min: 0,
|
||||||
|
precision: 0,
|
||||||
|
},
|
||||||
|
renderComponentContent: () => ({
|
||||||
|
addonBefore: () => '提前',
|
||||||
|
addonAfter: () => '天提醒',
|
||||||
|
}),
|
||||||
|
dependencies: {
|
||||||
|
triggerFields: ['notifyEnabled'],
|
||||||
|
show: (values) => values.notifyEnabled,
|
||||||
|
trigger(values) {
|
||||||
|
if (!values.notifyEnabled) {
|
||||||
|
values.notifyDays = undefined;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { VbenFormSchema } from '#/adapter/form';
|
|
||||||
import type { CrmContractConfigApi } from '#/api/crm/contract/config';
|
import type { CrmContractConfigApi } from '#/api/crm/contract/config';
|
||||||
|
|
||||||
import { onMounted } from 'vue';
|
import { onMounted } from 'vue';
|
||||||
@@ -15,51 +14,13 @@ import {
|
|||||||
} from '#/api/crm/contract/config';
|
} from '#/api/crm/contract/config';
|
||||||
import { $t } from '#/locales';
|
import { $t } from '#/locales';
|
||||||
|
|
||||||
const emit = defineEmits(['success']);
|
import { schema } from './data';
|
||||||
|
|
||||||
const schema: VbenFormSchema[] = [
|
|
||||||
{
|
|
||||||
component: 'RadioGroup',
|
|
||||||
fieldName: 'notifyEnabled',
|
|
||||||
label: '提前提醒设置',
|
|
||||||
componentProps: {
|
|
||||||
options: [
|
|
||||||
{ label: '提醒', value: true },
|
|
||||||
{ label: '不提醒', value: false },
|
|
||||||
],
|
|
||||||
},
|
|
||||||
defaultValue: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
component: 'InputNumber',
|
|
||||||
fieldName: 'notifyDays',
|
|
||||||
componentProps: {
|
|
||||||
min: 0,
|
|
||||||
precision: 0,
|
|
||||||
},
|
|
||||||
renderComponentContent: () => ({
|
|
||||||
addonBefore: () => '提前',
|
|
||||||
addonAfter: () => '天提醒',
|
|
||||||
}),
|
|
||||||
dependencies: {
|
|
||||||
triggerFields: ['notifyEnabled'],
|
|
||||||
show: (values) => values.notifyEnabled,
|
|
||||||
trigger(values) {
|
|
||||||
if (!values.notifyEnabled) {
|
|
||||||
values.notifyDays = undefined;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
const [Form, formApi] = useVbenForm({
|
const [Form, formApi] = useVbenForm({
|
||||||
commonConfig: {
|
commonConfig: {
|
||||||
labelClass: 'w-2/6',
|
labelClass: 'w-100',
|
||||||
},
|
},
|
||||||
layout: 'horizontal',
|
layout: 'horizontal',
|
||||||
wrapperClass: 'grid-cols-1',
|
|
||||||
actionWrapperClass: 'text-center',
|
|
||||||
schema,
|
schema,
|
||||||
handleSubmit,
|
handleSubmit,
|
||||||
});
|
});
|
||||||
@@ -76,7 +37,6 @@ async function handleSubmit() {
|
|||||||
}
|
}
|
||||||
await saveContractConfig(data);
|
await saveContractConfig(data);
|
||||||
await formApi.setValues(data);
|
await formApi.setValues(data);
|
||||||
emit('success');
|
|
||||||
message.success($t('ui.actionMessage.operationSuccess'));
|
message.success($t('ui.actionMessage.operationSuccess'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
78
apps/web-antd/src/views/crm/customer/poolConfig/data.ts
Normal file
78
apps/web-antd/src/views/crm/customer/poolConfig/data.ts
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
import type { VbenFormSchema } from '#/adapter/form';
|
||||||
|
|
||||||
|
export const schema: VbenFormSchema[] = [
|
||||||
|
{
|
||||||
|
component: 'RadioGroup',
|
||||||
|
fieldName: 'enabled',
|
||||||
|
label: '客户公海规则设置',
|
||||||
|
componentProps: {
|
||||||
|
options: [
|
||||||
|
{ label: '开启', value: true },
|
||||||
|
{ label: '关闭', value: false },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
component: 'InputNumber',
|
||||||
|
fieldName: 'contactExpireDays',
|
||||||
|
componentProps: {
|
||||||
|
min: 0,
|
||||||
|
precision: 0,
|
||||||
|
},
|
||||||
|
renderComponentContent: () => ({
|
||||||
|
addonAfter: () => '天不跟进或',
|
||||||
|
}),
|
||||||
|
dependencies: {
|
||||||
|
triggerFields: ['enabled'],
|
||||||
|
show: (value) => value.enabled,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
component: 'InputNumber',
|
||||||
|
fieldName: 'dealExpireDays',
|
||||||
|
renderComponentContent: () => ({
|
||||||
|
addonBefore: () => '或',
|
||||||
|
addonAfter: () => '天未成交',
|
||||||
|
}),
|
||||||
|
componentProps: {
|
||||||
|
min: 0,
|
||||||
|
precision: 0,
|
||||||
|
},
|
||||||
|
dependencies: {
|
||||||
|
triggerFields: ['enabled'],
|
||||||
|
show: (value) => value.enabled,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
component: 'RadioGroup',
|
||||||
|
fieldName: 'notifyEnabled',
|
||||||
|
label: '提前提醒设置',
|
||||||
|
componentProps: {
|
||||||
|
options: [
|
||||||
|
{ label: '开启', value: true },
|
||||||
|
{ label: '关闭', value: false },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
dependencies: {
|
||||||
|
triggerFields: ['enabled'],
|
||||||
|
show: (value) => value.enabled,
|
||||||
|
},
|
||||||
|
defaultValue: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
component: 'InputNumber',
|
||||||
|
fieldName: 'notifyDays',
|
||||||
|
componentProps: {
|
||||||
|
min: 0,
|
||||||
|
precision: 0,
|
||||||
|
},
|
||||||
|
renderComponentContent: () => ({
|
||||||
|
addonBefore: () => '提前',
|
||||||
|
addonAfter: () => '天提醒',
|
||||||
|
}),
|
||||||
|
dependencies: {
|
||||||
|
triggerFields: ['notifyEnabled'],
|
||||||
|
show: (value) => value.enabled && value.notifyEnabled,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { VbenFormSchema } from '#/adapter/form';
|
|
||||||
import type { CrmCustomerPoolConfigApi } from '#/api/crm/customer/poolConfig';
|
import type { CrmCustomerPoolConfigApi } from '#/api/crm/customer/poolConfig';
|
||||||
|
|
||||||
import { onMounted } from 'vue';
|
import { onMounted } from 'vue';
|
||||||
@@ -15,92 +14,13 @@ import {
|
|||||||
} from '#/api/crm/customer/poolConfig';
|
} from '#/api/crm/customer/poolConfig';
|
||||||
import { $t } from '#/locales';
|
import { $t } from '#/locales';
|
||||||
|
|
||||||
const emit = defineEmits(['success']);
|
import { schema } from './data';
|
||||||
|
|
||||||
const schema: VbenFormSchema[] = [
|
|
||||||
{
|
|
||||||
component: 'RadioGroup',
|
|
||||||
fieldName: 'enabled',
|
|
||||||
label: '客户公海规则设置',
|
|
||||||
componentProps: {
|
|
||||||
options: [
|
|
||||||
{ label: '开启', value: true },
|
|
||||||
{ label: '关闭', value: false },
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
component: 'InputNumber',
|
|
||||||
fieldName: 'contactExpireDays',
|
|
||||||
componentProps: {
|
|
||||||
min: 0,
|
|
||||||
precision: 0,
|
|
||||||
},
|
|
||||||
renderComponentContent: () => ({
|
|
||||||
addonAfter: () => '天不跟进或',
|
|
||||||
}),
|
|
||||||
dependencies: {
|
|
||||||
triggerFields: ['enabled'],
|
|
||||||
show: (value) => value.enabled,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
component: 'InputNumber',
|
|
||||||
fieldName: 'dealExpireDays',
|
|
||||||
renderComponentContent: () => ({
|
|
||||||
addonBefore: () => '或',
|
|
||||||
addonAfter: () => '天未成交',
|
|
||||||
}),
|
|
||||||
componentProps: {
|
|
||||||
min: 0,
|
|
||||||
precision: 0,
|
|
||||||
},
|
|
||||||
dependencies: {
|
|
||||||
triggerFields: ['enabled'],
|
|
||||||
show: (value) => value.enabled,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
component: 'RadioGroup',
|
|
||||||
fieldName: 'notifyEnabled',
|
|
||||||
label: '提前提醒设置',
|
|
||||||
componentProps: {
|
|
||||||
options: [
|
|
||||||
{ label: '开启', value: true },
|
|
||||||
{ label: '关闭', value: false },
|
|
||||||
],
|
|
||||||
},
|
|
||||||
dependencies: {
|
|
||||||
triggerFields: ['enabled'],
|
|
||||||
show: (value) => value.enabled,
|
|
||||||
},
|
|
||||||
defaultValue: false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
component: 'InputNumber',
|
|
||||||
fieldName: 'notifyDays',
|
|
||||||
componentProps: {
|
|
||||||
min: 0,
|
|
||||||
precision: 0,
|
|
||||||
},
|
|
||||||
renderComponentContent: () => ({
|
|
||||||
addonBefore: () => '提前',
|
|
||||||
addonAfter: () => '天提醒',
|
|
||||||
}),
|
|
||||||
dependencies: {
|
|
||||||
triggerFields: ['notifyEnabled'],
|
|
||||||
show: (value) => value.enabled && value.notifyEnabled,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
const [Form, formApi] = useVbenForm({
|
const [Form, formApi] = useVbenForm({
|
||||||
commonConfig: {
|
commonConfig: {
|
||||||
labelClass: 'w-2/6',
|
labelClass: 'w-100',
|
||||||
},
|
},
|
||||||
layout: 'horizontal',
|
layout: 'horizontal',
|
||||||
wrapperClass: 'grid-cols-1',
|
|
||||||
actionWrapperClass: 'text-center',
|
|
||||||
schema,
|
schema,
|
||||||
handleSubmit,
|
handleSubmit,
|
||||||
});
|
});
|
||||||
@@ -125,7 +45,6 @@ async function handleSubmit() {
|
|||||||
await saveCustomerPoolConfig(data);
|
await saveCustomerPoolConfig(data);
|
||||||
// 关闭并提示
|
// 关闭并提示
|
||||||
await formApi.setValues(data);
|
await formApi.setValues(data);
|
||||||
emit('success');
|
|
||||||
message.success($t('ui.actionMessage.operationSuccess'));
|
message.success($t('ui.actionMessage.operationSuccess'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -64,7 +64,6 @@ const [Form, formApi] = useVbenForm({
|
|||||||
labelClass: 'w-2/6',
|
labelClass: 'w-2/6',
|
||||||
},
|
},
|
||||||
wrapperClass: 'grid-cols-1',
|
wrapperClass: 'grid-cols-1',
|
||||||
actionWrapperClass: 'text-center',
|
|
||||||
handleSubmit: onSubmit,
|
handleSubmit: onSubmit,
|
||||||
layout: 'horizontal',
|
layout: 'horizontal',
|
||||||
resetButtonOptions: {
|
resetButtonOptions: {
|
||||||
|
|||||||
52
apps/web-antd/src/views/member/config/data.ts
Normal file
52
apps/web-antd/src/views/member/config/data.ts
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
import type { VbenFormSchema } from '#/adapter/form';
|
||||||
|
|
||||||
|
export const schema: VbenFormSchema[] = [
|
||||||
|
{
|
||||||
|
component: 'Input',
|
||||||
|
fieldName: 'id',
|
||||||
|
dependencies: {
|
||||||
|
triggerFields: [''],
|
||||||
|
show: () => false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
component: 'Switch',
|
||||||
|
fieldName: 'pointTradeDeductEnable',
|
||||||
|
label: '积分抵扣',
|
||||||
|
help: '下单积分是否抵用订单金额',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
component: 'InputNumber',
|
||||||
|
fieldName: 'pointTradeDeductUnitPrice',
|
||||||
|
label: '积分抵扣',
|
||||||
|
help: '积分抵用比例(1 积分抵多少金额),单位:元',
|
||||||
|
componentProps: {
|
||||||
|
min: 0,
|
||||||
|
precision: 2,
|
||||||
|
class: 'w-full',
|
||||||
|
placeholder: '请输入积分抵扣单价',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
component: 'InputNumber',
|
||||||
|
fieldName: 'pointTradeDeductMaxPrice',
|
||||||
|
label: '积分抵扣最大值',
|
||||||
|
help: '单次下单积分使用上限,0 不限制',
|
||||||
|
componentProps: {
|
||||||
|
min: 0,
|
||||||
|
class: 'w-full',
|
||||||
|
placeholder: '请输入积分抵扣最大值',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
component: 'InputNumber',
|
||||||
|
fieldName: 'pointTradeGivePoint',
|
||||||
|
label: '1 元赠送多少分',
|
||||||
|
help: '下单支付金额按比例赠送积分(实际支付 1 元赠送多少积分)',
|
||||||
|
componentProps: {
|
||||||
|
min: 0,
|
||||||
|
class: 'w-full',
|
||||||
|
placeholder: '请输入赠送积分比例',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
@@ -4,6 +4,7 @@ import type { MemberConfigApi } from '#/api/member/config';
|
|||||||
import { onMounted, ref } from 'vue';
|
import { onMounted, ref } from 'vue';
|
||||||
|
|
||||||
import { Page } from '@vben/common-ui';
|
import { Page } from '@vben/common-ui';
|
||||||
|
import { fenToYuan, yuanToFen } from '@vben/utils';
|
||||||
|
|
||||||
import { Card, message } from 'ant-design-vue';
|
import { Card, message } from 'ant-design-vue';
|
||||||
|
|
||||||
@@ -11,95 +12,47 @@ import { useVbenForm } from '#/adapter/form';
|
|||||||
import { getConfig, saveConfig } from '#/api/member/config';
|
import { getConfig, saveConfig } from '#/api/member/config';
|
||||||
import { $t } from '#/locales';
|
import { $t } from '#/locales';
|
||||||
|
|
||||||
const emit = defineEmits(['success']);
|
import { schema } from './data';
|
||||||
|
|
||||||
const formData = ref<MemberConfigApi.Config>();
|
const formData = ref<MemberConfigApi.Config>();
|
||||||
|
|
||||||
const [Form, formApi] = useVbenForm({
|
const [Form, formApi] = useVbenForm({
|
||||||
commonConfig: {
|
commonConfig: {
|
||||||
// 所有表单项
|
labelWidth: 120,
|
||||||
labelClass: 'w-2/6',
|
|
||||||
},
|
},
|
||||||
layout: 'horizontal',
|
layout: 'horizontal',
|
||||||
wrapperClass: 'grid-cols-1',
|
schema,
|
||||||
actionWrapperClass: 'text-center',
|
handleSubmit,
|
||||||
schema: [
|
|
||||||
{
|
|
||||||
component: 'Input',
|
|
||||||
fieldName: 'id',
|
|
||||||
dependencies: {
|
|
||||||
triggerFields: [''],
|
|
||||||
show: () => false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
component: 'Switch',
|
|
||||||
fieldName: 'pointTradeDeductEnable',
|
|
||||||
label: '积分抵扣',
|
|
||||||
help: '开启后,用户可以积分抵扣',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
component: 'InputNumber',
|
|
||||||
fieldName: 'pointTradeDeductUnitPrice',
|
|
||||||
label: '积分抵扣单价',
|
|
||||||
help: '用户每消费1元,可以抵扣多少积分',
|
|
||||||
componentProps: {
|
|
||||||
min: 0,
|
|
||||||
precision: 2,
|
|
||||||
class: 'w-full',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
component: 'InputNumber',
|
|
||||||
fieldName: 'pointTradeDeductMaxPrice',
|
|
||||||
label: '积分抵扣最大值',
|
|
||||||
help: '单次下单积分使用上限,0 不限制',
|
|
||||||
componentProps: {
|
|
||||||
min: 0,
|
|
||||||
class: 'w-full',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
component: 'InputNumber',
|
|
||||||
fieldName: 'pointTradeGivePoint',
|
|
||||||
label: '1 元赠送多少分',
|
|
||||||
help: '下单支付金额按比例赠送积分(实际支付 1 元赠送多少积分)',
|
|
||||||
componentProps: {
|
|
||||||
min: 0,
|
|
||||||
class: 'w-full',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
// 提交函数
|
|
||||||
handleSubmit: onSubmit,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
async function onSubmit() {
|
/** 提交表单 */
|
||||||
|
async function handleSubmit() {
|
||||||
const { valid } = await formApi.validate();
|
const { valid } = await formApi.validate();
|
||||||
if (!valid) {
|
if (!valid) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 提交表单
|
// 提交表单
|
||||||
const data = (await formApi.getValues()) as MemberConfigApi.Config;
|
const data = (await formApi.getValues()) as MemberConfigApi.Config;
|
||||||
formApi.setState({ commonConfig: { disabled: true } });
|
// 转换金额单位
|
||||||
try {
|
data.pointTradeDeductUnitPrice = yuanToFen(data.pointTradeDeductUnitPrice);
|
||||||
await saveConfig(data);
|
await saveConfig(data);
|
||||||
// 关闭并提示
|
// 关闭并提示
|
||||||
emit('success');
|
message.success($t('ui.actionMessage.operationSuccess'));
|
||||||
message.success($t('ui.actionMessage.operationSuccess'));
|
|
||||||
} finally {
|
|
||||||
formApi.setState({ commonConfig: { disabled: false } });
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 获取配置 */
|
||||||
async function getConfigInfo() {
|
async function getConfigInfo() {
|
||||||
try {
|
const res = await getConfig();
|
||||||
const res = await getConfig();
|
formData.value = res;
|
||||||
formData.value = res;
|
// 转换金额单位
|
||||||
} catch (error) {
|
res.pointTradeDeductUnitPrice = Number.parseFloat(
|
||||||
console.error(error);
|
fenToYuan(res.pointTradeDeductUnitPrice),
|
||||||
}
|
);
|
||||||
|
// 设置到 values
|
||||||
|
await formApi.setValues(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 初始化 */
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
getConfigInfo();
|
getConfigInfo();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -60,7 +60,6 @@ onMounted(() => {
|
|||||||
|
|
||||||
const [Form, formApi] = useVbenForm({
|
const [Form, formApi] = useVbenForm({
|
||||||
wrapperClass: 'grid-cols-1',
|
wrapperClass: 'grid-cols-1',
|
||||||
actionWrapperClass: 'text-center',
|
|
||||||
handleSubmit: onSubmit,
|
handleSubmit: onSubmit,
|
||||||
layout: 'horizontal',
|
layout: 'horizontal',
|
||||||
resetButtonOptions: {
|
resetButtonOptions: {
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ const [Form, formApi] = useVbenForm({
|
|||||||
},
|
},
|
||||||
layout: 'horizontal',
|
layout: 'horizontal',
|
||||||
wrapperClass: 'grid-cols-1',
|
wrapperClass: 'grid-cols-1',
|
||||||
actionWrapperClass: 'text-center',
|
|
||||||
schema: [
|
schema: [
|
||||||
{
|
{
|
||||||
component: 'Input',
|
component: 'Input',
|
||||||
|
|||||||
Reference in New Issue
Block a user