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/OrdersStore.js

70 lines
2.8 KiB
JavaScript

3 years ago
import {makeAutoObservable} from "mobx"
import * as config from "../config";
import moment from "moment";
3 years ago
class OrdersStore {
3 years ago
constructor(rootStore) {
this.rootStore = rootStore;
makeAutoObservable(this);
}
webcode = 'CHT';
orderCountData = [];//订单统计数据源
orderCountData_Form=[];//表单类型统计数据源
loading = false;
3 years ago
handleChange_webcode = (value) => {
this.webcode = value;
};
//网站订单数量
3 years ago
getOrderCount() {
this.loading = true;
const date_picker_store = this.rootStore.date_picker_store;
3 years ago
let url = '/service-web/QueryData/GetOrderCount'//?WebCode=cht&COLI_ApplyDate1=2022-08-01&COLI_ApplyDate2=2022-08-31&COLI_ApplyDateold1=2021-08-01&COLI_ApplyDateold2=2021-08-31';
url += '?WebCode=' + this.webcode + '&COLI_ApplyDate1=' + date_picker_store.start_date.format(config.DATE_FORMAT) + '&COLI_ApplyDate2=' + date_picker_store.end_date.format(config.DATE_FORMAT) + '%2023:59:59';
if (date_picker_store.start_date_cp && date_picker_store.end_date_cp) {
url += '&COLI_ApplyDateold1=' + date_picker_store.start_date_cp.format(config.DATE_FORMAT) + '&COLI_ApplyDateold2=' + date_picker_store.end_date_cp.format(config.DATE_FORMAT) + '%2023:59:59';
}
fetch(config.HT_HOST + url)
.then((response) => response.json())
.then((json) => {
this.orderCountData = json.ordercount;
this.loading = false;
})
.catch((error) => {
this.loading = false;
console.log('fetch data failed', error);
});
}
//网站订单类型
getOrderCountByType(order_type) {
this.loading = true;
const date_picker_store = this.rootStore.date_picker_store;
let url = '/service-web/QueryData/GetOrderCountByType'
url += '?WebCode=' + this.webcode + '&OrderType=' + order_type;
url += '&COLI_ApplyDate1=' + date_picker_store.start_date.format(config.DATE_FORMAT) + '&COLI_ApplyDate2=' + date_picker_store.end_date.format(config.DATE_FORMAT) + '%2023:59:59';
if (date_picker_store.start_date_cp && date_picker_store.end_date_cp) {
url += '&COLI_ApplyDateold1=' + date_picker_store.start_date_cp.format(config.DATE_FORMAT) + '&COLI_ApplyDateold2=' + date_picker_store.end_date_cp.format(config.DATE_FORMAT) + '%2023:59:59';
}
3 years ago
fetch(config.HT_HOST + url)
.then((response) => response.json())
.then((json) => {
this.orderCountData_Form = json.ordercount;
this.loading = false;
3 years ago
})
.catch((error) => {
this.loading = false;
3 years ago
console.log('fetch data failed', error);
});
}
3 years ago
}
3 years ago
3 years ago
export default OrdersStore;