|
@@ -1,11 +1,19 @@
|
|
|
import { cloneDeep } from 'lodash'
|
|
|
import { defaultPageFormValue, OrderProductCardItem, PayBackTableRow, SalePersonTableRow } from '@/views/create-order/data/interface'
|
|
|
import { dateFormatter } from '@/utils/globalFun'
|
|
|
-import { payWayOptions } from '@/views/create-order/data/index.js'
|
|
|
+import { getProductCodeWithType, sortCommonForm } from './common'
|
|
|
+import { payWayOptions, productGroupKeyMap, productKeyMap } from '@/views/create-order/data/index.js'
|
|
|
import { findUserInDeptTree, calcChannelSelectorList } from "@/views/create-order/hooks/utils"
|
|
|
import dayjs from 'dayjs'
|
|
|
import { div } from '@/utils/number'
|
|
|
|
|
|
+import { sortBigMemberProductFrom } from './bigmember'
|
|
|
+import { sortSvipProductFrom } from './svip'
|
|
|
+import { sortDataCountPackProductFrom } from './data-count-pack'
|
|
|
+import { sortMarketingProductFrom } from './marketing'
|
|
|
+import { sortOneSpecProductFrom } from './one-spec'
|
|
|
+
|
|
|
+
|
|
|
function findItemInOptions(options, cb) {
|
|
|
const t = options.find(r => cb(r))
|
|
|
if (t) {
|
|
@@ -15,7 +23,6 @@ function findItemInOptions(options, cb) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
// 将接口参数转换为store需要的参数
|
|
|
export function sortOrderInfo(order = {}) {
|
|
|
const pageFormValue = cloneDeep(defaultPageFormValue)
|
|
@@ -119,9 +126,11 @@ export function sortOrderInfo(order = {}) {
|
|
|
let productArr = []
|
|
|
if (Array.isArray(productData) && productData.length > 0) {
|
|
|
productArr = productData.map(pd => {
|
|
|
- const productForm = sortProductFormArr(pd)
|
|
|
+ const productCode = pd.productItemCode || getProductCodeWithType(pd.product_type)
|
|
|
+ const productForm = sortProductFormArr(productCode, pd, order)
|
|
|
+
|
|
|
const config = {
|
|
|
- productCode: pd.productItemCode,
|
|
|
+ productCode,
|
|
|
waitingRestoreForm: productForm,
|
|
|
}
|
|
|
return new OrderProductCardItem(undefined, undefined, config)
|
|
@@ -134,6 +143,39 @@ export function sortOrderInfo(order = {}) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-export function sortProductFormArr(product) {
|
|
|
- // console.log(product)
|
|
|
+
|
|
|
+export function sortProductFormArr(type, product, order) {
|
|
|
+ const map = {}
|
|
|
+ if (!type) {
|
|
|
+ console.warn('未传入type')
|
|
|
+ return map
|
|
|
+ }
|
|
|
+
|
|
|
+ let callback = undefined
|
|
|
+ if (type === productKeyMap.cjdy) {
|
|
|
+ callback = sortSvipProductFrom
|
|
|
+ } else if (type === productKeyMap.dhy) {
|
|
|
+ callback = sortBigMemberProductFrom
|
|
|
+ } else if (productGroupKeyMap.oneSpecProduct.includes(type)) {
|
|
|
+ callback = sortOneSpecProductFrom
|
|
|
+ } else if (productGroupKeyMap.dataCountProduct.includes(type)) {
|
|
|
+ callback = sortDataCountPackProductFrom
|
|
|
+ } else if (
|
|
|
+ productGroupKeyMap.marketingProduct.includes(type) ||
|
|
|
+ productGroupKeyMap.ggProduct.includes(type) ||
|
|
|
+ productGroupKeyMap.entityProduct.includes(type)
|
|
|
+ ) {
|
|
|
+ callback = sortMarketingProductFrom
|
|
|
+ } else {
|
|
|
+ console.log('未定义calcForm')
|
|
|
+ }
|
|
|
+
|
|
|
+ if (callback) {
|
|
|
+ const common = sortCommonForm(product, order)
|
|
|
+ const pForm = callback(product, order)
|
|
|
+ Object.assign(map, common, pForm)
|
|
|
+ console.log(common, pForm, map)
|
|
|
+ }
|
|
|
+
|
|
|
+ return map
|
|
|
}
|