Commit 1f404c81 authored by Bill's avatar Bill

fix: 修改加工订单数据

parent a4b90600
......@@ -61,12 +61,13 @@ export const orderProductColumns = [
},
{
title: `${intl.formatMessage({id: 'handling.assign.add.orderNum'})}`,
dataIndex: 'purchaseCount'
dataIndex: 'purchaseCount',
render: (text, record) => record.quantity
},
{
title: `${intl.formatMessage({id: 'handling.restProcessNum'})}`,
dataIndex: 'restNum',
render: (text, record) => +record.purchaseCount - (+record.processNum || 0)
render: (text, record) => +record.quantity - (+record.enhanceCount || 0)
},
{
title: `${intl.formatMessage({id: 'handling.hasProcessNm'})}`,
......
......@@ -54,6 +54,11 @@ registerVirtualBox('MellowCardBox', (_props) => {
)
})
type OrderProductType = GetOrderCommonEnhancePageResponseDetail["products"][0] & {
orderId: number,
orderNo: string
}
/** @tofix 临时的,因为后端不返回只能值么临时搞着 */
const MALL_NAME = {
"1": intl.formatMessage({id: 'handling.qiyeshangcheng'}),
......@@ -512,13 +517,16 @@ const Create = () => {
/** -------------- 加工商品相关结束 --------------- */
/** ------- 加工订单相关 -------*/
const onSelectChange = async (record: GetOrderCommonEnhancePageResponseDetail["products"][0], selected: boolean, selectedRows) => {
const currentOrderData = fetchedOrderData?.filter((_item) => _item.id === record.orderId)[0];
const key = `${record.orderId}_${record.id}`
const onSelectChange = async (record: OrderProductType, selected: boolean, selectedRows) => {
console.log(record, "fetchedOrderData", fetchedOrderData);
// 父级order 存储信息
const currentOrderData = fetchedOrderData?.find((_item) => _item.orderId === record.orderId)
console.log("orderProductselectRowRecord", orderProductselectRowRecord, "orderProductSelectRowKeys",orderProductSelectRowKeys, "setProcessOrder", processOrder)
const key = `${record.orderId}_${record.orderProductId}`
if (!selected) {
setOrderProductSelectRowKeys((prev) => prev.filter((_row) => (_row !== key)));
setOrderProductSelectRowRecord((prev) => prev.filter((_item) => `${_item.orderId}_${_item.id}` !== key ))
setProcessOrder((prev) => prev.filter((_item) => _item.id !== record.orderId))
setOrderProductSelectRowRecord((prev) => prev.filter((_item) => `${_item.orderId}_${_item.orderProductId}` !== key ))
setProcessOrder((prev) => prev.filter((_item) => _item.orderId !== record.orderId))
} else {
const children = currentOrderData.products;
const tempData = orderProductselectRowRecord.concat(record);
......@@ -558,13 +566,13 @@ const Create = () => {
},
onSelectAll: async (selected: boolean, selectedRows: GetOrderCommonEnhancePageResponseDetail['products'], changeRows: any[]) => {
const filterEmptyRows = changeRows.filter(Boolean)
const keys = filterEmptyRows.map((_item) => `${_item.orderId}_${_item.id}`);
const keys = filterEmptyRows.map((_item) => `${_item.orderId}_${_item.orderProductId}`);
const orderId = changeRows[0].orderId;
const currentOrderData = fetchedOrderData?.filter((_item) => _item.id === orderId)[0];
const currentOrderData = fetchedOrderData?.find((_item) => _item.orderId === orderId)
if (selected) {
const addTempRow = orderProductselectRowRecord.concat(filterEmptyRows);
const addTempRowKeys = addTempRow.map((_item) => `${_item.orderId}_${_item.id}`)
const addTempRowKeys = addTempRow.map((_item) => `${_item.orderId}_${_item.orderProductId}`)
/** @toRemove 这里逻辑重复,且要删除,让后端添加时自己判断 */
const formatData = addTempRow.map((_item) => {
......@@ -593,9 +601,9 @@ const Create = () => {
const removeKeys = orderProductSelectRowKeys.filter((_item) =>!keys.includes(_item))
// const removeRecord =
setOrderProductSelectRowKeys(removeKeys)
setOrderProductSelectRowRecord((prev) => prev.filter((_item) => !keys.includes(`${_item.orderId}_${_item.id}`)))
setOrderProductSelectRowRecord((prev) => prev.filter((_item) => !keys.includes(`${_item.orderId}_${_item.orderProductId}`)))
if (currentOrderData.products.length !== removeKeys.length) {
setProcessOrder((prev) => prev.filter((_item) => _item.id !== currentOrderData.id))
setProcessOrder((prev) => prev.filter((_item) => _item.orderId !== currentOrderData.orderId))
}
}
}
......@@ -626,18 +634,20 @@ const Create = () => {
}, [])
const handleBeforeOrderChecked = async (record: GetOrderCommonEnhancePageResponseDetail, checked: boolean, selectedRows: GetOrderCommonEnhancePageResponseDetail[]) => {
const { products, orderNo, id } = record;
const keys = products.map((_item) => `${_item.orderId}_${_item.id}`);
const { products, orderNo, orderId } = record;
const keys = products.map((_item) => `${orderId}_${_item.orderProductId}`);
if (checked) {
const uniqueKeys = Array.from(new Set(orderProductSelectRowKeys.concat(keys)))
const uniqueList = orderProductselectRowRecord.concat(
products.map((_item) => {
return {
orderNo: orderNo,
orderId: record.orderId,
..._item,
}
})
)
console.log(uniqueList)
const formatData = uniqueList.map((_item) => {
return {
productId: _item.productId,
......@@ -658,36 +668,36 @@ const Create = () => {
return false
} else {
setOrderProductSelectRowKeys((prev) => prev.filter((_row) => !keys.includes(_row)));
setOrderProductSelectRowRecord((prev) => prev.filter((_row) => !keys.includes(`${_row.orderId}_${_row.id}`)))
setProcessOrder((prev) => prev.filter((_item) => _item.id !== id))
setOrderProductSelectRowRecord((prev) => prev.filter((_row) => !keys.includes(`${_row.orderId}_${_row.orderProductId}`)))
setProcessOrder((prev) => prev.filter((_item) => _item.orderId !== orderId))
}
return true;
}
const tiggerProcessOrderProductOk = () => {
// const productOrderList = orderProductselectRowRecord.
const orderList = formActions.getFieldValue('detail.layout1.orderList');
const uniqueIdList = new Set(orderList.map((_item) => `${_item.orderId}_${_item.id}`));
const uniqueIdList = new Set(orderList.map((_item) => `${_item.orderId}_${_item.orderProductId}`));
/** 获取新增数列 */
const newAddList = orderProductselectRowRecord
.filter((_item) => !uniqueIdList.has(`${_item.orderId}_${_item.id}`))
.filter((_item) => !uniqueIdList.has(`${_item.orderId}_${_item.orderProductId}`))
.map((_item) => {
const surplusProcessNum = _item.purchaseCount - +_item.processNum
const surplusProcessNum = +_item.quantity - +_item.enhanceCount
return {
orderNo: _item.orderNo,
orderId: _item.orderId,
/** 主键id */
id: _item.id,
skuid: _item.productId,
commodityId: _item.commodityId || _item.productId,
id: _item.orderProductId,
skuid: _item.orderProductId,
commodityId: _item.orderProductId,
mainPic: _item.imgUrl,
name: _item.productName,
name: _item.name,
category: _item.category,
brand: _item.brand,
unitName: _item.unit,
purchaseCount: _item.purchaseCount,
purchaseCountAndUnit: `${_item.purchaseCount}/${_item.unit}`,
purchaseCount: +_item.quantity,
purchaseCountAndUnit: `${_item.quantity}/${_item.unit}`,
surplusProcessNum: surplusProcessNum,
surplusAndProcessNum: `${surplusProcessNum} / 0`
surplusAndProcessNum: `${surplusProcessNum} / ${_item.enhanceCount}`
}
});
......@@ -968,25 +978,27 @@ const Create = () => {
rowSelection={{
getCheckboxProps: (_record) => {
return {
disabled: _record.products.every((_item) => _item.purchaseCount - _item.processNum <= 0)
disabled: _record.products.every((_item) => +_item.quantity - +_item.enhanceCount <= 0)
}
}
}}
tableProps={{
rowKey: (record) => `${record.id}`,
rowKey: (record) => `${record.orderId}`,
// disabled: products.every((_i) => ),
expandable: {
expandedRowRender: (record) => {
const withOrderNo = record.products.map((_item) => {
return {
..._item,
orderNo: record.orderNo
orderNo: record.orderNo,
orderId: record.orderId,
}
})
return (
<Table
columns={orderProductColumns}
rowKey={(row) => `${row.orderId}_${row.id}`}
// rowKey={(row) => `${row.orderId}_${row.id}`}
rowKey={(row) => `${row.orderId}_${row.orderProductId}`}
dataSource={withOrderNo}
rowSelection={orderProductRowSelection}
pagination={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