<template>
    <div class="notificationDetail">
        <el-dialog title="公告详情" custom-class="startToDia" v-model="dialogVisible" width="900px" :close-on-click-modal="false">
            <div class="notifcaFrom">
                <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm" :validate-on-rule-change="false">      
                    <el-form-item label="公告标题" prop="noticeTitle">
                        <el-input v-model="ruleForm.noticeTitle"  placeholder="请输入公告标题" />
                    </el-form-item>
                    <el-form-item label="公告内容" prop="noticeContent">
                        <el-input v-model="ruleForm.noticeContent"
                            type="textarea" :rows="10" placeholder="请输入公告内容"></el-input>
                    </el-form-item>
                    <el-form-item label="发布对象" prop="sendTo">
                        <el-select v-model="ruleForm.sendTo" placeholder="请选择发布对象">
                            <el-option
                            v-for="item in sendToData"
                            :key="item.value"
                            :label="item.label"
                            :value="item.value">
                            </el-option>
                        </el-select>
                    </el-form-item>
                    <el-row>
                        <el-col :span="12" v-if="ruleForm.sendTo === '个别部门'">
                            <el-form-item label="个别部门" prop="sendToContent">
                                <el-select v-model="ruleForm.sendToContent" multiple collapse-tags placeholder="请选择部门">
                                    <el-option
                                    v-for="item in departData"
                                    :key="item.id"
                                    :label="item.keyName"
                                    :value="item.id">
                                    </el-option>
                                </el-select>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="排序">
                                <el-input-number v-model="ruleForm.serialNumber" :min="1" />
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-form-item label="附件">
                        <div class="fliesHeader">
                            <span>附件名</span>
                            <span>发送单位</span>
                            <span>操作</span>
                        </div>
                        <div v-for="it in filesListEdit" :key="it">
                            <div class="fliesMain">
                                <div>
                                    <img :src="file" style="margin-right: 10px" >
                                    <span class="fliesMainSpan spanOne">{{it}}</span>
                                </div>
                                <span class="fliesMainSpan spanTwo" style="font-size:14px">{{it.releaseDeptName}}</span>
                                <!-- <span>{{userMes.unitName}}</span> -->
                                <div class="fileOperate">
                                    <div @click="previewFile(it)" style="cursor:pointer">
                                        <img :src="yulan" style="margin-right: 10px;" >
                                        <span style="font-size:14px">预览</span>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </el-form-item>
                </el-form>
            </div>
        </el-dialog>
    </div>
</template>

<script>
import yulan from '../../assets/btnIcon/yulan.png'
import fileDelete from '../../assets/btnIcon/fileDelete.png'
export default {
    data() {
        return {
            dialogVisible: false,
            ruleForm: {
                serialNumber: 1,
                noticeTitle: '',
                noticeContent: '',
                sendTo: '',
                sendToContent: [],
                releaseDept: '',
                releasePeople: '',
            },
            filesListEdit: [],
            yulan: yulan,
            fileDelete: fileDelete
        }
    },
    methods: {
        init(row) {
            this.dialogVisible = true
            this.filesListEdit = []
            this.ruleForm = {
                serialNumber: row.serialNumber*1,
                noticeTitle: row.noticeTitle,
                noticeContent: row.noticeContent,
                sendTo: row.sendTo,
                sendToContent: row.sendToContent.split(','),
                releaseDept: row.releaseDept,
                releasePeople: row.releasePeople
            }
            let filesArr = row.noticeAnnex.split(',')
            this.filesListEdit = filesArr
        },
    }
}
</script>

<style lang="less">
.notificationDetail{
    .el-overlay{
        .startToDia{
            margin-top: 5vh;
            background: #EDEFF5;
            .el-dialog__body{
                padding: 30px 60px 30px 20px !important;
                .notifcaFrom{
                    .el-select, .el-input{
                        width: 100%;
                    }
                    .el-input{
                        height: 30px;
                    }
                    .uploadFiles{
                        .el-button{
                            height: 25px !important;
                        }
                    }
                    .fliesHeader{
                        width: 100%;
                        display: flex;
                        justify-content: space-around;
                        span{
                            font-size: 14px;
                        }
                    }
                    .fliesMain{
                        width: 100%;
                        display: flex;
                        .fliesMainSpan{
                            display: inline-block;
                            width: 260px;
                            overflow: hidden;
                            text-overflow: ellipsis;
                            white-space: nowrap;
                        }
                        .spanOne{
                            color: #1063CB;
                            font-size: 14px;
                        }
                        .fileOperate{
                            width: 160px;
                            display: flex;
                            justify-content: space-around;
                            .removeImg{
                                margin-right: 10px;
                                position: relative;
                                top: 2px;
                            }
                        }
                        .removeDiv{
                            width: 160px;
                            .removeImg{
                                margin: 0 10px 0 20px;
                                position: relative;
                                top: 3px;
                            }
                        }
                    }
                }
                .flowSty{
                    width: 100%;
                    height: 70vh;
                }
            }
            .el-dialog__footer{
                background: #fff;
                border-radius: 0 0 10px 10px;
                text-align: left;
                .notificationFooter{
                    margin-left: 20px;
                    .el-button{
                        height: 30px !important;
                    }
                }
            }
        }
    }
}
</style>