Commit 570a39b8 authored by XieZhiXiong's avatar XieZhiXiong

feat: 跟进评价接口

parent f19b7121
......@@ -2,7 +2,7 @@
* @Author: XieZhiXiong
* @Date: 2021-07-16 16:53:17
* @LastEditors: XieZhiXiong
* @LastEditTime: 2021-08-09 16:18:13
* @LastEditTime: 2021-08-09 18:40:47
* @Description: 评价 schema
*/
import { ISchema } from '@formily/antd';
......@@ -55,31 +55,55 @@ export const evaluateSchema: ISchema = {
'x-rules': {
max: 200,
},
},
picture: {
type: 'string',
title: '图片',
'x-component': 'FixUpload',
},
MEGA_LADYOUT: {
type: 'object',
'x-component': 'Mega-Layout',
'x-component-props': {
listType: 'card',
action: '/api/file/file/upload/prefix',
data: {
fileType: UPLOAD_TYPE,
prefix: '',
},
beforeUpload: '{{beforeUpload}}',
accept: '.png, .jpg, .jpeg',
labelCol: 9,
labelAlign: 'left',
grid: true,
full: true,
autoRow: true,
},
'x-rules': [
{
max: 4,
message: '最多可上传4张图片',
},
],
'x-mega-props': {
addonAfter: '{{UploadTip}}',
properties: {
picture: {
type: 'string',
title: '图片',
'x-component': 'FixUpload',
'x-mega-props': {
span: 2,
},
'x-component-props': {
listType: 'card',
action: '/api/file/file/upload/prefix',
data: {
fileType: UPLOAD_TYPE,
prefix: '',
},
beforeUpload: '{{beforeUpload}}',
accept: '.png, .jpg, .jpeg',
},
'x-rules': [
{
max: 4,
message: '最多可上传4张图片',
},
],
// 'x-mega-props': {
// addonAfter: '{{UploadTip}}',
// },
},
UPLOAD_TIP: {
type: 'object',
'x-mega-props': {
span: 1,
grid: false,
},
'x-component': 'UploadTip',
},
},
},
},
},
},
smile: {
......
......@@ -60,10 +60,18 @@ const EvaluateOrder: React.FC = () => {
id,
} as any).then(res => {
if (res.code === 1000) {
const { orderProductCommentList } = res.data;
const { orderProductCommentList } = res.data;
const unevaluatedList = normalizeUnevaluatedList(orderProductCommentList);
setOrderInfo({
...res.data,
unevaluatedList: normalizeUnevaluatedList(orderProductCommentList),
...res.data,
unevaluatedList,
});
unevaluatedList.forEach((item, index) => {
if (item.completeCommentStatus) {
formActions.setFieldState(`comments.${index}.*`, (fieldState) => {
fieldState.editable = false;
});
}
});
}
}).finally(() => {
......@@ -102,13 +110,8 @@ const EvaluateOrder: React.FC = () => {
});
PublicApi.postMemberCommentConsumerOrderTradeSubmit({
memberId: orderInfo.supplyMembersId,
roleId: orderInfo.supplyMembersRoleId,
orderId: orderInfo.id,
orderNo: orderInfo.orderNo,
orderType: orderInfo.type,
orderId: orderInfo.orderId,
commentSubmitDetailList: payload,
shopId: orderInfo.shopId,
}).then(res => {
if (res.code === 1000) {
setUnsaved(false);
......@@ -131,19 +134,18 @@ const EvaluateOrder: React.FC = () => {
return Promise.resolve();
};
const UploadTip = (
<span
const UploadTip = () => (
<div
style={{
lineHeight: '24px',
color: '#909399',
fontWeight: 400,
wordBreak: 'break-all',
position: 'relative',
top: '34px',
}}
>
支持JPG/PNG/JPEG <br />每张最大不超过 10M,尺寸不限 <br />最大数量限制 4张
</span>
</div>
);
return (
......@@ -202,12 +204,12 @@ const EvaluateOrder: React.FC = () => {
comments: orderInfo ? orderInfo.unevaluatedList : [],
}}
expressionScope={{
UploadTip,
beforeUpload,
}}
onSubmit={handleSubmit}
components={{
EvaluationList,
EvaluationList,
UploadTip,
}}
effects={($, actions) => {
createEffects($, actions);
......
......@@ -2,7 +2,7 @@
* @Author: XieZhiXiong
* @Date: 2020-10-19 16:02:53
* @LastEditors: XieZhiXiong
* @LastEditTime: 2021-08-09 16:00:36
* @LastEditTime: 2021-08-09 18:30:30
* @Description:
*/
......@@ -15,24 +15,23 @@ export const normalizeUnevaluatedList = (arr: {[key: string]: any}[]) => {
}
arr.forEach(item => {
// 未评价过的
if (!item.commentStatus) {
const atom = {
good: {
pic: item.logo || '',
productId: item.productId,
productName: item.name,
unit: item.unit,
price: item.price,
purchaseCount: item.quantity, // 采购数量
totalPrice: item.amount,
},
star: undefined, // 评分星星
comment: '', // 评价
picture: [],
smile: undefined, // 笑脸
};
ret.push(atom);
}
const atom = {
good: {
pic: item.logo || '',
productId: item.productId,
productName: item.name,
unit: item.unit,
price: item.price,
purchaseCount: item.quantity, // 采购数量
totalPrice: item.amount,
},
star: undefined, // 评分星星
comment: undefined, // 评价
picture: [],
smile: undefined, // 笑脸
completeCommentStatus: item.completeCommentStatus,
};
ret.push(atom);
});
return ret;
......
......@@ -14,7 +14,7 @@ import moment from 'moment';
import { createFormActions, FormEffectHooks } from '@formily/antd';
import { usePageStatus } from '@/hooks/usePageStatus';
import { PublicApi } from '@/services/api';
import { GetOrderPurchaseOrderDetailsResponse } from '@/services/OrderApi';
import { GetMemberCommentSupplyOrderTradeDetailResponse } from '@/services/MemberV2Api';
import AvatarWrap from '@/components/AvatarWrap';
import NiceForm from '@/components/NiceForm';
import { normalizeUnevaluatedList } from '../../../purchaserEvaluation/utils';
......@@ -40,7 +40,7 @@ interface Unevaluated {
smile: number;
};
interface OrderInfo extends GetOrderPurchaseOrderDetailsResponse {
interface OrderInfo extends GetMemberCommentSupplyOrderTradeDetailResponse {
unevaluatedList: Unevaluated[];
};
......@@ -56,15 +56,22 @@ const EvaluateOrder: React.FC = () => {
return;
}
setInfoLoading(true);
PublicApi.getOrderPurchaseOrderDetails({
PublicApi.getMemberCommentSupplyOrderTradeDetail({
id,
orderNo: '',
}).then(res => {
if (res.code === 1000) {
const { orderProductRequests } = res.data;
const { orderProductCommentList } = res.data;
const unevaluatedList = normalizeUnevaluatedList(orderProductCommentList);
setOrderInfo({
...res.data,
unevaluatedList: normalizeUnevaluatedList(orderProductRequests),
...res.data,
unevaluatedList,
});
unevaluatedList.forEach((item, index) => {
if (item.completeCommentStatus) {
formActions.setFieldState(`comments.${index}.*`, (fieldState) => {
fieldState.editable = false;
});
}
});
}
}).finally(() => {
......@@ -103,13 +110,8 @@ const EvaluateOrder: React.FC = () => {
});
PublicApi.postMemberCommentSupplyOrderTradeSubmit({
memberId: orderInfo.createMemberId,
roleId: orderInfo.createRoleId,
orderId: orderInfo.id,
orderNo: orderInfo.orderNo,
orderType: orderInfo.type,
orderId: orderInfo.orderId,
commentSubmitDetailList: payload,
shopId: orderInfo.shopId,
}).then(res => {
if (res.code === 1000) {
setUnsaved(false);
......@@ -132,19 +134,18 @@ const EvaluateOrder: React.FC = () => {
return Promise.resolve();
};
const UploadTip = (
<span
const UploadTip = () => (
<div
style={{
lineHeight: '24px',
color: '#909399',
fontWeight: 400,
wordBreak: 'break-all',
position: 'relative',
top: '34px',
}}
>
支持JPG/PNG/JPEG <br />每张最大不超过 10M,尺寸不限 <br />最大数量限制 4张
</span>
</div>
);
return (
......@@ -171,7 +172,7 @@ const EvaluateOrder: React.FC = () => {
<Button
type="primary"
icon={<FormOutlined />}
disabled={!orderInfo || !orderInfo.id}
disabled={!orderInfo}
loading={submitLoading}
onClick={() => formActions.submit()}
>
......@@ -187,7 +188,7 @@ const EvaluateOrder: React.FC = () => {
padding: '0 32px',
}}
>
<Descriptions.Item label="供应会员">{orderInfo?.supplyMembersName}</Descriptions.Item>
<Descriptions.Item label="供应会员">{orderInfo?.membersName}</Descriptions.Item>
<Descriptions.Item label="下单时间" span={2}>
{orderInfo && orderInfo.createTime ? moment(orderInfo.createTime).format('YYYY-MM-DD HH:mm:ss') : ''}
</Descriptions.Item>
......@@ -203,12 +204,12 @@ const EvaluateOrder: React.FC = () => {
comments: orderInfo ? orderInfo.unevaluatedList : [],
}}
expressionScope={{
UploadTip,
beforeUpload,
}}
onSubmit={handleSubmit}
components={{
EvaluationList,
EvaluationList,
UploadTip,
}}
effects={($, actions) => {
createEffects($, actions);
......
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