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

173 lines
6.0 KiB
JavaScript

import {makeAutoObservable, runInAction} from "mobx";
import * as config from "../config";
3 years ago
import * as comm from '../utils/commons';
import { fetchJSON } from '../utils/request';
3 years ago
// 财务管理
class FinancialStore {
constructor(rootStore) {
this.rootStore = rootStore;
makeAutoObservable(this);
this.get_bill_types();
}
bill_type_data = {
data: [],
bill_type_mode: false,
bill_types: ['ALL'],
bt_handleChange: this.bt_handleChange.bind(this),
3 years ago
};
bt_handleChange(value) {
this.bill_type_data.bill_types = value;
};
get_bill_types() {
const date_picker_store = this.rootStore.date_picker_store;
3 years ago
const url = '/service-web/QueryData/GetCreditCardBillType';
fetch(config.HT_HOST + url)
.then((response) => response.json())
.then((json) => {
runInAction(() => {
this.bill_type_data.data = json.billtype;
3 years ago
});
})
.catch((error) => {
console.log('fetch data failed', error);
});
}
set_bill_filtered(values) {
if (Array.isArray(values)) {
this.credit_card_data.filteredValue = values;
} else if (comm.empty(values)) {
this.credit_card_data.filteredValue = [];
} else {
this.credit_card_data.filteredValue = [values];
}
}
set_active_tab(value) {
this.credit_card_data.active_tab = value;
}
set_table_handleChange = (pagination, filters, sorter) => {
3 years ago
const filters_arr = Object.values(filters);
if (!comm.empty(filters_arr)) {
this.set_bill_filtered(filters_arr[0]);
}
};
credit_card_data = {
data: [],
data_by_type: [],
active_tab: 'summarized_data',
loading: false,
bu_select_mode: false,
business_units: ['ALL'],
group_select_mode: false,
groups: ['ALL'],
3 years ago
filteredValue: [],// 默认的筛选值
bu_handleChange: this.bu_handleChange.bind(this),
group_handleChange: this.group_handleChange.bind(this),
set_bill_filtered: this.set_bill_filtered.bind(this),
set_active_tab: this.set_active_tab.bind(this),
set_table_handleChange: this.set_table_handleChange.bind(this),
};
bu_handleChange(value) {
this.credit_card_data.business_units = value;
};
group_handleChange(value) {
this.credit_card_data.groups = value;
};
setSearchValues(obj, values) {
this.credit_card_data.business_units = obj.businessUnits;
// this.credit_card_data.groups = obj.businessUnits;
this.bill_type_data.bill_types = obj.billtype;
}
3 years ago
// 请求信用卡账单
get_credit_card_bills() {
const date_picker_store = this.rootStore.date_picker_store;
let url = '/service-web/QueryData/GetCreditCardBills';
url += `?business_unit=${this.credit_card_data.business_units}&groups=${this.credit_card_data.groups.toString()}&billtype=${this.bill_type_data.bill_types}`;
url += '&billdate1=' + date_picker_store.start_date.format(config.DATE_FORMAT) + '&billdate2=' + 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 += '&billdateOld1=' + date_picker_store.start_date_cp.format(config.DATE_FORMAT) + '&billdateOld2=' + date_picker_store.end_date_cp.format(config.DATE_FORMAT) + '%2023:59:59';
}
fetch(config.HT_HOST + url)
.then((response) => response.json())
.then((json) => {
runInAction(() => {
this.credit_card_data.data = json;
3 years ago
});
})
.catch((error) => {
console.log('fetch data failed', error);
});
}
3 years ago
// 请求信用卡账单
get_credit_card_bills_by_type() {
const date_picker_store = this.rootStore.date_picker_store;
let url = '/service-web/QueryData/GetCreditCardBillsByType';
url += `?business_unit=${this.credit_card_data.business_units}&groups=${this.credit_card_data.groups.toString()}`;
url += '&billdate1=' + date_picker_store.start_date.format(config.DATE_FORMAT) + '&billdate2=' + 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 += '&billdateOld1=' + date_picker_store.start_date_cp.format(config.DATE_FORMAT) + '&billdateOld2=' + date_picker_store.end_date_cp.format(config.DATE_FORMAT) + '%2023:59:59';
}
fetch(config.HT_HOST + url)
.then((response) => response.json())
.then((json) => {
runInAction(() => {
this.credit_card_data.data_by_type = json;
3 years ago
});
})
.catch((error) => {
console.log('fetch data failed', error);
});
}
/**
* 服务人数页面 ----
*/
servicePersonNum = { curTab: 'inbound',
'inbound': { loading: false, dataSource: [], total: {} },
'outbound': { loading: false, dataSource: [], total: {} },
'domestic': { loading: false, dataSource: [], total: {} },
};
setCurTab(v) {
this.servicePersonNum.curTab = v;
}
/**
* 获取服务人数
*/
async getPersonNum(queryData) {
this.servicePersonNum[this.servicePersonNum.curTab].loading = true;
const json = await fetchJSON('/inbound_person_num/test', queryData);
if (json.errcode === 0) {
runInAction(() => {
this.servicePersonNum[this.servicePersonNum.curTab].loading = false;
this.servicePersonNum[this.servicePersonNum.curTab].dataSource = [].concat([json.resultTotal], json.result);
this.servicePersonNum[this.servicePersonNum.curTab].total = json.resultTotal;
});
}
return json;
}
/**
* ---- end 服务人数页面
*/
}
export default FinancialStore;