| | |
| | | <template> |
| | | <!-- <BaseCard> --> |
| | | <el-row> å·¡æ¥æ±æ» </el-row> |
| | | <el-segmented v-model="value" :options="options" block /> |
| | | <div><el-text tag="i"> è¯ä¼° </el-text></div> |
| | | <el-row justify="space-evenly"> |
| | | <div> |
| | | <el-statistic title="æ»è®¡" :value="10"> </el-statistic> |
| | | <div class="statistic-footer"> |
| | | <div class="footer-item"> |
| | | <span>å¯¹æ¯æ¨æ¥</span> |
| | | <span class="green"> |
| | | 24% |
| | | <el-icon> |
| | | <CaretTop /> |
| | | </el-icon> |
| | | </span> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | <el-statistic title="é«é£é©" :value="2" :value-style="styleRed"> </el-statistic> |
| | | <el-statistic title="ä¸é£é©" :value="6" :value-style="styleYellow"> </el-statistic> |
| | | <el-statistic title="ä½é£é©" :value="2" :value-style="styleGreen"> </el-statistic> |
| | | </el-row> |
| | | <div><el-text tag="i"> 夿 ¸ </el-text></div> |
| | | <el-row justify="space-evenly"> |
| | | <div> |
| | | <el-statistic title="é夿 ¸" :value="2"> </el-statistic> |
| | | <div class="statistic-footer"> |
| | | <div class="footer-item"> |
| | | <span>å¯¹æ¯æ¨æ¥</span> |
| | | <span class="green"> |
| | | 24% |
| | | <el-icon> |
| | | <CaretTop /> |
| | | </el-icon> |
| | | </span> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | <el-statistic title="已宿" :value="2" :value-style="styleGreen"> </el-statistic> |
| | | </el-row> |
| | | <div><el-text tag="i"> é®é¢ </el-text></div> |
| | | <el-row justify="space-evenly"> |
| | | <div> |
| | | <el-statistic title="æ»è®¡" :value="10"> </el-statistic> |
| | | <div class="statistic-footer"> |
| | | <div class="footer-item"> |
| | | <span>å¯¹æ¯æ¨æ¥</span> |
| | | <span class="green"> |
| | | 24% |
| | | <el-icon> |
| | | <CaretTop /> |
| | | </el-icon> |
| | | </span> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | <el-statistic title="å¾
å®¡æ ¸" :value="2" :value-style="styleRed"> </el-statistic> |
| | | <el-statistic title="å·²å®¡æ ¸" :value="6" :value-style="styleYellow"> </el-statistic> |
| | | <el-statistic title="å¾
æ´æ¹" :value="2" :value-style="styleGreen"> </el-statistic> |
| | | <el-statistic title="å·²æ´æ¹" :value="2" :value-style="styleGreen"> </el-statistic> |
| | | <el-statistic title="å¾
确认" :value="2" :value-style="styleGreen"> </el-statistic> |
| | | </el-row> |
| | | <!-- </BaseCard> --> |
| | | <div v-show="value == '仿¥æ±æ»'"> |
| | | <div ref="echart1" class="bar-chart"></div> |
| | | </div> |
| | | <div v-show="value == 'æ¬å¨æ±æ»'"> |
| | | <div ref="echart2" class="bar-chart"></div> |
| | | </div> |
| | | <div v-show="value == 'ä¸å¨æ±æ»'"> |
| | | <div ref="echart3" class="bar-chart"></div> |
| | | </div> |
| | | <div v-show="value == 'æåº¦æ±æ»'"> |
| | | <div ref="echart4" class="bar-chart"></div> |
| | | </div> |
| | | </template> |
| | | |
| | | <script setup> |
| | | import { ref } from 'vue' |
| | | import * as echarts from 'echarts' |
| | | import { ref, onMounted } from 'vue' |
| | | import dayjs from 'dayjs' |
| | | import taskApi from '@/api/fysp/taskApi.js' |
| | | |
| | |
| | | |
| | | const emits = defineEmits(['update:height']) |
| | | |
| | | const alue = '仿¥æ±æ»' |
| | | const ptions = ['仿¥æ±æ»', 'å¨åº¦æ±æ»', 'æåº¦æ±æ»', 'å£åº¦æ±æ»', 'å¹´åº¦æ±æ»'] |
| | | const tyleRed = 'color:var(--el-color-danger);' |
| | | const tyleYellow = 'color:var(--el-color-warning);' |
| | | const tyleGreen = 'color:var(--el-color-success);' |
| | | const value = ref('æåº¦æ±æ»') |
| | | const options = ['仿¥æ±æ»', 'æ¬å¨æ±æ»', 'ä¸å¨æ±æ»', 'æåº¦æ±æ»'] |
| | | |
| | | function name(params) { |
| | | const subtaskToday = ref([]) |
| | | const subtaskWeek = ref([]) |
| | | const subtaskLastWeek = ref([]) |
| | | const subtaskMonth = ref([]) |
| | | |
| | | const echart1 = ref() |
| | | const echart2 = ref() |
| | | const echart3 = ref() |
| | | const echart4 = ref() |
| | | let echartToday |
| | | let echartWeek |
| | | let echartLastWeek |
| | | let echartMonth |
| | | |
| | | function getParams(type) { |
| | | const d = dayjs() |
| | | const area = { |
| | | starttime: d.startOf('day').format('YYYY-MM-DD HH:mm:ss'), |
| | | return { |
| | | starttime: d.startOf(type).format('YYYY-MM-DD HH:mm:ss'), |
| | | endtime: d.endOf(type).format('YYYY-MM-DD HH:mm:ss') |
| | | } |
| | | } |
| | | |
| | | taskApi.fetchSubtaskSummaryByArea(this.area).then((res) => { |
| | | this.subtaskList = res.data |
| | | function fetchSubtaskToday() { |
| | | const area = getParams('day') |
| | | taskApi.fetchSubtaskSummaryByArea(area).then((res) => { |
| | | subtaskToday.value = res.data |
| | | const series = refreshChartData(res.data) |
| | | setOption(echartToday, series) |
| | | }) |
| | | } |
| | | |
| | | function fetchSubtaskThisWeek() { |
| | | const area = getParams('week') |
| | | taskApi.fetchSubtaskSummaryByArea(area).then((res) => { |
| | | subtaskWeek.value = res.data |
| | | const series = refreshChartData(res.data) |
| | | setOption(echartWeek, series) |
| | | }) |
| | | } |
| | | |
| | | function fetchSubtaskLastWeek() { |
| | | const area = getParams('week') |
| | | area.starttime = dayjs(area.starttime).add(-7, 'day').format('YYYY-MM-DD HH:mm:ss') |
| | | area.endtime = dayjs(area.endtime).add(-7, 'day').format('YYYY-MM-DD HH:mm:ss') |
| | | taskApi.fetchSubtaskSummaryByArea(area).then((res) => { |
| | | subtaskLastWeek.value = res.data |
| | | const series = refreshChartData(res.data) |
| | | setOption(echartLastWeek, series) |
| | | }) |
| | | } |
| | | |
| | | function fetchSubtaskThisMonth() { |
| | | const area = getParams('month') |
| | | taskApi.fetchSubtaskSummaryByArea(area).then((res) => { |
| | | subtaskMonth.value = res.data |
| | | const series = refreshChartData(res.data) |
| | | setOption(echartMonth, series) |
| | | }) |
| | | } |
| | | |
| | | onMounted(() => { |
| | | echartToday = echarts.init(echart1.value) |
| | | echartWeek = echarts.init(echart2.value) |
| | | echartLastWeek = echarts.init(echart3.value) |
| | | echartMonth = echarts.init(echart4.value) |
| | | fetchSubtaskToday() |
| | | fetchSubtaskThisWeek() |
| | | fetchSubtaskLastWeek() |
| | | fetchSubtaskThisMonth() |
| | | }) |
| | | |
| | | /**chart**********************************************************************/ |
| | | function setOption(echart, series) { |
| | | const option = { |
| | | textStyle: { |
| | | color: 'white' |
| | | }, |
| | | legend: { |
| | | textStyle: { |
| | | color: 'white' |
| | | } |
| | | }, |
| | | tooltip: { |
| | | trigger: 'axis', |
| | | axisPointer: { |
| | | type: 'shadow' |
| | | } |
| | | }, |
| | | grid: { |
| | | left: '3%', |
| | | right: '4%', |
| | | bottom: '3%', |
| | | containLabel: true |
| | | }, |
| | | xAxis: [ |
| | | { |
| | | type: 'value' |
| | | } |
| | | ], |
| | | yAxis: [ |
| | | { |
| | | type: 'category', |
| | | data: ['æ´æ¹æ°', 'é®é¢æ°', '宿é'] |
| | | } |
| | | ], |
| | | series: series |
| | | } |
| | | echart.setOption(option) |
| | | } |
| | | |
| | | function refreshChartData(dataList) { |
| | | // ä»»å¡éãé®é¢æ°ãæ´æ¹æ° |
| | | // ä»»å¡é |
| | | const totalCount = { |
| | | numByTotal: {}, |
| | | numByDistrict: {}, |
| | | numByScene: {}, |
| | | numByUser: {} |
| | | } |
| | | // é®é¢æ° |
| | | const proCount = { |
| | | numByTotal: {}, |
| | | numByDistrict: {}, |
| | | numByScene: {}, |
| | | numByUser: {} |
| | | } |
| | | // æ´æ¹æ° |
| | | const changeCount = { |
| | | numByTotal: {}, |
| | | numByDistrict: {}, |
| | | numByScene: {}, |
| | | numByUser: {} |
| | | } |
| | | // // æç¨æ·åç±» |
| | | // const userCount = { |
| | | // numByTotal: {}, |
| | | // numByDistrict: {}, |
| | | // numByScene: {}, |
| | | // numByUser: {} |
| | | // } |
| | | dataList.forEach((d) => { |
| | | const tName = 'æ»è®¡' |
| | | const dName = d.subtask.districtname |
| | | const sType = d.sceneType |
| | | const uName = d.subtask.deployerrealname |
| | | |
| | | // ä»»å¡éæ»è®¡ |
| | | totalCount.numByTotal[tName] = totalCount.numByTotal[tName] |
| | | ? totalCount.numByTotal[tName] + 1 |
| | | : 1 |
| | | // ä»»å¡éååºå¿ |
| | | totalCount.numByDistrict[dName] = totalCount.numByDistrict[dName] |
| | | ? totalCount.numByDistrict[dName] + 1 |
| | | : 1 |
| | | // ä»»å¡éååºæ¯ç±»å |
| | | totalCount.numByScene[sType] = totalCount.numByScene[sType] |
| | | ? totalCount.numByScene[sType] + 1 |
| | | : 1 |
| | | // ä»»å¡éåç¨æ· |
| | | totalCount.numByUser[uName] = totalCount.numByUser[uName] ? totalCount.numByUser[uName] + 1 : 1 |
| | | |
| | | // é®é¢æ°æ»è®¡ |
| | | proCount.numByTotal[tName] = proCount.numByTotal[tName] |
| | | ? proCount.numByTotal[tName] + d.proCheckedNum |
| | | : d.proCheckedNum |
| | | // é®é¢æ°ååºå¿ |
| | | proCount.numByDistrict[dName] = proCount.numByDistrict[dName] |
| | | ? proCount.numByDistrict[dName] + d.proCheckedNum |
| | | : d.proCheckedNum |
| | | // é®é¢æ°ååºæ¯ç±»å |
| | | proCount.numByScene[sType] = proCount.numByScene[sType] |
| | | ? proCount.numByScene[sType] + d.proCheckedNum |
| | | : d.proCheckedNum |
| | | // é®é¢æ°åç¨æ· |
| | | proCount.numByUser[uName] = proCount.numByUser[uName] |
| | | ? proCount.numByUser[uName] + d.proCheckedNum |
| | | : d.proCheckedNum |
| | | |
| | | // æ´æ¹æ°æ»è®¡ |
| | | changeCount.numByTotal[tName] = changeCount.numByTotal[tName] |
| | | ? changeCount.numByTotal[tName] + d.changeCheckedNum |
| | | : d.changeCheckedNum |
| | | // æ´æ¹æ°ååºå¿ |
| | | changeCount.numByDistrict[dName] = changeCount.numByDistrict[dName] |
| | | ? changeCount.numByDistrict[dName] + d.changeCheckedNum |
| | | : d.changeCheckedNum |
| | | // æ´æ¹æ°ååºæ¯ç±»å |
| | | changeCount.numByScene[sType] = changeCount.numByScene[sType] |
| | | ? changeCount.numByScene[sType] + d.changeCheckedNum |
| | | : d.changeCheckedNum |
| | | // æ´æ¹æ°åç¨æ· |
| | | changeCount.numByUser[uName] = changeCount.numByUser[uName] |
| | | ? changeCount.numByUser[uName] + d.changeCheckedNum |
| | | : d.changeCheckedNum |
| | | }) |
| | | |
| | | let series = {} |
| | | totalCount |
| | | proCount |
| | | changeCount |
| | | parseSeries(series, changeCount) |
| | | parseSeries(series, proCount) |
| | | parseSeries(series, totalCount) |
| | | |
| | | const res = [] |
| | | for (const key in series) { |
| | | const e = series[key] |
| | | res.push(e) |
| | | } |
| | | |
| | | return res |
| | | } |
| | | |
| | | function parseSeries(series, c) { |
| | | // c.numByTotal |
| | | // c.numByDistrict |
| | | // c.numByScene |
| | | // c.numByUser |
| | | |
| | | for (const key in c.numByTotal) { |
| | | const value = c.numByTotal[key] |
| | | if (series[key]) { |
| | | series[key].data.push(value) |
| | | } else { |
| | | series[key] = { |
| | | name: key, |
| | | type: 'bar', |
| | | emphasis: { |
| | | focus: 'series' |
| | | }, |
| | | label: { |
| | | show: true, |
| | | formatter: '{c}' |
| | | // position: [0, 10], |
| | | }, |
| | | data: [value] |
| | | } |
| | | } |
| | | } |
| | | for (const key in c.numByDistrict) { |
| | | const value = c.numByDistrict[key] |
| | | if (series[key]) { |
| | | series[key].data.push(value) |
| | | } else { |
| | | series[key] = { |
| | | name: `åºå¿ï¼${key}`, |
| | | type: 'bar', |
| | | stack: 'district', |
| | | emphasis: { |
| | | focus: 'series' |
| | | }, |
| | | label: { |
| | | show: true, |
| | | formatter: '{c}' |
| | | // position: [0, 10], |
| | | }, |
| | | data: [value] |
| | | } |
| | | } |
| | | } |
| | | for (const key in c.numByScene) { |
| | | const value = c.numByScene[key] |
| | | if (series[key]) { |
| | | series[key].data.push(value) |
| | | } else { |
| | | series[key] = { |
| | | name: `åºæ¯ï¼${key}`, |
| | | type: 'bar', |
| | | stack: 'scene', |
| | | emphasis: { |
| | | focus: 'series' |
| | | }, |
| | | label: { |
| | | show: true, |
| | | formatter: '{c}' |
| | | // position: [0, 10], |
| | | }, |
| | | data: [value] |
| | | } |
| | | } |
| | | } |
| | | for (const key in c.numByUser) { |
| | | const value = c.numByUser[key] |
| | | if (series[key]) { |
| | | series[key].data.push(value) |
| | | } else { |
| | | series[key] = { |
| | | name: `ç¨æ·ï¼${key}`, |
| | | type: 'bar', |
| | | stack: 'user', |
| | | emphasis: { |
| | | focus: 'series' |
| | | }, |
| | | label: { |
| | | show: true, |
| | | formatter: '{c}' |
| | | // position: [0, 10], |
| | | }, |
| | | data: [value] |
| | | } |
| | | } |
| | | } |
| | | return series |
| | | } |
| | | </script> |
| | | |
| | |
| | | .red { |
| | | color: var(--el-color-error); |
| | | } |
| | | |
| | | .bar-chart { |
| | | width: 400px; |
| | | height: 600px; |
| | | } |
| | | </style> |