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.
62 lines
2.2 KiB
JavaScript
62 lines
2.2 KiB
JavaScript
2 years ago
|
import { makeAutoObservable, runInAction, toJS } from 'mobx';
|
||
|
import * as req from '../utils/request';
|
||
|
import { isEmpty, 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' },
|
||
|
};
|
||
|
class Distribution {
|
||
|
constructor(appStore){
|
||
|
this.appStore = appStore;
|
||
|
makeAutoObservable(this);
|
||
|
}
|
||
|
|
||
|
async getData(param){
|
||
|
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;
|
||
|
});
|
||
|
}
|
||
|
return this[mkey];
|
||
|
|
||
|
}
|
||
|
|
||
|
resetData() {
|
||
|
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: [] };
|
||
|
}
|
||
|
|
||
|
curTab = 'tourDays';
|
||
|
setCurTab(v) {
|
||
|
this.curTab = v;
|
||
|
}
|
||
|
|
||
|
pageLoading = false;
|
||
|
|
||
|
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: [] };
|
||
|
}
|
||
|
export default Distribution;
|