Commit 46350db2 authored by Bill's avatar Bill

fix: 修改加工订单接口

parent d82bf5f9
......@@ -27,11 +27,11 @@ import ProductDrawer, { productSubmitType, productInfo } from './components/Prod
import { priceFormat } from '@/utils/numberFomat';
import { orderColumns, orderProductColumns } from './common/columns/orderColumn';
import { orderSchema } from './common/schemas/orderSchema'
import { GetOrderProcessingOrderListRequest, GetOrderProcessingOrderListResponseDetail } from '@/services/OrderV2Api';
import { EnterpriceType, FileType, SubmitDataType, RestDataType, OtherAskType, SelectedProcessProductType } from './types';
import { history } from 'umi';
import moment from 'moment';
import useFormatData from './common/hooks/useFormatData';
import { GetOrderCommonEnhancePageRequest, GetOrderCommonEnhancePageResponseDetail } from '@/services/OrderV2NewApi';
const { confirm } = Modal;
......@@ -105,10 +105,10 @@ const Create = () => {
const [orderProductSelectRowKeys, setOrderProductSelectRowKeys] = useState<string[]>([])
const [orderProductselectRowRecord, setOrderProductSelectRowRecord] = useState<{[key: string]: any}[]>([]);
/** 勾选的加工订单数据 */
const [processOrder, setProcessOrder] = useState<GetOrderProcessingOrderListResponseDetail[]>([])
const [processOrder, setProcessOrder] = useState<GetOrderCommonEnhancePageResponseDetail[]>([])
/** ---- 加工订单end ------- */
/** 订单数据 */
const [fetchedOrderData, setFetchOrderData] = useState<GetOrderProcessingOrderListResponseDetail[]>([])
const [fetchedOrderData, setFetchOrderData] = useState<GetOrderCommonEnhancePageResponseDetail[]>([])
const [productActionType, setProductActionType] = useState<"view" | "edit">("view");
const [submitLoading, setSubmitLoading] = useState<boolean>(false);
......@@ -137,8 +137,8 @@ const Create = () => {
})
setProcessProduct(productList);
} else {
const initialProcessOrder = cacheInitialValue.orderList?.map((_item) => ({id: _item.orderId, productDateilss: _item})) || [];
setProcessOrder(initialProcessOrder as unknown as GetOrderProcessingOrderListResponseDetail[]);
const initialProcessOrder = cacheInitialValue.orderList?.map((_item) => ({id: _item.orderId, products: _item})) || [];
setProcessOrder(initialProcessOrder as unknown as GetOrderCommonEnhancePageResponseDetail[]);
setOrderProductSelectRowRecord(cacheInitialValue.orderList?.map((_item) => ({..._item, productId: _item.commodityId})) || []);
setOrderProductSelectRowKeys(cacheInitialValue.orderList?.map((_item) => `${_item.orderId}_${_item.id}`) || [])
}
......@@ -500,7 +500,7 @@ const Create = () => {
/** -------------- 加工商品相关结束 --------------- */
/** ------- 加工订单相关 -------*/
const onSelectChange = async (record: GetOrderProcessingOrderListResponseDetail["productDateilss"][0], selected: boolean, selectedRows) => {
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}`
if (!selected) {
......@@ -508,7 +508,7 @@ const Create = () => {
setOrderProductSelectRowRecord((prev) => prev.filter((_item) => `${_item.orderId}_${_item.id}` !== key ))
setProcessOrder((prev) => prev.filter((_item) => _item.id !== record.orderId))
} else {
const children = currentOrderData.productDateilss;
const children = currentOrderData.products;
const tempData = orderProductselectRowRecord.concat(record);
const keysList = tempData.filter((_item) => _item.orderId === record.orderId);
/** @toRemove 这里逻辑重复,且要删除,让后端添加时自己判断 */
......@@ -539,12 +539,12 @@ const Create = () => {
// type: 'checkbox',
selectedRowKeys: orderProductSelectRowKeys,
onSelect: onSelectChange,
getCheckboxProps: (record: GetOrderProcessingOrderListResponseDetail['productDateilss'][0]) => {
getCheckboxProps: (record: GetOrderCommonEnhancePageResponseDetail['products'][0]) => {
return {
disabled: record.purchaseCount - record.processNum <= 0, // Column configuration not to be checked
}
},
onSelectAll: async (selected: boolean, selectedRows: GetOrderProcessingOrderListResponseDetail['productDateilss'], changeRows: any[]) => {
onSelectAll: async (selected: boolean, selectedRows: GetOrderCommonEnhancePageResponseDetail['products'], changeRows: any[]) => {
const filterEmptyRows = changeRows.filter(Boolean)
const keys = filterEmptyRows.map((_item) => `${_item.orderId}_${_item.id}`);
const orderId = changeRows[0].orderId;
......@@ -572,7 +572,7 @@ const Create = () => {
setOrderProductSelectRowRecord(addTempRow)
const keysLength = addTempRowKeys.filter((_item) => _item.includes(orderId));
if (currentOrderData.productDateilss.length === keysLength.length) {
if (currentOrderData.products.length === keysLength.length) {
setProcessOrder((prev) => prev.concat(currentOrderData))
}
return;
......@@ -582,7 +582,7 @@ const Create = () => {
// const removeRecord =
setOrderProductSelectRowKeys(removeKeys)
setOrderProductSelectRowRecord((prev) => prev.filter((_item) => !keys.includes(`${_item.orderId}_${_item.id}`)))
if (currentOrderData.productDateilss.length !== removeKeys.length) {
if (currentOrderData.products.length !== removeKeys.length) {
setProcessOrder((prev) => prev.filter((_item) => _item.id !== currentOrderData.id))
}
}
......@@ -590,7 +590,7 @@ const Create = () => {
// onSelectAll: onSelectAll
}
const handleFetchOrderList = useCallback(async (params: GetOrderProcessingOrderListRequest) => {
const handleFetchOrderList = useCallback(async (params: GetOrderCommonEnhancePageRequest) => {
const { startCreateTime, endCreateTime, ...rest } = params as any;
let postData = rest;
if (startCreateTime) {
......@@ -602,7 +602,7 @@ const Create = () => {
}
}
const { data, code } = await PublicApi.getOrderProcessingOrderList(postData as GetOrderProcessingOrderListRequest);
const { data, code } = await PublicApi.getOrderCommonEnhancePage(postData as GetOrderCommonEnhancePageRequest);
if (code === 1000) {
setFetchOrderData(data.data);
return data
......@@ -613,13 +613,13 @@ const Create = () => {
}
}, [])
const handleBeforeOrderChecked = async (record: GetOrderProcessingOrderListResponseDetail, checked: boolean, selectedRows: GetOrderProcessingOrderListResponseDetail[]) => {
const { productDateilss, orderNo, id } = record;
const keys = productDateilss.map((_item) => `${_item.orderId}_${_item.id}`);
const handleBeforeOrderChecked = async (record: GetOrderCommonEnhancePageResponseDetail, checked: boolean, selectedRows: GetOrderCommonEnhancePageResponseDetail[]) => {
const { products, orderNo, id } = record;
const keys = products.map((_item) => `${_item.orderId}_${_item.id}`);
if (checked) {
const uniqueKeys = Array.from(new Set(orderProductSelectRowKeys.concat(keys)))
const uniqueList = orderProductselectRowRecord.concat(
productDateilss.map((_item) => {
products.map((_item) => {
return {
orderNo: orderNo,
..._item,
......@@ -956,16 +956,16 @@ const Create = () => {
rowSelection={{
getCheckboxProps: (_record) => {
return {
disabled: _record.productDateilss.every((_item) => _item.purchaseCount - _item.processNum <= 0)
disabled: _record.products.every((_item) => _item.purchaseCount - _item.processNum <= 0)
}
}
}}
tableProps={{
rowKey: (record) => `${record.id}`,
// disabled: productDateilss.every((_i) => ),
// disabled: products.every((_i) => ),
expandable: {
expandedRowRender: (record) => {
const withOrderNo = record.productDateilss.map((_item) => {
const withOrderNo = record.products.map((_item) => {
return {
..._item,
orderNo: record.orderNo
......
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