src/views/dashboard/IndexSignage.vue
@@ -15,39 +15,11 @@
            <div id="warranty_malfunction_chart" style="width:50%;height: 340px;"></div>
          </div>
          <div class="support-plan-container">
            <!--<div v-for="item in supportPlanList" class="support-plan-item"-->
            <!--:style="{background:item.background}">-->
            <!--<div>{{item.label}}</div>-->
            <!--<div class="plan-value-container">-->
            <!--<div class="plan-value">{{item.value}}</div>-->
            <!--<div>台</div>-->
            <!--</div>-->
            <!--</div>-->
            <div class="support-plan-item" style="background:#5FE0AF">
              <div>本月三保计划</div>
            <div v-for="(item,index) in supportPlanList" :key="index" class="support-plan-item"
                 :style="{background:item.backgroundColor}" @click="openMaintenanceModal(item)">
              <div>{{item.planTime}}</div>
              <div class="plan-value-container">
                <div class="plan-value">{{thisMonthMaintenancePlanNum}}</div>
                <div>台</div>
              </div>
            </div>
            <div class="support-plan-item" style="background:#409EFF">
              <div>本月完成</div>
              <div class="plan-value-container">
                <div class="plan-value">{{thisMonthMaintenanceRealNum}}</div>
                <div>台</div>
              </div>
            </div>
            <div class="support-plan-item" style="background:#D6BC52">
              <div>下月三保计划</div>
              <div class="plan-value-container">
                <div class="plan-value">{{nextMonthMaintenancePlanNum}}</div>
                <div>台</div>
              </div>
            </div>
            <div class="support-plan-item" style="background:#58D9F9">
              <div>下下月三保计划</div>
              <div class="plan-value-container">
                <div class="plan-value">{{nextNextMonthMaintenancePlanNum}}</div>
                <div class="plan-value">{{$data[item.planValueLabel]}}</div>
                <div>台</div>
              </div>
            </div>
@@ -68,15 +40,21 @@
        </dv-border-box-9>
      </div>
    </div>
    <SignageModal :modalVisible="modalVisible" :modalTitle=modalTitle :modalDataApiUrl="modalDataApiUrl"
                  :modalTableColumns="modalTableColumns"
                  @closeModal="modalVisible=false"/>
  </div>
