<template>
  <el-tabs v-model="activeName" @tab-click="handleClick"
           :style="{padding:'20px'}">
    <!--    承包商item -->
    <el-tab-pane v-for="(item,index) in consNameArr" :key="index"  :label="item.consName" :name="'tab'+index">
      <el-tabs v-model="activeChildName" @tab-click="handleChildClick" :style="{padding:'10px'}">
        <el-tab-pane label="承包商单位信息" name="first">
          <bns-cons-info-tabs
            :items="consUnitInformationItems">
          </bns-cons-info-tabs>
        </el-tab-pane>
        <el-tab-pane label="企业资质" name="second">
          <bns-file-list-tabs
            :items="enterpriseQualificationItems"></bns-file-list-tabs>
        </el-tab-pane>
        <el-tab-pane label="安全协议书" name="third">
          <bns-file-list-tabs
            :items="securityAgreementFileItems"></bns-file-list-tabs>
        </el-tab-pane>
        <el-tab-pane label="四措两案" name="fourth">
          <bns-file-list-tabs
            :items="fourMeasuresAndTwoMeasuresFileItems"></bns-file-list-tabs>
        </el-tab-pane>
        <el-tab-pane label="分包商信息" name="five">
          <div class="app-container">
            <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" label-width="68px">
              <el-form-item label="分包商单位名称" label-width="120px">
                <el-input
                  v-model="queryParams.subName"
                  placeholder="请输入分包商单位名称"
                  clearable v-no-whitespace
                  @keyup.enter.native="handleQuery"
                />
              </el-form-item>
              <el-form-item>
                <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
                <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
                <el-button
                  type="primary"
                  plain
                  icon="el-icon-download"
                  size="mini"
                  @click="handleExport"
                >导出
                </el-button>
              </el-form-item>
            </el-form>
            <el-table v-loading="loading" :data="subList">
              <el-table-column
                type="index"
                width="55"
                label="序号"
                align="center"
                :index="indexContinuous(queryParams.pageNum, queryParams.pageSize)"
              />
              <el-table-column label="分包商单位名称" align="center" prop="subName"/>
              <el-table-column label="法人姓名" align="center" prop="corporateName"/>
              <el-table-column label="法人联系方式" width="120" align="center">
                <template slot-scope="scope">
                  <!-- 检查是否存在身份证号 -->
                  <span v-if="scope.row.corporatePhone">{{ hideSensitiveInfo(scope.row.corporatePhone) }}</span>
                  <span v-else>-</span>
                </template>
              </el-table-column>
              <el-table-column label="单位地址" align="center" prop="address"/>
              <el-table-column label="社会统一征信代码" align="center" prop="socialUnifiedCreditCode"/>
              <el-table-column label="当前状态" align="center" prop="status"/>
              <el-table-column label="入场日期" align="center" prop="admissionDate"/>
              <el-table-column label="离场日期" align="center" prop="departureDate"/>
              <el-table-column label="操作" align="center" fixed="right" class-name="small-padding fixed-width">
                <template slot-scope="scope">
                  <el-button
                    size="mini"
                    type="text"
                    @click="handleSubView(scope.row)"
                  >查看详情
                  </el-button>
                </template>
              </el-table-column>
            </el-table>

            <pagination
              v-show="total>0"
              :total="total"
              :page.sync="queryParams.pageNum"
              :limit.sync="queryParams.pageSize"
              @pagination="getSubList"
            />
          </div>
        </el-tab-pane>
        <el-tab-pane label="施工人员信息" name="six">
          <div class="app-container">
            <el-form :model="personQueryParams" ref="personQueryForm" size="small" :inline="true" label-width="68px">
              <el-form-item label="施工人员姓名" label-width="120px" prop="supervisorName">
                <el-input
                  v-model="personQueryParams.name"
                  placeholder="请输入施工人员姓名"
                  clearable v-no-whitespace
                  @keyup.enter.native="handleQueryPerson"
                />
              </el-form-item>
              <el-form-item label="状态" prop="status">
                <el-select v-model="personQueryParams.status" placeholder="请选择状态" clearable>
                  <el-option label="在场" value="1"/>
                  <el-option label="离场" value="2"/>
                </el-select>
              </el-form-item>
              <el-form-item label="人员进场时间范围" label-width="150px">
                <el-date-picker
                  v-model="timeRange"
                  type="daterange"
                  align="right"
                  :editable="false"
                  unlink-panels
                  range-separator="至"
                  start-placeholder="开始日期"
                  end-placeholder="结束日期"
                  :picker-options="pickerOptions">
                </el-date-picker>
              </el-form-item>
              <el-form-item>
                <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQueryPerson">搜索</el-button>
                <el-button icon="el-icon-refresh" size="mini" @click="resetQueryPerson">重置</el-button>
                <el-button
                  type="primary"
                  plain
                  icon="el-icon-download"
                  size="mini"
                  @click="handleExportPerosn"
                >导出
                </el-button>
              </el-form-item>
            </el-form>
            <el-table v-loading="loading" :data="personList">
              <el-table-column
                type="index"
                width="55"
                label="序号"
                align="center"
                :index="indexContinuous(personQueryParams.pageNum, personQueryParams.pageSize)"
              />
              <el-table-column label="姓名" width="70" align="center" prop="name"/>
              <el-table-column label="岗位" width="100" align="center" prop="postName"/>
              <el-table-column label="特殊工种种类" width="100" align="center" prop="specialJobType"/>
              <el-table-column label="体检文件" width="100" align="center">
                <template slot-scope="scope">
                  <el-button size="mini" @click="handleShow(scope.row,1)">查看</el-button>
                </template>
              </el-table-column>
              <el-table-column label="保险文件" width="100" align="center">
                <template slot-scope="scope">
                  <el-button size="mini" @click="handleShow(scope.row,2)">查看</el-button>
                </template>
              </el-table-column>
              <el-table-column label="特殊工种文件" width="100" align="center">
                <template slot-scope="scope">
                  <el-button size="mini" @click="handleShow(scope.row,3)">查看</el-button>
                </template>
              </el-table-column>
              <el-table-column label="其他文件" width="100" align="center">
                <template slot-scope="scope">
                  <el-button size="mini" @click="handleShow(scope.row,4)">查看</el-button>
                </template>
              </el-table-column>
              <el-table-column label="性别" width="50" align="center" prop="sex"/>
              <el-table-column label="年龄" width="50" align="center" prop="age"/>
              <el-table-column label="联系方式" width="120" align="center">
                <template slot-scope="scope">
                  <!-- 检查是否存在身份证号 -->
                  <span v-if="scope.row.phone">{{ hideSensitiveInfo(scope.row.phone) }}</span>
                  <span v-else>-</span>
                </template>
              </el-table-column>
              <el-table-column label="籍贯" width="70" align="center" prop="nativePlace"/>
              <el-table-column label="身份证号码" width="160" align="center">
                <template slot-scope="scope">
                  <!-- 检查是否存在身份证号 -->
                  <span v-if="scope.row.idCard">{{ hideSensitiveInfo(scope.row.idCard) }}</span>
                  <span v-else>-</span>
                </template>
              </el-table-column>
              <el-table-column label="民族" width="70" align="center" prop="nation"/>
              <el-table-column label="家庭地址" width="200" align="center" prop="homeAddress"/>
              <el-table-column label="现地址" width="200" align="center" prop="currentAddress"/>
              <el-table-column label="进场日期" width="100" align="center" prop="admissionDate"/>
              <el-table-column label="离场日期" width="100" align="center" prop="departureDate"/>
              <el-table-column label="人脸照片" align="center" prop="faceUrl">
                <template slot-scope="scope">
                  <el-popover placement="right" title="" trigger="hover">
                    <img :src="`${scope.row.faceUrl ? lookFaceFile+scope.row.faceUrl : ''}`" :min-width="300" :height="300" alt="照片" />
                    <img slot="reference" :src="`${scope.row.faceUrl ? lookFaceFile+scope.row.faceUrl : ''}`" style="max-height: 50px; max-width: 50px"
                         :alt="`${scope.row.faceUrl ? lookFaceFile+scope.row.faceUrl : ''}`"
                    />
                  </el-popover>
                </template>
              </el-table-column>
              <el-table-column label="状态" align="center" prop="status"/>
              <el-table-column label="操作" fixed="right" width="150" align="center"
                               class-name="small-padding fixed-width">
                <template slot-scope="scope">
                  <el-button
                    size="mini"
                    type="text"
                    @click="handleView(scope.row)"
                  >查看
                  </el-button>
                  <el-button
                    size="mini"
                    type="text"
                    @click="handleGenerate(scope.row)"
                  >生成工作证
                  </el-button>
                </template>
              </el-table-column>
            </el-table>

            <pagination
              v-show="personTotal>0"
              :total="personTotal"
              :page.sync="personQueryParams.pageNum"
              :limit.sync="personQueryParams.pageSize"
              @pagination="getConsPersonList"
            />
            <el-dialog title="文件查看" :visible.sync="document" width="80%" top="5vh" append-to-body>
              <div style="width: 100%;height:720px">
                <bns-file-list-tabs :items="fileList" />
              </div>
            </el-dialog>
            <el-dialog title="文件查看" :visible.sync="documentPreview" width="80%" top="5vh" append-to-body>
              <div style="width: 100%;height:720px">
                <bns-kkFile-preview :items="kkFilePreview"></bns-kkFile-preview>
              </div>
            </el-dialog>

            <!--施工人员基本信息查看-->
            <el-dialog title="查看详情" :visible.sync="constructionPersonnelOpen" width="60%" append-to-body :close-on-click-modal="false" >
              <bns-cons-person-details-tabs
                :items="formData"></bns-cons-person-details-tabs>
            </el-dialog>

            <!--生成工作证-->
            <el-dialog title="生成工作证" :visible.sync="workCardOpen" width="30%" :append-to-body="true">
              <el-form ref="elForm" :model="formData" size="medium" label-width="100px">
                <bns-generate-work-card-tabs
                  :items="workCardItems"></bns-generate-work-card-tabs>
              </el-form>
            </el-dialog>
          </div>
        </el-tab-pane>
        <el-tab-pane label="工器具信息" name="seven">
          <div class="app-container">
            <el-form :model="equipQueryParams" ref="equipQueryForm" size="small" :inline="true" label-width="68px">
              <el-form-item label="工器具名称" label-width="120px">
                <el-input
                  v-model="equipQueryParams.equipName"
                  placeholder="请输入工器具名称"
                  clearable v-no-whitespace
                  @keyup.enter.native="equipHandleQuery"
                />
              </el-form-item>
              <el-form-item>
                <el-button type="primary" icon="el-icon-search" size="mini" @click="equipHandleQuery">搜索</el-button>
                <el-button icon="el-icon-refresh" size="mini" @click="equipResetQuery">重置</el-button>
                <el-button
                  type="primary"
                  plain
                  icon="el-icon-download"
                  size="mini"
                  @click="equipHandleExport"
                >导出
                </el-button>
              </el-form-item>
            </el-form>
            <el-table v-loading="loading" :data="equipList">
              <el-table-column
                type="index"
                width="55"
                label="序号"
                align="center"
                :index="indexContinuous(equipQueryParams.pageNum, equipQueryParams.pageSize)"
              />
              <el-table-column label="工器具名称" align="center" prop="equipName"/>
              <el-table-column label="型号" align="center" prop="model"/>
              <el-table-column label="单位" align="center" prop="unit"/>
              <el-table-column label="数量" align="center" prop="num"/>
              <el-table-column label="设备类型" align="center" prop="equipType"/>
              <el-table-column label="检测时间" align="center" prop="detectionTime"/>
              <el-table-column label="进场日期" align="center" prop="approachDate"/>
              <el-table-column label="操作" align="center" fixed="right" class-name="small-padding fixed-width">
                <template slot-scope="scope">
                  <el-button
                    size="mini"
                    type="text"
                    @click="equipHandleView(scope.row)"
                  >查看
                  </el-button>
                </template>
              </el-table-column>
            </el-table>
            <pagination
              v-show="equipTotal>0"
              :total="equipTotal"
              :page.sync="equipQueryParams.pageNum"
              :limit.sync="equipQueryParams.pageSize"
              @pagination="getConsEquipList"
            />

            <el-dialog title="查看详情" :visible.sync="equipOpen" width="40%" :append-to-body="true">
              <div>
                <el-form ref="elForm" size="medium" label-width="100px">
                  <el-form-item label-width="120px" label="工器具名称">
                    <el-input v-model="equipItem.equipName"  :disabled='true' clearable v-no-whitespace
                              :style="{width: '100%'}"></el-input>
                  </el-form-item>
                  <el-form-item label-width="120px" label="工器具名称">
                    <el-input v-model="equipItem.equipName"  :disabled='true' clearable v-no-whitespace
                              :style="{width: '100%'}"></el-input>
                  </el-form-item>
                  <el-form-item label-width="120px" label="型号">
                    <el-input v-model="equipItem.model"  :disabled='true' clearable v-no-whitespace
                              :style="{width: '100%'}"></el-input>
                  </el-form-item>
                  <el-form-item label-width="120px" label="单位">
                    <el-input v-model="equipItem.unit"  :disabled='true' clearable v-no-whitespace
                              :style="{width: '100%'}"></el-input>
                  </el-form-item>
                  <el-form-item label-width="120px" label="数量">
                    <el-input v-model="equipItem.num"  :disabled='true' clearable v-no-whitespace
                              :style="{width: '100%'}"></el-input>
                  </el-form-item>
                  <el-form-item label-width="120px" label="设备类型">
                    <el-input v-model="equipItem.equipType"  :disabled='true' clearable v-no-whitespace
                              :style="{width: '100%'}"></el-input>
                  </el-form-item>
                  <el-form-item label-width="120px" label="检测时间">
                    <el-input v-model="equipItem.detectionTime"  :disabled='true' clearable v-no-whitespace
                              :style="{width: '100%'}"></el-input>
                  </el-form-item>
                  <el-form-item label-width="120px" label="是否强制检测检验">
                    <el-input v-model="equipItem.isForceDetection"  :disabled='true' clearable v-no-whitespace
                              :style="{width: '100%'}"></el-input>
                  </el-form-item>
                  <el-form-item label-width="120px" label="下次检测时间">
                    <el-input v-model="equipItem.nextDetectionTime"  :disabled='true' clearable v-no-whitespace
                              :style="{width: '100%'}"></el-input>
                  </el-form-item>
                  <el-form-item label-width="120px" label="进场时间">
                    <el-input v-model="equipItem.approachDate"  :disabled='true' clearable v-no-whitespace
                              :style="{width: '100%'}"></el-input>
                  </el-form-item>
                  <el-form-item label-width="120px" label="工器具文件">
                  </el-form-item>
                  <img v-if="equipItem.fileList.length === 0" src="../../../../assets/file/no_file.png" alt="暂无数据"
                       style="width: 100px;height: 100px;margin-left: 45px;"/>
                  <bns-file-list-tabs
                    v-else
                    :items="equipItem.fileList"
                    :style="{marginLeft:'45px'}"></bns-file-list-tabs>

                </el-form>
              </div>
            </el-dialog>
          </div>
        </el-tab-pane>
        <el-tab-pane label="施工材料文件" name="eight">
          <div class="app-container">
            <el-form :model="materialsQueryParams" ref="materialsQueryForm" size="small" :inline="true" label-width="68px">
              <el-form-item label="文件名称" label-width="120px">
                <el-input
                  v-model="materialsQueryParams.fileName"
                  placeholder="请输入文件名称"
                  clearable v-no-whitespace
                  @keyup.enter.native="materialsHandleQuery"
                />
              </el-form-item>
              <el-form-item label="提交人姓名" label-width="120px">
                <el-input
                  v-model="materialsQueryParams.name"
                  placeholder="请输入提交人姓名"
                  clearable v-no-whitespace
                  @keyup.enter.native="materialsHandleQuery"
                />
              </el-form-item>
              <el-form-item label="提交时间范围" label-width="150px">
                <el-date-picker
                  v-model="materialsTimeRange"
                  type="daterange"
                  align="right"
                  :editable="false"
                  unlink-panels
                  range-separator="至"
                  start-placeholder="开始日期"
                  end-placeholder="结束日期"
                  :picker-options="pickerOptions">
                </el-date-picker>
              </el-form-item>
              <el-form-item>
                <el-button type="primary" icon="el-icon-search" size="mini" @click="materialsHandleQuery">搜索</el-button>
                <el-button icon="el-icon-refresh" size="mini" @click="materialsResetQuery">重置</el-button>
                <el-button
                  type="primary"
                  plain
                  icon="el-icon-download"
                  size="mini"
                  @click="materialsHandleExport"
                >导出
                </el-button>
              </el-form-item>
            </el-form>
            <el-table v-loading="loading" :data="materialsList">
              <el-table-column
                type="index"
                width="55"
                label="序号"
                align="center"
                :index="indexContinuous(materialsQueryParams.pageNum, materialsQueryParams.pageSize)"
              />
              <el-table-column label="文件名" align="center" prop="fileName"/>
              <el-table-column label="文件大小" align="center" prop="fileSize"/>
              <el-table-column label="提交人" align="center" prop="name"/>
              <el-table-column label="提交时间" align="center" prop="createTime"/>
              <el-table-column label="操作" align="center" fixed="right" class-name="small-padding fixed-width">
                <template slot-scope="scope">
                  <el-button
                    size="mini"
                    type="text"
                    @click="materialsHandlePreview(scope.row)"
                  >预览
                  </el-button>
                  <el-button
                    size="mini"
                    type="text"
                    @click="materialsHandleDownload(scope.row)"
                  >下载
                  </el-button>
                </template>
              </el-table-column>
            </el-table>

            <pagination
              v-show="materialsTotal>0"
              :total="materialsTotal"
              :page.sync="materialsQueryParams.pageNum"
              :limit.sync="materialsQueryParams.pageSize"
              @pagination="getConsMaterialsList"
            />
          </div>
          <el-dialog title="文件预览" :visible.sync="viewOpen" width="90%" append-to-body>
            <div style="width: 100%;height:720px">
              <bns-kkFile-preview :items="filePreview"></bns-kkFile-preview>
            </div>
          </el-dialog>
        </el-tab-pane>
      </el-tabs>
    </el-tab-pane>
  </el-tabs>
