<template>
  <section class="homeRTGT">
    <div class="htaTitle">
      <!-- <span class="TitleName"><i></i><strong>挂图作战</strong></span> -->
      <span class="TitleTab"><em v-for='(item,index) in titleArr' :key='index' @click='titleClick(item,index)'
          :class='inx==index?"active":""'>{{item.item_classify_name}}</em></span>
      <span class="more" @click='more'>更多<img src="~@/assets/images/RTImgs/moreicon.png"></span>
    </div>
    <div class="htaBoxInfoDy">
      <div class="tableContent">
        <ul class="newslistul">
          <li v-for="(item,index) in tableDataNewsList" :key='index' @click="DialogVisible = true;newsdetailli(item)">
            <span v-if='index==0'><em><img :src="item.imgpath"><strong>{{item.item_title}}</strong></em></span>
            <span v-else><b>{{item.item_title}}</b></span>
          </li>
          <!-- <li>
                        <span><em><img src="~@/assets/images/newtest.png"><strong>文字文字5555555文字5555555文字55555555555555</strong></em></span>
                        <span><b>测试文字1111测试文字1111测试文字1111测试文字1111测试文字1111测试文字1111</b></span>
                        <span><b>测试文字1111</b></span>
                        <span><b>测试文字1111</b></span>
                    </li> -->
        </ul>
      </div>
    </div>

    <!-- 弹窗 -->
    <el-dialog title="" :visible.sync="DialogVisible" :close-on-click-modal="false" width="90%" class="dialogpic"
      center>
      <span class="dialogImg">
        <section class="newsContent">
          <h3>{{detailContent.item_title}}</h3>
          <span class="linebottom"><em>{{detailContent.item_article}}</em><b><i
                class="el-icon-view"></i><strong>{{detailContent.item_readcount}}</strong></b>
            <el-divider direction="vertical"></el-divider> <b><i
                class="el-icon-time"></i><strong>{{detailContent.item_time}}</strong></b>
          </span>
          <el-divider></el-divider>
          <span class="nr" v-html="detailContent.item_content"></span>
          <el-divider></el-divider>
          <span class="fj" v-if='detailContent.fjArr'>
            <strong>附件：</strong>
            <ul>
              <li v-for="(item,index) in detailContent.fjArr" :key='index' @click='fjclick(item)'>{{item.name}}</li>
            </ul>
          </span>
        </section>
      </span>
    </el-dialog>

  </section>
