Commit 488c589e authored by 前端-钟卫鹏's avatar 前端-钟卫鹏

fix: merge、交易规则路由调整

parent 821fb4a3
/*
* @Author: XieZhiXiong
* @Date: 2020-09-23 17:00:24
* @LastEditors: XieZhiXiong
* @LastEditTime: 2020-10-20 17:58:51
* @Description:
*/
import { ISchema } from '@formily/antd';
import { UPLOAD_TYPE } from '@/constants';
export const evaluateSchema: ISchema = {
type: 'object',
properties: {
comments: {
type: 'array',
'x-component': 'EvaluationList',
default: [],
items: {
type: 'object',
properties: {
LEFT_RIGHT: {
type: 'object',
'x-component': 'LeftRightLayout',
'x-component-props': {
rightProps: {
span: 2,
offset: 4,
},
},
properties: {
MEGA_LADYOUT: {
type: 'object',
'x-component': 'Mega-Layout',
'x-component-props': {
labelCol: 6,
labelAlign: 'left',
position: 'left',
},
properties: {
star: {
title: '满意程度',
required: true,
'x-component': 'Rating',
'x-component-props': {
allowHalf: false,
},
'x-rules': [
{
required: true,
message: '请选择满意程度',
},
],
},
comment: {
type: 'string',
title: '评价',
'x-component': 'TextArea',
'x-component-props': {
rows: 4,
},
'x-rules': {
max: 200,
},
},
picture: {
type: 'string',
title: '图片',
'x-component': 'Upload',
'x-component-props': {
listType: 'card',
action: '/api/file/file/upload/prefix',
data: {
fileType: UPLOAD_TYPE,
prefix: '/purchaserEvaluation/',
},
beforeUpload: '{{beforeUpload}}',
accept: '.png, .jpg, .jpeg',
},
'x-mega-props': {
addonAfter: '{{UploadTip}}',
},
},
},
},
smile: {
type: 'object',
default: 1,
'x-component': 'SmilingFace',
'x-component-props': {
position: 'right',
},
},
},
},
},
},
},
},
};
\ No newline at end of file
import React, { useState, useEffect } from 'react';
import {
PageHeader,
Descriptions,
Card,
Spin,
Button,
message,
} from 'antd';
import { FormOutlined } from '@ant-design/icons';
import { PageHeaderWrapper } from '@ant-design/pro-layout';
import { history } from 'umi';
import { createFormActions, FormEffectHooks, FormPath } from '@formily/antd';
import { usePageStatus } from '@/hooks/usePageStatus';
import { PublicApi } from '@/services/api';
import { GetOrderPurchaseOrderDetailsResponse } from '@/services/OrderApi';
import { normalizeFiledata } from '@/utils';
import AvatarWrap from '@/components/AvatarWrap';
import NiceForm from '@/components/NiceForm';
import { normalizeUnevaluatedList } from '../../utils';
import { evaluateSchema } from './schema';
import { createEffects } from './effects';
import EvaluationList from '../../components/EvaluationList';
import styles from './index.less';
const formActions = createFormActions();
interface Unevaluated {
good: {
pic: string,
name: string,
price: string,
desc: string,
};
star: number;
comment: string;
picture: string[];
smile: number;
};
interface OrderInfo extends GetOrderPurchaseOrderDetailsResponse {
unevaluatedList: Unevaluated[];
};
const EvaluateOrder: React.FC = () => {
const { id } = usePageStatus();
const [orderInfo, setOrderInfo] = useState<OrderInfo>(null);
const [infoLoading, setInfoLoading] = useState(false);
const [submitLoading, setSubmitLoading] = useState(false);
const getOrderInfo = () => {
if (!id) {
return;
}
setInfoLoading(true);
PublicApi.getOrderProcurementOrderDetails({
id,
}).then(res => {
if (res.code === 1000) {
const { orderProductRequests } = res.data;
setOrderInfo({
...res.data,
unevaluatedList: normalizeUnevaluatedList(orderProductRequests),
});
}
}).finally(() => {
setInfoLoading(false);
});
};
useEffect(() => {
getOrderInfo();
}, []);
const handleSubmit = values => {
setSubmitLoading(true);
const payload = values.comments.map(item => {
const {
comment,
good,
picture,
star,
} = item;
return {
memberId: orderInfo.supplyMembersId,
roleId: orderInfo.supplyMembersRoleId,
memberName: orderInfo.supplyMembersName || '',
star,
comment,
product: JSON.stringify(good),
remark: orderInfo.orderNo,
productId: good.productId,
orderId: orderInfo.id,
productImgUrl: good.pic,
dealTime: orderInfo.createTime,
dealCount: good.purchaseCount,
price: good.price,
totalPrice: orderInfo.sumPrice,
pics: picture.map(item => item.status === 'done' && item.data).filter(Boolean),
};
});
PublicApi.postMemberCommentConsumerOrderTradeSubmit({
commentSubmitDetailList: payload,
}).then(res => {
if (res.code === 1000) {
setTimeout(() => {
history.goBack();
}, 800);
}
}).finally(() => {
setSubmitLoading(false);
});
};
const beforeUpload = file => {
if (file.size / 1024 < 10) {
message.warning('图片大小超过10M');
return Promise.reject();
}
};
const UploadTip = (
<span
style={{
lineHeight: '24px',
color: '#909399',
fontWeight: 400,
wordBreak: 'break-all',
position: 'relative',
top: '34px',
}}
>
支持JPG/PNG/JPEG <br />每张最大不超过 10M,尺寸不限 <br />最大数量限制 4张
</span>
);
return (
<Spin spinning={infoLoading}>
<PageHeaderWrapper
title={
<>
<PageHeader
style={{ padding: '0' }}
onBack={() => history.goBack()}
title={
<AvatarWrap
info={{
aloneTxt: '单',
name: orderInfo?.orderNo,
}}
/>
}
extra={(
<>
<Button
type="primary"
icon={<FormOutlined />}
disabled={!orderInfo || !orderInfo.id}
loading={submitLoading}
onClick={() => formActions.submit()}
>
发布
</Button>
</>
)}
>
<Descriptions
size="small"
column={3}
style={{
padding: '0 32px',
}}
>
<Descriptions.Item label="供应会员">{orderInfo?.supplyMembersName}</Descriptions.Item>
<Descriptions.Item label="下单时间" span={2}>{orderInfo?.createTime}</Descriptions.Item>
</Descriptions>
</PageHeader>
</>
}
>
<NiceForm
actions={formActions}
initialValues={{
comments: orderInfo ? orderInfo.unevaluatedList : [],
}}
expressionScope={{
UploadTip,
beforeUpload,
}}
onSubmit={handleSubmit}
components={{
EvaluationList,
}}
effects={($, actions) => {
createEffects($, actions);
}}
schema={evaluateSchema}
/>
</PageHeaderWrapper>
</Spin>
);
};
export default EvaluateOrder;
\ No newline at end of file
/*
* @Author: XieZhiXiong
* @Date: 2020-09-23 17:00:24
* @LastEditors: XieZhiXiong
* @LastEditTime: 2020-10-20 17:58:51
* @Description:
*/
import { ISchema } from '@formily/antd';
import { UPLOAD_TYPE } from '@/constants';
export const evaluateSchema: ISchema = {
type: 'object',
properties: {
comments: {
type: 'array',
'x-component': 'EvaluationList',
default: [],
items: {
type: 'object',
properties: {
LEFT_RIGHT: {
type: 'object',
'x-component': 'LeftRightLayout',
'x-component-props': {
rightProps: {
span: 2,
offset: 4,
},
},
properties: {
MEGA_LADYOUT: {
type: 'object',
'x-component': 'Mega-Layout',
'x-component-props': {
labelCol: 6,
labelAlign: 'left',
position: 'left',
},
properties: {
star: {
title: '满意程度',
required: true,
'x-component': 'Rating',
'x-component-props': {
allowHalf: false,
},
'x-rules': [
{
required: true,
message: '请选择满意程度',
},
],
},
comment: {
type: 'string',
title: '评价',
'x-component': 'TextArea',
'x-component-props': {
rows: 4,
},
'x-rules': {
max: 200,
},
},
picture: {
type: 'string',
title: '图片',
'x-component': 'Upload',
'x-component-props': {
listType: 'card',
action: '/api/file/file/upload/prefix',
data: {
fileType: UPLOAD_TYPE,
prefix: '/purchaserEvaluation/',
},
beforeUpload: '{{beforeUpload}}',
accept: '.png, .jpg, .jpeg',
},
'x-mega-props': {
addonAfter: '{{UploadTip}}',
},
},
},
},
smile: {
type: 'object',
default: 1,
'x-component': 'SmilingFace',
'x-component-props': {
position: 'right',
},
},
},
},
},
},
},
},
};
\ 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