<template>
    <div class="mc-wrap">
        <div class="container-box-t">
            <div class="mc-top">
                <div class="mc-top-left">

                    <div class="grid-content bg-purple">
                        <el-carousel height="250px">
                            <el-carousel-item v-for="item in bannerData" :key="item.id">
                                <img v-bind:src="item.src" alt="" style="width: 100%;height: 100%">
                            </el-carousel-item>
                        </el-carousel>
                    </div>

                    <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('/noticec')">更多</span>
                                </div>
                            </el-carousel-item>
                        </el-carousel>
                    </div>

                    <div class="car-line">
                        <el-carousel height="40px" direction="vertical" trigger="click">
                            <el-carousel-item v-for="item in knowledgeData" :key="item.id">
                                <div class="car-box">
                                    <span>知识库</span>
                                    <span style="color: #0b82ff" @click="uploadknow(item)">{{item.knowledgeTitle}}</span>
                                    <span @click="jNotice('/knowledge')">我的</span>
                                </div>
                            </el-carousel-item>
                        </el-carousel>
                    </div>

                    <div style="margin-top: 10px;background: #fff;padding: 20px;min-height: 300px;">
                        <div style="height: 36px;">待办任务</div>
                        <div class="tabbox">
                            <el-table class="com-table" ref="multipleTable" :data="niticList" tooltip-effect="dark"
                                size="small" border style="width: 100%">
                                <el-table-column prop="woTitle" label="上报标题">
                                </el-table-column>
                                <el-table-column prop="sendNo" label="上报人">
                                </el-table-column>
                                <el-table-column label="上报姓名">
                                    <template slot-scope="scope">
                                          <span>{{$desensitization(scope.row.sendName,1)}}</span>
                                    </template>
                                </el-table-column>
                                <el-table-column prop="sendTime" label="上报时间">
                                </el-table-column>
                                <el-table-column prop="deptName" label="上报部门">
                                </el-table-column>

                                <el-table-column label="操作" width="160px" align="center">
                                    <template slot-scope="scope">
                                        <el-button v-if="scope.row.sts == 2" size="mini" type="primary" @click="checkNotic(1,scope.row)">处理</el-button>
                                        <el-button v-if="scope.row.sts == 0" size="mini" type="danger" @click="checkNotic(2,scope.row)">审核</el-button>
                                    </template>
                                </el-table-column>
                            </el-table>
                        </div>
                    </div>

                </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>
        </el-dialog>

        <el-dialog title='管理任务' :visible.sync="noticStatus" width="50%" :destroy-on-close="true" :modal-append-to-body="false"
            :close-on-click-modal="false">

            <el-form :model="noticList" ref="noticList" style="max-height: 50vh;overflow-y: scroll;">

                <div class="info-line">
                    <el-form-item>
                        <span>任务标题</span>
                        <el-input v-model="noticList.woTitle" placeholder="标题" disabled></el-input>
                    </el-form-item>
                    <el-form-item>
                        <span>反馈时间</span>
                        <el-date-picker v-model="noticList.requireTime" type="date" placeholder="要求反馈时间" disabled>
                        </el-date-picker>
                    </el-form-item>
                </div>

                <el-form-item class="info-line online">
                    <span>任务描述</span>
                    <el-input v-model="noticList.arcDesc" placeholder="任务描述" type="textarea" :rows="3" disabled></el-input>
                </el-form-item>

                <div style="padding:0 20px 0 100px;margin-bottom: 20px;">
                    <uploadDown :datalist="datalistn" :dialogStatus="noticStatus"></uploadDown>
                </div>

                <el-form-item class="info-line" v-if="noticList.type == 1&&noticList.sts == 2">
                    <span>信息类别</span>
                    <el-select @change="changemsgType" v-model="noticList.msgType" placeholder="信息类别" clearable>
                        <el-option v-for="item in typelist" :key="item.id" :label="item.msgType" :value="item.id">
                        </el-option>
                    </el-select>
                </el-form-item>
                <el-form-item class="info-line online" v-if="noticList.sts == 2">
                    <span>回复内容</span>
                    <el-input v-model="noticList.dealTypeDesc" placeholder="回复内容" type="textarea" :rows="3"></el-input>
                </el-form-item>
            </el-form>

            <div slot="footer" class="dialog-footer">
                <el-button type="primary" @click="dialogCli(2)" v-if="noticList.sts == '2'">确 定</el-button>
                <el-button type="primary" @click="dialogCli(3)" v-if="noticList.sts == '0'">通 过</el-button>
                <el-button type="primary" @click="dialogCli(4)" v-if="noticList.sts == '0'">打 回</el-button>
                <el-button @click="dialogCli(1)">取 消</el-button>
            </div>
        </el-dialog>

		<el-dialog title="知识库" :visible.sync="diaKnowStatus" 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">
                <div class="info-line">
                    <el-form-item>
                        <span>知识库标题</span>
                        <div class="mytxt">{{infolist.knowledgeTitle}}</div>
                    </el-form-item>
                    <el-form-item>
                        <span>发布类型</span>
                        <div class="mytxt">{{infolist.pubTypeName}}</div>
                    </el-form-item>
                </div>
                <div class="info-line">
                    <el-form-item>
                        <span>发布人</span>
                        <div class="mytxt">{{infolist.opName}}</div>
                    </el-form-item>
                    <!-- <el-form-item>
                        <span>发布电话</span>
                        <div class="mytxt">{{infolist.contactPhone}}</div>
                    </el-form-item> -->
                </div>

                <div style="padding: 0 20px;">
                    <uploadDown :datalist="datalistk" :dialogStatus="uploadstatus"></uploadDown>
                </div>
            </el-form>
        </el-dialog>
    </div>
