<template>
    <div class="generalizationDetailPanel">
        <el-form ref="form" :model="form" :rules="rules" label-width="225px">
            <!-- <el-row :gutter="10">
                <el-col :span="8" :offset="16">
                    <div class="changeBtn">
                        <el-button type="primary" @click="changeTemplate"
                            >更换模板</el-button
                        >
                    </div>
                </el-col>
            </el-row> -->

            <el-row :gutter="10">
                <el-col :span="8">
                    <el-form-item label="场景发生时刻:" prop="scenarioTime">
                        <el-time-picker
                            v-model="form.scenarioTime"
                            value-format="HH:mm:ss"
                            placeholder="请选择"
                            :disabled="disabled"
                        >
                        </el-time-picker>
                    </el-form-item>
                </el-col>
                <el-col :span="8">
                    <el-form-item label="天气:" prop="scenarioWeather">
                        <el-select
                            v-model="form.scenarioWeather"
                            :disabled="disabled"
                        >
                            <el-option
                                v-for="item in scenarioWeatherList"
                                :label="item.caption"
                                :value="item.code"
                                :key="item.code"
                            ></el-option>
                        </el-select>
                    </el-form-item>
                </el-col>
                <!-- <el-col :span="8">
                    <el-form-item label="车辆模型:" prop="scenarioVehicleModel">
                        <el-select v-model="form.scenarioVehicleModel">
                            <el-option
                                v-for="item in scenarioVehicleModelList"
                                :label="item.caption"
                                :value="item.code"
                                :key="item.code"
                            ></el-option>
                        </el-select>
                    </el-form-item>
                </el-col> -->
            </el-row>

            <el-row
                :gutter="10"
                v-if="
                    form.scenarioRoadType === '2' ||
                    form.scenarioRoadType === '3'
                "
            >
                <el-col :span="8">
                    <el-form-item label="道路类型:" prop="scenarioRoadType">
                        <el-select v-model="form.scenarioRoadType" disabled>
                            <el-option
                                v-for="item in scenarioRoadTypeList"
                                :label="item.caption"
                                :value="item.code"
                                :key="item.code"
                            ></el-option>
                        </el-select>
                    </el-form-item>
                </el-col>
                <el-col :span="8">
                    <el-form-item
                        label="车道线曲率半径:"
                        prop="scenarioRadiusCurvatureView"
                    >
                        <el-select
                            v-model="form.scenarioRadiusCurvatureView"
                            multiple
                            :disabled="disabled"
                        >
                            <el-option
                                v-for="item in scenarioRadiusCurvatureList"
                                :label="item.caption"
                                :value="item.code"
                                :key="item.code"
                            ></el-option>
                        </el-select>
                    </el-form-item>
                </el-col>
            </el-row>

            <el-row :gutter="10">
                <el-col :span="8">
                    <!-- <div class="info">
                        <span>场景编号:</span>
                        <b>{{ form.sceneId }}</b>
                    </div> -->
                    <el-form-item label="场景编号:" prop="sceneId">
                        <b class="infos">{{ form.sceneId }}</b>
                    </el-form-item>
                </el-col>
                <el-col :span="16">
                    <div class="info">
                        <span>场景简述:</span>
                        <b>{{ form.scenarioResume }}</b>
                    </div>
                </el-col>
            </el-row>

            <el-row :gutter="10">
                <el-col :span="24">
                    <div class="info">
                        <span>场景描述:</span>
                        <b>{{ form.sceneDetailedDescription }}</b>
                    </div>
                </el-col>
            </el-row>

            <el-row :gutter="10">
                <el-col :span="8" class="boxA">
                    <el-form-item
                        label="自车初始X坐标:"
                        prop="egoStartX1"
                        v-bind:class="
                            generalizationType.egoStartX === 2 ||
                            generalizationType.egoStartX === 4
                                ? 'itemA'
                                : ''
                        "
                    >
                        <el-input
                            v-if="
                                generalizationType.egoStartX === 2 ||
                                generalizationType.egoStartX === 4
                            "
                            placeholder="请输入"
                            maxlength="12"
                            v-autoTrim="{
                                obj: form,
                                key: 'egoStartX1',
                            }"
                            v-model="form.egoStartX1"
                            :disabled="disabled"
                        >
                        </el-input>

                        <!-- <el-input
                            v-else
                            v-model="form.egoStartX"
                            disabled
                        >
                        </el-input> -->

                        <b class="infos" v-else>{{ form.egoStartX }}</b>
                    </el-form-item>
                    <i
                        class="line"
                        v-if="
                            generalizationType.egoStartX === 2 ||
                            generalizationType.egoStartX === 4
                        "
                    ></i>
                    <el-form-item
                        v-if="
                            generalizationType.egoStartX === 2 ||
                            generalizationType.egoStartX === 4
                        "
                        label=""
                        prop="egoStartX2"
                        class="itemB"
                    >
                        <el-input
                            placeholder="请输入"
                            maxlength="12"
                            v-autoTrim="{
                                obj: form,
                                key: 'egoStartX2',
                            }"
                            v-model="form.egoStartX2"
                            :disabled="disabled"
                        >
                        </el-input>
                    </el-form-item>
                </el-col>
                <el-col
                    :span="8"
                    v-if="
                        generalizationType.egoStartX === 2 ||
                        generalizationType.egoStartX === 4
                    "
                >
                    <el-form-item label="间隔:" prop="egoStartX3">
                        <el-input
                            placeholder="请输入"
                            maxlength="12"
                            v-autoTrim="{ obj: form, key: 'egoStartX3' }"
                            v-model="form.egoStartX3"
                            :disabled="disabled"
                        >
                        </el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="8" v-if="generalizationType.egoStartX === 4">
                    <div class="info">
                        <b>且需满足 {{ form.egoStartXFormula }}</b>
                    </div>
                </el-col>
            </el-row>

            <el-row :gutter="10">
                <el-col :span="8" class="boxA">
                    <el-form-item
                        label="自车初始Y坐标:"
                        prop="egoStartY1"
                        v-bind:class="
                            generalizationType.egoStartY === 2 ||
                            generalizationType.egoStartY === 4
                                ? 'itemA'
                                : ''
                        "
                    >
                        <el-input
                            v-if="
                                generalizationType.egoStartY === 2 ||
                                generalizationType.egoStartY === 4
                            "
                            placeholder="请输入"
                            maxlength="12"
                            v-autoTrim="{
                                obj: form,
                                key: 'egoStartY1',
                            }"
                            v-model="form.egoStartY1"
                            :disabled="disabled"
                        >
                        </el-input>

                        <b class="infos" v-else>{{ form.egoStartY }}</b>
                    </el-form-item>
                    <i
                        class="line"
                        v-if="
                            generalizationType.egoStartY === 2 ||
                            generalizationType.egoStartY === 4
                        "
                    ></i>
                    <el-form-item
                        v-if="
                            generalizationType.egoStartY === 2 ||
                            generalizationType.egoStartY === 4
                        "
                        label=""
                        prop="egoStartY2"
                        class="itemB"
                    >
                        <el-input
                            placeholder="请输入"
                            maxlength="12"
                            v-autoTrim="{
                                obj: form,
                                key: 'egoStartY2',
                            }"
                            v-model="form.egoStartY2"
                            :disabled="disabled"
                        >
                        </el-input>
                    </el-form-item>
                </el-col>
                <el-col
                    :span="8"
                    v-if="
                        generalizationType.egoStartY === 2 ||
                        generalizationType.egoStartY === 4
                    "
                >
                    <el-form-item label="间隔:" prop="egoStartY3">
                        <el-input
                            placeholder="请输入"
                            maxlength="12"
                            v-autoTrim="{ obj: form, key: 'egoStartY3' }"
                            v-model="form.egoStartY3"
                            :disabled="disabled"
                        >
                        </el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="8" v-if="generalizationType.egoStartY === 4">
                    <div class="info">
                        <b>且需满足 {{ form.egoStartYFormula }}</b>
                    </div>
                </el-col>
            </el-row>

            <el-row :gutter="10">
                <el-col :span="8" class="boxA">
                    <el-form-item
                        label="自车初始速度(km/h):"
                        prop="egoStartVelocity1"
                        v-bind:class="
                            generalizationType.egoStartVelocity === 2 ||
                            generalizationType.egoStartVelocity === 4
                                ? 'itemA'
                                : ''
                        "
                    >
                        <el-input
                            v-if="
                                generalizationType.egoStartVelocity === 2 ||
                                generalizationType.egoStartVelocity === 4
                            "
                            placeholder="请输入"
                            maxlength="12"
                            v-autoTrim="{
                                obj: form,
                                key: 'egoStartVelocity1',
                            }"
                            v-model="form.egoStartVelocity1"
                            :disabled="disabled"
                        >
                        </el-input>

                        <b class="infos" v-else>{{ form.egoStartVelocity }}</b>
                    </el-form-item>
                    <i
                        class="line"
                        v-if="
                            generalizationType.egoStartVelocity === 2 ||
                            generalizationType.egoStartVelocity === 4
                        "
                    ></i>
                    <el-form-item
                        v-if="
                            generalizationType.egoStartVelocity === 2 ||
                            generalizationType.egoStartVelocity === 4
                        "
                        label=""
                        prop="egoStartVelocity2"
                        class="itemB"
                    >
                        <el-input
                            placeholder="请输入"
                            maxlength="12"
                            v-autoTrim="{
                                obj: form,
                                key: 'egoStartVelocity2',
                            }"
                            v-model="form.egoStartVelocity2"
                            :disabled="disabled"
                        >
                        </el-input>
                    </el-form-item>
                </el-col>
                <el-col
                    :span="8"
                    v-if="
                        generalizationType.egoStartVelocity === 2 ||
                        generalizationType.egoStartVelocity === 4
                    "
                >
                    <el-form-item label="间隔:" prop="egoStartVelocity3">
                        <el-input
                            placeholder="请输入"
                            maxlength="12"
                            v-autoTrim="{ obj: form, key: 'egoStartVelocity3' }"
                            v-model="form.egoStartVelocity3"
                            :disabled="disabled"
                        >
                        </el-input>
                    </el-form-item>
                </el-col>
                <el-col
                    :span="8"
                    v-if="generalizationType.egoStartVelocity === 4"
                >
                    <div class="info">
                        <b>且需满足 {{ form.egoStartVelocityFormula }}</b>
                    </div>
                </el-col>
            </el-row>

            <el-row :gutter="10">
                <el-col :span="8">
                    <div class="info">
                        <span>
                            自车行驶速度状态
                            <i
                                class="el-icon-info cursor"
                                title="按照时间先后顺序"
                            ></i>
                            :</span
                        >
                        <b>{{
                            dataToView(speedStateList, form.egoVelocityStatus)
                        }}</b>
                    </div>
                </el-col>
                <el-col :span="8">
                    <div class="info">
                        <span>自车轨迹形态:</span>
                        <b>{{
                            dataToView(trajectoryList, form.egoTrajectory)
                        }}</b>
                    </div>
                </el-col>
            </el-row>

            <el-row :gutter="10">
                <!-- <el-col :span="8">
                    <el-form-item
                        label="自车轨迹持续时间(s):"
                        prop="egoDurationTime"
                    >
                        <el-input
                            v-if="
                                generalizationType.egoDurationTime === 2 ||
                                generalizationType.egoDurationTime === 4
                            "
                            placeholder="请输入"
                            maxlength="12"
                            v-autoTrim="{ obj: form, key: 'egoDurationTime' }"
                            v-model="form.egoDurationTime"
                        >
                        </el-input>
                        <b class="infos" v-else>{{ form.egoDurationTime }}</b>
                    </el-form-item>
                </el-col>
                <el-col
                    :span="8"
                    v-if="generalizationType.egoDurationTime === 4"
                >
                    <div class="info">
                        <b>{{ form.egoDurationTimeFormula }}</b>
                    </div>
                </el-col> -->
                <el-col :span="8">
                    <div class="info">
                        <span>自车轨迹持续时间(s):</span>
                        <b>{{ form.egoDurationTime }}</b>
                    </div>
                </el-col>
                <el-col :span="8">
                    <div class="info">
                        <span>自车轨迹形态分段持续时间(s):</span>
                        <b>{{ form.egoTrajectoryTime }}</b>
                    </div>
                </el-col>
            </el-row>

            <el-collapse v-model="activeNames">
                <el-collapse-item
                    v-for="(item, index) in form.listMb"
                    :title="'目标物' + Number(index + 1)"
                    :key="'form' + index"
                    :name="'form' + index"
                >
                    <el-form
                        :ref="'form' + index"
                        :model="item"
                        :rules="rulesA"
                        label-width="225px"
                    >
                        <!-- <el-form
                v-for="(item, index) in form.listMb"
                :ref="'form' + index"
                :model="item"
                :rules="rulesA"
                label-width="225px"
            > -->
                        <!-- <el-row :gutter="10">
                    <el-col :span="8">
                        <el-form-item label="目标物初始x坐标:" prop="obsStartX">
                            <el-input
                                v-if="
                                    JSON.parse(item.generalizationType)
                                        .obsStartX === 2 ||
                                    JSON.parse(item.generalizationType)
                                        .obsStartX === 4
                                "
                                placeholder="请输入"
                                maxlength="12"
                                v-model.trim="item.obsStartX"
                            >
                            </el-input>

                            <b class="infos" v-else>{{ item.obsStartX }}</b>
                        </el-form-item>
                    </el-col>
                    <el-col
                        :span="8"
                        v-if="
                            JSON.parse(item.generalizationType).obsStartX === 4
                        "
                    >
                        <div class="info">
                            <b>{{ item.obsStartXFormula }}</b>
                        </div>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item label="目标物初始y坐标:" prop="obsStartY">
                            <el-input
                                v-if="
                                    JSON.parse(item.generalizationType)
                                        .obsStartY === 2 ||
                                    JSON.parse(item.generalizationType)
                                        .obsStartY === 4
                                "
                                placeholder="请输入"
                                maxlength="12"
                                v-model.trim="item.obsStartY"
                            >
                            </el-input>
                            <b class="infos" v-else>{{ item.obsStartY }}</b>
                        </el-form-item>
                    </el-col>
                    <el-col
                        :span="8"
                        v-if="
                            JSON.parse(item.generalizationType).obsStartY === 4
                        "
                    >
                        <div class="info">
                            <b>{{ item.obsStartYFormula }}</b>
                        </div>
                    </el-col>
                </el-row> -->

                        <el-row :gutter="10">
                            <el-col :span="8" class="boxA">
                                <el-form-item
                                    label="目标物初始x坐标:"
                                    prop="obsStartX1"
                                    v-bind:class="
                                        JSON.parse(item.generalizationType)
                                            .obsStartX === 2 ||
                                        JSON.parse(item.generalizationType)
                                            .obsStartX === 4
                                            ? 'itemA'
                                            : ''
                                    "
                                >
                                    <el-input
                                        v-if="
                                            JSON.parse(item.generalizationType)
                                                .obsStartX === 2 ||
                                            JSON.parse(item.generalizationType)
                                                .obsStartX === 4
                                        "
                                        placeholder="请输入"
                                        maxlength="12"
                                        v-model.trim="item.obsStartX1"
                                        :disabled="disabled"
                                    >
                                    </el-input>

                                    <b class="infos" v-else>{{
                                        item.obsStartX
                                    }}</b>
                                </el-form-item>
                                <i
                                    class="line"
                                    v-if="
                                        JSON.parse(item.generalizationType)
                                            .obsStartX === 2 ||
                                        JSON.parse(item.generalizationType)
                                            .obsStartX === 4
                                    "
                                ></i>
                                <el-form-item
                                    v-if="
                                        JSON.parse(item.generalizationType)
                                            .obsStartX === 2 ||
                                        JSON.parse(item.generalizationType)
                                            .obsStartX === 4
                                    "
                                    label=""
                                    prop="obsStartX2"
                                    class="itemB"
                                >
                                    <el-input
                                        placeholder="请输入"
                                        maxlength="12"
                                        v-model.trim="item.obsStartX2"
                                        :disabled="disabled"
                                    >
                                    </el-input>
                                </el-form-item>
                            </el-col>
                            <el-col
                                :span="8"
                                v-if="
                                    JSON.parse(item.generalizationType)
                                        .obsStartX === 2 ||
                                    JSON.parse(item.generalizationType)
                                        .obsStartX === 4
                                "
                            >
                                <el-form-item label="间隔:" prop="obsStartX3">
                                    <el-input
                                        placeholder="请输入"
                                        maxlength="12"
                                        v-model.trim="item.obsStartX3"
                                        :disabled="disabled"
                                    >
                                    </el-input>
                                </el-form-item>
                            </el-col>
                            <el-col
                                :span="8"
                                v-if="
                                    JSON.parse(item.generalizationType)
                                        .obsStartX === 4
                                "
                            >
                                <div class="info">
                                    <b>且需满足 {{ item.obsStartXFormula }}</b>
                                </div>
                            </el-col>
                        </el-row>

                        <el-row :gutter="10">
                            <el-col :span="8" class="boxA">
                                <el-form-item
                                    label="目标物初始y坐标:"
                                    prop="obsStartY1"
                                    v-bind:class="
                                        JSON.parse(item.generalizationType)
                                            .obsStartY === 2 ||
                                        JSON.parse(item.generalizationType)
                                            .obsStartY === 4
                                            ? 'itemA'
                                            : ''
                                    "
                                >
                                    <el-input
                                        v-if="
                                            JSON.parse(item.generalizationType)
                                                .obsStartY === 2 ||
                                            JSON.parse(item.generalizationType)
                                                .obsStartY === 4
                                        "
                                        placeholder="请输入"
                                        maxlength="12"
                                        v-model.trim="item.obsStartY1"
                                        :disabled="disabled"
                                    >
                                    </el-input>

                                    <b class="infos" v-else>{{
                                        item.obsStartY
                                    }}</b>
                                </el-form-item>
                                <i
                                    class="line"
                                    v-if="
                                        JSON.parse(item.generalizationType)
                                            .obsStartY === 2 ||
                                        JSON.parse(item.generalizationType)
                                            .obsStartY === 4
                                    "
                                ></i>
                                <el-form-item
                                    v-if="
                                        JSON.parse(item.generalizationType)
                                            .obsStartY === 2 ||
                                        JSON.parse(item.generalizationType)
                                            .obsStartY === 4
                                    "
                                    label=""
                                    prop="obsStartY2"
                                    class="itemB"
                                >
                                    <el-input
                                        placeholder="请输入"
                                        maxlength="12"
                                        v-model.trim="item.obsStartY2"
                                        :disabled="disabled"
                                    >
                                    </el-input>
                                </el-form-item>
                            </el-col>
                            <el-col
                                :span="8"
                                v-if="
                                    JSON.parse(item.generalizationType)
                                        .obsStartY === 2 ||
                                    JSON.parse(item.generalizationType)
                                        .obsStartY === 4
                                "
                            >
                                <el-form-item label="间隔:" prop="obsStartY3">
                                    <el-input
                                        placeholder="请输入"
                                        maxlength="12"
                                        v-model.trim="item.obsStartY3"
                                        :disabled="disabled"
                                    >
                                    </el-input>
                                </el-form-item>
                            </el-col>
                            <el-col
                                :span="8"
                                v-if="
                                    JSON.parse(item.generalizationType)
                                        .obsStartY === 4
                                "
                            >
                                <div class="info">
                                    <b>且需满足 {{ item.obsStartYFormula }}</b>
                                </div>
                            </el-col>
                        </el-row>

                        <el-row :gutter="10">
                            <el-col :span="8" class="boxA">
                                <el-form-item
                                    label="目标物初始速度(km/h):"
                                    prop="obsStartVelocity1"
                                    v-bind:class="
                                        JSON.parse(item.generalizationType)
                                            .obsStartVelocity === 2 ||
                                        JSON.parse(item.generalizationType)
                                            .obsStartVelocity === 4
                                            ? 'itemA'
                                            : ''
                                    "
                                >
                                    <el-input
                                        v-if="
                                            JSON.parse(item.generalizationType)
                                                .obsStartVelocity === 2 ||
                                            JSON.parse(item.generalizationType)
                                                .obsStartVelocity === 4
                                        "
                                        placeholder="请输入"
                                        maxlength="12"
                                        v-model.trim="item.obsStartVelocity1"
                                        :disabled="disabled"
                                    >
                                    </el-input>

                                    <b class="infos" v-else>{{
                                        item.obsStartVelocity
                                    }}</b>
                                </el-form-item>
                                <i
                                    class="line"
                                    v-if="
                                        JSON.parse(item.generalizationType)
                                            .obsStartVelocity === 2 ||
                                        JSON.parse(item.generalizationType)
                                            .obsStartVelocity === 4
                                    "
                                ></i>
                                <el-form-item
                                    v-if="
                                        JSON.parse(item.generalizationType)
                                            .obsStartVelocity === 2 ||
                                        JSON.parse(item.generalizationType)
                                            .obsStartVelocity === 4
                                    "
                                    label=""
                                    prop="obsStartVelocity2"
                                    class="itemB"
                                >
                                    <el-input
                                        placeholder="请输入"
                                        maxlength="12"
                                        v-model.trim="item.obsStartVelocity2"
                                        :disabled="disabled"
                                    >
                                    </el-input>
                                </el-form-item>
                            </el-col>
                            <el-col
                                :span="8"
                                v-if="
                                    JSON.parse(item.generalizationType)
                                        .obsStartVelocity === 2 ||
                                    JSON.parse(item.generalizationType)
                                        .obsStartVelocity === 4
                                "
                            >
                                <el-form-item
                                    label="间隔:"
                                    prop="obsStartVelocity3"
                                >
                                    <el-input
                                        placeholder="请输入"
                                        maxlength="12"
                                        v-model.trim="item.obsStartVelocity3"
                                        :disabled="disabled"
                                    >
                                    </el-input>
                                </el-form-item>
                            </el-col>
                            <el-col
                                :span="8"
                                v-if="
                                    JSON.parse(item.generalizationType)
                                        .obsStartVelocity === 4
                                "
                            >
                                <div class="info">
                                    <!-- <span>公式:</span> -->
                                    <b
                                        >且需满足
                                        {{ item.obsStartVelocityFormula }}</b
                                    >
                                </div>
                            </el-col>
                        </el-row>

                        <el-row :gutter="10">
                            <el-col :span="8">
                                <div class="info">
                                    <span>目标物模型:</span>
                                    <b>{{
                                        dataToView(obsTypeList, item.obsType)
                                    }}</b>
                                </div>
                            </el-col>
                            <el-col :span="16">
                                <div class="info">
                                    <span>目标物轨迹形态:</span>
                                    <b>{{
                                        dataToView(
                                            trajectoryList,
                                            item.obsTrajectory
                                        )
                                    }}</b>
                                </div>
                            </el-col>
                        </el-row>

                        <el-row :gutter="10">
                            <el-col :span="16" class="boxB">
                                <template
                                    v-if="
                                        JSON.parse(item.generalizationType)
                                            .obsLateralAcceleration === 2 ||
                                        JSON.parse(item.generalizationType)
                                            .obsLateralAcceleration === 4
                                    "
                                >
                                    <template
                                        v-for="(
                                            ele, i
                                        ) in item.obsLateralAccelerationView"
                                    >
                                        <div class="info mr0" v-if="i === 0">
                                            <span class="required"
                                                >目标物最大横向加速度(m/s²):</span
                                            >
                                        </div>
                                        <el-form-item
                                            v-if="Array.isArray(ele)"
                                            label=""
                                            :prop="
                                                'obsLateralAcceleration' +
                                                i +
                                                '1'
                                            "
                                            class="itemB"
                                        >
                                            <el-input
                                                placeholder="请输入"
                                                maxlength="12"
                                                v-model.trim="
                                                    item[
                                                        'obsLateralAcceleration' +
                                                            i +
                                                            '1'
                                                    ]
                                                "
                                                :disabled="disabled"
                                            >
                                            </el-input>
                                        </el-form-item>
                                        <i
                                            v-if="Array.isArray(ele)"
                                            class="line"
                                        ></i>
                                        <el-form-item
                                            v-if="Array.isArray(ele)"
                                            label=""
                                            :prop="
                                                'obsLateralAcceleration' +
                                                i +
                                                '2'
                                            "
                                            class="itemB"
                                        >
                                            <el-input
                                                placeholder="请输入"
                                                maxlength="12"
                                                v-model.trim="
                                                    item[
                                                        'obsLateralAcceleration' +
                                                            i +
                                                            '2'
                                                    ]
                                                "
                                                :disabled="disabled"
                                            >
                                            </el-input>
                                        </el-form-item>
                                        <i
                                            v-if="Array.isArray(ele)"
                                            class="line"
                                        ></i>
                                        <el-form-item
                                            v-if="Array.isArray(ele)"
                                            label=""
                                            :prop="
                                                'obsLateralAcceleration' +
                                                i +
                                                '3'
                                            "
                                            class="itemB"
                                        >
                                            <el-input
                                                placeholder="请输入"
                                                maxlength="12"
                                                v-model.trim="
                                                    item[
                                                        'obsLateralAcceleration' +
                                                            i +
                                                            '3'
                                                    ]
                                                "
                                                :disabled="disabled"
                                            >
                                            </el-input>
                                        </el-form-item>
                                        <div
                                            class="obsInfo"
                                            v-if="Array.isArray(ele)"
                                        >
                                            ,
                                        </div>
                                        <div v-else class="obsInfo">
                                            {{ ele }}
                                            <span
                                                v-if="
                                                    i <
                                                    item
                                                        .obsLateralAccelerationView
                                                        .length -
                                                        1
                                                "
                                                >,</span
                                            >
                                        </div>
                                    </template>
                                </template>
                                <el-form-item
                                    v-else
                                    label="目标物最大横向加速度(m/s²):"
                                    prop="obsLateralAcceleration"
                                >
                                    <b class="infos">{{
                                        item.obsLateralAcceleration == -1
                                            ? "不做限制"
                                            : item.obsLateralAcceleration
                                    }}</b>
                                </el-form-item>
                            </el-col>
                            <el-col
                                :span="8"
                                v-if="
                                    JSON.parse(item.generalizationType)
                                        .obsLateralAcceleration === 4
                                "
                            >
                                <div class="info">
                                    <b
                                        >且需满足
                                        {{
                                            item.obsLateralAccelerationFormula
                                        }}</b
                                    >
                                </div>
                            </el-col>
                        </el-row>

                        <el-row :gutter="10">
                            <el-col :span="24">
                                <div class="info">
                                    <span
                                        >目标物行驶速度状态
                                        <i
                                            class="el-icon-info cursor"
                                            title="按照时间先后顺序"
                                        ></i>
                                        :</span
                                    >
                                    <b>{{
                                        dataToView(
                                            speedStateList,
                                            item.obsVelocityStatus
                                        )
                                    }}</b>
                                </div>
                            </el-col>
                        </el-row>

                        <el-row :gutter="10">
                            <el-col :span="16" class="boxB">
                                <template
                                    v-if="
                                        JSON.parse(item.generalizationType)
                                            .obsLongitudinalAcceleration ===
                                            2 ||
                                        JSON.parse(item.generalizationType)
                                            .obsLongitudinalAcceleration === 4
                                    "
                                >
                                    <template
                                        v-for="(
                                            ele, i
                                        ) in item.obsLongitudinalAccelerationView"
                                    >
                                        <div class="info mr0" v-if="i === 0">
                                            <span class="required"
                                                >目标物最大纵向加速度(m/s²):</span
                                            >
                                        </div>
                                        <el-form-item
                                            v-if="Array.isArray(ele)"
                                            label=""
                                            :prop="
                                                'obsLongitudinalAcceleration' +
                                                i +
                                                '1'
                                            "
                                            class="itemB"
                                        >
                                            <el-input
                                                placeholder="请输入"
                                                maxlength="12"
                                                v-model.trim="
                                                    item[
                                                        'obsLongitudinalAcceleration' +
                                                            i +
                                                            '1'
                                                    ]
                                                "
                                                :disabled="disabled"
                                            >
                                            </el-input>
                                        </el-form-item>
                                        <i
                                            v-if="Array.isArray(ele)"
                                            class="line"
                                        ></i>
                                        <el-form-item
                                            v-if="Array.isArray(ele)"
                                            label=""
                                            :prop="
                                                'obsLongitudinalAcceleration' +
                                                i +
                                                '2'
                                            "
                                            class="itemB"
                                        >
                                            <el-input
                                                placeholder="请输入"
                                                maxlength="12"
                                                v-model.trim="
                                                    item[
                                                        'obsLongitudinalAcceleration' +
                                                            i +
                                                            '2'
                                                    ]
                                                "
                                                :disabled="disabled"
                                            >
                                            </el-input>
                                        </el-form-item>
                                        <i
                                            v-if="Array.isArray(ele)"
                                            class="line"
                                        ></i>
                                        <el-form-item
                                            v-if="Array.isArray(ele)"
                                            label=""
                                            :prop="
                                                'obsLongitudinalAcceleration' +
                                                i +
                                                '3'
                                            "
                                            class="itemB"
                                        >
                                            <el-input
                                                placeholder="请输入"
                                                maxlength="12"
                                                v-model.trim="
                                                    item[
                                                        'obsLongitudinalAcceleration' +
                                                            i +
                                                            '3'
                                                    ]
                                                "
                                                :disabled="disabled"
                                            >
                                            </el-input>
                                        </el-form-item>
                                        <div
                                            class="obsInfo"
                                            v-if="Array.isArray(ele)"
                                        >
                                            ,
                                        </div>
                                        <div v-else class="obsInfo">
                                            {{ ele }}
                                            <span
                                                v-if="
                                                    i <
                                                    item
                                                        .obsLongitudinalAccelerationView
                                                        .length -
                                                        1
                                                "
                                                >,</span
                                            >
                                        </div>
                                    </template>
                                </template>
                                <el-form-item
                                    v-else
                                    label="目标物最大纵向加速度(m/s²):"
                                    prop="obsLongitudinalAcceleration"
                                >
                                    <b class="infos">{{
                                        item.obsLongitudinalAcceleration == -1
                                            ? "不做限制"
                                            : item.obsLongitudinalAcceleration
                                    }}</b>
                                </el-form-item>
                            </el-col>
                            <el-col
                                :span="8"
                                v-if="
                                    JSON.parse(item.generalizationType)
                                        .obsLongitudinalAcceleration === 4
                                "
                            >
                                <div class="info">
                                    <b
                                        >且需满足
                                        {{
                                            item.obsLongitudinalAccelerationFormula
                                        }}</b
                                    >
                                </div>
                            </el-col>
                        </el-row>

                        <el-row :gutter="10">
                            <el-col :span="8">
                                <div class="info">
                                    <span>目标物轨迹持续时间(s):</span>
                                    <b>{{ item.obsDurationTime }}</b>
                                </div>
                            </el-col>
                            <el-col :span="8">
                                <div class="info">
                                    <span>目标物轨迹形态分段持续时间(s):</span>
                                    <b>{{ item.obsTrailTime }}</b>
                                </div>
                            </el-col>
                            <el-col :span="8">
                                <div class="info">
                                    <span
                                        >目标物相对自车航向角
                                        <i
                                            class="el-icon-info cursor"
                                            title="角度值，逆时针增加"
                                        ></i>
                                        :</span
                                    >
                                    <!-- <b>{{
                                dataToView(
                                    targetDirectionList,
                                    item.obsHeadingAngleRel
                                )
                            }}</b> -->
                                    <b> {{ item.obsHeadingAngleRel }}</b>
                                </div>
                            </el-col>
                        </el-row>
                    </el-form>
                    <!-- </el-form> -->
                </el-collapse-item>
                <!-- <el-collapse v-model="activeNames"> -->
                <el-collapse-item title="说明" name="1">
                    <div class="collapseInfo">
                        1.界面中出现的算式代表此参数需要根据其他参数泛化的结果计算所得<br />
                        2.算式中因子对照<br />
                        <i class="place"></i>车道线曲率半径 rc<br />
                        <i class="place"></i>自车初始x坐标 ep_x，自车初始y坐标
                        ep_y<br />
                        <i class="place"></i>自车初始速度V0(km/h)
                        ev，自车速度分段持续时间 ev_t<br />
                        <i class="place"></i>自车轨迹形态分段持续时间
                        et_t，目标初始x坐标 op_x<br />
                        <i class="place"></i>目标初始y坐标
                        op_y，目标初始速度V1(km/h) ov<br />
                        <i class="place"></i>目标速度分段持续时间(s)
                        ov_t，目标轨迹形态分段持续时间(s) ot_t<br />
                        3.目标物有关因子中括号数字代表某一个目标物：ov[0]代表第一个目标物初始速度，
                        ov[1]代表第二个目标物的初始速度，以此类推<br />
                        4.时间有关因子中括号代表某一段时间：自车轨迹分三段的轨迹中ev_t[0]代表自车第一段轨迹的持续时间,
                        ev_t[1]代表第二段轨迹的持续时间，以此类推<br />
                        5.目标物的时间因子同时出现是前面的中括号控制目标物，后一个轨迹分段<br />
                        6.这是对每一段轨迹的限制，目标纵向加速度应该和行驶速度状态每段对齐，
                        目标横向加速度应该和轨迹形态对齐<br />
                        7.格式说明：需要连续输入的3个输入框，其值分别为a、b、c，
                        需同时满足：b>a，c>0，b-a的差能被c整除，(b-a)/c&lt;20<br />
                    </div>
                </el-collapse-item>
            </el-collapse>
        </el-form>
    </div>
