From e1725ad8bfa9167d20184f6c166fbd459cfcc1fb Mon Sep 17 00:00:00 2001 From: gaoshp <291585735@qq.com> Date: 星期二, 18 六月 2024 20:19:11 +0800 Subject: [PATCH] update --- src/views/mdc/components/Time.vue | 62 ++++++++++++++++++++---------- 1 files changed, 41 insertions(+), 21 deletions(-) diff --git a/src/views/mdc/components/Time.vue b/src/views/mdc/components/Time.vue index 5bb8fcd..cd12ccb 100644 --- a/src/views/mdc/components/Time.vue +++ b/src/views/mdc/components/Time.vue @@ -1,16 +1,15 @@ <!-- * @Date: 2024-04-18 21:52:18 * @LastEditors: Sneed - * @LastEditTime: 2024-06-17 23:37:51 + * @LastEditTime: 2024-06-18 20:09:02 * @FilePath: /belleson-frontend/Users/mache/Documents/demo/cps-web/src/views/mdc/components/Time.vue --> <template> <el-row> <el-col> <el-button-group> - <el-button size="small" @click="statisticalMethod = item.value" - :type="statisticalMethod == item.value ? 'primary' : ''" v-for="item in btnList" - :key="item.value">{{ + <el-button size="small" @click="change(item)" :type="statisticalMethod == item.value ? 'primary' : ''" + v-for="item in btnList" :key="item.value">{{ item.label }}</el-button> </el-button-group> </el-col> @@ -39,6 +38,7 @@ <script> import scEcharts from '@/components/scEcharts'; +import moment from 'moment' export default { props: { url: { @@ -90,19 +90,26 @@ cols: [], chartsData: [], option2: {}, + btnListNew: [] } }, watch: { statisticalMethod(val) { - this.query({ - ...this.params, - }) - this.queryChart({ - ...this.params, - }) + // this.query({ + // ...this.params, + // }) + // this.queryChart({ + // ...this.params, + // }) } }, methods: { + change(item) { + this.statisticalMethod = item.value + this.init({ + ...this.params + }) + }, init(params) { this.params = params this.getTime({ @@ -110,9 +117,22 @@ startDate: params.startDate, statisticalMethod: this.statisticalMethod }).then(res => { - this.query({ + let startDate = Math.min(...res.data.map(v => new Date(v.startDate).getTime())) + let endDate = Math.max(...res.data.map(v => new Date(v.startDate).getTime())) + let data = { ...params, statisticalMethod: this.statisticalMethod + } + if (this.statisticalMethod !== 'Day') { + data = { + ...data, + endDate: moment(endDate).format('YYYY-MM-DD'), + statisticalMethod: this.statisticalMethod + } + } + console.log(startDate, endDate) + this.query({ + ...data }) this.queryChart({ ...params, @@ -122,14 +142,15 @@ }, getTime(data) { - return Promise.resolve() - // return this.$HTTP.post('/api/blade-mdc/efficiency-analysis/interval', { - // ...data - // }).then(res => { - // if (res.code === 200) { - // this.btnList = res.data - // } - // }) + //return Promise.resolve() + return this.$HTTP.post('/api/blade-mdc/efficiency-analysis/interval', { + ...data + }).then(res => { + if (res.code === 200) { + this.btnListNew = res.data + return res + } + }) }, queryChart(data) { let params = { @@ -201,8 +222,7 @@ console.log(option2) }) }, - query(params) { - this.params = params + query() { this.apiObj = { get: async (data) => { let params = { -- Gitblit v1.9.3