<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="projectNumber">
        <el-input size="small" v-model="searchForm.projectNumber" placeholder="请输入项目编号" clearable></el-input>
      </el-form-item>
      <el-form-item label="项目名称" prop="projectName">
        <el-input size="small" v-model="searchForm.projectName" placeholder="请输入项目名称" clearable></el-input>
      </el-form-item>
      <el-form-item label="项目经理" prop="projectMasterId">
        <SelectUserTree
          ref="companyTree"
          :props="{
                  value: 'id',             // ID字段名
                  label: 'name',         // 显示名称
                  children: 'children'    // 子级字段名
                }"
          :url="`/sys/user/treeUserDataAllOffice?type=2`"
          :value="searchForm.projectMasterId"
          :clearable="true"
          :accordion="true"
          @getValue="(value) => {searchForm.projectMasterId=value}"/>
<!--        <el-input size="small" v-model="searchForm.projectMasterName" placeholder="请输入项目经理" clearable></el-input>-->
      </el-form-item>
      <el-form-item label="创建人" prop="createBy">
        <SelectUserTree
          ref="companyTree"
          :props="{
                  value: 'id',             // ID字段名
                  label: 'name',         // 显示名称
                  children: 'children'    // 子级字段名
                }"
          :url="`/sys/user/treeUserDataAllOffice?type=2`"
          :value="searchForm.createBy"
          :clearable="true"
          :accordion="true"
          @getValue="(value) => {searchForm.createBy=value}"/>
      </el-form-item>
      <el-form-item label="报告文号" prop="reportNo">
        <el-input size="small" v-model="searchForm.reportNo" placeholder="请输入报告文号" clearable></el-input>
      </el-form-item>
      <el-form-item label="审计收费(元)" prop="contractAmounts">
        <InputNumber :disabled="false" :precision="num" v-model="searchForm.contractAmounts"></InputNumber>
      </el-form-item>
      <el-form-item label="创建时间" prop="contractDates">
        <el-date-picker
          placement="bottom-start"
          format="yyyy-MM-dd HH:mm:ss"
          value-format="yyyy-MM-dd HH:mm:ss"
          v-model="searchForm.contractDates"
          type="datetimerange"
          range-separator="至"
          start-placeholder="开始日期"
          end-placeholder="结束日期">
        </el-date-picker>
      </el-form-item>

      <el-form-item>
        <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 print custom>
        <template #buttons>
          <el-button v-if="hasPermission('cw_work_client:info:add')" type="primary" size="small" icon="el-icon-plus" @click="start()">新建</el-button>
          <!--          <el-button v-if="hasPermission('klg:question:del')" type="danger"   size="small" icon="el-icon-delete" @click="del()" :disabled="$refs.questionsTable && $refs.questionsTable.getCheckboxRecords().length === 0" plain>删除</el-button>-->
        </template>
      </vxe-toolbar>
      <div style="height: calc(100% - 90px)">
        <vxe-table
          border="inner"
          auto-resize
          resizable
          height="auto"
          :loading="loading"
          size="small"
          ref="clientTable"
          show-header-overflow
          show-overflow
          highlight-hover-row
          :print-config="{}"
          :export-config="{
                    remote: true,
                    filename: `报告信息${moment(new Date()).format('YYYY-MM-DD')}`,
                    sheetName: '报告信息',
                    exportMethod: exportMethod,
                    types: ['xlsx'],
                    modes: ['current', 'selected', 'all']
                  }"
          :menu-config="{}"
          @sort-change="sortChangeHandle"
          :sort-config="{remote:true}"
          :data="dataList"
          :checkbox-config="{}">
          <vxe-column type="seq" width="60" title="序号"></vxe-column>
          <vxe-column min-width="160" align="center" title="单据编号" field="documentNo">
            <template slot-scope="scope">
              <el-link  type="primary" :underline="false" v-if="hasPermission('cwProjectReport:list')" @click="view(scope.row.id)">{{scope.row.documentNo}}</el-link>
              <el-link  type="primary" :underline="false" v-else-if="hasPermission('cwProjectReport:list')"  @click="view(scope.row.id,)">{{scope.row.documentNo}}</el-link>
              <span v-else>{{scope.row.documentNo}}</span>
            </template>
          </vxe-column>
          <vxe-column min-width="160" align="center" title="项目编号" field="projectNumber"></vxe-column>
          <vxe-column min-width="160" align="center" title="项目名称" field="projectName"></vxe-column>
          <vxe-column min-width="160" align="center" title="报告文号" field="reportNo"></vxe-column>
          <vxe-column min-width="160" align="center" title="报告所属部门" field="departmentName"></vxe-column>
          <vxe-column min-width="160" align="center" title="项目经理" field="projectMasterName"></vxe-column>