</template>

<script>
//import  from '';

/* 
自车3个、目标物5个标识位,x、y、初始速度,新增加速度，x、y可为负，其余为正
是2或4就对应3个input
两个加速度为新增，如果是基本值，直接展示，如果是array，数组元素是基本值的直接展示，是二维数组的3个input
解释的展示
*/

// 2923ab09-f051-4226-8e61-7573c19b523d aliyun-dev
// 这是 70环境的  Bearer dd26d02c-7284-4080-8d1d-a4d444cb5402

// 校验最多2位小数的非负数
let validateNum = (rule, value, callback) => {
    !/^(0|[1-9][0-9]*)(\.\d{1,2})?$/.test(value) &&
        callback(new Error(rule.message));
    callback();
};
// 校验最多2位小数-可为负
let validateNumA = (rule, value, callback) => {
    !/^(-?(0|[1-9][0-9]*))(\.\d{1,2})?$/.test(value) &&
        callback(new Error(rule.message));
    callback();
};
// 校验最多2位小数的正数
let isMoreThan0 = (rule, value, callback) => {
    if (value <= 0) {
        callback(new Error(rule.message));
        return;
    }
    !/^(0|[1-9][0-9]*)(\.\d{1,2})?$/.test(value) &&
        callback(new Error(rule.message));
    callback();
};

