<template>
  <div class="all-box">
    <el-dialog :close-on-click-modal="false" title="提醒录入费用列表" :visible.sync="homeVisible">
      <div style="color: red;font-size: 14px;font-weight: 600;">PS: 请确认以下团组是否发生成本，有的话请及时录入成本费用，以便于财务收款！</div>
      <el-table height="500px" border :data="gridData" @selection-change="handleSelectionChange">
        <el-table-column type="selection" width="55"></el-table-column>
        <el-table-column property="groupName" label="团组名称"></el-table-column>
        <el-table-column property="visitDate" label="出访日期">
          <template slot-scope="scope">
           {{processingdate(scope.row.visitDate)}}
          </template>
        </el-table-column>
        <el-table-column label="操作" width="120px">
          <template slot-scope="scope">
            <el-button size="mini" @click="Confirmknow(scope.row.id)" type="primary">无成本费用</el-button>
          </template>
        </el-table-column>
      </el-table>
      <div style="margin-top: 15px;text-align: right;">
        <el-button @click="Confirmknow('批量')" type="primary">无成本费用（批量）</el-button>
      </div>
    </el-dialog>
    <div class="home-dialog">
      <el-dialog :close-on-click-modal="false" top="0" title="系统通知" :visible.sync="dialogVisible" width="30%">
        <el-tabs v-model="activeName" type="card" @tab-click="handleClick">
          <el-tab-pane v-for="(msgitem,index) in msgtype" :key="index" :label="msgitem.id+''" :name="msgitem.name">
            <span slot="label">
              {{ msgitem.name }}
              <el-badge :hidden="msgitem.unReadCount==0?true:false" :value="msgitem.unReadCount" :max="9999"></el-badge>
            </span>
          </el-tab-pane>
          <div class="msg-box">
            <div class="read-btn">
              <el-button type="primary" @click="taskclicks(2)" size="mini" :plain="tasknobtn">未读</el-button>
              <el-button type="primary" @click="taskclicks(3)" size="mini" :plain="taskbtn">已读</el-button>
            </div>
            <div class="scroll-box">
              <div class="news-box" v-for="(item,index) in msglist" :key="index">
                <div class="news-box-list">
                  <div class="news-list-hade">
                    <div v-if="type==1021">系统通知</div>
                    <div v-if="type!=1021">{{item.title}}</div>
                    <div v-if="type!=1021">所属部门: {{item.issuerDep}}</div>
                  </div>
                  <div class="news-list-content" v-html="item.content">
                  </div>
                  <div class="news-list-posts">
                    <div v-if="type==1020">发布人: {{item.issuerUser}}</div>
                    <div v-if="type==1020">发布时间: {{item.releaseTime}}</div>
                    <div v-if="type!=1020">发送时间: {{item.releaseTime}}</div>
                  </div>
                  <div v-if="type==1020" class="news-list-btn">
                    <el-button @click="DeleMsg(index,item)" size="mini" v-if="item.isRead==0"
                      type="primary">前往任务</el-button>
                    <el-button v-if="item.isRead==1" size="mini" type="info">已读任务</el-button>
                  </div>
                  <div v-else class="news-list-btn">
                    <el-button @click="DeleMsg(index,item)" size="mini" v-if="item.isRead==0"
                      type="primary">确认已读</el-button>
                    <el-button v-if="item.isRead==1" size="mini" type="info">已读</el-button>
                  </div>
                </div>
              </div>
              <div v-if="count>10&&msglist.length<count" class="loadmore">
                <el-button @click="loadadd" size="mini">加载更多</el-button>
              </div>
              <el-divider v-if="msglist.length>=count">没有更多了！</el-divider>
            </div>
          </div>
        </el-tabs>
      </el-dialog>
    </div>
    <div class="gpt-dialog">
      <el-dialog :close-on-click-modal="false" top="3vh" width="1600px" title="请自行用手机号注册即可使用" :visible.sync="gptdialog">
        <iframe :src="indexsrc" width="100%" height="800px"></iframe>
      </el-dialog>
    </div>
    <el-container class="all">
      <el-aside class="delwh menubar">
        <div ref="haeds" class="user">
          <div class="user-box">
            <div class="user-img">
              <img src="../assets/logo2.png" />
            </div>
            <div v-if="panduan" class="user-text">
              泛美国际 - AI智能办公系统
            </div>
          </div>
        </div>
        <div ref="avatarhaeds" class="avatar-box">
          <div class="nei-avatar">
            <div class="avatar">
              <div class="avatar-img">
                <img v-if="sex==1" src="../assets/nv.png" alt="" />
                <img v-else src="../assets/nan.png" alt="" />
              </div>
              <div v-if="panduan" class="avatar-text">
                <div class="avatar-name">员工: {{ userinif.userInfo.cnName }}</div>
                <div class="avatar-division">职位: {{ userinif.userInfo.jobName }}</div>
                <div>部门: {{ userinif.userInfo.depName }}</div>
                <div>系统版本: {{ systemversion }}</div>
              </div>
            </div>
          </div>
        </div>
        <el-menu :style="gaodu" :default-active="indexs" class="el-menu-vertical-demo meun-ul" @open="handleOpen"
          @close="handleClose" :collapse="isCollapse">
          <el-menu-item v-for="(item, filindex) in filmenuList" :key="filindex + '/'"
            :index="item.modulid + '-' + item.pageList[0].pageid" @click="toURLs($event.index, item)">
            <i :class="iconfont+item.remark"></i>
            <span slot="title">{{ item.pageList[0].pageName }}</span>
          </el-menu-item>
          <el-submenu v-for="(item, index) in filmenuLists" :key="index" :index='item.modulid + ""'
            @click="toURL($event.index)">
            <template slot="title">
              <i :class="iconfont+item.remark"></i>
              <span>{{ item.modulName }}</span>
            </template>
            <el-menu-item-group>
              <el-menu-item @click="toURL($event.index, items)" v-for="(items, index) in item.pageList" :key="index"
                :index="items.modulid + '-' + items.pageid">{{ items.pageName }}</el-menu-item>
            </el-menu-item-group>
          </el-submenu>
        </el-menu>
      </el-aside>
      <el-container>
        <el-header>
          <div class="btnradio">
            <el-radio-group v-model="isCollapse" @change="radioChange($event)">
              <el-radio-button :class="classA" class="radiobox" :label="false"><span
                  class="iconfont icon-caidanzhankai icon"></span></el-radio-button>
              <el-radio-button :class="classB" class="radiobox" :label="true"><span
                  class="iconfont icon-caidanshouqi icon"></span></el-radio-button>
            </el-radio-group>
            <div class="header-title">首页</div>
          </div>
          <div class="name-box">
            <div class="instrument" @click="Openitactively">
              <i class="iconfont icon-wenjian"></i>
            </div>
            <div class="instrument" @click="instrumentclick('.instrument-box', $event)">
              <i class="iconfont icon-shiyonggongju"></i>
            </div>
            <div class="message">
              <el-badge :value="unReadCount" class="item">
                <i class="iconfont icon-tongzhi" @click="dialogVisible= true"></i>
              </el-badge>
            </div>
            <div class="user-inif" @click="instrumentclick('.user-operate', $event)">
              <div class="user-inifs">
                <img v-if="sex==1" src="../assets/nv.png" alt="" />
                <img v-else src="../assets/nan.png" alt="" />
              </div>
            </div>
          </div>
          <div class="instrument-box">
            <div class="instrument-box-title">实用工具</div>
            <div class="instrument-box-inif">
              <div class="box-inif-ul">
                <div @click="gptdialogbtn('KIMI')" class="box-inif-li">
                  <div class="inif-li-img">
                    <img src="../assets/kimi.png" alt="" />
                  </div>
                  <div class="inif-li-text">KIMI</div>
                </div>
                <div @click="gptdialogbtn('有道')" class="box-inif-li">
                  <div class="inif-li-img">
                    <img src="../assets/youdao.png" alt="" />
                  </div>
                  <div class="inif-li-text">有道</div>
                </div>
                <div @click="opengpt" class="box-inif-li">
                  <div class="inif-li-img">
                    <img src="../assets/gpt.png" alt="" />
                  </div>
                  <div class="inif-li-text">GPT</div>
                </div>
              </div>
            </div>
          </div>
          <div class="user-operate">
            <div class="operate-title">
              <div class="avatar">
                <div class="avatar-img">
                  <img v-if="sex==1" src="../assets/nv.png" alt="" />
                  <img v-else src="../assets/nan.png" alt="" />
                </div>
                <div class="avatar-text">
                  <div class="avatar-name">姓名:{{ userinif.userInfo.cnName }} 部门: {{ userinif.userInfo.depName }}</div>
                  <div class="avatar-division">职位: {{ userinif.userInfo.jobName }}</div>
                </div>
              </div>
            </div>
            <div class="operate-ul">
              <!-- <div class="operate-li">全屏</div>
              <div class="operate-li">修改密码</div>
              <div class="operate-li">个人资料</div> -->
              <div @click="logOut()" class="operate-li">退出</div>
            </div>
          </div>
        </el-header>
        <div class="Jumplists">
          <el-breadcrumb separator="|" class="Jumparr-ul" @mousedown.native="downCursor" @mousemove.native="moveCursor"
            :style="{transform: 'translateX('+disX+'px)'}">
            <el-breadcrumb-item v-for="(item,index) in Jumparr" :key="index" :to="{ path: '/home'+item.webUrl }">
              <div class="Jumparr-li" :class="{'activeCss':activeVar==item.indexs}" @click="SelectJump(item,index)">
                <div style="display: flex;align-items: center;">
                  <div>{{item.pageName}}</div>
                  <div v-if="!item.pageName.includes('主页')" @click.stop="Jumparrdel(item,index)" class="Jumparr-cha">✖
                  </div>
                  <div v-else class="Jumparr-chas"></div>
                </div>
              </div>
            </el-breadcrumb-item>
          </el-breadcrumb>
        </div>
        <el-main style="height: 100%;">
          <router-view @transfer="getUser" />
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>
<script>
//import * as signalR from "@aspnet/signalr";
// const signalR=require('@microsoft/signalr')
// import * as signalR from "@microsoft/signalr";
// import * as signalR from "../../node_modules/microso";
// import child from '~/components/Finance/FeesPage';
// const signalR=require('@microsoft/signalr')
 