<!--          <vxe-column min-width="160" align="center" title="报告主办人" field="reportSponsor"></vxe-column>-->
          <vxe-column min-width="160" align="center" title="创建人" field="userName"></vxe-column>
          <vxe-column min-width="160" align="center" title="创建时间" field="createDate"></vxe-column>
          <vxe-column  min-width="150px"align="center" fixed="right" title="状态" field="status" >
            <template slot-scope="scope">
              <el-button  type="text" @click="detail(scope.row)" effect="dark" size="mini"
                          :type="$dictUtils.getDictLabel('cw_status_flag', scope.row.status, '-')">
                {{$dictUtils.getDictLabel("cw_status", scope.row.status, '-')}}
              </el-button>
            </template>
          </vxe-column>
          <vxe-column  min-width="150px"align="center" fixed="right" title="签章状态" >
            <template slot-scope="scope">
              <el-button v-if="scope.row.signatureType === '1'"  type="text" @click="detailS(scope.row)" effect="dark" size="mini"
                          :type="$dictUtils.getDictLabel('cw_status_flag', scope.row.status1, '-')">
                {{$dictUtils.getDictLabel("cw_status", scope.row.status1, '-')}}
              </el-button>
              <el-button v-if="scope.row.signatureType === '2'" type="text" @click="detailS2(scope.row)" effect="dark" size="mini"
                          :type="$dictUtils.getDictLabel('cw_project_report_sign_status_flag', scope.row.status2, '-')">
                {{$dictUtils.getDictLabel("cw_project_report_sign_status", scope.row.status2, '-')}}
              </el-button>
            </template>
          </vxe-column>

          <vxe-column title="操作" width="150px" fixed="right" align="center">
            <template  slot-scope="scope">
              <el-button v-if="hasPermission('cwProjectReport:edit')&&scope.row.createById === $store.state.user.id&&(scope.row.status==='1'||scope.row.status==='3')" type="text"  size="small" @click="push(scope.row)">修改</el-button>
              <el-button v-else-if="hasPermission('cwProjectReport:edit')&&isAdmin&&(scope.row.status==='1'||scope.row.status==='3'||scope.row.status==='5')" type="text"  size="small" @click="edit(scope.row.id)">修改</el-button>
              <el-button v-if="hasPermission('cwProjectReport:edit')&&scope.row.createById === $store.state.user.id&&scope.row.status==='2'" type="text"  size="small" @click="reback(scope.row)">撤回</el-button>
              <el-button v-if="hasPermission('cwProjectReport:del')&&scope.row.createById === $store.state.user.id&&(scope.row.status==='1'||scope.row.status==='3')" type="text"   size="small" @click="del(scope.row.id)">删除</el-button>
              <el-button v-else-if="hasPermission('cwProjectReport:del')&&isAdmin&&(scope.row.status==='1'||scope.row.status==='3'||scope.row.status==='5')" type="text"   size="small" @click="del(scope.row.id)">删除</el-button>
<!--              公章流程-->
              <el-button v-if="hasPermission('cw:workContract:filed') && scope.row.status === '5' && scope.row.signatureType === '1' && (scope.row.status1 === '0' || scope.row.status1 === '3' || scope.row.status1 === '4')" type="text" size="small" @click="pushS(scope.row)">公章</el-button>
              <el-button v-if="hasPermission('cw:workContract:filed') && scope.row.status === '5' && scope.row.signatureType === '1' && scope.row.status1 === '2'" type="text" size="small" @click="rebackS(scope.row)">撤回签章申请</el-button>
