Commit dc8487d7 authored by XieZhiXiong's avatar XieZhiXiong

feat: 完成会员待入库分类新增/会员维护修改入库分类信息相关

parent 65426d1d
/* --------------------------------- 结算方式 -------------------------------- */
/**
* 现结
*/
export const PAY_TYPE_CASH = 1;
/**
* 账期(按天)
*/
export const PAY_TYPE_PAYMENT_DAYS_DAY = 2;
/**
* 账期(按月)
*/
export const PAY_TYPE_PAYMENT_DAYS_MONTH = 3;
/**
* 月结
*/
export const PAY_TYPE_MONTHLY_STATEMENT = 4;
\ No newline at end of file
......@@ -528,8 +528,9 @@ export default {
'member.components.MemberDocCategory.partnerTypeName':'Membership',
'member.components.MemberDocCategory.category':'Main category',
'member.components.MemberDocCategory.category.name':'Category',
'member.components.MemberDocCategory.category.paymentDay':'Payment cycle (days)',
'member.components.MemberDocCategory.category.paymentDay':'결제 방식',
'member.components.MemberDocCategory.category.invoiceTypeName':'Invoice Type',
'member.components.MemberDocCategory.category.taxPoint':'Tax Point',
'member.components.MemberDocCategory.title':'Category Information',
'member.components.MemberDocCategory.edit':'Modify',
'member.components.MemberDocCategory.edit.message':'Submitting, please wait...',
......
......@@ -530,6 +530,7 @@ export default {
'member.components.MemberDocCategory.category.name': '종류',
'member.components.MemberDocCategory.category.paymentDay': '결제 주기(일)',
'member.components.MemberDocCategory.category.invoiceTypeName': '청구서 유형',
'member.components.MemberDocCategory.category.taxPoint': '세점',
'member.components.MemberDocCategory.title': '분류 정보',
'member.components.MemberDocCategory.edit': '수정',
'member.components.MemberDocCategory.edit.message': '커밋 중입니다. 잠시 기다려 주십시오...',
......
......@@ -528,8 +528,9 @@ export default {
'member.components.MemberDocCategory.partnerTypeName': '会员关系',
'member.components.MemberDocCategory.category': '主营品类',
'member.components.MemberDocCategory.category.name': '品类',
'member.components.MemberDocCategory.category.paymentDay': '付款周期(天)',
'member.components.MemberDocCategory.category.paymentDay': '结算方式',
'member.components.MemberDocCategory.category.invoiceTypeName': '发票类型',
'member.components.MemberDocCategory.category.taxPoint': '税点',
'member.components.MemberDocCategory.title': '分类信息',
'member.components.MemberDocCategory.edit': '修改',
'member.components.MemberDocCategory.edit.message': '正在提交,请稍候...',
......
......@@ -41,19 +41,52 @@ export type DocCategoryProps = Omit<CustomizeColumnProps, 'data' | 'columns'> &
/**
* 主营品类
*/
categories: {
categories: {
/**
* 数据id
* 品类信息id
*/
id: number,
/**
* 品类名称
* 品类列表 ,BusinessCategoryDetailQueryVO
*/
name: string,
details: {
/**
* 品类层级
*/
level?: number,
/**
* 品类Id
*/
categoryId?: number,
/**
* 品类名称
*/
name?: string,
}[]
/**
* 付款周期(天)
* 结算方式,1-现结,2-账期(按天),3-账期(按月),4-月结
*/
paymentDay: number,
payType: number,
/**
* 结算方式名称
*/
payTypeName: string,
/**
* 月,结算方式为账期(按月)时大于0
*/
month: number,
/**
* 每月几号,结算方式为“账期(按月)”或“月结”时大于0
*/
monthDay: number,
/**
* 天,结算方式为账期(按天)时大于0
*/
days: number,
/**
* 发票类型,1-增值税专用发票,2-普通发票,3-机动车专用发票,4-机打发票,5-定额发票
*/
invoiceType: number,
/**
* 发票类型名称
*/
......@@ -108,10 +141,12 @@ const MemberDocCategory: React.FC<DocCategoryProps> = (props: DocCategoryProps)
partnerType: res.data?.partnerType,
maxAmount: res.data?.maxAmount,
areaCodes: res.data?.areaCodes,
categories: res.data?.categories.map(({ names, paymentDay, taxPoint, ...rest }) => ({
category: names,
paymentDay: `${paymentDay}`,
taxPoint: +taxPoint,
categories: res.data?.categories.map(({ details, month, monthDay, days, taxPoint, ...rest }) => ({
category: details?.map((item) => `${item.categoryId}`),
month: month ? `${month}` : '',
monthDay: monthDay ? `${monthDay}` : '',
days: days ? `${days}` : '',
taxPoint: taxPoint,
...rest
})),
});
......@@ -181,8 +216,15 @@ const MemberDocCategory: React.FC<DocCategoryProps> = (props: DocCategoryProps)
{dataSource?.categories.map((item) => (
<li className={styles['category-list-item']} key={item.id}>
<Descriptions column={1}>
<Descriptions.Item label={intl.formatMessage({ id: 'member.components.MemberDocCategory.category.name' })}>{item.name}</Descriptions.Item>
<Descriptions.Item label={intl.formatMessage({ id: 'member.components.MemberDocCategory.category.paymentDay' })}>{item.paymentDay}</Descriptions.Item>
<Descriptions.Item label={intl.formatMessage({ id: 'member.components.MemberDocCategory.category.name' })}>
{item.details?.map((item) => item.name).join(' / ')}
</Descriptions.Item>
<Descriptions.Item label={intl.formatMessage({ id: 'member.components.MemberDocCategory.category.paymentDay' })}>
{`${item.payTypeName} `}
{item.month ? `${item.month}个月` : ''}
{item.monthDay ? `${item.monthDay}号` : ''}
{item.days ? `${item.days}天` : ''}
</Descriptions.Item>
<Descriptions.Item label={intl.formatMessage({ id: 'member.components.MemberDocCategory.category.invoiceTypeName' })}>{item.invoiceTypeName}</Descriptions.Item>
<Descriptions.Item label={intl.formatMessage({ id: 'member.components.MemberDocCategory.category.taxPoint' })}>{item.taxPoint}%</Descriptions.Item>
</Descriptions>
......
......@@ -5,7 +5,7 @@
* @LastEditTime: 2021-12-04 16:06:39
* @Description: 修改入库分类信息 抽屉
*/
import React, { useEffect } from 'react';
import React, { useEffect, useRef } from 'react';
import { useIntl } from 'umi';
import {
Drawer,
......@@ -20,25 +20,61 @@ import {
} from '@formily/antd';
import { useLinkageUtils } from '@/utils/formEffectUtils';
import { ArrayCards } from '@formily/antd-components';
import {
getMemberAbilityMaintenanceDetailRecordClassifyCategoryItems,
getMemberAbilityMaintenanceDetailRecordClassifyCity,
getMemberAbilityMaintenanceDetailRecordClassifyProvince,
} from '@/services/MemberV2Api';
import { getProductCustomerGetCustomerCategoryTree } from '@/services/ProductV2Api';
import {
PAY_TYPE_CASH,
PAY_TYPE_MONTHLY_STATEMENT,
PAY_TYPE_PAYMENT_DAYS_DAY,
PAY_TYPE_PAYMENT_DAYS_MONTH,
} from '@/constants/settlement';
import { schema } from './schema';
import { CategoryItemType, completeCategory } from '../../utils';
import CascaderFormItem from '../CascaderFormItem';
import styles from './index.less';
import { getMemberAbilityMaintenanceDetailRecordClassifyCity, getMemberAbilityMaintenanceDetailRecordClassifyProvince } from '@/services/MemberV2Api';
import { getProductCustomerGetCustomerCategoryTree } from '@/services/ProductV2Api';
type CategoriesType = {
/**
* 品类名称
* 品类明细
*/
details: {
/**
* 层级
*/
level: number,
/**
* 品类id
*/
categoryId: number,
/**
* 品类名称
*/
name: string,
}[],
/**
* 结算方式
*/
payType: number,
/**
* 月份数
*/
month?: number,
/**
* 结算日
*/
names: string[],
monthDay?: number,
/**
* 付款周期(天)
* 天数
*/
paymentDay: number,
days?: number,
/**
* 发票类型名称
* 发票类型
*/
invoiceTypeName: string,
invoiceType: number,
/**
* 税点,只要百分比的分子部分,不要转换为小数
*/
......@@ -47,12 +83,8 @@ type CategoriesType = {
export type ValueType = {
/**
* 会员编码
*/
code: string,
/**
* 合作关系类型枚举
*/
* 合作关系类型枚举
*/
partnerType: number,
/**
* 单次合作金额
......@@ -79,6 +111,10 @@ export type ValueType = {
export interface FormValueType extends Omit<ValueType, ('maxAmount' | 'categories')> {
/**
* 会员编码
*/
code: string,
/**
* 单次合作金额
*/
maxAmount: string,
......@@ -87,66 +123,36 @@ export interface FormValueType extends Omit<ValueType, ('maxAmount' | 'categorie
*/
categories: {
/**
* 已选品类
* 已选品类,id string[]
*/
category: string[],
/**
* 付款周期(天)
* 结算方式
*/
payType: number,
/**
* 月份数
*/
paymentDay: string,
month?: string,
/**
* 发票类型名称
* 结算日
*/
invoiceTypeName: string,
monthDay?: string,
/**
* 天数
*/
days?: string,
/**
* 发票类型
*/
invoiceType: number,
/**
* 税点,只要百分比的分子部分,不要转换为小数
*/
taxPoint: number,
taxPoint: string,
}[],
}
interface CategoryItem {
/**
* 数据id
*/
id: string,
/**
* 父级id
*/
parentId: string,
/**
* 标题
*/
title: string,
/**
* 是否选中
*/
checked: boolean,
/**
* 图片url路径
*/
imageUrl: string,
/**
* 子元素
*/
children: CategoryItem[],
}
type CategoryType = {
/**
* label
*/
label: string,
/**
* 值
*/
value: string,
/**
* 子元素
*/
children: CategoryType[],
}
export type PartnerTypesItem = {
/**
* label
......@@ -202,6 +208,8 @@ const ComingClassifyDrawer: React.FC<IProps> = (props: IProps) => {
submitLoading,
} = props;
const categoryTreeRef = useRef<CategoryItemType[]>([]);
const intl = useIntl();
useEffect(() => {
......@@ -221,12 +229,22 @@ const ComingClassifyDrawer: React.FC<IProps> = (props: IProps) => {
const handleSubmit = (values: FormValueType) => {
if (onSubmit) {
const { maxAmount, categories, ...rest } = values;
const formated = categories.map((item) => ({
names: item.category,
paymentDay: +item.paymentDay,
invoiceTypeName: item.invoiceTypeName,
taxPoint: +item.taxPoint,
}));
const formated = categories.map((item) => {
const categoryArr = completeCategory(item.category, categoryTreeRef.current);
return {
details: categoryArr.map((category, level) => ({
level: level + 1,
categoryId: +category.id,
name: category.title,
})),
payType: item.payType,
month: item.month ? +item.month : undefined,
monthDay: item.monthDay ? +item.monthDay : undefined,
days: item.days ? +item.days : undefined,
invoiceType: item.invoiceType,
taxPoint: +item.taxPoint,
};
});
onSubmit({
maxAmount: +maxAmount,
categories: formated,
......@@ -297,6 +315,51 @@ const ComingClassifyDrawer: React.FC<IProps> = (props: IProps) => {
);
});
});
// 结算方式改变,联动显示对应的 FormItem
onFieldValueChange$('categories.*.payType').subscribe((fieldState) => {
formActions.setFieldState(
FormPath.transform(fieldState.name, /\d/, $1 => `categories.${$1}.*(PAYMENT_DAYS_MONTH_WRAP,PAYMENT_DAYS_DAY_WRAP,MONTHLY_TATEMENT_WRAP)`),
state => {
FormPath.setIn(state, 'visible', false);
}
);
switch (fieldState.value) {
case PAY_TYPE_CASH: {
break;
}
case PAY_TYPE_PAYMENT_DAYS_DAY: {
formActions.setFieldState(
FormPath.transform(fieldState.name, /\d/, $1 => `categories.${$1}.PAYMENT_DAYS_MONTH_WRAP`),
state => {
FormPath.setIn(state, 'visible', true);
}
);
break;
}
case PAY_TYPE_PAYMENT_DAYS_MONTH: {
formActions.setFieldState(
FormPath.transform(fieldState.name, /\d/, $1 => `categories.${$1}.PAYMENT_DAYS_DAY_WRAP`),
state => {
FormPath.setIn(state, 'visible', true);
}
);
break;
}
case PAY_TYPE_MONTHLY_STATEMENT: {
formActions.setFieldState(
FormPath.transform(fieldState.name, /\d/, $1 => `categories.${$1}.MONTHLY_TATEMENT_WRAP`),
state => {
FormPath.setIn(state, 'visible', true);
}
);
break;
}
default:
break;
}
});
}
return (
......@@ -356,6 +419,7 @@ const ComingClassifyDrawer: React.FC<IProps> = (props: IProps) => {
getProductCustomerGetCustomerCategoryTree().then(res => {
if (res.code === 1000) {
const { data = [] } = res;
categoryTreeRef.current = data as CategoryItemType[];
formActions.setFieldState('categories.*.category', state => {
FormPath.setIn(state, 'props.x-component-props.options', data);
});
......@@ -363,6 +427,27 @@ const ComingClassifyDrawer: React.FC<IProps> = (props: IProps) => {
}).catch((err) => {
console.warn(err);
});
// 请求结算方式与发票类型数据
getMemberAbilityMaintenanceDetailRecordClassifyCategoryItems().then(res => {
if (res.code === 1000 && res.data) {
const { payTypes = [], invoiceTypes } = res.data;
formActions.setFieldState('categories.*.payType', state => {
FormPath.setIn(state, 'props.enum', payTypes.map((item) => ({
label: item.payTypeName,
value: item.payType,
})));
});
formActions.setFieldState('categories.*.invoiceType', state => {
FormPath.setIn(state, 'props.enum', invoiceTypes.map((item) => ({
label: item.invoiceTypeName,
value: item.invoiceType,
})));
});
}
}).catch((err) => {
console.warn(err);
});
});
}}
actions={formActions}
......
......@@ -8,12 +8,6 @@
import { ISchema } from '@formily/antd';
import { getIntl } from 'umi';
import {
MEMBER_INVOICE_TYPE_1,
MEMBER_INVOICE_TYPE_2,
MEMBER_INVOICE_TYPE_3,
MEMBER_INVOICE_TYPE_4,
MEMBER_INVOICE_TYPE_5,
MEMBER_INVOICE_TYPE,
MEMBER_TAX_POINT_1,
MEMBER_TAX_POINT_2,
MEMBER_TAX_POINT_3,
......@@ -132,7 +126,7 @@ export const schema: ISchema = {
title: intl.formatMessage({ id: 'member.management.memberPrComingClassify.drawer.form.classify.category' }),
'x-component': 'CascaderFormItem',
'x-component-props': {
fieldNames: { label: 'title', value: 'title', children: 'children' },
fieldNames: { label: 'title', value: 'id', children: 'children' },
changeOnSelect: true,
expandTrigger: 'hover',
},
......@@ -182,41 +176,126 @@ export const schema: ISchema = {
// },
// },
// },
paymentDay: {
payType: {
type: 'string',
title: intl.formatMessage({ id: 'member.management.memberPrComingClassify.drawer.form.classify.paymentDay' }),
required: true,
enum: [],
'x-component': 'Radio',
title: '结算方式',
'x-rules': [
{
pattern: /^([0]|[1-9][0-9]{0,7})$/,
message: intl.formatMessage({ id: 'member.management.memberPrComingClassify.drawer.form.classify.paymentDay.rules-legal' }),
required: true,
message: '请选择结算方式',
},
],
},
invoiceTypeName: {
type: 'string',
enum: [
{
label: MEMBER_INVOICE_TYPE[MEMBER_INVOICE_TYPE_1],
value: MEMBER_INVOICE_TYPE[MEMBER_INVOICE_TYPE_1],
},
{
label: MEMBER_INVOICE_TYPE[MEMBER_INVOICE_TYPE_2],
value: MEMBER_INVOICE_TYPE[MEMBER_INVOICE_TYPE_2],
PAYMENT_DAYS_MONTH_WRAP: {
type: 'object',
'x-component': 'Mega-Layout',
'x-component-props': {
grid: true,
full: true,
autoRow: true,
columns: 2,
label: ' ',
labelCol: 8,
},
properties: {
month: {
type: 'string',
title: '',
'x-component-props': {
addonAfter: '个月',
},
'x-rules': [
{
pattern: PATTERN_MAPS.quantity,
message: '请输入正整数',
},
],
},
{
label: MEMBER_INVOICE_TYPE[MEMBER_INVOICE_TYPE_3],
value: MEMBER_INVOICE_TYPE[MEMBER_INVOICE_TYPE_3],
monthDay: {
type: 'string',
title: '结算日',
'x-component-props': {
addonAfter: '号',
},
'x-rules': [
{
pattern: PATTERN_MAPS.quantity,
message: '请输入正整数',
},
{
validator(value) {
const intVal = +value;
return intVal > 28 || intVal < 0 ? '请输入大于0 小于等于 28的数值' : '';
}
},
],
},
{
label: MEMBER_INVOICE_TYPE[MEMBER_INVOICE_TYPE_4],
value: MEMBER_INVOICE_TYPE[MEMBER_INVOICE_TYPE_4],
},
visible: false,
},
PAYMENT_DAYS_DAY_WRAP: {
type: 'object',
'x-component': 'Mega-Layout',
'x-component-props': {
grid: true,
full: true,
autoRow: true,
columns: 2,
label: ' ',
labelCol: 8,
},
properties: {
days: {
type: 'string',
title: '',
'x-component-props': {
addonAfter: '天',
},
'x-rules': [
{
pattern: PATTERN_MAPS.quantity,
message: '请输入正整数',
},
],
},
{
label: MEMBER_INVOICE_TYPE[MEMBER_INVOICE_TYPE_5],
value: MEMBER_INVOICE_TYPE[MEMBER_INVOICE_TYPE_5],
},
visible: false,
},
MONTHLY_TATEMENT_WRAP: {
type: 'object',
'x-component': 'Mega-Layout',
'x-component-props': {
grid: true,
full: true,
autoRow: true,
columns: 2,
label: ' ',
labelCol: 8,
},
properties: {
monthDay: {
type: 'string',
title: '结算日',
'x-component-props': {
addonAfter: '号',
},
'x-rules': [
{
validator(value) {
const intVal = +value;
return intVal > 28 || intVal < 0 ? '请输入大于0 小于等于 28的数值' : '';
}
},
],
},
],
},
visible: false,
},
invoiceType: {
type: 'string',
enum: [],
title: intl.formatMessage({ id: 'member.management.memberPrComingClassify.drawer.form.classify.invoiceTypeName' }),
required: true,
},
......
......@@ -5,7 +5,7 @@
* @LastEditTime: 2021-12-03 17:52:44
* @Description: 审核Form抽屉
*/
import React, { useEffect } from 'react';
import React, { useEffect, useRef } from 'react';
import {
Drawer,
Button,
......@@ -18,27 +18,59 @@ import {
FormEffectHooks,
FormPath,
} from '@formily/antd';
import { getMemberDepositClassifyCity, getMemberDepositClassifyProvince } from '@/services/MemberV2Api';
import { getMemberDepositClassifyCategoryItems, getMemberDepositClassifyCity, getMemberDepositClassifyProvince } from '@/services/MemberV2Api';
import { getProductCustomerGetCustomerCategoryTree } from '@/services/ProductV2Api';
import { useLinkageUtils } from '@/utils/formEffectUtils';
import {
PAY_TYPE_CASH,
PAY_TYPE_PAYMENT_DAYS_DAY,
PAY_TYPE_PAYMENT_DAYS_MONTH,
PAY_TYPE_MONTHLY_STATEMENT,
} from '@/constants/settlement';
import { ArrayCards } from '@formily/antd-components';
import { schema } from './schema';
import { CategoryItemType, completeCategory } from '../../../utils';
import CascaderFormItem from '../../../components/CascaderFormItem';
import styles from './index.less';
type CategoriesType = {
/**
* 品类名称
* 品类明细
*/
names: string[],
details: {
/**
* 层级
*/
level: number,
/**
* 品类id
*/
categoryId: number,
/**
* 品类名称
*/
name: string,
}[],
/**
* 付款周期(天)
* 结算方式
*/
paymentDay: number,
payType: number,
/**
* 月份数
*/
month?: number,
/**
* 发票类型名称
* 结算日
*/
invoiceTypeName: string,
monthDay?: number,
/**
* 天数
*/
days?: number,
/**
* 发票类型
*/
invoiceType: number,
/**
* 税点,只要百分比的分子部分,不要转换为小数
*/
......@@ -75,6 +107,10 @@ export type ValueType = {
interface FormValueType extends Omit<ValueType, ('maxAmount' | 'categories')> {
/**
* 会员编码
*/
code: string,
/**
* 单次合作金额
*/
maxAmount: string,
......@@ -83,51 +119,36 @@ interface FormValueType extends Omit<ValueType, ('maxAmount' | 'categories')> {
*/
categories: {
/**
* 已选品类
* 已选品类,id string[]
*/
category: string[],
/**
* 付款周期(天)
* 结算方式
*/
payType: number,
/**
* 月份数
*/
paymentDay: string,
month?: string,
/**
* 发票类型名称
* 结算日
*/
invoiceTypeName: string,
monthDay?: string,
/**
* 天数
*/
days?: string,
/**
* 发票类型
*/
invoiceType: number,
/**
* 税点,只要百分比的分子部分,不要转换为小数
*/
taxPoint: number,
taxPoint: string,
}[],
}
interface CategoryItem {
/**
* 数据id
*/
id: string,
/**
* 父级id
*/
parentId: string,
/**
* 标题
*/
title: string,
/**
* 是否选中
*/
checked: boolean,
/**
* 图片url路径
*/
imageUrl: string,
/**
* 子元素
*/
children: CategoryItem[],
}
type CategoryType = {
/**
* label
......@@ -143,7 +164,7 @@ type CategoryType = {
children: CategoryType[],
}
function recursionCategoryData(dataSource: CategoryItem[]): CategoryType[] {
function recursionCategoryData(dataSource: CategoryItemType[]): CategoryType[] {
const ret: CategoryType[] = [];
dataSource.forEach((item) => {
......@@ -208,6 +229,8 @@ const ComingClassifyDrawer: React.FC<IProps> = (props: IProps) => {
submitLoading,
} = props;
const categoryTreeRef = useRef<CategoryItemType[]>([]);
const intl = useIntl();
useEffect(() => {
......@@ -227,12 +250,22 @@ const ComingClassifyDrawer: React.FC<IProps> = (props: IProps) => {
const handleSubmit = (values: FormValueType) => {
if (onSubmit) {
const { maxAmount, categories, ...rest } = values;
const formated = categories.map((item) => ({
names: item.category,
paymentDay: +item.paymentDay,
invoiceTypeName: item.invoiceTypeName,
taxPoint: +item.taxPoint,
}));
const formated = categories.map((item) => {
const categoryArr = completeCategory(item.category, categoryTreeRef.current);
return {
details: categoryArr.map((category, level) => ({
level: level + 1,
categoryId: +category.id,
name: category.title,
})),
payType: item.payType,
month: item.month ? +item.month : undefined,
monthDay: item.monthDay ? +item.monthDay : undefined,
days: item.days ? +item.days : undefined,
invoiceType: item.invoiceType,
taxPoint: +item.taxPoint,
};
});
onSubmit({
maxAmount: +maxAmount,
categories: formated,
......@@ -303,6 +336,51 @@ const ComingClassifyDrawer: React.FC<IProps> = (props: IProps) => {
);
});
});
// 结算方式改变,联动显示对应的 FormItem
onFieldValueChange$('categories.*.payType').subscribe((fieldState) => {
formActions.setFieldState(
FormPath.transform(fieldState.name, /\d/, $1 => `categories.${$1}.*(PAYMENT_DAYS_MONTH_WRAP,PAYMENT_DAYS_DAY_WRAP,MONTHLY_TATEMENT_WRAP)`),
state => {
FormPath.setIn(state, 'visible', false);
}
);
switch (fieldState.value) {
case PAY_TYPE_CASH: {
break;
}
case PAY_TYPE_PAYMENT_DAYS_DAY: {
formActions.setFieldState(
FormPath.transform(fieldState.name, /\d/, $1 => `categories.${$1}.PAYMENT_DAYS_MONTH_WRAP`),
state => {
FormPath.setIn(state, 'visible', true);
}
);
break;
}
case PAY_TYPE_PAYMENT_DAYS_MONTH: {
formActions.setFieldState(
FormPath.transform(fieldState.name, /\d/, $1 => `categories.${$1}.PAYMENT_DAYS_DAY_WRAP`),
state => {
FormPath.setIn(state, 'visible', true);
}
);
break;
}
case PAY_TYPE_MONTHLY_STATEMENT: {
formActions.setFieldState(
FormPath.transform(fieldState.name, /\d/, $1 => `categories.${$1}.MONTHLY_TATEMENT_WRAP`),
state => {
FormPath.setIn(state, 'visible', true);
}
);
break;
}
default:
break;
}
});
}
return (
......@@ -361,6 +439,7 @@ const ComingClassifyDrawer: React.FC<IProps> = (props: IProps) => {
getProductCustomerGetCustomerCategoryTree().then(res => {
if (res.code === 1000) {
const { data = [] } = res;
categoryTreeRef.current = data as CategoryItemType[];
formActions.setFieldState('categories.*.category', state => {
FormPath.setIn(state, 'props.x-component-props.options', data);
});
......@@ -368,6 +447,27 @@ const ComingClassifyDrawer: React.FC<IProps> = (props: IProps) => {
}).catch((err) => {
console.warn(err);
});
// 请求结算方式与发票类型数据
getMemberDepositClassifyCategoryItems().then(res => {
if (res.code === 1000 && res.data) {
const { payTypes = [], invoiceTypes } = res.data;
formActions.setFieldState('categories.*.payType', state => {
FormPath.setIn(state, 'props.enum', payTypes.map((item) => ({
label: item.payTypeName,
value: item.payType,
})));
});
formActions.setFieldState('categories.*.invoiceType', state => {
FormPath.setIn(state, 'props.enum', invoiceTypes.map((item) => ({
label: item.invoiceTypeName,
value: item.invoiceType,
})));
});
}
}).catch((err) => {
console.warn(err);
});
});
onFieldValueChange$('agree').subscribe(fieldState => {
......
......@@ -8,12 +8,6 @@
import { ISchema } from '@formily/antd';
import { getIntl } from 'umi';
import {
MEMBER_INVOICE_TYPE_1,
MEMBER_INVOICE_TYPE_2,
MEMBER_INVOICE_TYPE_3,
MEMBER_INVOICE_TYPE_4,
MEMBER_INVOICE_TYPE_5,
MEMBER_INVOICE_TYPE,
MEMBER_TAX_POINT_1,
MEMBER_TAX_POINT_2,
MEMBER_TAX_POINT_3,
......@@ -132,7 +126,7 @@ export const schema: ISchema = {
title: intl.formatMessage({ id: 'member.management.memberPrComingClassify.drawer.form.classify.category' }),
'x-component': 'CascaderFormItem',
'x-component-props': {
fieldNames: { label: 'title', value: 'title', children: 'children' },
fieldNames: { label: 'title', value: 'id', children: 'children' },
changeOnSelect: true,
expandTrigger: 'hover',
},
......@@ -182,41 +176,126 @@ export const schema: ISchema = {
// },
// },
// },
paymentDay: {
payType: {
type: 'string',
title: intl.formatMessage({ id: 'member.management.memberPrComingClassify.drawer.form.classify.paymentDay' }),
required: true,
enum: [],
'x-component': 'Radio',
title: '结算方式',
'x-rules': [
{
pattern: /^([0]|[1-9][0-9]{0,7})$/,
message: intl.formatMessage({ id: 'member.management.memberPrComingClassify.drawer.form.classify.paymentDay.rules-legal' }),
required: true,
message: '请选择结算方式',
},
],
},
invoiceTypeName: {
type: 'string',
enum: [
{
label: MEMBER_INVOICE_TYPE[MEMBER_INVOICE_TYPE_1],
value: MEMBER_INVOICE_TYPE[MEMBER_INVOICE_TYPE_1],
},
{
label: MEMBER_INVOICE_TYPE[MEMBER_INVOICE_TYPE_2],
value: MEMBER_INVOICE_TYPE[MEMBER_INVOICE_TYPE_2],
PAYMENT_DAYS_MONTH_WRAP: {
type: 'object',
'x-component': 'Mega-Layout',
'x-component-props': {
grid: true,
full: true,
autoRow: true,
columns: 2,
label: ' ',
labelCol: 8,
},
properties: {
month: {
type: 'string',
title: '',
'x-component-props': {
addonAfter: '个月',
},
'x-rules': [
{
pattern: PATTERN_MAPS.quantity,
message: '请输入正整数',
},
],
},
{
label: MEMBER_INVOICE_TYPE[MEMBER_INVOICE_TYPE_3],
value: MEMBER_INVOICE_TYPE[MEMBER_INVOICE_TYPE_3],
monthDay: {
type: 'string',
title: '结算日',
'x-component-props': {
addonAfter: '号',
},
'x-rules': [
{
pattern: PATTERN_MAPS.quantity,
message: '请输入正整数',
},
{
validator(value) {
const intVal = +value;
return intVal > 28 || intVal < 0 ? '请输入大于0 小于等于 28的数值' : '';
}
},
],
},
{
label: MEMBER_INVOICE_TYPE[MEMBER_INVOICE_TYPE_4],
value: MEMBER_INVOICE_TYPE[MEMBER_INVOICE_TYPE_4],
},
visible: false,
},
PAYMENT_DAYS_DAY_WRAP: {
type: 'object',
'x-component': 'Mega-Layout',
'x-component-props': {
grid: true,
full: true,
autoRow: true,
columns: 2,
label: ' ',
labelCol: 8,
},
properties: {
days: {
type: 'string',
title: '',
'x-component-props': {
addonAfter: '天',
},
'x-rules': [
{
pattern: PATTERN_MAPS.quantity,
message: '请输入正整数',
},
],
},
{
label: MEMBER_INVOICE_TYPE[MEMBER_INVOICE_TYPE_5],
value: MEMBER_INVOICE_TYPE[MEMBER_INVOICE_TYPE_5],
},
visible: false,
},
MONTHLY_TATEMENT_WRAP: {
type: 'object',
'x-component': 'Mega-Layout',
'x-component-props': {
grid: true,
full: true,
autoRow: true,
columns: 2,
label: ' ',
labelCol: 8,
},
properties: {
monthDay: {
type: 'string',
title: '结算日',
'x-component-props': {
addonAfter: '号',
},
'x-rules': [
{
validator(value) {
const intVal = +value;
return intVal > 28 || intVal < 0 ? '请输入大于0 小于等于 28的数值' : '';
}
},
],
},
],
},
visible: false,
},
invoiceType: {
type: 'string',
enum: [],
title: intl.formatMessage({ id: 'member.management.memberPrComingClassify.drawer.form.classify.invoiceTypeName' }),
required: true,
},
......
......@@ -252,4 +252,44 @@ export function renderFieldTypeContent(fieldType: FieldType, fieldValue: any): R
break;
}
return node;
};
export type CategoryItemType = {
/**
* 数据id
*/
id: string,
/**
* 父级id
*/
parentId: string,
/**
* 标题
*/
title: string,
/**
* 是否选中
*/
checked: boolean,
/**
* 图片url路径
*/
imageUrl: string,
/**
* 子元素
*/
children: CategoryItemType[],
}
export function completeCategory(ids: string[], dataSource: CategoryItemType[]): CategoryItemType[] {
const ret: CategoryItemType[] = [];
if (!Array.isArray(dataSource)) {
return ret;
}
ids.forEach((curId, index) => {
const target = (ret[index - 1]?.children || dataSource).find((item) => item.id === curId);
if (target) {
ret.push(target);
}
});
return ret;
};
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment