gaoshp
2024-06-17 18c60ace50725ec8b430cb737368f9af996fda28
src/views/mdc/components/Time.vue
@@ -1,14 +1,14 @@
<!--
 * @Date: 2024-04-18 21:52:18
 * @LastEditors: Sneed
 * @LastEditTime: 2024-04-20 20:57:47
 * @LastEditTime: 2024-06-17 22:37:51
 * @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"
                <el-button size="small" @click="statisticalMethod = item.value"
                    :type="statisticalMethod == item.value ? 'primary' : ''" v-for="item in btnList"
                    :key="item.value">{{
                        item.label }}</el-button>
@@ -26,9 +26,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>
@@ -44,6 +44,25 @@
        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: {
@@ -70,7 +89,7 @@
            ],
            cols: [],
            chartsData: [],
            option2: null,
            option2: {},
        }
    },
    watch: {
@@ -121,39 +140,19 @@
                queryType: 0,
                statisticalMethod: this.statisticalMethod
            }
            // console.log(this.option2.series, '>>>>>>>>>>???')
            try {
                this.option2.dataset.source = []
                this.option2.series = []
            } catch (error) {
            }
            return this.$HTTP.post(this.url, dataSend, { params }).then(res => {
                this.chartsData = res.data.items.records
                let option2 = {
                    // legend: {
                    //     type: 'plain',
                    // },
                    title: {
                        text: '统计图表',
                        subtext: '',
                    },
                    grid: {
                        top: '80px'
                    },
                    tooltip: {
                        trigger: 'axis'
                    },
                    xAxis: {
                        type: 'category',
                        axisLabel: {
                            interval: 'auto'
                        }
                    },
                    yAxis: {
                        type: 'value'
                    },
                    dataZoom: [
                        { type: 'slider' }
                    ],
                    dataset: {
                        source: []
                    },
                    series: []
                    ...this.options
                }
                option2.series = []
                let source1 = ['product']
                let row = res.data.items.records[0]
                Object.values(row.nameData).forEach(v => {
@@ -162,11 +161,13 @@
                    })
                    source1.push(v)
                })
                option2.dataset.source = [source1]
                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)
                });