| | |
| | | import type { Ref } from 'vue'; |
| | | import JSONbig from 'json-bigint'; |
| | | import { ElMessage, ElMessageBox } from 'element-plus'; |
| | | import JSONbig from 'json-bigint'; |
| | | import { storeToRefs } from 'pinia'; |
| | | import type { Ref } from 'vue'; |
| | | import { useTagsViewRoutes } from '/@/stores/tagsViewRoutes'; |
| | | import { useThemeConfig } from '/@/stores/themeConfig'; |
| | | import { storeToRefs } from 'pinia'; |
| | | import request from '/@/utils/request'; |
| | | // 导入依赖 |
| | | import axios from 'axios'; |
| | | import FileSaver from 'file-saver'; |
| | | import * as XLSX from 'xlsx'; |
| | | import axios from 'axios'; |
| | | import { MAIN_URL } from '../constants'; |
| | | |
| | | |
| | | /** |
| | | * 普通对象转为 formData |
| | |
| | | addFormData(obj); |
| | | return formData; |
| | | }; |
| | | |
| | | |
| | | /** |
| | | * @description 当碰到 JSON 中存在过长的数字时,使用 JSONbigString 解析,数字会转为字符串处理 |
| | |
| | | ) => { |
| | | if (!treeData || treeData.length === 0) return; |
| | | if (!parent) parent = treeData; |
| | | |
| | | |
| | | for (let index = 0; index < treeData.length; index++) { |
| | | const value = treeData[index] as any; |
| | | if (markParent) { |
| | |
| | | |
| | | themeConfig.value.isTagsview = !isHide; |
| | | }; |
| | | |
| | | /** |
| | | * 最近 n 天的 startDate、endDate |
| | | * @param dates |
| | | */ |
| | | export const getRecentDateRange = (dates: number) => { |
| | | export const getRecentDateRange = (dates: number, includesCurrent = true) => { |
| | | dates = includesCurrent ? dates - 1 : dates; |
| | | // 获取当前日期 |
| | | const currentDate = new Date(); |
| | | |
| | | const endDate = new Date(); |
| | | const startDate = new Date(); |
| | | startDate.setDate(currentDate.getDate() - dates + 1); |
| | | // 将时分秒设为0 |
| | | startDate.setHours(0); |
| | | startDate.setMinutes(0); |
| | | startDate.setSeconds(0); |
| | | // 获取当前日期作为终止节点 |
| | | const endDate = currentDate; |
| | | return { startDate, endDate }; |
| | | startDate.setTime(startDate.getTime() - 3600 * 1000 * 24 * dates); |
| | | startDate.setHours(0, 0, 0, 0); |
| | | return [startDate, endDate]; |
| | | }; |
| | | |
| | | /** |
| | | * 最近 n 天的 date |
| | | * @param dates |
| | | */ |
| | | export const getRecentDate = (dates: number) => { |
| | | // 获取当前日期 |
| | | const recentDate = new Date(); |
| | | recentDate.setTime(recentDate.getTime() - 3600 * 1000 * 24 * dates); |
| | | recentDate.setHours(0, 0, 0, 0); |
| | | return recentDate; |
| | | }; |
| | | |
| | | //#region ====================== 最近时间 ====================== |
| | | export const getAWeek = () => getRecentDateRange(7); |
| | | export const getAWeek = () => { |
| | | return getRecentDateRange(7); |
| | | }; |
| | | export const getHalfMonth = () => getRecentDateRange(15); |
| | | export const getAMonth = () => getRecentDateRange(30); |
| | | export const getThreeMonth = () => getRecentDateRange(90); |
| | |
| | | export const arrayIsEmpty = (arr: any) => { |
| | | return !arr || arr.length === 0; |
| | | }; |
| | | |
| | | type GetTextWidthOption = { |
| | | size?: string; |
| | | family?: string; |
| | | }; |
| | | |
| | | export function getTextWidth(text: string, option: GetTextWidthOption) { |
| | | if (!text) return 0; |
| | | const { size = '14px', family = 'Microsoft YaHei' } = option; |
| | | const spanEle = document.createElement('span'); |
| | | document.body.appendChild(spanEle); |
| | | |
| | | spanEle.style.font = 'times new roman'; |
| | | spanEle.style.fontSize = size; |
| | | spanEle.style.height = 'auto'; |
| | | spanEle.style.width = 'auto'; |
| | | spanEle.style.position = 'absolute'; |
| | | spanEle.style.whiteSpace = 'no-wrap'; |
| | | spanEle.innerHTML = text; |
| | | |
| | | const width = spanEle.clientWidth; |
| | | |
| | | document.body.removeChild(spanEle); |
| | | return width; |
| | | } |