湖里大屏(质量管理):新增问题类型,天数 Switch 组件

This commit is contained in:
Jack 2022-08-23 11:51:14 +08:00
parent c77ab15260
commit 0ff56f032a
2 changed files with 79 additions and 12 deletions

View File

@ -0,0 +1,61 @@
<template>
<div class="days-switch">
<div
class="type"
:class="{ checked: daysType === type.value }"
v-for="type in daysTypes"
:key="type.value"
@click="handleSwitch(type.value)"
>
{{ type.label }}
</div>
</div>
</template>
<script>
export default {
props: {
daysTypes: {
type: Array,
default: () => [
{ label: '全部', value: 0 },
{ label: '近30天', value: 30 }
]
}
},
data() {
return {
daysType: 0
}
},
methods: {
handleSwitch(val) {
this.daysType = val
this.$emit('change', val)
}
}
}
</script>
<style lang="less" scoped>
.days-switch {
width: 100px;
padding: 1px;
display: flex;
border: 1px solid #4794a4;
border-radius: 2px;
div {
width: 50px;
height: 20px;
line-height: 20px;
text-align: center;
font-size: 12px;
border-radius: 4px;
cursor: pointer;
&.checked {
color: #000;
background-color: #6ee4f0;
}
}
}
</style>

View File

@ -1,6 +1,7 @@
<template> <template>
<div class="question-type"> <div class="question-type">
<div class="title">{{ title }}</div> <div class="title">{{ title }}</div>
<DaysSwitch class="days-switch" @change="handleSwitch" />
<div class="content"> <div class="content">
<JProgressChart :seriesData="seriesData" :yData="yData" /> <JProgressChart :seriesData="seriesData" :yData="yData" />
</div> </div>
@ -9,9 +10,10 @@
<script> <script>
import JProgressChart from '../jChart/bar/JProgressChart.vue' import JProgressChart from '../jChart/bar/JProgressChart.vue'
import DaysSwitch from './components/DaysSwitch.vue'
import { selectDangerTypeQualityCountApi } from '@/assets/js/api/dataBoard' import { selectDangerTypeQualityCountApi } from '@/assets/js/api/dataBoard'
export default { export default {
components: { JProgressChart }, components: { JProgressChart, DaysSwitch },
props: { props: {
title: { title: {
type: String, type: String,
@ -20,35 +22,34 @@ export default {
}, },
data() { data() {
return { return {
yData: ['地理老师', '地理老师', '地理老师', '地理老师', '地理老师', '地理老师', '地理老师', '地理老师', '地理老师', '地理老师'], yData: [],
seriesData: [100, 235, 232, 532, 112, 532, 449, 269, 998, 33] seriesData: [100, 235, 232, 532, 112, 532, 449, 269, 998, 33]
} }
}, },
mounted(){ mounted() {
this.getData(2); this.getData(2)
}, },
methods:{ methods: {
getData(opType){ getData(opType) {
let data = { let data = {
projectSn: this.$store.state.projectSn, projectSn: this.$store.state.projectSn,
opType: opType opType: opType
} }
selectDangerTypeQualityCountApi(data).then(res => { selectDangerTypeQualityCountApi(data).then(res => {
console.log('-----------',res)
var arr = res.result.list var arr = res.result.list
var xdata = [] var xdata = []
var ydata=[] var ydata = []
arr.forEach(item => { arr.forEach(item => {
xdata.push(item.dangerName) xdata.push(item.dangerName)
ydata.push(item.num) ydata.push(item.num)
}) })
this.yData = xdata this.yData = xdata
this.seriesData = ydata this.seriesData = ydata
console.log('xdata',this.yData)
console.log('ydata',this.seriesData)
}) })
},
handleSwitch(val) {
console.log(val, 'hello')
} }
} }
} }
</script> </script>
@ -65,8 +66,13 @@ export default {
font-size: 18px; font-size: 18px;
color: #6ee4f0; color: #6ee4f0;
} }
.days-switch {
margin-top: 10px;
margin-right: 20px;
margin-left: auto;
}
.content { .content {
height: calc(100% - 30px); height: calc(100% - 64px);
} }
} }
</style> </style>