<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.runState }}</b>
                </div>
                <div class="info">
                    <span>场景描述:</span>
                    <b>{{ info.sceneDescribe }}</b>
                </div>
                <div class="info">
                    <span>场景名称:</span>
                    <b>{{ info.sceneName }}</b>
                </div>
                <div class="info">
                    <span>结束时间:</span>
                    <b>{{ info.runEndTime }}</b>
                </div>
                <div class="info">
                    <span>完成状态:</span>
                    <b>{{ info.finishState }}</b>
                </div>
            </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>
        </div>

        <div class="panel boxC">
            <div class="titlePanel">
                <div class="titlePanelBor">基本数据</div>
            </div>
            <div class="contentBox">
                <div class="info">
                    <span>里程(千米):</span>
                    <b>{{ info.mileage }}</b>
                </div>
                <div class="info">
                    <span>平均速度(千米/小时):</span>
                    <b>{{ info.averageVelocity }}</b>
                </div>
                <div class="info">
                    <span>最大速度(千米/小时):</span>
                    <b>{{ info.maximunSpeed }}</b>
                </div>
                <div class="info">
                    <span>最小速度(千米/小时):</span>
                    <b>{{ info.minimunVelocity }}</b>
                </div>
                <div class="info">
                    <span>最大加速度(千米/小时):</span>
                    <b>{{ info.maximumAcceleration }}</b>
                </div>
                <div class="info">
                    <span>最大减速度(千米/小时):</span>
                    <b>{{ info.maximumDeceleration }}</b>
                </div>
                <div class="info">
                    <span>最大摆角速度(弧度/秒):</span>
                    <b>{{ info.maximumSwingSpeed }}</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>
                            <!-- v-show="yListA.length > 0" -->
                        <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>
                            <!-- v-if="yListB.length > 0" -->
                        <line-chart-task-info
                            id="taskInfoLineB"
                            :xList="xList"
                            :yList="yListB"
                            yUnit="m"
                        ></line-chart-task-info>
                    </div>
                    <div class="chart">
                        <div class="title">刹车变化曲线</div>
                            <!-- v-if="yListC.length > 0" -->
                        <line-chart-task-info
                            id="taskInfoLineC"
                            :xList="xList"
                            :yList="yListC"
                            yUnit="百分比"
                        ></line-chart-task-info>
                    </div>
                    <div class="chart">
                        <div class="title">方向盘转角变化曲线</div>
                            <!-- v-if="yListD.length > 0" -->
                        <line-chart-task-info
                            id="taskInfoLineD"
                            :xList="xList"
                            :yList="yListD"
                            yUnit="°"
                        ></line-chart-task-info>
                    </div>
                    <div class="chart">
                        <div class="title">油门变化曲线</div>
                            <!-- v-if="yListE.length > 0" -->
                        <line-chart-task-info
                            id="taskInfoLineE"
                            :xList="xList"
                            :yList="yListE"
                            yUnit="百分比"
                        ></line-chart-task-info>
                    </div>
                    <div class="chart">
                        <div class="title">横摆角速度变化曲线</div>
                            <!-- v-if="yListF.length > 0" -->
                        <line-chart-task-info
                            id="taskInfoLineF"
                            :xList="xList"
                            :yList="yListF"
                            yUnit="°/s"
                        ></line-chart-task-info>
                    </div>
                    <div class="chart">
                        <div class="title">速度变化曲线</div>
                            <!-- v-if="yListG.length > 0" -->
                        <line-chart-task-info
                            id="taskInfoLineG"
                            :xList="xList"
                            :yList="yListG"
                            yUnit="m/s"
                        ></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 {
            // id: "",
            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: {},
            },
            xList: [],
            yListA: [],
            yListB: [],
            yListC: [],
            yListD: [],
            yListE: [],
            yListF: [],
            yListG: [],
        };
    },

    computed: {},

    methods: {},

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

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

            this.$axios({
                method: "post",
                url: this.$api.workManagement.selectProjectTaskById,
                data: {
                    id,
                    taskId,
                },
            }).then((res) => {
                if (res.code == 200 && res.info) {
                    this.info = res.info;
                    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;
                } 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 {
        .contentBox {
            display: flex;
            flex-wrap: wrap;
            padding: 18px 15px;
        }

        .info {
            display: flex;
            width: 300px;
            margin: 0 20px 22px 0;

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

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

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

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

        .info {
            display: flex;
            width: 250px;
            margin: 0 20px 22px 0;

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

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

    .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-bottom: 60px;

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