<template lang="pug">
    el-dialog( title="发布结果" width="50%" :close-on-click-modal="false" :close-on-press-escape="true" append-to-body :visible.sync="visible" :before-close="beforeClose" )
        .title-bold(slot='title') 发布结果
        el-card()
            div(slot="header") 事件基本信息
            el-form(:model="item" size="mini" label-width="100px")
                el-col(:span="12")
                    el-form-item( label="事件名称:" prop="name")
                        el-input.mywidth(readonly class="inputWidth" v-model="item.name" )
                el-col(:span="12")
                    el-form-item( label="发生时间:" prop="happenTime")
                        el-date-picker.mywidth(readonly type="datetime"  v-model="item.happenTime" )
                el-col(:span="24")
                    el-form-item( label="发生地点:" prop="happenAddress")
                        el-input.mywidth(readonly type="textarea" :rows="3" resize="none" v-model="item.happenAddress" )
                el-col(:span="24")
                    el-form-item( label="事故原因:" prop="reasonWhy")
                        el-input.mywidth(readonly type="textarea" :rows="3" resize="none" v-model="item.reasonWhy" )
                el-col(:span="24")
                    el-form-item( label="现场情况:" prop="sceneDescription")
                        el-input.mywidth(readonly type="textarea" :rows="3" resize="none" v-model="item.sceneDescription" )
        el-card()
            div(slot="header") 决策信息
            font().plan {{planName}}预案
            el-steps(direction="vertical" :active=`logList.length` align-center class="steps" )
                el-step( v-for='(item, index) in logList' :key='index')
                    template(slot='title')
                        span {{item.stepName}}
                    template(slot='description')
                        div(v-if="item.instructs.length")
                            el-row(v-for="(ins, insIndex) in item.instructs" :key="insIndex" class="row")
                                el-col()
                                    span 资源点:{{ins.resourceName}}
                                el-col()
                                    span 动作:{{ins.actionInfo}}
                                        font.action_font(class="el-icon-picture" v-if="ins.actionInfo === '抓图' && ins.result === 2" @click="queryActionHandle(ins.logInsId,1)") 抓图详情
                                        font.action_font(class="el-icon-picture" v-if="ins.actionInfo === '录像下载' && ins.result === 2" @click="queryActionHandle(ins.logInsId,2)") 录像下载详情
                                el-col()
                                    span 系统执行:{{ins.updateTime}}
                                        font().resultFont {{ins.resultName}}
                        el-row(v-else class="row")
                            el-col()
                                span {{item.content}}
                            el-col()
                                span 系统执行:{{item.startTime}}
                                    font().resultFont {{item.resultName}}
        el-card
            div(slot="header") 评估信息
            el-form(:model="dataForm" ref="dataForm" size="mini" label-width="130px")
                el-col(:span="24")
                    el-form-item( label="运行计划恢复时间:" prop="restoreTime")
                        el-date-picker.mywidth(readonly type="datetime" value-format="yyyy-MM-dd HH:mm:ss" format="yyyy-MM-dd HH:mm:ss" v-model="dataForm.restoreTime" )
                el-col(:span="24")
                    el-form-item( label="出行交通管制:" prop="controls")
                        el-input.mywidth(readonly type="textarea" :rows="3" resize="none" v-model="dataForm.controls" clearable)
                el-col(:span="24")
                    el-form-item( label="临时交通措施:" prop="measures")
                        el-input.mywidth(readonly type="textarea" :rows="3" resize="none" v-model="dataForm.measures" clearable)
                el-col(:span="24")
                    el-form-item( label="环境影响:" prop="environment")
                        el-input.mywidth(readonly type="textarea" :rows="3" resize="none" v-model="dataForm.environment" clearable)
                el-col(:span="24")
                    el-form-item( label="其他影响:" prop="other")
                        el-input.mywidth(readonly type="textarea" :rows="3" resize="none" v-model="dataForm.other" clearable)
        span.dialog-footer(slot='footer')
            el-button( type='primary' size='medium' @click='visible = false') 关闭

        el-dialog(:modal="false" width="35%" :modal-append-to-body="false" class="dialogActionClass" :close-on-press-escape="false" :visible.sync="actionVisible")
            div(slot="title")
                span.title-bold {{actionType == 0 ? '' : actionType==1 ? '抓图详情' : '录像下载详情'}}
            div(v-loading="actionLoading")
                img(v-if="actionList.length === 0" height="360px" width="100%" src="../../../assets/images/videoImg.png" alt="")
                el-carousel(v-if="actionList.length > 0" height="360px" arrow="always")
                    el-carousel-item(v-for="(item,index) in actionList")
                        img(v-if="item.fileType === 'jpg' && item.path && item.path != 'null'" :src="urlPath+item.path" height="320px" width="100%")
                        video(v-else-if="item.fileType === 'mp4' && item.path && item.path != 'null'" height="320px" width="100%" :src="urlPath+item.path" autoplay loop controls muted="true")
                        img(v-else height="360px" width="100%" src="../../../assets/images/videoImg.png" alt="")
                        div.action_div
                            span.action_span(style="") {{index+1}}</span>{{'/'+actionList.length}}
