import {makeAutoObservable, runInAction} from "mobx"; import * as dd from 'dingtalk-jsapi'; import * as config from "../config"; //财务管理 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; let 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); }); } credit_card_data = { data: [], data_by_type: [], loading:false, bu_select_mode: false, business_units: ['ALL'], group_select_mode: false, groups: ['ALL'], bu_handleChange: this.bu_handleChange.bind(this), group_handleChange: this.group_handleChange.bind(this), }; bu_handleChange(value) { this.credit_card_data.business_units = value; }; group_handleChange(value) { this.credit_card_data.groups = value; }; //请求信用卡账单 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.toString()}&groups=${this.credit_card_data.groups.toString()}&billtype=${this.bill_type_data.bill_types.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 = 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.toString()}&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;