<template>
  <div class="page" >
    <el-form size="small" :inline="true" class="query-form" ref="searchForm" :model="searchForm" @keyup.enter.native="refreshList()" @submit.native.prevent>
      <!-- 搜索框-->
      <el-form-item label="项目名称" prop="name">
        <el-input size="small" v-model="searchForm.name" placeholder="请输入项目名称" clearable></el-input>
      </el-form-item>
      <el-form-item label="项目编号" prop="no">
        <el-input size="small" v-model="searchForm.no" placeholder="请输入项目编号" clearable></el-input>
      </el-form-item>
      <el-form-item v-if="showHideItem" label="登记人" prop="createBy">
        <UserSelect :limit='1' :readonly="true" :userName="applyUserName" @getValue='(value, label) => {searchForm.createBy = value,applyUserName  = label}'></UserSelect>
      </el-form-item>
      <el-form-item v-if="showHideItem" label="项目负责人" prop="projectManagerName">
        <el-input size="small" v-model="searchForm.projectManagerName" placeholder="请输入项目负责人" clearable></el-input>
      </el-form-item>
      <el-form-item v-if="showHideItem" label="合同名称" prop="contractName">
        <el-input size="small" v-model="searchForm.contractName" placeholder="请输入合同名称" clearable></el-input>
      </el-form-item>
      <el-form-item v-if="showHideItem" label="委托方" prop="clientName">
        <el-input size="small" v-model="searchForm.clientName" placeholder="请输入委托方" clearable></el-input>
      </el-form-item>
      <el-form-item v-if="showHideItem" label="创建时间" prop="createDates">
        <el-date-picker
          placement="bottom-start"
          format="yyyy-MM-dd HH:mm:ss"
          value-format="yyyy-MM-dd HH:mm:ss"
          v-model="searchForm.createDates"
          type="datetimerange"
          range-separator="至"
          start-placeholder="开始日期"
          end-placeholder="结束日期">
        </el-date-picker>
      </el-form-item>
      <el-form-item v-if="showHideItem" label="状态" prop="status">
        <el-select v-model="searchForm.status" placeholder="请选择" style="width:100%;"clearable>
          <el-option
            v-for="item in $dictUtils.getDictList('program_project_list_info_status')"
            :key="item.value"
            :label="item.label"
            :value="item.value">
          </el-option>
        </el-select>
      </el-form-item>

      <el-form-item>
        <el-button type="default" @click="showHide" size="small" :icon="showHideIcon">{{showHideName}}</el-button>
        <el-button type="primary" @click="refreshList()" size="small" icon="el-icon-search">查询</el-button>
        <el-button @click="resetSearch()" size="small" icon="el-icon-refresh-right">重置</el-button>
      </el-form-item>
    </el-form>

    <div class="bg-white top" style="">
      <vxe-toolbar :refresh="{query: refreshList}" export custom>
        <template #buttons>
          <el-button v-if="hasPermission('program:registered:add')" type="primary" size="small" icon="el-icon-plus" @click="start()">新建</el-button>
          <el-button v-if="hasPermission('program:registered:del')" type="danger"   size="small" icon="el-icon-delete" @click="deleteAll()" :disabled="$refs.typeDictTable && $refs.typeDictTable.getCheckboxRecords().length === 0" plain>删除</el-button>
        </template>
      </vxe-toolbar>
      <div style="height: calc(100% - 80px)">
        <vxe-table
          border="inner"
          auto-resize
          resizable
          height="auto"
          :loading="loading"
          size="small"
          ref="typeDictTable"
          show-header-overflow
          show-overflow
          highlight-hover-row
          :menu-config="{}"
          @sort-change="sortChangeHandle"
          :export-config="{
                    remote: true,
                    filename: `兴光评估项目数据${moment(new Date()).format('YYYY-MM-DD')}`,
                    sheetName: `兴光评估项目数据${moment(new Date()).format('YYYY-MM-DD')}`,
                    exportMethod: exportMethod,
                    types: ['xlsx'],
                    modes: ['current', 'selected', 'all']
                  }"
          :sort-config="{remote:true}"
          :data="dataList"
          :tree-config="{}"
          :checkbox-config="{}">
          <vxe-column type="seq" width="60" title="序号"></vxe-column>
          <vxe-column type="checkbox" width="40" ></vxe-column>
          <vxe-column min-width="170" align="center" title="项目名称" field="name" >
            <template slot-scope="scope">
              <el-link  type="primary" :underline="false" v-if="hasPermission('program:registered:view')" @click="view(scope.row)">{{scope.row.name}}</el-link>
              <el-link  type="primary" :underline="false" v-else-if="hasPermission('program:registered:view')" @click="view(scope.row)">{{scope.row.name}}</el-link>
              <span v-else>{{scope.row.name}}</span>
            </template>
          </vxe-column>
          <vxe-column min-width="100"align="center" title="项目编号" field="no"></vxe-column>
          <vxe-column min-width="180"align="center" title="合同名称" field="contractName">
            <template slot-scope="scope">
              <el-link  type="primary" :underline="false" v-if="hasPermission('program:registered:view')" @click="viewContract(scope.row.contractId)">{{scope.row.contractName}}</el-link>
              <el-link  type="primary" :underline="false" v-else-if="hasPermission('program:registered:view')" @click="viewContract(scope.row.contractId)">{{scope.row.contractName}}</el-link>
              <span v-else>{{scope.row.name}}</span>
            </template>
          </vxe-column>
          <vxe-column min-width="100"align="center" title="项目负责人" field="projectManagerName"></vxe-column>
          <vxe-column min-width="180"align="center" title="委托方" field="clientName"></vxe-column>
          <vxe-column min-width="210"align="center" title="报告号" field="reportNo"></vxe-column>
          <vxe-column min-width="100"align="center" title="登记人" field="createBy"></vxe-column>
          <vxe-column min-width="120"align="center" title="创建日期" field="createDate"></vxe-column>

          <vxe-column  min-width="150px"align="center" title="状态" field="status" >
            <template slot-scope="scope">
              <el-button  type="text" @click="registeredDetail(scope.row)" :type="$dictUtils.getDictLabel('program_project_list_info_status_info', scope.row.status, '-')" effect="dark" size="mini">{{$dictUtils.getDictLabel("program_project_list_info_status", scope.row.status, '-')}} </el-button>
            </template>
          </vxe-column>
          <vxe-column min-width="120"align="center" title="一级校审" field="status1">
            <template slot-scope="scope">
              <el-button  type="text" @click="firstAuditDetail(scope.row)" :type="$dictUtils.getDictLabel('program_project_list_info_status_info', scope.row.status1, '-')" effect="dark" size="mini">{{$dictUtils.getDictLabel("program_project_list_info_status", scope.row.status1, '-')}} </el-button>
            </template>
          </vxe-column>
          <vxe-column min-width="120"align="center" title="二级校审" field="status2">
            <template slot-scope="scope">
              <el-button  type="text" @click="secondAuditDetail(scope.row)" :type="$dictUtils.getDictLabel('program_project_list_info_status_info', scope.row.status2, '-')" effect="dark" size="mini">{{$dictUtils.getDictLabel("program_project_list_info_status", scope.row.status2, '-')}} </el-button>
            </template>
          </vxe-column>
          <vxe-column min-width="120"align="center" title="三级校审" field="status3">
            <template slot-scope="scope">
              <el-button  type="text" @click="thirdAuditDetail(scope.row)" :type="$dictUtils.getDictLabel('program_project_list_info_status_info', scope.row.status3, '-')" effect="dark" size="mini">{{$dictUtils.getDictLabel("program_project_list_info_status", scope.row.status3, '-')}} </el-button>
            </template>
          </vxe-column>
          <vxe-column  min-width="150px"align="center" title="签发单状态" field="issuedStatus" >
            <template slot-scope="scope">
              <el-button  type="text" @click="issuedDetail(scope.row)" :type="$dictUtils.getDictLabel('program_project_list_info_status_info', scope.row.issuedStatus, '-')" effect="dark" size="mini">{{$dictUtils.getDictLabel("program_project_list_info_status", scope.row.issuedStatus, '未登记')}} </el-button>
            </template>
          </vxe-column>
          <vxe-column min-width="120"align="center" title="项目归档" field="archiveStatus">
            <template slot-scope="scope">
              <el-button  type="text" @click="archiveDetail(scope.row)" :type="$dictUtils.getDictLabel('program_project_list_info_status_info', scope.row.archiveStatus, '-')" effect="dark" size="mini">{{$dictUtils.getDictLabel("program_project_list_info_status", scope.row.archiveStatus, '-')}} </el-button>
            </template>
          </vxe-column>
          <vxe-column title="操作" min-width="200px" fixed="right" align="center">
            <template  slot-scope="scope">
              <el-button v-if="hasPermission('program:registered:edit')&&(scope.row.status === '1' || scope.row.status === '3')&&(scope.row.createBy === createName||haveProjectIds.includes(scope.row.id))" type="text" size="small" @click="registeredPush(scope.row)">修改</el-button>
              <!--管理员角色登记完成后可修改-->
              <el-button v-if="hasPermission('program:registered:edit')&&scope.row.status === '5' && isAdmin" type="text" size="small" @click="edit(scope.row.id)">修改</el-button>
              <!--项目负责人修改-->
              <el-button v-if="hasPermission('program:registered:edit')&&scope.row.status === '5' &&(scope.row.createBy === createName||haveProjectIds.includes(scope.row.id)) && (scope.row.archiveStatus === null ||scope.row.archiveStatus === undefined ||scope.row.archiveStatus === '' ||scope.row.archiveStatus === '0')" type="text" size="small" @click="edit(scope.row.id)">修改</el-button>
              <el-button v-if="hasPermission('program:registered:edit')&&scope.row.status === '2'&&(scope.row.createBy === createName||haveProjectIds.includes(scope.row.id))" type="text" size="small" @click="registeredReback(scope.row)">撤回</el-button>
              <!--项目登记  审核-->
              <el-button v-if="scope.row.status==='2' && checkIsAudit(scope.row)" type="text"  size="small" @click="examine(scope.row)">登记审核</el-button>
              <!--项目登记  被驳回后当前申请人重新调整-->
              <el-button v-if="hasPermission('program:registered:edit')&&(scope.row.createBy === createName||haveProjectIds.includes(scope.row.id))&&scope.row.status === '4'" type="text"  size="small" @click="adjust(scope.row)">驳回调整</el-button>

              <el-button v-if="hasPermission('program:registered:del')&&(scope.row.status === '1' || scope.row.status === '3')&&(scope.row.createBy === createName||haveProjectIds.includes(scope.row.id))" type="text" size="small" @click="del(scope.row.id)">删除</el-button>
              <!--管理员角色登记完成后可删除-->
              <el-button v-if="hasPermission('program:registered:del')&&scope.row.status === '5' && isAdmin" type="text" size="small" @click="del(scope.row.id)">删除</el-button>