</template>

<script>
    export default {
        name: 'release-info',
        data() {
            return {
                urlPath: window.CONFIG.urlPath,
                actionVisible: false,
                actionLoading: false,
                actionList: [],
                actionType: 0,
                visible: false,
                planName: '',
                item: {},
                logList: [],
                dataForm: {}
            }
        },
        methods: {
          //指令步骤抓图和录像下载查询
            queryActionHandle(id, type) {
                this.actionType = type
                this.actionList = []
                this.actionVisible = true
                this.actionLoading = true
                this.$http({
                    url: this.$http.adornUrlAlarm(`/orAttachment/queryByLogInstructId/` + id),
                    method: 'get'
                }).then(data => {
                    this.actionLoading = false
                    if (data && data.code === 0) {
                        this.actionList = data.list
                    }
                })
            },
            init(item) {
                console.log(item)
                this.visible = true
                this.item = item
                this.getLog()
                this.getAssessInfo()
            },
            getLog() {
                this.$http({
                    url: this.$http.adornUrlAlarm('/eventDecision/getDecisionInfo'),
                    method: 'get',
                    params: { eventId: this.item.id }
                }).then(data => {
                    if (data && data.code === 0) {
                        this.logList = data.list
                        this.planName = this.logList[0].planName || ''
                    } else {
                        this.$message(data.msg)
                    }
                })
            },
            getAssessInfo() {
                this.$http({
                    url: this.$http.adornUrlAlarm('/eventDecision/assessInfo'),
                    method: 'get',
                    params: { eventId: this.item.id }
                }).then(data => {
                    if (data && data.code === 0) {
                        this.dataForm = data.list[0] || {}
                    } else {
                        this.dataForm = {}
                    }
                })
            },
            beforeClose() {
                this.planName = ''
                this.logList = []
                this.item = {}
                this.visible = false
                this.dataForm = {}
            }
        }
    }
</script>

<style lang='scss' scoped>
    .action_font{
        cursor:pointer;
        line-height: 20px;
        padding-left:10px;
    }

    .action_div{
        float:left;
        width:100%;
        height:40px;
        background: #F6F7FB;
        line-height: 40px;
        bottom: 0;
    }
    .action_span{
        float:left;
        text-indent: 1rem;
        font-size:18px;
        font-weight:bold;
        color:rgba(33,172,252,1)
    }
    .dialogActionClass{
        /deep/ .el-dialog__body{
            padding: 10px;
        }
    }
    .plan {
        font-size: 16px;
        color: #00b0e8;
        font-weight: bold;
    }

    .steps {
        margin-top: 15px;
    }

    .row {
        margin: 10px auto;
    }

    .resultFont {
        margin-left: 15px;
        color: #32A5EA;

    }
</style>