</template>
<script>
export default {
  data() {
    return {
      titleArr: [
        { name: "信息化动态", type: 1 },
        { name: "信息化工作思路", type: 2 },
      ],
      inx: 0,
      params: {
        //搜索条件
        pageIndex: 1,
        pageSize: 3,
        total: 0,
      },
      type: 1,
      tableDataNewsList: [],
      tableData: [],
      tableData2: [],
      tableData3: [],
      DialogVisible: false,
      detailContent: {},
    };
  },
  mounted() {
    this.newsCate();
  },
  methods: {
    newsCate() {
      this.$api.newsCateApi(this.params, {
        onSucess: (response) => {
          console.log(response);
          let newsData = response.data.data.filter((item) => {
            return item.item_workbench == "是";
          });
          this.titleArr = newsData;
          // console.log(this.titleArr)
          let item = this.titleArr[0]; //默认取第一个分类的列表
          this.newslist(item);
        },
      });
    },
    titleClick(item, index) {
      this.inx = index;
      this.type = item.type;
      this.newslist(item);
    },
    newslist(item) {
      let jsonData = {
        classificationid: item.classificationid,
        ...this.params,
      };
      this.$api.newslistApi(jsonData, {
        onSucess: (response) => {
          console.log(response.data.data);
          this.tableDataNewsList = response.data.data;
          this.tableDataNewsList.forEach((item) => {
            if (item.item_image) {
              let path = JSON.parse(item.item_image)[0].path;
              if (path.indexOf("http") > -1) {
                this.$set(item, "imgpath", path);
              } else {
                this.$set(item, "imgpath", "/obpm" + path);
              }
            }
          });
        },
      });
    },
    newsdetailli(item) {
      let jsonData = { articleid: item.articleid, ...this.params };
      this.$api.newsdetailliApi(jsonData, {
        onSucess: (response) => {
          console.log(response.data.data);
          this.detailContent = response.data.data[0];
          if (this.detailContent.item_enclosure) {
            this.detailContent.fjArr = JSON.parse(
              this.detailContent.item_enclosure
            );
          }
        },
      });

      this.$api.newsdetailReadingApi(jsonData, {
        onSucess: (response) => {
          console.log(response.data.data);
        },
      });
    },
    fjclick(item) {
      if (item.path.indexOf("http") > -1) {
        window.open(item.path);
      } else {
        window.open("/obpm" + item.path);
      }
    },
    more() {
      this.$parent.$parent.$parent.$parent.navtopmenuclick(6);
      // if(this.type==1){
      //      let appId='__Hab04s0VNDPrjFZ3Xlo'
      //     let name='挂图作战'
      //     let flag=1
      //     this.$store.dispatch("loadMenus", {appId, name,flag});
      // }else if(this.type==2){
      //     let appId='__l8yB8fdHv3OmXOrHfyF'
      //     let name='进度滞后预警'
      //     let flag=1
      //     this.$store.dispatch("loadMenus", {appId, name,flag});
      // }else if(this.type==3){
      //     let appId='__u1xGyTCVhsSaWrgdBed'
      //     let name='联合专班日报'
      //     let flag=1
      //     this.$store.dispatch("loadMenus", {appId, name,flag});
      // }
    },
  },
};
</script>
<style lang="scss" scoped>
.homeRTGT {
  display: flex;
  flex-direction: column;
  background: #fff;
  box-shadow: 0px 6px 16px 0px rgba(0, 0, 0, 0.08),
    0px 3px 6px -4px rgba(0, 0, 0, 0.12);
  border-radius: 8px;
  .htaTitle {
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    font-size: 18px;
    color: rgba(0, 0, 0, 0.85);
    padding: 16px;
    display: flex;
    align-items: center;
    .TitleName {
      display: flex;
      align-items: center;
      margin-right: 40px;
      i {
        width: 2px;
        height: 18px;
        background: #0e71ff;
        margin-right: 4px;
      }
      strong {
        color: rgba(0, 0, 0, 0.85);
        font-size: 16px;
      }
    }
    .TitleTab {
      flex: 1;
      em {
        margin-right: 15px;
        font-size: 16px;
        padding-bottom: 16px;
        cursor: pointer;
        &.active {
          border-bottom: 1px solid #0076f6;
          color: #0076f6;
        }
      }
    }
    .more {
      flex-wrap: 150px;
      font-size: 14px;
      cursor: pointer;
      color: rgba(0, 0, 0, 0.45);
      display: flex;
      align-items: center;
    }
  }
  .htaBox {
    padding: 16px 0 16px 16px;
    ul {
      display: flex;
      flex-wrap: wrap;
      align-content: flex-start;

      li {
        background: #fff;
        width: 140px;
        height: 100px;
        border-radius: 4px;
        display: flex;
        flex-direction: column;
        padding: 16px;
        margin-right: 16px;
        margin-bottom: 16px;
        align-items: center;
        text-align: center;
        span {
          margin-bottom: 8px;
          img {
            width: 48px;
            height: 48px;
          }
          strong {
            color: rgba(0, 0, 0, 0.85);
            font-size: 14px;
            font-weight: normal;
          }
        }
      }
    }
  }
  .scrollbarClass {
    .el-scrollbar__wrap {
      overflow: scroll !important;
      height: calc(100% + 20px) !important; //多出来的20px是横向滚动条默认的样式
    }
    .el-table--scrollable-x .el-table__body-wrapper {
      overflow-x: hidden !important;
    }
  }

  .htaBoxInfoDy {
    .newslistul {
      display: flex;
      flex-direction: column;
      height: 260px;
      overflow: auto;
      li {
        padding: 10px;
        display: flex;
        flex-direction: column;
        cursor: pointer;
        span {
          em {
            position: relative;
            display: flex;
            img {
              width: 100%;
              height: 150px;
            }
            strong {
              position: absolute;
              bottom: 0;
              left: 0;
              right: 0;
              background: rgba(0, 0, 0, 0.3);
              color: #fff;
              padding: 10px 0;
              text-indent: 10px;
              display: block;
              overflow: hidden;
              text-overflow: ellipsis;
              white-space: nowrap;
              width: 500px;
            }
          }
          b {
            color: rgba(0, 0, 0, 0.65);
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            width: 500px;
            display: block;
          }
        }
      }
    }
  }
}
</style>
<style lang="scss" scoped>
.newsContent {
  display: flex;
  flex-direction: column;
  h3 {
    text-align: center;
    margin-bottom: 10px;
  }
  .linebottom {
    display: flex;
    justify-content: center;
    align-items: center;
    color: rgba(0, 0, 0, 0.65);
    em {
      color: #0f71ff;
      margin-right: 30px;
    }
    b {
      strong {
        font-weight: normal;
      }
    }
  }
  .nr {
  }
  .fj {
    ul {
      li {
        cursor: pointer;
        color: #0e71ff;
        text-decoration: underline;
      }
    }
  }
}
</style>