Commit 04a3136b authored by Bill's avatar Bill

Merge branch 'dev' of 10.0.0.22:lingxi/lingxi-business-paltform into dev

parents 95ddd461 a438be94
......@@ -1855,7 +1855,7 @@ export const PAY_CHANNEL_UNION = 3;
*/
export const PAY_CHANNEL_BALANCE = 4;
/**
* 线下支付
* 线下支付线上确认
*/
export const PAY_CHANNEL_OFFLINE = 5;
/**
......@@ -1875,7 +1875,7 @@ export const PAY_CHANNEL = {
[PAY_CHANNEL_WECHAT]: '微信',
[PAY_CHANNEL_UNION]: '银联',
[PAY_CHANNEL_BALANCE]: '余额',
[PAY_CHANNEL_OFFLINE]: '线下支付',
[PAY_CHANNEL_OFFLINE]: '线下支付线上确认',
[PAY_CHANNEL_CREDIT]: '授信',
[PAY_CHANNEL_COD]: '货到付款',
};
......@@ -359,6 +359,6 @@ a {
}
}
.ant-form-horizontal .ant-form-item-control {
.mega-layout-container-content {
overflow: hidden;
}
/*
* @Author: XieZhiXiong
* @Date: 2020-11-03 18:30:47
* @LastEditors: XieZhiXiong
* @LastEditTime: 2020-12-08 09:53:29
* @Description: 联动逻辑相关
*/
import { Modal } from 'antd';
import { FormEffectHooks, FormPath } from '@formily/antd';
import { useLinkageUtils } from '@/utils/formEffectUtils';
import { useStateFilterSearchLinkageEffect } from '@/formSchema/effects/useFilterSearch';
import { PublicApi } from '@/services/api';
const {
onFieldInputChange$,
onFieldValueChange$,
} = FormEffectHooks;
export const useBusinessEffects = (context, actions) => {
const {
getFieldValue,
setFieldValue,
getFieldState,
setFieldState,
} = actions;
const linkage = useLinkageUtils();
// 联动退款金额
onFieldValueChange$('payList.*.refundAmount').subscribe(fieldState => {
const payListValue = getFieldValue('payList');
const amount = payListValue.reduce((pre, now) => +now.refundAmount + pre, 0);
setFieldValue('refundAmount', amount);
});
// 退款数量 联动,支付信息里边的 退款金额
onFieldInputChange$('returnCount').subscribe(fieldState => {
const { value } = fieldState;
const purchasePriceValue = getFieldValue('purchasePrice');
const newData = [...getFieldValue('payList')].map(item => {
return {
...item,
refundAmount: +(+value * purchasePriceValue * (item.payRatio / 100)).toFixed(2),
};
});
setFieldValue('payList', newData);
});
// 校验退货数量
onFieldInputChange$('returnCount').subscribe(fieldState => {
const { name, value } = fieldState;
// 采购数量
const purchaseCountValue = getFieldValue('purchaseCount');
setFieldState(
'returnCount',
state => {
if (+value > purchaseCountValue) {
state.errors = '填写值已超过最大可退货数量,请重新填写';
} else {
state.errors = '';
}
}
);
});
/*
* @Author: XieZhiXiong
* @Date: 2020-11-03 18:30:47
* @LastEditors: XieZhiXiong
* @LastEditTime: 2021-01-05 13:53:58
* @Description: 联动逻辑相关
*/
import { Modal } from 'antd';
import { FormEffectHooks, FormPath } from '@formily/antd';
import { useLinkageUtils } from '@/utils/formEffectUtils';
import { useStateFilterSearchLinkageEffect } from '@/formSchema/effects/useFilterSearch';
import { PublicApi } from '@/services/api';
const {
onFieldInputChange$,
onFieldValueChange$,
} = FormEffectHooks;
export const useBusinessEffects = (context, actions) => {
const {
getFieldValue,
setFieldValue,
getFieldState,
setFieldState,
} = actions;
const linkage = useLinkageUtils();
// 联动退款金额
onFieldValueChange$('payList.*.refundAmount').subscribe(fieldState => {
const payListValue = getFieldValue('payList');
const amount = payListValue.reduce((pre, now) => +now.refundAmount + pre, 0);
setFieldValue('refundAmount', amount);
});
// 退款数量 联动,支付信息里边的 退款金额
onFieldInputChange$('returnCount').subscribe(fieldState => {
const { value } = fieldState;
const purchasePriceValue = getFieldValue('purchasePrice');
const newData = [...getFieldValue('payList')].map(item => {
return {
...item,
refundAmount: +(+value * purchasePriceValue * (item.payRatio / 100)).toFixed(2),
};
});
setFieldValue('payList', newData);
});
// 校验退货数量
onFieldInputChange$('returnCount').subscribe(fieldState => {
const { name, value } = fieldState;
// 采购数量
const remainingValue = getFieldValue('remaining');
setFieldState(
'returnCount',
state => {
if (+value > remainingValue) {
state.errors = '填写值已超过最大可退货数量,请重新填写';
} else {
state.errors = '';
}
}
);
});
}
\ No newline at end of file
......@@ -2,7 +2,7 @@
* @Author: XieZhiXiong
* @Date: 2020-11-05 17:36:45
* @LastEditors: XieZhiXiong
* @LastEditTime: 2020-12-21 11:13:21
* @LastEditTime: 2021-01-05 13:51:21
* @Description: 查看退货数量与退款金额 抽屉
*/
import React from 'react';
......@@ -94,6 +94,10 @@ export interface OrderInfo {
*/
payList: PayListItem;
/**
* 剩余可退货数量
*/
remaining: number;
/**
* 退款数量
*/
returnCount?: number | string;
......@@ -130,7 +134,8 @@ const ReturnInfoDrawer: React.FC<ReturnInfoDrawerProps> = ({
const handleSubmit = values => {
if (onSubmit) {
onSubmit(values);
const { remaining, ...rest } = values;
onSubmit(rest);
} else {
onClose();
}
......
......@@ -58,7 +58,7 @@ export const useBusinessEffects = (context, actions) => {
FormPath.transform(name, /\d/, $1 => {
return `replaceGoodsList.${$1}.extraData`
}),
state => state.value.replacedCount,
state => state.value.remaining,
);
setFieldState(
......
......@@ -5,6 +5,7 @@ import { DeleteOutlined } from '@ant-design/icons';
import { Radio, ArrayTable } from '@formily/antd-components';
import { history, Prompt } from 'umi';
import moment from 'moment';
import { findLastIndex } from 'lodash';
import { PageHeaderWrapper } from '@ant-design/pro-layout';
import { SaveOutlined, PlusOutlined } from '@ant-design/icons';
import { createFormActions, FormEffectHooks } from '@formily/antd';
......@@ -251,7 +252,7 @@ const ExchangeForm: React.FC<BillsFormProps> = ({
data: goodsDetailList.map(item => ({
...item,
extraData: {
replacedCount: item.purchaseCount || 0, // 已换货数量,这里取 采购数量判断即可
remaining: item.purchaseCount || 0, // 已换货数量,这里取 采购数量判断即可
id: item.orderRecordId,
taskType,
},
......@@ -426,30 +427,29 @@ const ExchangeForm: React.FC<BillsFormProps> = ({
const value = [];
values.forEach(item => {
const existing = preValues.find(val => val.id === item.id);
const atom =
existing ?
existing :
{
orderNo: item.orderNo,
productId: item.productId,
productName: item.productName,
category: item.category,
brand: item.brand,
unit: item.unit,
purchasePrice: item.price,
purchaseCount: item.purchaseCount,
purchaseAmount: +(item.price * item.purchaseCount).toFixed(2),
replaceReason: '',
extraData: {
replacedCount: item.replaceCount || item.purchaseCount || 0, // 已换货数量
id: item.id,
taskType: item.processEnum,
},
};
const atom = {
orderNo: item.orderNo,
productId: item.productId,
productName: item.productName,
category: item.category,
brand: item.brand,
unit: item.unit,
purchasePrice: item.price,
purchaseCount: item.purchaseCount,
purchaseAmount: +(item.price * item.purchaseCount).toFixed(2),
replaceReason: '',
extraData: {
remaining: item.purchaseCount - (item.replaceCount || 0), // 可换货数量
id: item.id,
taskType: item.processEnum,
},
};
value.push(atom);
});
addSchemaAction.setFieldValue('replaceGoodsList', value);
const concated = [...value, ...preValues];
const newData = concated.filter((item, index) => findLastIndex(concated, val => val.extraData.id === item.extraData.id) === index).reverse();
addSchemaAction.setFieldValue('replaceGoodsList', newData);
};
const handleGoodsChange = values => {
......
......@@ -35,7 +35,7 @@ export const useBusinessEffects = (context, actions) => {
FormPath.transform(name, /\d/, $1 => {
return `repairGoodsList.${$1}.extraData`
}),
state => state.value.repairedCount,
state => state.value.remaining,
);
setFieldState(
......
......@@ -4,6 +4,7 @@ import { DeleteOutlined } from '@ant-design/icons';
import { Radio, ArrayTable } from '@formily/antd-components';
import { history, Prompt } from 'umi';
import moment from 'moment';
import { findLastIndex } from 'lodash';
import { PageHeaderWrapper } from '@ant-design/pro-layout';
import { SaveOutlined, PlusOutlined } from '@ant-design/icons';
import { createFormActions, FormEffectHooks } from '@formily/antd';
......@@ -129,7 +130,7 @@ const RepairForm: React.FC<BillsFormProps> = ({
extraData: {
id: item.orderRecordId,
orderId: item.orderId,
repairedCount: item.purchaseCount || 0, // 已维修数量,这里取 采购数量判断即可
remaining: item.purchaseCount || 0, // 已维修数量,这里取 采购数量判断即可
},
})),
totalCount: res.data.totalCount,
......@@ -271,28 +272,26 @@ const RepairForm: React.FC<BillsFormProps> = ({
const value = [];
values.forEach(item => {
const existing = preValues.find(val => val.id === item.id);
const atom =
existing ?
existing :
{
orderNo: item.orderNo,
productId: item.productId,
productName: item.productName,
category: item.category,
brand: item.brand,
unit: item.unit,
purchaseCount: item.purchaseCount,
repairReason: '',
extraData: {
id: item.id,
orderId: item.orderId,
repairedCount: item.repairCount || item.purchaseCount || 0, // 已维修数量
},
};
const atom = {
orderNo: item.orderNo,
productId: item.productId,
productName: item.productName,
category: item.category,
brand: item.brand,
unit: item.unit,
purchaseCount: item.purchaseCount,
repairReason: '',
extraData: {
id: item.id,
orderId: item.orderId,
remaining: item.purchaseCount - (item.repairCount || 0), // 可维修数量
},
};
value.push(atom);
});
addSchemaAction.setFieldValue('repairGoodsList', value);
const concated = [...value, ...preValues];
const newData = concated.filter((item, index) => findLastIndex(concated, val => val.extraData.id === item.extraData.id) === index).reverse();
addSchemaAction.setFieldValue('repairGoodsList', newData);
};
const handleGoodsChange = values => {
......
......@@ -2,7 +2,7 @@
* @Author: XieZhiXiong
* @Date: 2020-11-03 18:30:47
* @LastEditors: XieZhiXiong
* @LastEditTime: 2020-12-09 16:18:45
* @LastEditTime: 2021-01-05 11:40:35
* @Description: 联动逻辑相关
*/
import { FormEffectHooks, FormPath } from '@formily/antd';
......
......@@ -5,6 +5,7 @@ import { DeleteOutlined } from '@ant-design/icons';
import { Radio, ArrayTable } from '@formily/antd-components';
import { history, Prompt } from 'umi';
import moment from 'moment';
import { findLastIndex } from 'lodash';
import { PageHeaderWrapper } from '@ant-design/pro-layout';
import { SaveOutlined, PlusOutlined } from '@ant-design/icons';
import { createFormActions, FormEffectHooks, FormPath } from '@formily/antd';
......@@ -60,7 +61,6 @@ const ReturnForm: React.FC<BillsFormProps> = ({
applyTime: moment().format('YYYY-MM-DD HH:mm:ss'),
});
const [returnGoodsList, setReturnGoodsList] = useState<GetAsReturnGoodsPageReturnedGoodsResponse>({ data: [], totalCount: 0 });
const [visible, setVisible] = useState(false);
const [unsaved, setUnsaved] = useState(false);
const [infoLoading, setInfoLoading] = useState(false);
const [submitLoading, setSubmitLoading] = useState(false);
......@@ -89,6 +89,7 @@ const ReturnForm: React.FC<BillsFormProps> = ({
title: '下单时间',
dataIndex: 'createTime',
align: 'center',
render: text => moment(text).format('YYYY-MM-DD HH:mm:ss'),
},
{
title: '订单状态',
......@@ -252,7 +253,7 @@ const ReturnForm: React.FC<BillsFormProps> = ({
setReturnGoodsList({
data: goodsDetailList.map(item => ({
...item,
returnedCount: item.purchaseCount || 0, // 已退货数量,这里取 采购数量判断即可
remaining: item.purchaseCount || 0, // 可退货数量,这里取 采购数量判断即可
extraData: {
returnReason: item.returnReason,
payList: item.payList || [],
......@@ -448,36 +449,35 @@ const ReturnForm: React.FC<BillsFormProps> = ({
const value = [];
values.forEach(item => {
const existing = preValues.find(val => val.extraData.id === item.id);
const atom =
existing ?
existing :
{
id: item.id,
orderId: item.orderId,
orderNo: item.orderNo,
productId: item.productId,
productName: item.productName,
category: item.category,
brand: item.brand,
unit: item.unit,
purchasePrice: item.price,
purchaseCount: item.purchaseCount,
purchaseAmount: +(item.price * item.purchaseCount).toFixed(2),
returnedCount: item.returnCount || item.purchaseCount || 0, // 已退货数量
payAmount: item.payAmount,
returnCount: '',
refundAmount: '',
extraData: {
id: item.id,
returnReason: '',
payList: item.payList,
taskType: item.processEnum,
},
};
const atom = {
id: item.id,
orderId: item.orderId,
orderNo: item.orderNo,
productId: item.productId,
productName: item.productName,
category: item.category,
brand: item.brand,
unit: item.unit,
purchasePrice: item.price,
purchaseCount: item.purchaseCount,
purchaseAmount: +(item.price * item.purchaseCount).toFixed(2),
payAmount: item.payAmount,
returnCount: '',
refundAmount: '',
extraData: {
id: item.id,
returnReason: '',
payList: item.payList,
taskType: item.processEnum,
remaining: item.purchaseCount - (item.returnCount || 0), // 可退货数量
},
};
value.push(atom);
});
addSchemaAction.setFieldValue('returnGoodsList', value);
const concated = [...value, ...preValues];
const newData = concated.filter((item, index) => findLastIndex(concated, val => val.extraData.id === item.extraData.id) === index).reverse();
addSchemaAction.setFieldValue('returnGoodsList', newData);
};
const handleGoodsChange = values => {
......@@ -493,6 +493,7 @@ const ReturnForm: React.FC<BillsFormProps> = ({
index,
...item,
payList: item.extraData.payList,
remaining: item.extraData.remaining,
});
setVisibleReturnInfoDrawer(true)
};
......
......@@ -861,11 +861,37 @@ const CommodityDetail = (props) => {
*/
const getAmount = (state = true) => {
const unitPrice = getUnitPrice()
const amount = unitPrice * (Number(buyCount) || 0)
const amount = accMul(unitPrice, buyCount)
return state ? priceFormat(amount) : amount
}
/**
** 乘法函数,用来得到精确的乘法结果
** 说明:javascript的乘法结果会有误差,在两个浮点数相乘的时候会比较明显。这个函数返回较为精确的乘法结果。
** 调用:accMul(arg1,arg2)
** 返回值:arg1乘以 arg2的精确结果
**/
const accMul = (arg1: number, arg2: number) => {
if(!arg1 || !arg2){
return 0
}
let m = 0
const s1 = arg1.toString()
const s2 = arg2.toString()
try {
m += s1.split(".")[1].length;
} catch (e) {
console.log(e)
}
try {
m += s2.split(".")[1].length;
} catch (e) {
console.log(e)
}
return Number(s1.replace(".", "")) * Number(s2.replace(".", "")) / Math.pow(10, m);
}
/**
* 获取金额区间中数量最大的区间
*/
const getMaxCountRange = () => {
......
......@@ -289,9 +289,9 @@ const QuotaMenage: React.FC = () => {
} = data;
return {
level: memberTypes.map(item => ({ label: item.memberTypeName, value: item.memberTypeId })),
memberTypeId: roles.map(item => ({ label: item.roleName, value: item.roleId })),
subRoleId: levels.map(item => ({ label: item.levelTag, value: item.level })),
memberTypeId: memberTypes.map(item => ({ label: item.memberTypeName, value: item.memberTypeId })),
subRoleId: roles.map(item => ({ label: item.roleName, value: item.roleId })),
level: levels.map(item => ({ label: item.levelTag, value: item.level })),
};
}
return {};
......
......@@ -5,6 +5,8 @@ import BillsForm from './components/BillsForm';
const BillsDetail: React.FC = () => {
const {
id,
deliveryNo = 0,
storageNo = 0,
invoicesTypeId, // 单据类型ID
relevanceInvoices, // 对应单据
relevanceInvoicesId, // 单据id,可能是待新增销售发货单,待新增采购入库单跳转过来的
......@@ -13,6 +15,8 @@ const BillsDetail: React.FC = () => {
return (
<BillsForm
id={id}
deliveryNo={deliveryNo}
storageNo={storageNo}
invoicesTypeId={invoicesTypeId}
relevanceInvoices={relevanceInvoices}
relevanceInvoicesId={relevanceInvoicesId}
......
......@@ -44,13 +44,33 @@ const {
} = FormEffectHooks;
interface BillsFormProps {
/**
* 单据id
*/
id?: string;
/**
* 发货单号
*/
deliveryNo?: number;
/**
* 入库单号
*/
storageNo?: number;
validateId?: string;
// 是否是编辑的
isEdit?: boolean;
invoicesTypeId: string; // 单据类型ID
relevanceInvoices: string; // 对应单据
relevanceInvoicesId: string, // 单据id,可能是待新增销售发货单,待新增采购入库单跳转过来的
/**
* 单据类型ID
*/
invoicesTypeId: string;
/**
* 对应单据
*/
relevanceInvoices: string;
/**
* 单据id,可能是待新增销售发货单,待新增采购入库单跳转过来的
*/
relevanceInvoicesId: string;
};
function transforDirection(type) {
......@@ -72,6 +92,8 @@ function transforDirection(type) {
const BillsForm: React.FC<BillsFormProps> = ({
id,
deliveryNo = 0,
storageNo = 0,
isEdit = false,
invoicesTypeId,
relevanceInvoices,
......@@ -143,6 +165,8 @@ const BillsForm: React.FC<BillsFormProps> = ({
setInfoLoading(true);
PublicApi.getWarehouseInvoicesDetails({
invoicesId: id,
deliveryNo,
storageNo,
}).then(res => {
if (res.code !== 1000) {
return;
......
......@@ -5,6 +5,8 @@ import BillsForm from './components/BillsForm';
const EditBills: React.FC = () => {
const {
id,
deliveryNo = 0,
storageNo = 0,
invoicesTypeId, // 单据类型ID
relevanceInvoices, // 对应单据
relevanceInvoicesId, // 单据id,可能是待新增销售发货单,待新增采购入库单跳转过来的
......@@ -13,6 +15,8 @@ const EditBills: React.FC = () => {
return (
<BillsForm
id={id}
deliveryNo={deliveryNo}
storageNo={storageNo}
invoicesTypeId={invoicesTypeId}
relevanceInvoices={relevanceInvoices}
relevanceInvoicesId={relevanceInvoicesId}
......
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