|
@@ -1,4 +1,5 @@
|
|
const path = require("path");
|
|
const path = require("path");
|
|
|
|
+import { RangePicker, RangePickerText } from "./config/range";
|
|
|
|
|
|
/**
|
|
/**
|
|
* json字符串格式化
|
|
* json字符串格式化
|
|
@@ -74,3 +75,18 @@ export const formatSelectOptions = <T>(
|
|
};
|
|
};
|
|
});
|
|
});
|
|
};
|
|
};
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * 获取需要筛选的时间区间
|
|
|
|
+ * @param range eg: ["today", "month", "week", "three_month"]
|
|
|
|
+ */
|
|
|
|
+export const rangePicker = (range: string[]) => {
|
|
|
|
+ let rangeConfig: Record<string, moment.Moment[]> = Object.create({});
|
|
|
|
+
|
|
|
|
+ range.forEach((r: string) => {
|
|
|
|
+ const text = (<Record<string, string>>RangePickerText)[r];
|
|
|
|
+ rangeConfig[text] = (RangePicker as Record<string, moment.Moment[]>)[r];
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ return rangeConfig;
|
|
|
|
+};
|