<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>
            <el-col :span="24">
              <leaderTag :dynamicTags="dynamicTags"></leaderTag>
            </el-col>
          </el-row>
          <el-row>
            <div v-if="status">
              <el-col :span="18">
                <hometask></hometask>
              </el-col>
              <el-col :span="6">
                <numberhits :numHits="numHits"></numberhits>
              </el-col>
            </div>
            <div v-else>
              <el-col :span="24">
                <hometask></hometask>
              </el-col>
            </div>
          </el-row>
          <el-row style="margin-top: 10px">
            <ProcessingInstruction></ProcessingInstruction>
          </el-row>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import ProcessingInstruction from "./leaderHprocess.vue";
import hometask from "./leaderhomeTask.vue";
import numberhits from "./numberHits.vue";
import leaderTag from "./leaderTag.vue";

export default {
  components: {
    ProcessingInstruction,
    hometask,
    numberhits,
    leaderTag,
  },
  data() {
    return {
      noticeData: [], // 公告数据源
      status: true,
      dynamicTags: [], //已添加的常用功能
      numHits: [], //点击率排行
      menuqList: [], //有权限的菜单
    };
  },
  methods: {
    
    //获取员工信息
    getpeo() {
      this.$http({
        url: "/sysmgr/csysdept/queryGroupListByLoginNo",
        method: "post",
        headers: {
          "Content-Type": "application/json",
        },
        data: {},
      }).then((res) => {
        if (res.data[0].parentorgid === "00440063000000000000") {
          this.status = false;
        }
      });
    },
    //获取公告
    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)
        // }
      });
    },
    jNotice() {
      this.$router.push("/noticec");
      // this.setabList("公告管理","/noticec");
    },
    //获取初始Tags
    getTags() {
      this.$http({
        url: "/market/usuaFun/queryFun",
        method: "post",
        headers: {
          "Content-Type": "application/json",
        },
        data: {},
      }).then((res) => {
        this.dynamicTags = res.data;
      });
    },
    //获取点击量
    getnumberHit() {
      // this.$http({
      //   url: "/sysmgr/sys/login/auth/functions",
      //   method: "post",
      //   headers: {
      //     "Content-Type": "application/json",
      //   },
      //   data: {
      //     // roleCode: val.roleCode,
      //     // roleCode: "647733085966045184"
      //   },
      // }).then((res) => {
      //   let men = res.data.functions;
      //   let newmen = [];
      //   for (let i in men) {
      //     if (men[i].jspUrl != "#") {
      //       newmen.push(men[i]);
      //     }
      //   }
      //   console.log("array", newmen);
      //   this.menuqList = newmen;
      //   let newmen1 = [];
      //   for (let b in this.menuqList) {
      //     for (let a in this.numHits) {
      //       if (this.menuqList[b].jspUrl == this.numHits[a].jsp_url) {
      //         newmen1.push(this.numHits[a]);
      //       }
      //     }
      //   }
      //   console.log(this.numHits)
      //   console.log([...newmen1]);
      // });
      this.$http({
        url: "/market/clickRate/queryClickRate",
        method: "post",
        headers: {
          "Content-Type": "application/json",
        },
        data: {},
      }).then((res) => {
        let men = res.data;
        let newmen = [];
        for (let i in men) {
          if (men[i].jspUrl != "#") {
            newmen.push(men[i]);
          }
        }
        this.numHits = newmen;
      });
    },
  },
  mounted() {
    this.getpeo();
    this.getNotice();
    this.getTags();
    this.getnumberHit();
  },
};
</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: 10px;
    overflow-y: scroll;
    padding: 0 0 0 15px;
  }
}

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

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

.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;
  }
}
.car-line {
  height: 40px;
  background: #fff;
  border-radius: 5px;
  // 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;
    }
  }
}
</style>
