Commit cd338a80 authored by XieZhiXiong's avatar XieZhiXiong

fix: 修复无法勾选父级的问题

parent 3434c348
......@@ -2,7 +2,7 @@
* @Author: XieZhiXiong
* @Date: 2020-11-04 15:09:09
* @LastEditors: XieZhiXiong
* @LastEditTime: 2021-08-09 16:39:07
* @LastEditTime: 2021-08-10 11:29:44
* @Description: 维修商品抽屉组件
*/
import React from 'react';
......@@ -179,45 +179,50 @@ class GoodsDrawer extends React.Component<GoodsDrawerProps, GoodsDrawerState> {
}
this.setState({ loading: true });
const orderListRes = await fetchOrderList({
current: `${page}`,
pageSize: `${size}`,
...searchVal,
});
if (orderListRes) {
const { data, ...rest } = orderListRes;
const newData: { [key: string]: any }[] = data.map((item) => ({
...item,
products: item.products.map(({ productId, ...rest }) => ({
id: productId,
...rest,
quantity: +rest.quantity,
purchasePrice: +rest.purchasePrice,
tax: rest.tax ? 1 : 0,
taxRate: +rest.taxRate,
orderNo: item.orderNo,
orderId: item.orderId,
payInfoList: item.payInfoList,
orderType: item.orderType,
contractId: item.contractId,
contractNo: item.contractNo,
})),
}));
newData.forEach((item) => {
item.products.forEach((product) => {
// 防止重复添加数据
if (!this.flattened.find(flat => flat.id === product.id)) {
this.flattened.push(product);
}
});
});
this.setState({
dataSource: {
data: newData,
...rest,
},
try {
const orderListRes = await fetchOrderList({
current: `${page}`,
pageSize: `${size}`,
...searchVal,
});
if (orderListRes) {
const { data, ...rest } = orderListRes;
const newData: { [key: string]: any }[] = data.map((item) => ({
...item,
id: item.orderId,
products: item.products.map(({ productId, ...rest }) => ({
id: productId,
...rest,
quantity: +rest.quantity,
purchasePrice: +rest.purchasePrice,
tax: rest.tax ? 1 : 0,
taxRate: +rest.taxRate,
orderNo: item.orderNo,
orderId: item.orderId,
payInfoList: item.payInfoList,
orderType: item.orderType,
contractId: item.contractId,
contractNo: item.contractNo,
})),
}));
newData.forEach((item) => {
item.products.forEach((product) => {
// 防止重复添加数据
if (!this.flattened.find(flat => flat.id === product.id)) {
this.flattened.push(product);
}
});
});
this.setState({
dataSource: {
data: newData,
...rest,
},
});
}
} catch (error) {
console.warn('error', error);
}
this.setState({ loading: 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