import {makeAutoObservable, runInAction} from "mobx"; import { fetchJSON } from '../utils/request'; import * as config from "../config"; import { groupsMappedByKey, sitesMappedByCode, pivotBy } from './../libs/ht'; import { sortBy, show_vs_tag, formatPercent, groupBy, isEmpty } from "../utils/commons"; import moment from 'moment'; /** * 用于透视的数据 */ const getDetailData = async (param) => { const json = await fetchJSON('/service-Analyse2/GetTradeApartDetail', param); return json.errcode === 0 ? json.result : []; }; class CustomerStore { constructor(rootStore) { this.rootStore = rootStore; makeAutoObservable(this); } // 潜力客户 beign potential_customer_order(get_detail = false) { this.potential_data.loading = true; const date_picker_store = this.rootStore.date_picker_store; let url = '/service-tourdesign/PotentialCusOrder'; url += '?Website=' + this.potential_data.webcode.toString() + '&DEI_SNList=' + this.potential_data.groups.toString(); if (String(this.potential_data.date_type).toLowerCase() === 'applydate') { url += '&ApplydateCheck=1&EntrancedateCheck=0&ConfirmDateCheck=0'; } else if(String(this.potential_data.date_type).toLowerCase() === 'confirmdate'){ url += '&ApplydateCheck=0&EntrancedateCheck=0&ConfirmDateCheck=1'; }else { url += '&ApplydateCheck=0&EntrancedateCheck=1&ConfirmDateCheck=0'; } url += '&ApplydateStart=' + date_picker_store.start_date.format(config.DATE_FORMAT) + '&ApplydateEnd=' + date_picker_store.end_date.format(config.SMALL_DATETIME_FORMAT); url += '&EntrancedateStart=' + date_picker_store.start_date.format(config.DATE_FORMAT) + '&EntrancedateEnd=' + date_picker_store.end_date.format(config.SMALL_DATETIME_FORMAT); url += '&ConfirmdateStart=' + date_picker_store.start_date.format(config.DATE_FORMAT) + '&ConfirmdateEnd=' + date_picker_store.end_date.format(config.SMALL_DATETIME_FORMAT); if (get_detail) { url += '&IsDetail=1'; } else { url += '&IsDetail=0'; } fetch(config.HT_HOST + url) .then((response) => response.json()) .then((json) => { runInAction(() => { if (get_detail) { this.potential_data.data_detail = json; } else { this.potential_data.data = json; } this.potential_data.loading = false; }); }) .catch((error) => { this.potential_data.loading = false; console.log('fetch data failed', error); }); } handleChange_webcode = (value) => { this.potential_data.webcode = value; }; handleChange_group_select(value) { this.potential_data.groups = value; }; onChange_datetype(e) { this.potential_data.date_type = e.target.value; }; onChange_show_detail_table() { this.potential_data.show_detail_table = !this.potential_data.show_detail_table; } potential_data = { loading: false, data: [], data_detail: [], webcode: 'GHKYZG', site_select_mode: 'multiple',// 站点是否多选 group_select_mode: 'multiple',// 是否多选分组 groups: ['1', '2', '7'], date_type: 'applyDate', group_handleChange: this.handleChange_group_select.bind(this), onChange_datetype: this.onChange_datetype.bind(this), potential_customer_order: this.potential_customer_order.bind(this), onChange_show_detail_table: this.onChange_show_detail_table.bind(this), handleChange_webcode: this.handleChange_webcode.bind(this), searchValues: { DepartmentList: ['1', '2', '7'].map(kk => groupsMappedByKey[kk]), WebCode: ['GHKYZG'].map(kk => sitesMappedByCode[kk]), DateType: { key: 'applyDate', label: '提交日期'}, }, }; // 潜力客户 end // 老客户 beign // isCompare对比数据boolean isCompareRender对比折线boolean regular_customer_order(get_detail = false, isCompare = false, isCompareRender=false) { let pivotByOrder = 'SumOrder'; let pivotByDate = 'applyDate'; this.regular_data.loading = true; this.regular_data.detail_loading = get_detail; const date_picker_store = this.rootStore.date_picker_store; let url = '/service-tourdesign/RegularCusOrder'; url += '?Website=' + this.regular_data.webcode.toString() + '&DEI_SNList=' + this.regular_data.groups.toString(); if (String(this.regular_data.date_type).toLowerCase() === 'applydate') { url += '&ApplydateCheck=1&EntrancedateCheck=0&ConfirmDateCheck=0'; } else if(String(this.regular_data.date_type).toLowerCase() === 'confirmdate'){ url += '&ApplydateCheck=0&EntrancedateCheck=0&ConfirmDateCheck=1'; pivotByOrder = 'ConfirmOrder'; pivotByDate = 'confirmDate'; }else { url += '&ApplydateCheck=0&EntrancedateCheck=1&ConfirmDateCheck=0'; pivotByOrder = 'ConfirmOrder'; pivotByDate = 'startDate'; } if (isCompare){ url += '&ApplydateStart=' + date_picker_store.start_date_cp.format(config.DATE_FORMAT) + '&ApplydateEnd=' + date_picker_store.end_date_cp.format(config.SMALL_DATETIME_FORMAT); url += '&EntrancedateStart=' + date_picker_store.start_date_cp.format(config.DATE_FORMAT) + '&EntrancedateEnd=' + date_picker_store.end_date_cp.format(config.SMALL_DATETIME_FORMAT); url += '&ConfirmdateStart=' + date_picker_store.start_date_cp.format(config.DATE_FORMAT) + '&ConfirmdateEnd=' + date_picker_store.end_date_cp.format(config.SMALL_DATETIME_FORMAT); } else{ url += '&ApplydateStart=' + date_picker_store.start_date.format(config.DATE_FORMAT) + '&ApplydateEnd=' + date_picker_store.end_date.format(config.SMALL_DATETIME_FORMAT); url += '&EntrancedateStart=' + date_picker_store.start_date.format(config.DATE_FORMAT) + '&EntrancedateEnd=' + date_picker_store.end_date.format(config.SMALL_DATETIME_FORMAT); url += '&ConfirmdateStart=' + date_picker_store.start_date.format(config.DATE_FORMAT) + '&ConfirmdateEnd=' + date_picker_store.end_date.format(config.SMALL_DATETIME_FORMAT); } if (get_detail) { url += '&IsDetail=1'; } else { url += '&IsDetail=0'; } url += `&IncludeTickets=${this.regular_data.include_tickets}`; return new Promise((resolve, reject) => { fetch(config.HT_HOST + url) .then((response) => response.json()) .then((json) => { runInAction(() => { if (get_detail) { if (!isCompare){ this.regular_data.data_detail = json; } if (isCompareRender){ this.regular_data.solidLineTime=date_picker_store.start_date.format(config.DATE_FORMAT)+ '-' +date_picker_store.end_date.format(config.SMALL_DATETIME_FORMAT); this.regular_data.solidLineCompareTime=date_picker_store.start_date_cp.format(config.DATE_FORMAT)+ '-' +date_picker_store.end_date_cp.format(config.SMALL_DATETIME_FORMAT); const dump_l = (json || []).filter(ele => ele.COLI_IsOld !== '' && ele.COLI_IsCusCommend !== '').length; this.regular_data.total_data_tips = dump_l > 0 ? `包含 ${dump_l} 条同时勾选的数据` : ''; /** 使用明细数据画图 */ const data_detail = (json || []).map((ele) => ({ ...ele, key: ele.COLI_ID, orderState: ele.OrderState, applyDate: moment(ele.COLI_ApplyDate).format('YYYY-MM-DD'), startDate: ele.COLI_OrderStartDate, confirmDate: moment(ele.COLI_ConfirmDate).format('YYYY-MM-DD'), })); const { data: IsOldData, } = pivotBy(data_detail.filter(ele => ele.COLI_IsOld === '是'), [['COLI_IsOld', ], [], pivotByDate]); const { data: isCusCommendData, } = pivotBy(data_detail.filter(ele => ele.COLI_IsCusCommend === '是'), [['COLI_IsCusCommend', ], [], pivotByDate]); // console.log('IsOldData====', IsOldData, '\nisCusCommend', isCusCommendData); // 合并成两个系列 const seriesData = [].concat(IsOldData.map(ele => ({...ele, _ylabel: '老客户'})), isCusCommendData.map(ele => ({...ele, _ylabel: '老客户推荐'})),).sort(sortBy(pivotByDate)); const seriesNewData = seriesData.map(item => { if (isCompare){ return { ...item, _ylabel: date_picker_store.start_date_cp.format(config.DATE_FORMAT)+ '-' +date_picker_store.end_date_cp.format(config.SMALL_DATETIME_FORMAT) + item._ylabel }; } else{ return { ...item, _ylabel: date_picker_store.start_date.format(config.DATE_FORMAT)+ '-' +date_picker_store.end_date.format(config.SMALL_DATETIME_FORMAT) + item._ylabel }; } }); // console.log('seriesData====', seriesNewData); if (this.regular_data.data_compare.length===0){ this.regular_data.data_compare=seriesNewData; } else{ let seriesCompareData = []; const fistCompareDetail = this.regular_data.data_compare; if (fistCompareDetail.length>seriesNewData.length){ seriesCompareData = fistCompareDetail; for (let i = 0; i < seriesNewData.length; i++) { seriesNewData[i][pivotByDate] = fistCompareDetail[i][pivotByDate]; } seriesCompareData.push(...seriesNewData); } else{ seriesCompareData=seriesNewData; for (let i = 0; i < fistCompareDetail.length; i++) { fistCompareDetail[i][pivotByDate] = seriesNewData[i][pivotByDate]; } seriesCompareData.push(...fistCompareDetail); } this.regular_data.detail_loading = false; this.regular_data.pivotData = seriesCompareData; // { IsOldData, isCusCommendData, }; this.regular_data.pivotY = pivotByOrder; this.regular_data.pivotX = pivotByDate; } } else{ this.regular_data.detail_loading = false; const dump_l = (json || []).filter(ele => ele.COLI_IsOld !== '' && ele.COLI_IsCusCommend !== '').length; this.regular_data.total_data_tips = dump_l > 0 ? `包含 ${dump_l} 条同时勾选的数据` : ''; /** 使用明细数据画图 */ const data_detail = (json || []).map((ele) => ({ ...ele, key: ele.COLI_ID, orderState: ele.OrderState, applyDate: moment(ele.COLI_ApplyDate).format('YYYY-MM-DD'), startDate: ele.COLI_OrderStartDate, confirmDate: moment(ele.COLI_ConfirmDate).format('YYYY-MM-DD'), })); const { data: IsOldData, } = pivotBy(data_detail.filter(ele => ele.COLI_IsOld === '是'), [['COLI_IsOld', ], [], pivotByDate]); const { data: isCusCommendData, } = pivotBy(data_detail.filter(ele => ele.COLI_IsCusCommend === '是'), [['COLI_IsCusCommend', ], [], pivotByDate]); // console.log('IsOldData====', IsOldData, '\nisCusCommend', isCusCommendData); // 合并成两个系列 const seriesData = [].concat(IsOldData.map(ele => ({...ele, _ylabel: '老客户'})), isCusCommendData.map(ele => ({...ele, _ylabel: '老客户推荐'})),).sort(sortBy(pivotByDate)); this.regular_data.pivotData = seriesData; // { IsOldData, isCusCommendData, }; this.regular_data.pivotY = pivotByOrder; this.regular_data.pivotX = pivotByDate; } } else { if (isCompare){ const result = []; const firstCompareData = this.regular_data.data; for (const item1 of firstCompareData) { for (const item2 of json) { if (item1.ItemName === item2.ItemName) { result.push({ ItemName: item1.ItemName, OrderNum: show_vs_tag(formatPercent((item1.OrderNum-item2.OrderNum)/(item2.OrderNum===0?1:item2.OrderNum)), item1.OrderNum-item2.OrderNum,item1.OrderNum,item2.OrderNum), SUCOrderNum: show_vs_tag(formatPercent((item1.SUCOrderNum-item2.SUCOrderNum)/(item2.SUCOrderNum===0?1:item2.SUCOrderNum)), item1.SUCOrderNum-item2.SUCOrderNum,item1.SUCOrderNum,item2.SUCOrderNum), SUCRate: show_vs_tag(formatPercent((item1.SUCRate-item2.SUCRate)/(item2.SUCRate===0?1:item2.SUCRate)), formatPercent(item1.SUCRate-item2.SUCRate),formatPercent(item1.SUCRate),formatPercent(item2.SUCRate)), ML: show_vs_tag(formatPercent((item1.ML-item2.ML)/(item2.ML===0?1:item2.ML)), (item1.ML-item2.ML).toFixed(2),item1.ML,item2.ML), PersonNum: show_vs_tag(formatPercent((item1.PersonNum-item2.PersonNum)/(item2.PersonNum===0?1:item2.PersonNum)), item1.PersonNum-item2.PersonNum,item1.PersonNum,item2.PersonNum), }); } } }; this.regular_data.data = result; } else{ this.regular_data.data = json; } } this.regular_data.loading = false; resolve(); }); }) .catch((error) => { this.regular_data.loading = false; console.log('fetch data failed', error); }); }); } handleChange_webcode_regular = (value) => { this.regular_data.webcode = value; }; handleChange_group_select_regular(value) { this.regular_data.groups = value; }; onChange_datetype_regular(e) { this.regular_data.date_type = e.target.value; }; onChange_show_detail_table_regular() { this.regular_data.show_detail_table = !this.regular_data.show_detail_table; } regular_data = { loading: false, detail_loading: false, data: [], data_detail: [], data_compare: [], showCompareSum:false, solidLineTime:'', solidLineCompareTime:'', solidLineDash:'老客户推荐', isCompareLine:false, total_data_tips: '', webcode: 'ALL', site_select_mode: 'multiple',// 站点是否多选 group_select_mode: 'multiple',// 是否多选分组 groups: ['1', '2', '28', '7'], date_type: 'applyDate', include_tickets: 0, group_handleChange: this.handleChange_group_select_regular.bind(this), onChange_datetype: this.onChange_datetype_regular.bind(this), regular_customer_order: this.regular_customer_order.bind(this), onChange_show_detail_table: this.onChange_show_detail_table_regular.bind(this), handleChange_webcode: this.handleChange_webcode_regular.bind(this), searchValues: { DepartmentList: ['1', '2', '28', '7'].map(kk => groupsMappedByKey[kk]), WebCode: ['CHT','AH','JH','GH','ZWQD','GH_ZWQD_HW','GHKYZG','GHKYHW'].map(kk => sitesMappedByCode[kk]), DateType: { key: 'applyDate', label: '提交日期'}, IncludeTickets: { key: '0', label: '不含门票' }, }, pivotData: [], pivotY: 'SumOrder', pivotX: 'applyDate', }; // 老客户 end // 在华客人 beign inchina_customer_order(get_detail = false) { this.inchina_data.loading = true; const date_picker_store = this.rootStore.date_picker_store; let url = '/service-tourdesign/RegularCusInChinaOrder'; url += '?Website=' + this.inchina_data.webcode.toString() + '&DEI_SNList=' + this.inchina_data.groups.toString(); if (String(this.inchina_data.date_type).toLowerCase() === 'applydate') { url += '&ApplydateCheck=1&EntrancedateCheck=0&ConfirmDateCheck=0'; } else if(String(this.inchina_data.date_type).toLowerCase() === 'confirmdate'){ url += '&ApplydateCheck=0&EntrancedateCheck=0&ConfirmDateCheck=1'; }else { url += '&ApplydateCheck=0&EntrancedateCheck=1&ConfirmDateCheck=0'; } if (get_detail) { url += '&IsDetail=1'; } else { url += '&IsDetail=0'; } url += '&ApplydateStart=' + date_picker_store.start_date.format(config.DATE_FORMAT) + '&ApplydateEnd=' + date_picker_store.end_date.format(config.SMALL_DATETIME_FORMAT); url += '&EntrancedateStart=' + date_picker_store.start_date.format(config.DATE_FORMAT) + '&EntrancedateEnd=' + date_picker_store.end_date.format(config.SMALL_DATETIME_FORMAT); url += '&ConfirmdateStart=' + date_picker_store.start_date.format(config.DATE_FORMAT) + '&ConfirmdateEnd=' + date_picker_store.end_date.format(config.SMALL_DATETIME_FORMAT); fetch(config.HT_HOST + url) .then((response) => response.json()) .then((json) => { runInAction(() => { if (get_detail) { this.inchina_data.data_detail = json; } else { this.inchina_data.data = json; } this.inchina_data.loading = false; }); }) .catch((error) => { this.inchina_data.loading = false; console.log('fetch data failed', error); }); } handleChange_webcode_inchina = (value) => { this.inchina_data.webcode = value; }; handleChange_group_select_inchina(value) { this.inchina_data.groups = value; }; onChange_datetype_inchina(e) { this.inchina_data.date_type = e.target.value; }; onChange_show_detail_table_inchina() { this.inchina_data.show_detail_table = !this.inchina_data.show_detail_table; } inchina_data = { loading: false, data: [], data_detail: [], webcode: 'ALL', site_select_mode: 'multiple',// 站点是否多选 group_select_mode: 'multiple',// 是否多选分组 groups: ['1', '2', '28', '7'], date_type: 'applyDate', group_handleChange: this.handleChange_group_select_inchina.bind(this), onChange_datetype: this.onChange_datetype_inchina.bind(this), inchina_customer_order: this.inchina_customer_order.bind(this), onChange_show_detail_table: this.onChange_show_detail_table_inchina.bind(this), handleChange_webcode: this.handleChange_webcode_inchina.bind(this), searchValues: { DepartmentList: ['1', '2', '28', '7'].map(kk => groupsMappedByKey[kk]), WebCode: undefined, // ['ALL'].map(kk => sitesMappedByCode[kk]), DateType: { key: 'applyDate', label: '提交日期'}, }, }; // 在华客人 end // 东道主项目 begin host_case_data = { loading: false, summaryData: [], // 汇总数据 groupData: [], // 小组数据 counselorData: [], // 顾问数据 group_select_mode: 'multiple', groups: ['1', '2', '28', '7'], searchValues: { DepartmentList: ['1', '2', '28', '7'].map(kk => groupsMappedByKey[kk]), }, }; getHostCaseData(groupBy) { this.host_case_data.loading = true; const date_picker_store = this.rootStore.date_picker_store; let url = '/service-Analyse2/DDZCount'; url += '?DEI_SN=' + this.host_case_data.groups.toString(); url += '&ArriveDateStart=' + date_picker_store.start_date.format(config.DATE_FORMAT) + '&ArriveDateEnd=' + date_picker_store.end_date.format(config.SMALL_DATETIME_FORMAT); url += '&GroupBy=' + groupBy; fetch(config.HT_HOST + url) .then((response) => response.json()) .then((json) => { runInAction(() => { this.host_case_data.loading = false; switch(groupBy){ case "1": this.host_case_data.summaryData = json.result?json.result:[]; break; case "2": this.host_case_data.counselorData = json.result?json.result:[]; break; case "3": this.host_case_data.groupData = json.result?json.result:[]; break; } }); }) .catch((error) => { this.host_case_data.loading = false; console.log('fetch data failed', error); }); }; // 东道主项目 end // 销售-老客户 sales_regular_data = { loading: false, data: [], mergedData: [], rawData: [], searchValues: { DepartmentList: ['1', '2', '28', '7'].map(kk => groupsMappedByKey[kk]), WebCode: ['CHT','AH','JH','GH','ZWQD','GH_ZWQD_HW','GHKYZG','GHKYHW'].map(kk => sitesMappedByCode[kk]), DateType: { key: 'applyDate', label: '提交日期'}, IncludeTickets: { key: '0', label: '不含门票' }, }, }; get_sales_regular_data_vs = async (param) => { this.sales_regular_data.loading = true; const hasCompare = !isEmpty(param.DateDiff1); const [result1, result2] = await Promise.all([ this.get_sales_regular_data(param), hasCompare ? this.get_sales_regular_data({...param, Date1: param.DateDiff1, Date2: param.DateDiff2}) : { mergeDataBySales: [], mergeDataBySalesAccount: [], filterHasOld: []}, ]); const allTypes = ['老客户', '老客户推荐']; // 独立的账户 const allSales = Array.from(new Set([...result1.mergeDataBySales.map(row=>row.operatorName), ...result2.mergeDataBySales.map(row=>row.operatorName)])); const sales1 = groupBy(result1.mergeDataBySales, 'operatorName'); const sales2 = groupBy(result2.mergeDataBySales, 'operatorName'); const mergeDataBySales = allSales.reduce((r, sale) => { const _default = { operatorName: sale, rowLabel: sales1?.[sale]?.rowLabel || sales2?.[sale]?.rowLabel, children: sales1?.[sale]?.children || [], key: sale}; const operatorRow = {...(sales1?.[sale]?.[0] || _default), vsData: sales2?.[sale]?.[0] || {}}; // 展开的两项: '老客户', '老客户推荐' const series1Children = sales1?.[sale]?.[0]?.children || []; const series2Children = sales2?.[sale]?.[0]?.children || []; const children = allTypes.reduce((r, type) => { const _default = { operatorName: type, rowLabel: type, key: type}; const _typeRow = series1Children.find(sc => sc.operatorName === type) || _default; const _typeVSRow = series2Children.find(sc => sc.operatorName === type) || {}; return r.concat({..._typeRow, vsData: _typeVSRow}); }, []); operatorRow.children = children; return r.concat(operatorRow); }, []); // 合并顾问的账户 const allSalesMerged = Array.from(new Set([...result1.mergeDataBySalesAccount.map(row=>row.operatorName), ...result2.mergeDataBySalesAccount.map(row=>row.operatorName)])); const salesM1 = groupBy(result1.mergeDataBySalesAccount, 'operatorName'); const salesM2 = groupBy(result2.mergeDataBySalesAccount, 'operatorName'); const mergeDataBySalesAccount = allSalesMerged.reduce((r, sale) => { const _default = { operatorName: sale, rowLabel: salesM1?.[sale]?.rowLabel || salesM2?.[sale]?.rowLabel, children: salesM1?.[sale]?.children || [], key: sale}; const operatorRow = {...(salesM1?.[sale]?.[0] || _default), vsData: salesM2?.[sale]?.[0] || {}}; // 展开的两项: '老客户', '老客户推荐' const series1Children = salesM1?.[sale]?.[0]?.children || []; const series2Children = salesM2?.[sale]?.[0]?.children || []; const children = allTypes.reduce((r, type) => { const _default = { operatorName: type, rowLabel: type, key: type}; const _typeRow = series1Children.find(sc => sc.operatorName === type) || _default; const _typeVSRow = series2Children.find(sc => sc.operatorName === type) || {}; return r.concat({..._typeRow, vsData: _typeVSRow}); }, []); operatorRow.children = children; return r.concat(operatorRow); }, []); this.sales_regular_data.loading = false; this.sales_regular_data.data = mergeDataBySales; this.sales_regular_data.mergedData = mergeDataBySalesAccount; this.sales_regular_data.rawData = [].concat(result1.filterHasOld, result2.filterHasOld); }; get_sales_regular_data = async (param) => { const seriesKey = `${param.Date1}至${param.Date2}`; const rawData = await getDetailData({...param, }); const filterHasOld = rawData.filter(ele => (ele.IsOld === '1' || ele.isCusCommend === '1')).map(e => ({ ...e, seriesKey, operatorNameB: e.operatorName.replace(/\([^)]*\)/gi, '').toLowerCase(), })); const { data: hasOldData, } = pivotBy(filterHasOld, [['hasOld', 'operatorName'], [], []]); const { data: IsOldData, } = pivotBy(filterHasOld.filter(ele => ele.IsOld === '1'), [['operatorName', 'IsOld_txt', ], [], []]); const { data: isCusCommendData, } = pivotBy(filterHasOld.filter(ele => ele.isCusCommend === '1'), [['operatorName', 'isCusCommend_txt', ], [], []]); // console.log('IsOldData====', IsOldData, '\nisCusCommend', isCusCommendData); // console.log('data====', rawData, '\ncolumnValues', columnValues, '\nsummaryRows', summaryRows, '\nsummaryColumns', summaryColumns, '\nsummaryMix', summaryMix, '\nhasOld',filterHasOld); const mergeDataBySales = hasOldData.map((ele) => ({ ...ele, seriesKey, children: [].concat( IsOldData.filter((ele1) => ele1.operatorName === ele.operatorName).map(o => ({...o, operatorName: o.IsOld_txt, key: o.rowLabel, seriesKey,})), isCusCommendData.filter((ele2) => ele2.operatorName === ele.operatorName).map(o => ({...o, operatorName: o.isCusCommend_txt, key: o.rowLabel, seriesKey,})) ), })); // 合并顾问的账户 const { data: hasOldDataSales, } = pivotBy(filterHasOld, [['hasOld', 'operatorNameB'], [], []]); const { data: IsOldDataSales, } = pivotBy(filterHasOld.filter(ele => ele.IsOld === '1'), [['operatorNameB', 'IsOld_txt', ], [], []]); const { data: isCusCommendDataSales, } = pivotBy(filterHasOld.filter(ele => ele.isCusCommend === '1'), [['operatorNameB', 'isCusCommend_txt', ], [], []]); const mergeDataBySalesAccount = hasOldDataSales.map((ele) => ({ ...ele, operatorName: ele.operatorNameB, seriesKey, children: [].concat( IsOldDataSales.filter((ele1) => ele1.operatorNameB === ele.operatorNameB).map(o => ({...o, operatorName: o.IsOld_txt, key: o.rowLabel, seriesKey,})), isCusCommendDataSales.filter((ele2) => ele2.operatorNameB === ele.operatorNameB).map(o => ({...o, operatorName: o.isCusCommend_txt, key: o.rowLabel, seriesKey,})) ), })); // console.log('IsOldDataSales====', IsOldDataSales, '\nisCusCommendDataSales', isCusCommendDataSales); // console.log('mergeDataBySalesAccount====', mergeDataBySalesAccount); return { mergeDataBySales, mergeDataBySalesAccount, filterHasOld }; // this.sales_regular_data.loading = false; // this.sales_regular_data.data = mergeDataBySales; // this.sales_regular_data.mergedData = mergeDataBySalesAccount; // this.sales_regular_data.rawData = filterHasOld; }; setSearchValues(obj, values, target) { this[target].groups = obj.DepartmentList; this[target].webcode = obj.WebCode; this[target].include_tickets = obj.IncludeTickets; this[target].date_type = obj.DateType; } } export default CustomerStore;