export default {
  data() {
    return {
      systemversion: 'V1.0.1',
      userId:'',
      token:'',
      menuList: [],
      isCollapse: false,
      panduan: "",
      username: "雷怡",
      indexs: "1",
      pdinstrument: true,
      userinif: '',
      dialogVisible: false ,
      newstasklist:[],
      newsgrouplist:[],
      activeName: '',
      tasknot:0,//任务未读条数
      groupnot:0,//团组未读条数
      tasknotlist:[],//任务未读
      taskReadlist:[],//任务以读
      groupnotlist:[],//团组未读
      groupReadlist:[],//团组以读
      taskbtn:true,//plain任务已读
      tasknobtn:false,//plain任务未读
      groupbtn:true,//plain团组已读
      groupnobtn:true,//plain团组未读
      unReadCount:0,//未读总条数
      msgtype:[],//未读总条数
      pageIndex:1,//页码
      pageSize:10,//条数
      type:0,//类型
      readStatus:2,//状态
      msglist:[],//list
      count:0,//list数量
      panduans:false,
      iconfont:'iconfont ',
      gaodu:'',
      gptdialog:false,
      indexsrc:'',
      sex:0,
      classA:'',
      classB:'',

      ////////////
      Jumparr:[],
      activeVar:0,
      Cursoridentification:false,
      Jumparrul:'',
      Jumparrbox:'',
      disX:0,
      disXs:0,


      ///定时访问
      currentTime: '',
      nextExecution: '',
      status: '等待中',
      timer: null,
      gridData:[],
      homeVisible:false,
      multipleSelection:[],
    };
  },
  // components: {
  //   child
  // },
  methods: {
    //处理日期
    processingdate(vals){
        vals=vals+""
        return vals.split(' ')[0]
    },
    //鼠标按下事件
    downCursor(e){
      this.Cursoridentification=true;
      this.disXs = e.clientX;
      let dragWidth = this.Jumparrul[0].offsetWidth;
      // console.log(this.Jumparrul[0].scrollWidth + '-------小盒子');
      // console.log(this.Jumparrbox[0].scrollWidth +'-------大盒子');
      document.onmousemove = (e) => {
        if (this.Cursoridentification == true) {
          let moveX = e.clientX - this.disXs;
          if (moveX >= 0) {
            moveX = 0;
          }
          this.disX = moveX;
          // console.log(e.clientX+'-------鼠标');
          console.log(this.Jumparrul[0].scrollWidth + '-------小盒子');
          // console.log(this.Jumparrul[0]);
          console.log(this.Jumparrbox[0].scrollWidth +'-------大盒子');
          // console.log(this.Jumparrbox[0]);
        }
      };
      document.onmouseup = (e) => {
        // let moveXs=e.clientX - this.disXs;
        // if (moveXs >= 0) {
        //   this.disX = 0;
        // }
        document.onmousemove = null;
        this.Cursoridentification=false
      };
    },
    moveCursor(e){
      // if (this.Cursoridentification==true) {
      //   let moveX = e.clien tX - this.disXs;
      //   console.log(moveX);
        
      //   if (moveX <= 0) {
      //     moveX = 0;
      //   }
      //   this.disX=moveX
      // }
      
    },
    upCursor(){
      // console.log('songkai');
      // this.Cursoridentification=false
    },
    //子传父
    getUser(msg){
      console.log(msg);
      this.radioChange(msg);
    },
    handleOpen(key, keyPath) {
      console.log(key, keyPath);
    },
    handleClose(key, keyPath) {
      console.log(key, keyPath);
    },
    //移除element行内样式
    removal() {
      document.querySelector(".menubar").style.height = window.innerHeight + "px";
      document.querySelector(".all").style.height = window.innerHeight + "px";
      document.querySelector(".delwh").style.width = "";
      document.querySelector(".meun-ul").style.height=(window.innerHeight-(this.$refs.haeds.offsetHeight+this.$refs.avatarhaeds.offsetHeight))+'px';
      console.log(window.innerHeight-(this.$refs.haeds.offsetHeight+this.$refs.avatarhaeds.offsetHeight))
    },
    toURLs(val, item) {
      this.activeVar=val;
      localStorage.setItem("indexs", val);
      localStorage.setItem("innhtml", item.pageList[0].pageName);
      localStorage.setItem("Permissions", JSON.stringify(item.pageAuth));
      this.$router.push({ path: "/home" + item.pageList[0].webUrl });
      document.querySelector(".header-title").innerHTML = item.pageList[0].pageName;
    },
    toURL(val, item) {
      this.activeVar=val;
      this.Jumparr.push(
        {
          pageName:item.pageName,
          webUrl:item.webUrl,
          indexs:val,
        }
      )
      let nArr = this.Jumparr.filter((currentValue, currentIndex, selfArr) => {
        return selfArr.findIndex(x =>x.pageName === currentValue.pageName) === currentIndex
      });
      this.Jumparr=nArr
      console.log(this.Jumparr);
      localStorage.setItem('Jumparr', JSON.stringify(this.Jumparr));
      localStorage.setItem("indexs", val);
      localStorage.setItem('activeVar', JSON.stringify(val));
      localStorage.setItem("innhtml", item.pageName);
      localStorage.setItem("Permissions", JSON.stringify(item.pageAuth));
      this.$router.push({ path: "/home" + item.webUrl });
      document.querySelector(".header-title").innerHTML = item.pageName;
    },
    //yeneiyemian
    gptdialogbtn(val){
      this.indexsrc='';
      this.gptdialog = true;
      if(val=='KIMI'){
        this.indexsrc='https://kimi.moonshot.cn';
      }
      if(val=='有道'){
        this.indexsrc='https://fanyi.youdao.com/#/AITranslate?keyfrom=fanyiweb_tab'
      }
    },
    //打开gpt
    opengpt(){
      window.open('https://chat.openai.com')
    },
    
    radioChange(val) {
      this.gaodu='height:'+ (window.innerHeight-(this.$refs.haeds.offsetHeight+this.$refs.avatarhaeds.offsetHeight))+'px'
      var radiobox = document.querySelectorAll(".radiobox");
      console.log(radiobox)
      if (val == true) {
        this.panduan = false;
        document.querySelector(".user-text").style.display = "none";
        document.querySelector(".avatar-text").style.display = "none";
        this.isCollapse=val
        radiobox[1].style.display = "none";
        radiobox[0].style.display = "inline-block";
      } else if (val == false) {
        this.panduan = true;
        this.isCollapse=val
        radiobox[1].style.display = "inline-block";
        radiobox[0].style.display = "none";
      }
    },
    ifIndexValue() {
      this.indexs = localStorage.getItem('indexs');
      document.querySelector(".header-title").innerHTML = localStorage.getItem('innhtml');
    },
    //实用工具
    instrumentclick(val, evt) {
      if (document.querySelector(val).style.top != "60px") {
        evt.currentTarget.style.backgroundImage = "linear-gradient(rgba(29,33,41,.03),rgba(29,33,41,.1))";
        evt.currentTarget.firstElementChild.style.color = "#666";
        document.querySelector(val).style.top = 60 + "px";
      } else {
        evt.currentTarget.style.backgroundImage = "";
        evt.currentTarget.firstElementChild.style.color = "";
        document.querySelector(val).style.top = -570 + "px";
      }
    },
    getmenu() {
      this.menuList = JSON.parse(localStorage.getItem('userinif')).authData;
      var that = this
      this.menuList.filter(function (item) {
        if (item.modulName == '主页') {
          if (that.Jumparr.length==0) {
            that.Jumparr.push({
              pageName:item.pageList[0].pageName,
              webUrl:item.pageList[0].webUrl,
              indexs:item.modulid+'-'+item.pageList[0].pageid,
            })
            that.activeVar=item.modulid+'-'+item.pageList[0].pageid,
            localStorage.setItem('Jumparr', JSON.stringify(that.Jumparr));
          }
          return item
        }
      })
    },
    //登出
    logOut() {
      this.$confirm('此操作将退出此账号, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.$router.push({ name: 'Login' })
        localStorage.clear();
        this.$message({
          type: 'success',
          message: '已退出!'
        });
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消退出'
        });
      });
      // this.$router.push({name:'Login'})
      // localStorage.clear();
    },
    fatherMethod() {
      console.log('测试');
    },
    handleClick(tab, event) {
      this.pageIndex=1;
      this.pageSize=10;
      this.msglist=[];
      this.type=Number(tab.label);
      this.PotsMessagePageList();
    },
    //已读未读切换
    taskclicks(val){
      if(val==2){
        this.tasknobtn=false;
        this.taskbtn=true;
      }else{
        this.tasknobtn=true;
        this.taskbtn=false;
      }
      this.readStatus=val;
      this.pageIndex=1;
      this.pageSize=10;
      this.msglist=[];
      this.PotsMessagePageList();
    },
    //加载更多
    loadadd(){
      this.pageIndex++
      this.PotsMessagePageList()
    },
    //确认知晓
    Confirmknow(val){
      var arrdiid=[];
      if (val=='批量') {
        arrdiid=this.multipleSelection.map(item=>item.id)
        if (arrdiid.length==0) {
          this.$message.error("请至少选择一条数据进行确认知晓！");
          return
        }
      }else{
        arrdiid.push(val)
      }
      var url = "/api/Groups/FeeEntryAcknowledgeCrate"
      var that = this
      this.$axios({
          method: 'post',
          url: url,
          headers: {
              Authorization: 'Bearer ' + that.token
          },
          data:{
            currUserId:that.userId,
            groupIds:arrdiid,
            daysAgo:10
          }
      }).then(function (res) {
          if(res.data.code==200){
            that.$message({
              type: 'success',
              message: res.data.msg
            });
            that.gridData=res.data.data.groupNames;
          }else{
            that.$message.error(res.data.msg);
          }
      }).catch(function (error) {
          that.$message.error("获取消息列表失败！");
      });
    },
    //消息list
    PotsMessagePageList(){
      console.log(this.type)
      var url = "/api/System/PotsMessagePageList"
      var that = this
      this.$axios({
          method: 'post',
          url: url,
          headers: {
              Authorization: 'Bearer ' + that.token
          },
          data:{
            portType:1,
            pageIndex:that.pageIndex,
            pageSize:that.pageSize,
            type:that.type,
            userId:that.userId,
            readStatus:that.readStatus
          }
      }).then(function (res) {
          console.log(res)
          if(res.data.code==200){
            var magarr=res.data.data;
            that.count=res.data.count;
            for(let j=0;j<magarr.length;j++){
              that.msglist.push(magarr[j])
            }
          }else{
            that.$message.error(res.data.msg);
          }
      }).catch(function (error) {
          that.$message.error("获取消息列表失败！");
      });
    },
    //任务通知切换
    newstasklistclick(){
      console.log(this.newstasklist)
    },
    //消息类型
    PotsMsgTypeData(){
      this.msglist=[];
      var url = "/api/System/PotsMsgTypeData"
      var that = this
      this.$axios({
          method: 'post',
          url: url,
          headers: {
              Authorization: 'Bearer ' + that.token
          },
          data:{
            portType:1,
            userId:that.userId
          }
      }).then(function (res) {
          console.log(res)
          if(res.data.code==200){
            that.msgtype=res.data.data;
            if(!that.panduans){
              that.activeName=that.msgtype[0].name;
              that.type=that.msgtype[0].id;
            }
            that.panduans=false
            that.PotsMessagePageList()
          }else{
            that.$message.error(res.data.msg);
          }
      }).catch(function (error) {
          that.$message.error(error);
      });
    },
    //未读条数
    PotsMessageUnreadTotalCount(){
        var url = "/api/System/PotsMessageUnreadTotalCount"
        var that = this
        this.$axios({
            method: 'post',
            url: url,
            headers: {
                Authorization: 'Bearer ' + that.token
            },
            data:{
              userId:that.userId
            }
        }).then(function (res) {
            if(res.data.code==200){
              that.unReadCount=res.data.data.messageUnReadCount;
              if(that.unReadCount!=localStorage.getItem('unReadCount')){
                that.PotsMsgTypeData();
                window.localStorage.removeItem('unReadCount');
                localStorage.setItem('unReadCount', JSON.stringify(that.unReadCount));
              }else{
                console.log('没有新通知！')
              }
                // return res.data.data.unreadCount;
            }else if(res.data.code==204){
                localStorage.clear();
                that.$router.push({ name: 'Login' })
                that.$message.error(res.data.msg);
            }
            else{
                that.$message.error(res.data.msg);
            }
        }).catch(function (error) {
            that.$message.error(error);
        });
    },
    //消息确认已读
    DeleMsg(index,row){
      this.$confirm('此操作将认定你已知晓此通知?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        var url = "/api/System/SetMessageRead"
        var that = this
        this.$axios({
            method: 'post',
            url: url,
            headers: {
                Authorization: 'Bearer ' + that.token
            },
            data:{
              portType:1,
              msgId:row.id,
              userId:that.userId
            }
        }).then(function (res) {
            console.log(res)
            if(res.data.code==200){
              if(that.type==1020){
                that.$router.push({ path: "/home/TaskList"});
                that.dialogVisible=false;
              }
              that.panduans=true;
              that.PotsMsgTypeData();
              that.$message({
                type: 'success',
                message: res.data.msg
              });
            }else{
              that.$message.error(res.data.msg);
            }
        }).catch(function (error) {
            that.$message.error("确认已读失败！");
        });
        
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消确认已读'
        });          
      });
      console.log(index,row)
      console.log(this.type)
      
    },
    //修改未读条数
    uplocal(){
      window.localStorage.removeItem('unReadCount');
      this.unReadCount--;
      localStorage.setItem('unReadCount', JSON.stringify(this.unReadCount));
    },
    //任务切换
    taskclick(text){
      if(text=='未读'){
        this.newstasklist=this.tasknotlist
        this.tasknobtn=false;
        this.taskbtn=true;
      }else{
        this.newstasklist=this.taskReadlist
        this.tasknobtn=true;
        this.taskbtn=false;
      }
      console.log(this.newstasklist)
    },
    //团组切换
    groupclick(text){
      if(text=='未读'){
        this.newsgrouplist=this.groupnotlist
        this.groupnobtn=false;
        this.groupbtn=true;
      }else{
        this.newsgrouplist=this.groupReadlist
        this.groupnobtn=true;
        this.groupbtn=false;
      }
    },
    //消息通知
    chatHub(){
        var url = "/api/chatHub"
        var that = this
        this.$axios({
            method: 'post',
            url: url,
            headers: {
                Authorization: 'Bearer ' + that.token
            },
            data:{
              userId:that.userId
            }
        }).then(function (res) {
            console.log(res)
            if(res.data.code==200){
              
            }else{
                that.$message.error(res.data.msg);
            }
        }).catch(function (error) {
            that.$message.error("获取数据源失败！");
        });
    },

    handleClosezz(done) {
      this.$confirm('确认关闭？')
        .then(_ => {
          done();
        })
        .catch(_ => {});
    },
    setIntervaltime(){

    },
    SelectJump(item,index){
      this.activeVar=item.indexs;
      this.indexs=item.indexs;
      localStorage.setItem("indexs", this.indexs);
      localStorage.setItem('activeVar', JSON.stringify(this.activeVar));
    },
    Jumparrdel(item,index){
      this.Jumparr.splice(index, 1);
      localStorage.setItem('Jumparr', JSON.stringify(this.Jumparr));
      console.log(item);
      if(item.indexs==JSON.parse(localStorage.getItem('activeVar'))){
        this.$router.push({ path: "/home" + this.Jumparr[0].webUrl });
        this.indexs=this.Jumparr[0].indexs;
        this.activeVar=this.Jumparr[0].indexs;
      }
      // this.activeVar= JSON.parse(localStorage.getItem('activeVar')) || 0;
    },

    handleSelectionChange(val) {
      this.multipleSelection = val;
      console.log(this.multipleSelection);
      
    },
    //10点钟定时
    getNextExecutionTime() {
      const now = new Date()
      const targetTime = new Date()
      // 设置目标时间为今天的10:00:00
      targetTime.setHours(10, 0, 0, 0)
      // 如果今天10点已过，设置为明天10点
      if (now > targetTime) {
        targetTime.setDate(targetTime.getDate() + 1)
      }
      return targetTime
    },
    
    calculateTimeUntilNext() {
      const now = new Date()
      const nextTime = this.getNextExecutionTime()
      const diff = nextTime - now
      
      return {
        nextTime,
        diff

      }
    },
    
    async executeTask() {
      try {
        this.status = '执行每日任务中...'
        var that = this;
        this.$axios({ 
          method: 'get',
          url: '/api/Groups/GetGroupNamesByUserId?currUserId='+this.userId+'&daysAgo=8',
           
        }).then(function (res) {
          console.log(res);
          if(res.data.code==200){
            that.gridData=res.data.data.groupNames;
            that.homeVisible=res.data.data.isTips;
          }
        })
        this.status = `今日任务已完成 (${new Date().toLocaleTimeString()})`
        // 重新设置下一次执行
        this.scheduleNextExecution()
      } catch (error) {
        console.error('任务执行失败:', error)
        this.status = '执行失败，1分钟后重试'
        setTimeout(this.scheduleNextExecution, 60000)
      }
    },
    Openitactively(){
      this.homeVisible = true;
      var that = this;
      this.$axios({
        method: 'get',
        url: '/api/Groups/GetGroupNamesByUserId?currUserId=' + this.userId + '&daysAgo=8',

      }).then(function (res) {
        console.log(res);
        if (res.data.code == 200) {
          that.gridData = res.data.data.groupNames;
          that.homeVisible = res.data.data.isTips;
        }
      })
    },
    scheduleNextExecution() {
      const { nextTime, diff } = this.calculateTimeUntilNext()
      this.nextExecution = nextTime.toLocaleString()
      this.status = `等待下一次执行 (${Math.round(diff/1000/60)}分钟后)`
      // 清除之前的定时器
      if (this.timer) {
        clearTimeout(this.timer)
      }
      // 设置新的定时器
      this.timer = setTimeout(() => {
        this.executeTask()
      }, diff)
    },
    
    updateCurrentTime() {
      this.currentTime = new Date().toLocaleString()
    },
    //ding
  },
  mounted() {
    
    // this.unReadCount=JSON.parse(localStorage.getItem('unReadCount'));
    this.Jumparrul = document.getElementsByClassName("Jumparr-ul");
    this.Jumparrbox = document.getElementsByClassName("Jumplists");
    console.log(this.Jumparrul);
    
    this.removal();
    this.radioChange(false);
    this.ifIndexValue();
    this.getmenu();
    
    this.PotsMsgTypeData();

    let timers = setInterval(() => {
      this.PotsMessageUnreadTotalCount();
    }, 10000)
    this.$once('hook:beforeDestroy', () => {
      clearInterval(timers)
      timers = null
    })

    // 每秒更新当前时间
    setInterval(this.updateCurrentTime, 1000)
    this.updateCurrentTime()
    
    // 开始调度
    this.scheduleNextExecution()
    // setTimeout(this.PotsMessagePageList(),500)
    // this.setIntervaltime();
    // setInterval(this.PotsMessageUnreadTotalCount, 10000);
    // setInterval(this.PsotMsgPageList, 3000);
    // this.chatHub();
  },
  beforeUnmount(){
    if (this.timer) {
      clearTimeout(this.timer)
    }
  },
  created() {
    this.userId=JSON.parse(localStorage.getItem('userinif')).userInfo.userId;
    this.sex=JSON.parse(localStorage.getItem('userinif')).userInfo.sex;
    this.token=JSON.parse(localStorage.getItem('userinif')).token;
    this.userinif = JSON.parse(localStorage.getItem('userinif'));
    this.Jumparr= JSON.parse(localStorage.getItem('Jumparr')) || [];
    this.activeVar= JSON.parse(localStorage.getItem('activeVar')) || 0;
    this.PotsMessageUnreadTotalCount();
    // if (this.userId!=21) {
    //     localStorage.clear();
    // }
    // this.startConnection();
  },
  computed: {
    getWsMsg (){
        return this.$store.state.webSocketMsg
    },
    filmenuList: function () {
      return this.menuList.filter(function (item) {
        if (item.modulName == '主页') {
          return item
        }
      })
    },
    filmenuLists: function () {
      return this.menuList.filter(function (item) {
        if (item.modulName != '主页') {
          return item
        }
      })
    }
  },
  watch:{
    PotsMessageUnreadTotalCount:{
      handler(newVal,oldVal) {
          console.log(newVal,oldVal)
      }
    }
  }
};
</script>
<style>
*{
  font-family:"微软雅黑";
  
}
.all-box{
  font-family:"微软雅黑";
  font-size: 13px;
}
.el-menu .el-menu-item.is-active {
  color: #fff;
  background-color: rgba(0, 0, 0, 0.1);
}