<!--              <el-button v-if="hasPermission('program:registered:edit')&&scope.row.status === '5' && commonJS.isEmpty(scope.row.reportNo) && scope.row.createBy === createName" type="text" size="small" @click="saveReportNo(scope.row.id)">生成报告号</el-button>-->

              <!-- 一级校审  发起-->
              <el-button v-if="hasPermission('program:registered:edit')&&scope.row.status === '5' &&(scope.row.createBy === createName||haveProjectIds.includes(scope.row.id))&&(scope.row.status1 === '0'||scope.row.status1 === '1'||scope.row.status1 === '3')" type="text" size="small" @click="firstAuditPush(scope.row)">一级校审</el-button>
              <!-- 一级校审  撤回-->
              <el-button v-if="hasPermission('program:registered:edit')&&scope.row.status1 === '2' &&(scope.row.createBy === createName||haveProjectIds.includes(scope.row.id))" type="text" size="small" @click="firstAuditReback(scope.row)">校审撤回</el-button>
              <!-- 一级校审  审核-->
              <el-button v-if="scope.row.status1==='2' && checkIsAuditFirst(scope.row)" type="text"  size="small" @click="examineFirst(scope.row)">一级校审审核</el-button>
              <!-- 一级校审  被驳回后当前申请人重新调整-->
              <el-button v-if="hasPermission('program:registered:edit')&&(scope.row.createBy === createName||haveProjectIds.includes(scope.row.id))&&scope.row.status1 === '4'" type="text"  size="small" @click="adjustFirst(scope.row)">驳回调整</el-button>

              <!-- 二级校审  发起-->
              <el-button v-if="hasPermission('program:registered:edit')&&(scope.row.createBy === createName||haveProjectIds.includes(scope.row.id))&&scope.row.status1 === '5'&&(scope.row.status2 === '0'||scope.row.status2 === '1'||scope.row.status2 === '3')" type="text" size="small" @click="secondAuditPush(scope.row)">二级校审</el-button>
              <!-- 二级校审  撤回-->
              <el-button v-if="hasPermission('program:registered:edit')&&scope.row.status2 === '2'&&(scope.row.createBy === createName||haveProjectIds.includes(scope.row.id))" type="text" size="small" @click="secondAuditReback(scope.row)">校审撤回</el-button>
              <!-- 二级校审  审核-->
              <el-button v-if="scope.row.status2==='2' && checkIsAuditSecond(scope.row)" type="text"  size="small" @click="examineSecond(scope.row)">二级校审审核</el-button>
              <!-- 二级校审  被驳回后当前申请人重新调整-->
              <el-button v-if="hasPermission('program:registered:edit')&&(scope.row.createBy === createName||haveProjectIds.includes(scope.row.id))&&scope.row.status2 === '4'" type="text"  size="small" @click="adjustSecond(scope.row)">驳回调整</el-button>

              <!-- 三级校审  发起-->
              <el-button v-if="hasPermission('program:registered:edit')&&(scope.row.createBy === createName||haveProjectIds.includes(scope.row.id))&&scope.row.status2 === '5' &&(scope.row.status3 === '0'||scope.row.status3 === '1'||scope.row.status3 === '3')" type="text" size="small" @click="thirdAuditPush(scope.row)">三级校审</el-button>
              <!-- 三级校审  撤回-->
              <el-button v-if="hasPermission('program:registered:edit')&&(scope.row.createBy === createName||haveProjectIds.includes(scope.row.id))&&scope.row.status3 === '2'" type="text" size="small" @click="thirdAuditReback(scope.row)">校审撤回</el-button>
              <!-- 三级校审  审核-->
              <el-button v-if="scope.row.status3==='2' && checkIsAuditThird(scope.row)" type="text"  size="small" @click="examineThird(scope.row)">三级校审审核</el-button>
              <!-- 三级校审  被驳回后当前申请人重新调整-->
              <el-button v-if="hasPermission('program:registered:edit')&&(scope.row.createBy === createName||haveProjectIds.includes(scope.row.id))&&scope.row.status3 === '4'" type="text"  size="small" @click="adjustThird(scope.row)">驳回调整</el-button>

              <!--三神结束后，评估报告签发前进行资产评估项目（校对）-->
              <el-button v-if="hasPermission('program:registered:proo')&&(scope.row.createBy === createName||haveProjectIds.includes(scope.row.id))&&scope.row.status3 === '5'&&commonJS.isEmpty(scope.row.issuedStatus)" type="text" size="small" @click="proofread(scope.row.id)">校对</el-button>
              <!--报告签发-->
              <el-button v-if="hasPermission('program:registered:browse')&&(scope.row.createBy === createName||haveProjectIds.includes(scope.row.id)) &&scope.row.status3 === '5' && (scope.row.issuedStatus === null ||scope.row.issuedStatus === undefined ||scope.row.issuedStatus === '' ||scope.row.issuedStatus === '0' || scope.row.issuedStatus === '1' || scope.row.issuedStatus === '3')" type="text" size="small" @click="issued(scope.row)">签发</el-button>
              <!--报告签发撤回-->
              <el-button v-if="hasPermission('program:registered:browse')&&(scope.row.createBy === createName||haveProjectIds.includes(scope.row.id)) && scope.row.issuedStatus === '2'" type="text" size="small" @click="issuedReback(scope.row)">签发撤回</el-button>
              <!-- 报告签发  审核-->
              <el-button v-if="scope.row.issuedStatus==='2' && checkIsAuditIssued(scope.row)" type="text"  size="small" @click="examineIssued(scope.row)">签发审核</el-button>
              <!-- 报告签发  被驳回后当前申请人重新调整-->
              <el-button v-if="hasPermission('program:registered:browse')&&(scope.row.createBy === createName||haveProjectIds.includes(scope.row.id))&&scope.row.issuedStatus === '4'" type="text"  size="small" @click="adjustIssued(scope.row)">驳回调整</el-button>

              <!--评估报告装订后的审核-->
              <el-button v-if="hasPermission('program:registered:browse')&&(scope.row.createBy === createName||haveProjectIds.includes(scope.row.id))&&scope.row.issuedStatus === '5'&&scope.row.archiveStatus === '0'" type="text" size="small" @click="browse(scope.row.id)">装订自校</el-button>

              <!-- 项目归档-->
              <el-button v-if="hasPermission('program:registered:edit')&&(scope.row.createBy === createName||haveProjectIds.includes(scope.row.id))&&scope.row.issuedStatus === '5' &&(scope.row.archiveStatus === '0'||scope.row.archiveStatus === '1'||scope.row.archiveStatus === '3')" type="text" size="small" @click="archivePush(scope.row)">项目归档</el-button>
              <!-- 项目归档撤回-->
              <el-button v-if="hasPermission('program:registered:edit')&&(scope.row.createBy === createName||haveProjectIds.includes(scope.row.id))&&scope.row.archiveStatus === '2'" type="text" size="small" @click="archiveReback(scope.row)">项目归档撤回</el-button>
              <!-- 项目归档  审核-->
              <el-button v-if="scope.row.archiveStatus==='2' && checkIsAuditArchive(scope.row)" type="text"  size="small" @click="examineArchive(scope.row)">归档审核</el-button>
              <!-- 项目归档  被驳回后当前申请人重新调整-->
              <el-button v-if="hasPermission('program:registered:edit')&&(scope.row.createBy === createName||haveProjectIds.includes(scope.row.id))&&scope.row.archiveStatus === '4'" type="text"  size="small" @click="adjustArchive(scope.row)">驳回调整</el-button>

              <!--一级校审ftl文件下载-->
