<template>
  <div>
    <div style="margin-top: 5px">
      <div id="hover">
        <div
          v-for="item in tableData"
          :key="item"
          style="display: flex; padding: 8px"
        >
          <div style="width: 10px">
            <div
              style="
                width: 6px;
                height: 6px;
                margin-top: 5px;
                background-color: #409eff;
                border-radius: 50%;
              "
            ></div>
          </div>

          <div style="display: inline-block; margin-left: 5px">
            <div
              id="titleHover"
              @click="openPdfViewer(item)"
              style="
                font-size: 15px;
                width: 15vw;

                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;
                cursor: pointer;
              "
            >
              <span>{{ item.Title }}</span>
            </div>
            <div style="color: #8e959c; font-size: 14px; margin-top: 12px">
              {{ item.FlowName }}
              <div style="display: inline-block; margin-left: 20px">
                {{ parseTime(item.SendDT, "{y}-{m}-{d} {h}:{i}") }}
              </div>
            </div>
          </div>
          <!-- <div style="display: flex; position: absolute; right: 13px">
            <span style="font-size: 14px; display: inline-block; width: 58px">{{
              item.NodeName
            }}</span>

          </div> -->
        </div>
      </div>
    </div>
    <el-dialog width="75%" title="信息审核" v-model="approvalDialog">
      <InfoApply
        :showcolumn="showcolumn"
        :FK_Flow="FK_Flow"
        :nodeName="nodeName"
        @closeViewLeave="closeViewLeave"
        :WorkId1="WorkId1"
        :trueLeave="trueLeave"
        :fldata="fldata"
        :FKNode1="FKNode1"
      ></InfoApply>
    </el-dialog>
    <el-dialog width="80%" title="请假审批" v-model="leaveDialog">
      <leaveApplication
        ref="child"
        :showTable="showTable"
        :WorkId="WorkId"
        :FK_Flow="FK_Flow"
        :nodeName="nodeName"
        :trueLeave="trueLeave"
        @change="change"
        :FKNode1="FKNode1"
        @closeViewLeave="closeViewLeave"
        :dialogVisible="dialogVisible"
        :before-close="handleClose"
      ></leaveApplication>
    </el-dialog>
    <el-dialog width="85%" :title="titleFw" v-model="ReceivedQiLinDialog">
      <ReceivedQiLin
        ref="QiLinRef"
        :hanldType="hanldType"
        @closeViewLeave="closeViewLeave"
        :ReceivedQiLinData="ReceivedQiLinData"
        :nowShow="nowShow"
      ></ReceivedQiLin>
    </el-dialog>
    <el-dialog width="85%" title="论文审批" v-model="paperApprovalQiLinDialog">
      <paperApprovalQiLin
        ref="paperQiLinRef"
        :hanldType="hanldType"
        @closeViewLeave="closeViewLeave"
        :paperQiLinData="paperQiLinData"
      ></paperApprovalQiLin>
    </el-dialog>
    <sw-view-pdf
      ref="importRef1"
      @guanbi="handleQuery"
      :receiverData1="receiverData1"
    >
    </sw-view-pdf>
    <tripRecord ref="tripRef" @guanbi="handleQuery"> </tripRecord>
    <qtsw-view-pdf
      ref="importRef"
      @guanbi="handleQuery"
      :receiverData="receiverData"
    />
    <carApproval ref="carRef" @guanbi="handleQuery"></carApproval>
    <workApply ref="workRef" @guanbi="handleQuery"></workApply>
    <Supervise ref="superRef" @guanbi="handleQuery"></Supervise>
    <sealApplicational ref="sealRef" @guanbi="handleQuery"></sealApplicational>
    <contSeal ref="contSealRef" @guanbi="handleQuery"></contSeal>

    <outTeacher ref="teacherRef" @guanbi="handleQuery"> </outTeacher>
  </div>
</template>

<script>
import carApproval from "@/views/liucheng/todowork/formView/carApproval.vue";
import workApply from "@/views/liucheng/todowork/formView/workApply.vue";

