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.
dashboard/src/stores/CustomerStore.js

262 lines
11 KiB
JavaScript

import {makeAutoObservable, runInAction} from "mobx";
import * as config from "../config";
import { groupsMappedByKey, dataFieldAlias, sitesMappedByCode } from './../libs/ht';
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.DATE_FORMAT) + '%2023:59:59';
url += '&EntrancedateStart=' + date_picker_store.start_date.format(config.DATE_FORMAT) + '&EntrancedateEnd=' + date_picker_store.end_date.format(config.DATE_FORMAT) + '%2023:59:59';
url += '&ConfirmdateStart=' + date_picker_store.start_date.format(config.DATE_FORMAT) + '&ConfirmdateEnd=' + date_picker_store.end_date.format(config.DATE_FORMAT) + '%2023:59:59';
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
regular_customer_order(get_detail = false) {
this.regular_data.loading = true;
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';
}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.DATE_FORMAT) + '%2023:59:59';
url += '&EntrancedateStart=' + date_picker_store.start_date.format(config.DATE_FORMAT) + '&EntrancedateEnd=' + date_picker_store.end_date.format(config.DATE_FORMAT) + '%2023:59:59';
url += '&ConfirmdateStart=' + date_picker_store.start_date.format(config.DATE_FORMAT) + '&ConfirmdateEnd=' + date_picker_store.end_date.format(config.DATE_FORMAT) + '%2023:59:59';
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.regular_data.data_detail = json;
} else {
this.regular_data.data = json;
}
this.regular_data.loading = false;
});
})
.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,
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_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: undefined, // ['ALL'].map(kk => sitesMappedByCode[kk]),
DateType: { key: 'applyDate', label: '提交日期'},
},
};
// 老客户 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.DATE_FORMAT) + '%2023:59:59';
url += '&EntrancedateStart=' + date_picker_store.start_date.format(config.DATE_FORMAT) + '&EntrancedateEnd=' + date_picker_store.end_date.format(config.DATE_FORMAT) + '%2023:59:59';
url += '&ConfirmdateStart=' + date_picker_store.start_date.format(config.DATE_FORMAT) + '&ConfirmdateEnd=' + date_picker_store.end_date.format(config.DATE_FORMAT) + '%2023:59:59';
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
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;