</template>
<script>
  import signageApi from '@/api/signage'
  import moment from 'moment'
  import SignageModal from './modules/SignageModal'
  export default {
    name: 'IndexSignage',
    components: { SignageModal },
    data() {
      return {
        runningStateChart: '',
@@ -100,54 +78,56 @@
          { value: '10', name: '停机' },
          { value: '8', name: '运行' }
        ],
        supportPlanList: [
          {
            planTime: '本月三保计划',
            planValueLabel: 'thisMonthMaintenancePlanNum',
            backgroundColor: '#5FE0AF'
          },
          {
            planTime: '本月完成',
            planValueLabel: 'thisMonthMaintenanceRealNum',
            backgroundColor: '#409EFF'
          },
          {
            planTime: '下月三保计划',
            planValueLabel: 'nextMonthMaintenancePlanNum',
            backgroundColor: '#D6BC52'
          },
          {
            planTime: '下下月三保计划',
            planValueLabel: 'nextNextMonthMaintenancePlanNum',
            backgroundColor: '#58D9F9'
          }
        ],
        thisMonthMaintenancePlanNum: 0,
        thisMonthMaintenanceRealNum: 0,
        nextMonthMaintenancePlanNum: 0,
        nextNextMonthMaintenancePlanNum: 0,
        twoMaintenanceChartData: [['-', '-', '-']],
        barChart: '',
        barChartData: [
          {
            'value': '32',
            'name': '401',
            'productionCode': '125487318',
            'productionId': '1729419336207761409'
          },
          {
            'value': '23',
            'name': '406',
            'productionCode': '4212152142',
            'productionId': '1729419361201618945'
          },
          {
            'value': '11',
            'name': '407',
            'productionCode': '321321345',
            'productionId': '1729419381665628161'
          },
          {
            'value': '44',
            'name': '408',
            'productionCode': '536341343',
            'productionId': '1729670118396067842'
          }
        ],
        barChartData: [],
        doubleBarChart: '',
        doubleBarChartData: {},
        workshopProblemChartData: [['-', '-', '-']],
        efficiencyChartConfig: {},
        maintenanceConfig: {},
        problemConfig: {}
        problemConfig: {},
        modalVisible: false,
        modalTitle: '',
        modalDataApiUrl: '',
        modalTableColumns: []
      }
    },
    mounted() {
      window.addEventListener('resize', this.handleWindowResize)
      this.drawCharts()
      this.getChartDataByApi()
    },
    beforeDestroy() {
      window.removeEventListener('resize', this.handleWindowResize)
    },
    methods: {
      /* 调用接口获取图表数据汇总方法 */
      getChartDataByApi() {
        this.getRunningStateDataByApi()
        this.getEfficiencyDataByApi()
@@ -155,21 +135,36 @@
        this.getWarrantyMalfunctionDataByApi()
        this.getMonthMaintenanceNumByApi()
        this.getTwoMaintenanceChartDataByApi()
        // this.getBarChartDataByApi()
        this.getBarChartDataByApi()
        this.getDoubleBarChartDataByApi()
        this.getWorkshopProblemChartDataByApi()
      },
      /* 调用接口获取设备运行状态 */
      getRunningStateDataByApi() {
        this.runningStateChart = this.$echarts.init(document.getElementById('running_state_chart'))
        this.runningStateChart.showLoading({
          text: '数据加载中 ...',
          color: '#0696e1', // 加载动画颜色
          textColor: '#fff',
          maskColor: 'rgba(1, 25, 75, 0.2)' // 遮罩层
        })
        signageApi.getEquipmentStatusStatisticsApi()
          .then(res => {
            if (res.success) this.runningStateData = res.result.list
            this.drawRunningStateChart(res.result.producitonId)
            this.drawRunningStateChart(res.result.productionId)
          })
      },
      /* 调用接口获取设备利用率 */
      getEfficiencyDataByApi() {
        this.efficiencyChart = this.$echarts.init(document.getElementById('efficiency_chart'))
        this.efficiencyChart.showLoading({
          text: '数据加载中 ...',
          color: '#0696e1', // 加载动画颜色
          textColor: '#fff',
          maskColor: 'rgba(1, 25, 75, 0.2)' // 遮罩层
        })
        signageApi.getEquipmentUtilizationStatisticsApi()
          .then(res => {
            if (res.success) this.efficiencyData = res.result
@@ -179,9 +174,16 @@
      /* 调用接口获取技术状态 */
      getTechConditionDataByApi() {
        this.techConditionChart = this.$echarts.init(document.getElementById('tech_condition_chart'))
        this.techConditionChart.showLoading({
          text: '数据加载中 ...',
          color: '#0696e1', // 加载动画颜色
          textColor: '#fff',
          maskColor: 'rgba(1, 25, 75, 0.2)' // 遮罩层
        })
        signageApi.getEquipmentTechnologyStatusListApi()
          .then(res => {
            if (res.success) {
            if (res.success && res.result) {
              this.techConditionData = [
                { value: res.result[0].qualifiedCount, name: '合格' },
                { value: res.result[0].disabledCount, name: '禁用' },
@@ -194,9 +196,16 @@
      /* 调用接口获取设备报修故障 */
      getWarrantyMalfunctionDataByApi() {
        this.warrantyMalfunctionChart = this.$echarts.init(document.getElementById('warranty_malfunction_chart'))
        this.warrantyMalfunctionChart.showLoading({
          text: '数据加载中 ...',
          color: '#0696e1', // 加载动画颜色
          textColor: '#fff',
          maskColor: 'rgba(1, 25, 75, 0.2)' // 遮罩层
        })
        signageApi.getReportRepairEquipmentListApi()
          .then(res => {
            if (res.success) {
            if (res.success && res.result) {
              this.warrantyMalfunctionData = [
                { value: res.result[0].failurTotalCount, name: '报修' },
                { value: res.result[0].stopCount, name: '停机' },
@@ -231,13 +240,20 @@
      getTwoMaintenanceChartDataByApi() {
        signageApi.getTwoMaintenancePlanListApi()
          .then(res => {
            if (res.success && res.result) this.twoMaintenanceChartData = res.result.map(item => [item.centerName, item.maintenanceDate, item.content])
            if (res.success && res.result.length > 0) this.twoMaintenanceChartData = res.result.map(item => [item.centerName, item.maintenanceDate, item.content])
            this.drawMaintenanceChart()
          })
      },
      /* 调用接口获取设备OEE统计 */
      getBarChartDataByApi() {
        this.barChart = this.$echarts.init(document.getElementById('bar_chart'))
        this.barChart.showLoading({
          text: '数据加载中 ...',
          color: '#0696e1', // 加载动画颜色
          textColor: '#fff',
          maskColor: 'rgba(1, 25, 75, 0.2)' // 遮罩层
        })
        signageApi.getEquipmentOEEStatistics()
          .then(res => {
            if (res.success) this.barChartData = res.result
@@ -247,6 +263,13 @@
      /* 调用接口获取设备OEE和利用率对比 */
      getDoubleBarChartDataByApi() {
        this.doubleBarChart = this.$echarts.init(document.getElementById('double_bar_chart'))
        this.doubleBarChart.showLoading({
          text: '数据加载中 ...',
          color: '#0696e1', // 加载动画颜色
          textColor: '#fff',
          maskColor: 'rgba(1, 25, 75, 0.2)' // 遮罩层
        })
        signageApi.getEquipmentMonthStatisticsApi()
          .then(res => {
            if (res.success) this.doubleBarChartData = res.result
@@ -254,21 +277,18 @@
          })
      },
      /* 绘制图表汇总方法 */
      drawCharts() {
        this.drawRunningStateChart()
        this.drawEfficiencyChart()
        this.drawTechConditionChart()
        this.drawWarrantyMalfunctionChart()
        this.drawMaintenanceChart()
        this.drawBarChart()
        this.drawDoubleBarChart()
        this.drawProblemChart()
      /* 调用接口获取车间问题列表*/
      getWorkshopProblemChartDataByApi() {
        signageApi.getWorkshopProblemListApi()
          .then(res => {
            console.log('res', res.result)
            if (res.success && res.result.length > 0) this.workshopProblemChartData = res.result.map(item => [item.content, item.createTime])
            this.drawWorkshopProblemChart()
          })
      },
      /* 绘制设备运行状态玫瑰饼图 */
      drawRunningStateChart(productionId) {
        this.runningStateChart = this.$echarts.init(document.getElementById('running_state_chart'))
        const option = {
          height: 300,
          title: {
@@ -346,6 +366,7 @@
          ]
        }
        this.runningStateChart.setOption(option, true)
        this.runningStateChart.hideLoading()
        this.runningStateChart.on('click', params => {
          this.$router.push({
@@ -357,7 +378,6 @@
      /* 绘制设备利用率胶囊图 */
      drawEfficiencyChart() {
        this.efficiencyChart = this.$echarts.init(document.getElementById('efficiency_chart'))
        const data = this.efficiencyData
        const colorArray = [
          {
@@ -388,7 +408,13 @@
            bottom: '#F7B7A0'
          }
        ]
        const defaultData = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100]
        const defaultData = []
        const dataMax = +data.sort((x, y) => +y.value - +x.value)[0].value
        let yAxisMax
        if (dataMax === 0) yAxisMax = 1 // 若数据中最大值为0,则将背景默认值设置为1
        else yAxisMax = Math.ceil(dataMax / 5) * 5 // 设置柱图背景阴影默认值,思路为数据最大值最接近的能被5整除的数字
        const yAxisInterval = yAxisMax / 5 // 同时将刻度值分成5份
        data.forEach(item => defaultData.push(yAxisMax))
        const option = {
          title: {
            show: true, // 是否显示标题,默认为true
@@ -420,7 +446,7 @@
            }
          },
          xAxis: {
            name: '单位',
            name: '',
            nameTextStyle: {
              color: '#fff'
            },
@@ -431,6 +457,9 @@
              }
            },
            show: true,
            min: 0,
            max: 'dataMax',
            interval: yAxisInterval,
            type: 'value',
            axisTick: {
              show: false
@@ -544,9 +573,9 @@
            }
          ]
        }
        option.title.text = `${moment().format('M月D日')}利用率`
        option.title.text = `${moment().subtract(1, 'days').format('M月D日')}利用率`
        this.efficiencyChart.setOption(option, true)
        this.efficiencyChart.hideLoading()
        this.efficiencyChart.on('click', params => {
          // 点击触发的为柱状体,除此除外是标题
          if (params.componentType === 'series') {
@@ -576,7 +605,6 @@
      /* 绘制技术状态饼图 */
      drawTechConditionChart() {
        this.techConditionChart = this.$echarts.init(document.getElementById('tech_condition_chart'))
        const option = {
          height: 300,
          title: {
@@ -625,7 +653,7 @@
              center: ['45%', '60%'],
              color: [
                '#0FC61A',
                '#0DAF15',
                '#F56436',
                '#8B8B8B'
              ],
              label: {
@@ -651,11 +679,55 @@
          ]
        }
        this.techConditionChart.setOption(option, true)
        this.techConditionChart.hideLoading()
        // this.techConditionChart.on('click', params => {
        //   console.log('params', params)
        //   this.modalTitle = '技术状态'
        //   this.modalTableColumns = [
        //     {
        //       title: '#',
        //       dataIndex: '',
        //       key: 'rowIndex',
        //       width: 60,
        //       align: 'center',
        //       customRender: function(t, r, index) {
        //         return parseInt(index) + 1
        //       }
        //     },
        //     {
        //       title: '设备编号',
        //       dataIndex: 'equipmentId',
        //       key: 'equipmentId'
        //     },
        //     {
        //       title: '设备名称',
        //       dataIndex: 'equipmentName',
        //       key: 'equipmentName'
        //     },
        //     {
        //       title: '设备型号',
        //       dataIndex: 'equipmentModel',
        //       key: 'equipmentModel'
        //     },
        //     {
        //       title: '设备类型',
        //       key: 'equipmentType',
        //       dataIndex: 'equipmentType'
        //     },
        //     {
        //       title: '驱动类型',
        //       key: 'driveType',
        //       dataIndex: 'driveType'
        //     }
        //   ]
        //   this.modalDataApiUrl = '/mdc/mdcEquipment/list'
        //   this.modalVisible = true
        // })
      },
      /* 绘制设备报修故障饼图 */
      drawWarrantyMalfunctionChart() {
        this.warrantyMalfunctionChart = this.$echarts.init(document.getElementById('warranty_malfunction_chart'))
        const option = {
          height: 300,
          title: {
@@ -730,6 +802,46 @@
          ]
        }
        this.warrantyMalfunctionChart.setOption(option, true)
        this.warrantyMalfunctionChart.hideLoading()
        // this.warrantyMalfunctionChart.on('click', params => {
        //   console.log('params', params)
        //   this.modalTitle = '报修故障'
        //   this.modalTableColumns = [
        //     {
        //       title: '#',
        //       dataIndex: '',
        //       key: 'rowIndex',
        //       width: 60,
        //       align: 'center',
        //       customRender: function(t, r, index) {
        //         return parseInt(index) + 1
        //       }
        //     },
        //     {
        //       title: '类型',
        //       align: 'center',
        //       dataIndex: 'planCloseType'
        //     },
        //     {
        //       title: '时间类型',
        //       align: 'center',
        //       dataIndex: 'planCloseTimeType'
        //     },
        //     {
        //       title: '时长(分钟)',
        //       align: 'center',
        //       dataIndex: 'planCloseTimeLong'
        //     },
        //     {
        //       title: '备注',
        //       align: 'center',
        //       dataIndex: 'remark'
        //     }
        //   ]
        //   this.modalDataApiUrl = '/mdc/mdcPlanClose/list'
        //   this.modalVisible = true
        // })
      },
      /* 绘制车间保养滚动表 */
@@ -742,15 +854,20 @@
          evenRowBGC: '#295562',
          data: this.twoMaintenanceChartData,
          index: true,
          columnWidth: [100],
          columnWidth: [100, 300, 300, 300],
          align: ['center', 'center', 'center', 'center']
        }
      },
      /* 绘制单柱图 */
      drawBarChart() {
        this.barChart = this.$echarts.init(document.getElementById('bar_chart'))
        const defaultData = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100]
        const defaultData = []
        const dataMax = +this.barChartData.sort((x, y) => +y.value - +x.value)[0].value
        let yAxisMax
        if (dataMax === 0) yAxisMax = 1 // 若数据中最大值为0,则将背景默认值设置为1
        else yAxisMax = Math.ceil(dataMax / 5) * 5 // 设置柱图背景阴影默认值,思路为数据最大值最接近的能被5整除的数字
        const yAxisInterval = yAxisMax / 5 // 同时将刻度值分成5份
        this.barChartData.forEach(item => defaultData.push(yAxisMax))
        const option = {
          title: {
            show: true, // 是否显示标题,默认为true
@@ -812,10 +929,12 @@
          }],
          yAxis: [{
            name: '%',
            max: 100,
            min: 0,
            max: yAxisMax,
            interval: yAxisInterval,
            axisLabel: {
              formatter: '{value}',
              color: '#e2e9ff'
              color: '#fff'
            },
            axisTick: {
              show: false
@@ -868,6 +987,7 @@
        }
        option.title.text = moment().subtract(1, 'months').format('M月') + `OEE车间`
        this.barChart.setOption(option, true)
        this.barChart.hideLoading()
        this.barChart.on('click', params => {
          console.log('params', params)
@@ -886,7 +1006,6 @@
      /* 绘制双柱图 */
      drawDoubleBarChart() {
        this.doubleBarChart = this.$echarts.init(document.getElementById('double_bar_chart'))
        const option = {
          color: ['#409EFF', '#0FC61A'],
          tooltip: {
@@ -1032,32 +1151,64 @@
          ]
        }
        this.doubleBarChart.setOption(option, true)
        this.doubleBarChart.hideLoading()
      },
      /* 绘制问题滚动表 */
      drawProblemChart() {
      drawWorkshopProblemChart() {
        this.problemConfig = {
          indexHeader: '序号',
          header: ['时间', '问题内容'],
          header: [ '问题内容', '时间'],
          headerBGC: '#86D186',
          oddRowBGC: '#7CBF7C',
          evenRowBGC: '#7CBF7C',
          data: [
            // ['2024年3月23号', '大家注意安全问题'],
            // ['2024年3月23号', '大家注意安全问题'],
            // ['2024年3月23号', '大家注意安全问题'],
            // ['2024年3月23号', '大家注意安全问题'],
            // ['2024年3月23号', '大家注意安全问题'],
            // ['2024年3月23号', '大家注意安全问题'],
            // ['2024年3月23号', '大家注意安全问题'],
            // ['2024年3月23号', '大家注意安全问题'],
            // ['2024年3月23号', '大家注意安全问题'],
            // ['2024年3月23号', '大家注意安全问题']
          ],
          data: this.workshopProblemChartData,
          index: true,
          columnWidth: [100, 300, 300],
          columnWidth: [100, 300, 150],
          align: ['center']
        }
      },
      /**
       * 点击三保展示栏后打开弹窗
       * @param record 点击当前三保信息
       */
      openMaintenanceModal(record) {
        this.modalTitle = record.planTime
        this.modalTableColumns = [
          {
            title: '#',
            dataIndex: '',
            key: 'rowIndex',
            width: 60,
            align: 'center',
            customRender: function(t, r, index) {
              return parseInt(index) + 1
            }
          },
          {
            title: '类型',
            align: 'center',
            dataIndex: 'planCloseType'
          },
          {
            title: '时间类型',
            align: 'center',
            dataIndex: 'planCloseTimeType'
          },
          {
            title: '时长(分钟)',
            align: 'center',
            dataIndex: 'planCloseTimeLong'
          },
          {
            title: '备注',
            align: 'center',
            dataIndex: 'remark'
          }
        ]
        this.modalDataApiUrl = '/mdc/mdcPlanClose/list'
        // this.modalVisible = true
      },
      /**
@@ -1105,6 +1256,7 @@
            padding: 5px 20px;
            font-size: 20px;
            margin-bottom: 10px;
            cursor: pointer;
            .plan-value-container {
              display: flex;