123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274 |
- <template>
- <moduleEnclosure title="近30天工单趋势">
- <template v-slot:rightce>
- <el-tabs v-model="tabCurrent" type="card" @tab-click="changeTab">
- <el-tab-pane v-for="(item, index) in tabList" :key="index" :label="item" :name="item"></el-tab-pane>
- </el-tabs>
-
- </template>
- <div class="all-container">
- <div id="workorderEcharts1" style="width: 100%; height: 100%"></div>
- </div>
- </moduleEnclosure>
- </template>
- <script>
- import vScrollView from 'v-scroll-view'
- import moduleEnclosure from '@/components/moduleEnclosure.vue';
- import * as echarts from 'echarts';
- import { getWorkorderTrend } from '@/api/bigView.js';
- import { csize } from '@/utils/const.js';
- export default {
- components: {
- moduleEnclosure,
- vScrollView
- },
- data() {
- return {
- tabList: [],
- tabCurrent: '',
- tableData: [],
- };
- },
- mounted() {
- this.dingshishuaxin()
- },
- beforeUnmount() {
- this.mouseenter();
- },
- watch: {
- tabCurrent() {
- this.mouseenter();
- this.dingshishuaxin()
- }
- },
- methods: {
- mouseenter() {
- if (this.TimeId) {
- clearTimeout(this.TimeId)
- }
- },
- dingshishuaxin() {
- this.initData();
- this.TimeId = setTimeout(() => {
- this.setbiuaoji()
- }, 3000)
- },
- getDate() {
- const today = new Date();
- const dates = [];
- for (let i = 0; i < 30; i++) {
- const d = new Date();
- d.setDate(today.getDate() - i);
- dates.unshift(d.toISOString().split('T')[0].slice(5, 11));
- }
- return dates;
- },
- setbiuaoji() {
- var index = this.tabList.indexOf(this.tabCurrent)
- if (index >= (this.tabList.length - 1)) {
- this.tabCurrent = this.tabList[0]
- } else {
- this.tabCurrent = this.tabList[index + 1]
- }
- },
- changeTab(item) {
- this.tabCurrent = item.name;
- this.initEcharts();
- },
- initData() {
- getWorkorderTrend().then(res => {
- this.tabList = res.data.map(o => o.lx);
- if (this.tabCurrent == "") {
- this.setbiuaoji()
- }
- this.tableData = res.data;
- this.initEcharts();
- })
- },
- initEcharts() {
- var chartDom = document.getElementById('workorderEcharts1');
- var myChart = echarts.init(chartDom);
- var option;
- option = {
- title: {
- text: ''
- },
- tooltip: {
- confine: true,
- trigger: 'axis',
- transitionDuration: 0,
- backgroundColor: '#092a66',
- borderColor: '#0462b5',
- borderRadius: 8,
- borderWidth: 2,
- padding: [5, 10],
- axisPointer: {
- type: 'line',
- lineStyle: {
- type: 'dashed',
- color: '#8AB1DC',
- },
- },
- textStyle: {
- color: '#ffffff'
- }
- },
- legend: {
- icon: 'circle',
- itemWidth: 8,
- itemHeight: 8,
- itemGap: 10,
- top: '16',
- right: '10',
- data: ['已完工', '未完工'],
- textStyle: {
- color: '#A9BBCC'
- },
- },
- // grid: {
- // left: '3%',
- // right: '4%',
- // bottom: '3%',
- // containLabel: true
- // },
- toolbox: {
- // feature: {
- // saveAsImage: {}
- // }
- },
- grid: {
- x: csize(40),
- y: csize(50),
- x2: csize(20),
- y2: csize(20),
- },
- xAxis: {
- type: 'category',
- boundaryGap: false,
- axisLabel: {
- fontSize: csize(12),
- },
- axisLine: {
- lineStyle: {
- color: '#8AB1DC', // x轴文字颜色
- }
- },
- splitLine: {
- show: true,
- lineStyle: {
- color: '#364D95', // x轴辅助线颜色
- }
- },
- data: this.getDate()
- },
- yAxis: {
- type: 'value',
- name: "(单/台)",
- nameTextStyle: {
- color: "#aaa",
- nameLocation: "start",
- // align: 'right'
- },
- axisLabel: {
- fontSize: csize(12),
- },
- axisLine: {
- lineStyle: {
- color: '#8AB1DC', // y轴文字颜色
- }
- },
- splitLine: {
- show: true,
- lineStyle: {
- color: '#364D95', // y轴辅助线颜色
- }
- }
- },
- series: [
- {
- name: '已完工',
- type: 'line',
- stack: 'Total',
- itemStyle: {
- normal: {
- color: '#44E28F',
- },
- },
- data: this.tableData.find(o => o.lx == this.tabCurrent).unitNum
- },
- {
- name: '未完工',
- type: 'line',
- stack: 'Total',
- itemStyle: {
- normal: {
- color: '#D73A79',
- },
- },
- data: this.tableData.find(o => o.lx == this.tabCurrent).unitNumWwg
- },
- ]
- };
- option && myChart.setOption(option);
- }
- },
- };
- </script>
- <style scoped lang="scss">
- ::v-deep .el-tabs {
- width: 100%;
- .el-tabs__header {
- margin-bottom: 0;
- border-bottom: none;
- }
- .el-tabs__nav {
- border: none;
- }
- .el-tabs__nav-prev {
- line-height: 30px;
- }
- .el-tabs__nav-next {
- line-height: 30px;
- }
- .el-tabs__item {
- width: 50px;
- height: 30px;
- line-height: 30px;
- color: #ffffff;
- border: 1px solid #254280 !important;
- font-size: 12px;
- font-weight: bold;
- margin-right: 10px;
- padding: 0 !important;
- text-align: center;
- &:last-child {
- margin-right: 0;
- }
- &.is-active {
- border: 1px solid #153781 !important;
- color: #1a8dc8;
- }
- }
- }
- .all-container {
- width: 100%;
- height: 100%;
- box-sizing: border-box;
- padding-top: 16px;
- }
- </style>
|