diff --git a/package.json b/package.json index cfbb01a..58d5885 100644 --- a/package.json +++ b/package.json @@ -18,8 +18,10 @@ "avue-plugin-map": "^1.0.1", "axios": "0.18.1", "core-js": "3.6.5", + "echarts": "^4.2.1", "element-ui": "2.13.2", "js-cookie": "2.2.0", + "moment": "^2.29.4", "normalize.css": "7.0.0", "nprogress": "0.2.0", "path-to-regexp": "2.4.0", diff --git a/src/api/rain/report/inspectionContentReport.js b/src/api/rain/report/inspectionContentReport.js new file mode 100644 index 0000000..9506a6a --- /dev/null +++ b/src/api/rain/report/inspectionContentReport.js @@ -0,0 +1,9 @@ +import request from '@/utils/request' + +export function inspectionChart(data) { + return request({ + url: '/api/admin/rain-inspection/chart', + method: 'get', + params:data + }) +} diff --git a/src/api/rain/report/maintainContentReport.js b/src/api/rain/report/maintainContentReport.js new file mode 100644 index 0000000..ec7dcec --- /dev/null +++ b/src/api/rain/report/maintainContentReport.js @@ -0,0 +1,9 @@ +import request from '@/utils/request' + +export function maintainsChart(data) { + return request({ + url: '/api/admin/rain-maintains/chart', + method: 'get', + params:data + }) +} diff --git a/src/main.js b/src/main.js index af26d29..9ec8ca4 100644 --- a/src/main.js +++ b/src/main.js @@ -13,7 +13,9 @@ import router from './router' import '@/icons' // icon import '@/permission' // permission control -import ViewUI from 'view-design'; +import ViewUI from 'view-design'; +import moment from "moment" +Vue.prototype.$moment = moment; import './styles/viewui-mine.less'; Vue.use(ViewUI); /** diff --git a/src/utils/request.js b/src/utils/request.js index b530ddb..0ec346c 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -1,87 +1,101 @@ -import axios from 'axios' -import { MessageBox, Message } from 'element-ui' -import store from '@/store' -import { getToken } from '@/utils/auth' - -// create an axios instance -const service = axios.create({ - baseURL: process.env.VUE_APP_BASE_API, // url = base url + request url - // withCredentials: true, // send cookies when cross-domain requests - timeout: 50000 // request timeout -}) - -// request interceptor -service.interceptors.request.use( - config => { - // do something before request is sent - - if (store.getters.token) { - // let each request carry token - // ['X-Token'] is a custom headers key - // please modify it according to the actual situation - //config.headers['X-Token'] = getToken(); - - config.headers['Authorization'] ="Bearer "+getToken() - } - return config - }, - error => { - // do something with request error - console.log(error) // for debug - return Promise.reject(error) - } -) - -// response interceptor -service.interceptors.response.use( - /** - * If you want to get http information such as headers or status - * Please return response => response - */ - - /** - * Determine the request status by custom code - * Here is just an example - * You can also judge the status by HTTP Status Code - */ - response => { - const res = response.data - - // if the custom code is not 20000, it is judged as an error. - if (res.errcode) { - Message({ - message: res.errmsg || 'Error', - type: 'error', - duration: 5 * 1000 - }) - - // 50008: Illegal token; 50012: Other clients logged in; 50014: Token expired; - if (res.errcode === 50008 || res.errcode === 50012 || res.errcode === 50014) { - // to re-login - MessageBox.confirm('You have been logged out, you can cancel to stay on this page, or log in again', 'Confirm logout', { - confirmButtonText: 'Re-Login', - cancelButtonText: 'Cancel', - type: 'warning' - }).then(() => { - store.dispatch('user/resetToken').then(() => { - location.reload() - }) - }) - } - return Promise.reject(new Error(res.errmsg || 'Error')) - } else { - return res - } - }, - error => { - console.log('err' + error) // for debug - Message({ - message: error.message, - type: 'error', - duration: 5 * 1000 - }) - return Promise.reject(error) - } -) - +import axios from 'axios' +import { + MessageBox, + Message, + Loading +} from 'element-ui' +import store from '@/store' +import { + getToken +} from '@/utils/auth' +let loading; + +// create an axios instance +const service = axios.create({ + baseURL: process.env.VUE_APP_BASE_API, // url = base url + request url + // withCredentials: true, // send cookies when cross-domain requests + timeout: 50000 // request timeout +}) + +// request interceptor +service.interceptors.request.use( + config => { + // do something before request is sent + loading = Loading.service({ + lock: true, + background: "rgba(0,0,0,0.4)", + text: "正在加载中..." + }) + if (store.getters.token) { + // let each request carry token + // ['X-Token'] is a custom headers key + // please modify it according to the actual situation + //config.headers['X-Token'] = getToken(); + + config.headers['Authorization'] = "Bearer " + getToken() + } + return config + }, + error => { + // do something with request error + console.log(error) // for debug + return Promise.reject(error) + } +) + +// response interceptor +service.interceptors.response.use( + /** + * If you want to get http information such as headers or status + * Please return response => response + */ + + /** + * Determine the request status by custom code + * Here is just an example + * You can also judge the status by HTTP Status Code + */ + response => { + const res = response.data + + loading.close() + // if the custom code is not 20000, it is judged as an error. + if (res.errcode) { + Message({ + message: res.errmsg || 'Error', + type: 'error', + duration: 5 * 1000 + }) + + // 50008: Illegal token; 50012: Other clients logged in; 50014: Token expired; + if (res.errcode === 50008 || res.errcode === 50012 || res.errcode === 50014) { + // to re-login + MessageBox.confirm('You have been logged out, you can cancel to stay on this page, or log in again', + 'Confirm logout', { + confirmButtonText: 'Re-Login', + cancelButtonText: 'Cancel', + type: 'warning' + }).then(() => { + store.dispatch('user/resetToken').then(() => { + location.reload() + }) + }) + } + return Promise.reject(new Error(res.errmsg || 'Error')) + } else { + return res + } + }, + error => { + loading.close() + console.log('err' + error) // for debug + Message({ + message: error.message, + type: 'error', + duration: 5 * 1000 + }) + return Promise.reject(error) + } +) + export default service diff --git a/src/views/rain/report.vue b/src/views/rain/report.vue new file mode 100644 index 0000000..569a535 --- /dev/null +++ b/src/views/rain/report.vue @@ -0,0 +1,9 @@ + + + + + + + diff --git a/src/views/rain/report/components/BarChart.vue b/src/views/rain/report/components/BarChart.vue new file mode 100644 index 0000000..cef9fb2 --- /dev/null +++ b/src/views/rain/report/components/BarChart.vue @@ -0,0 +1,149 @@ + + + + + + diff --git a/src/views/rain/report/components/LineChart.vue b/src/views/rain/report/components/LineChart.vue new file mode 100644 index 0000000..1cc468a --- /dev/null +++ b/src/views/rain/report/components/LineChart.vue @@ -0,0 +1,144 @@ + + + + + + diff --git a/src/views/rain/report/components/PieChart.vue b/src/views/rain/report/components/PieChart.vue new file mode 100644 index 0000000..3979b90 --- /dev/null +++ b/src/views/rain/report/components/PieChart.vue @@ -0,0 +1,163 @@ + + + + + + diff --git a/src/views/rain/report/components/mixins/resize.js b/src/views/rain/report/components/mixins/resize.js new file mode 100644 index 0000000..234953b --- /dev/null +++ b/src/views/rain/report/components/mixins/resize.js @@ -0,0 +1,55 @@ +import { debounce } from '@/utils' + +export default { + data() { + return { + $_sidebarElm: null, + $_resizeHandler: null + } + }, + mounted() { + this.$_resizeHandler = debounce(() => { + if (this.chart) { + this.chart.resize() + } + }, 100) + this.$_initResizeEvent() + this.$_initSidebarResizeEvent() + }, + beforeDestroy() { + this.$_destroyResizeEvent() + this.$_destroySidebarResizeEvent() + }, + // to fixed bug when cached by keep-alive + // https://github.com/PanJiaChen/vue-element-admin/issues/2116 + activated() { + this.$_initResizeEvent() + this.$_initSidebarResizeEvent() + }, + deactivated() { + this.$_destroyResizeEvent() + this.$_destroySidebarResizeEvent() + }, + methods: { + // use $_ for mixins properties + // https://vuejs.org/v2/style-guide/index.html#Private-property-names-essential + $_initResizeEvent() { + window.addEventListener('resize', this.$_resizeHandler) + }, + $_destroyResizeEvent() { + window.removeEventListener('resize', this.$_resizeHandler) + }, + $_sidebarResizeHandler(e) { + if (e.propertyName === 'width') { + this.$_resizeHandler() + } + }, + $_initSidebarResizeEvent() { + this.$_sidebarElm = document.getElementsByClassName('sidebar-container')[0] + this.$_sidebarElm && this.$_sidebarElm.addEventListener('transitionend', this.$_sidebarResizeHandler) + }, + $_destroySidebarResizeEvent() { + this.$_sidebarElm && this.$_sidebarElm.removeEventListener('transitionend', this.$_sidebarResizeHandler) + } + } +} diff --git a/src/views/rain/report/inspectionContentReport.vue b/src/views/rain/report/inspectionContentReport.vue new file mode 100644 index 0000000..789f82a --- /dev/null +++ b/src/views/rain/report/inspectionContentReport.vue @@ -0,0 +1,150 @@ + + + + + + + + + + + + 查询 + {{btnText}} + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/views/rain/report/maintainContentReport.vue b/src/views/rain/report/maintainContentReport.vue new file mode 100644 index 0000000..6bb25e6 --- /dev/null +++ b/src/views/rain/report/maintainContentReport.vue @@ -0,0 +1,176 @@ + + + + + + + + + + + + + + + 查询 + {{btnText}} + + + + + + + + + + + + + + + + + + + + + + + +