Commit da792376 authored by XieZhiXiong's avatar XieZhiXiong

对接完已有接口

parent 2bffb388
......@@ -82,6 +82,9 @@ export const STATUS_ENUM = [
}
]
// 1是阿里云oss服务器, 2是本地文件服务器
export const UPLOAD_TYPE = isDev ? 2 : 1
// 会员规则类型
export const VIP_RULE_TRANSACTION = 1; // 交易
export const VIP_RULE_LOGIN = 2; // 登录
......
......@@ -172,9 +172,11 @@ const addEquity: React.FC<[]> = () => {
setSubmitLoading(true);
try {
const res = await Promise.all(promises);
message.success('保存成功');
getMemberLevelInfo();
const resArr = await Promise.all(promises);
if (resArr.every(item => item && item.code === 1000)) {
message.success('保存成功');
getMemberLevelInfo();
}
} catch (errInfo) {
}
......
import { ISchema } from '@formily/antd';
import { FORM_FILTER_PATH } from '@/formSchema/const';
import { UPLOAD_TYPE } from '@/constants';
import { PATTERN_MAPS } from '@/constants/regExp';
export const importSchema: ISchema = {
type: 'object',
......@@ -154,44 +156,59 @@ export const auditModalSchema: ISchema = {
},
};
const FIELD_TYPE_MAP = {
'string': 'string',
'long': 'string',
'upload': 'customUpload',
};
const getXComponentProps = (type, item) => {
const MAP = {
'string': {
placeholder: item.fieldRemark,
},
'upload': {
listType: 'card',
action: '/api/file/file/upload',
data: { fileType: UPLOAD_TYPE },
fileList: [],
onChange: file => console.log(file),
},
};
return MAP[type];
};
const getCompnentValue = (elements: any) => {
let components = {};
const components = {};
for (let item of elements) {
let xComponentProps =
item.fieldType === 'string'
? {
placeholder: item.fieldRemark,
}
: {
listType: 'card',
action: '/api/file/file/upload',
data: { fileType: 2 },
fileList: [],
onChange: file => console.log(file),
};
components[item.fieldName] = {
type: item.fieldType,
required: item.fieldEmpty === 0,
title: item.fieldCNName,
'x-component-props': xComponentProps,
};
// 先判断是否存在 type,防止不存在的 type 报错
const realType = FIELD_TYPE_MAP[item.fieldType];
if (realType) {
components[item.fieldName] = {
type: FIELD_TYPE_MAP[item.fieldType],
required: item.fieldEmpty === 0,
title: item.fieldCNName,
'x-component-props': getXComponentProps(realType, item),
};
}
}
return components;
};
export const initDetailSchema = (props: any) => {
let tabSchema = {
let tabSchema: ISchema = {
properties: {
'tab-1': {
type: 'object',
'x-component': 'tabpane',
'x-component': 'TabPane',
'x-component-props': {
tab: '基本信息',
},
properties: {
MEGA_LAYOUT1: {
type: 'object',
'x-component': 'mega-layout',
'x-component': 'Mega-Layout',
'x-component-props': {
labelCol: 4,
wrapperCol: 8,
......@@ -213,10 +230,13 @@ export const initDetailSchema = (props: any) => {
title: '会员角色',
enum: [],
'x-component-props': {
placeholder: '请选择',
placeholder: '请选择',
},
'x-props': {
hasFeedback: true,
},
},
level: {
levelId: {
type: 'string',
required: true,
title: '会员等级',
......@@ -224,69 +244,73 @@ export const initDetailSchema = (props: any) => {
'x-component-props': {
placeholder: '请选择',
},
'x-props': {
hasFeedback: true,
},
},
MEGA_LAYOUT1_1: {
type: 'object',
'x-component': 'mega-layout',
'x-component': 'Mega-Layout',
'x-component-props': {
label: '注册手机',
wrapperCol: 24,
required: true,
},
required: true,
inline: true,
},
properties: {
MEGA_LAYOUT1_1_1: {
type: 'object',
'x-component': 'mega-layout',
countryCodeId: {
type: 'string',
enum: [],
'x-component-props': {
grid: true,
full: true,
},
properties: {
telCode: {
type: 'string',
enum: [],
'x-component-props': {
placeholder: '请选择',
},
required: true,
},
tel: {
type: 'string',
'x-mega-props': { span: 2 },
'x-component-props': {
placeholder: '请输入你的手机号码',
maxLength: 11,
},
required: true,
placeholder: '请选择',
},
required: true,
},
phone: {
type: 'string',
required: true,
'x-component-props': {
placeholder: '请输入你的手机号码',
maxLength: 11,
},
'x-rules': [
{
pattern: PATTERN_MAPS.phone,
message: '请输入正确格式的手机号',
},
},
],
},
},
},
memberEmail: {
email: {
type: 'string',
title: '邮箱',
'x-component-props': {},
'x-rules': [
{
pattern: PATTERN_MAPS.email,
message: '请输入正确格式的邮箱',
},
],
},
},
},
},
},
},
},
};
if (Object.keys(props).length > 0) {
for (let [index, item] of props.groups.entries()) {
tabSchema.properties[`tab-${index + 2}`] = {
if (Array.isArray(props)) {
for (let [index, item] of props.entries()) {
tabSchema.properties![`tab-${index + 2}`] = {
type: 'object',
'x-component': 'tabpane',
'x-component': 'TabPane',
'x-component-props': {
tab: item.groupName,
},
properties: {
[`MEGA_LAYOUT${index + 2}`]: {
type: 'object',
'x-component': 'mega-layout',
'x-component': 'Mega-Layout',
'x-component-props': {
labelCol: 4,
wrapperCol: 8,
......@@ -299,13 +323,15 @@ export const initDetailSchema = (props: any) => {
}
}
let detailSchema = {
let detailSchema: ISchema = {
type: 'object',
properties: {
REPOSIT_TABS: {
tabs: {
type: 'object',
'x-component': 'tab',
'x-component-props': {},
'x-component': 'Tab',
'x-component-props': {
type: 'card',
},
...tabSchema,
},
},
......
......@@ -237,12 +237,14 @@ const AuditPr1: React.FC<QueryProps> = props => {
}),
];
Promise.all(promises).then(res => {
Promise.all(promises).then(resArr => {
if (resArr.every(item => item && item.code === 1000)) {
setTimeout(() => {
history.goBack();
}, 800);
setModalVisible(false);
}
setConfirmLoading(false);
setTimeout(() => {
history.goBack();
}, 800);
setModalVisible(false);
}).catch(() => {
setConfirmLoading(false);
});
......
......@@ -237,12 +237,14 @@ const AuditPr2: React.FC<QueryProps> = props => {
}),
];
Promise.all(promises).then(res => {
Promise.all(promises).then(resArr => {
if (resArr.every(item => item && item.code === 1000)) {
setTimeout(() => {
history.goBack();
}, 800);
setModalVisible(false);
}
setConfirmLoading(false);
setTimeout(() => {
history.goBack();
}, 800);
setModalVisible(false);
}).catch(() => {
setConfirmLoading(false);
});
......
......@@ -237,12 +237,14 @@ const AuditPrComfirm: React.FC<QueryProps> = props => {
}),
];
Promise.all(promises).then(res => {
Promise.all(promises).then(resArr => {
if (resArr.every(item => item && item.code === 1000)) {
setTimeout(() => {
history.goBack();
}, 800);
setModalVisible(false);
}
setConfirmLoading(false);
setTimeout(() => {
history.goBack();
}, 800);
setModalVisible(false);
}).catch(() => {
setConfirmLoading(false);
});
......
......@@ -237,12 +237,14 @@ const AuditPrSubmit: React.FC<QueryProps> = props => {
}),
];
Promise.all(promises).then(res => {
Promise.all(promises).then(resArr => {
if (resArr.every(item => item && item.code === 1000)) {
setTimeout(() => {
history.goBack();
}, 800);
setModalVisible(false);
}
setConfirmLoading(false);
setTimeout(() => {
history.goBack();
}, 800);
setModalVisible(false);
}).catch(() => {
setConfirmLoading(false);
});
......
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