diff --git a/ruoyi-ui/package.json b/ruoyi-ui/package.json index 431f62a..6daf376 100644 --- a/ruoyi-ui/package.json +++ b/ruoyi-ui/package.json @@ -42,6 +42,7 @@ "core-js": "3.37.1", "dplayer": "^1.27.1", "echarts": "5.4.0", + "echarts-liquidfill": "^3.1.0", "element-ui": "2.15.14", "file-saver": "2.0.5", "fuse.js": "6.4.3", @@ -59,7 +60,8 @@ "vue-meta": "2.4.0", "vue-router": "3.4.9", "vuedraggable": "2.24.3", - "vuex": "3.6.0" + "vuex": "3.6.0", + "xlsx": "^0.18.5" }, "devDependencies": { "@vue/cli-plugin-babel": "4.4.6", diff --git a/ruoyi-ui/src/assets/images/electricityIcon.svg b/ruoyi-ui/src/assets/images/electricityIcon.svg new file mode 100644 index 0000000..c150c81 --- /dev/null +++ b/ruoyi-ui/src/assets/images/electricityIcon.svg @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/ruoyi-ui/src/components/Charts/Chart.vue b/ruoyi-ui/src/components/Charts/Chart.vue new file mode 100644 index 0000000..6eb0e6e --- /dev/null +++ b/ruoyi-ui/src/components/Charts/Chart.vue @@ -0,0 +1,51 @@ + + + diff --git a/ruoyi-ui/src/utils/dateReportUtils.js b/ruoyi-ui/src/utils/dateReportUtils.js new file mode 100644 index 0000000..6485110 --- /dev/null +++ b/ruoyi-ui/src/utils/dateReportUtils.js @@ -0,0 +1,63 @@ +export function getHoursBetween(startHourStr, endHourStr) { + const startHour = new Date(startHourStr) + let endHour = new Date(endHourStr) + let nowDate = new Date() + nowDate.setHours(nowDate.getHours() - 1); + if (endHour.getTime() > nowDate.getTime()) { + endHour = nowDate + } + const hours = [] + while (startHour <= endHour) { + const hourString = `${startHour.getFullYear()}-${String(startHour.getMonth() + 1).padStart(2, '0')}-${String(startHour.getDate()).padStart(2, '0')} ${String(startHour.getHours()).padStart(2, '0')}:00:00` + hours.push(hourString) + startHour.setTime(startHour.getTime() + 60 * 60 * 1000) + } + // return hours; + return hours.sort((a, b) => new Date(b) - new Date(a)) +} + +export function getDatesBetween(startDateStr, endDateStr) { + const startDate = new Date(startDateStr) + let endDate = new Date(endDateStr) + let nowDate = new Date() + nowDate.setHours(nowDate.getHours() - 1); + if (endDate.getTime() > nowDate.getTime()) { + endDate = nowDate + } + const dates = [] + while (startDate <= endDate) { + dates.push(`${startDate.getFullYear()}-${String(startDate.getMonth() + 1).padStart(2, '0')}-${String(startDate.getDate()).padStart(2, '0')}`) + startDate.setDate(startDate.getDate() + 1) + } + // return dates; + return dates.sort((a, b) => new Date(b) - new Date(a)) +} + +export function getMonthsBetween(startMonthStr, endMonthStr) { + const result = [] + const startDate = new Date(startMonthStr + '-01') + let endDate = new Date(endMonthStr + '-01') + const currentDate = new Date(startDate) + let nowDate = new Date() + nowDate.setHours(nowDate.getHours() - 1); + if (endDate.getTime() > nowDate.getTime()) { + endDate = nowDate + } + while (currentDate <= endDate) { + const year = currentDate.getFullYear() + const month = String(currentDate.getMonth() + 1).padStart(2, '0') + result.push(`${year}-${month}`) + currentDate.setMonth(currentDate.getMonth() + 1) + } + return result.sort((a, b) => new Date(b) - new Date(a)) +} + +export function getYearsBetween(startYearStr, endYearStr) { + const result = [] + const startYear = Number(startYearStr.substring(0, 4)) + const endYear = Number(endYearStr.substring(0, 4)) + for (let i = startYear; i <= endYear; i++) { + result.push(`${i}`) + } + return result.sort((a, b) => new Date(b) - new Date(a)) +} diff --git a/ruoyi-ui/src/utils/export.js b/ruoyi-ui/src/utils/export.js new file mode 100644 index 0000000..3c8c6c8 --- /dev/null +++ b/ruoyi-ui/src/utils/export.js @@ -0,0 +1,36 @@ + +import FileSaver from "file-saver"; +import XLSX from "xlsx"; + + +/** + * 字符权限校验 + * @param {Array} value 校验值 + * @returns {Boolean} + * id:表ID + * name:导出表名字 + *xlsxParam:true/false:如果表格里有数字、日期这些、需要加上raw: true + */ +export function handleExport(id,name,xlsxParam) { + var wb = XLSX.utils.table_to_book( + document.querySelector('#'+id), + {raw: xlsxParam} + ); + + var wbout = XLSX.write(wb, { + bookType: "xlsx", + bookSST: true, + type: "array", + }); + try { + FileSaver.saveAs( + new Blob([wbout], { type: "application/octet-stream" }), + name+".xlsx" + ); + } catch (e) { + if (typeof console !== "undefined") { + console.log(e, wbout); + } + } + return wbout; +}