import CONSTANT from './constant' export default { // 人群分层 getGroupedClassify (datas, statusText, hasNew) { // hasNew 表示有新增人群 const aware = { aiplKey: 'Aware', aiplName: '认知', color: 'rgba(56,134,255,1)' } const interest = { aiplKey: 'Interest', aiplName: '兴趣', color: 'rgba(54,203,168,1)' } const purchase = { aiplKey: 'Purchase', aiplName: '购买', color: 'rgba(255,202,87,1)' } const lolalty = { aiplKey: 'Lolalty', aiplName: '忠诚', color: 'rgba(255,134,60,1)' } const crowdNew = { aiplKey: 'new', aiplName: '新增' } const statusList = $.extend(true, [], CONSTANT.statusList) const groupedNames = { [statusList[0].key]: { ...aware, ...statusList[0] }, [statusList[1].key]: { ...aware, ...statusList[1] }, [statusList[2].key]: { ...interest, ...statusList[2] }, [statusList[3].key]: { ...interest, ...statusList[3] }, [statusList[4].key]: { ...purchase, ...statusList[4] }, [statusList[5].key]: { ...lolalty, ...statusList[5] }, [statusList[6].key]: { ...lolalty, ...statusList[6] } } if (hasNew) { groupedNames[statusList[7].key] = { ...crowdNew, ...statusList[7] } } const list = datas.map(item => { const key = item.headers[statusText] const groupedObj = groupedNames[key] return { ...item.targets, ...groupedObj, key } }) return { list } } }