<template>
    <div class="taskInfoPanel">
        <div class="panel boxA">
            <div class="titlePanel">
                <div class="titlePanelBor">基本信息</div>
            </div>
            <div class="contentBox">
                <div class="info">
                    <span>任务ID:</span>
                    <b>{{ info.taskId }}</b>
                </div>
                <div class="info">
                    <span>开始时间:</span>
                    <b>{{ info.runStartTime }}</b>
                </div>
                <div class="info">
                    <span>结束时间:</span>
                    <b>{{ info.runEndTime }}</b>
                </div>
                <div class="info">
                    <span>执行状态:</span>
                    <b>{{ info.runState }}</b>
                </div>
                <div class="info">
                    <span>场景名称:</span>
                    <b>{{ info.sceneName }}</b>
                </div>
                <div class="info">
                    <span>完成状态:</span>
                    <b>{{ info.finishState }}</b>
                </div>
                <div class="info">
                    <span>场景描述:</span>
                    <b>{{ info.sceneDescribe }}</b>
                </div>
            </div>
        </div>

        <div class="panel">
            <div class="titlePanel">
                <div class="titlePanelBor">得分详情</div>
            </div>
            <div class="box">
                <tableList
                    style="margin: 30px 0"
                    :columns="columnsB"
                    :getDataWay="getDataWayB"
                >
                </tableList>
            </div>
        </div>

        <div class="panel boxB">
            <div class="titlePanel">
                <div class="titlePanelBor">仿真动画</div>
            </div>
            <div class="contentBox">
                <!-- <div class="content">
                    <img
                        src="../../assets/common/image/others/3.png"
                        width="100%"
                    />
                </div> -->
                <div
                    class="content"
                    v-for="item in videoUrl"
                    :key="item + Math.random()"
                >
                    <video :src="item" controls="controls"></video>
                    <!-- <video controls="controls">
                        <source :src="item" type="video/mp4">
                    </video> -->
                </div>
            </div>
        </div>

        <div class="panel boxC">
            <div class="titlePanel">
                <div class="titlePanelBor">基本数据</div>
            </div>
            <div class="contentBox">
                <div class="info">
                    <span>里程(米):</span>
                    <b>{{ getNumber(info.mileage) }}</b>
                </div>
                <div class="info">
                    <span>平均速度(千米/小时):</span>
                    <b>{{ getNumber(info.averageVelocity) }}</b>
                </div>
                <div class="info">
                    <span>最大速度(千米/小时):</span>
                    <b>{{ getNumber(info.maximunSpeed) }}</b>
                </div>
                <div class="info">
                    <span>最小速度(千米/小时):</span>
                    <b>{{ getNumber(info.minimunVelocity) }}</b>
                </div>
                <div class="info">
                    <span>最大横摆角速度(弧度/秒):</span>
                    <b>{{ getNumber(info.maximumSwingSpeed) }}</b>
                </div>
                <div class="info">
                    <span>最大横向加速度(米/秒²):</span>
                    <b>{{ getNumber(info.maximumAcceleration) }}</b>
                </div>
                <div class="info">
                    <span>最大横向减速度(米/秒²):</span>
                    <b>{{ getNumber(info.maximumDeceleration) }}</b>
                </div>
                <div class="info">
                    <span>最大纵向加速度(米/秒²):</span>
                    <b>{{ getNumber(info.maxLongitudinalAcceleration) }}</b>
                </div>
                <div class="info">
                    <span>最大纵向减速度(米/秒²):</span>
                    <b>{{ getNumber(info.minLongitudinalAcceleration) }}</b>
                </div>
            </div>
        </div>

        <div class="panel boxD">
            <div class="titlePanel">
                <div class="titlePanelBor">舒适性参数</div>
            </div>
            <div class="contentBox">
                <div class="content">
                    <div class="tip">
                        自车速度方差：{{ info.speedVariance }}
                    </div>
                    <tableList
                        :columns="columns"
                        :getDataWay="getDataWay"
                        class="colorfulTable"
                    >
                    </tableList>
                </div>
                <div class="content">
                    <div class="tip">
                        自车横摆角速度均方根：{{
                            info.swingSpeedMeanSquareRoot
                        }}
                    </div>
                    <tableList
                        :columns="columnsA"
                        :getDataWay="getDataWayA"
                        class="colorfulTable"
                    >
                    </tableList>
                </div>
            </div>
        </div>

        <div class="panel boxE">
            <div class="titlePanel">
                <div class="titlePanelBor">变化曲线图</div>
            </div>
            <div class="contentBox">
                <div class="content">
                    <div class="chart">
                        <div class="title">横向加速度变化曲线</div>
                        <line-chart-task-info
                            id="taskInfoLineA"
                            :xList="xList"
                            :yList="yListA"
                            yUnit="m/s²"
                        ></line-chart-task-info>
                    </div>
                    <div class="chart">
                        <div class="title">纵向加速度变化曲线</div>
                        <line-chart-task-info
                            id="taskInfoLineH"
                            :xList="xList"
                            :yList="yListH"
                            yUnit="m/s²"
                        ></line-chart-task-info>
                    </div>
                    <div class="chart">
                        <div class="title">距车道中心线距离变化曲线</div>
                        <line-chart-task-info
                            id="taskInfoLineB"
                            :xList="xList"
                            :yList="yListB"
                            yUnit="m"
                        ></line-chart-task-info>
                    </div>
                    <!-- <div class="chart">
                        <div class="title">刹车变化曲线</div>
                        <line-chart-task-info
                            id="taskInfoLineC"
                            :xList="xList"
                            :yList="yListC"
                            yUnit="百分比"
                        ></line-chart-task-info>
                    </div> -->
                    <div class="chart">
                        <div class="title">方向盘转角变化曲线</div>
                        <line-chart-task-info
                            id="taskInfoLineD"
                            :xList="xList"
                            :yList="yListD"
                            yUnit="°"
                        ></line-chart-task-info>
                    </div>
                    <!-- <div class="chart">
                        <div class="title">油门变化曲线</div>
                        <line-chart-task-info
                            id="taskInfoLineE"
                            :xList="xList"
                            :yList="yListE"
                            yUnit="百分比"
                        ></line-chart-task-info>
                    </div> -->
                    <div class="chart">
                        <div class="title">横摆角速度变化曲线</div>
                        <line-chart-task-info
                            id="taskInfoLineF"
                            :xList="xList"
                            :yList="yListF"
                            yUnit="°/s"
                        ></line-chart-task-info>
                    </div>
                    <div class="chart">
                        <div class="title">速度变化曲线</div>
                        <line-chart-task-info
                            id="taskInfoLineG"
                            :xList="xList"
                            :yList="yListG"
                            yUnit="km/h"
                        ></line-chart-task-info>
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
import tableList from "@/components/grid/TableList";
import lineChartTaskInfo from "@/components/echarts/lineChartTaskInfo";