<!--              <el-button v-if="hasPermission('program:registered:edit')" type="text"  icon="el-icon-circle-check" size="small" @click="downloadFirstAuditTpl(scope.row)">一级校审下载</el-button>-->
<!--              <el-button v-if="hasPermission('program:registered:edit')" type="text"  icon="el-icon-circle-check" size="small" @click="downloadSecondAuditTpl(scope.row)">二级校审下载</el-button>-->
<!--              <el-button v-if="hasPermission('program:registered:edit')" type="text"  icon="el-icon-circle-check" size="small" @click="downloadThirdlyAuditTpl(scope.row)">三级校审下载</el-button>-->

              <!--自校功能ftl文件下载-->
<!--              <el-button v-if="hasPermission('program:registered:edit')" type="text"  icon="el-icon-circle-check" size="small" @click="downloadProofreadAuditTpl(scope.row)">校对审核</el-button>-->
<!--              <el-button v-if="hasPermission('program:registered:edit')" type="text"  icon="el-icon-circle-check" size="small" @click="downloadAuditRecordFormAfterBindingTpl(scope.row)">评估报告装订后</el-button>-->

              <!--报告签发单-->
<!--              <el-button v-if="hasPermission('program:registered:edit')" type="text"  icon="el-icon-circle-check" size="small" @click="downloadReportAusstellungTpl(scope.row)">报告签发单</el-button>-->

            </template>
          </vxe-column>
        </vxe-table>
        <vxe-pager
          background
          size="small"
          :current-page="tablePage.currentPage"
          :page-size="tablePage.pageSize"
          :total="tablePage.total"
          :page-sizes="[10, 20, 100, 1000, {label: '全量数据', value: 1000000}]"
          :layouts="['PrevPage', 'JumpNumber', 'NextPage', 'FullJump', 'Sizes', 'Total']"
          @page-change="currentChangeHandle">
        </vxe-pager>
      </div>
    </div>
    <ProjectForm  ref="projectForm" @refreshDataList="refreshList"></ProjectForm>
    <ProjectFormUpdate ref="projectFormUpdate" @refreshDataList="refreshList"></ProjectFormUpdate>
    <ProofreadForm  ref="proofreadForm" @refreshDataList="refreshList"></ProofreadForm>
    <ProofreadBrowseForm  ref="proofreadBrowseForm" @refreshDataList="refreshList"></ProofreadBrowseForm>
    <WorkContractForm2 ref="workContractForm2" @refreshDataList="refreshList"></WorkContractForm2>
  </div>
</template>