<!--              公章+执业章流程-->
              <el-button v-if="hasPermission('cw:workContract:filed') && scope.row.status === '5' && scope.row.signatureType === '2' && (scope.row.status2 === '0' || scope.row.status2 === '3' || scope.row.status2 === '4')" type="text" size="small" @click="pushS2(scope.row)">公章+执业章</el-button>
              <el-button v-if="hasPermission('cw:workContract:filed') && scope.row.status === '5' && scope.row.signatureType === '2' && (scope.row.status2 === '2' || scope.row.status2 === '6' || scope.row.status2 === '7')" type="text" size="small" @click="rebackS2(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>
    <ReportManagementForm ref="reportManagementForm"></ReportManagementForm>
  </div>
</template>

<script>
  import InputNumber from '@/views/modules/cw/workContract/InputNumber.vue'
  import WorkClientService from '@/api/cw/workClientInfo/WorkClientService'
  import ProjectReportService from '@/api/cw/reportManagement/ProjectReportService'
  import TaskService from '@/api/flowable/TaskService'
  import ProcessService from '@/api/flowable/ProcessService'
  import ReportManagementForm from './ReportManagementForm'
  import pick from 'lodash.pick'
  import UserService from '@/api/sys/UserService'
  import SelectUserTree from '@/views/modules/utils/treeUserSelect'
  export default {
    data () {
      return {
        num: 0,
        searchForm: {
          contractAmounts: [],
          reportNo: '',
          projectNumber: '',
          projectName: '',
          projectMasterId: '',
          createBy: '',
          contractDates: []
        },
        dataList: [],
        tablePage: {
          total: 0,
          currentPage: 1,
          pageSize: 10,
          orders: []
        },
        tableKey: '',
        loading: false,
        processDefinitionAuditId: '',
        procDefAuditKey: '',
        isAdmin: false,
        create: '',
        processDefinitionSId: '',
        procDefSKey: '',
        processDefinitionSId2: '',
        procDefSKey2: ''
      }
    },
    workClientService: null,
    projectReportService: null,
    taskService: null,
    processService: null,
    userService: null,
    created () {
      this.workClientService = new WorkClientService()
      this.projectReportService = new ProjectReportService()
      this.taskService = new TaskService()
      this.processService = new ProcessService()
      this.userService = new UserService()
    },
    components: {
      ReportManagementForm,
      SelectUserTree,
      InputNumber
    },
    computed: {
      userName () {
        return JSON.parse(localStorage.getItem('user')).name
      },
      user () {
        this.createName = JSON.parse(localStorage.getItem('user')).name
        return JSON.parse(localStorage.getItem('user'))
      }
    },
    mounted () {
      this.refreshList()
    },
    activated () {
      this.refreshList()
    },
    methods: {
      // 新增
      add () {
        // this.$refs.workClientForm.init('add', '')
        // this.$refs.reportManagementTaskForm.init('add', '')
        this.$refs.reportManagementForm.init('add', '')
      },
      // 修改
      edit (id) {
        id = id || this.$refs.clientTable.getCheckboxRecords().map(item => {
          return item.id
        })[0]
        // this.$refs.workClientForm.init('edit', id)
        // this.$refs.reportManagementTaskForm.init('edit', id)
        this.$refs.reportManagementForm.init('edit', id)
      },
      // 查看
      view (id) {
        // this.$refs.workClientForm.init('view', id)
        // this.$refs.reportManagementTaskForm.init('view', id)
        this.$refs.reportManagementForm.init('view', id)
      },
      // 查询当前用户是否是管理员用户
      checkIsAdmin () {
        this.userService.is().then(({data}) => {
          this.isAdmin = data
        })
      },
      // 获取数据列表
      refreshList () {
        this.loading = true
        // this.workClientService.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.tableKey = Math.random()
        //   this.loading = false
        // })
        this.projectReportService.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.tableKey = Math.random()
          this.loading = false
        })
        this.checkIsAdmin()
        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.processDefinitionSId = data.id
            this.procDefSKey = data.key
          }
        })
        this.processService.getByName('财务-报告签章-公章+执业章').then(({data}) => {
          if (!this.commonJS.isEmpty(data.id)) {
            this.processDefinitionSId2 = data.id
            this.procDefSKey2 = 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()
      },
      // 删除
      del (id) {
        let ids = id || this.$refs.clientTable.getCheckboxRecords().map(item => {
          return item.id
        }).join(',')
        this.$confirm(`确定删除所选项吗?`, '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          this.loading = true
          this.projectReportService.delete(ids).then(({data}) => {
            this.$message.success(data)
            this.refreshList()
            this.loading = false
          })
          // this.workClientService.delete(ids).then(({data}) => {
          //   this.$message.success(data)
          //   this.refreshList()
          //   this.loading = false
          // })
        })
      },
      resetSearch () {
        this.$refs.searchForm.resetFields()
        this.refreshList()
      },
      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: '/cw/reportManagement/ReportManagementList'
              }
            })
          })
      },
      // 发起客户登记
      push (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: 'cw_project_report'}).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: 'cw_work_client_base',
                businessId: row.id,
                isShow: 'false',
                status: status,
                routePath: '/cw/reportManagement/ReportManagementList'
              }
            })
          })
      },
      // 查看客户登记流程结果
      detail (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'
              }
            })
          })
        }
      },
      // 撤回报告流程
      reback (row) {
        this.$confirm(`确定要撤回该申请吗?`, '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(async () => {
          await this.projectReportService.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.workClientService.updateStatusById(form)
                this.projectReportService.updateStatusById(form)
                this.$message.success(data)
                this.refreshList()
              })
            }
          })
          // await this.workClientService.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.workClientService.updateStatusById(form)
          //       this.$message.success(data)
          //       this.refreshList()
          //     })
          //   }
          // })
        })
      },
      // 归档
      // filed (id) {
      //   this.processService.getByName('财务-合同登记归档').then(({data}) => {
      //     if (!this.commonJS.isEmpty(data.id)) {
      //       // console.log('data', data)
      //       // 读取流程表单
      //       let tabTitle = `发起流程【财务-报告管理-盖公章】`
      //       let processTitle = `${this.userName} 在 ${this.moment(new Date()).format('YYYY-MM-DD HH:mm')} 发起了 [财务-合同登记归档]`
      //       this.taskService.getTaskDef({ procDefId: data.id,
      //         businessId: id,
      //         businessTable: 'cw_work_contract_file',
      //         status: 'startAndHoldFiled'}).then((reture) => {
      //           this.$router.push({
      //             path: '/flowable/task/TaskForm',
      //             query: {
      //               procDefId: data.id,
      //               procDefKey: data.key,
      //               status: 'startAndHoldFiled',
      //               title: tabTitle,
      //               formType: reture.data.formType,
      //               formUrl: reture.data.formUrl,
      //               formTitle: processTitle,
      //               businessTable: 'cw_work_contract_file',
      //               businessId: id,
      //               isShow: false,
      //               routePath: '/cw/workContract/ContractRegistration'
      //             }
      //           })
      //         })
      //     }
      //   })
      // }
      // 发起报告签章-公章流程
      pushS (row) {
        // 读取流程表单
        let title = `发起流程【报告签章-公章】`
        let processTitle = `${this.userName} 在 ${this.moment(new Date()).format('YYYY-MM-DD HH:mm')} 发起了[报告签章-公章]`
        let status = 'startAndClose'
        if (row.status1 === '3' || row.status1 === '4') {
          status = 'startAndClose'
        }
        this.taskService.getTaskDef({ procDefId: this.processDefinitionSId,
          businessId: row.sid1,
          businessTable: 'cw_project_report_signature'}).then((data) => {
            // console.log('row', row)
            // console.log('rowid', row.sid1)
            this.$router.push({
              path: '/flowable/task/TaskForm',
              query: {
                procDefId: this.processDefinitionSId,
                procDefKey: this.procDefSKey,
                title: title,
                formType: data.data.formType,
                formUrl: data.data.formUrl,
                formTitle: processTitle,
                businessTable: 'cw_project_report_signature',
                businessId: row.sid1,
                isShow: 'false',
                status: status,
                routePath: '/cw/reportManagement/ReportManagementList'
              }
            })
          })
      },
      // 查看报告签章-公章流程结果
      detailS (row) {
        if (row.status1 !== '0' && row.status1 !== '1') {
          // eslint-disable-next-line eqeqeq
          this.taskService.getTaskDef({
            procInsId: row.procInsId1,
            procDefId: this.processDefinitionSId
          }).then(({data}) => {
            this.$router.push({
              path: '/flowable/task/TaskFormDetail',
              query: {
                isShow: 'false',
                readOnly: true,
                title: '报告签章-公章' + '流程详情',
                formTitle: '报告签章-公章' + '流程详情',
                businessId: row.sid1,
                status: 'reback',
                ...pick(data, 'formType', 'formUrl', 'procDefKey', 'taskDefKey', 'procInsId', 'procDefId', 'taskId', 'title', 'businessId')
              }
            })
          })
        }
      },
      // 撤回报告签章-公章的申请流程
      rebackS (row) {
        this.$confirm(`确定要撤回该申请吗?`, '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(async () => {
          await this.projectReportService.findBySignatureId(row.sid1).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.sid1}
                this.projectReportService.updateSignatureStatusById(form)
                this.$message.success(data)
                this.refreshList()
              })
            }
          })
        })
      },
      // 发起报告签章-公章+执业章流程
      pushS2 (row) {
        // 读取流程表单
        let title = `发起流程【报告签章-公章+执业章】`
        let processTitle = `${this.userName} 在 ${this.moment(new Date()).format('YYYY-MM-DD HH:mm')} 发起了[报告签章-公章+执业章]`
        let status = 'startAndClose'
        if (row.status2 === '3' || row.status2 === '4') {
          status = 'startAndClose'
        }
        this.taskService.getTaskDef({ procDefId: this.processDefinitionSId2,
          businessId: row.sid2,
          businessTable: 'cw_project_report_signature'}).then((data) => {
            this.$router.push({
              path: '/flowable/task/TaskForm',
              query: {
                procDefId: this.processDefinitionSId2,
                procDefKey: this.procDefSKey2,
                title: title,
                formType: data.data.formType,
                formUrl: data.data.formUrl,
                formTitle: processTitle,
                businessTable: 'cw_project_report_signature',
                businessId: row.sid2,
                isShow: 'false',
                status: status,
                routePath: '/cw/reportManagement/ReportManagementList'
              }
            })
          })
      },
      // 查看报告签章-公章+执业章流程结果
      detailS2 (row) {
        if (row.status2 !== '0' && row.status2 !== '1') {
          // eslint-disable-next-line eqeqeq
          this.taskService.getTaskDef({
            procInsId: row.procInsId2,
            procDefId: this.processDefinitionSId2
          }).then(({data}) => {
            this.$router.push({
              path: '/flowable/task/TaskFormDetail',
              query: {
                isShow: 'false',
                readOnly: true,
                title: '报告签章-公章+执业章' + '流程详情',
                formTitle: '报告签章-公章+执业章' + '流程详情',
                businessId: row.sid2,
                status: 'reback',
                ...pick(data, 'formType', 'formUrl', 'procDefKey', 'taskDefKey', 'procInsId', 'procDefId', 'taskId', 'title', 'businessId')
              }
            })
          })
        }
      },
      // 撤回报告签章-公章+执业章的申请流程
      rebackS2 (row) {
        this.$confirm(`确定要撤回该申请吗?`, '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(async () => {
          await this.projectReportService.findBySignatureId(row.sid2).then(({data}) => {
            if (data.status !== row.status2) { // status的值不等于“审核中”，就弹出提示
              this.$message.error('数据已发生改变或不存在，请刷新数据')
              this.refreshList()
            } else {
              this.processService.revokeProcIns(row.procInsId2).then(({data}) => {
                let form = {status: '3', id: row.sid2}
                this.projectReportService.updateSignatureStatusById(form)
                this.$message.success(data)
                this.refreshList()
              })
            }
          })
        })
      },
      // 自定义服务端导出
      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.projectReportService.exportExcel(params).then((res) => {
          // 将二进制流文件写入excel表，以下为重要步骤
          this.$utils.downloadExcel(res.data, options.filename + '.xls')
        }).catch(function (err) {
          if (err.response) {
            // console.log(err.response)
          }
        })
      }
    }
  }
</script>