</template>
<script>
    import uploadDown from '../../../components/uploadDown'

    export default {
        components: {
            uploadDown
        },
        data() {
            return {
                activeIndex: '1',
                bannerData: [{
                        src: require('../../../static/img/bannar-1.png'),
                        id: '1'
                    },
                    {
                        src: require('../../../static/img/bannar-1.png'),
                        id: '2'
                    },
                    {
                        src: require('../../../static/img/bannar-1.png'),
                        id: '3'
                    },
                ],
                calendar: new Date(),
                timeDay: 0,
                noticeData: [],
                knowledgeData: [],
                srcsc: '',
                ifrshow: false,
                infolist: {},
                dialogStatus: false,
                diaKnowStatus: false,
                uploadstatus: false,
                datalist: {
                    url: '/sysmgr/noticeatt/downfile',
                    type: 1
                },
                datalistn: {
                    url: '/sysmgr/noticeatt/downfile',
                    type: 1

                },
                datalistk: {
                    url: '/market/compatt/downfile',
                    type: 1
                },
                attList: [],
                niticList: [],
                noticStatus: false,
                noticList: {},
                typelist: [],
                userInfo: {},
                knowledgeData: [],
            }
        },
        methods: {
            jNotice(v) {
                this.$router.push(v);
            },
            //获取公告
            getNotice() {
                this.userInfo = JSON.parse(window.sessionStorage.userInfo);
                this.$http({
                    url: "/sysmgr/notice/queryPage",
                    method: "post",
                    headers: {
                        "Content-Type": "application/json",
                        "page": '{"pageNo":"' + 1 + '","pageSize":"20"}'
                    },
                    data: {
                        sts: 2
                    },
                }).then((res) => {
                    this.noticeData = res.data.data;
                });
                this.$http({
                    url: "/market/cwo/queryDbInfo",
                    method: "post",
                    headers: {
                        "Content-Type": "application/json",
                    },
                    data: {},
                }).then((res) => {
                    this.niticList = res.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;
                });
            },
            checkNotic(n, v) {
                this.$http({
                    url: "/market/cwo/queryInfo",
                    method: "post",
                    headers: {
                        "Content-Type": "application/json",
                    },
                    data: {
                        woNo: v.woNo
                    },
                }).then((res) => {
                    this.noticStatus = true;
                    this.noticList = res.data;
                    this.datalistn.attList = res.data.attList;
                });
            },
            getType() {
                this.$http({
                    url: "/market/qatype/queryPage",
                    method: "post",
                    headers: {
                        "Content-Type": "application/json",
                        "page": '{"pageNo":"' + 1 + '","pageSize":"100"}'
                    },
                    data: {},
                }).then((res) => {
                    this.typelist = res.data.data;
                });
            },
            changemsgType() {
                for (let i = 0; i < this.typelist.length; i++) {
                    if (this.infolist.msgType === this.typelist[i].id) {
                        this.infolist.msgTypeName = this.typelist[i].msgType;
                    }
                }
            },
            dialogCli(v) {
                if (v === 1) {
                    this.noticList = {};
                    this.noticStatus = false;
                    return
                } else if (v === 2) {
                    let params = {
                        woNo: this.noticList.woNo,
                        // deptCode:1001,
                        sts: '1',
                        stsDesc: '已回复',
                        dealRemark: this.noticList.dealTypeDesc,
                        attList: [],
                        auditNo: this.userInfo.loginNo,
                        auditName: this.userInfo.loginName,
                        auditTime: this.$formatDate(new Date(), "YYYY-MM-DD")
                    }
                    let attList = [];
                    for (let i = 0; i < this.attList.length; i++) {
                        attList.push({
                            id: this.attList[i].id,
                            fileCode: this.attList[i].fileCode,
                            fileName: this.attList[i].fileName,
                            opName: this.attList[i].opName,
                            opNo: this.attList[i].opNo,
                            opTime: this.attList[i].opTime,
                            noticeId: this.noticList.noticeId
                        });
                    }
                    params.attList = attList;
                    if (this.noticList.type == 1) {
                        params.msgType = this.noticList.msgType;
                        params.msgTypeName = this.noticList.msgTypeName;
                        params.msgInfo = this.noticList.dealTypeDesc;
                        params.msgTital = this.noticList.woTitle;
                        this.submitInfo("/market/cwo/recRptInfo", params);
                    } else {
                        this.submitInfo("/market/cwo/recWoInfo", params);
                    }
                } else {
                    let params = {
                        woNo: this.noticList.woNo,
                        dealResult: v === 3 ? '0' : '1',
                        dealResultDesc: v === 3 ? '通过' : '打回',
                        auditNo: this.userInfo.loginNo,
                        auditName: this.userInfo.loginName,
                        auditTime: this.$formatDate(new Date(), "YYYY-MM-DD")
                        // dealRemark:this.infolist.dealTypeDesc
                    }
                    this.submitInfo("/market/cwo/chkWoInfo", params);
                }
                this.noticList.opTime = new Date().getTime();
            },
            submitInfo(u, v) {
                let _this = this;
                this.$http({
                    url: u,
                    method: "post",
                    headers: {
                        "Content-Type": "application/json",
                    },
                    data: v,
                }).then((res) => {
                    if (res.data.result === 1) {
                        _this.$message({
                            message: res.data.desc,
                            type: 'error'
                        });
                    } else {
                        _this.$message({
                            message: '成功',
                            type: 'success'
                        });
                        _this.noticList = {};
                        _this.noticStatus = false;
                        _this.getNotice();
                    }

                });
            },
            //获取知识库
            getKnowledge() {
                this.$http({
                    url: "/satisfy/cknowledge/queryListPage",
                    method: "post",
                    headers: {
                        "Content-Type": "application/json",
                        "page": '{"pageNo":"' + 1 + '","pageSize":"20"}'
                    },
                    data: {
                        sts: 1
                    },
                }).then((res) => {
                    this.knowledgeData = res.data.data;
                });
            },
            //预览知识库
            uploadknow(v) {
                this.diaKnowStatus = true;
                this.infolist = v;
                this.$http({
                    url: "/satisfy/cknowledge/queryInfo",
                    method: "post",
                    headers: {
                        "Content-Type": "application/json",
                    },
                    data: {
                        id: v.id
                    },
                }).then((res) => {
                    this.uploadstatus = !this.uploadstatus;
                    this.datalistk.attList = [];
                    this.datalistk.attList = res.data.attList;
                    // console.log(res.data)
                });
            },
        },
        mounted() {
            this.getNotice();
            this.getType();
            this.getKnowledge();
        },
        created() {

        },
    }
</script>

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

        .container-box-t {
            // width: 100%;
            height: calc(100vh - 160px);
            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-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;
    }

    .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-wrap .ztree li a.curSelectedNode {
        border: none !important;
        background-color: white !important;
    }

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

    @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;
            overflow: hidden;
        }

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

        span {
            width: 80px;
            height: 40px;
            line-height: 40px;
            display: inline-block;
            text-align: left;
            float: 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);
        }
    }
</style>
