1
lzhe
2024-04-30 a6cf534c976bc6a4505951a9c6c1d2bbaefc6d99
1
已修改1个文件
54 ■■■■ 文件已修改
src/views/mdc/time-analysis.vue 54 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/mdc/time-analysis.vue
@@ -2,7 +2,7 @@
 * @Author: lzhe lzhe@example.com
 * @Date: 2024-04-26 09:36:18
 * @LastEditors: lzhe lzhe@example.com
 * @LastEditTime: 2024-04-28 18:58:58
 * @LastEditTime: 2024-04-30 10:03:05
 * @FilePath: /smart-web/src/views/mdc/status-record.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
@@ -59,9 +59,9 @@
                            </el-collapse-item>
                            </el-collapse>
                        </div>
                        <div class="paginationwork">
                        <!-- <div class="paginationwork">
                            <el-pagination layout="prev, pager, next" @current-change="recordChange" :total="total" :default-page-size="6"/>
                        </div>
                        </div> -->
                    </div>
                </el-tab-pane>
                <el-tab-pane label="按时间周期统计" name="time">
@@ -323,45 +323,6 @@
        this.getDataA();
    },
    methods: {
        convertArrayToPercentage(inputArray) {
            return inputArray.map((subarray, index) => {
                // 计算子数组的总和
                var total = subarray.reduce((acc, obj) => acc + obj.count, 0);
                // 确保总和不为0,以避免除以0的错误
                if (total === 0) {
                    return {
                        name: `Direct${index + 1}`,
                        type: 'bar',
                        stack: 'total',
                        label: {
                            show: true
                        },
                        emphasis: {
                            focus: 'series'
                        },
                        data: subarray.map(() => 0) // 如果总和为0,则返回全为'0%'的百分比数组
                    };
                }
                // 计算百分比并创建新的data数组
                var percentages = subarray.map(obj => ((obj.count / total) * 100).toFixed(2));
                // 返回结果对象
                return {
                    name: `Direct${index + 1}`,
                    type: 'bar',
                    stack: 'total',
                    label: {
                        show: true
                    },
                    emphasis: {
                        focus: 'series'
                    },
                    data: percentages // 将计算得到的百分比数组作为data
                };
            });
        },
        getDataA() {
            var ids = [];
            this.treeChecked.forEach(item=> {
@@ -431,6 +392,7 @@
                    emphasis: {
                        focus: 'series'
                    },
                    barWidth: 60,
                    data
                }
            }); 
@@ -530,6 +492,14 @@
            this.activeName = val;
            if(val == "time") {  //按时间周期统计
                if(this.setTitle.length != 0) {
                    var obj = {
                        endDate: this.btnList[0].id,
                        startDate: this.btnList[0].id,
                        statisticalMethod: "WEEK"
                    }
                    this.$HTTP.post(`/api/blade-mdc/efficiency-analysis/interval`,obj).then(res=> {
                        console.log(res)
                    })
                    var arr = [];
                    arr.push({
                        btnList: this.btnList,