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.
140 lines
5.0 KiB
JavaScript
140 lines
5.0 KiB
JavaScript
import {makeAutoObservable, runInAction} from "mobx";
|
|
import * as dd from 'dingtalk-jsapi';
|
|
import * as config from "../config";
|
|
import * as comm from '../utils/commons';
|
|
|
|
|
|
// 财务管理
|
|
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),
|
|
};
|
|
|
|
bt_handleChange(value) {
|
|
this.bill_type_data.bill_types = value;
|
|
};
|
|
|
|
get_bill_types() {
|
|
const date_picker_store = this.rootStore.date_picker_store;
|
|
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;
|
|
});
|
|
})
|
|
.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) => {
|
|
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'],
|
|
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;
|
|
}
|
|
|
|
// 请求信用卡账单
|
|
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;
|
|
});
|
|
})
|
|
.catch((error) => {
|
|
console.log('fetch data failed', error);
|
|
});
|
|
}
|
|
|
|
// 请求信用卡账单
|
|
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;
|
|
});
|
|
})
|
|
.catch((error) => {
|
|
console.log('fetch data failed', error);
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
export default FinancialStore;
|
|
|