Commit 1f404c81 authored by Bill's avatar Bill

fix: 修改加工订单数据

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