import type { FormDataType, OrderDetailValueType, ExpressLogisticsSelectVaueType, EnterPrisePaymentValueType, ItemSelectValueType } from '@/types' import { isNull } from '@/utils' // 淘宝商品组件信息处理 type GoodType = { numIid: number title: string picUrl: string price: string outerId: string platform: string num: number skuInfoDTO: { itemId: number supplierName: string picUrl?: string price?: string skuId?: string propertiesName?: string outerSkuId?: number } } const taobaoGoodHandle = ( arr: Array = [], type: string, config: { changeSku: boolean } ): ItemSelectValueType[] => { const { changeSku } = config // 存放从ERP获取的SKU规格信息 const newList: ItemSelectValueType[] = arr?.map((item: GoodType) => { const { numIid, title, picUrl, price, outerId, platform, skuInfoDTO, num } = item const params: ItemSelectValueType = { numIid, title, picUrl, price, platform, itemId: skuInfoDTO?.itemId, supplierName: skuInfoDTO?.supplierName } if (skuInfoDTO && !isNull(skuInfoDTO)) { params.picUrl = skuInfoDTO?.picUrl || '' params.price = skuInfoDTO?.price || '' params.skuId = skuInfoDTO?.skuId || '' } if (changeSku) { params.propertiesName = skuInfoDTO?.propertiesName || '' } if (type === 'ITEM_ENCODE') { params.outerId = outerId params.num = num if (skuInfoDTO?.outerSkuId) { params.outerSkuId = skuInfoDTO?.outerSkuId } } return params }) return newList } export const reverseFillDataTransform = ( from: FormDataType, detail: OrderDetailValueType ) => { console.group('******** fill data transofrm start ********') console.log(from, detail) const res: { [propName: string]: | string | number | ExpressLogisticsSelectVaueType | EnterPrisePaymentValueType | ItemSelectValueType[] } = {} detail && from.currentNodeDetail.workOrderTemplateInfo.componentDtoList.forEach( fieldData => { switch (fieldData.workOrderComponentType) { case 'EXPRESS_LOGISTICS_SELECT': res[fieldData.uniqueKey] = { order: detail.expressLogisticsCode || '', company: detail.expressLogisticsCompany || '' } break case 'ENTERPRISE_PAYMENT': res[fieldData.uniqueKey] = { name: '', user: '', buyerNick: detail.buyerNick, buyerOpenUid: detail.buyerOpenUid, tid: detail.orderNo, refundFee: '', status: '', time: '' } break case 'ACTUAL_PAYMENT': res[fieldData.uniqueKey] = detail['actualPayment'] break case 'ACTUAL_RECEIPT_PAYMENT': res[fieldData.uniqueKey] = detail['actualReceiptPayment'] break case 'ITEM_SELECT': case 'ITEM_ID': case 'ITEM_ENCODE': res[fieldData.uniqueKey] = taobaoGoodHandle( detail['itemList'] as Array, fieldData.workOrderComponentType, fieldData.componentConfig ) break default: break } } ) console.log('reverseData: ', res) console.groupEnd() return res }