<template>
  <div class="information" id="information">

    <div class="ADContainer" v-if="ADContainershow">
      <!-- 公告头部 -->
      <div class="adTop"><span class="title">公告</span>
        <el-button type="primary" size="small" @click="centerDialogVisible = true" v-if="domainAdmin">发公告</el-button>
      </div>

      <!-- 公告列表-->
      <div class="adlist">
        <ul>
          <li v-for="item in announcementList" :key="item.id">
            <div><span class="title" style="font-size: 24px;" @click="adlidetail(item)">{{item.title}}<em class="top"
                v-show="item.sticky">置顶</em></span></div>
            <div>分类：<span class="DateInfo"><i>{{item.category}}</i></span></div>
            <div>公告内容：<span class="content" v-html="item.content"></span></div>
            <div>发布时间：<span class="DateInfo"><i>{{item.createTime}}</i></span></div>
            <div>发布来源：<span class="DateInfo"><i>{{item.sender}}</i></span></div>
            <span class="closebtn" @click="deleteMessage(item,2)"><img
                src="~@/assets/images/other/closelink.png"></span>
          </li>
        </ul>
        <div class="adlistmore" @click="viewmore" v-if="!noDataLength"><span>查看更多</span></div>
        <div class="adlistnodata" v-if="noDataLength"><span>没有更多了</span></div>
      </div>
    </div>

    <div class="ADContainerDetail" v-if="ADContainerDetailshow">
      <div class="DetailTop">
        <el-button size="small" @click="backGoAD">返回</el-button>
      </div>
      <div class="AdDetailContent">
        <span class="title">{{addetailobj.title}}</span>
        <span class="dateinfo"><i>{{addetailobj.sender}}</i><i>{{addetailobj.createTime}}</i></span>
        <span class="content" v-html="addetailobj.content"></span>
      </div>
    </div>

    <!--发公告弹窗-->
    <el-dialog :close-on-click-modal="false" class="bulletin-dialog" title="发公告" :visible.sync="centerDialogVisible"
      width="55%" center v-loading="loading">
      <div class="dialog-box">
        <el-scrollbar class="scrollbar">
          <el-form :label-position="labelPosition" label-width="80px">
            <el-form-item label="标题:">
              <el-input v-model="headline"></el-input>
            </el-form-item>
            <el-form-item label="接收人:">
              <el-input v-model="recipient" class="recipientVisible" readonly ref="recipient"></el-input>
              <el-button icon="el-icon-plus" @click="PlusSign(false)"></el-button>
              <el-button icon="el-icon-close" class="minus-msg" @click="eduiminus"></el-button>
            </el-form-item>
            <el-form-item label="分类:">
              <el-select v-model="category">
                <el-option
                  v-for="(item, index) in categoryList"
                  :key="index"
                  :label="item.label"
                  :value="item.value"
                >
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="其他设置:">
              <el-checkbox v-model="otherSettings">置顶</el-checkbox>
            </el-form-item>
            <el-form-item label="公告内容:" class="edit-html">
              <div class="html-box">
                <div>
                  <vue-html5-editor @change="updateData" :content="textarea">
                  </vue-html5-editor>
                </div>
                <div class="text-num">
                  当前已输入{{currentWordCount}}个字符, 您还可以输入{{wordsRemaining}}个字符。
                </div>
              </div>
            </el-form-item>

          </el-form>
        </el-scrollbar>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button size="medium" @click="hiddenBulletinDialog()">取 消</el-button>
        <el-button size="medium" type="primary" @click="eduirelease">发布</el-button>
      </span>
    </el-dialog>

    <!--部门树弹窗-->

    <el-dialog :close-on-click-modal="false" title="选择部门" class="dept-dialog" v-if="Receivedby"
      :visible.sync="Receivedby" width="40%">
      <div class="msg-pull-box">
        <el-scrollbar class="scrollbar">
          <el-tree empty-text="加载中..." :props="propsPull" :load="loadNodeDept" node-key="id" ref="deptTree" lazy
            show-checkbox :check-strictly="true" :default-checked-keys="defaultCheckedKeys"
            @check-change="Receivethetitle($event)">
          </el-tree>
        </el-scrollbar>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button size="medium" @click="Receivedby = false">取消</el-button>
        <el-button size="medium" type="primary" @click="getDeptData">确定</el-button>
      </span>
    </el-dialog>
  </div>