export default {
    name: "taskInfo", // 任务详情
    components: { tableList, lineChartTaskInfo },
    data() {
        return {
            info: {},
            columns: [
                {
                    label: "方差范围",
                    prop: "range",
                },
                {
                    label: "舒适程度",
                    prop: "ktName",
                },
            ],
            getDataWay: {
                //加载表格数据
                dataType: "data",
                type: "post",
                firstRequest: false,
                data: [
                    {
                        range: "0≤方差值≤5",
                        ktName: "舒适",
                    },
                    {
                        range: "5<方差值≤10",
                        ktName: "不舒适",
                    },
                    {
                        range: "方差值>10",
                        ktName: "极不舒适",
                    },
                ],
                param: {},
            },
            columnsA: [
                {
                    label: "均方根范围",
                    prop: "range",
                },
                {
                    label: "舒适程度",
                    prop: "ktName",
                },
            ],
            getDataWayA: {
                //加载表格数据
                dataType: "data",
                type: "post",
                firstRequest: false,
                data: [
                    {
                        range: "0≤均方根值≤0.02",
                        ktName: "舒适",
                    },
                    {
                        range: "0.02<均方根值≤0.04",
                        ktName: "不舒适",
                    },
                    {
                        range: "均方根值>0.04",
                        ktName: "极不舒适",
                    },
                ],
                param: {},
            },
            columnsB: [],
            getDataWayB: {
                //加载表格数据
                dataType: "data",
                type: "post",
                firstRequest: false,
                data: [],
                param: {},
            },
            xList: [],
            yListA: [],
            yListB: [],
            yListC: [],
            yListD: [],
            yListE: [],
            yListF: [],
            yListG: [],
            yListH: [],
            videoUrl: [],
        };
    },

    computed: {},

    methods: {
        getNumber(val) {
            if (isNaN(val)) return "";
            if (val == 0) return 0;
            return Number(val).toFixed(4);
        },
    },

    mounted() {
        let taskId = this.$route.query.taskId;
        let id = this.$route.query.id;
        let projectType = this.$route.query.projectType || "1";

        if (taskId && id) {
            let id = this.$route.query.id;

            this.$axios({
                method: "post",
                url: this.$api.workManagement.selectProjectTaskById,
                data: {
                    id,
                    taskId,
                    projectType,
                },
            }).then((res) => {
                if (res.code == 200 && res.info) {
                    this.info = res.info;

                    if (res.info.curveData) {
                        this.xList = res.info.curveData.time || [];

                        this.yListA = res.info.curveData.acceleration || [];
                        this.yListB = res.info.curveData.lane_offset || [];
                        this.yListC = res.info.curveData.brake || [];
                        this.yListD = res.info.curveData.steeting || [];
                        this.yListE = res.info.curveData.throttle || [];
                        this.yListF = res.info.curveData.yaw_rate || [];
                        this.yListG = res.info.curveData.velocity || [];
                        this.yListH = res.info.curveData.acceleration_longitudinal || [];
                    }

                    this.videoUrl = res.info.videoUrl || [];

                    this.columnsB = res.info.sceneScoreLiTitle;
                    this.getDataWayB.data = res.info.sceneScoreLi;
                } else {
                    this.$message.error(res.message || "获取信息失败");
                }
            });
        }
    },
};
</script>