export default {
    name: "generalizationDetail", // 泛化信息
    components: {},
    data() {
        return {
            scenarioWeatherList: [], // 天气情况
            scenarioVehicleModelList: [], // 车辆模型
            speedStateList: [], // 速度形态
            trajectoryList: [], // 轨迹形态
            obsTypeList: [], // 目标物模型
            // targetDirectionList: [], // 目标方向
            scenarioRoadTypeList: [], // 道路类型
            scenarioRadiusCurvatureList: [], // 泛化模板车道线曲率半径
            formula: {}, // 公式集合
            form: {
                scenarioTime: "", // 场景发生时刻
                scenarioWeather: "", // 天气
                scenarioVehicleModel: "", // 车辆模型
                id: "", // id
                sceneId: "", // 场景编号
                scenarioResume: "", // 场景简述
                sceneDetailedDescription: "", // 场景描述
                scenarioRoadType: "", // 道路类型
                scenarioRadiusCurvature: "", // 车道线曲率半径
                scenarioRadiusCurvatureView: [], // 车道线曲率半径-展示用
                egoVelocityStatus: "", // 自车行驶速度状态
                egoStartX: "", // 自车初始X坐标
                egoStartX1: "", // 自车初始X坐标
                egoStartX2: "", // 自车初始X坐标
                egoStartX3: "", // 自车初始X坐标-间隔
                egoStartY: "", // 自车初始Y坐标
                egoStartY1: "", // 自车初始Y坐标
                egoStartY2: "", // 自车初始Y坐标
                egoStartY3: "", // 自车初始Y坐标-间隔
                egoStartVelocity: "", // 自车初始速度
                egoStartVelocity1: "", // 自车初始速度
                egoStartVelocity2: "", // 自车初始速度
                egoStartVelocity3: "", // 自车初始速度-间隔
                egoTrajectory: "", // 自车轨迹形态
                egoDurationTime: "", // 自车轨迹持续时间
                egoTrajectoryTime: "", // 自车轨迹形态分段持续时间
                // obsStartX: "", // 目标物初始x坐标
                // obsStartY: "", // 目标物初始y坐标
                // obsStartVelocity: "", // 目标物初始速度
                // obsStartVelocity1: "", // 目标物初始速度
                // obsStartVelocity2: "", // 目标物初始速度
                // obsStartVelocity3: "", // 目标物初始速度
                // obsVelocityStatus: "", // 目标物行驶速度状态
                // obsTrajectory: "", // 目标物轨迹形态
                // obsDurationTime: "", // 目标物轨迹持续时间
                // obsTrailTime: "", // 目标物轨迹形态分段持续时间
                // obsHeadingAngleRel: "", // 目标物相对自车航向角
                // obsLateralAcceleration: "", // 目标物最大横向加速度(m/s²)
                // obsLongitudinalAcceleration: "", // 目标物最大纵向加速度(m/s²)
                listMb: [], // 目标物数组
            },
            generalizationType: {}, // 标识对象
            rules: {
                scenarioTime: [
                    { required: true, message: "请选择", trigger: "change" },
                ],
                scenarioWeather: [
                    { required: true, message: "请选择", trigger: "change" },
                ],
                // scenarioVehicleModel: [
                //     { required: true, message: "请选择", trigger: "change" },
                // ],
                scenarioResume: [
                    { required: true, message: "请选择", trigger: "change" },
                ],
                sceneDetailedDescription: [
                    { required: true, message: "请选择", trigger: "change" },
                ],
                // egoVelocityStatus: [
                //     { required: true, message: "请选择", trigger: "change" },
                // ],
                egoStartX1: [
                    { required: true, message: "请输入", trigger: "blur" },
                    {
                        validator: validateNumA,
                        message: "请输入最多带有2位小数的数字",
                        trigger: ["blur"],
                    },
                ],
                egoStartX2: [
                    { required: true, message: "请输入", trigger: "blur" },
                    {
                        validator: validateNumA,
                        message: "请输入最多带有2位小数的数字",
                        trigger: ["blur"],
                    },
                ],
                egoStartX3: [
                    { required: true, message: "请输入", trigger: "blur" },
                    {
                        validator: isMoreThan0,
                        message: "请输入最多带有2位小数的正数",
                        trigger: ["blur"],
                    },
                ],
                egoStartY1: [
                    { required: true, message: "请输入", trigger: "blur" },
                    {
                        validator: validateNumA,
                        message: "请输入最多带有2位小数的数字",
                        trigger: ["blur"],
                    },
                ],
                egoStartY2: [
                    { required: true, message: "请输入", trigger: "blur" },
                    {
                        validator: validateNumA,
                        message: "请输入最多带有2位小数的数字",
                        trigger: ["blur"],
                    },
                ],
                egoStartY3: [
                    { required: true, message: "请输入", trigger: "blur" },
                    {
                        validator: isMoreThan0,
                        message: "请输入最多带有2位小数的正数",
                        trigger: ["blur"],
                    },
                ],
                egoStartVelocity1: [
                    { required: true, message: "请输入", trigger: "blur" },
                    {
                        validator: validateNum,
                        message: "请输入最多带有2位小数的非负数",
                        trigger: ["blur"],
                    },
                ],
                egoStartVelocity2: [
                    { required: true, message: "请输入", trigger: "blur" },
                    {
                        validator: validateNum,
                        message: "请输入最多带有2位小数的非负数",
                        trigger: ["blur"],
                    },
                ],
                egoStartVelocity3: [
                    { required: true, message: "请输入", trigger: "blur" },
                    {
                        validator: isMoreThan0,
                        message: "请输入最多带有2位小数的正数",
                        trigger: ["blur"],
                    },
                ],
                // egoTrajectory: [
                //     { required: true, message: "请选择", trigger: "change" },
                // ],
                // egoTrajectoryTime: [
                //     { required: true, message: "请选择", trigger: "change" },
                // ],
            },
            rulesA: {
                obsStartX1: [
                    { required: true, message: "请输入", trigger: "blur" },
                    {
                        validator: validateNumA,
                        message: "请输入最多带有2位小数的数字",
                        trigger: ["blur"],
                    },
                ],
                obsStartX2: [
                    { required: true, message: "请输入", trigger: "blur" },
                    {
                        validator: validateNumA,
                        message: "请输入最多带有2位小数的数字",
                        trigger: ["blur"],
                    },
                ],
                obsStartX3: [
                    { required: true, message: "请输入", trigger: "blur" },
                    {
                        validator: isMoreThan0,
                        message: "请输入最多带有2位小数的正数",
                        trigger: ["blur"],
                    },
                ],
                obsStartY1: [
                    { required: true, message: "请输入", trigger: "blur" },
                    {
                        validator: validateNumA,
                        message: "请输入最多带有2位小数的数字",
                        trigger: ["blur"],
                    },
                ],
                obsStartY2: [
                    { required: true, message: "请输入", trigger: "blur" },
                    {
                        validator: validateNumA,
                        message: "请输入最多带有2位小数的数字",
                        trigger: ["blur"],
                    },
                ],
                obsStart3Y: [
                    { required: true, message: "请输入", trigger: "blur" },
                    {
                        validator: isMoreThan0,
                        message: "请输入最多带有2位小数的正数",
                        trigger: ["blur"],
                    },
                ],
                obsStartVelocity1: [
                    { required: true, message: "请输入", trigger: "blur" },
                    {
                        validator: validateNum,
                        message: "请输入最多带有2位小数的非负数",
                        trigger: ["blur"],
                    },
                ],
                obsStartVelocity2: [
                    { required: true, message: "请输入", trigger: "blur" },
                    {
                        validator: validateNum,
                        message: "请输入最多带有2位小数的非负数",
                        trigger: ["blur"],
                    },
                ],
                obsStartVelocity3: [
                    { required: true, message: "请输入", trigger: "blur" },
                    {
                        validator: isMoreThan0,
                        message: "请输入最多带有2位小数的正数",
                        trigger: ["blur"],
                    },
                ],
                obsLateralAcceleration: [
                    { required: true, message: "请输入", trigger: "blur" },
                ],
                obsLongitudinalAcceleration: [
                    { required: true, message: "请输入", trigger: "blur" },
                ],
                // obsVelocityStatus: [
                //     { required: true, message: "请选择", trigger: "change" },
                // ],
                // obsTrailTime: [
                //     { required: true, message: "请选择", trigger: "change" },
                // ],
                // obsHeadingAngleRel: [
                //     { required: true, message: "请选择", trigger: "change" },
                // ],
            },
            activeNames: [""],
        };
    },

    props: {
        id: {
            type: String,
            default: "",
        },
        curId: {
            type: String,
            default: "",
        },
        exampleId: {
            type: String,
            default: "",
        },
        ruleName: {
            type: String,
            default: "",
        },
        rulesId: {
            type: String,
            default: "",
        },
        ruleNameArrayS: {
            type: Array,
            default: function () {
                return [];
            },
        },
        genUrlType: {
            type: Number,
            default: 1,
        },
        disabled: {
            type: Boolean,
            default: false,
        },
    },

    methods: {
        getInfo() {
            let url = this.$api.sceneLibrary.querySceneGeneralTemplateById;
            let id = this.id;

            if (this.genUrlType === 2) {
                url = this.$api.sceneLibrary.queryGeneralTemplateByFh;
                id = this.exampleId;
            }

            this.$axios({
                method: "post",
                url,
                data: { id },
            }).then((res) => {
                if (res.code == 200 && res.info) {
                    // res.info.listMb[0].obsLateralAcceleration =
                    //     "[-1,[2,4,1],-1,[1,2,3],-1]|ovaslkdkjhlaskjdlkj";
                    // res.info.listMb[0].generalizationType =
                    //     '{"obsStartVelocity":2,"obsLongitudinalAcceleration":2,"obsLateralAcceleration":4}';
                    if (this.genUrlType === 2 && res.info.isTure === "1") {
                        this.$message.warning("该模板已变更");
                    }

                    let listMb = res.info.listMb;
                    res.info.listMb = [];
                    Object.assign(this.form, res.info);
                    this.$emit("getGeneralizationSceneId", res.info.sceneId);

                    if (
                        res.info.scenarioRoadType === "2" ||
                        res.info.scenarioRoadType === "3"
                    ) {
                        // scenarioRoadTypes 2or3 时，车道线曲率半径需要展示，并全部选中
                        let list = res.info.scenarioRadiusCurvature.split(",");
                        list.forEach((i) => {
                            this.scenarioRadiusCurvatureList.push({
                                code: i,
                                caption: i,
                            });
                        });
                        this.form.scenarioRadiusCurvatureView = list;
                        this.rules.scenarioRadiusCurvatureView = [
                            {
                                required: true,
                                message: "请选择",
                                trigger: "change",
                            },
                        ];
                    }

                    // 处理标识
                    this.generalizationType = JSON.parse(
                        res.info.generalizationType
                    );

                    this.handleGeneralizationType(
                        this.generalizationType,
                        this.form,
                        res.info
                    );

                    if (listMb.length > 0) {
                        listMb.forEach((item, i) => {
                            let generalizationType = JSON.parse(
                                item.generalizationType
                            );

                            this.handleGeneralizationType(
                                generalizationType,
                                item,
                                item,
                                true
                            );
                        });

                        this.form.listMb = listMb;
                    }
                } else {
                    this.$message.error(res.message || "获取模板详情失败");
                }
            });
        },
        done() {
            let i = 0;
            this.$refs.form.validate((valid) => {
                if (valid) {
                    i++;
                } else {
                    console.log("校验");
                }
            });

            if (this.form.listMb.length > 0) {
                for (let index = 0; index < this.form.listMb.length; index++) {
                    let ref = "form" + index;
                    this.$refs[ref][0].validate((valid) => {
                        if (valid) {
                            i++;
                        } else {
                            console.log("校验" + i);
                        }
                    });
                }
            }

            if (i >= 1 + this.form.listMb.length) {
                // console.log(666);
                let isTrue = this.checkEditKey();
                if (!isTrue) return;

                let data = {};
                Object.keys(this.form).forEach((k) => {
                    if (k != "listMb") {
                        data[k] = this.form[k];
                    }
                });

                this.generalizationTypeToData(
                    this.generalizationType,
                    data,
                    this.form
                );

                data.listMb = [];

                for (let index = 0; index < this.form.listMb.length; index++) {
                    let ele = this.form.listMb[index];
                    let obj = Object.assign({}, ele);
                    let generalizationType = JSON.parse(ele.generalizationType);
                    this.generalizationTypeToData(
                        generalizationType,
                        obj,
                        ele,
                        true
                    );
                    data.listMb[index] = obj;
                }

                let obj = {
                    curId: this.curId,
                    ruleName: this.ruleName,
                    rulesId: this.rulesId,
                    ruleNameArrayS: this.ruleNameArrayS,
                };
                this.$emit("generalizationBegin");

                this.$instance({
                    method: "post",
                    noLoading: true,
                    url: this.$api.sceneLibrary.saveSceneGeneralExample,
                    data,
                })
                    .then((res) => {
                        if (res.code == 200 && res.info) {
                            /* setTimeout(() => {
                            // 此写法有问题 覆盖?不全部执行? 只执行最后一个
                            // this.$emit("generalizationDone", res.info, obj);
                        }, 60000); */
                            this.$parent.$parent.generalizationDone(
                                res.info,
                                obj
                            );
                            this.$message.success("泛化成功");
                        } else {
                            this.$parent.$parent.generalizationDone(
                                null,
                                obj,
                                false
                            );
                            this.$message.error(res.message || "泛化失败");
                        }
                    })
                    .catch((error) => {
                        this.$parent.$parent.generalizationDone(
                            null,
                            obj,
                            false
                        );
                        this.$message.error("泛化失败");
                    });
            }
        },
        // 数据转换展示
        dataToView(arr, val) {
            let info = "";
            let pre = "";
            if (!val) return;
            val.split("").forEach((ele) => {
                let v = arr.find((i) => i.code === ele);
                if (v) v = v.caption;
                if (v && v != pre) {
                    pre = v;
                    info += v + ",";
                }
            });
            if (info) {
                info = info.slice(0, -1);
            }
            return info;
        },

        /**
         * fn:处理标识
         * arguments:标识对象，目标对象，获取属性对应的值的对象，是否已经处理过一轮(即是否处理过自车)
         * handled（针对处理目标物时自车已处理过了，需过滤）即 自车false 目标物true
         */
        handleGeneralizationType(obj, target, data, handled = false) {
            // 自车需要处理的标识字段
            let egoArr = ["egoStartX", "egoStartY", "egoStartVelocity"];
            let obsArr = [
                "obsStartX",
                "obsStartY",
                "obsStartVelocity",
                "obsLateralAcceleration",
                "obsLongitudinalAcceleration",
            ];

            let rule = [
                { required: true, message: "请输入", trigger: "blur" },
                {
                    validator: validateNum,
                    message: "请输入最多带有2位小数的非负数",
                    trigger: ["blur"],
                },
            ];

            let rule1 = [
                { required: true, message: "请输入", trigger: "blur" },
                {
                    validator: isMoreThan0,
                    message: "请输入最多带有2位小数的正数",
                    trigger: ["blur"],
                },
            ];

            let handleArr = egoArr;
            if (handled) handleArr = obsArr;

            handleArr.forEach((item) => {
                if (obj[item] === 2) {
                    if (
                        item === "obsLateralAcceleration" ||
                        item === "obsLongitudinalAcceleration"
                    ) {
                        // [-1,[2,4,1],-1,-1]
                        let arr = JSON.parse(data[item]);
                        target[item + "View"] = arr;

                        arr.forEach((ele, i) => {
                            if (Array.isArray(ele)) {
                                target[item + i + "1"] = ele[0];
                                target[item + i + "2"] = ele[1];
                                target[item + i + "3"] = ele[2];

                                this.rulesA[item + i + "1"] = rule;
                                this.rulesA[item + i + "2"] = rule;
                                this.rulesA[item + i + "3"] = rule1;
                            }
                        });
                    } else {
                        // "[30,80,10]"
                        let arr = JSON.parse(data[item]);
                        target[item + "1"] = arr[0];
                        target[item + "2"] = arr[1];
                        target[item + "3"] = arr[2];
                    }
                } else if (obj[item] === 4) {
                    if (
                        item === "obsLateralAcceleration" ||
                        item === "obsLongitudinalAcceleration"
                    ) {
                        let brr = data[item].split("|");
                        let arr = JSON.parse(brr[0]);
                        target[item + "View"] = arr;

                        arr.forEach((ele, i) => {
                            if (Array.isArray(ele)) {
                                target[item + i + "1"] = ele[0];
                                target[item + i + "2"] = ele[1];
                                target[item + i + "3"] = ele[2];

                                this.rulesA[item + i + "1"] = rule;
                                this.rulesA[item + i + "2"] = rule;
                                this.rulesA[item + i + "3"] = rule1;
                            }
                        });

                        target[item + "Formula"] = brr[1];
                    } else {
                        // "[30,80,10]|0<ov[0]-ov[1]<=20"
                        let brr = data[item].split("|");
                        let arr = JSON.parse(brr[0]);

                        target[item + "1"] = arr[0];
                        target[item + "2"] = arr[1];
                        target[item + "3"] = arr[2];

                        // 对应公式
                        target[item + "Formula"] = brr[1];
                    }
                } else {
                    // 处理不可编辑时，form中rule的校验问题
                    target[item + "1"] = 0;
                    target[item + "2"] = 0;
                    target[item + "3"] = 0;
                }
            });
        },
        // 参数同上 handleGeneralizationType
        generalizationTypeToData(obj, target, data, handled = false) {
            let egoArr = ["egoStartX", "egoStartY", "egoStartVelocity"];
            let obsArr = [
                "obsStartX",
                "obsStartY",
                "obsStartVelocity",
                "obsLateralAcceleration",
                "obsLongitudinalAcceleration",
            ];

            let handleArr = egoArr;
            if (handled) handleArr = obsArr;

            handleArr.forEach((item) => {
                if (obj[item] === 2) {
                    if (
                        item === "obsLateralAcceleration" ||
                        item === "obsLongitudinalAcceleration"
                    ) {
                        let oriArr = data[item + "View"];
                        let s = "";
                        oriArr.forEach((ele, i) => {
                            if (Array.isArray(ele)) {
                                s += `[${data[item + i + "1"]},${
                                    data[item + i + "2"]
                                },${data[item + i + "3"]}],`;
                            } else {
                                s += ele + ",";
                            }
                        });
                        target[item] = `[${s.slice(0, -1)}]`;
                    } else {
                        target[item] = `[${data[item + "1"]},${
                            data[item + "2"]
                        },${data[item + "3"]}]`;
                    }
                } else if (obj[item] === 4) {
                    if (
                        item === "obsLateralAcceleration" ||
                        item === "obsLongitudinalAcceleration"
                    ) {
                        let oriArr = data[item + "View"];
                        let s = "";
                        oriArr.forEach((ele, i) => {
                            if (Array.isArray(ele)) {
                                s += `[${data[item + i + "1"]},${
                                    data[item + i + "2"]
                                },${data[item + i + "3"]}],`;
                            } else {
                                s += ele + ",";
                            }
                        });
                        target[item] = `[${s.slice(0, -1)}]|${
                            data[item + "Formula"]
                        }`;
                    } else {
                        target[item] = `[${data[item + "1"]},${
                            data[item + "2"]
                        },${data[item + "3"]}]|${data[item + "Formula"]}`;
                    }
                }
            });
        },
        // 校验可编辑的字段 3个input
        checkEditKey() {
            let isTrue = true;
            let egoArr = ["egoStartX", "egoStartY", "egoStartVelocity"];
            let egoInfoArr = ["自车初始X坐标", "自车初始Y坐标", "自车初始速度"];
            let obsArr = [
                "obsStartX",
                "obsStartY",
                "obsStartVelocity",
                "obsLateralAcceleration",
                "obsLongitudinalAcceleration",
            ];
            let obsInfoArr = [
                "目标物初始x坐标",
                "目标物初始y坐标",
                "目标物初始速度",
                "目标物最大横向加速度",
                "目标物最大纵向加速度",
            ];

            egoArr.forEach((item, index) => {
                if (
                    this.generalizationType[item] === 2 ||
                    this.generalizationType[item] === 4
                ) {
                    let a = this.form[item + "1"];
                    let b = this.form[item + "2"];
                    let c = this.form[item + "3"];
                    let result = this.checkRule(a, b, c);
                    if (!result) {
                        isTrue = false;
                        let timer = setTimeout(() => {
                            this.$message.error(
                                `${egoInfoArr[index]}数据格式错误，参考说明中的第7条`
                            );
                            clearTimeout(timer);
                        }, 100);
                    }
                }
            });

            let listMb = this.form.listMb;

            obsArr.forEach((item, index) => {
                listMb.forEach((ele, i) => {
                    let generalizationType = JSON.parse(ele.generalizationType);
                    if (
                        generalizationType[item] === 2 ||
                        generalizationType[item] === 4
                    ) {
                        if (
                            item === "obsLateralAcceleration" ||
                            item === "obsLongitudinalAcceleration"
                        ) {
                            let oriArr = ele[item + "View"];
                            oriArr.forEach((el, j) => {
                                if (Array.isArray(el)) {
                                    let a = ele[item + j + "1"];
                                    let b = ele[item + j + "2"];
                                    let c = ele[item + j + "3"];
                                    let result = this.checkRule(a, b, c);
                                    if (!result) {
                                        isTrue = false;
                                        let timer = setTimeout(() => {
                                            this.$message.error(
                                                `目标物${i + 1}中${
                                                    obsInfoArr[index]
                                                }数据格式错误，参考说明中的第7条`
                                            );
                                            clearTimeout(timer);
                                        }, 100);
                                    }
                                }
                            });
                        } else {
                            let a = ele[item + "1"];
                            let b = ele[item + "2"];
                            let c = ele[item + "3"];
                            let result = this.checkRule(a, b, c);
                            if (!result) {
                                isTrue = false;
                                let timer = setTimeout(() => {
                                    this.$message.error(
                                        `${obsInfoArr[index]}数据格式错误，参考说明中的第7条`
                                    );
                                    clearTimeout(timer);
                                }, 100);
                            }
                        }
                    }
                });
            });

            return isTrue;
        },
        // a,b,c, b比a大，c大于0，差除以c为整数
        checkRule(x, y, z) {
            let a = x * 100;
            let b = y * 100;
            let c = z * 100;
            let ba = b - a;
            if (ba <= 0 || c <= 0) return false;
            if (ba % c != 0 || ba / c >= 20) return false;
            return true;
        },
        changeTemplate() {
            this.$emit("changeTemplate");
        },
    },

    async mounted() {
        await this.$dicsListsInit({
            scenarioWeatherList: "scenarioWeather",
            scenarioVehicleModelList: "scenarioVehicleModel",
            scenarioRoadTypeList: "scenarioRoadType",
            speedStateList: "speedState",
            trajectoryList: "trajectory",
            obsTypeList: "obsType",
            // targetDirectionList: "targetDirection",
            // scenarioRadiusCurvatureList: "scenarioRadiusCurvature",
        });

        this.getInfo();
    },
};
</script>

