You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
92 lines
3.3 KiB
JavaScript
92 lines
3.3 KiB
JavaScript
import { makeAutoObservable, runInAction, toJS } from 'mobx';
|
|
import * as req from '../utils/request';
|
|
import { isEmpty, pick, sortBy } from '../utils/commons';
|
|
|
|
const modelMapper = {
|
|
'tourDays': { url: '/service-Analyse2/GetTradeApartByTourDays' },
|
|
'PML': { url: '/service-Analyse2/GetTradeApartByPML' },
|
|
'ConfirmDays': { url: '/service-Analyse2/GetTradeApartByConfirmDays' },
|
|
'ApplyDays': { url: '/service-Analyse2/GetTradeApartByApplyDays' },
|
|
'PersonNum': { url: '/service-Analyse2/GetTradeApartByPersonNum' },
|
|
'destination': { url: '/service-Analyse2/GetTradeApartByDestination' },
|
|
'GlobalDestination': { url: '/service-Analyse2/GetTradeApartByGlobalDestination' },
|
|
'destinationCountry': { url: '/service-Analyse2/GetTradeApartByDestinationCountry' },
|
|
};
|
|
class Distribution {
|
|
constructor(appStore){
|
|
this.appStore = appStore;
|
|
makeAutoObservable(this);
|
|
}
|
|
|
|
/**
|
|
* 各个类型的分布
|
|
*/
|
|
getApartData = async (param) => {
|
|
this.pageLoading = true;
|
|
const mkey = this.curTab;
|
|
this[mkey] = { loading: true, dataSource: [] };
|
|
const json = await req.fetchJSON(modelMapper[mkey].url, param);
|
|
if (json.errcode === 0) {
|
|
runInAction(() => {
|
|
const dataLength = json.result.length;
|
|
this[mkey].loading = false;
|
|
this[mkey].originData = json.result;
|
|
this[mkey].dataSource = dataLength > 20 ? json.result.slice(0, 30) : json.result;
|
|
this.pageLoading = false;
|
|
});
|
|
}
|
|
return this[mkey];
|
|
};
|
|
|
|
/**
|
|
* 明细
|
|
*/
|
|
getDetailData = async (param) => {
|
|
this.detailData.loading = true;
|
|
const json = await req.fetchJSON('/service-Analyse2/GetTradeApartDetail', param);
|
|
if (json.errcode === 0) {
|
|
runInAction(() => {
|
|
this.detailData.loading = false;
|
|
this.detailData.dataSource = json.result;
|
|
const daysData = json.result.filter(ele => ele.confirmDays).map(row => pick(row, ['o_id', 'tourdays', 'applyDays', 'personNum', 'country', 'startDate']));
|
|
this.scatterDays = daysData;
|
|
});
|
|
}
|
|
return this.detailData;
|
|
};
|
|
|
|
resetData = () => {
|
|
// this.detailData = { loading: false, dataSource: [] };
|
|
// this.scatterDays = [];
|
|
|
|
this.tourDays = { loading: false, dataSource: [] };
|
|
this.PML = { loading: false, dataSource: [] };
|
|
this.ConfirmDays = { loading: false, dataSource: [] };
|
|
this.ApplyDays = { loading: false, dataSource: [] };
|
|
this.PersonNum = { loading: false, dataSource: [] };
|
|
this.destination = { loading: false, dataSource: [] };
|
|
this.GlobalDestination = { loading: false, dataSource: [] };
|
|
this.destinationCountry = { loading: false, dataSource: [] };
|
|
};
|
|
|
|
curTab = 'tourDays';
|
|
setCurTab(v) {
|
|
this.curTab = v;
|
|
}
|
|
|
|
pageLoading = false;
|
|
|
|
detailData = { loading: false, dataSource: [], };
|
|
scatterDays = [];
|
|
|
|
tourDays = { loading: false, dataSource: [] };
|
|
PML = { loading: false, dataSource: [] };
|
|
ConfirmDays = { loading: false, dataSource: [] };
|
|
ApplyDays = { loading: false, dataSource: [] };
|
|
PersonNum = { loading: false, dataSource: [] };
|
|
destination = { loading: false, dataSource: [] };
|
|
GlobalDestination = { loading: false, dataSource: [] };
|
|
destinationCountry = { loading: false, dataSource: [] };
|
|
}
|
|
export default Distribution;
|