From e84c5e92533e677778cb3eef9923cd62d5e82935 Mon Sep 17 00:00:00 2001
From: gaoshp <291585735@qq.com>
Date: 星期二, 18 六月 2024 23:11:17 +0800
Subject: [PATCH] update
---
src/views/mdc/components/Time.vue | 115 ++++++++++++++++++++++++++++++++++++++++++---------------
1 files changed, 84 insertions(+), 31 deletions(-)
diff --git a/src/views/mdc/components/Time.vue b/src/views/mdc/components/Time.vue
index c01ab7c..cd12ccb 100644
--- a/src/views/mdc/components/Time.vue
+++ b/src/views/mdc/components/Time.vue
@@ -1,22 +1,21 @@
<!--
* @Date: 2024-04-18 21:52:18
* @LastEditors: Sneed
- * @LastEditTime: 2024-04-20 20:41:13
+ * @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 @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>
<el-col style="margin-top: 12px;">
<el-card shadow="never">
- <scEcharts height="300px" :option="option2"></scEcharts>
+ <scEcharts height="300px" :option="option2" v-if="option2.title" />
</el-card>
</el-col>
<el-col>
@@ -26,9 +25,9 @@
<scTable ref="table" row-key="id" border :params="params" :apiObj="apiObj" stripe>
<el-table-column prop="workstationCode" label="宸ヤ綅缂栫爜" />
<el-table-column prop="workstationName" label="宸ヤ綅鍚嶇О" />
- <el-table-column prop="" :label="item" v-for="item in cols">
+ <el-table-column prop="" :label="item" v-for="item in cols" :key="item">
<template #default="scope">
- <span>{{ scope.row.data[item] }}</span>
+ <span>{{ colnameFn(scope.row.data[item]) }}</span>
</template>
</el-table-column>
@@ -39,7 +38,33 @@
<script>
import scEcharts from '@/components/scEcharts';
+import moment from 'moment'
export default {
+ props: {
+ url: {
+ default: '/api/blade-mdc/efficiency-analysis',
+ type: String,
+ },
+ options: {
+ default() {
+ return {}
+ },
+ },
+ colnameFn: {
+ type: Function,
+ default: val => {
+ if (isNaN(val)) return '-'
+ return `${(val ? val * 100 : 0).toFixed(2)}%`
+ }
+ },
+ resFn: {
+ type: Function,
+ default: val => {
+ if (isNaN(val)) return 0
+ return (val - 0) * 100
+ }
+ }
+ },
components: {
scEcharts
},
@@ -64,20 +89,27 @@
],
cols: [],
chartsData: [],
- option2: null,
+ 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({
@@ -85,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,
@@ -97,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 = {
@@ -115,7 +161,8 @@
queryType: 0,
statisticalMethod: this.statisticalMethod
}
- return this.$HTTP.post('/api/blade-mdc/efficiency-analysis', dataSend, { params }).then(res => {
+ this.option2 = {}
+ return this.$HTTP.post(this.url, dataSend, { params }).then(res => {
this.chartsData = res.data.items.records
let option2 = {
// legend: {
@@ -134,11 +181,16 @@
xAxis: {
type: 'category',
axisLabel: {
- interval: 'auto'
+ interval: 'auto',
}
},
yAxis: {
- type: 'value'
+ type: 'value',
+ axisLabel: {
+ formatter: (value) => {
+ return value + '%'
+ }
+ },
},
dataZoom: [
{ type: 'slider' }
@@ -146,7 +198,8 @@
dataset: {
source: []
},
- series: []
+ ...this.options,
+ series: [],
}
let source1 = ['product']
let row = res.data.items.records[0]
@@ -160,7 +213,8 @@
res.data.items.records.forEach(v => {
let current = [v.id]
Object.keys(v.nameData).forEach(key => {
- current.push(row.data[key] - 0)
+ current.push(this.resFn(v.data[key]))
+ // current.push((v.data[key] - 0) * 100)
})
option2.dataset.source.push(current)
});
@@ -168,8 +222,7 @@
console.log(option2)
})
},
- query(params) {
- this.params = params
+ query() {
this.apiObj = {
get: async (data) => {
let params = {
@@ -185,7 +238,7 @@
delete dataSend.size
delete dataSend.order
delete dataSend.prop
- return await this.$HTTP.post('/api/blade-mdc/efficiency-analysis', dataSend, { params }).then(res => {
+ return await this.$HTTP.post(this.url, dataSend, { params }).then(res => {
let row = res.data.items?.records[0]?.data || {}
this.cols = Object.keys(row)
console.log(this.cols)
--
Gitblit v1.9.3