<style lang='less' scoped>
.generalizationDetailPanel {
    padding-top: 24px;

    .el-row:nth-child(odd) {
        background-color: #f9f9f9;
    }

    .el-form {
        /deep/ .el-input,
        .el-select {
            width: 100%;
        }

        .el-form-item {
            margin-top: 11px;
            margin-bottom: 11px;
        }

        .infos {
            font-weight: normal;
            word-break: break-all;
        }

        .changeBtn {
            width: 225px;
            margin-bottom: 22px;
            text-align: right;
        }

        .info {
            display: flex;
            line-height: 32px;
            // margin: 0 12px 22px 0;
            margin: 11px 12px 11px 0;
            word-break: break-all;

            span {
                display: block;
                width: 225px;
                padding-right: 20px;
                text-align: right;
            }

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

        .mr0 {
            margin-right: 0;
        }

        .boxA,
        .boxB {
            display: flex;
            flex-wrap: wrap;

            .line {
                display: block;
                width: 10px;
                margin: 27px 6px 0;
                border-top: 1px solid #606266;
            }

            /deep/ .itemA.el-form-item {
                width: calc(50% - 12px + 112.5px);
            }

            /deep/ .itemB.el-form-item {
                width: calc(50% - 12px - 112.5px);
            }

            .itemB {
                /deep/ .el-form-item__content {
                    margin-left: 0 !important;
                }
            }

            /deep/ .el-form-item {
                .el-form-item__content {
                    display: flex;
                }
            }
        }

        .boxB {
            /deep/ .itemB.el-form-item {
                width: calc(15% - 18px - 36px);
            }
        }

        .obsInfo {
            line-height: 54px;
            padding: 0 6px;
            word-break: break-all;
        }

        .required {
            &:before {
                content: "*";
                color: #f56c6c;
                margin-right: 4px;
            }
        }
    }

    .collapseInfo {
        padding-left: 18px;
        line-height: 24px;

        .place {
            padding-left: 10px;
        }
    }

    /deep/
        .el-form-item.is-required:not(.is-no-asterisk)
        .el-form-item__label-wrap
        > .el-form-item__label:before,
    /deep/
        .el-form-item.is-required:not(.is-no-asterisk)
        > .el-form-item__label:before {
        content: "";
    }
}
</style>