<style lang='less' scoped>
.taskInfoPanel {
    // padding: 18px;

    .panel {
        border: 1px solid #dfdfdf;
        padding: 12px 24px;
        margin-bottom: 25px;
        box-shadow: 0 4px 9px #dcdcdc;
        border-radius: 3px;
    }

    .titlePanel {
        padding-bottom: 6px;
        border-bottom: 1px dotted @gray;
    }

    .boxA,
    .boxC {
        .info {
            display: flex;
            width: 345px;
            margin: 0 12px 22px 0;
            word-break: break-all;

            b {
                flex: 1;
                font-weight: normal;
            }
        }
    }

    .boxA {
        .contentBox {
            display: flex;
            flex-wrap: wrap;
            padding: 18px 15px;
        }

        .info {
            span {
                display: block;
                width: 75px;
                color: @gray;
            }
        }
    }

    .boxB,
    .boxE {
        .contentBox {
            display: flex;
            justify-content: center;
            align-items: center;
            padding: 30px 0;
        }
    }

    .boxB {
        .contentBox {
            justify-content: space-around;
            flex-wrap: wrap;

            .content {
                width: 45%;
                margin-bottom: 30px;

                video {
                    width: 100%;
                }
            }
        }
    }

    .boxC {
        .contentBox {
            display: flex;
            flex-wrap: wrap;
            padding: 18px 15px;
        }

        .info {
            span {
                display: block;
                width: 174px;
                padding-right: 10px;
                color: @gray;
            }
        }
    }

    .boxD {
        .contentBox {
            display: flex;
            flex-wrap: wrap;
            padding: 18px 15px;
        }

        .content {
            width: 50%;

            /deep/ .el-table {
                width: 480px;

                .el-table_3_column_6 {
                    background-color: #a3e432;
                }
            }
        }

        .tip {
            padding: 20px 0 15px;
            margin: 0 10px;
        }

        .colorfulTable {
            /deep/ .el-table__body {
                .el-table__row:first-child {
                    td:last-child {
                        background-color: #a3e432;
                    }
                }

                .el-table__row:nth-child(2) {
                    td:last-child {
                        background-color: #f4e015;
                    }
                }

                .el-table__row:last-child {
                    td:last-child {
                        background-color: #f56c6c;
                    }
                }
            }
        }
    }

    .boxE {
        // .contentBox {
        //     flex-wrap: wrap;
        // }

        .content {
            display: flex;
            flex: 1;
            flex-wrap: wrap;
        }

        .chart {
            width: 33%;
            height: calc(25vh);
            margin-right: 3px;
            margin-bottom: 60px;

            .title {
                text-align: center;
                color: @themeColor;
            }
        }
    }
}
</style>