cashier_app/pageProduct/util.js

42 lines
999 B
JavaScript

import { $types } from '@/commons/goodsData.js'
export function returnSkuSnap(goods) {
const selectSpec = typeof goods.selectSpec === 'string' ? JSON.parse(goods.selectSpec) : goods.selectSpec
let result = selectSpec.map(v => {
return {
name: v.name,
value: v.selectSpecResult.join(',')
}
})
return result
}
export function returnTypeEnum(type) {
const item = $types.find(v => v.title == type)
let result = item ? item.value : undefined
return result
}
export function returnCategory(cateName, cateList) {
console.log(cateName);
console.log(cateList);
const item = cateList.find(v => v.name == cateName)
let result = item ? item : undefined
return result
}
export function returnAllCategory(arr) {
const result = arr.reduce((prve, cur) => {
prve.push(...[{
...cur,
name: '' + cur.name,
childrenList: undefined
},
// ...cur.childrenList.map(v => {
// return {
// ...v,
// name: '' + v.name
// }
// })
])
return prve
}, [])
return result
}