<template>
  <div class="app-container">
    <div>
      <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">

        <el-form-item :label="$t('部门')" prop="units">
          <el-select v-model="units" :placeholder="$t('请选择') + $t('部门')" clearable size="small" multiple
                     @change="handleQuery">
            <el-option
              v-for="dict in unitOptions"
              :key="dict.dictValue"
              :label="dict.dictLabel"
              :value="dict.dictValue"
            />
          </el-select>
        </el-form-item>
        <el-form-item :label="$t('班值')" prop="teams">
          <el-select v-model="teams" :placeholder="$t('请选择') + $t('班值')" clearable size="small" multiple
                     @change="handleQuery">
            <el-option
              v-for="dict in teamOptions"
              :key="dict.dictValue"
              :label="dict.dictLabel"
              :value="dict.dictValue"
            />
          </el-select>
        </el-form-item>
        <el-form-item :label="$t('实际岗位')" prop="actualposts" label-width="200">
          <el-select v-model="actualposts" :placeholder="$t('请选择') + $t('实际岗位')" clearable size="small" multiple
                     @change="handleQuery">
            <el-option
              v-for="dict in actualpostOptions"
              :key="dict.dictValue"
              :label="dict.dictLabel"
              :value="dict.dictValue"
            />
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">{{ $t('搜索') }}</el-button>
          <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">{{ $t('重置') }}</el-button>
        </el-form-item>
      </el-form>
      <el-row :gutter="10" class="mb8">
        <el-col :span="1.5">
          <div class="bz-box">
            <i class="iconfont icon-star"></i> 应急响应管理小组组长
            <i class="iconfont icon-love"></i> 志愿响应小组(VRT)队长
            <i  class="iconfont icon-triangle"></i>危化品应急处置小组成员
            <i  class="iconfont icon-square"></i>班组安全代表
            <i  class="iconfont icon-plus"></i>急救员
            <i  class="iconfont icon-round"></i>义务消防员
            <i  class="iconfont icon-yuanjiaoliujiaoxing"></i>安委会成员
            <i  class="iconfont icon-shebeitubiao_famen"></i>TDS负责人
          </div>
        </el-col>
        <right-toolbar :showSearch.sync="showSearch" @queryTable="getChartData"></right-toolbar>
      </el-row>
      <div id="tree" ref="orgChartDom"></div>
    </div>
    <vue-draggable-resizable w="auto" h="auto" :draggable="dragMove" style="background-color:white">
      <div class="zoom" @wheel.prevent="handleTableWheel($event)" ref="branch">
        <branch :dataArray="list1"></branch>
      </div>
    </vue-draggable-resizable>
    <!-- 侧栏 --->
    <el-drawer
      title="附件"
      ref="drawer"
      direction="rtl"
      :visible.sync="drawer">
      <el-table :data="doc.commonfileList" border>
        <el-table-column :label="$t('文件名')" align="center" prop="fileName" :show-overflow-tooltip="true">
          <template slot-scope="scope">
            <a class="link-type" @click="handleDownload(scope.row)">
              <span>{{ scope.row.fileName }}</span>
            </a>
          </template>
        </el-table-column>
        <el-table-column :label="$t('大小(Kb)')" align="center" prop="fileSize" :show-overflow-tooltip="true" width="80"/>
        <el-table-column :label="$t('上传人')" align="center" prop="creator" :show-overflow-tooltip="true" width="120"/>
        <el-table-column :label="$t('操作')" align="center" width="120" class-name="small-padding fixed-width">
          <template slot-scope="scope">
            <el-button
              v-if="scope.row.fileName.endsWith('pdf')"
              size="mini"
              type="text"
              icon="el-icon-view"
              @click="handleSee(scope.row)"
            >{{ $t('预览') }}
            </el-button>
            <el-button
              size="mini"
              type="text"
              icon="el-icon-download"
              @click="handleDownload(scope.row)"
            >{{ $t('下载') }}
            </el-button>
          </template>
        </el-table-column>
      </el-table>
      <el-dialog v-dialogDrag :title="pdf.title" :visible.sync="pdf.open" width="1300px" append-to-body>
        <div style="margin-top: -60px;float: right;margin-right: 40px;">
          <el-button size="mini" type="text" @click="openPdf">{{ $t('新页面打开PDF') }}</el-button>
        </div>
        <div style="margin-top: -30px">
          <iframe :src="pdf.pdfUrl" frameborder="0" width="100%" height="700px"></iframe>
        </div>
      </el-dialog>
    </el-drawer>
  </div>