import ReceivedQiLin from "@/views/liucheng/todowork/formView/ReceivedQiLin.vue";
import paperApprovalQiLin from "@/views/liucheng/todowork/formView/paperApprovalQiLin.vue";
import tripRecord from "@/views/liucheng/todowork/formView/businessTripRecord.vue";
import InfoApply from "@/views/liucheng/todowork/InfoApply.vue";
import outTeacher from "@/views/liucheng/todowork/formView/recordOfOutTeaching.vue";
import Infoarticle from "@/views/liucheng/todowork/Infoarticle.vue";
import leaveApplication from "@/views/liucheng/leaveApplication1.vue";
import Supervise from "@/views/liucheng/todowork/formView/Supervise.vue";
import sealApplicational from "@/views/liucheng/todowork/formView/sealApplicational.vue";
import contSeal from "@/views/liucheng/todowork/formView/contSeal.vue";

import QtswViewPdf from "@/views/liucheng/todowork/formView/qtswViewPdf";
import SwViewPdf from "@/views/liucheng/todowork/formView/swViewPdf";
import { getHandleList } from "@/api/liucheng/index";
import { getReceiveByWorkId } from "@/api/office/received";
import { getInitiateList } from "@/api/liucheng/index";
import {
  kg_uuid,
  GetUrlbasePath,
  GetUrlbase,
} from "../../official/hookFunction";
import { updateIsRead } from "@/api/liucheng";
import Cookies from "js-cookie";
import { getToken, getJToken } from "@/utils/auth";
export default {
  name: "YinetoaTodoList",
  components: {
    SwViewPdf,
    QtswViewPdf,
    outTeacher,
    tripRecord,
    Infoarticle,
    InfoApply,
    leaveApplication,
    ReceivedQiLin,
    paperApprovalQiLin,
    carApproval,
    workApply,
    Supervise,
    sealApplicational,
    contSeal,
  },
  data() {
    return {
      hanldType: false,
      trueLeave: false,
      nowShow: null,
      InfoDialog: false,
      paperQiLinData: null,
      paperApprovalQiLinDialog: false,
      ReceivedQiLinData: null,
      ReceivedQiLinDialog: false,
      FKNode1: null,
      leaveDialog: false,
      approvalDialog: false,
      fldata: null,
      WorkId: null,
      WorkId1: null,
      receiverData: undefined,
      receiverData1: undefined,
      queryParams: {
        title: undefined,
      },
      token: "",
      activeName: "first",
      tableData: [],
      guijiDialog: false,
      tuurl: "",
      currentRow: "",
      myList: [],
      //待办分页
      dbPageSize: 10,
      dbPageNum: 1,
      dbTotal: 0,
      dbLoading: false,
      //在途分页
      ztPageSize: 10,
      ztPageNum: 1,
      ztTotal: 0,
      ztLoading: false,
      //已办分页
      ybPageSize: 10,
      ybPageNum: 1,
      ybTotal: 0,
      ybLoading: false,
      //我发起的列表参数
      myPageSize: 10,
      myPageNum: 1,
      myTotal: 0,
      myLoading: false,
    };
  },
  created() {
    this.token = getJToken();
    this.getList(
      this.token,
      this.dbPageSize,
      this.dbPageNum,
      this.queryParams.title
    );
  },
  mounted() {},

  methods: {
    handleQuery() {
      this.getList(
        this.token,
        this.dbPageSize,
        this.dbPageNum,
        this.queryParams.title
      );
    },
    closeViewLeave() {
      this.leaveDialog = false;
      this.approvalDialog = false;
      this.ReceivedQiLinDialog = false;
      this.paperApprovalQiLinDialog = false;
      this.handleQuery();
      this.WorkId = null;
      this.WorkId1 = null;
      this.ReceivedQiLinData = null;
      this.paperQiLinData = null;
    },
    openTrajectory(data) {
      /*      this.tuurl=Cookies.get("jFontIp")+"/WF/WorkOpt/OneWork/OneWork.htm?" +
                "CurrTab=Truck&FK_Node="+data.FK_Node+"&FID="+data.FID+"&WorkID="+data.WorkID+"&FK_Flow="+data.FK_Flow+
                "&Info=&s="+Math.random()+"&isFrameCross=0&token="+this.token;*/

      this.tuurl =
        Cookies.get("jFontIp") +
        "/WF/Port.htm?DoWhat=OneWork1&WorkID=" +
        data.WorkID +
        "&FK_Flow=" +
        data.FK_Flow +
        "&Token=" +
        this.token;
      this.guijiDialog = true;
    },
    openPdfViewer(data) {
      if (data.FK_Flow == "012") {
        getReceiveByWorkId(data.WorkID).then((response) => {
          this.receiverData = response.data;
          this.$nextTick(() => {
            this.$refs.importRef.show(this.receiverData, data, false);
          });
        });
      } else if (data.FK_Flow == "003") {
        getReceiveByWorkId(data.WorkID).then((response) => {
          this.receiverData1 = response.data;
          this.$nextTick(() => {
            this.$refs.importRef1.showdetal2(
              this.receiverData1,
              data,
              true,
              "no"
            );
          });
        });
      } else if (data.FK_Flow == "002") {
        var agent = navigator.userAgent.toLowerCase();
        if (agent.indexOf("windows") > -1) {
          this.handleOpenAppReceived(
            data.WorkID,
            data.NodeName,
            data.FK_Flow,
            data.FK_Node
          );
        } else {
          this.handleOpenAppReceivedQiLin(data, "no");
        }
      } else if (data.FK_Flow == "005") {
        var agent = navigator.userAgent.toLowerCase();
        if (agent.indexOf("windows") > -1) {
          this.handleOpenAppReceived(
            data.WorkID,
            data.NodeName,
            data.FK_Flow,
            data.FK_Node
          );
        } else {
          this.handleOpenAppReceivedQiLin(data);
        }
      } else if (data.FK_Flow == "006") {
        this.$refs.tripRef.showDetail1(data);
        this.$refs.tripRef.closeSendNext();
      } else if (data.FK_Flow == "007") {
        this.$refs.teacherRef.showDetail1(data);
        this.$refs.teacherRef.closeSendNext();
      } else if (data.FK_Flow == "008") {
        var agent = navigator.userAgent.toLowerCase();
        if (agent.indexOf("windows") > -1) {
          this.handleOpenAppReceived1(
            data.WorkID,
            data.NodeName,
            data.FK_Flow,
            data.FK_Node
          );
        } else {
          this.handleOpenAppPaperQiLin1(data);
        }
      } else if (data.FK_Flow == "009") {
        this.leaveDialog = true;
        this.showTable = true;
        this.WorkId = data.WorkID;
        this.FKNode1 = data.FK_Node;
        this.FK_Flow = data.FK_Flow;
        this.trueLeave = true;
        this.nodeName = data.NodeName;
      } else if (data.FK_Flow == "010") {
        this.approvalDialog = true;
        this.WorkId1 = data.WorkID;
        this.showcolumn = true;
        this.FK_Flow = data.FK_Flow;
        this.FKNode1 = data.FK_Node;
        this.nodeName = data.NodeName;
        this.fldata = data;
      } else if (data.FK_Flow == "015") {
        this.$refs.carRef.showDetail1(data);
        this.$refs.carRef.closeSendNext();
      } else if (data.FK_Flow == "020") {
        this.$refs.workRef.showDetail1(data);
        this.$refs.workRef.closeSendNext();
      } else if (data.FK_Flow == "016") {
        this.$refs.superRef.showDetail1(data);
        this.$refs.superRef.closeSendNext();
      } else if (data.FK_Flow == "017") {
        this.$refs.sealRef.showDetail1(data);
        this.$refs.sealRef.closeSendNext();
      } else if (data.FK_Flow == "018") {
        this.$refs.contSealRef.showDetail1(data);
        this.$refs.contSealRef.closeSendNext();
      }
      //修改为已读
      // if(data.IsRead=="0"){
      //   updateIsRead(data.WorkID,this.token,data.FK_Emp,data.FK_Node,data.FK_Flow).then(response=>{
      //
      //   })
      // }
    },
    //麒麟（论文）
    handleOpenAppPaperQiLin1(data) {
      this.paperApprovalQiLinDialog = true;
      this.paperQiLinData = data;
      this.$nextTick(() => {
        this.$refs.paperQiLinRef.OnReady();
      });
    },
    //麒麟
    handleOpenAppReceivedQiLin(data, nowShow) {
      this.ReceivedQiLinDialog = true;
      if (data.FK_Flow == "002") {
        this.titleFw = "发文";
      } else if (data.FK_Flow == "005") {
        this.titleFw = "其他处室发文";
      }
      this.ReceivedQiLinData = data;
      this.nowShow = nowShow;
      this.$nextTick(() => {
        this.$refs.QiLinRef.OnReady();
      });
    },
    //打开收文弹窗浏览器
    handleOpenAppReceived1(workId, NodeName, FK_Flow, FK_Node) {
      this.$modal.loading("正在打开视图，请稍候...");
      let webUrl =
        GetUrlbase() +
        "/todopaperApproval?FK_Flow=" +
        FK_Flow +
        "&FK_Node=" +
        FK_Node +
        "&hanldType=true&workId=" +
        workId +
        "&NodeName=" +
        encodeURIComponent(NodeName) +
        "&fkNode=";
      var uuid = kg_uuid(16, 32);
      var targetuuid = kg_uuid(16, 32);
      let urlString =
        "http://127.0.0.1:9588/StartApp?" +
        "&id=" +
        uuid +
        "&title=" +
        "发表学术论文审批登记" +
        "&targetid=" +
        targetuuid +
        "&showMode=1" +
        "&cookie=Admin-Token=" +
        getToken() +
        ";J-Token=" +
        getJToken() +
        ";jFontIp=" +
        encodeURIComponent(Cookies.get("jFontIp")) +
        "&weburl=" +
        encodeURIComponent(webUrl);
      fetch(urlString, {
        method: "get",
      }).then((res) => {
        this.$modal.closeLoading();
      });
    },
    //打开收文弹窗浏览器
    handleOpenAppReceived(workId, NodeName, FK_Flow, FK_Node, nowShow) {
      this.$modal.loading("正在打开视图，请稍候...");
      let webUrl =
        GetUrlbase() +
        "/todoReceived?FK_Flow=" +
        FK_Flow +
        "&FK_Node=" +
        FK_Node +
        "&nowShow=" +
        nowShow +
        "&hanldType=false&workId=" +
        workId +
        "&NodeName=" +
        encodeURIComponent(NodeName) +
        "&fkNode=";
      var uuid = kg_uuid(16, 32);
      var targetuuid = kg_uuid(16, 32);
      let urlString =
        "http://127.0.0.1:9588/StartApp?" +
        "&id=" +
        uuid +
        "&title=" +
        "发文" +
        "&targetid=" +
        targetuuid +
        "&showMode=1" +
        "&cookie=Admin-Token=" +
        getToken() +
        ";J-Token=" +
        getJToken() +
        ";jFontIp=" +
        encodeURIComponent(Cookies.get("jFontIp")) +
        "&weburl=" +
        encodeURIComponent(webUrl);
      fetch(urlString, {
        method: "get",
      }).then((res) => {
        this.$modal.closeLoading();
      });
    },
    //获取列表
    getList(v, s, n, t) {
      getInitiateList(v, s, n, t).then((res) => {
        this.dbTotal = res.total;
        this.tableData = res.list.slice(0, 6);
      });
    },
  },
};
</script>

<style lang="scss" scoped>
#titleHover :hover {
  color: #409eff !important;
  text-decoration: underline !important;
}
#hover :hover {
  background-color: aliceblue;
}
#button :hover {
  // background-color: #e6a23c;
  background-color: #409eff !important;
  color: white;
}
#button1 :hover {
  // background-color: #e6a23c;
  background-color: #909399 !important;
  color: white;
}
#button2 :hover {
  // background-color: #e6a23c;
  background-color: #f56c6c !important;
  color: white;
}
</style>
