<template>
    <div class="devfiling">
        <div v-if="!showDetail">
        <div class="search-wrap">
            <!-- <el-select v-model="devSn" style="width: 156px;margin-right: 15px" size="small" placeholder="设备名称">
                <el-option
                v-for="item in options"
                :key="item.value"
                :label="item.label"
                :value="item.value">
                </el-option>
            </el-select> -->
            <!-- <el-button type="primary" size="small" @click="selectSchemeRecord">查询</el-button> -->
            <el-button type="primary" size="small" icon="el-icon-plus" @click="showDialog = true">
                <!-- 新增 -->
                {{ $t('message.lifter.add') }}
            </el-button>
        </div>
        <div class="devfilling-table-wrap">
            <el-table
                class="tables"
                :data="tableData"
                height="600"
                style="width: 100%;">
                <!-- 设备名称 -->
                <el-table-column prop="devName" :label="$t('message.lifter.devName')" align="center">
                </el-table-column>
                <!-- 设备型号 -->
                <el-table-column prop="devModel" :label="$t('message.lifter.equipmentModel')" align="center">
                </el-table-column>
                <!-- <el-table-column prop="sceneNumber" label="现场编号" align="center">
                </el-table-column>
                <el-table-column prop="manufacturingLicenseNo" label="制造许可证编号"></el-table-column>
                <el-table-column
                    prop="structureType"
                    label="结构形式"
                    align="center"
                >
                </el-table-column>
                <el-table-column
                    prop="installEnterprise"
                    label="安装单位"
                    align="center"
                >
                </el-table-column>
                <el-table-column
                    prop="leaseEnterprise"
                    label="租赁单位"
                    align="center"
                >
                </el-table-column>
                <el-table-column prop="leaveFactoryNo" label="出厂编号" align="center"></el-table-column>
                <el-table-column
                    prop="leaveFactoryTime"
                    label="出厂时间"
                    align="center"
                >
                </el-table-column> -->

                <!-- 进场时间 -->
                <el-table-column prop="enterTime" :label="$t('message.lifter.mobilizationTime')"></el-table-column>
                <!-- <el-table-column prop="productionEnterprise" label="生产厂家"></el-table-column>
                <el-table-column prop="propertyRightFilingNo" label="产权备案号"></el-table-column>
                <el-table-column prop="ratedLoadCapacity" label="额定载重量"></el-table-column> -->

                <!-- 状态 -->
                <el-table-column prop="status" :label="$t('message.lifter.state')">
                    <template slot-scope="scope">
                        <!-- 使用  停用  拆除 -->
                        {{scope.row.status == 1 ? $t('message.lifter.use') :scope.row.status == 2 ? $t('message.lifter.deactivate') : scope.row.status == 3 ? $t('message.lifter.dismantle') :""}}
                    </template>
                </el-table-column>
                <!-- 添加时间 -->
                <el-table-column prop="addTime" :label="$t('message.lifter.addTime')"></el-table-column>
                <!-- 操作 -->
                <el-table-column width="200" :label="$t('message.lifter.operation')">
                <template slot-scope="scope">
                    <el-button
                    type="text"
                    size="mini"
                    class="primary-btn"
                    icon="el-icon-document"
                    @click="previewData(scope.row)"
                    >
                    <!-- 详细 -->
                    {{ $t('message.lifter.detailed') }}
                    </el-button>
                    <!-- <el-button
                    type="text"
                    size="mini"
                    class="primary-btn"
                    icon="el-icon-edit-outline"
                    @click="editData(scope.row)"
                    >编辑</el-button> -->
                    <el-button
                    size="mini"
                    type="text"
                    class="delete-btn"
                    icon="el-icon-delete"
                    @click="deleteData(scope.row)"
                    >
                    <!-- 删除 -->
                    {{ $t('message.lifter.delete') }}
                    </el-button>
                </template>
                </el-table-column>
            </el-table>
            <el-pagination
                class="pagerBox"
                @size-change="handleSizeChange"
                @current-change="handleCurrentChange"
                :current-page="pageNo"
                :page-sizes="$store.state.PAGESIZRS"
                :page-size="pageSize"
                layout="total, sizes, prev, pager, next"
                :total="total"
                background
            ></el-pagination>
        </div>

        <formDialog v-if="showDialog" :title="dialogTitle" @closeDialog="closeDialog">
            <div slot="content" class="dialog-content">
                <vue-scroll style="width: 100%;height: 520px; padding-bottom: 30px;">
                    <el-form
                        v-show="step == 1"
                        ref="addForm"
                        class="dialog-form"
                        label-position="right"
                        label-width="120px"
                        :model="formData"
                        :rules="rules"
                        size="medium">
                        <!-- 设备型号 -->
                        <el-form-item :label="$t('message.lifter.equipmentModel')" prop="devModel" required>
                            <el-input
                                :disabled="isDisabled"
                                v-model="formData.devModel"
                                :placeholder="$t('message.lifter.pleaseEnter')"
                            ></el-input>
                        </el-form-item>
                        <!-- 首次安装高度 -->
                        <el-form-item :label="$t('message.lifter.firstInstallHeight')" prop="firstInstallHeight" required>
                            <el-input
                                :disabled="isDisabled"
                                v-model="formData.firstInstallHeight"
                                :placeholder="$t('message.lifter.pleaseEnter')"
                            ></el-input>
                        </el-form-item>
                        <!-- 最终安装高度 -->
                        <el-form-item :label="$t('message.lifter.lastInstallHeight')" prop="finalInstallHeight" required>
                            <el-input
                                :disabled="isDisabled"
                                v-model="formData.finalInstallHeight"
                                :placeholder="$t('message.lifter.pleaseEnter')"
                            ></el-input>
                        </el-form-item>
                        <!-- 计划进场时间 -->
                        <el-form-item :label="$t('message.lifter.planMobilizationTime')" prop="planEnterTime" required>
                            <el-date-picker
                                value-format="yyyy-MM-dd"
                                :disabled="isDisabled"
                                :picker-options="pickerOptions"
                                v-model="formData.planEnterTime"
                                type="date"
                                :placeholder="$t('message.lifter.selectDateAndTime')"
                                style="width: 100%"
                            >
                            </el-date-picker>
                        </el-form-item>
                        <!-- 计划安装时间 -->
                        <el-form-item :label="$t('message.lifter.planInstallTime')" prop="planInstallTime" required>
                            <el-date-picker
                                value-format="yyyy-MM-dd"
                                :disabled="isDisabled"
                                :picker-options="pickerOptions"
                                v-model="formData.planInstallTime"
                                type="date"
                                :placeholder="$t('message.lifter.selectDateAndTime')"
                                style="width: 100%"
                            >
                            </el-date-picker>
                        </el-form-item>
                        <!-- 计划拆除时间 -->
                        <el-form-item :label="$t('message.lifter.planDismantleTime')" prop="planDismantleTime" required>
                            <el-date-picker
                                value-format="yyyy-MM-dd"
                                :disabled="isDisabled"
                                :picker-options="pickerOptions"
                                v-model="formData.planDismantleTime"
                                type="date"
                                :placeholder="$t('message.lifter.selectDateAndTime')"
                                style="width: 100%"
                            >
                            </el-date-picker>
                        </el-form-item>
                        <!-- 现场编号 -->
                        <el-form-item :label="$t('message.lifter.siteNumber')" prop="sceneNumber" required>
                            <el-input
                                :disabled="isDisabled"
                                v-model="formData.sceneNumber"
                                :placeholder="$t('message.lifter.pleaseEnter')"
                            ></el-input>
                        </el-form-item>
                        <!-- <el-form-item v-if="formData.jackingList && formData.jackingList.length>0" class="list-title" label="顶升列表" prop="jackingList" style="text-align: left;">
                        </el-form-item> -->
                        <div class="form-list" v-for="(item,index) in formData.jackingList" :key="index">
                            <div class="list-label">{{$t('message.lifter.theFirst')}} {{item.sequenceNo}} {{$t('message.lifter.jackingTime')}}</div>
                            <el-date-picker
                                value-format="yyyy-MM-dd"
                                :disabled="isDisabled"
                                :picker-options="pickerOptions"
                                v-model="item.jackingTime"
                                type="date"
                                :placeholder="$t('message.lifter.selectDateAndTime')"
                                size="small"
                            >
                            </el-date-picker>
                            <i v-if="index !== 0 && !isDisabled" class="el-icon-remove deelet-btn" @click="deleteTime(index)"></i>
                            <div v-if="formData.jackingList.length-1 == index && !isDisabled" class="add-item" @click="addTime">
                                <!-- 新增 -->
                                {{$t('message.lifter.add')}}
                            </div>
                        </div>
                    </el-form>

                    <el-form
                        v-show="step == 2"
                        ref="addForm2"
                        class="dialog-form"
                        label-position="right"
                        label-width="140px"
                        :model="formData2"
                        :rules="rules2"
                        size="medium">
                        <!-- 设备名称 -->
                        <el-form-item :label="$t('message.lifter.devName')" prop="devName" required>
                            <el-input
                                :disabled="isDisabled2"
                                v-model="formData2.devName"
                                :placeholder="$t('message.lifter.pleaseEnter')"
                            ></el-input>
                        </el-form-item>
                        <!-- 设备编号 -->
                        <el-form-item :label="$t('message.lifter.devNumber')" prop="devSn" required>
                            <el-input
                                :disabled="isDisabled2"
                                v-model="formData2.devSn"
                                :placeholder="$t('message.lifter.pleaseEnter')"
                            ></el-input>
                        </el-form-item>
                        <!-- 结构形式 -->
                        <el-form-item :label="$t('message.lifter.structuralStyle')" prop="structureType" required>
                            <el-input
                                :disabled="isDisabled2"
                                v-model="formData2.structureType"
                                :placeholder="$t('message.lifter.pleaseEnter')"
                            ></el-input>
                        </el-form-item>
                        <!-- 制造许可证编号 -->
                        <el-form-item :label="$t('message.lifter.licenseNo')" prop="manufacturingLicenseNo" required>
                            <el-input
                                :disabled="isDisabled2"
                                v-model="formData2.manufacturingLicenseNo"
                                :placeholder="$t('message.lifter.pleaseEnter')"
                            ></el-input>
                        </el-form-item>
                        <!-- 产权备案号 -->
                        <el-form-item :label="$t('message.lifter.propertyNumber')" prop="propertyRightFilingNo" required>
                            <el-input
                                :disabled="isDisabled2"
                                v-model="formData2.propertyRightFilingNo"
                                :placeholder="$t('message.lifter.pleaseEnter')"
                            ></el-input>
                        </el-form-item>
                        <!-- 生产厂家 -->
                        <el-form-item :label="$t('message.lifter.manufacturer')" prop="productionEnterprise" required>
                            <el-input
                                :disabled="isDisabled2"
                                v-model="formData2.productionEnterprise"
                                :placeholder="$t('message.lifter.pleaseEnter')"
                            ></el-input>
                        </el-form-item>
                        <!-- 出厂时间 -->
                        <el-form-item :label="$t('message.lifter.deliveryTime')" prop="leaveFactoryTime" required>
                            <el-date-picker
                                value-format="yyyy-MM-dd"
                                :disabled="isDisabled2"
                                v-model="formData2.leaveFactoryTime"
                                type="date"
                                :placeholder="$t('message.lifter.selectDateAndTime')"
                                style="width: 100%"
                            >
                            </el-date-picker>
                        </el-form-item>
                        <!-- 出厂编号 -->
                        <el-form-item :label="$t('message.lifter.factoryNumber')" prop="leaveFactoryNo" required>
                            <el-input
                                :disabled="isDisabled2"
                                v-model="formData2.leaveFactoryNo"
                                :placeholder="$t('message.lifter.pleaseEnter')"
                            ></el-input>
                        </el-form-item>
                        <!-- 租赁单位 -->
                        <el-form-item :label="$t('message.lifter.rentalUnit')" prop="leaseEnterprise" required>
                            <el-input
                                :disabled="isDisabled2"
                                v-model="formData2.leaseEnterprise"
                                :placeholder="$t('message.lifter.pleaseEnter')"
                            ></el-input>
                        </el-form-item>
                        <!-- 安装单位 -->
                        <el-form-item :label="$t('message.lifter.installUnit')" prop="installEnterprise" required>
                            <el-input
                                :disabled="isDisabled2"
                                v-model="formData2.installEnterprise"
                                :placeholder="$t('message.lifter.pleaseEnter')"
                            ></el-input>
                        </el-form-item>
                        <!-- 进场时间 -->
                        <el-form-item :label="$t('message.lifter.mobilizationTime')" prop="enterTime" required>
                            <el-date-picker
                                value-format="yyyy-MM-dd"
                                :disabled="isDisabled2"
                                :picker-options="pickerOptions"
                                v-model="formData2.enterTime"
                                type="date"
                                :placeholder="$t('message.lifter.selectDateAndTime')"
                                style="width: 100%"
                            >
                            </el-date-picker>
                        </el-form-item>
                        <!-- 额定载重量 -->
                        <el-form-item :label="$t('message.lifter.ratedLoadCapacity')" prop="ratedLoadCapacity" required>
                            <el-input
                                :disabled="isDisabled2"
                                v-model="formData2.ratedLoadCapacity"
                                :placeholder="$t('message.lifter.pleaseEnter')"
                            ></el-input>
                        </el-form-item>
                        <!-- 设备状态 -->
                        <el-form-item :label="$t('message.lifter.equipmentStatus')" prop="status" required>
                            <!-- 请选择策划记录 -->
                             <el-select v-model="formData2.status" style="width: 100%" size="small" :placeholder="$t('message.lifter.selectPlanningRecord')">
                                <el-option
                                v-for="item in options2"
                                :key="item.id"
                                :label="item.statusName"
                                :value="item.id">
                                </el-option>
                            </el-select>
                        </el-form-item>
                    </el-form>
                </vue-scroll>
                <div class="btn-box" v-if="!isDisabled">
                    <!-- 取 消 -->
                    <el-button v-if="step == 1" class="cancle-btn cancleBtn" size="small" icon="el-icon-circle-close" @click="closeDialog">{{ $t('message.lifter.cancel') }}</el-button>
                    <!-- 下一步 -->
                    <el-button v-if="step == 1" type="primary" icon="el-icon-circle-check" size="small" @click="submitForm">{{ $t('message.lifter.nextStep') }}</el-button>
                    <!-- 确 定 -->
                    <el-button v-else type="primary" icon="el-icon-circle-check" size="small" @click="submitForm2">{{ $t('message.lifter.determine') }}</el-button>
                </div>
            </div>
        </formDialog>

        <formDialog v-if="showDialog2" :title="dialogTitle2" @closeDialog="closeDialog2">
            <div slot="content" class="dialog-content">
                <vue-scroll style="width: 100%;height: 520px; padding-bottom: 30px;">

                </vue-scroll>
                <div class="btn-box" v-if="!isDisabled2">
                    <!-- 取 消 -->
                    <el-button class="cancle-btn cancleBtn" size="small" icon="el-icon-circle-close" @click="closeDialog2">{{ $t('message.lifter.cancel') }}</el-button>
                    <!-- 确 定 -->
                    <el-button type="primary" icon="el-icon-circle-check" size="small" @click="submitForm2">{{ $t('message.lifter.determine') }}</el-button>
                </div>
            </div>
        </formDialog>
        </div>
        <div style="height: 100%" v-else>
            <!-- 备案详情 -->
            <el-page-header
                @back="goBack"
                :content="$t('message.lifter.filingDetails')"
                class="backText"
            ></el-page-header>
            <devFilingDetail :detailData="detailData" :devType="devType"></devFilingDetail>
        </div>
    </div>