</template>

<script>
import VueDraggableResizable from 'vue-draggable-resizable'
import Branch from './branch'
import {listOgzStaffmgr} from "@/api/plant/staffmgr";
import {getToken} from "@/utils/auth";
import {allFileList} from "@/api/common/commonfile";

export default {
  components: {Branch, VueDraggableResizable},
  data() {
    return {
      showSearch: false,
      // 实际岗位字典
      actualpostOptions: [],
      showOrgChartData: [],
      staffmgrList: [],
      // 部门字典
      unitOptions: [],
      // 班值字典
      teamOptions: [],
      // 查询参数
      queryParams: {
        unit: null,
        team: null,
        actualpost: null,
        education: null,
        enAbility: null,
        educations: null,
        units: null,
        teams: null,
        actualposts: null,
      },
      units: [],
      teams: [],
      actualposts: ["24", "26", "14", "16", "18", "20", "12", "10", "34", "36","15"],
      dragMove: true,
      drawer: false,
      info: {},
      list0: [{
        "id": 10109,
        "pId": 0,
        "label": "朱晶",
        "post": "装置经理",
        "secretary": [[{
          "id": 10113,
          "pId": 10109,
          "label": "赵建清",
          "post": "装置副经理",
          "secretary": [[], []],
          "children": [{"id": 10101, "pId": 10113, "label": "张磊", "post": "资深工程师", "secretary": [[], []]}, {
            "id": 10103,
            "pId": 10113,
            "label": "高勇",
            "post": "资深工程师",
            "secretary": [[], []]
          }]
        }, {
          "id": 10117,
          "pId": 10109,
          "label": "居海波",
          "post": "装置副经理",
          "secretary": [[], []],
          "children": [{"id": 10106, "pId": 10117, "label": "邹生耀", "post": "资深工程师", "secretary": [[], []]}]
        }, {"id": 10102, "pId": 10109, "label": "韦岳平", "post": "装置副经理", "secretary": [[], []]}], []],
        "children": [{"id": 10116, "pId": 10109, "label": "陈琨", "post": "资深工程师", "secretary": [[], []]}, {
          "id": 10114,
          "pId": 10109,
          "label": "樊宏斌",
          "post": "生产主管",
          "secretary": [[], []]
        }, {"id": 10108, "pId": 10109, "label": "袁永成", "post": "生产主管", "secretary": [[], []]}, {
          "id": 10107,
          "pId": 10109,
          "label": "潘传安",
          "post": "生产主管",
          "secretary": [[], []]
        }, {"id": 10104, "pId": 10109, "label": "胡文逵", "post": "生产主管", "secretary": [[], []]}, {
          "id": 10110,
          "pId": 10109,
          "label": "孙文龙",
          "post": "生产主管",
          "secretary": [[], []]
        }, {"id": 10115, "pId": 10109, "label": "鲍波", "post": "工长", "secretary": [[], []]}, {
          "id": 10043,
          "pId": 10109,
          "label": "占丽萍",
          "post": "职员",
          "secretary": [[], []]
        }, {"id": 10112, "pId": 10109, "label": "何氢", "post": "主操（白班）", "secretary": [[], []]}, {
          "id": 10054,
          "pId": 10109,
          "label": "李滕",
          "post": "主操（白班）",
          "secretary": [[], []]
        }, {
          "id": 10001,
          "pId": 10109,
          "label": "徐建飞",
          "post": "倒班班长",
          "secretary": [[], []],
          "children": [{"id": 10014, "pId": 10001, "label": "陈涛", "post": "倒班副班长", "secretary": [[], []]}, {
            "id": 10012,
            "pId": 10001,
            "label": "陆危圣",
            "post": "倒班副班长",
            "secretary": [[], []]
          }, {"id": 10008, "pId": 10001, "label": "任秋香", "post": "主操", "secretary": [[], []]}, {
            "id": 10019,
            "pId": 10001,
            "label": "刘伟程",
            "post": "主操",
            "secretary": [[], []]
          }, {"id": 10010, "pId": 10001, "label": "张磊", "post": "主操", "secretary": [[], []]}, {
            "id": 10015,
            "pId": 10001,
            "label": "崔海军",
            "post": "主操",
            "secretary": [[], []]
          }, {"id": 10000, "pId": 10001, "label": "王俊", "post": "主操", "secretary": [[], []]}, {
            "id": 10003,
            "pId": 10001,
            "label": "马国春",
            "post": "主操",
            "secretary": [[], []]
          }, {"id": 10004, "pId": 10001, "label": "申海宁", "post": "主操", "secretary": [[], []]}, {
            "id": 10006,
            "pId": 10001,
            "label": "张燕燕",
            "post": "主操",
            "secretary": [[], []]
          }, {"id": 10009, "pId": 10001, "label": "缪海荣", "post": "主操", "secretary": [[], []]}, {
            "id": 10017,
            "pId": 10001,
            "label": "高峰",
            "post": "主操",
            "secretary": [[], []]
          }, {"id": 10018, "pId": 10001, "label": "蒋恒兵", "post": "主操", "secretary": [[], []]}, {
            "id": 10020,
            "pId": 10001,
            "label": "刘金京",
            "post": "主操",
            "secretary": [[], []]
          }, {"id": 10002, "pId": 10001, "label": "张力飞", "post": "主操", "secretary": [[], []]}, {
            "id": 10005,
            "pId": 10001,
            "label": "李欣阳",
            "post": "主操",
            "secretary": [[], []]
          }, {"id": 10007, "pId": 10001, "label": "宋月民", "post": "主操", "secretary": [[], []]}, {
            "id": 10013,
            "pId": 10001,
            "label": "贾云飞",
            "post": "主操",
            "secretary": [[], []]
          }, {"id": 10016, "pId": 10001, "label": "张炜", "post": "主操", "secretary": [[], []]}, {
            "id": 10011,
            "pId": 10001,
            "label": "宋章浩",
            "post": "主操",
            "secretary": [[], []]
          }]
        }, {
          "id": 10031,
          "pId": 10109,
          "label": "臧闽军",
          "post": "倒班班长",
          "secretary": [[], []],
          "children": [{"id": 10028, "pId": 10031, "label": "朱健", "post": "倒班副班长", "secretary": [[], []]}, {
            "id": 10032,
            "pId": 10031,
            "label": "袁晨",
            "post": "倒班副班长",
            "secretary": [[], []]
          }, {"id": 10035, "pId": 10031, "label": "陈海飞", "post": "主操", "secretary": [[], []]}, {
            "id": 10024,
            "pId": 10031,
            "label": "刘尊超",
            "post": "主操",
            "secretary": [[], []]
          }, {"id": 10026, "pId": 10031, "label": "马卫兵", "post": "主操", "secretary": [[], []]}, {
            "id": 10027,
            "pId": 10031,
            "label": "曹西元",
            "post": "主操",
            "secretary": [[], []]
          }, {"id": 10029, "pId": 10031, "label": "顾仁海", "post": "主操", "secretary": [[], []]}, {
            "id": 10036,
            "pId": 10031,
            "label": "李静",
            "post": "主操",
            "secretary": [[], []]
          }, {"id": 10037, "pId": 10031, "label": "朱永宜", "post": "主操", "secretary": [[], []]}, {
            "id": 10039,
            "pId": 10031,
            "label": "封公瑾",
            "post": "主操",
            "secretary": [[], []]
          }, {"id": 10040, "pId": 10031, "label": "姜翠君", "post": "主操", "secretary": [[], []]}, {
            "id": 10022,
            "pId": 10031,
            "label": "周湘",
            "post": "主操",
            "secretary": [[], []]
          }, {"id": 10041, "pId": 10031, "label": "梁宏伟", "post": "主操", "secretary": [[], []]}, {
            "id": 10025,
            "pId": 10031,
            "label": "蒋宁宁",
            "post": "主操",
            "secretary": [[], []]
          }, {"id": 10030, "pId": 10031, "label": "吴中鑫", "post": "主操", "secretary": [[], []]}, {
            "id": 10038,
            "pId": 10031,
            "label": "刘辉",
            "post": "主操",
            "secretary": [[], []]
          }, {"id": 10033, "pId": 10031, "label": "郑骅", "post": "主操", "secretary": [[], []]}, {
            "id": 10034,
            "pId": 10031,
            "label": "张琦",
            "post": "主操",
            "secretary": [[], []]
          }, {"id": 10023, "pId": 10031, "label": "邓阳", "post": "主操", "secretary": [[], []]}, {
            "id": 10021,
            "pId": 10031,
            "label": "李凤希",
            "post": "主操",
            "secretary": [[], []]
          }]
        }, {
          "id": 10049,
          "pId": 10109,
          "label": "沈涛",
          "post": "倒班班长",
          "secretary": [[], []],
          "children": [{"id": 10048, "pId": 10049, "label": "乔刚", "post": "倒班副班长", "secretary": [[], []]}, {
            "id": 10045,
            "pId": 10049,
            "label": "宦文恺",
            "post": "倒班副班长",
            "secretary": [[], []]
          }, {"id": 10050, "pId": 10049, "label": "卓兴凤", "post": "主操", "secretary": [[], []]}, {
            "id": 10052,
            "pId": 10049,
            "label": "阚久龙",
            "post": "主操",
            "secretary": [[], []]
          }, {"id": 10055, "pId": 10049, "label": "王超", "post": "主操", "secretary": [[], []]}, {
            "id": 10056,
            "pId": 10049,
            "label": "张永",
            "post": "主操",
            "secretary": [[], []]
          }, {"id": 10058, "pId": 10049, "label": "宋浦江", "post": "主操", "secretary": [[], []]}, {
            "id": 10060,
            "pId": 10049,
            "label": "夏军",
            "post": "主操",
            "secretary": [[], []]
          }, {"id": 10047, "pId": 10049, "label": "劳青川", "post": "主操", "secretary": [[], []]}, {
            "id": 10062,
            "pId": 10049,
            "label": "邢启元",
            "post": "主操",
            "secretary": [[], []]
          }, {"id": 10061, "pId": 10049, "label": "韩叶锋", "post": "主操", "secretary": [[], []]}, {
            "id": 10053,
            "pId": 10049,
            "label": "谢振华",
            "post": "主操",
            "secretary": [[], []]
          }, {"id": 10057, "pId": 10049, "label": "黄梓赫", "post": "主操", "secretary": [[], []]}, {
            "id": 10059,
            "pId": 10049,
            "label": "周权",
            "post": "主操",
            "secretary": [[], []]
          }, {"id": 10046, "pId": 10049, "label": "赵振湘", "post": "主操", "secretary": [[], []]}, {
            "id": 10051,
            "pId": 10049,
            "label": "沈文勇",
            "post": "主操",
            "secretary": [[], []]
          }, {"id": 10042, "pId": 10049, "label": "卞传庆", "post": "主操", "secretary": [[], []]}, {
            "id": 10044,
            "pId": 10049,
            "label": "李士军",
            "post": "主操",
            "secretary": [[], []]
          }]
        }, {
          "id": 10064,
          "pId": 10109,
          "label": "刘遵胜",
          "post": "倒班班长",
          "secretary": [[], []],
          "children": [{
            "id": 10063,
            "pId": 10064,
            "label": "王维庆",
            "post": "倒班副班长",
            "secretary": [[], []]
          }, {"id": 10083, "pId": 10064, "label": "郝维祥", "post": "倒班副班长", "secretary": [[], []]}, {
            "id": 10073,
            "pId": 10064,
            "label": "李飞虎",
            "post": "主操",
            "secretary": [[], []]
          }, {"id": 10075, "pId": 10064, "label": "杨赞", "post": "主操", "secretary": [[], []]}, {
            "id": 10078,
            "pId": 10064,
            "label": "何叡颖",
            "post": "主操",
            "secretary": [[], []]
          }, {"id": 10082, "pId": 10064, "label": "王欢", "post": "主操", "secretary": [[], []]}, {
            "id": 10084,
            "pId": 10064,
            "label": "王守清",
            "post": "主操",
            "secretary": [[], []]
          }, {"id": 10079, "pId": 10064, "label": "王竹宣", "post": "主操", "secretary": [[], []]}, {
            "id": 10066,
            "pId": 10064,
            "label": "徐乐",
            "post": "主操",
            "secretary": [[], []]
          }, {"id": 10071, "pId": 10064, "label": "胡远斌", "post": "主操", "secretary": [[], []]}, {
            "id": 10074,
            "pId": 10064,
            "label": "马云凤",
            "post": "主操",
            "secretary": [[], []]
          }, {"id": 10077, "pId": 10064, "label": "秦飞", "post": "主操", "secretary": [[], []]}, {
            "id": 10081,
            "pId": 10064,
            "label": "程佩佩",
            "post": "主操",
            "secretary": [[], []]
          }, {"id": 10069, "pId": 10064, "label": "孙夕斌", "post": "主操", "secretary": [[], []]}, {
            "id": 10070,
            "pId": 10064,
            "label": "胡保宁",
            "post": "主操",
            "secretary": [[], []]
          }, {"id": 10068, "pId": 10064, "label": "王刚", "post": "主操", "secretary": [[], []]}, {
            "id": 10072,
            "pId": 10064,
            "label": "王勇",
            "post": "主操",
            "secretary": [[], []]
          }, {"id": 10065, "pId": 10064, "label": "陈熹", "post": "主操", "secretary": [[], []]}, {
            "id": 10067,
            "pId": 10064,
            "label": "朱国柱",
            "post": "主操",
            "secretary": [[], []]
          }, {"id": 10080, "pId": 10064, "label": "孙浩", "post": "主操", "secretary": [[], []]}]
        }]
      }],
      list1: []
      ,
      list2: [],
      // 报告附件参数
      doc: {
        file: "",
        // 是否显示弹出层（报告附件）
        open: false,
        // 弹出层标题（报告附件）
        title: "",
        // 是否禁用上传
        isUploading: false,
        // 是否更新已经存在的用户数据
        updateSupport: 0,
        // 报告附件上传位置编号
        ids: 0,
        // 设置上传的请求头部
        headers: {Authorization: "Bearer " + getToken()},
        // 上传的地址
        url: process.env.VUE_APP_BASE_API + "/common/commonfile/uploadFile",
        commonfileList: null,
        queryParams: {
          pId: null,
          pType: 'staffmgr'
        },
        pType: 'staffmgr',
        pId: null
      },
      pdf: {
        title: '',
        pdfUrl: '',
        numPages: null,
        open: false,
        pageNum: 1,
        pageTotalNum: 1,
        loadedRatio: 0,
      },
    }
  },
  created() {
    this.getDicts("ACTUALPOST").then(response => {
      this.actualpostOptions = response.data;
    });
    this.getDicts("STAFF_UNIT").then(response => {
      this.unitOptions = response.data;
    });
    this.getDicts("TEAM_DIVIDE").then(response => {
      this.teamOptions = response.data;
    });
    this.getChartData()
  },
  mounted() {
    this.bus.$on('info', (data) => {
      this.drawer = true
      this.doc.queryParams.pId = data.id
      allFileList(this.doc.queryParams).then(response => {
        this.doc.commonfileList = response;
      });
      this.info = data
    })
  },
  methods: {
    handleTableWheel(event) {
      let obj = this.$refs['branch']
      return this.tableZoom(obj, event)
    },
    tableZoom(obj, event) {
      // 一开始默认是100%
      let zoom = parseInt(obj.style.zoom, 10) || 100
      // 滚轮滚一下wheelDelta的值增加或减少120
      zoom += event.wheelDelta / 12
      if (zoom > 50) {
        obj.style.zoom = zoom + '%'
      }
      return false
    },
    dclick() {
      this.drawer = true
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.units = []
      this.teams = []
      this.actualposts = []
      this.handleQuery();
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.getChartData();
    },
    getChartData() {
      this.queryParams.units = this.units.join()
      this.queryParams.teams = this.teams.join()
      this.queryParams.actualposts = this.actualposts.join()
      listOgzStaffmgr(this.queryParams).then(response => {
        this.staffmgrList = response;
        this.list2 = []

        for (let i = 0; i < this.staffmgrList.length; i++) {
          console.log("第" + i)
          let post = this.selectDictLabel(this.actualpostOptions, this.staffmgrList[i].actualpost)
          if (this.staffmgrList[i].pId == 0) {
            let nodeData = {
              id: this.staffmgrList[i].id,
              pId: this.staffmgrList[i].pId,
              label: this.staffmgrList[i].name,
              post: post,
              secretary: [[], []],
              // img: 'http://47.114.101.16:8080' + process.env.VUE_APP_BASE_API +　this.staffmgrList[i].photo,
              img: 'https://cpms.basf-ypc.net.cn' + process.env.VUE_APP_BASE_API + this.staffmgrList[i].photo,
              bz1: false,
              bz2: false,
              bz3: false,
              bz4: false,
              bz5: false,
              bz6: false,
              bz7: false,
              bz8: false
            }
            if (this.staffmgrList[i].specialDuty) {
              // console.log(this.staffmgrList[i].specialDuty)
              let dutyArr = this.staffmgrList[i].specialDuty.split(",")
              for (let i = 0; i < dutyArr.length; i++) {
                if (dutyArr[i] == "10") {
                  nodeData.bz4 = true
                } else if (dutyArr[i] == "12") {
                  nodeData.bz3 = true
                } else if (dutyArr[i] == "14") {
                  nodeData.bz5 = true
                } else if (dutyArr[i] == "16") {
                  nodeData.bz6 = true
                } else if (dutyArr[i] == "18") {
                  nodeData.bz2 = true
                } else if (dutyArr[i] == "20") {
                  nodeData.bz1 = true
                } else if (dutyArr[i] == "22") {
                  nodeData.bz8 = true
                } else if (dutyArr[i] == "24") {
                  nodeData.bz7 = true
                }
              }
            }
            this.list2.push(nodeData)
          } else {
            let nodeData = {
              id: this.staffmgrList[i].id,
              pId: this.staffmgrList[i].pId,
              label: this.staffmgrList[i].name,
              post: post,
              img: 'https://cpms.basf-ypc.net.cn' + process.env.VUE_APP_BASE_API + this.staffmgrList[i].photo,
              // img: 'http://47.114.101.16:8080' + process.env.VUE_APP_BASE_API +　this.staffmgrList[i].photo,
              bz1: false,
              bz2: false,
              bz3: false,
              bz4: false,
              bz5: false,
              bz6: false,
              bz7: false,
              bz8: false
            }
            if (this.staffmgrList[i].specialDuty) {
              // console.log(this.staffmgrList[i].specialDuty)
              let dutyArr = this.staffmgrList[i].specialDuty.split(",")
              for (let i = 0; i < dutyArr.length; i++) {
                if (dutyArr[i] == "10") {
                  nodeData.bz4 = true
                } else if (dutyArr[i] == "12") {
                  nodeData.bz3 = true
                } else if (dutyArr[i] == "14") {
                  nodeData.bz5 = true
                } else if (dutyArr[i] == "16") {
                  nodeData.bz6 = true
                } else if (dutyArr[i] == "18") {
                  nodeData.bz2 = true
                } else if (dutyArr[i] == "20") {
                  nodeData.bz1 = true
                } else if (dutyArr[i] == "22") {
                  nodeData.bz8 = true
                } else if (dutyArr[i] == "24") {
                  nodeData.bz7 = true
                }
              }
            }
            this.list2.push(nodeData)
          }
        }

        this.list1 = this.listToTree(this.list2)
        console.log(this.list1)
        console.log(JSON.stringify(this.list1))
      })
    },
    listToTree(list) {
      let map = {};
      list.forEach(item => {
        if (!map[item.id]) {
          map[item.id] = item;
        }
      });
      list.forEach(item => {
        if (item.pId !== 0 && map[item.pId]) {
          // map[item.pId].children ? map[item.pId].children.push(item) : map[item.pId].children = [item];
          if (item.post == '装置副经理') {
            map[item.pId].secretary ? map[item.pId].secretary[0].push(item) : map[item.pId].secretary[0] = [item];
          } else if (item.post == '生产主管' || item.post == '工长') {
            map[item.pId].secretary[1].push(item)
          }else if ((item.post == '资深工程师' || item.post == '工程师') && map[item.pId].pId == 0) { //直属装置经理的资深工程师
            map[item.pId].secretary ? map[item.pId].secretary[0].push(item) : map[item.pId].secretary[0] = [item];
          } else {
            map[item.pId].children ? map[item.pId].children.push(item) : map[item.pId].children = [item];
          }
        }
      });
      return list.filter(item => {
        if (item.pId === 0) {
          return item;
        }
      })
    },
    // 文件下载处理
    handleDownload(row) {
      var name = row.fileName;
      var url = row.fileUrl;
      var suffix = url.substring(url.lastIndexOf("."), url.length)
      const a = document.createElement('a')
      a.setAttribute('download', name)
      a.setAttribute('target', '_blank')
      a.setAttribute('href', process.env.VUE_APP_BASE_API + url)
      a.click()
    },
    handleSee(row) {
      this.pdf.open = true
      this.pdf.title = row.fileName
      this.pdf.pdfUrl = process.env.VUE_APP_BASE_API + '/pdf/web/viewer.html?file=' + process.env.VUE_APP_BASE_API + row.fileUrl
    },
    openPdf() {
      window.open(this.pdf.pdfUrl);//path是文件的全路径地址
    },
  }
}
</script>
<style scoped>
.iconfont{
  color: #ff0000;
}
</style>
