<template>
    <div class="mc-wrap">
        <div class="container-box">
            <div class="mc-top">
                <div class="mc-top-left">
                    <el-row >
                        <el-col :span="24">
                            <div class="car-line">
                                <el-carousel height="40px" direction="vertical" trigger="click">
                                    <el-carousel-item v-for="item in noticeData" :key="item.noticeId">
                                        <div class="car-box">
                                            <i class="el-icon-message-solid"></i>
                                            <span>公告</span>
                                            <span style="color: #0b82ff" @click="uploadsee(item)">{{
                        item.noticeTitle
                      }}</span>
                                            <span @click="jNotice">更多</span>
                                        </div>
                                    </el-carousel-item>
                                </el-carousel>
                            </div>
                        </el-col>
                    </el-row>
                    <el-row>
                        <ProcessingInstruction></ProcessingInstruction>
                    </el-row>
                </div>
            </div>
        </div>
        <div class="if-box-top" v-if="ifrshow" @keyup.esc="ifrshow = false">
            <i class="el-icon-close" @click="ifrshow = false"></i>
            <iframe height="100%" width="100%" :src="srcsc"> </iframe>
        </div>

        <el-dialog title="公告" :visible.sync="dialogStatus" width="50%" :close-on-press-escape="false" :show-close="true"
            :destroy-on-close="true" :modal-append-to-body="false" :close-on-click-modal="false">
            <el-form :model="infolist" ref="infolist" style="max-height: 50vh; overflow-y: scroll">
                <div class="info-line">
                    <el-form-item>
                        <span>公告标题</span>
                        <div class="mytxt">{{ infolist.noticeTitle }}</div>
                    </el-form-item>
                    <el-form-item>
                        <span>发布人</span>
                        <div class="mytxt">{{ infolist.opName }}</div>
                    </el-form-item>
                </div>
                <el-form-item class="info-line online">
                    <span>发布内容</span>
                    <div class="mytxtinfo">{{ infolist.noticeContent }}</div>
                </el-form-item>

                <div style="padding: 0 20px">
                    <uploadDown :datalist="datalist" :dialogStatus="uploadstatus"></uploadDown>
                </div>
            </el-form>
            <!-- <div slot="footer" class="dialog-footer">
                <el-button @click="dialogStatus=false">确 定</el-button>
                <el-button @click="dialogStatus=false">取 消</el-button>
            </div> -->
        </el-dialog>
    </div>