</template>

<script>

import devFilingDetail from './../../projectFront/towerCrane/devFilingDetail.vue'
import {
  selectSchemeRecordApi,
  selectByIdSchemeRecordApi,
  selectRegisterRecordApi,
  addSchemeRecordApi,
  editSchemeRecordApi,
  deleteRegisterRecordApi,
  addRegisterRecordApi,
  deleteSchemeRecordApi
} from "@/assets/js/api/towerCrane";
import formDialog from './../workstation/compontents/formDialog.vue'
export default {
    components: {
        formDialog,
        devFilingDetail
    },
    data(){
        return {
            devSn: "",
            showDetail: false,
            options:[{
                label: "2",
                value: 0
            }],
            options2:[{
                id: 1,
                statusName: this.$t('message.lifter.use') // 使用
            },{
                id: 2,
                statusName: this.$t('message.lifter.deactivate') // 停用
            },{
                id: 3,
                statusName: this.$t('message.lifter.dismantle') // 拆除
            }],
            tableData: [],
            projectSn: "",
            pageNo: 1,
            pageSize: 10,
            total: 0,
            showDialog2: false,
            isDisabled2: false,
            pickerOptions: {
                disabledDate(time) {
                    return time.getTime() < Date.now() - 8.64e7;
                },
            },
            formData2:{
                enterTime: "",
                installEnterprise: "",
                leaseEnterprise: "",
                leaveFactoryNo: "",
                leaveFactoryTime: "",
                manufacturingLicenseNo: "",
                productionEnterprise: "",
                propertyRightFilingNo: "",
                ratedLoadCapacity: "",
                status: "",
                structureType: "",
                devName: "",
                devSn: "",
            },
            showDialog: false,
            dialogTitle: this.$t('message.lifter.newPlanningInfo'), // 新增策划信息
            dialogTitle2: this.$t('message.lifter.newEquipmentReg'), // 新增设备登记
            formData:{
                devModel: "",
                firstInstallHeight: "",
                finalInstallHeight: "",
                planDismantleTime: "",
                planEnterTime: "",
                planInstallTime: "",
                sceneNumber: "",
                jackingList:[{
                    jackingTime: "",
                    sequenceNo: 1
                }]
            },
            rules: {
                // 请输入设备型号
                devModel: [{ required: true, message: this.$t('message.lifter.rules01'), trigger: "blur" },
                { required: true, message: this.$t('message.lifter.rules01'), trigger: "change" }],
                // 请输入首次安装高度
                firstInstallHeight: [{ required: true, message: this.$t('message.lifter.rules02'), trigger: "blur" },
                { required: true, message: this.$t('message.lifter.rules02'), trigger: "change" }],
                // 请输入最终安装高度
                finalInstallHeight: [{ required: true, message: this.$t('message.lifter.rules03'), trigger: "blur" },
                { required: true, message: this.$t('message.lifter.rules03'), trigger: "change" }],
                // 请选择计划拆除时间
                planDismantleTime: [{ type: 'string',required: true,message: this.$t('message.lifter.rules04'),trigger: "blur" },
                { type: 'string',required: true,message: this.$t('message.lifter.rules04'),trigger: "change" }],
                // 请选择计划进场时间
                planEnterTime: [{ type: 'string',required: true,message: this.$t('message.lifter.rules05'),trigger: "blur" },
                { type: 'string',required: true,message: this.$t('message.lifter.rules05'),trigger: "change" }],
                // 请选择计划安装时间
                planInstallTime: [{ type: 'string',required: true,message: this.$t('message.lifter.rules06'),trigger: "blur" },
                { type: 'string',required: true,message: this.$t('message.lifter.rules06'),trigger: "change" }],
                // 请输入现场编号
                sceneNumber: [{ required: true, message: this.$t('message.lifter.rules07'), trigger: "blur" },
                { required: true, message: this.$t('message.lifter.rules07'), trigger: "change" }],
            },
            rules2: {
                // 请输入设备名称
                devName: [{ required: true, message: this.$t('message.lifter.rules08'), trigger: "blur" },
                { required: true, message: this.$t('message.lifter.rules08'), trigger: "change" }],
                // 请输入设备编号
                devSn: [{ required: true, message: this.$t('message.lifter.rules09'), trigger: "blur" },
                { required: true, message: this.$t('message.lifter.rules09'), trigger: "change" }],
                // 请输入结构形式
                structureType: [{ required: true, message: this.$t('message.lifter.rules10'), trigger: "blur" },
                { required: true, message: this.$t('message.lifter.rules10'), trigger: "change" }],
                // 请选择策划记录
                schemeId: [{ required: true, message: this.$t('message.lifter.rules11'), trigger: "blur" },
                { required: true, message: this.$t('message.lifter.rules11'), trigger: "change" }],
                // 请输入制造许可证编号
                manufacturingLicenseNo: [{ required: true, message: this.$t('message.lifter.rules12'), trigger: "blur" },
                { required: true, message: this.$t('message.lifter.rules12'), trigger: "change" }],
                // 请选择进场时间
                enterTime: [{ type: 'string',required: true,message: this.$t('message.lifter.rules13'),trigger: "blur" },
                { type: 'string',required: true,message: this.$t('message.lifter.rules13'),trigger: "change" }],
                // 请选择出厂时间
                leaveFactoryTime: [{ type: 'string',required: true,message: this.$t('message.lifter.rules14'),trigger: "blur" },
                { type: 'string',required: true,message: this.$t('message.lifter.rules14'),trigger: "change" }],
                // 请输入产权备案号
                propertyRightFilingNo: [{ required: true, message: this.$t('message.lifter.rules15'), trigger: "blur" },
                { required: true, message: this.$t('message.lifter.rules15'), trigger: "change" }],
                // 请输入额定载重量
                ratedLoadCapacity: [{ required: true, message: this.$t('message.lifter.rules16'), trigger: "blur" },
                { required: true, message: this.$t('message.lifter.rules16'), trigger: "change" }],
                // 请选择状态
                status: [{ required: true, message: this.$t('message.lifter.rules17'), trigger: "blur" },
                { required: true, message: this.$t('message.lifter.rules17'), trigger: "change" }],
                // 请输入租赁单位
                leaseEnterprise:[{ required: true, message: this.$t('message.lifter.rules18'), trigger: "blur" },
                { required: true, message: this.$t('message.lifter.rules18'), trigger: "change" }],
                // 请输入安装单位
                installEnterprise:[{ required: true, message: this.$t('message.lifter.rules19'), trigger: "blur" },
                { required: true, message: this.$t('message.lifter.rules19'), trigger: "change" }],
                // 请输入出厂编号
                leaveFactoryNo: [{ required: true, message: this.$t('message.lifter.rules20'), trigger: "blur" },
                { required: true, message: this.$t('message.lifter.rules20'), trigger: "change" }],
                // 请输入生产厂家
                productionEnterprise: [{ required: true, message: this.$t('message.lifter.rules21'), trigger: "blur" },
                { required: true, message: this.$t('message.lifter.rules21'), trigger: "change" }]
            },
            isDisabled: false,
            isDisabled2: false,
            formType: 1, //1、新增 2、编辑
            schemeId: "",
            step: 1,
            detailData: "",
            devType: 3
        }
    },
    created(){
        this.projectSn = this.$store.state.projectSn;
        this.userId = this.$store.state.userInfo.userId
        this.selectRegisterRecord()
    },
    methods: {
        goBack(){
            this.showDetail = false
        },
        openDialog2(val){
            this.showDialog2 = true
            this.schemeId = val.id
        },
        selectRegisterRecord(){
            let data = {
                devType: this.devType,
                projectSn: this.projectSn,
                pageNo: this.pageNo,
                pageSize: this.pageSize
            }
            selectRegisterRecordApi(data).then(res=>{
                console.log(res)
                if(res.code == 200){
                    this.tableData = res.result.records
                    this.total = res.result.total
                }
            })
        },
        selectSchemeRecord(){
            let data = {
                devType: this.devType,
                projectSn: this.projectSn,
                pageNo: this.pageNo,
                pageSize: this.pageSize
            }
            // selectSchemeRecordApi(data).then(res=>{
            //     console.log(res)
            //     if(res.code == 200){
            //         this.tableData = res.result.records
            //         this.total = res.result.total
            //     }
            // })
        },
        deleteTime(index){
            if(this.formData.jackingList.length > 1){
                this.formData.jackingList.splice(index, 1)
            }
            this.formData.jackingList.forEach((item,index)=>{
                item.sequenceNo = index+1
            })
            console.log(this.formData.jackingList)
        },
        addTime(){
            this.formData.jackingList.push({
                jackingTime: "",
                sequenceNo: this.formData.jackingList.length + 1
            })
            console.log(this.formData.jackingList)
        },
        submitForm(){
            this.$refs['addForm'].validate((valid) => {
                console.log(valid)
                if(valid){
                    let data = this.formData
                    if(data.planEnterTime.split("-").join("")>data.planInstallTime.split("-").join("")){
                        // 计划进场时间必须早于计划安装时间！
                        this.$message.error(this.$t('message.lifter.planTimeTips1'))
                        return;
                    }
                    if(data.planInstallTime.split("-").join("")>data.planDismantleTime.split("-").join("")){
                        // 计划安装时间必须早于计划拆除时间
                        this.$message.error(this.$t('message.lifter.planTimeTips2'))
                        return;
                    }
                    let arr = []
                    data.jackingList.forEach(item=>{
                        if(item.jackingTime){
                            arr.push(item)
                        }
                    })
                    let flag = true
                    arr.forEach((item,index)=>{
                        item.sequenceNo = (index + 1)
                        if(index > 0 && item.jackingTime.split("-").join("")<arr[index-1].jackingTime.split("-").join("")){
                            flag = false
                            return
                        }
                    })
                    if(!flag){
                        // 顶升列表时间选择顺序不正确！
                        this.$message.error(this.$t('message.lifter.tips1'))
                        return;
                    }
                    data.jackingList = arr
                    data.projectSn = this.projectSn
                    data.devType = this.devType
                    console.log(data)
                    if(this.formType == 1){
                        data.createUser = this.userId
                        addSchemeRecordApi(data).then(res=>{
                            console.log(res)
                            if(res.code == 200){
                                // 添加成功
                                this.$message.success(this.$t('message.lifter.addSuccess'))
                                this.schemeId = res.result.id
                                this.step = 2
                                this.dialogTitle = this.$t('message.lifter.tips2') // 新增设备登记
                                // this.$refs['addForm'].resetFields()
                                // this.$refs['addForm2'].resetFields()
                                // this.resetForm()
                                // this.closeDialog()
                                // this.selectSchemeRecord()
                            }
                        })
                    } else if(this.formType == 2){
                        // editSchemeRecordApi(data).then(res=>{
                        //     console.log(res)
                        //     if(res.code == 200){
                        //         this.$message.success("编辑成功")
                        //         this.closeDialog()
                        //         this.selectSchemeRecord()
                        //     }
                        // })
                    }
                }
            })
        },
        resetForm(){
            this.formData = {
                devModel: "",
                firstInstallHeight: "",
                finalInstallHeight: "",
                planDismantleTime: "",
                planEnterTime: "",
                planInstallTime: "",
                sceneNumber: "",
                jackingList:[{
                    jackingTime: "",
                    sequenceNo: 1
                }]
            }
        },
        resetForm2(){
            this.formData2 = {
                enterTime: "",
                installEnterprise: "",
                leaseEnterprise: "",
                leaveFactoryNo: "",
                leaveFactoryTime: "",
                manufacturingLicenseNo: "",
                productionEnterprise: "",
                propertyRightFilingNo: "",
                ratedLoadCapacity: "",
                status: "",
                structureType: "",
                devName: "",
                devSn: ""
            }
            this.schemeId = ""
        },
        closeDialog(){
            if(this.step == 2){
                return;
            }
            this.showDialog = false
            this.isDisabled = false
            this.formType = 1
            this.dialogTitle = this.$t('message.lifter.newPlanningInfo') // 新增策划信息
            this.resetForm()
        },
        closeDialog2(){
            this.showDialog2 = false
            this.resetForm2()
        },
        submitForm2(){
            this.$refs['addForm2'].validate((valid) => {
                console.log(valid)
                if(valid){
                    let data = this.formData2
                    data.projectSn = this.projectSn
                    data.schemeId = this.schemeId
                    data.devType = this.devType
                    console.log(data)
                    addRegisterRecordApi(data).then(res=>{
                        console.log(res)
                        if(res.code == 200){
                            this.$message.success(this.$t('message.lifter.addSuccess')) // 添加成功
                            this.step = 1
                            this.closeDialog()
                            this.selectRegisterRecord()
                        }
                    })
                }
            })
        },
        previewData(val){
            console.log(val)
            this.detailData = val
            this.showDetail = true
            // this.showDialog = true
            // this.isDisabled = true
            // this.dialogTitle = "策划信息详情"
            // selectByIdSchemeRecordApi({id: val.id}).then(res=>{
            //     if(res.code == 200){
                    // this.formData = res.result
            //     }
            //     console.log(res)
            // })
            // console.log(val)
        },
        editData(val){
            this.showDialog = true
            selectByIdSchemeRecordApi({id: val.id}).then(res=>{
                if(res.code == 200){
                    this.formData = res.result
                    if(this.formData.jackingList && this.formData.jackingList.length == 0){
                        this.formData.jackingList = [{
                            jackingTime: "",
                            sequenceNo: 1
                        }]
                    }
                }
                // console.log(res)
            })
            this.formType = 2
            this.dialogTitle = this.$t('message.lifter.tips3') // 编辑策划信息
        },
        deleteData(val){
            // 此操作将删除该条记录, 是否继续? , 提示
            this.$confirm(this.$t('message.lifter.tips4'), this.$t('message.lifter.tips'), {
                confirmButtonText: this.$t('message.lifter.determine'), // 确 定
                cancelButtonText: this.$t('message.lifter.cancel'), // 取 消
                type: 'warning'
            }).then(() => {
                  deleteRegisterRecordApi({id: val.id}).then(res=>{
                    console.log(res)
                    if(res.code == 200){
                        this.$message.success(this.$t('message.lifter.deleteSucceeded')+"！") // deleteSucceeded
                        this.selectRegisterRecord()
                    }
                })
            }).catch(() => {
                this.$message({
                    type: 'info',
                    message: this.$t('message.lifter.deletionCancelled') // 已取消删除
                });
            });
        },
        handleSizeChange(val) {
            this.pageSize = val;
            this.selectRegisterRecord();
        },
        handleCurrentChange(val) {
            this.pageNo = val;
            this.selectRegisterRecord();
        },
    }
}
</script>