body {
  margin: 0;
  padding: 0;
}

html {
  background-color: #fff;
}

.home-dialog .el-dialog{
  position: fixed;
  right: 0;
  height: 100%;
  margin: 0;
}
.el-menu-vertical-demo:not(.el-menu--collapse) {
  width: 260px;
  min-height: 400px;
}

.el-menu {
  border-right: none;
}

.delwh {
  border-right: solid 1px #e6e6e6;
  background-image: linear-gradient(270deg,
      rgba(178, 45, 226, 0.18),
      transparent);
  background-color: #0f619f;
}

.el-menu-vertical-demo {
  background-image: linear-gradient(270deg,
      rgba(178, 45, 226, 0.18),
      transparent);
  background-color: #0f619f;
}
.aligns{
  display: flex;
  justify-content: space-between;
}
.el-header {
  border-bottom: solid 1px #e6e6e6;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
  z-index: 3;
}

.instrument-box {
  position: absolute;
  z-index: 2;
  right: 20px;
  top: -400px;
  width: 350px;
  border-radius: 5px;
  overflow: hidden;
  box-shadow: 0 0 5px #0005;
  transition: all 0.5s;
}

.instrument-box-title {
  background: linear-gradient(250deg, #3e93d6, #8a75aa);
  padding: 20px;
  text-align: center;
  color: #fff;
}

.instrument-box-inif {
  background-color: #fff;
  height: 320px;
  overflow-y: auto;
}

.box-inif-ul {
  display: flex;
  flex-wrap: wrap;
  padding: 10px;
}

.inif-li-text {
  font-size: 12px;
}

.box-inif-li {
  width: 25%;
  height: 81px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  border-radius: 50%;
  padding: 10px;
  margin: 0 3px;
  cursor: pointer;
}

.box-inif-li:hover {
  background-image: linear-gradient(rgba(29, 33, 41, 0.03),
      rgba(29, 33, 41, 0.04));
  color: #967bbd;
  transition: all 0.2s ease;
  transform: translateY(-3px);
    
  
}
.el-submenu:hover{
  transition: all 0.2s ease;
  transform: translateY(-3px);
}
.el-menu-item:hover{
  transition: all 0.2s ease;
  transform: translateY(-3px);
}
.btnradio {
  display: flex;
  align-items: center;
}
.home-dialog .el-dialog__body{
  padding: 0px 20px;
}
.name-box {
  display: flex;
  font-size: 14px;
}

.user-operate {
  position: absolute;
  z-index: 2;
  right: 20px;
  top: -300px;
  width: 310px;
  border-radius: 5px;
  overflow: hidden;
  box-shadow: 0 0 5px #0005;
  transition: all 0.5s;
}

.operate-title {
  background: linear-gradient(250deg, #3e93d6, #8a75aa);
  padding: 20px;
  text-align: center;
  color: #fff;
}

.operate-ul {
  background-color: #fff;
}

.operate-li {
  padding: 12px 24px;
  cursor: pointer;
  color: #555;
}

.operate-li:hover {
  background-image: linear-gradient(rgba(29, 33, 41, 0.03),
      rgba(29, 33, 41, 0.04));
  color: #967bbd;
}

.names {
  margin-right: 20px;
}

.quit {
  cursor: pointer;
}

.btnradio .el-radio-button:first-child .el-radio-button__inner {
  border: none;
}

.el-radio-button:last-child .el-radio-button__inner {
  border: none;
}

.icon {
  font-size: 20px;
}

.el-radio-button__inner {
  padding: 0;
}

.header-title {
  margin-left: 20px;
}

.icon-shouye {
  margin-right: 5px;
  width: 24px;
  text-align: center;
  font-size: 18px;
  vertical-align: middle;
  display: inline-block;
  font-weight: 600;
}

.icon-tongjitu {
  margin-right: 5px;
  width: 24px;
  text-align: center;
  font-size: 18px;
  vertical-align: middle;
  display: inline-block;
  font-weight: 600;
}

.user-img {
  width: 40px;
  height: 40px;
}

.user-img img {
  width: 100%;
  height: 100%;
}

.user-box {
  padding: 10px 0;
  display: flex;
  justify-content: center;
  align-items: center;
}

.user-text {
  /*margin-left: 15px;*/
  font-size: 16px;
  /*font-weight: 600;*/
  color: #fff;
}

.naem-box {
  font-size: 16px;
}

.naem-box div {
  padding-left: 20px;
}

.el-menu-vertical-demo .el-menu-item {
  color: #82c2f3;
}

.el-menu-vertical-demo .el-menu-item:focus,
.el-menu-vertical-demo .el-menu-item:hover {
  background-color: rgba(0, 0, 0, 0.1);
  color: #fff;
}

.el-menu-vertical-demo .el-menu-item i {
  color: #2595ea;
}

.avatar-box {
  height: 9.53rem;
  background-image: url("../assets/cover-2-lg.png");
  background-repeat: no-repeat;
}

.nei-avatar {
  height: 100%;
  background-color: rgba(27, 92, 164, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  transition: all 1.5s;
}

.nei-avatar:hover {
  background-color: rgba(27, 92, 164, 0);
}

.avatar {
  display: flex;
  align-items: center;
  justify-content: center;
}

.avatar-text {
  color: #fff;
  margin-left: 15px;
  font-size: 14px;
  text-align: left;
}

.avatar-text>div {
  line-height: 24px;
}

.avatar-img {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  overflow: hidden;
}

.avatar-img img {
  width: 100%;
}

.user-inifs {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  overflow: hidden;
}

.user-inif img {
  width: 100%;
}

i.icon-shiyonggongju {
  font-size: 31px;
  color: #2198f3;
}
i.icon-wenjian {
    font-size: 31px;
    color: #2198f3;
}
i.icon-tongzhi {
  font-size: 32px;
  color: #2198f3;
}

.name-box>div {
  cursor: pointer;
  margin-left: 15px;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 50px;
  height: 50px;
  border-radius: 50%;
}

.name-box i:hover {
  color: #666;
}

.el-main {
  background-color: #ebf6fd;
}

.inif-li-img {
  width: 50px;
  height: 50px;
}

.inif-li-img img {
  width: 100%;
}
.meun-ul{
  overflow: auto;
}
.meun-ul::-webkit-scrollbar {
  width: 5px;
  height: 10px;
}

.meun-ul::-webkit-scrollbar-track {
  border-radius: 10px;
}

.meun-ul::-webkit-scrollbar-thumb {
  border-radius: 10px;
  box-shadow: inset 0 0 0 rgba(0, 158, 255, 0.46);
  background-color: rgba(0, 158, 255, 0.46);
}
/*消息*/ 
.news-box:last-child{
  border-bottom: 1px solid #EBEEF5;
}
.news-box:hover{
  background-color: #EBEEF5;
}
.news-box{
  border-top: 1px solid #EBEEF5;
  padding: 10px;
}
.news-list-hade{
  display: flex;
  justify-content: space-between;
  font-size:15px;
  font-weight: 600;
  margin-bottom: 15px;
}
.news-list-posts{
  text-align: right;
  margin: 10px 0;
  font-size: 15px;
  font-weight: 600;
}
.instrument-box-inif::-webkit-scrollbar {
  width: 5px;
  height: 16px;
  background-color: transparent;
}
.news-list-btn{
  text-align: right;
}
.home-dialog .el-tabs__header{
  margin-bottom: 0;
}
.read-btn{
  margin: 10px 0;
}
.read-btn .el-badge{
  margin-right: 15px;
}
.notyet{
  height: 20px;
  line-height: 20px;
  font-size: 17px;
  font-weight: 600;
  text-align: center;
}
.home-dialog .el-dialog__header{
  padding: 10px 20px;
}
.news-list-content{
  line-height: 20px;
}
.loadmore{
  margin-top: 20px;
  text-align: center;
}



/*定义滚动条轨道
    内阴影+圆角*/
.instrument-box-inif::-webkit-scrollbar-track {
  -webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, 0);
  border-radius: 10px;
  background-color: transparent;
}

/*定义滑块
    内阴影+圆角*/
.instrument-box-inif::-webkit-scrollbar-thumb {
  border-radius: 10px;
  -webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.3);
  background-color: #b9bcc0;
}

.delwh .el-menu {
  background-color: #0f619f;
}

.delwh .el-submenu__title:hover,
.delwh .el-submenu__title:focus {
  background-color: rgba(0, 0, 0, 0.1);
  color: #fff;
}

.delwh .el-submenu__title {
  color: #82c2f3;
}

.delwh .el-submenu__title i {
  color: #2595ea;
}

.delwh .el-menu-item-group__title {
  padding: 0;
}

.el-menu-item-group .el-menu-item-group__title {
  padding: 0;
}
.delwh::-webkit-scrollbar {display:none}
.scroll-box{
  height: 750px;
  overflow-y: auto;
}
.scroll-box::-webkit-scrollbar {
  width: 6px;
}
.scroll-box::-webkit-scrollbar-track {
  background: rgb(239, 239, 239);
  border-radius: 2px;
}
.scroll-box::-webkit-scrollbar-thumb {
  background: #40a0ff49;
  border-radius: 10px;
}
.scroll-box::-webkit-scrollbar-thumb:hover {
  background: #40a0ff;
}
.all-box .communal-box .el-autocomplete,.el-select{
  margin-right: 0;
}
.all-box .el-table th.el-table__cell>.cell{
  text-align: center;
  font-size: 13px;
}
.all-box .el-table--enable-row-transition .el-table__body td.el-table__cell{
  text-align: center;
  font-size: 13px;
}

.gpt-dialog .el-dialog__body{
  padding: 0 20px;
  padding-bottom:10px;
}
.all-box .el-submenu__title{
  font-size: 13px;
}
.all-box .el-menu-item{
  font-size: 13px;
}
.all-box .el-button{
  font-size: 13px;
}
.all-box .el-form-item__label{
  font-size: 13px;
}
.all-box .el-input__inner{
  font-size: 13px;
}
.all-box .el-textarea__inner{
  font-size: 13px;
}
.el-card__body, .el-main{
  padding-top: 20px;
}
.Jumplists{
  padding: 0 20px;
  padding-top: 10px;
  display: flex;
  overflow: hidden;
  align-items: flex-end;
  height: 40px;
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE and Edge */
  -moz-user-select:none; /* Firefox私有属性 */
  -webkit-user-select:none; /* WebKit内核私有属性 */
  -ms-user-select:none; /* IE私有属性(IE10及以后) */
  -khtml-user-select:none; /* KHTML内核私有属性 */
  -o-user-select:none; /* Opera私有属性 */
  user-select:none; /* CSS3属性 */
  border-bottom: 1px solid #ffdddd;
}
.Jumplists::-webkit-scrollbar {
  display: none; /* Chrome, Safari, and Opera */
}
.Jumplists .el-breadcrumb{
  display: -webkit-inline-box;
  transition-property: transform;
  transition-duration: 500ms;
  transition-timing-function: cubic-bezier(0.165, 0.84, 0.44, 1);
}
.Jumplists .el-breadcrumb__item{
  display: flex;
  align-items: center;
  background-color: #fff;
}
.Jumplists .Jumparr-li{
  padding: 10px 0px 10px 10px;
  font-weight: 600;
  color: #606266;
  
}

.Jumplists .Jumparr-li:hover{
  background-color: #ebf6fd;
  font-weight: 600;
  border-radius: 10px 10px 0px 0px;
  cursor: pointer;
  color: #409eff;
}
.Jumparr-chas{
  width: 20px;
  height: 18px;
  display: inline-block;
}
.Jumparr-cha{
  margin-left: 10px;
  font-size: 18px;
  margin-right: 5px;
}
.Jumparr-cha:hover{
  color: red;
}
.Jumplists .activeCss{
  background-color: #ebf6fd;
  font-weight: 600;
  border-radius: 10px 10px 0px 0px;
  cursor: pointer;
  color: #409eff;
}
</style>