</template>
<script>
    import uploadDown from "../../../components/uploadDown";
    import ProcessingInstruction from "./processInitiation.vue";
    import knowOrgStruc from "./knowOrgStruc.vue";

    export default {
        components: {
            uploadDown,
            ProcessingInstruction,
            knowOrgStruc,
        },
        data() {
            return {
                indexDialogStatus: false, // 需求修改弹窗
                rightData: [
                ],
                myHeight: {
                    height: "auto",
                },
                myHeightauto: {
                    height: "auto",
                },
                noticeData: [], // 公告数据源
                srcsc: "", // 预览ifream路径
                ifrshow: false, // ifream 是否显示
                infolist: {}, // 公告详情数据
                dialogStatus: false, // 公告弹窗
                uploadstatus: false, // 附件回显组件参数
                datalist: { // 附件回显组件参数
                    url: "/sysmgr/noticeatt/downfile",
                    type: 1,
                },
                attList: [],
                formData: {}, // 需求详情数据
                lineopt: [], // 单元下拉数据源
                rules: {
                    unitCode: [{
                        required: true,
                        message: "请选择单元",
                        trigger: "blur",
                    }, ],
                    reqTitle: [{
                        required: true,
                        message: "请输入需求标题",
                        trigger: "blur",
                    }, ],
                    reqDesc: [{
                        required: true,
                        message: "请输入需求描述",
                        trigger: "blur",
                    }, ],
                    requiredTime: [{
                        required: true,
                        message: "请选择期望上线时间",
                        trigger: "blur",
                    }, ],
                    sts: [{
                        required: true,
                        message: "请选择需求状态",
                        trigger: "blur",
                    }, ],
                },
                stsOptions: [ // 状态下拉数据源
                    {
                        value: "0",
                        label: "待开始"
                    },
                    {
                        value: "1",
                        label: "需求分析"
                    },
                    {
                        value: "2",
                        label: "设计中"
                    },
                    {
                        value: "3",
                        label: "开发中"
                    },
                    {
                        value: "4",
                        label: "完成"
                    },
                ],
            };
        },
        methods: {
            // 状态下拉监听获取label
            formmat(val) {
                this.stsOptions.map((item) => {
                    if (item.value == val) {
                        this.formData.stsDesc = item.label;
                    }
                });
            },
            // 单元下拉监听获取label
            changetype(val) {
                this.lineopt.map((item) => {
                    if (item.lineId == val) {
                        this.formData.unitName = item.lineName;
                    }
                });
            },
            // 获取单元数据
            getLineOpations() {
                this.$http({
                    url: "/market/mkline/queryList",
                    method: "post",
                    headers: {
                        "Content-Type": "application/json",
                    },
                    data: {},
                }).then((res) => {
                    this.lineopt = res.data;
                });
            },
            // 增加表单处理
            async subUser(formName) {
                let valid = await this.$refs[formName].validate().catch((err) => err);
                if (valid) {
                    // this.formData.planTime = this.$formatDate(this.formData.planTime, "YYYY-MM-DD")
                    // this.formData.planTime = this.$formatDate(this.formData.finishTime, "YYYY-MM-DD")
                    // this.formData.planTime = this.$formatDate(this.formData.requiredTime, "YYYY-MM-DD")
                    let results = await this.$http({
                        url: "/market/cReqInfo/update",
                        method: "post",
                        headers: {
                            "Content-Type": "application/json",
                        },
                        data: this.formData,
                    });
                    if (results.data.result == 0) {
                        this.$message({
                            type: "success",
                            message: "修改成功",
                        });
                        this.indexDialogStatus = false;
                    }
                }
            },
            // 取消提交
            resetUser(formName) {
                this.$refs[formName].resetFields();
                this.indexDialogStatus = false;
            },
            //统一高度
            hAuto() {
                if (this.$refs.boxtLeft) {
                    let boxtLeft = this.$refs.boxtLeft.offsetHeight;
                    let boxtRight = this.$refs.boxtRight.offsetHeight;
                    if (boxtLeft > boxtRight) {
                        this.myHeight.height = boxtLeft + "px";
                        this.myHeightauto.height = boxLeft + 300 + "px";
                    } else {
                        this.myHeight.height = boxtRight + "px";
                        this.myHeightauto.height = boxtRight + 300 + "px";
                    }
                }
            },
            //跳转
            jumpTo(v) {
                if (v.href) {
                    this.$router.push(v.href);
                    // this.setabList(v.text,v.href);
                }
            },
            jNotice() {
                this.$router.push("/noticec");
                // this.setabList("公告管理","/noticec");
            },
            //获取公告
            getNotice() {
                this.$http({
                    url: "/sysmgr/notice/queryPage",
                    method: "post",
                    headers: {
                        "Content-Type": "application/json",
                        page: '{"pageNo":"' + 1 + '","pageSize":"10"}',
                    },
                    data: {
                        sts: 2,
                    },
                }).then((res) => {
                    this.noticeData = res.data.data;
                });
            },
            //预览公告
            uploadsee(v) {
                this.dialogStatus = true;
                this.infolist = v;
                this.$http({
                    url: "/sysmgr/cnotice/queryInfo",
                    method: "post",
                    headers: {
                        "Content-Type": "application/json",
                    },
                    data: {
                        noticeId: v.noticeId,
                    },
                }).then((res) => {
                    this.uploadstatus = !this.uploadstatus;
                    this.datalist.attList = [];
                    this.datalist.attList = res.data.attList;
                    // if(res.data.attList){
                    //     res.data.attList.forEach(item => {
                    //         this.attList.push({
                    //             name: item.fileName,
                    //             url: '',
                    //             id: item.id,
                    //             fileName: item.fileName
                    //         });
                    //     })
                    //     this.datalist.attList = this.attList;
                    //     console.log(this.datalist.attList)
                    // }
                });
            },
            //添加tab
            setabList(n, p) {
                let params = {
                    children: "",
                    name: n,
                    rountPath: p,
                    target: "_self",
                };
                for (let i = 0; i < this.$store.state.tabList.length; i++) {
                    if (this.$store.state.tabList[i].name === params.name) {
                        this.$store.state.tabList[i] = params;
                    }
                }
                let set = new Set(this.$store.state.tabList);
                set.add(params);
                this.$store.commit("setDefaultActive", params.rountPath);
                this.$store.commit("setTabList", Array.from(set));
            },
        },
        mounted() {
            this.getLineOpations();
            this.getNotice();
        },
        created() {
            // this.hAuto();
        },
        computed: {
            collapse() {
                return this.$store.state.collapse;
            },
        },
        //   watch: {
        //     collapse() {
        //       let _this = this;
        //       _this.echartsKpiDom.resize();
        //       _this.echartsCompleteDom.resize();
        //       _this.echartsImportantDom.resize();
        //       _this.hAuto();
        //     },
        //   },
    };
