diff --git a/public/index.html b/public/index.html
index 2b0b7a3..637312a 100644
--- a/public/index.html
+++ b/public/index.html
@@ -24,9 +24,7 @@
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
-
React App
-
-
+ Hainatravel Dashboard
diff --git a/src/config.js b/src/config.js
index 5d3c28c..a07dcf8 100644
--- a/src/config.js
+++ b/src/config.js
@@ -2,5 +2,5 @@ import React from "react";
export const stores_Context = React.createContext();
export const DATE_FORMAT = 'YYYY-MM-DD';
-//export const HT_HOST = 'https://p9axztuwd7x8a7.mycht.cn';
-export const HT_HOST = 'http://202.103.68.100:890';//889正式库
\ No newline at end of file
+export const HT_HOST = 'https://p9axztuwd7x8a7.mycht.cn';
+//export const HT_HOST = 'http://202.103.68.100:890';//889正式库
\ No newline at end of file
diff --git a/src/stores/AuthStore.js b/src/stores/AuthStore.js
index 9c093ad..d5f70ce 100644
--- a/src/stores/AuthStore.js
+++ b/src/stores/AuthStore.js
@@ -9,11 +9,11 @@ class AuthStore {
constructor(rootStore) {
this.rootStore = rootStore;
makeAutoObservable(this);
- //this.get_auth();
+ //this.get_auth(); //放到钉钉环境才能开启
}
- auth = ['admin'];
- user = {name:'ycc',userid:'12345678'};
+ auth = ['admin']; //开发时候用,正式环境留空
+ user = {name:'ycc',userid:'12345678'};//开发时候用,正式环境留空
has_permission(requireds) {
if (Object.keys(requireds).length == 0) {
diff --git a/src/stores/FinancialStore.js b/src/stores/FinancialStore.js
index 1d6f320..245ff2d 100644
--- a/src/stores/FinancialStore.js
+++ b/src/stores/FinancialStore.js
@@ -1,6 +1,7 @@
import {makeAutoObservable, runInAction} from "mobx";
import * as dd from 'dingtalk-jsapi';
import * as config from "../config";
+import * as comm from '../utils/commons'
//财务管理
@@ -38,15 +39,42 @@ class FinancialStore {
});
}
+ 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) => {
+ let filters_arr = Object.values(filters);
+ if (!comm.empty(filters_arr)) {
+ this.set_bill_filtered(filters_arr[0]);
+ }
+ };
+
credit_card_data = {
data: [],
- loading:false,
+ 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) {
@@ -77,6 +105,27 @@ class FinancialStore {
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);
+ });
+ }
}
diff --git a/src/stores/OrdersStore.js b/src/stores/OrdersStore.js
index 3467dc3..f2ec8f4 100644
--- a/src/stores/OrdersStore.js
+++ b/src/stores/OrdersStore.js
@@ -8,7 +8,6 @@ import * as config from "../config";
import moment from "moment";
import {NavLink} from "react-router-dom";
-
class OrdersStore {
constructor(rootStore) {
@@ -50,7 +49,10 @@ class OrdersStore {
})
}
if (data_source.ordercount2 && end_date) {
- let diff_days = start_date.diff(end_date, 'days');
+ //不能直接用diff计算,因为日期是含有时间的,会导致计算差一天,先转成格式化的日期再比较
+ let _start_date=moment(start_date.format(config.DATE_FORMAT));
+ let _end_date=moment(end_date.format(config.DATE_FORMAT));
+ let diff_days = _start_date.diff(_end_date, 'days');
for (let item of data_source.ordercount2) {
result.push({
'xField': moment(item.ApplyDate).add(diff_days, 'days').format(config.DATE_FORMAT),
@@ -109,16 +111,6 @@ class OrdersStore {
});
}
- show_vs_tag(vs, data1, data2) {
- let tag = '-';
- if (parseInt(vs) < 0) {
- tag = } color="gold">{vs}
- } else if (parseInt(vs) > 0) {
- tag = } color="lime">{vs}
- }
- return
{data1} vs {data2}
- {tag}
- }
//网站订单类型
getOrderCountByType(order_type) {
diff --git a/src/utils/commons.js b/src/utils/commons.js
index b9b9c59..f501970 100644
--- a/src/utils/commons.js
+++ b/src/utils/commons.js
@@ -1,18 +1,24 @@
// https://github.com/uxitten/polyfill/blob/master/string.polyfill.js
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/padStart
+import {Tag} from "antd";
+import {
+ CaretUpOutlined,
+ CaretDownOutlined
+} from '@ant-design/icons';
+import moment from "moment";
+
if (!String.prototype.padStart) {
- String.prototype.padStart = function padStart(targetLength,padString) {
- targetLength = targetLength>>0; //floor if number or convert non-number to 0;
+ String.prototype.padStart = function padStart(targetLength, padString) {
+ targetLength = targetLength >> 0; //floor if number or convert non-number to 0;
padString = String((typeof padString !== 'undefined' ? padString : ' '));
if (this.length > targetLength) {
return String(this);
- }
- else {
- targetLength = targetLength-this.length;
+ } else {
+ targetLength = targetLength - this.length;
if (targetLength > padString.length) {
- padString += padString.repeat(targetLength/padString.length); //append to original to ensure we are longer than needed
+ padString += padString.repeat(targetLength / padString.length); //append to original to ensure we are longer than needed
}
- return padString.slice(0,targetLength) + String(this);
+ return padString.slice(0, targetLength) + String(this);
}
};
}
@@ -28,21 +34,21 @@ export function named(value) {
}
export function formatCurrency(name) {
- if (name === 'USD' ) {
- return '$';
- } else if (name === 'RMB') {
- return '¥';
- } else if (name === 'EUR') {
- return '€'
- } else if (name === 'GBP') {
- return '£'
- } else {
- return name + ' ';
- }
+ if (name === 'USD') {
+ return '$';
+ } else if (name === 'RMB') {
+ return '¥';
+ } else if (name === 'EUR') {
+ return '€'
+ } else if (name === 'GBP') {
+ return '£'
+ } else {
+ return name + ' ';
+ }
}
export function formatPrice(price) {
- return Math.ceil(price).toLocaleString();
+ return Math.ceil(price).toLocaleString();
}
export function formatPercent(number) {
@@ -50,7 +56,9 @@ export function formatPercent(number) {
}
export function formatDate(date) {
- if (isEmpty(date)) { return 'NaN'; }
+ if (isEmpty(date)) {
+ return 'NaN';
+ }
const year = date.getFullYear();
const month = date.getMonth() + 1;
@@ -60,7 +68,7 @@ export function formatDate(date) {
const dayStr = ('' + day).padStart(2, 0);
const formatted = year + '-' + monthStr + '-' + dayStr;
- return formatted;
+ return formatted;
}
export function formatTime(date) {
@@ -170,8 +178,8 @@ export function debounce(fn, delay = 500) {
export function throttle(fn, delay, atleast) {
let timeout = null,
- startTime = new Date();
- return function() {
+ startTime = new Date();
+ return function () {
let curTime = new Date();
clearTimeout(timeout);
if (curTime - startTime >= atleast) {
@@ -188,4 +196,44 @@ export function clickUrl(url) {
httpLink.href = url;
httpLink.target = '_blank';
httpLink.click();
-}
\ No newline at end of file
+}
+
+export function show_vs_tag(vs, vs_diff, data1, data2) {
+ let tag = '-';
+ if (parseInt(vs) < 0) {
+ tag = } color="gold">{vs} {vs_diff}
+ } else if (parseInt(vs) > 0) {
+ tag = } color="lime">{vs} {vs_diff}
+ }// else {
+ // tag = } color="lime">{vs} {vs_diff}
+ // }
+ return