<script>
  import ProgramProjectListInfoService from '@/api/program/ProgramProjectListInfoService'
  import ProjectForm from './ProjectForm'
  import ProjectFormUpdate from './ProjectFormUpdate'
  import ProofreadForm from './ProofreadForm'
  import ProofreadBrowseForm from './ProofreadBrowseForm'
  import WorkContractForm2 from '../../sys/workContract/WorkContractForm2'
  import SelectUserTree from '@/views/modules/utils/treeUserSelect'
  import pick from 'lodash.pick'
  import TaskService from '@/api/flowable/TaskService'
  import ProcessService from '@/api/flowable/ProcessService'
  import UserService from '@/api/sys/UserService'
  import ProofreadIssuedService from '@/api/sys/ProofreadIssuedService'
  import UserSelect from '@/components/userSelect'

  export default {
    data () {
      return {
        applyUserName: '',
        showHideItem: false,
        showHideIcon: 'el-icon-arrow-down',
        showHideName: '展示',
        searchForm: {
          name: '',
          no: '',
          createBy: '',
          projectManager: '',
          contractName: '',
          clientName: '',
          createDates: [],
          status: ''
        },
        dataList: [],
        tablePage: {
          total: 0,
          currentPage: 1,
          pageSize: 10,
          orders: []
        },
        createName: '',
        loading: false,
        processDefinitionAuditId: '',
        procDefAuditKey: '',
        isAdmin: false,
        processDefinitionId1: '',
        procDefKey1: '',
        processDefinitionId2: '',
        procDefKey2: '',
        processDefinitionId3: '',
        procDefKey3: '',
        processDefinitionIdArchive: '',
        procDefKeyArchive: '',
        processDefinitionId4: '',
        procDefKey4: '',
        haveProjectIds: ''
      }
    },
    programProjectListInfoService: null,
    taskService: null,
    processService: null,
    userService: null,
    proofreadIssuedService: null,
    created () {
      this.programProjectListInfoService = new ProgramProjectListInfoService()
      this.taskService = new TaskService()
      this.processService = new ProcessService()
      this.userService = new UserService()
      this.proofreadIssuedService = new ProofreadIssuedService()
    },
    components: {
      ProjectForm,
      WorkContractForm2,
      SelectUserTree,
      ProofreadForm,
      ProofreadBrowseForm,
      ProjectFormUpdate,
      UserSelect
    },
    mounted () {
      this.refreshList()
    },
    activated () {
      this.is()
      this.refreshList()
    },
    computed: {
      userName () {
        return JSON.parse(localStorage.getItem('user')).name
      },
      user () {
        this.createName = JSON.parse(localStorage.getItem('user')).name
        return JSON.parse(localStorage.getItem('user'))
      }
    },
    methods: {
      showHide () {
        if (this.showHideItem === false) {
          this.showHideItem = true
          this.showHideIcon = 'el-icon-arrow-up'
          this.showHideName = '隐藏'
        } else {
          this.showHideItem = false
          this.showHideIcon = 'el-icon-arrow-down'
          this.showHideName = '展示'
        }
      },
      // 新增
      add () {
        this.$refs.projectForm.init('add', '')
      },
      // 修改
      edit (id) {
        id = id || this.$refs.typeDictTable.getCheckboxRecords().map(item => {
          return item.id
        })[0]
        this.$refs.projectFormUpdate.init('edit', id)
      },
      // 查看
      view (row) {
        this.$refs.projectForm.init('view', row.id, row.auditId1, row.auditId2, row.auditId3, row.archiveId)
      },
      // 获取数据列表
      refreshList () {
        this.loading = true
        this.createName = JSON.parse(localStorage.getItem('user')).name
        this.programProjectListInfoService.list({
          'current': this.tablePage.currentPage,
          'size': this.tablePage.pageSize,
          'orders': this.tablePage.orders,
          ...this.searchForm
        }).then(({data}) => {
          this.dataList = data.records
          this.tablePage.total = data.total
          this.loading = false
        })
        // 获取当前登录人的所属项目id集合
        this.programProjectListInfoService.getHaveProjectIds().then(({data}) => {
          if (this.commonJS.isNotEmpty(data)) {
            this.haveProjectIds = data.map(i => {
              if (this.commonJS.isNotEmpty(i)) {
                return i
              }
            }).join(',')
          }
        })
        this.processService.getByName('评估-项目登记').then(({data}) => {
          if (!this.commonJS.isEmpty(data.id)) {
            this.processDefinitionAuditId = data.id
            this.procDefAuditKey = data.key
          }
        })
        this.processService.getByName('评估-项目一级校审').then(({data}) => {
          if (!this.commonJS.isEmpty(data.id)) {
            this.processDefinitionId1 = data.id
            this.procDefKey1 = data.key
          }
        })
        this.processService.getByName('评估-项目二级校审').then(({data}) => {
          if (!this.commonJS.isEmpty(data.id)) {
            this.processDefinitionId2 = data.id
            this.procDefKey2 = data.key
          }
        })
        this.processService.getByName('评估-项目三级校审').then(({data}) => {
          if (!this.commonJS.isEmpty(data.id)) {
            this.processDefinitionId3 = data.id
            this.procDefKey3 = data.key
          }
        })
        this.processService.getByName('评估-项目归档').then(({data}) => {
          if (!this.commonJS.isEmpty(data.id)) {
            this.processDefinitionIdArchive = data.id
            this.procDefKeyArchive = data.key
          }
        })
        this.processService.getByName('评估-报告签发').then(({data}) => {
          if (!this.commonJS.isEmpty(data.id)) {
            this.processDefinitionId4 = data.id
            this.procDefKey4 = data.key
          }
        })
      },
      // 当前页
      currentChangeHandle ({ currentPage, pageSize }) {
        this.tablePage.currentPage = currentPage
        this.tablePage.pageSize = pageSize
        this.refreshList()
      },
      // 排序
      sortChangeHandle (column) {
        this.tablePage.orders = []
        if (column.order != null) {
          this.tablePage.orders.push({column: this.$utils.toLine(column.property), asc: column.order === 'asc'})
        }
        this.refreshList()
      },
      // 删除
      deleteAll (id) {
        let ids = id || this.$refs.typeDictTable.getCheckboxRecords().map(item => {
          return item.id
        }).join(',')
        this.$confirm(`确定删除所选项吗?`, '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          this.loading = true
          this.programProjectListInfoService.deleteAll(ids).then(({data}) => {
            this.$message.success(data)
            this.refreshList()
            this.loading = false
          })
        })
      },
      // 删除
      del (id) {
        let ids = id || this.$refs.typeDictTable.getCheckboxRecords().map(item => {
          return item.id
        }).join(',')
        this.$confirm(`确定删除所选项吗?`, '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          this.loading = true
          this.programProjectListInfoService.delete(ids).then(({data}) => {
            this.$message.success(data)
            this.refreshList()
            this.loading = false
          })
        })
      },
      resetSearch () {
        this.applyUserName = ''
        this.$refs.searchForm.resetFields()
        this.refreshList()
      },
      viewContract (id) {
        this.$refs.workContractForm2.init('view', id)
      },
      start () {
        // 读取流程表单
        let tabTitle = `发起流程【评估-项目登记】`
        let processTitle = `${this.userName} 在 ${this.moment(new Date()).format('YYYY-MM-DD HH:mm')} 发起了 [评估-项目登记]`
        this.taskService.getTaskDef({ procDefId: this.processDefinitionAuditId,
          status: 'startAndHold'}).then((data) => {
            this.$router.push({
              path: '/flowable/task/TaskForm',
              query: {
                ...pick(data.data, 'formType', 'formUrl', 'procDefKey', 'taskDefKey', 'procInsId', 'procDefId', 'taskId', 'status', 'title'),
                procDefId: this.processDefinitionAuditId,
                procDefKey: this.procDefAuditKey,
                status: 'startAndHold',
                title: tabTitle,
                formType: data.data.formType,
                formUrl: data.data.formUrl,
                formTitle: processTitle,
                businessId: 'false',
                isShow: false,
                routePath: '/program/registered/ProjectList'
              }
            })
          })
      },
      // 发起项目登记审批
      registeredPush (row) {
        // 读取流程表单
        let title = `发起流程【项目登记审批】`
        let processTitle = `${this.userName} 在 ${this.moment(new Date()).format('YYYY-MM-DD HH:mm')} 发起了[项目登记审批]`
        let status = 'startAndHold'
        if (row.status === '3') {
          status = 'startAndClose'
        } else if (row.status === '4') {
          status = 'reapplyFlag'
        }
        this.taskService.getTaskDef({ procDefId: this.processDefinitionAuditId,
          businessId: row.id,
          businessTable: 'program_project_list_info'}).then((data) => {
            this.$router.push({
              path: '/flowable/task/TaskForm',
              query: {
                ...pick(data.data, 'formType', 'formUrl', 'procDefKey', 'taskDefKey', 'procInsId', 'procDefId', 'taskId', 'status', 'title'),
                procDefId: this.processDefinitionAuditId,
                procDefKey: this.procDefAuditKey,
                title: title,
                formType: data.data.formType,
                formUrl: data.data.formUrl,
                formTitle: processTitle,
                businessTable: 'program_project_list_info',
                businessId: row.id,
                isShow: 'false',
                status: status,
                routePath: '/program/registered/ProjectList'
              }
            })
          })
      },
      // 查看项目登记审批流程结果
      registeredDetail (row) {
        if (row.status !== '0' && row.status !== '1') {
          // eslint-disable-next-line eqeqeq
          this.taskService.getTaskDef({
            procInsId: row.procInsId,
            procDefId: this.processDefinitionAuditId
          }).then(({data}) => {
            this.$router.push({
              path: '/flowable/task/TaskFormDetail',
              query: {
                ...pick(data, 'formType', 'formUrl', 'procDefKey', 'taskDefKey', 'procInsId', 'procDefId', 'taskId', 'status', 'title'),
                isShow: 'false',
                readOnly: true,
                title: '项目登记' + '流程详情',
                formTitle: '项目登记' + '流程详情',
                businessId: row.id,
                status: 'reback'
              }
            })
          })
        }
      },
      // 撤回项目登记审批
      registeredReback (row) {
        this.$confirm(`确定要撤回该申请吗?`, '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(async () => {
          await this.programProjectListInfoService.queryById(row.id).then(({data}) => {
            if (data.status !== '2') { // status的值不等于“审核中”，就弹出提示
              this.$message.error('数据已发生改变或不存在，请刷新数据')
              this.refreshList()
            } else {
              this.processService.revokeProcIns(row.procInsId).then(({data}) => {
                let form = {status: '3', id: row.id}
                this.programProjectListInfoService.updateStatusById(form)
                this.$message.success(data)
                this.refreshList()
              })
            }
          })
        })
      },
      // 发起一级校审
      firstAuditPush (row) {
        // 读取流程表单
        let title = `发起流程【评估-项目一级校审】`
        let processTitle = `${this.userName} 在 ${this.moment(new Date()).format('YYYY-MM-DD HH:mm')} 发起了[评估-项目一级校审]`
        let status = 'startAndHold'
        if (row.status1 === '3') {
          status = 'startAndClose'
        } else if (row.status1 === '4') {
          status = 'reapplyFlag'
        }
        this.taskService.getTaskDef({ procDefId: this.processDefinitionId1,
          businessId: row.auditId1,
          businessTable: 'program_audit'}).then((data) => {
            this.$router.push({
              path: '/flowable/task/TaskForm',
              query: {
                ...pick(data.data, 'formType', 'formUrl', 'procDefKey', 'taskDefKey', 'procInsId', 'procDefId', 'taskId', 'status', 'title'),
                procDefId: this.processDefinitionId1,
                procDefKey: this.procDefKey1,
                title: title,
                formType: data.data.formType,
                formUrl: data.data.formUrl,
                formTitle: processTitle,
                businessTable: 'program_audit',
                businessId: row.auditId1,
                isShow: 'false',
                status: status,
                routePath: '/program/registered/ProjectList'
              }
            })
          })
      },
      // 查看一级校审审批流程结果
      firstAuditDetail (row) {
        if (row.status1 !== '0' && row.status1 !== '1') {
          // eslint-disable-next-line eqeqeq
          this.taskService.getTaskDef({
            procInsId: row.procInsId1,
            procDefId: this.processDefinitionId1
          }).then(({data}) => {
            this.$router.push({
              path: '/flowable/task/TaskFormDetail',
              query: {
                ...pick(data, 'formType', 'formUrl', 'procDefKey', 'taskDefKey', 'procInsId', 'procDefId', 'taskId', 'status', 'title'),
                isShow: 'false',
                readOnly: true,
                title: '一级校审' + '流程详情',
                formTitle: '一级校审' + '流程详情',
                businessId: row.auditId1,
                status: 'reback'
              }
            })
          })
        }
      },
      // 撤回一级校审
      firstAuditReback (row) {
        this.$confirm(`确定要撤回该申请吗?`, '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(async () => {
          await this.programProjectListInfoService.findByIdAudit(row.auditId1).then(({data}) => {
            if (data.status !== '2') { // status的值不等于“审核中”，就弹出提示
              this.$message.error('数据已发生改变或不存在，请刷新数据')
              this.refreshList()
            } else {
              this.processService.revokeProcIns(row.procInsId1).then(({data}) => {
                let form = {status: '3', id: row.auditId1}
                this.programProjectListInfoService.updateStatusByAuditId(form)
                this.$message.success(data)
                this.refreshList()
              })
            }
          })
        })
      },
      // 发起二级校审
      secondAuditPush (row) {
        // 读取流程表单
        let title = `发起流程【评估-项目二级校审】`
        let processTitle = `${this.userName} 在 ${this.moment(new Date()).format('YYYY-MM-DD HH:mm')} 发起了[评估-项目二级校审]`
        let status = 'startAndHold'
        if (row.status2 === '3') {
          status = 'startAndClose'
        } else if (row.status2 === '4') {
          status = 'reapplyFlag'
        }
        this.taskService.getTaskDef({ procDefId: this.processDefinitionId2,
          businessId: row.auditId2,
          businessTable: 'program_audit'}).then((data) => {
            this.$router.push({
              path: '/flowable/task/TaskForm',
              query: {
                ...pick(data.data, 'formType', 'formUrl', 'procDefKey', 'taskDefKey', 'procInsId', 'procDefId', 'taskId', 'status', 'title'),
                procDefId: this.processDefinitionId2,
                procDefKey: this.procDefKey2,
                title: title,
                formType: data.data.formType,
                formUrl: data.data.formUrl,
                formTitle: processTitle,
                businessTable: 'program_audit',
                businessId: row.auditId2,
                isShow: 'false',
                status: status,
                routePath: '/program/registered/ProjectList'
              }
            })
          })
      },
      // 查看二级校审审批流程结果
      secondAuditDetail (row) {
        if (row.status2 !== '0' && row.status2 !== '1') {
          // eslint-disable-next-line eqeqeq
          this.taskService.getTaskDef({
            procInsId: row.procInsId2,
            procDefId: this.processDefinitionId2
          }).then(({data}) => {
            this.$router.push({
              path: '/flowable/task/TaskFormDetail',
              query: {
                ...pick(data, 'formType', 'formUrl', 'procDefKey', 'taskDefKey', 'procInsId', 'procDefId', 'taskId', 'status', 'title'),
                isShow: 'false',
                readOnly: true,
                title: '二级校审' + '流程详情',
                formTitle: '二级校审' + '流程详情',
                businessId: row.auditId2,
                status: 'reback'
              }
            })
          })
        }
      },
      // 撤回二级校审
      secondAuditReback (row) {
        this.$confirm(`确定要撤回该申请吗?`, '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(async () => {
          await this.programProjectListInfoService.findByIdAudit(row.auditId2).then(({data}) => {
            if (data.status !== '2') { // status的值不等于“审核中”，就弹出提示
              this.$message.error('数据已发生改变或不存在，请刷新数据')
              this.refreshList()
            } else {
              this.processService.revokeProcIns(row.procInsId2).then(({data}) => {
                let form = {status: '3', id: row.auditId2}
                this.programProjectListInfoService.updateStatusByAuditId(form)
                this.$message.success(data)
                this.refreshList()
              })
            }
          })
        })
      },
      // 发起三级校审
      thirdAuditPush (row) {
        // 读取流程表单
        let title = `发起流程【评估-项目三级校审】`
        let processTitle = `${this.userName} 在 ${this.moment(new Date()).format('YYYY-MM-DD HH:mm')} 发起了[评估-项目三级校审]`
        let status = 'startAndHold'
        if (row.status3 === '3') {
          status = 'startAndClose'
        } else if (row.status3 === '4') {
          status = 'reapplyFlag'
        }
        this.taskService.getTaskDef({ procDefId: this.processDefinitionId3,
          businessId: row.auditId3,
          businessTable: 'program_audit'}).then((data) => {
            this.$router.push({
              path: '/flowable/task/TaskForm',
              query: {
                ...pick(data.data, 'formType', 'formUrl', 'procDefKey', 'taskDefKey', 'procInsId', 'procDefId', 'taskId', 'status', 'title'),
                procDefId: this.processDefinitionId3,
                procDefKey: this.procDefKey3,
                title: title,
                formType: data.data.formType,
                formUrl: data.data.formUrl,
                formTitle: processTitle,
                businessTable: 'program_audit',
                businessId: row.auditId3,
                isShow: 'false',
                status: status,
                routePath: '/program/registered/ProjectList'
              }
            })
          })
      },
      // 查看三级校审审批流程结果
      thirdAuditDetail (row) {
        if (row.status3 !== '0' && row.status3 !== '1') {
          // eslint-disable-next-line eqeqeq
          this.taskService.getTaskDef({
            procInsId: row.procInsId3,
            procDefId: this.processDefinitionId3
          }).then(({data}) => {
            this.$router.push({
              path: '/flowable/task/TaskFormDetail',
              query: {
                ...pick(data, 'formType', 'formUrl', 'procDefKey', 'taskDefKey', 'procInsId', 'procDefId', 'taskId', 'status', 'title'),
                isShow: 'false',
                readOnly: true,
                title: '三级校审' + '流程详情',
                formTitle: '三级校审' + '流程详情',
                businessId: row.auditId3,
                status: 'reback'
              }
            })
          })
        }
      },
      // 撤回三级校审
      thirdAuditReback (row) {
        this.$confirm(`确定要撤回该申请吗?`, '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(async () => {
          await this.programProjectListInfoService.findByIdAudit(row.auditId3).then(({data}) => {
            if (data.status !== '2') { // status的值不等于“审核中”，就弹出提示
              this.$message.error('数据已发生改变或不存在，请刷新数据')
              this.refreshList()
            } else {
              this.processService.revokeProcIns(row.procInsId3).then(({data}) => {
                let form = {status: '3', id: row.auditId3}
                this.programProjectListInfoService.updateStatusByAuditId(form)
                this.$message.success(data)
                this.refreshList()
              })
            }
          })
        })
      },
      // 发起项目登记归档
      archivePush (row) {
        // 读取流程表单
        let title = `发起流程【评估-项目归档】`
        let processTitle = `${this.userName} 在 ${this.moment(new Date()).format('YYYY-MM-DD HH:mm')} 发起了[评估-项目归档]`
        let status = 'startAndHold'
        if (row.archiveStatus === '3') {
          status = 'startAndClose'
        } else if (row.archiveStatus === '4') {
          status = 'reapplyFlag'
        }
        this.taskService.getTaskDef({ procDefId: this.processDefinitionIdArchive,
          businessId: row.archiveId,
          businessTable: 'program_archive'}).then((data) => {
            this.$router.push({
              path: '/flowable/task/TaskForm',
              query: {
                ...pick(data.data, 'formType', 'formUrl', 'procDefKey', 'taskDefKey', 'procInsId', 'procDefId', 'taskId', 'status', 'title'),
                procDefId: this.processDefinitionIdArchive,
                procDefKey: this.procDefKeyArchive,
                title: title,
                formType: data.data.formType,
                formUrl: data.data.formUrl,
                formTitle: processTitle,
                businessTable: 'program_archive',
                businessId: row.archiveId,
                isShow: 'false',
                status: status,
                routePath: '/program/registered/ProjectList'
              }
            })
          })
      },
      // 查看项目归档审批流程结果
      archiveDetail (row) {
        if (row.archiveStatus !== '0' && row.archiveStatus !== '1') {
          // eslint-disable-next-line eqeqeq
          this.taskService.getTaskDef({
            procInsId: row.procInsIdArchive,
            procDefId: this.processDefinitionIdArchive
          }).then(({data}) => {
            this.$router.push({
              path: '/flowable/task/TaskFormDetail',
              query: {
                ...pick(data, 'formType', 'formUrl', 'procDefKey', 'taskDefKey', 'procInsId', 'procDefId', 'taskId', 'status', 'title'),
                isShow: 'false',
                readOnly: true,
                title: '评估-项目归档' + '流程详情',
                formTitle: '评估-项目归档' + '流程详情',
                businessId: row.archiveId,
                status: 'reback'
              }
            })
          })
        }
      },
      // 撤回三级校审
      archiveReback (row) {
        this.$confirm(`确定要撤回该申请吗?`, '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(async () => {
          await this.programProjectListInfoService.findByIdArchive(row.archiveId).then(({data}) => {
            if (data.status !== '2') { // status的值不等于“审核中”，就弹出提示
              this.$message.error('数据已发生改变或不存在，请刷新数据')
              this.refreshList()
            } else {
              this.processService.revokeProcIns(row.procInsIdArchive).then(({data}) => {
                let form = {status: '3', id: row.archiveId}
                this.programProjectListInfoService.updateStatusByArchiveId(form)
                this.$message.success(data)
                this.refreshList()
              })
            }
          })
        })
      },
      // 下载一级校审
      downloadFirstAuditTpl (row) {
        // this.$utils.downloadExcel('/sys/project/import/template')
        this.loading = true
        this.programProjectListInfoService.downloadFirstAuditTpl(row.id, row.auditId1).then((res) => {
          // 将二进制流文件写入excel表，以下为重要步骤
          this.$utils.downloadWord(res.data, '一级校审')
          this.loading = false
        }).catch(function (err) {
          this.loading = false
          if (err.response) {
            console.log(err.response)
          }
        })
      },
      // 下载二级校审
      downloadSecondAuditTpl (row) {
        // this.$utils.downloadExcel('/sys/project/import/template')
        this.loading = true
        this.programProjectListInfoService.downloadSecondAuditTpl(row.id, row.auditId2).then((res) => {
          // 将二进制流文件写入excel表，以下为重要步骤
          this.$utils.downloadWord(res.data, '二级校审')
          this.loading = false
        }).catch(function (err) {
          this.loading = false
          if (err.response) {
            console.log(err.response)
          }
        })
      },
      // 下载三级校审
      downloadThirdlyAuditTpl (row) {
        // this.$utils.downloadExcel('/sys/project/import/template')
        this.loading = true
        this.programProjectListInfoService.downloadThirdlyAuditTpl(row.id, row.auditId3).then((res) => {
          // 将二进制流文件写入excel表，以下为重要步骤
          this.$utils.downloadWord(res.data, '三级校审')
          this.loading = false
        }).catch(function (err) {
          this.loading = false
          if (err.response) {
            console.log(err.response)
          }
        })
      },
      // 下载资产评估项目（校对）审核记录表
      downloadProofreadAuditTpl (row) {
      // this.$utils.downloadExcel('/sys/project/import/template')
        this.loading = true
        this.programProjectListInfoService.downloadProofreadAuditTpl(row.id).then((res) => {
          // 将二进制流文件写入excel表，以下为重要步骤
          this.$utils.downloadExcel(res.data, '资产评估项目（校对）审核记录表.xls')
          this.loading = false
        }).catch(function (err) {
          this.loading = false
          if (err.response) {
            console.log(err.response)
          }
        })
      },
      // 下载评估报告装订后浏览审核记录表
      downloadAuditRecordFormAfterBindingTpl (row) {
        // this.$utils.downloadExcel('/sys/project/import/template')
        this.loading = true
        this.programProjectListInfoService.downloadAuditRecordFormAfterBindingTpl(row.id).then((res) => {
          // 将二进制流文件写入excel表，以下为重要步骤
          this.$utils.downloadExcel(res.data, '评估报告装订后浏览审核记录表.xls')
          this.loading = false
        }).catch(function (err) {
          this.loading = false
          if (err.response) {
            console.log(err.response)
          }
        })
      },
      // 下载报告签发单
      downloadReportAusstellungTpl (row) {
        // this.$utils.downloadExcel('/sys/project/import/template')
        this.loading = true
        this.programProjectListInfoService.downloadReportAusstellungTpl(row.id).then((res) => {
          // 将二进制流文件写入excel表，以下为重要步骤
          this.$utils.downloadWord(res.data, '报告签发单')
          this.loading = false
        }).catch(function (err) {
          this.loading = false
          if (err.response) {
            console.log(err.response)
          }
        })
      },
      is () {
        this.userService.is().then(({data}) => {
          this.isAdmin = data
        })
      },
      saveReportNo (id) {
        this.$confirm(`确定生成项目报告号吗?`, '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          this.loading = true
          this.programProjectListInfoService.saveReportNo(id).then((data) => {
            this.$message.success(data.data)
            this.refreshList()
            this.loading = false
          }).catch((e) => {
            this.loading = false
          })
        })
      },
      // 校对
      proofread (id) {
        this.$refs.proofreadForm.init(id)
      },
      // 浏览审核
      browse (id) {
        this.$refs.proofreadBrowseForm.init(id)
      },
      // 签发
      issued (row) {
        // 读取流程表单
        let title = `发起流程【评估-报告签发】`
        let processTitle = `${this.userName} 在 ${this.moment(new Date()).format('YYYY-MM-DD HH:mm')} 发起了[评估-报告签发]`
        let status = 'startAndHold'
        if (row.issuedStatus === '3' || row.issuedStatus === '2') {
          status = 'startAndClose'
        } else if (row.issuedStatus === '4') {
          status = 'reapplyFlag'
        }
        this.taskService.getTaskDef({ procDefId: this.processDefinitionId4,
          businessId: row.id,
          businessTable: 'proofread_issued'}).then((data) => {
            this.$router.push({
              path: '/flowable/task/TaskForm',
              query: {
                ...pick(data.data, 'formType', 'formUrl', 'procDefKey', 'taskDefKey', 'procInsId', 'procDefId', 'taskId', 'status', 'title'),
                procDefId: this.processDefinitionId4,
                procDefKey: this.procDefKey4,
                title: title,
                formType: data.data.formType,
                formUrl: data.data.formUrl,
                formTitle: processTitle,
                businessTable: 'proofread_issued',
                businessId: row.id,
                isShow: 'false',
                status: status,
                routePath: '/program/registered/ProjectList'
              }
            })
          })
      },
      // 签发单详情
      issuedDetail (row) {
        if (row.issuedStatus !== undefined && row.issuedStatus !== '1') {
          // eslint-disable-next-line eqeqeq
          this.taskService.getTaskDef({
            procInsId: row.procInsId4,
            procDefId: this.processDefinitionId4
          }).then(({data}) => {
            this.$router.push({
              path: '/flowable/task/TaskFormDetail',
              query: {
                ...pick(data, 'formType', 'formUrl', 'procDefKey', 'taskDefKey', 'procInsId', 'procDefId', 'taskId', 'status', 'title'),
                isShow: 'false',
                readOnly: true,
                title: '报告签发单' + '流程详情',
                formTitle: '报告签发单' + '流程详情',
                businessId: row.id,
                status: 'reback'
              }
            })
          })
        }
      },
      // 签发撤回
      issuedReback (row) {
        this.$confirm(`确定要撤回该申请吗?`, '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(async () => {
          await this.proofreadIssuedService.findById(row.id).then(({data}) => {
            if (data.status !== '2') { // status的值不等于“审核中”，就弹出提示
              this.$message.error('数据已发生改变或不存在，请刷新数据')
              this.refreshList()
            } else {
              this.processService.revokeProcIns(row.procInsId4).then(({data}) => {
                let form = {status: '3', id: row.id}
                this.proofreadIssuedService.updateStatus(form)
                this.$message.success(data)
                this.refreshList()
              })
            }
          })
        })
      },
      // 驳回后调整
      adjust (row) {
        this.programProjectListInfoService.queryById(row.id).then(({data}) => {
          if (data.status !== '4') { // status的值不等于“驳回”，就弹出提示
            this.$message.error('数据已发生改变或不存在，请刷新数据')
            this.refreshList()
          } else {
            this.todo(row)
          }
        })
      },
      // 审核
      examine (row) {
        this.programProjectListInfoService.queryById(row.id).then(({data}) => {
          if (data.status !== '2') { // status的值不等于“审核中”，就弹出提示
            this.$message.error('数据已发生改变或不存在，请刷新数据')
            this.refreshList()
          } else {
            this.todo(row)
          }
        })
      },
      // 审核或重新调整跳转
      todo (row) {
        let cUser = false
        this.taskService.getTaskDefInfo({
          taskId: row.taskId
        }).then(({data}) => {
          this.$router.push({
            path: '/flowable/task/TaskForm',
            query: {
              ...pick(data, 'formType', 'formUrl', 'procDefKey', 'taskDefKey', 'procInsId', 'procDefId', 'taskId', 'status', 'title', 'businessId'),
              isShow: false,
              formReadOnly: true,
              formTitle: `${data.taskName}`,
              cUser: cUser,
              title: `审批【${data.taskName || ''}】`,
              routePath: '/program/registered/ProjectList'   // 数据处理后需要跳转的页面路径
            }
          })
        })
      },
      // 查询当前登录人是否是数据的审核人
      checkIsAudit (row) {
        let loginUserId = this.$store.state.user.id  // 获取当前登录用户id
        if (this.commonJS.isNotEmpty(row.auditUserIds)) {
          for (const userId of row.auditUserIds) {
            if (userId === loginUserId) {  // 当数据的审核人中包含当前登录人id时，返回true
              return true
            }
          }
        }
        return false
      },
      // 驳回后调整  一级校审
      adjustFirst (row) {
        this.programProjectListInfoService.findByIdAudit(row.auditId1).then(({data}) => {
          if (data.status !== '4') { // status的值不等于“驳回”，就弹出提示
            this.$message.error('数据已发生改变或不存在，请刷新数据')
            this.refreshList()
          } else {
            this.todoFirst(row)
          }
        })
      },
      // 审核  一级校审
      examineFirst (row) {
        this.programProjectListInfoService.findByIdAudit(row.auditId1).then(({data}) => {
          if (data.status !== '2') { // status的值不等于“审核中”，就弹出提示
            this.$message.error('数据已发生改变或不存在，请刷新数据')
            this.refreshList()
          } else {
            this.todoFirst(row)
          }
        })
      },
      // 审核或重新调整跳转  一级校审
      todoFirst (row) {
        let cUser = false
        this.taskService.getTaskDefInfo({
          taskId: row.taskIdAudit1
        }).then(({data}) => {
          this.$router.push({
            path: '/flowable/task/TaskForm',
            query: {
              ...pick(data, 'formType', 'formUrl', 'procDefKey', 'taskDefKey', 'procInsId', 'procDefId', 'taskId', 'status', 'title', 'businessId'),
              isShow: false,
              formReadOnly: true,
              formTitle: `${data.taskName}`,
              cUser: cUser,
              title: `审批【${data.taskName || ''}】`,
              routePath: '/program/registered/ProjectList'   // 数据处理后需要跳转的页面路径
            }
          })
        })
      },
      // 查询当前登录人是否是数据的审核人  一级校审
      checkIsAuditFirst (row) {
        let loginUserId = this.$store.state.user.id  // 获取当前登录用户id
        if (this.commonJS.isNotEmpty(row.auditUserIds1)) {
          for (const userId of row.auditUserIds1) {
            if (userId === loginUserId) {  // 当数据的审核人中包含当前登录人id时，返回true
              return true
            }
          }
        }
        return false
      },
      // 驳回后调整  二级校审
      adjustSecond (row) {
        this.programProjectListInfoService.findByIdAudit(row.auditId2).then(({data}) => {
          if (data.status !== '4') { // status的值不等于“驳回”，就弹出提示
            this.$message.error('数据已发生改变或不存在，请刷新数据')
            this.refreshList()
          } else {
            this.todoSecond(row)
          }
        })
      },
      // 审核  二级校审
      examineSecond (row) {
        this.programProjectListInfoService.findByIdAudit(row.auditId2).then(({data}) => {
          if (data.status !== '2') { // status的值不等于“审核中”，就弹出提示
            this.$message.error('数据已发生改变或不存在，请刷新数据')
            this.refreshList()
          } else {
            this.todoSecond(row)
          }
        })
      },
      // 审核或重新调整跳转  二级校审
      todoSecond (row) {
        let cUser = false
        this.taskService.getTaskDefInfo({
          taskId: row.taskIdAudit2
        }).then(({data}) => {
          this.$router.push({
            path: '/flowable/task/TaskForm',
            query: {
              ...pick(data, 'formType', 'formUrl', 'procDefKey', 'taskDefKey', 'procInsId', 'procDefId', 'taskId', 'status', 'title', 'businessId'),
              isShow: false,
              formReadOnly: true,
              formTitle: `${data.taskName}`,
              cUser: cUser,
              title: `审批【${data.taskName || ''}】`,
              routePath: '/program/registered/ProjectList'   // 数据处理后需要跳转的页面路径
            }
          })
        })
      },
      // 查询当前登录人是否是数据的审核人  二级校审
      checkIsAuditSecond (row) {
        let loginUserId = this.$store.state.user.id  // 获取当前登录用户id
        if (this.commonJS.isNotEmpty(row.auditUserIds2)) {
          for (const userId of row.auditUserIds2) {
            if (userId === loginUserId) {  // 当数据的审核人中包含当前登录人id时，返回true
              return true
            }
          }
        }
        return false
      },
      // 驳回后调整  三级校审
      adjustThird (row) {
        this.programProjectListInfoService.findByIdAudit(row.auditId3).then(({data}) => {
          if (data.status !== '4') { // status的值不等于“驳回”，就弹出提示
            this.$message.error('数据已发生改变或不存在，请刷新数据')
            this.refreshList()
          } else {
            this.todoThird(row)
          }
        })
      },
      // 审核  三级校审
      examineThird (row) {
        this.programProjectListInfoService.findByIdAudit(row.auditId3).then(({data}) => {
          if (data.status !== '2') { // status的值不等于“审核中”，就弹出提示
            this.$message.error('数据已发生改变或不存在，请刷新数据')
            this.refreshList()
          } else {
            this.todoThird(row)
          }
        })
      },
      // 审核或重新调整跳转  三级校审
      todoThird (row) {
        let cUser = false
        this.taskService.getTaskDefInfo({
          taskId: row.taskIdAudit3
        }).then(({data}) => {
          this.$router.push({
            path: '/flowable/task/TaskForm',
            query: {
              ...pick(data, 'formType', 'formUrl', 'procDefKey', 'taskDefKey', 'procInsId', 'procDefId', 'taskId', 'status', 'title', 'businessId'),
              isShow: false,
              formReadOnly: true,
              formTitle: `${data.taskName}`,
              cUser: cUser,
              title: `审批【${data.taskName || ''}】`,
              routePath: '/program/registered/ProjectList'   // 数据处理后需要跳转的页面路径
            }
          })
        })
      },
      // 查询当前登录人是否是数据的审核人  三级校审
      checkIsAuditThird (row) {
        let loginUserId = this.$store.state.user.id  // 获取当前登录用户id
        if (this.commonJS.isNotEmpty(row.auditUserIds3)) {
          for (const userId of row.auditUserIds3) {
            if (userId === loginUserId) {  // 当数据的审核人中包含当前登录人id时，返回true
              return true
            }
          }
        }
        return false
      },
      // 驳回后调整  签发
      adjustIssued (row) {
        this.proofreadIssuedService.findById(row.id).then(({data}) => {
          if (data.status !== '4') { // status的值不等于“驳回”，就弹出提示
            this.$message.error('数据已发生改变或不存在，请刷新数据')
            this.refreshList()
          } else {
            this.todoIssued(row)
          }
        })
      },
      // 审核  签发
      examineIssued (row) {
        this.proofreadIssuedService.findById(row.id).then(({data}) => {
          if (data.status !== '2') { // status的值不等于“审核中”，就弹出提示
            this.$message.error('数据已发生改变或不存在，请刷新数据')
            this.refreshList()
          } else {
            this.todoIssued(row)
          }
        })
      },
      // 审核或重新调整跳转  签发
      todoIssued (row) {
        let cUser = false
        this.taskService.getTaskDefInfo({
          taskId: row.taskIdIssued
        }).then(({data}) => {
          this.$router.push({
            path: '/flowable/task/TaskForm',
            query: {
              ...pick(data, 'formType', 'formUrl', 'procDefKey', 'taskDefKey', 'procInsId', 'procDefId', 'taskId', 'status', 'title', 'businessId'),
              isShow: false,
              formReadOnly: true,
              formTitle: `${data.taskName}`,
              cUser: cUser,
              title: `审批【${data.taskName || ''}】`,
              routePath: '/program/registered/ProjectList'   // 数据处理后需要跳转的页面路径
            }
          })
        })
      },
      // 查询当前登录人是否是数据的审核人  签发
      checkIsAuditIssued (row) {
        let loginUserId = this.$store.state.user.id  // 获取当前登录用户id
        if (this.commonJS.isNotEmpty(row.auditUserIdsIssued)) {
          for (const userId of row.auditUserIdsIssued) {
            if (userId === loginUserId) {  // 当数据的审核人中包含当前登录人id时，返回true
              return true
            }
          }
        }
        return false
      },
      // 驳回后调整  归档
      adjustArchive (row) {
        this.programProjectListInfoService.findByIdArchive(row.archiveId).then(({data}) => {
          if (data.status !== '4') { // status的值不等于“驳回”，就弹出提示
            this.$message.error('数据已发生改变或不存在，请刷新数据')
            this.refreshList()
          } else {
            this.todoArchive(row)
          }
        })
      },
      // 审核  归档
      examineArchive (row) {
        this.programProjectListInfoService.findByIdArchive(row.archiveId).then(({data}) => {
          if (data.status !== '2') { // status的值不等于“审核中”，就弹出提示
            this.$message.error('数据已发生改变或不存在，请刷新数据')
            this.refreshList()
          } else {
            this.todoArchive(row)
          }
        })
      },
      // 审核或重新调整跳转  归档
      todoArchive (row) {
        let cUser = false
        this.taskService.getTaskDefInfo({
          taskId: row.taskIdArchive
        }).then(({data}) => {
          this.$router.push({
            path: '/flowable/task/TaskForm',
            query: {
              ...pick(data, 'formType', 'formUrl', 'procDefKey', 'taskDefKey', 'procInsId', 'procDefId', 'taskId', 'status', 'title', 'businessId'),
              isShow: false,
              formReadOnly: true,
              formTitle: `${data.taskName}`,
              cUser: cUser,
              title: `审批【${data.taskName || ''}】`,
              routePath: '/program/registered/ProjectList'   // 数据处理后需要跳转的页面路径
            }
          })
        })
      },
      // 查询当前登录人是否是数据的审核人  归档
      checkIsAuditArchive (row) {
        let loginUserId = this.$store.state.user.id  // 获取当前登录用户id
        if (this.commonJS.isNotEmpty(row.auditUserIdsArchive)) {
          for (const userId of row.auditUserIdsArchive) {
            if (userId === loginUserId) {  // 当数据的审核人中包含当前登录人id时，返回true
              return true
            }
          }
        }
        return false
      },
      // 自定义服务端导出
      exportMethod ({ options }) {
        // 传给服务端的参数
        const params = {
          'current': this.tablePage.currentPage,
          'size': this.tablePage.pageSize,
          'orders': this.tablePage.orders,
          ...this.searchForm,
          filename: options.filename,
          sheetName: options.sheetName,
          isHeader: options.isHeader,
          original: options.original,
          mode: options.mode,
          selectIds: options.mode === 'selected' ? options.data.map(item => item.id) : [],
          exportFields: options.columns.map(column => column.property)
        }
        return this.programProjectListInfoService.exportFile(params).then((res) => {
          // 将二进制流文件写入excel表，以下为重要步骤
          this.$utils.downloadExcel(res.data, options.filename)
        }).catch(function (err) {
          if (err.response) {
            console.log(err.response)
          }
        })
      }
    }
  }
</script>
