|
|
|
@ -2,7 +2,7 @@ import {makeAutoObservable, runInAction} from "mobx";
|
|
|
|
|
import { fetchJSON } from '../utils/request';
|
|
|
|
|
import * as config from "../config";
|
|
|
|
|
import { groupsMappedByKey, sitesMappedByCode, pivotBy } from './../libs/ht';
|
|
|
|
|
import { sortBy } from "../utils/commons";
|
|
|
|
|
import { sortBy, show_vs_tag, formatPercent } from "../utils/commons";
|
|
|
|
|
import moment from 'moment';
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -101,7 +101,7 @@ class CustomerStore {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 老客户 beign
|
|
|
|
|
regular_customer_order(get_detail = false) {
|
|
|
|
|
regular_customer_order(get_detail = false, isCompare = false, isRender=false) {
|
|
|
|
|
let pivotByOrder = 'SumOrder';
|
|
|
|
|
let pivotByDate = 'applyDate';
|
|
|
|
|
this.regular_data.loading = true;
|
|
|
|
@ -120,55 +120,131 @@ class CustomerStore {
|
|
|
|
|
pivotByOrder = 'ConfirmOrder';
|
|
|
|
|
pivotByDate = 'startDate';
|
|
|
|
|
}
|
|
|
|
|
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 (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) {
|
|
|
|
|
this.regular_data.detail_loading = false;
|
|
|
|
|
this.regular_data.data_detail = json;
|
|
|
|
|
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));
|
|
|
|
|
// console.log('seriesData====', seriesData);
|
|
|
|
|
|
|
|
|
|
this.regular_data.pivotData = seriesData; // { IsOldData, isCusCommendData, };
|
|
|
|
|
this.regular_data.pivotY = pivotByOrder;
|
|
|
|
|
this.regular_data.pivotX = pivotByDate;
|
|
|
|
|
if (!isCompare){
|
|
|
|
|
this.regular_data.data_detail = json;
|
|
|
|
|
}
|
|
|
|
|
if (this.regular_data.data_compare.length===0){
|
|
|
|
|
this.regular_data.data_compare = json;
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
const fistCompareDetail = this.regular_data.data_compare;
|
|
|
|
|
json.push(...fistCompareDetail);
|
|
|
|
|
}
|
|
|
|
|
if (isRender){
|
|
|
|
|
if (this.regular_data.isRenderCount===0){
|
|
|
|
|
this.regular_data.isRenderCount=1;
|
|
|
|
|
}
|
|
|
|
|
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));
|
|
|
|
|
// console.log('seriesData====', seriesData);
|
|
|
|
|
|
|
|
|
|
this.regular_data.pivotData = seriesData; // { 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));
|
|
|
|
|
// console.log('seriesData====', seriesData);
|
|
|
|
|
|
|
|
|
|
this.regular_data.pivotData = seriesData; // { IsOldData, isCusCommendData, };
|
|
|
|
|
this.regular_data.pivotY = pivotByOrder;
|
|
|
|
|
this.regular_data.pivotX = pivotByDate;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
this.regular_data.data = json;
|
|
|
|
|
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) => {
|
|
|
|
@ -192,6 +268,8 @@ class CustomerStore {
|
|
|
|
|
detail_loading: false,
|
|
|
|
|
data: [],
|
|
|
|
|
data_detail: [],
|
|
|
|
|
data_compare: [],
|
|
|
|
|
isRenderCount:0,
|
|
|
|
|
total_data_tips: '',
|
|
|
|
|
webcode: 'ALL',
|
|
|
|
|
site_select_mode: 'multiple',// 站点是否多选
|
|
|
|
|