</template>
<script>
import { hideSensitiveInfo, indexContinuous, lookFaceFile } from '@/utils/bonus'
import bnsSubInfoTabs from '@/components/pro-tabs/bns-sub-info-tabs.vue';
import bnsConsInfoTabs from '@/components/pro-tabs/bns-cons-info-tabs.vue';
import bnsFileListTabs from '@/components/pro-tabs/bns-file-list-tabs.vue';
import bnsGenerateWorkCardTabs from '@/components/pro-tabs/bns-generate-work-card-tabs.vue';
import bnsConsPersonDetailsTabs from '@/components/pro-tabs/bns-cons-person-details-tabs.vue'
import bnsKkFilePreview from '@/components/pro-tabs/bns-kkFile-preview.vue';

import {
  selectConArr,
  getConsDetailsInfo,
  getSubList,
  getConsPersonList,
  getConsEquipList,
  getConsMaterialsList,
  getConstructionPersonnelDetails,
  getEquipDetails
} from '@/api/pro/outsourcingPro'
import {selectFile,downloadFile} from "@/api/tool/select";

import { encryptCBC } from '@/utils/aescbc'
export default {
  components: {
    bnsConsInfoTabs,
    bnsSubInfoTabs,
    bnsFileListTabs,
    bnsGenerateWorkCardTabs,
    bnsConsPersonDetailsTabs,
    bnsKkFilePreview
  },
  data() {
    return {
      timeRange: [],
      materialsTimeRange:[],
      equipItem:{
        fileList:[]
      },
      filePreview:{},
      viewOpen: false,
      equipOpen: false,
      document:false,
      documentPreview: false,
      fileList: [],
      kkFilePreview: {
        filePreviewUrl: '',
        fileName: '',
        showDownloadButton: false
      },
      proId:undefined,
      consId: undefined,
      //当前激活的标签页
      activeName: 'tab0',
      activeChildName: 'first',
      //施工人员详情弹出层
      constructionPersonnelOpen: false,
      //生成工作证弹出层
      workCardOpen: false,
      //时间范围选择器
      pickerOptions: {
        shortcuts: [{
          text: '最近一周',
          onClick(picker) {
            const end = new Date();
            const start = new Date();
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
            picker.$emit('pick', [start, end]);
          }
        }, {
          text: '最近一个月',
          onClick(picker) {
            const end = new Date();
            const start = new Date();
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
            picker.$emit('pick', [start, end]);
          }
        }, {
          text: '最近三个月',
          onClick(picker) {
            const end = new Date();
            const start = new Date();
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
            picker.$emit('pick', [start, end]);
          }
        }]
      },
      gutterValue: parseInt("21", 10),
      // 遮罩层
      loading: false,
      // 总条数
      total: 0,
      personTotal: 0,
      equipTotal: 0,
      materialsTotal: 0,
      //承包商单位信息
      consUnitInformationItems: {},
      // 分包商信息查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        subName: undefined,
      },
      // 施工人员基本信息查询参数
      personQueryParams: {
        pageNum: 1,
        pageSize: 10,
        name: undefined,
        status: undefined,
        admissionDate: undefined,
        departureDate: undefined,
      },
      // 工器具信息查询参数
      equipQueryParams: {
        pageNum: 1,
        pageSize: 10,
        equipName: undefined,
      },
      // 施工材料文件信息查询参数
      materialsQueryParams: {
        pageNum: 1,
        pageSize: 10,
        fileName: undefined,
        name: undefined,
        startDate: undefined,
        endDate: undefined
      },
      //承包商单位名称
      consNameArr: [],
      //企业资质
      enterpriseQualificationItems: [],
      //安全协议书
      securityAgreementFileItems: [],
      //四措两案
      fourMeasuresAndTwoMeasuresFileItems: [],
      // 分包商基本信息表格数据
      subList: [],
      // 施工人员基本信息表格数据
      personList: [],
      // 工器具信息表格数据
      equipList: [],
      // 施工材料文件表格数据
      materialsList: [],
      //工作证信息
      workCardItems: {},
      // 人员详情  表单参数
      formData: {},
      lookFaceFile:''
    };
  },
  created() {
    this.lookFaceFile = lookFaceFile()
    this.proId = this.$route.params && this.$route.params.proId;
    this.getConsArr()
  },
  methods: {
    indexContinuous,
    lookFaceFile,
    hideSensitiveInfo,
    changTime(){
      this.personQueryParams.admissionDate = this.timeRange[0]
      this.personQueryParams.departureDate = this.timeRange[1]
    },
    changMaterialsTime(){
      this.materialsQueryParams.startDate = this.materialsTimeRange[0]
      this.materialsQueryParams.endDate = this.materialsTimeRange[1]
    },
    /** 文件查看按钮操作 */
    handleShow(row,informationType) {
      this.loading = true
      const arr = {
        1: '体检文件',
        2: '保险文件',
        3: '特殊工种文件',
        4: '其他文件'
      }
      selectFile({classification:9, uuid: row.uuid,informationType: informationType,fromType:2 }).then(response => {
        console.log(response)
        if (response.data.length === 0){
          this.fileList = []
          this.$message.warning(arr[informationType] + '暂无')
        }else if(response.data.length === 1) {
          this.kkFilePreview = {
            filePreviewUrl: response.data[0].filePath,
            fileName: response.data[0].fileName,
            showDownloadButton: false
          }
          this.documentPreview = true
        }else{
          this.fileList = response.data
          this.document = true
        }
        this.loading = false
      })
    },
    /**获取承包商名称数组*/
    getConsArr() {
      this.loading = true;
      const params = {
        proId : this.proId
      }
      selectConArr(params).then(response => {
        this.consNameArr = response.data;
        this.loading = false;
        //在进行加载其他数据
        this.consId = this.consNameArr[0].uuid
        this.init(this.consNameArr[0].uuid)
      });
    },
    /**初始化数据*/
    init(){
      this.getConsDetailsInfo()
      this.getEnterpriseQualification()
      this.getSecurityAgreement()
      this.getFourMeasuresAndTwoMeasures()
      this.getSubList()
      this.getConsPersonList()
      this.getConsEquipList()
      this.getConsMaterialsList()
    },
    /**获取承包商基本信息*/
    getConsDetailsInfo(){
      const params = {
        consUuid : this.consId,
        proId: this.proId
      }
      getConsDetailsInfo(params).then(response => {
        this.consUnitInformationItems = response;
        this.loading = false;
      });
    },
    /**获取企业资质*/
    getEnterpriseQualification(){
      const params = {
        consUuid : this.consId,
        proId: this.proId,
        classification: '2',
        fromType : '1',
        informationType : '1',
      }
      selectFile(params).then(response => {
        this.enterpriseQualificationItems = []
        this.enterpriseQualificationItems = response.data;
      });
    },
    /**获取安全协议书*/
    getSecurityAgreement(){
      const params = {
        consUuid : this.consId,
        proId: this.proId,
        classification: '2',
        fromType : '1',
        informationType : '2',
      }
      selectFile(params).then(response => {
        this.securityAgreementFileItems = []
        this.securityAgreementFileItems = response.data;
      });
    },
    /**获取四措两案*/
    getFourMeasuresAndTwoMeasures(){
      const params = {
        consUuid : this.consId,
        proId: this.proId,
        classification: '2',
        fromType : '1',
        informationType : '3',
      }
      selectFile(params).then(response => {
        this.fourMeasuresAndTwoMeasuresFileItems = []
        this.fourMeasuresAndTwoMeasuresFileItems = response.data;
      });
    },
    /**分包商信息查询*/
    getSubList() {
      this.loading = true;
      this.queryParams.consUuid = this.consId
      this.queryParams.proId = this.proId
      getSubList(this.queryParams).then(response => {
        this.subList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    /**分包商信息查询*/
    getConsPersonList() {
      this.loading = true;
      this.personQueryParams.consUuid = this.consId
      this.personQueryParams.proId = this.proId
      this.changTime()
      getConsPersonList(this.personQueryParams).then(response => {
        this.personList = response.rows;
        this.personTotal = response.total;
        this.loading = false;
      });
    },
    /**工器具信息查询*/
    getConsEquipList() {
      this.loading = true;
      this.equipQueryParams.consUuid = this.consId
      this.equipQueryParams.proId = this.proId
      getConsEquipList(this.equipQueryParams).then(response => {
        this.equipList = response.rows;
        this.equipTotal = response.total;
        this.loading = false;
      });
    },
    /**施工材料信息查询*/
    getConsMaterialsList() {
      this.loading = true;
      this.materialsQueryParams.consUuid = this.consId
      this.materialsQueryParams.proId = this.proId
      this.changMaterialsTime()
      getConsMaterialsList(this.materialsQueryParams).then(response => {
        this.materialsList = response.rows;
        this.materialsTotal = response.total;
        this.loading = false;
      });
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getSubList();
    },
    handleQueryPerson() {
      this.queryParams.pageNum = 1;
      this.getConsPersonList();
    },
    equipHandleQuery() {
      this.queryParams.pageNum = 1;
      this.getConsEquipList();
    },
    materialsHandleQuery() {
      this.queryParams.pageNum = 1;
      this.getConsMaterialsList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.queryParams.subName = undefined;
      this.handleQuery();
    },
    /** 重置按钮操作 */
    resetQueryPerson() {
      this.personQueryParams.name = undefined
      this.personQueryParams.status = undefined
      this.personQueryParams.admissionDate = undefined
      this.personQueryParams.departureDate = undefined
      this.timeRange = []
      this.handleQueryPerson();
    },
    /** 重置按钮操作 */
    equipResetQuery() {
      this.equipQueryParams.equipName = undefined
      this.equipHandleQuery();
    },
    /** 重置按钮操作 */
    materialsResetQuery() {
      this.materialsQueryParams.startDate = undefined
      this.materialsQueryParams.endDate = undefined
      this.materialsTimeRange = []
      this.materialsQueryParams.fileName = undefined
      this.materialsQueryParams.name = undefined
      this.materialsHandleQuery();
    },
    /** 导出按钮操作 */
    handleExport() {
      this.derive('system/post/export', {
        ...this.queryParams
      }, `post_${new Date().getTime()}.xlsx`)
    },
    /** 导出按钮操作 */
    handleExportPerosn() {
      this.derive('system/post/export', {
        ...this.queryParams
      }, `post_${new Date().getTime()}.xlsx`)
    },
    /** 导出按钮操作 */
    equipHandleExport() {
      this.derive('system/post/export', {
        ...this.queryParams
      }, `post_${new Date().getTime()}.xlsx`)
    },
    /** 导出按钮操作 */
    materialsHandleExport() {
      this.derive('system/post/export', {
        ...this.queryParams
      }, `post_${new Date().getTime()}.xlsx`)
    },
    // 点击tab事件  切换tab
    handleClick(tab, event) {
      //切换tab  重获加载数据
      this.consId = this.consNameArr[tab.index].uuid
      this.init(this.consNameArr[tab.index].uuid)
    },
    // 点击tab事件  切换tab
    handleChildClick(tab, event) {
    },
    /**分包商基本信息查看*/
    handleSubView(row) {
      this.$router.push('/system/outsourcing-subDetailsInfo-auth/subDetailsInfo/' + encryptCBC(JSON.stringify({
        proId: row.proId,
        consUuid: row.consUuid,
        supUuid: row.supUuid,
        subId: row.id,
        subUuid: row.subUuid,
        uuid: row.uuid
      })))
    },
    /**人员基本信息查看*/
    handleView(row) {
      this.supervisorOpen = false;
      this.workCardOpen = false;
      this.constructionPersonnelOpen = true;
      const params = {
        uuid: row.uuid
      }
      getConstructionPersonnelDetails(params).then(response => {
        console.log(response)
        this.formData = response.data;
        this.loading = false;
      });
    },
    close() {
      this.supervisorOpen = false;
      this.workCardOpen = false;
    },
    /**弹出工作证页面按钮*/
    handleGenerate(row) {
      this.workCardOpen = true;
      this.workCardItems={
          proName: row.proName,
          faceUrl: row.faceUrl,
          name: row.name,
          phone: row.phone,
          postName:row.postName
      }
    },
    /**弹出工作证页面按钮*/
    equipHandleView(row) {
      this.equipOpen = true;
      const params = {
          id : row.id,
          consUuid : this.consId,
          proId :this.proId
      }
      getEquipDetails(params).then(response => {
        this.equipItem = response.data;
        this.loading = false;
      });
    },
    /**预览文件*/
    materialsHandlePreview(row) {
      this.viewOpen = true;
      this.filePreview = {
        filePreviewUrl: row.filePath,
        fileName: row.fileName,
      }
    },
    /**下载文件*/
    materialsHandleDownload(row) {
      downloadFile(row.filePath,row.fileName);
    },
  },
};
</script>
<style scoped>
</style>