</script>

<style lang="scss" scoped>
    .mc-wrap {
        box-sizing: border-box !important;
        margin: 0;
        height: calc(100vh - 120px);
        overflow: hidden;
        width: 100%;
        padding-right: 10px;

        .container-box {
            width: 100%;
            height: calc(100% - 40px);
            margin-top: 20px;
            overflow-y: scroll;
            padding: 0 0 0 15px;
        }
    }

    .mc-top {
        display: flex;
        width: 100%;
    }

    .mc-wrap .mc-top-left {
        width: 100%;
        margin-right: 15px;
    }

    .car-line {
        height: 40px;
        background: #fff;
        // margin: 10px 0 0 0;

        .car-box {
            padding: 0 20px;
            line-height: 40px;
            color: #333;

            span {
                cursor: pointer;
                margin-right: 20px;
            }

            span:first-child {
                cursor: auto;
            }

            span:last-child {
                float: right;
                margin-right: 0;
            }
        }
    }

    .mc-wrap .mc-top-right {
        width: calc(20% - 15px);
        background-color: white;
        overflow: hidden;

        .inner-box {
            width: calc(100% + 20px);
            background-color: white;
            overflow-y: scroll;
        }
    }

    #swiper-container {
        padding: 0 !important;
        width: 100%;
        height: 250px;
        overflow: hidden;
        position: relative;
        background-color: white;
    }

    #swiper-container img {
        object-fit: contain;
    }

    .swiper-pagination {
        position: absolute;
        bottom: 0;
    }

    .main-box .item {
        float: left;
        width: 50%;
    }

    .main-box {
        overflow: hidden;
    }

    #test-n2 #layui-laydate1 {
        width: 100% !important;
    }

    .mc-wrap .laydate-theme-grid .layui-laydate-content td {
        border: none !important;
        border-radius: 50%;
    }

    .mc-wrap .layui-laydate-main {
        width: 100% !important;
    }

    .mc-wrap .layui-laydate-content table {
        width: 100%;
    }

    .mc-wrap .layui-laydate-static {
        width: 100% !important;
        border: none !important;
        box-shadow: none !important;
    }

    .mc-wrap .laydate-day-mark::after {
        bottom: 0 !important;
        left: 45% !important;
        top: 50px !important;
    }

    .mc-wrap .laydate-day-mark {
        overflow: inherit !important;
        overflow: none !important;
    }

    .mc-wrap .layui-laydate .layui-this {
        background-color: #a3c1e5 !important;
    }

    #test-n2 {
        width: initial !important;
    }

    .tasksituation {
        border-bottom: 1px solid #f7f7f7;
    }

    .mc-wrap .tasksituation>.title {
        font-size: 16px;
        font-weight: 500;
        padding-top: 20px;
        padding-left: 20px;
        color: #333;
    }

    .mc-wrap .main-box .point {
        color: #ff6060;
        font-size: 30px;
        font-weight: 500;
    }

    .mc-wrap .main-box .item img {
        width: 100%;
    }

    .mc-wrap .describe {
        text-align: center;
    }

    .mc-wrap .describe .title {
        color: #999;
        font-size: 12px;
        padding: 5px 0;
    }

    .mc-wrap .describe .day {
        color: #0081cc;
        font-size: 16px;
    }

    .mc-wrap .swiper-pagination-bullet {
        width: 10% !important;
        border-radius: 0;
        height: 5px !important;
    }

    .mc-wrap .laydate-icon {
        display: none;
    }

    .mc-wrap .laydate-set-ym {
        text-align: left;
    }

    .mc-wrap .layui-laydate-header {
        padding: 0;
    }

    .mc-wrap .layui-laydate-header i {
        display: none !important;
    }

    .mc-wrap .data-box {
        position: relative;
    }

    .datetimeBox {
        .el-timeline {
            padding-left: 20px;
        }
    }

    .mc-wrap .operation {
        padding-right: 20px;
        cursor: pointer;
        margin-top: 10px;
        text-align: right;
    }

    .notify {
        height: 40px;
        margin-top: 10px;
        background-color: white;
        overflow: hidden;
    }

    .echarts-box {
        margin-top: 10px;
        display: flex;
        background-color: #f2f2f2;
    }

    .left-echart-box {
        width: calc(62.5% - 7px);
        background-color: white;
        display: flex;
        padding-bottom: 20px;
        margin-right: 15px;
    }

    .left-echart-box .left-echart {
        width: 50%;
        padding: 25px 0px 0 25px;
    }

    .mc-nomal-title {
        font-size: 20px;
        font-weight: 500;
        color: #333;
        padding-bottom: 10px;
    }

    .mc-nomal-checked {
        color: #999;
        font-size: 12px;
    }

    .mc-nomal-show-num {
        display: flex;
        justify-content: space-between;
        text-align: center;
        margin-top: 10px;
        width: 75%;
    }

    .mc-nomal-num {
        font-size: 20px;
    }

    .echart-style {
        width: 98%;
        margin: 0 auto;
        min-height: 250px;
    }

    .right-echart-box {
        width: calc(37.5% - 7px);
        padding-bottom: 20px;
        background-color: white;
    }

    .right-echart {
        padding: 20px 0px 0 20px;
    }

    .mc-wrap .layui-laydate-footer {
        display: none;
    }

    .mc-wrap .layui-timeline-axis {
        width: 50px !important;
        height: 18px;
        border-radius: 20px;
        top: 3px;
        color: white;
        line-height: 18px;
    }

    .mc-wrap .layui-timeline-content {
        margin-left: 35px;
    }

    .mc-wrap .layui-timeline {
        width: 80%;
        margin: 0 auto;
    }

    .mc-wrap .layui-timeline-item:before {
        left: 9% !important;
        width: 3px;
        background-color: #daeaf2;
        top: 3px;
    }

    .mc-wrap .layui-timeline-axis:hover {
        color: white !important;
    }

    .mc-title-box {
        display: flex;
    }

    .mc-right-title {
        margin-top: 10px;
        text-align: right;
        width: 55%;
    }

    .mc-function-item {
        margin-top: 10px;
    }

    .mc-func-title {
        font-size: 16px;
        font-weight: 400;
        color: #333;
        padding-left: 20px;
    }

    .mc-func-box {
        display: flex;
        margin-top: 20px;
    }

    .mc-func-item {
        width: 20%;
        text-align: center;
    }

    .mc-func-icon {
        height: 50px;
        width: 50px;
        margin: 0 auto;
        background-color: red;
        border-radius: 20px;
        text-align: center;
        line-height: 50px;
        cursor: pointer;
        color: white;
    }

    .mc-icon-style {
        width: 50%;
        height: 100%;
        vertical-align: -0.15em;
        fill: currentColor;
        overflow: hidden;
        cursor: pointer;
    }

    .mc-nomal-i {
        float: right;
        margin-right: 10px;
        cursor: pointer;
        color: #50a8ec;
    }

    .person-box {
        display: flex;
        height: 30px;
        border-bottom: 1px solid #f5f5f5;
        padding-bottom: 5px;
        margin-top: 5px;
    }

    .person-logo {
        width: 30px;
    }

    .person-logo img {
        border-radius: 50%;
    }

    .person-msg {
        width: 40%;
        padding-left: 2%;
    }

    .person-type {
        width: 40%;
        line-height: 30px;
        text-align: right;
    }

    .person-name {
        font-size: 12px;
        line-height: 15px;
    }

    .person-phone {
        font-size: 10px;
        color: grey;
        line-height: 15px;
    }

    .ztree li a {
        height: initial !important;
        height: 100% \0;
        width: 80%;
    }

    .ztree li span.button.switch {
        width: 18px;
        height: 18px;
    }

    .echartItem {
        overflow: hidden;
    }

    .echartItem-text {
        float: left;
        text-align: right;
        margin-left: 20px;
    }

    .mc-gonggao {
        margin-left: 20px;
        vertical-align: middle;
    }

    .mc-gonggao-style {
        vertical-align: bottom;
        margin-left: 10px;
        color: #408fff;
        cursor: pointer;
    }

    .mc-swiper-more {
        float: right;
        margin-right: 10px;
        cursor: pointer;
    }

    .mc-wrap .ztree li a.curSelectedNode {
        border: none !important;
        background-color: white !important;
    }

    .swiper-pagination-bullet-active {
        background-color: white;
    }

    .point-baifen {
        font-size: 14px;
        margin-left: -5%;
    }

    .mc-loading {
        position: absolute;
        top: 0;
        left: 7.5px;
        width: 100%;
        height: 100%;
        background-color: #ffffff;
        z-index: 999999;
    }

    .mc-loading .loading-main {
        display: block;
        position: relative;
        left: 50%;
        top: 50%;
        width: 150px;
        height: 150px;
        margin: -75px 0 0 -75px;
        border-radius: 50%;
        border: 3px solid transparent;
        border-top-color: #1e9fff;
        animation: spin 2s linear infinite;
    }

    .mc-loading .loading-main:before {
        content: "";
        position: absolute;
        top: 5px;
        left: 5px;
        right: 5px;
        bottom: 5px;
        border-radius: 50%;
        border: 3px solid transparent;
        border-top-color: #1e9fff;
        animation: spin 3s linear infinite;
    }

    .mc-loading .loading-main:after {
        content: "";
        position: absolute;
        top: 15px;
        left: 15px;
        right: 15px;
        bottom: 15px;
        border-radius: 50%;
        border: 3px solid transparent;
        border-top-color: #1e9fff;
        animation: spin 1.5s linear infinite;
    }

    .mc-red {
        color: #ff6060;
    }

    .mc-type-box {
        display: flex;
    }

    .mc-padding-no {
        padding-left: 20px;
    }

    @keyframes spin {
        0% {
            transform: rotate(0deg);
        }

        to {
            transform: rotate(1turn);
        }
    }

    .info-line {
        width: 100%;
        display: block;
        padding-left: 20px;

        div {
            width: 50%;
            display: inline-block;
        }

        .mytxt {
            height: 40px;
            padding-left: 20px;
            border: 1px solid #ddd;
            border-radius: 5px;
            width: calc(100% - 100px);
        }

        .mytxtinfo {
            line-height: 40px;
            height: auto;
            padding-left: 20px;
            border: 1px solid #ddd;
            border-radius: 5px;
            width: calc(100% - 100px);
        }

        span {
            width: 80px;
            display: inline-block;
            text-align: left;

            i {
                color: red;
                display: inline-block;
                padding-right: 5px;
            }
        }

        .el-select,
        .el-input {
            width: calc(100% - 100px);
        }
    }

    .online {
        width: 100%;

        .el-select {
            width: calc(100% - 100px);
        }

        span {
            vertical-align: top;
        }

        .el-textarea {
            width: calc(100% - 100px);
        }
    }

    .right-title-box {
        width: 90%;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
        cursor: pointer;
    }

    .right-title {
        font-size: 12px;
    }
</style>