<style lang="less" scoped>
.devfiling{
    width: 100%;
    height: 100%;
    .pagerBox{
        margin-top: 20px;
    }
    .search-wrap{
        margin-bottom: 26px;
    }
    .primary-btn{
        color: #9297A2;
        /deep/i{
          color: #88E7F0;
        }
    }
    .delete-btn{
        color: #FE6565;
    }
    .dialog-content{
        width: 678px;
        padding: 40px 0 42px 0;
    }
    .dialog-form{
        width: 60%;
        margin: 0 auto;
        margin-bottom: 60px;
    }
    .btn-box{
        display: flex;
        justify-content: center;
        .cancle-btn{
            margin-right: 80px;
        }
    }
    .list-title{
        /deep/.el-form-item__label{
            text-align: left;
        }
    }
    .form-list{
        display: flex;
        align-items: center;
        // padding-left: 20px;
        margin-bottom: 20px;
        .list-label{
            font-size: 14px;
            white-space: nowrap;
            // margin-right: 10px;
            width: 120px;
        }
        .deelet-btn{
            margin-left: 10px;
            color: #FE6565;
            cursor: pointer;
            font-size: 20px;
            white-space: nowrap;
        }
        .add-item{
            color: #409EFF;
            font-size: 14px;
            margin-left: 10px;
            cursor: pointer;
            white-space: nowrap;
        }
    }
    .backText{
        /deep/.el-page-header__content{
            color: #fff;
            font-size: 16px;
        }
    }
}
</style>