</template>
<script>
import API from "@/api.js";
import Constant from "@/Constant.js";
export default {
  props: ["openParams"],
  data() {
    return {
      domainAdmin: localStorage.getItem("domainAdmin") == "true" ? true : false,
      param: {
        currpage: 1,
        pagesize: 10,
      },
      announcementList: [], //公告列表数组
      noDataLength: false,
      addetailobj: {}, //公告详情
      ADContainershow: true,
      ADContainerDetailshow: false,
      loading: false,
      categoryList: [
        {
          label: '人事公告',
          value: '人事公告'
        },{
          label: '业务公告',
          value: '业务公告'
        },{
          label: '制度公告',
          value: '制度公告'
        },{
          label: '活动公告',
          value: '活动公告'
        }
      ],
      Constant,
      showEmotion: false,
      imag: '<img src="/obpm/message/img/face/qlx_thumb.gif" />gddd',
      emotionList: [
        {
          type: "[去旅行]",
          path: '<img src="/obpm/message/img/face/qlx_thumb.gif" />',
          url: "/obpm/message/img/face/qlx_thumb.gif",
        },
        {
          type: "[广告]",
          path: '<img src="/obpm/message/img/face/ad_new0902_thumb.gif" />',
          url: "/obpm/message/img/face/ad_new0902_thumb.gif",
        },
        {
          type: "[doge]",
          path: '<img src="/obpm/message/img/face/doge_thumb.gif" />',
          url: "/obpm/message/img/face/doge_thumb.gif",
        },
        {
          type: "[喵喵]",
          path: '<img src="/obpm/message/img/face/mm_thumb.gif" />',
          url: "/obpm/message/img/face/mm_thumb.gif",
        },
        {
          type: "[二哈]",
          path: '<img src="/obpm/message/img/face/moren_hashiqi_thumb.png" />',
          url: "/obpm/message/img/face/moren_hashiqi_thumb.png",
        },
        {
          type: "[哆啦A梦吃惊]",
          path: '<img src="/obpm/message/img/face/dorachijing_thumb.gif" />',
          url: "/obpm/message/img/face/dorachijing_thumb.gif",
        },
        {
          type: "[哆啦A梦花心]",
          path: '<img src="/obpm/message/img/face/dorahaose_thumb.gif" />',
          url: "/obpm/message/img/face/dorachijing_thumb.gif",
        },
        {
          type: "[哆啦A梦微笑]",
          path: '<img src="/obpm/message/img/face/jqmweixiao_thumb.gif" />',
          url: "/obpm/message/img/face/jqmweixiao_thumb.gif",
        },
        {
          type: "[笑cry]",
          path: '< src="/obpm/message/img/face/xiaoku_thumb.gif" />',
          url: "/obpm/message/img/face/xiaoku_thumb.gif",
        },
        {
          type: "[摊手]",
          path: '<img src="/obpm/message/img/face/pcmoren_tanshou_thumb.png" />',
          url: "/obpm/message/img/face/pcmoren_tanshou_thumb.png",
        },
        {
          type: "[抱手]",
          path: '<img src="/obpm/message/img/face/pcmoren_baobao_thumb.png" />',
          url: "/obpm/message/img/face/pcmoren_baobao_thumb.png",
        },
        {
          type: "[群体围观]",
          path: '<img src="/obpm/message/img/face/lxhweiguan_thumb.gif" />',
          url: "/obpm/message/img/face/lxhweiguan_thumb.gif",
        },

        //12
        {
          type: "[坏笑]",
          path: '<img src="/obpm/message/img/face/pcmoren_huaixiao_thumb.png" />',
          url: "/obpm/message/img/face/pcmoren_huaixiao_thumb.png",
        },
        {
          type: "[舔屏]",
          path: '<img src="/obpm/message/img/face/pcmoren_tian_thumb.png" />',
          url: "/obpm/message/img/face/pcmoren_tian_thumb.png",
        },
        {
          type: "[污]",
          path: '<img src="/obpm/message/img/face/pcmoren_wu_thumb.png" />',
          url: "/obpm/message/img/face/pcmoren_wu_thumb.png",
        },
        {
          type: "[微笑]",
          path: '<img src="/obpm/message/img/face/huanglianwx_thumb.gif" />',
          url: "/obpm/message/img/face/huanglianwx_thumb.gif",
        },
        {
          type: "[嘻嘻]",
          path: '<img src="/obpm/message/img/face/tootha_thumb.gif" />',
          url: "/obpm/message/img/face/tootha_thumb.gif",
        },
        {
          type: "[哈哈]",
          path: '<img src="/obpm/message/img/face/laugh.gif" />',
          url: "/obpm/message/img/face/laugh.gif",
        },
        {
          type: "[挖鼻]",
          path: '<img src="/obpm/message/img/face/wabi_thumb.gif" />',
          url: "/obpm/message/img/face/wabi_thumb.gif",
        },
        {
          type: "[可爱]",
          path: '<img src="/obpm/message/img/face/tza_thumb.gif" />',
          url: "/obpm/message/img/face/tza_thumb.gif",
        },
        {
          type: "[可怜]",
          path: '<img src="/obpm/message/img/face/kl_thumb.gif" />',
          url: "/obpm/message/img/face/kl_thumb.gif",
        },
        {
          type: "[吃惊]",
          path: '<img src="/obpm/message/img/face/cj_thumb.gif" />',
          url: "/obpm/message/img/face/cj_thumb.gif",
        },
        {
          type: "[害羞]",
          path: '<img src="/obpm/message/img/face/shamea_thumb.gif" />',
          url: "/obpm/message/img/face/shamea_thumb.gif",
        },
        {
          type: "[挤眼]",
          path: '<img src="/obpm/message/img/face/zy_thumb.gif" />',
          url: "/obpm/message/img/face/zy_thumb.gif",
        },
        //24
        {
          type: "[闭嘴]",
          path: '<img src="/obpm/message/img/face/bz_thumb.gif" />',
          url: "/obpm/message/img/face/bz_thumb.gif",
        },
        {
          type: "[鄙视]",
          path: '<img src="/obpm/message/img/face/bs2_thumb.gif" />',
          url: "/obpm/message/img/face/bs2_thumb.gif",
        },
        {
          type: "[爱你]",
          path: '<img src="/obpm/message/img/face/lovea_thumb.gif" />',
          url: "/obpm/message/img/face/lovea_thumb.gif",
        },
        {
          type: "[泪]",
          path: '<img src="/obpm/message/img/face/sada_thumb.gif" />',
          url: "/obpm/message/img/face/sada_thumb.gif",
        },
        {
          type: "[偷笑]",
          path: '<img src="/obpm/message/img/face/heia_thumb.gif" />',
          url: "/obpm/message/img/face/heia_thumb.gif",
        },
        {
          type: "[亲亲]",
          path: '<img src="/obpm/message/img/face/qq_thumb.gif" />',
          url: "/obpm/message/img/face/qq_thumb.gif",
        },
        {
          type: "[生病]",
          path: '<img src="/obpm/message/img/face/sb_thumb.gif" />',
          url: "/obpm/message/img/face/sb_thumb.gif",
        },
        {
          type: "[太开心]",
          path: '<img src="/obpm/message/img/face/mb_thumb.gif" />',
          url: "/obpm/message/img/face/mb_thumb.gif",
        },
        {
          type: "[白眼]",
          path: '<img src="/obpm/message/img/face/landeln_thumb.gif" />',
          url: "/obpm/message/img/face/landeln_thumb.gif",
        },
        {
          type: "[右哼哼]",
          path: '<img src="/obpm/message/img/face/yhh_thumb.gif" />',
          url: "/obpm/message/img/face/yhh_thumb.gif",
        },
        {
          type: "[左哼哼]",
          path: '<img src="/obpm/message/img/face/zhh_thumb.gif" />',
          url: "/obpm/message/img/face/zhh_thumb.gif",
        },
        {
          type: "[嘘]",
          path: '<img src="/obpm/message/img/face/x_thumb.gif" />',
          url: "/obpm/message/img/face/x_thumb.gif",
        },
        //36
        {
          type: "[哀]",
          path: '<img src="/obpm/message/img/face/cry.gif" />',
          url: "/obpm/message/img/face/cry.gif",
        },
        {
          type: "[委屈]",
          path: '<img src="/obpm/message/img/face/wq_thumb.gif" />',
          url: "/obpm/message/img/face/wq_thumb.gif",
        },

        {
          type: "[吐]",
          path: '<img src="/obpm/message/img/face/t_thumb.gif" />',
          url: "/obpm/message/img/face/t_thumb.gif",
        },
        {
          type: "[哈欠]",
          path: '<img src="/obpm/message/img/face/haqianv2_thumb.gif" />',
          url: "/obpm/message/img/face/haqianv2_thumb.gif",
        },
        {
          type: "[抱抱_旧]",
          path: '<img src="/obpm/message/img/face/bba_thumb.gif" />',
          url: "/obpm/message/img/face/bba_thumb.gif",
        },
        {
          type: "[怒]",
          path: '<img src="/obpm/message/img/face/angrya_thumb.gif" />',
          url: "/obpm/message/img/face/angrya_thumb.gif",
        },
        {
          type: "[疑问]",
          path: '<img src="/obpm/message/img/face/yw_thumb.gif" />',
          url: "/obpm/message/img/face/yw_thumb.gif",
        },
        {
          type: "[馋嘴]",
          path: '<img src="/obpm/message/img/face/cza_thumb.gif" />',
          url: "/obpm/message/img/face/cza_thumb.gif",
        },
        {
          type: "[拜拜]",
          path: '<img src="/obpm/message/img/face/88_thumb.gif" />',
          url: "/obpm/message/img/face/88_thumb.gif",
        },
        {
          type: "[思考]",
          path: '<img src="/obpm/message/img/face/sk_thumb.gif" />',
          url: "/obpm/message/img/face/sk_thumb.gif",
        },
        {
          type: "[汗]",
          path: '<img src="/obpm/message/img/face/sweata_thumb.gif" />',
          url: "/obpm/message/img/face/sweata_thumb.gif",
        },
        {
          type: "[困]",
          path: '<img src="/obpm/message/img/face/kunv2_thumb.gif" />',
          url: "/obpm/message/img/face/kunv2_thumb.gif",
        },
        //48
        {
          type: "[睡]",
          path: '<img src="/obpm/message/img/face/huangliansj_thumb.gif" />',
          url: "/obpm/message/img/face/huangliansj_thumb.gif",
        },
        {
          type: "[钱]",
          path: '<img src="/obpm/message/img/face/money_thumb.gif" />',
          url: "/obpm/message/img/face/money_thumb.gif",
        },
        {
          type: "[失望]",
          path: '<img src="/obpm/message/img/face/sw_thumb.gif" />',
          url: "/obpm/message/img/face/sw_thumb.gif",
        },
        {
          type: "[酷]",
          path: '<img src="/obpm/message/img/face/cool_thumb.gif" />',
          url: "/obpm/message/img/face/cool_thumb.gif",
        },
        {
          type: "[色]",
          path: '<img src="/obpm/message/img/face/huanglianse_thumb.gif" />',
          url: "/obpm/message/img/face/huanglianse_thumb.gif",
        },
        {
          type: "[哼]",
          path: '<img src="/obpm/message/img/face/hatea_thumb.gif" />',
          url: "/obpm/message/img/face/hatea_thumb.gif",
        },
        {
          type: "[鼓掌]",
          path: '<img src="/obpm/message/img/face/gza_thumb.gif" />',
          url: "/obpm/message/img/face/gza_thumb.gif",
        },
        {
          type: "[晕]",
          path: '<img src="/obpm/message/img/face/dizzya_thumb.gif" />',
          url: "/obpm/message/img/face/dizzya_thumb.gif",
        },
        {
          type: "[悲伤]",
          path: '<img src="/obpm/message/img/face/bs_thumb.gif" />',
          url: "/obpm/message/img/face/bs_thumb.gif",
        },
        {
          type: "[抓狂]",
          path: '<img src="/obpm/message/img/face/crazya_thumb.gif" />',
          url: "/obpm/message/img/face/crazya_thumb.gif",
        },
        {
          type: "[黑线]",
          path: '<img src="/obpm/message/img/face/h_thumb.gif" />',
          url: "/obpm/message/img/face/h_thumb.gif",
        },
        {
          type: "[阴险]",
          path: '<img src="/obpm/message/img/face/yx_thumb.gif" />',
          url: "/obpm/message/img/face/yx_thumb.gif",
        },
        //60
        {
          type: "[怒骂]",
          path: '<img src="/obpm/message/img/face/numav2_thumb.gif" />',
          url: "/obpm/message/img/face/numav2_thumb.gif",
        },
        {
          type: "[互粉]",
          path: '<img src="/obpm/message/img/face/hufen_thumb.gif" />',
          url: "/obpm/message/img/face/hufen_thumb.gif",
        },
        {
          type: "[心]",
          path: '<img src="/obpm/message/img/face/hearta_thumb.gif" />',
          url: "/obpm/message/img/face/hearta_thumb.gif",
        },
        {
          type: "[伤心]",
          path: '<img src="/obpm/message/img/face/unheart.gif" />',
          url: "/obpm/message/img/face/unheart.gif",
        },
        {
          type: "[猪头]",
          path: '<img src="/obpm/message/img/face/pig.gif" />',
          url: "/obpm/message/img/face/pig.gif",
        },
        {
          type: "[熊猫]",
          path: '<img src="/obpm/message/img/face/panda_thumb.gif" />',
          url: "/obpm/message/img/face/panda_thumb.gif",
        },
        {
          type: "[兔子]",
          path: '<img src="/obpm/message/img/face/rabbit_thumb.gif" />',
          url: "/obpm/message/img/face/rabbit_thumb.gif",
        },
        {
          type: "[ok]",
          path: '<img src="/obpm/message/img/face/ok_thumb.gif" />',
          url: "/obpm/message/img/face/ok_thumb.gif",
        },
        {
          type: "[耶]",
          path: '<img src="/obpm/message/img/face/ye_thumb.gif" />',
          url: "/obpm/message/img/face/ye_thumb.gif",
        },
        {
          type: "[good]",
          path: '<img src="/obpm/message/img/face/good_thumb.gif" />',
          url: "/obpm/message/img/face/good_thumb.gif",
        },
        {
          type: "[NO]",
          path: '<img src="/obpm/message/img/face/buyao_org.gif" />',
          url: "/obpm/message/img/face/buyao_org.gif",
        },
        {
          type: "[赞]",
          path: '<img src="/obpm/message/img/face/z2_thumb.gif" />',
          url: "/obpm/message/img/face/z2_thumb.gif",
        },
        //72
        {
          type: "[来]",
          path: '<img src="/obpm/message/img/face/come_thumb.gif" />',
          url: "/obpm/message/img/face/come_thumb.gif",
        },
        {
          type: "[弱]",
          path: '<img src="/obpm/message/img/face/sad_thumb.gif" />',
          url: "/obpm/message/img/face/sad_thumb.gif",
        },
        {
          type: "[草泥马]",
          path: '<img src="/obpm/message/img/face/shenshou_thumb.gif" />',
          url: "/obpm/message/img/face/shenshou_thumb.gif",
        },
        {
          type: "[神马]",
          path: '<img src="/obpm/message/img/face/horse2_thumb.gif" />',
          url: "/obpm/message/img/face/horse2_thumb.gif",
        },
        {
          type: "[囧]",
          path: '<img src="/obpm/message/img/face/j_thumb.gif" />',
          url: "/obpm/message/img/face/j_thumb.gif",
        },
        {
          type: "[浮云]",
          path: '<img src="/obpm/message/img/face/fuyun_thumb.gif" />',
          url: "/obpm/message/img/face/fuyun_thumb.gif",
        },
        {
          type: "[给力]",
          path: '<img src="/obpm/message/img/face/geiliv2_thumb.gif" />',
          url: "/obpm/message/img/face/geiliv2_thumb.gif",
        },
        {
          type: "[围观]",
          path: '<img src="/obpm/message/img/face/wg_thumb.gif" />',
          url: "/obpm/message/img/face/wg_thumb.gif",
        },
        {
          type: "[威武]",
          path: '<img src="/obpm/message/img/face/vw_thumb.gif" />',
          url: "/obpm/message/img/face/vw_thumb.gif",
        },
        {
          type: "[话筒]",
          path: '<img src="/obpm/message/img/face/huatongv2_thumb.gif" />',
          url: "/obpm/message/img/face/huatongv2_thumb.gif",
        },
        {
          type: "[蜡烛]",
          path: '<img src="/obpm/message/img/face/lazhuv2_thumb.gif" />',
          url: "/obpm/message/img/face/lazhuv2_thumb.gif",
        },
        {
          type: "[蛋糕]",
          path: '<img src="/obpm/message/img/face/cakev2_thumb.gif" />',
          url: "/obpm/message/img/face/cakev2_thumb.gif",
        },
      ],
      readStatus: "",
      currentActiveName: "first",
      currentWordCount: 0,
      wordsRemaining: 10000,
      isEmptyPage: false,
      noReply: false,
      noReplyMy: false,
      allIsEmptyPage: false,
      messagesListNum: "", //企业动态信息列表数量
      messagesList: [], //企业动态信息列表
      currentArray: [],
      currentIndex: "", //点击回复时的index值
      isSendRange: "",
      sendRangeList: [], //发送范围部门列表
      sendRangeName: "", //发送范围部门名字
      deptList: [],
      otherSettings: false,
      labelPosition: "right",
      fileList: [],
      tabPosition: "left",
      information: "",
      msgsubmit: "",
      headline: "",
      recipient: "",
      category: "",
      selectDeptList: "", //发公告窗口选择的部门数据
      Howmanywords: 140,
      tabpanelComment: "",
      textarea: "",
      workslide: "first",
      activekeep: "first",
      activeName: "first",
      dialogVisible: false,
      Receivedby: false, //发公告里面的加号弹框
      centerDialogVisible: false,
      remnant: 140,
      eduiPlus: 0,
      eduisubtract: 10000,
      props: {
        label: "name",
        children: "zones",
        isLeaf: "leaf",
      },
      propsPull: {
        label: "name",
        children: "zones",
        isLeaf: "leaf",
      },

      //评论回复接口所需的参数缓存
      replyToUser: "",
      replyToUserId: "",
      replyMessageId: "",
      replyCommentId: "",
      replyTocontent: "",

      labelSwitchVal: "first",
      unreadWorkItems: [], //未读工作事项
      unreadWorkNum: 0,
      allNotice: [], //全部工作事项
      allNoticeNum: 0,
      myReplyData: [],
      myReplyNum: 0,
      receiveNum: 0,
      receiveData: [],
      currentFlowType: "",
      currentFlowTypeNum: "",
      flowType: "first",
      defaultCheckedKeys: [],
    };
  },
  created() {
    //查询公告列表
    this.getMessagesAdList();

    //this.notices();
    this.getMessagesList();
    // console.log("this.openParams----->",this.openParams);

    //点击消息提醒通过传入自定义参数，判断参数再定义currentActiveName的值即可
    if (this.openParams.remind) {
      this.currentActiveName = "second";
      this.labelSwitch("first");
    }
    if (this.openParams.isWorkMatters) {
      this.currentActiveName = "second";
      let readStatus = 0;
      let type = 0;
      let data = {
        readStatus: 0,
        type: 0,
      };
      this.$api.getNotice(data, {
        onSucess: (res) => {
          if (res.data.data.datas.length == 0) {
            this.isEmptyPage = true;
          } else {
            this.unreadWorkNum = res.data.data.rowCount;
            this.unreadWorkItems = res.data.data.datas;
          }
        },
      });
    }
  },
  methods: {
    getMessagesAdList() {
      //公告列表分页
      this.$api.getAnnouncementPage(this.param.currpage, this.param.pagesize, {
        onSucess: (res) => {
          if (res.data.data.datas.length) {
            if (res.data.data.datas.length < this.param.pagesize)
              this.noDataLength = true;
            let datas = res.data.data.datas;
            datas.forEach((item) => {
              this.announcementList.push(item);
            });
          } else {
            this.noDataLength = true;
          }
        },
      });
    },
    deleteMessage(item, type) {
      let messageId = item.id;
      this.$confirm("删除后无法恢复，确定删除吗？", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          this.$api.deleteMessage(messageId, {
            onSucess: (response) => {
              if (response.data.status == 1) {
                this.param.currpage = 1; //重置第一页
                this.announcementList = []; //重置列表
                if (type == "1") {
                  this.$api.getMessagesList({
                    onSucess: (res) => {
                      this.messagesListNum = res.data.data.rowCount;
                      this.messagesList = res.data.data.datas;
                    },
                  });
                } else if (type == "2") {
                  this.getMessagesAdList(); //分页公告列表
                }
              }
            },
          });
        })
        .catch(() => {});
    },
    adlidetail(item) {
      //公告详情
      this.addetailobj = item;
      this.ADContainerDetailshow = true;
      this.ADContainershow = false;
    },
    backGoAD() {
      //公告返回
      this.ADContainerDetailshow = false;
      this.ADContainershow = true;
    },
    viewmore() {
      this.param.currpage++;
      this.getMessagesAdList();
    },
    showEmotionDialog(val) {
      if (val) {
        this.showEmotion = false;
      } else {
        this.showEmotion = !this.showEmotion;
      }
    },
    getEmoticons(item) {
      console.log("item--->", item);
      this.information += item.type;
    },
    deleteReplyMessage(el, index, parentIndex) {
      let commentId = el.id,
        messageId = el.messageId;
      this.$confirm("删除后无法恢复，确定删除吗？", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          this.$api.deleteReply(commentId, messageId, {
            onSucess: (res) => {
              if (res.data.status == 1) {
                this.$notify({
                  title: "删除成功!",
                  message: "",
                  type: "sucess",
                });
                this.messagesList[parentIndex].replayData.splice(index, 1);
                this.$forceUpdate();
              }
            },
          });
        })
        .catch(() => {});
    },
    hiddenBulletinDialog() {
      this.headline = "";
      this.recipient = "";
      this.textarea = "";
      this.centerDialogVisible = false;
    },

    //我回复的（删除）
    deleteReply(item, index, num) {
      let commentId = item.id,
        messageId = item.messageId;
      this.$confirm("删除后无法恢复，确定删除吗？", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          this.$api.deleteReply(commentId, messageId, {
            onSucess: (res) => {
              if (res.data.status == 1) {
                this.$notify({
                  title: "删除成功!",
                  message: "",
                  type: "sucess",
                });
                if (num == "1") {
                  this.myReplyData.splice(index, 1);
                } else if (num == "2") {
                  this.receiveData.splice(index, 1);
                }
                this.$forceUpdate();
              }
            },
          });
        })
        .catch(() => {});
    },

    doJump(item, index) {
      let obj = JSON.parse(item.linkParams);
      let params = {
        appId: this.$root.appid,
        linkType: "00",
        actionContent: obj._formid,
        name: "流程",
        docId: obj._docid,
        _select: obj._docid,
      };
      this.$emit("add-tab", params);
      if (index >= 0) {
        this.$api.noticeRead(item.id, {
          onSucess: () => {},
        });
        this.unreadWorkItems.splice(index, 1);
        if (this.unreadWorkItems.length == 0) {
          this.isEmptyPage = true;
        }
      }
    },
    announcementClick(tab) {
      if (tab.index == 1) {
        this.$api.getAnnouncement({
          onSucess: (res) => {
            this.announcementList = res.data.data.datas;
          },
        });
      }
    },
    paging() {},
    workHandleClick(val, currentType) {
      // console.log("----------->menu", val)
      this.currentFlowType = currentType;
      this.currentFlowTypeNum = val;
      let readStatus = "";
      let type = val;
      let data;
      if (this.flowType == "first") {
        data = {
          readStatus: 0,
          type: val,
        };
        this.$api.getNotice(data, {
          onSucess: (res) => {
            if (res.data.data.datas.length == 0) {
              this.isEmptyPage = true;
            } else {
              this.isEmptyPage = false;
              this.unreadWorkNum = res.data.data.rowCount;
              this.unreadWorkItems = res.data.data.datas;
            }
          },
        });
      } else if (this.flowType == "second") {
        data = {
          readStatus: "",
          type: val,
        };
        this.$api.getNotice(data, {
          onSucess: (res) => {
            this.allNoticeNum = res.data.data.rowCount;
            this.allNotice = res.data.data.datas;
            if (res.data.data.datas.length <= 0) {
              this.allIsEmptyPage = true;
            } else {
              this.allIsEmptyPage = false;
            }
          },
        });
      }
    },

    replyClick(tab) {
      if (tab.index == 1) {
        let currpage = 1;
        let _rowcount = 30;
        this.$api.getReceive(currpage, _rowcount, {
          onSucess: (res) => {
            if (res.data.data.rowCount <= 0) {
              this.noReplyMy = true;
            }
            this.receiveNum = res.data.data.rowCount;
            this.receiveData = res.data.data.datas;
          },
        });
      }
    },

    handleClick(tab) {
      if (tab.index == 1) {
        let readStatus = 0;
        let type = 0;
        let data = {
          readStatus: 0,
          type: 0,
        };
        this.$api.getNotice(data, {
          onSucess: (res) => {
            if (res.data.data.datas.length == 0) {
              this.isEmptyPage = true;
            } else {
              this.unreadWorkNum = res.data.data.rowCount;
              this.unreadWorkItems = res.data.data.datas;
            }
          },
        });
      } else if (tab.index == 2) {
        let currpage = 1;
        let _rowcount = 30;
        this.$api.getMyreply(currpage, _rowcount, {
          onSucess: (res) => {
            if (res.data.data.rowCount <= 0) {
              this.noReply = true;
            }
            this.myReplyNum = res.data.data.rowCount;
            this.myReplyData = res.data.data.datas;
          },
        });
      }
    },

    //全部标记已读
    setAllRead() {
      this.$api.setAllRead({
        onSucess: (res) => {
          // console.log("res-->",res);
          if (res.data.status) {
            this.readStatus = 0;
            let type = 0;
            let data = {
              readStatus: 0,
              type: this.currentFlowTypeNum ? this.currentFlowTypeNum : 0,
            };
            this.$api.getNotice(data, {
              onSucess: (res) => {
                if (res.data.data.datas.length == 0) {
                  this.isEmptyPage = true;
                } else {
                  this.unreadWorkNum = res.data.data.rowCount;
                  this.unreadWorkItems = res.data.data.datas;
                }
              },
            });
          }
        },
      });
    },

    //删除工作事项
    deleteWorkItem(id, index, val) {
      this.$confirm("删除后无法恢复，确定删除吗？", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          this.$api.deleteNotice(id, {
            onSucess: (res) => {
              if (res.data.status == 1) {
                this.$notify({
                  title: "删除成功!",
                  message: "",
                  type: "sucess",
                });
                if (val == "isUnread") {
                  this.$api.getNotice(
                    {
                      readStatus: 0,
                      type: 0,
                    },
                    {
                      onSucess: (res) => {
                        if (res.data.data.datas.length == 0) {
                          this.isEmptyPage = true;
                        } else {
                          this.unreadWorkNum = res.data.data.rowCount;
                          this.unreadWorkItems = res.data.data.datas;
                        }
                      },
                    }
                  );
                } else if (val == "isHaveRead") {
                  this.allNotice.splice(index, 1);
                  if (this.allNotice.length <= 0) {
                    this.allIsEmptyPage = true;
                  }
                }
              }
            },
          });
        })
        .catch(() => {});
    },

    //工作事项
    labelSwitch(val) {
      this.labelSwitchVal = val;
      //this.currentFlowType = '';
      if (val == "first") {
        this.flowType = "first";
        this.readStatus = 0;
        let type = 0;
        let data = {
          readStatus: 0,
          type: this.currentFlowTypeNum ? this.currentFlowTypeNum : 0,
        };
        this.$api.getNotice(data, {
          onSucess: (res) => {
            if (res.data.data.datas.length == 0) {
              this.isEmptyPage = true;
            } else {
              this.isEmptyPage = false;
              this.unreadWorkNum = res.data.data.rowCount;
              this.unreadWorkItems = res.data.data.datas;
            }
          },
        });
      } else if (val == "second") {
        this.flowType = "second";
        let readStatus = "";
        let type = 0;
        let data = {
          readStatus: "",
          type: this.currentFlowTypeNum ? this.currentFlowTypeNum : 0,
        };

        this.$api.getNotice(data, {
          onSucess: (res) => {
            this.allNoticeNum = res.data.data.rowCount;
            this.allNotice = res.data.data.datas;
            if (res.data.data.datas.length <= 0) {
              this.allIsEmptyPage = true;
            } else {
              this.allIsEmptyPage = false;
            }
            this.$forceUpdate();
          },
        });
      }
    },
    //回复
    doComment(toUser, toUserId, messageId, toContent, index) {
      let newData =
        encodeURIComponent("content.toUser") +
        "=" +
        encodeURIComponent(this.replyToUser ? this.replyToUser : toUser) +
        "&" +
        encodeURIComponent("content.toUserId") +
        "=" +
        encodeURIComponent(this.replyToUserId ? this.replyToUserId : toUserId) +
        "&" +
        encodeURIComponent("content.messageId") +
        "=" +
        encodeURIComponent(
          this.replyMessageId ? this.replyMessageId : messageId
        ) +
        "&" +
        encodeURIComponent("content.commentId") +
        "=" +
        encodeURIComponent(this.replyCommentId) +
        "&" +
        encodeURIComponent("toContent") +
        "=" +
        encodeURIComponent(
          this.replyTocontent ? this.replyTocontent : toContent
        ) +
        "&" +
        encodeURIComponent("content.content") +
        "=" +
        encodeURIComponent(this.tabpanelComment) +
        "&" +
        encodeURIComponent("content.attachment") +
        "=" +
        encodeURIComponent("");
      this.$api.doComment(newData, {
        onSucess: (res) => {
          if (res.data.status == 1) {
            this.messagesList[
              this.currentIndex ? this.currentIndex : index
            ].replayData.unshift(res.data.data);
            this.$forceUpdate();
            this.replyToUser = "";
            this.replyToUserId = "";
            this.replyMessageId = "";
            this.replyCommentId = "";
            this.replyTocontent = "";
            this.tabpanelComment = "";
          }
        },
      });
    },
    //评论回复
    replyToComment(toUser, toUserId, messageId, id, content, index) {
      this.tabpanelComment = "回复 @" + toUser + " ";
      this.replyToUser = toUser;
      this.replyToUserId = toUserId;
      this.replyMessageId = messageId;
      this.replyCommentId = id;
      this.replyTocontent = content;
      this.currentIndex = index;
    },

    //展示评论区
    showComments(index, id) {
      if (this.currentArray.indexOf(index) > -1) {
        for (let i = 0; i < this.currentArray.length; i++) {
          if (index == this.currentArray[i]) {
            this.currentArray.splice(i, 1);
            return;
          }
        }
      } else {
        this.currentArray.push(index);
        this.$api.getMessagesReplay(id, {
          onSucess: (res) => {
            this.messagesList[index].replayData = res.data.data.datas;
            this.$forceUpdate();
          },
        });
      }
    },
    //上传文件
    uploadFile(e) {
      let fileArray = e.file;
      let file = fileArray;
      let that = this;
      let form = new FormData();
      let id = "WU_FILE_0",
        name = e.file.name,
        type = e.file.type,
        lastModifiedDate = e.file.lastModifiedDate,
        size = e.file.size;
      form.append("id", id);
      form.append("name", name);
      form.append("type", type);
      form.append("lastModifiedDate", lastModifiedDate);
      form.append("size", size);
      form.append("file", file);
      this.$api.messageUploadFile(form, {
        onSucess: (res) => {
          let obj = {
            extName: res.data.extName,
            id: res.data.id,
            size: res.data.size,
            type: res.data.type,
            name: res.data.name,

            url: res.data.url,
          };
          this.fileList.push(obj);
        },
      });
    },

    getDeptData() {
      let nodes = this.$refs.deptTree.getCheckedNodes();
      let dept = [];
      let name = [];
      let deptIdArray = [];
      if (nodes && nodes.length > 0) {
        for (let i = 0; i < nodes.length; i++) {
          let obj = {};
          obj.deptId = nodes[i].id;
          obj.deptName = nodes[i].name;
          name += nodes[i].name + ";";
          dept.push(obj);
          deptIdArray.push(nodes[i].id);
        }
        this.defaultCheckedKeys = deptIdArray;
        // this.$refs.deptTree.setCheckedKeys(deptIdArray);
        if (this.isSendRange) {
          this.sendRangeName = name;
          this.sendRangeList = dept;
        } else {
          this.recipient = name;
          this.selectDeptList = dept;
        }
      }

      this.Receivedby = false;
    },

    loadNodeDept(node, resolve) {
      let appid = this.$root.appid;
      if (node.level === 0) {
        API.getDepartmentsByParentId(appid, "", {
          onSucess: function (response) {
            resolve(response.data.data);
          },
        });
      } else {
        API.getDepartmentsByParentId(appid, node.key, {
          onSucess: function (response) {
            resolve(response.data.data);
          },
        });
      }
    },

    //发送公告里面的加号弹框
    PlusSign(val) {
      if (val) {
        this.isSendRange = true;
      } else {
        this.isSendRange = "";
      }
      this.$api.getAllDeptList({
        onSucess: (res) => {
          this.deptList = res.data.data;
        },
      });
      this.Receivedby = true;
    },
    //把获取到的数据放到接受人里面去
    Receivethetitle(event) {
      this.recipient = event.name;
    },
    Sendthescope(event) {
      this.msgsubmit = event.name;
    },

    updateData(event) {
      this.textarea = event;
      // console.log("event--->",event);
      this.currentWordCount = event.length;
      this.wordsRemaining = 10000 - event.length;
    },

    eduirelease() {
      let that = this;
      if (this.headline.length == 0) {
        this.$message({
          message: "标题不能为空!",
          type: "warning",
        });
      } else if (this.recipient.length == 0) {
        this.$message({
          message: "接收人不能为空!",
          type: "warning",
        });
      } else if (this.category.length == 0) {
        this.$message({
          message: "分类不能为空!",
          type: "warning",
        });
      } else if (this.textarea.length == 0) {
        this.$message({
          message: "内容不能为空!",
          type: "warning",
        });
      } else {
        let userData = {
          user: [],
          dept: this.selectDeptList,
        };
        let newData =
          encodeURIComponent("content.title") +
          "=" +
          encodeURIComponent(this.headline) +
          "&" +
          encodeURIComponent("content.category") +
          "=" +
          encodeURIComponent(this.category) +
          "&" +
          encodeURIComponent("content.content") +
          "=" +
          encodeURIComponent(this.textarea) +
          "&" +
          encodeURIComponent("content.attachment") +
          "=" +
          encodeURIComponent("") +
          "&" +
          encodeURIComponent("content.scope") +
          "=" +
          encodeURIComponent(2) +
          "&" +
          encodeURIComponent("receiverInfo") +
          "=" +
          encodeURIComponent(JSON.stringify(userData)) +
          "&" +
          encodeURIComponent("content.type") +
          "=" +
          encodeURIComponent(1) +
          "&" +
          encodeURIComponent("content.sticky") +
          "=" +
          encodeURIComponent(this.otherSettings);
        this.loading = true;
        this.$api.makeAnnouncement(newData, {
          onSucess: (res) => {
            if (res.data.status == 1) {
              this.otherSettings = false;
              that.getMessagesList();
              that.centerDialogVisible = false;
              that.$notify({
                title: res.data.message,
                message: "",
                type: "success",
              });
              this.$api.getAnnouncement({
                onSucess: (res) => {
                  this.announcementList = res.data.data.datas;
                },
              });
            } else {
              that.centerDialogVisible = false;
              that.$notify({
                title: "发布失败",
                message: "",
                type: "error",
              });
            }
            this.loading = false;
          },
        });
        this.headline = "";
        this.recipient = "";
        this.textarea = "";
      }
    },
    tabpanelInput() {
      let txtVal = this.tabpanelComment.length;
      this.Howmanywords = 140 - txtVal;
    },
    eduiInput() {
      let txtVal = this.textarea.length;
      this.eduisubtract = 10000 - txtVal;
      this.eduiPlus = 0 + txtVal;
    },
    descInput() {
      let txtVal = this.information.length;
      this.remnant = 140 - txtVal;
    },
    handleRemove(file, fileList) {
      let fl = this.fileList;
      if (fl && fl.length > 0) {
        for (let i = 0; i < fl.length; i++) {
          if (file.id == fl[i].id) {
            fl.splice(i, 1);
            break;
          }
        }
      }
      this.fileList = fl;
    },
    handlePreview(file) {
      let params = {
        id: file.id,
        extName: file.extName,
        url: file.url,
        _: new Date().getTime(),
      };
      this.$api.getPreview(params, {
        onSucess: (res) => {
          if (res.data.status === 1) {
            // console.log("file--->",file);
            let fileName = file.id + file.extName;
            let url =
              this.obpmConfig.obpmFilePath +
              "/message/pdfviewer.html?fileName=" +
              fileName +
              "&path=" +
              file.url +
              "&showName=" +
              encodeURI(file.name) +
              "&fileType=" +
              file.extName;
            let URL = encodeURI(url);
            window.open(URL);
          }
        },
      });
    },
    handleExceed(files) {
      this.$message.warning(
        `当前限制选择 3 个文件，本次选择了 ${files.length} 个文件，共选择了 ${files.length} 个文件`
      );
    },
    beforeRemove(file) {
      return this.$confirm(`确定移除 ${file.name}？`);
    },
    //重置发送范围的输入框
    minus() {
      this.sendRangeName = "";
    },
    eduiminus() {
      // console.log("this.recipient-->",this.recipient);
      // console.log("this.selectDeptList-->",this.selectDeptList);
      this.recipient = "";
      this.selectDeptList = "";
    },
    adhibition() {
      let that = this;
      if (!this.information) {
        this.$message({
          message: "内容不能为空!",
          type: "warning",
        });
      } else if (!this.sendRangeName) {
        this.$message({
          message: "发送范围不能为空!",
          type: "warning",
        });
      } else {
        let userData = {
          user: [],
          dept: this.sendRangeList,
        };
        let newData =
          encodeURIComponent("content.content") +
          "=" +
          encodeURIComponent(this.information) +
          "&" +
          encodeURIComponent("content.attachment") +
          "=" +
          encodeURIComponent(JSON.stringify(this.fileList)) +
          "&" +
          encodeURIComponent("content.scope") +
          "=" +
          encodeURIComponent(2) +
          "&" +
          encodeURIComponent("receiverInfo") +
          "=" +
          encodeURIComponent(JSON.stringify(userData)) +
          "&" +
          encodeURIComponent("content.type") +
          "=" +
          encodeURIComponent(0);
        // console.log('fileList==>',this.fileList)
        // console.log('newData==>',newData)
        this.$api.annouce(newData, {
          onSucess: (res) => {
            if (res.data.status == 1) {
              this.information = "";
              this.sendRangeName = "";
              this.sendRangeList = [];
              this.getMessagesList();
              that.$notify({
                title: res.data.message,
                message: "",
                type: "success",
              });
            }
          },
        });
      }
    },
    //获取企业动态公告和评论
    getMessagesList() {
      this.$api.getMessagesList({
        onSucess: (res) => {
          this.messagesListNum = res.data.data.rowCount;
          //this.messagesList = res.data.data.datas;
          let newData = res.data.data.datas.map((item) => {
            return {
              attachment: item.attachment,
              comment: item.comment,
              commentCount: item.commentCount,
              content: this.getEmot(item.content),
              createTime: item.createTime,
              id: item.id,
              module: item.module,
              receiverDeptId: item.receiverDeptId,
              receiverId: item.receiverId,
              receiverInfo: item.receiverInfo,
              scope: item.scope,
              sender: item.sender,
              senderDept: item.senderDept,
              senderDeptId: item.senderDeptId,
              senderId: item.senderId,
              sticky: item.sticky,
              title: item.title,
              type: item.type,
            };
          });
          this.messagesList = newData;
        },
      });
    },
    getEmot(val) {
      //   eplaceFace : function(str){
      //     if(str && str != undefined){
      //       let re = /\[.[^[]*\]/g;
      //       let faceArr = str.match(re);
      //       if(faceArr != null && faceArr.length > 0){
      //         for(let i = 0; i < faceArr.length; i++){
      //           let fileName = Message.Util.cache.mapping["face_"+faceArr[i]];
      //           str = str.replace(faceArr[i],'<img src="img/face/'+fileName+'" border="0" />');
      //         }
      //       }
      //       return str;
      //     }
      //   },
      let value = val;
      let emo = "";
      for (let i = 0; i < this.emotionList.length; i++) {
        //value = value.replace(this.emotionList[i].type,'<img src="obpm/message/img/face/ad_new0902_thumb.gif" />');

        value = value.replace(
          this.emotionList[i].type,
          this.emotionList[i].path
        );
        // console.log("value.--->",value)
      }
      return value;
    },

    timeAgo(dateTimeStamp) {
      const minute = 1000 * 60;
      const hour = minute * 60;
      const day = hour * 24;
      const halfamonth = day * 15;
      const month = day * 30;
      let time = "";
      if (dateTimeStamp == undefined) {
        return false;
      } else {
        dateTimeStamp = dateTimeStamp.replace(/\-/g, "/");
        let sTime = new Date(dateTimeStamp).getTime(); //把时间pretime的值转为时间戳
        let now = new Date().getTime(); //获取当前时间的时间戳
        let diffValue = now - sTime;
        if (diffValue < 0) {
          console.log("结束日期不能小于开始日期！");
        }
        let monthC = diffValue / month;
        let weekC = diffValue / (7 * day);
        let dayC = diffValue / day;
        let hourC = diffValue / hour;
        let minC = diffValue / minute;
        if (monthC >= 1) {
          time = parseInt(monthC) + "个月前";
        } else if (weekC >= 1) {
          time = parseInt(weekC) + "周前";
        } else if (dayC >= 1) {
          time = parseInt(dayC) + "天前";
        } else if (hourC >= 1) {
          time = parseInt(hourC) + "个小时前";
        } else if (minC >= 1) {
          time = parseInt(minC) + "分钟前";
        } else {
          time = "刚刚";
        }
      }
      return time;
    },
  },
};
</script>
<style lang="scss">
.information {
  em,
  b,
  i {
    font-style: normal;
  }
  .ADContainer {
    height: 100%;
    .adTop {
      background: #fff;
      padding: 24px;
      display: flex;
      .title {
        flex: 1;
        font-size: 18px;
      }
    }
    .adlist {
      background: #fff;
      // height: 670px;
      max-height: calc(100% - 80px);
      overflow: auto;
      ul {
        list-style: none;
        padding: 24px;
        display: flex;

        flex-wrap: wrap;
        justify-content: space-between;
        li {
          border: 1px solid #e9e9e9;
          border-radius: 5px;
          padding: 16px;
          width: 49%;
          margin-bottom: 16px;
          display: flex;
          flex-direction: column;
          position: relative;
          .title {
            color: #1e263c;
            font-size: 14px;
            height: 20px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            width: 80%;
            cursor: pointer;
            em {
              background: #ff2855;
              border-radius: 4px;
              color: #fff;
              margin-left: 10px;
              font-size: 12px;
              padding: 5px;
            }
          }
          .content {
            color: #808191;
            font-size: 14px;
            margin: 4px 0 8px;
            height: 20px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
          }
          .DateInfo {
            color: #9fa0a3;
            font-size: 10px;
            i {
              margin-right: 8px;
            }
          }
          .closebtn {
            position: absolute;
            top: 8px;
            right: 8px;
            cursor: pointer;
          }
        }
      }
      .adlistmore {
        text-align: center;
        color: #808191;
        font-size: 14px;
      }
      .adlistnodata {
        text-align: center;
        color: #808191;
        font-size: 14px;
      }
    }
  }

  .ADContainerDetail {
    .DetailTop {
      background: #fff;
      padding: 24px;
      display: flex;
    }
    .AdDetailContent {
      display: flex;
      flex-direction: column;
      padding: 24px;
      .title {
        text-align: center;
        padding: 10px 0px 10px 20px;
        color: #000;
      }
      .dateinfo {
        color: #999999;
        display: flex;
        justify-content: center;
        i {
          margin-right: 30px;
        }
      }
      .content {
        border-top: 1px solid #eeeeee;
        padding: 10px 0;
        margin-top: 10px;
        height: 580px;
        overflow: auto;
      }
    }
  }
}
</style>
