<template>
  <div class="page">
    <el-form :inline="true" v-if="searchVisible" class="query-form m-b-10" ref="searchForm" :model="searchForm" @keyup.enter.native="refreshList()" @submit.native.prevent>
      <!-- 搜索框-->
      <el-form-item label="客户名称" prop="name">
        <el-input  v-model="searchForm.name" placeholder="请输入客户名称" clearable></el-input>
      </el-form-item>
      <el-form-item label="客户编号" prop="no">
        <el-input  v-model="searchForm.no" placeholder="请输入客户编号" clearable></el-input>
      </el-form-item>
      <el-form-item v-if="showHideItem" label="统一社会信用代码" prop="uscCode">
        <el-input v-model="searchForm.uscCode" placeholder="请输入统一社会信用代码" clearable></el-input>
      </el-form-item>
      <el-form-item v-if="showHideItem" label="企业隶属关系划分" prop="affiliation">
        <el-select v-model="searchForm.affiliation" placeholder="请选择" style="width:100%;" clearable>
          <el-option
            v-for="item in $dictUtils.getDictList('cw_work_client_affiliation')"
            :key="item.value"
            :label="item.label"
            :value="item.value">
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item v-if="showHideItem" label="按所有制性质分类" prop="cwWorkClientTypeDTO.ownershipType">
        <el-select v-model="searchForm.cwWorkClientTypeDTO.ownershipType" placeholder="请选择" style="width:100%;" clearable>
          <el-option
            v-for="item in $dictUtils.getDictList('cw_work_client_ownership_type')"
            :key="item.value"
            :label="item.label"
            :value="item.value">
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item v-if="showHideItem" label="所属行业" prop="industry">
        <el-select v-model="searchForm.industry" placeholder="请选择" style="width:100%;" clearable>
          <el-option
            v-for="item in $dictUtils.getDictList('cw_work_client_industry')"
            :key="item.value"
            :label="item.label"
            :value="item.value">
          </el-option>
        </el-select>
      </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('cw_status')"
            :key="item.value"
            :label="item.label"
            :value="item.value">
          </el-option>
        </el-select>
      </el-form-item>
      <!--<el-form-item label="拥有人" prop="updateUserName">
        <el-input size="small" v-model="searchForm.updateUserName" placeholder="请输入拥有人" clearable></el-input>
      </el-form-item>-->
      <el-form-item>
        <el-button type="default" @click="showHide"  :icon="showHideIcon">{{showHideName}}</el-button>
        <el-button type="primary" @click="refreshList()"  icon="el-icon-search">查询</el-button>
        <el-button @click="resetSearch()"  icon="el-icon-refresh-right">重置</el-button>
      </el-form-item>
    </el-form>
    <div class="jp-table top" style="">
      <vxe-toolbar :refresh="{query: refreshList}" ref="toolbarRef" export custom>
        <template #buttons>
          <el-button v-if="hasPermission('cw_work_client:info:add')" type="primary"  icon="el-icon-plus" @click="add()">新建</el-button>
<!--          <el-button v-if="hasPermission('cw_work_client:info:view')" size="small" @click="viewUpdateLog()">修改申请记录</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>-->
<!--          <el-button type="warning" size="small" icon="el-icon-download" @click="exportFile()" plain>导出</el-button>-->
		</template>
		  <template #tools>
			  <vxe-button
				  type="text"
				  :title="searchVisible ? '收起检索' : '展开检索'"
				  icon="vxe-icon-search"
				  class="tool-btn"
				  @click="searchVisible = !searchVisible"
			  ></vxe-button>
		  </template>
      </vxe-toolbar>
      <div style="height: calc(100% - 90px)">
        <vxe-table
          :key="tableKey"
          border="inner"
          auto-resize
          resizable
          height="auto"
          :loading="loading"
          size="small"
          ref="clientTable"
          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"
          :checkbox-config="{}">
          <vxe-column type="seq" width="60" title="序号"></vxe-column>
          <vxe-column type="checkbox" width="40" ></vxe-column>
          <vxe-column min-width="230" align="center" title="客户名称" field="name">
            <template #default="scope">
              <el-link  type="primary" :underline="false" v-if="hasPermission('cw_work_client:info:view')" @click="view(scope.row.id)">{{scope.row.name}}</el-link>
              <el-link  type="primary" :underline="false" v-else-if="hasPermission('cw_work_client:info:view')"  @click="view(scope.row.id)">{{scope.row.name}}</el-link>
              <span v-else>{{scope.row.name}}</span>
            </template>
          </vxe-column>
          <vxe-column min-width="160" align="center" title="客户编号" field="no"></vxe-column>
          <vxe-column min-width="160" align="center" title="客户类型" field="type">
            <template #default="scope">
              {{$dictUtils.getDictLabel('cw_work_client_type', scope.row.type, '-')}}
            </template>
          </vxe-column>
          <vxe-column min-width="160" align="center" title="统一社会信用代码" field="uscCode"></vxe-column>
<!--          <vxe-column min-width="160" align="center" title="英文名称" field="englishName"></vxe-column>-->
          <vxe-column min-width="160" align="center" title="所属行业" field="industry">
            <template #default="scope">
              {{$dictUtils.getDictLabel('cw_work_client_industry', scope.row.industry, '-')}}
            </template>
          </vxe-column>
          <vxe-column min-width="160" align="center" title="是否上市" field="cwWorkClientTypeDTO.isListed">
            <template #default="scope">
              {{$dictUtils.getDictLabel('yes_no', scope.row.cwWorkClientTypeDTO.isListed, '-')}}
            </template>
          </vxe-column>
          <vxe-column min-width="160" align="center" title="企业隶属关系划分" field="affiliation">
            <template #default="scope">
              {{$dictUtils.getDictLabel('cw_work_client_affiliation', scope.row.affiliation, '-')}}
            </template>
          </vxe-column>
          <vxe-column min-width="160" align="center" title="按所有制性质分类" field="cwWorkClientTypeDTO.ownershipType">
            <template #default="scope">
              {{$dictUtils.getDictLabel('cw_work_client_ownership_type', scope.row.cwWorkClientTypeDTO.ownershipType, '-')}}
            </template>
          </vxe-column>
          <vxe-column min-width="160" align="center" title="按最终地位分类" field="cwWorkClientTypeDTO.finalStatusType"></vxe-column>
<!--          <vxe-column min-width="160" align="center" title="客户报备类型" field="reportType">-->
<!--            <template #default="scope">-->
<!--              {{$dictUtils.getDictLabel('cw_work_client_report_type', scope.row.reportType, '-')}}-->
<!--            </template>-->
<!--          </vxe-column>-->
          <vxe-column min-width="160" align="center" title="创建人" field="createBy.name"></vxe-column>
          <vxe-column min-width="160" align="center" title="创建时间" field="createTime"></vxe-column>
          <vxe-column min-width="120" align="center" title="拥有人" fixed="right" field="updateUserName">
            <template #default="scope">
              <el-link  type="primary" :underline="false" v-if="hasPermission('cw_work_client:info:view')" @click="updateLog(scope.row.id)">{{scope.row.updateUserName}}</el-link>
<!--              <span v-else>{{scope.row.updateUserName}}</span>-->
            </template>
          </vxe-column>
          <vxe-column  min-width="100px" align="center" fixed="right" title="修改申请状态" field="status" >
            <template #default="scope">
              <el-button @click="detail(scope.row)" effect="dark" size="small"
                          :type="$dictUtils.getDictLabel('cw_status_flag', scope.row.status, '-')">
                {{$dictUtils.getDictLabel("cw_status", scope.row.status, '-')}}
              </el-button>
            </template>
          </vxe-column>
          <vxe-column title="操作" width="140px" fixed="right" align="center">
            <template  #default="scope">
              <div v-if="isAdmin">
                <el-button v-if="(scope.row.status==='0'||scope.row.status==='5')" text type="primary"  size="small" @click="edit(scope.row.id)">修改</el-button>
                <el-button v-if="(scope.row.status==='0'||scope.row.status==='5')" text type="primary"   size="small" @click="del(scope.row.id)">删除</el-button>
              </div>
              <div v-else>
                <!--              拥有人修改-->
                <el-button v-if="hasPermission('cw_work_client:info:edit')&&scope.row.updateUser === $store.state.user.id&&(scope.row.status==='0'||scope.row.status==='5')" text type="primary"  size="small" @click="edit(scope.row.id)">修改</el-button>
                <!--              其他人修改-->
                <el-button v-if="hasPermission('cw_work_client:info:edit')&&scope.row.updateUser !== $store.state.user.id&&(scope.row.status==='0'||scope.row.status==='5')" text type="primary"  size="small" @click="push(scope.row)">申请修改</el-button>
                <!--              审核-->
                <el-button v-if="scope.row.status==='2' && checkIsAudit(scope.row)" text type="primary"  size="small" @click="examine(scope.row)">审核</el-button>
                <!--              被驳回后当前申请人重新调整-->
                <el-button v-if="hasPermission('cw_work_client:info:edit')&&scope.row.requestUserId === $store.state.user.id&&scope.row.status === '4'" text type="primary"  size="small" @click="adjust(scope.row)">驳回调整</el-button>
                <!--              当前申请人撤回-->
                <el-button v-if="hasPermission('cw_work_client:info:edit')&&scope.row.requestUserId === $store.state.user.id&&scope.row.status==='2'" text type="primary"  size="small" @click="reback(scope.row)">撤回</el-button>
                <!--              当前申请人撤回后->申请修改-->
                <el-button v-if="hasPermission('cw_work_client:info:edit')&&scope.row.requestUserId === $store.state.user.id&&scope.row.status==='3'" text type="primary"  size="small" @click="push(scope.row)">申请修改</el-button>
                <!--              当前申请人撤回后->取消修改申请-->
                <el-button v-if="hasPermission('cw_work_client:info:edit')&&scope.row.requestUserId === $store.state.user.id&&scope.row.status==='3'" text type="primary"  size="small" @click="stopUpdate(scope.row.id)">取消修改</el-button>
                <!--              拥有人删除-->
                <el-button v-if="hasPermission('cw_work_client:info:del')&&scope.row.updateUser === $store.state.user.id&&(scope.row.status==='0'||scope.row.status==='5')" text type="primary"   size="small" @click="del(scope.row.id)">删除</el-button>
              </div>
            </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>
    <WorkClientForm ref="workClientForm" @refreshList="refreshList"></WorkClientForm>
    <WorkClientAddForm ref="workClientAddForm" @refreshList="refreshList" @updateDialogData="updateDialogData" @updateFlowAbleData="updateFlowAbleData"></WorkClientAddForm>
    <WorkClientUpdateLog ref="workClientUpdateLog" @refreshList=""></WorkClientUpdateLog>
  </div>
</template>

<script>
  import workClientService from '@/api/cw/workClientInfo/WorkClientService'
  import taskService from '@/api/flowable/TaskService'
  import processService from '@/api/flowable/ProcessService'
  import WorkClientForm from './WorkClientForm'
  import pick from 'lodash.pick'
  import userService from '@/api/sys/UserService'
  import WorkClientAddForm from './WorkClientAddForm'
  import WorkClientUpdateLog from './WorkClientUpdateLog'
  export default {
    data () {
      return {
		searchVisible: true,
        showHideItem: false,
        showHideIcon: 'el-icon-arrow-down',
        showHideName: '展示',
        searchForm: {
          name: '',
          no: '',
          uscCode: '',
          affiliation: '',
          cwWorkClientTypeDTO: {
            ownershipType: ''
          },
          industry: '',
          createDates: [],
          status: '',
          updateUserName: ''
        },
        dataList: [],
        tablePage: {
          total: 0,
          currentPage: 1,
          pageSize: 10,
          orders: []
        },
        tableKey: '',
        loading: false,
        processDefinitionAuditId: '',
        procDefAuditKey: '',
        isAdmin: false
      }
    },
    created () {
    },
    components: {
      WorkClientForm,
      WorkClientAddForm,
      WorkClientUpdateLog
    },
    computed: {
      userName () {
        return this.$store.state.user.name
      },
      user () {
        this.createName = this.$store.state.user.name
        return this.$store.state.user
      }
    },
    mounted () {
      this.refreshList();
		this.$nextTick(() => {
			//将表格和工具栏进行关联
			const $table = this.$refs.clientTable;
			const $toolbar = this.$refs.toolbarRef;
			$table.connect($toolbar);
		})
    },
    activated () {
      let query = this.$route.query
      if (this.commonJS.isNotEmpty(query.methodName)) {
        if (query.methodName === 'updateFlowAbleData') {
          this.updateFlowAbleData(query.dataId)
        }
        if (query.methodName === 'updateDialogData') {
          this.updateDialogData(query.dataId)
        }
      }
      this.refreshList()
    },
    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 = '展示'
        }
      },
      // 修改申请日志
      viewUpdateLog () {
        this.$refs.workClientUpdateLog.init()
      },
      // 修改申请日志
      updateLog (id) {
        this.$refs.workClientUpdateLog.init(id)
      },
      // 新增
      add () {
        this.$refs.workClientAddForm.init('add', 'false')
      },
      // 修改
      edit (id) {
        id = id || this.$refs.clientTable.getCheckboxRecords().map(item => {
          return item.id
        })[0]
        this.$refs.workClientAddForm.init('edit', id)
      },
      updateDialogData (id) {
        this.$refs.workClientAddForm.init('edit', id)
        this.$store.dispatch('tagsView/delView', {fullPath: this.$route.fullPath})
        this.$router.push({query: {}})
      },
      // 查看
      view (id) {
        this.$refs.workClientForm.init('view', id)
      },
      // 查询当前用户是否是管理员用户
      checkIsAdmin () {
        userService.is().then((data) => {
          this.isAdmin = data
        })
      },
      // 获取数据列表
      refreshList () {
        this.loading = true
        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.loading = false
        })
        this.checkIsAdmin()
        processService.getByName('客户修改').then(async (data) => {
          if (!this.commonJS.isEmpty(data.id)) {
            this.processDefinitionAuditId = data.id
            this.procDefAuditKey = 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
          workClientService.delete(ids).then((data) => {
            if (data === '删除成功') {
              this.$message.success(data)
            } else {
              this.$message.error(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')} 发起了 [客户修改]`
        taskService.getTaskDef({ procDefId: this.processDefinitionAuditId,
          status: 'startAndHold'}).then((data) => {
            this.$router.push({
              path: '/flowable/task/TaskForm',
              query: {
                ...pick(data, 'formType', 'formUrl', 'procDefKey', 'taskDefKey', 'procInsId', 'procDefId', 'taskId', 'status', 'title'),
                procDefId: this.processDefinitionAuditId,
                procDefKey: this.procDefAuditKey,
                status: 'startAndHold',
                title: tabTitle,
                formType: data.formType,
                formUrl: data.formUrl,
                formTitle: processTitle,
                businessId: 'false',
                isShow: false,
                routePath: '/cw/workClientInfo/WorkClientList'
              }
            })
          })
      },
      updateFlowAbleData (id) {
        workClientService.queryById(id).then((data) => {
          this.$store.dispatch('tagsView/delView', {fullPath: this.$route.fullPath})
          this.$router.push({query: {}})
          // 读取流程表单
          let title = `发起流程【客户修改】`
          let processTitle = `${this.userName} 发起了 ${data.no} - ${data.name} [客户修改]`
          let status = 'startAndClose'
          if (data.status === '3') {
            status = 'startAndClose'
          } else if (data.status === '4') {
            status = 'reapplyFlag'
          }
          taskService.getTaskDef({ procDefId: this.processDefinitionAuditId,
            businessId: data.id,
            businessTable: 'cw_work_client_base'}).then((task) => {
              this.$router.push({
                path: '/flowable/task/TaskForm',
                query: {
                  ...pick(task, 'formType', 'formUrl', 'procDefKey', 'taskDefKey', 'procInsId', 'procDefId', 'taskId', 'status', 'title'),
                  procDefId: this.processDefinitionAuditId,
                  procDefKey: this.procDefAuditKey,
                  title: title,
                  formType: task.formType,
                  formUrl: task.formUrl,
                  formTitle: processTitle,
                  businessTable: 'cw_work_client_base',
                  businessId: data.id,
                  isShow: 'false',
                  status: status,
                  routePath: '/cw/workClientInfo/WorkClientList'
                }
              })
            })
        })
      },
      // 发起客户修改
      push (row) {
        workClientService.queryById(row.id).then((data) => {
          if (data.status !== row.status) { // status的值不等于“审核中”，就弹出提示
            this.$message.error('数据已发生改变或不存在，请刷新数据')
            this.refreshList()
          } else {
            // 读取流程表单
            let title = `发起流程【客户修改】`
            let processTitle = `${this.userName} 发起了 ${row.no} - ${row.name} [客户修改]`
            let status = 'startAndClose'
            if (row.status === '3') {
              status = 'startAndClose'
            } else if (row.status === '4') {
              status = 'reapplyFlag'
            }
            taskService.getTaskDef({ procDefId: this.processDefinitionAuditId,
              businessId: row.id,
              businessTable: 'cw_work_client_base'}).then((data) => {
                this.$router.push({
                  path: '/flowable/task/TaskForm',
                  query: {
                    ...pick(data, 'formType', 'formUrl', 'procDefKey', 'taskDefKey', 'procInsId', 'procDefId', 'taskId', 'status', 'title'),
                    procDefId: this.processDefinitionAuditId,
                    procDefKey: this.procDefAuditKey,
                    title: title,
                    formType: data.formType,
                    formUrl: data.formUrl,
                    formTitle: processTitle,
                    businessTable: 'cw_work_client_base',
                    businessId: row.id,
                    isShow: 'false',
                    status: status,
                    routePath: '/cw/workClientInfo/WorkClientList'
                  }
                })
              })
          }
        })
      },
      // 查看客户修改流程结果
      detail (row) {
        if (row.status !== '0' && row.status !== '1') {
          // eslint-disable-next-line eqeqeq
          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(() => {
          workClientService.queryById(row.id).then((data) => {
            if (data.status !== '2') { // status的值不等于“审核中”，就弹出提示
              this.$message.error('数据已发生改变或不存在，请刷新数据')
              this.refreshList()
            } else {
              processService.revokeProcIns(row.procInsId).then((data) => {
                let form = {status: '3', id: row.id}
                workClientService.updateStatusById(form).then(() => {
                  workClientService.rebackUpdate(row.id).then(() => {
                    this.$message.success(data)
                    this.refreshList()
                  })
                })
              })
            }
          })
        })
      },
      // 取消修改申请
      stopUpdate (id) {
        this.$confirm(`确定要取消修改申请?`, '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          workClientService.stopUpdate(id).then(() => {
            this.$message.success('修改申请已取消')
            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.map(item => item.id) : [],
          exportFields: options.columns.map(column => column.property)
        }
        return workClientService.exportFile(params).then((res) => {
          // 将二进制流文件写入excel表，以下为重要步骤
          this.$utils.downloadExcel(res, options.filename)
        }).catch(function (err) {
          if (err.response) {
            console.log(err.response)
          }
        })
      },
      // 驳回后调整
      adjust (row) {
        workClientService.queryById(row.id).then((data) => {
          if (data.status !== '4') { // status的值不等于“驳回”，就弹出提示
            this.$message.error('数据已发生改变或不存在，请刷新数据')
            this.refreshList()
          } else {
            this.todo(row)
          }
        })
      },
      // 审核
      examine (row) {
        workClientService.queryById(row.id).then((data) => {
          if (data.status !== '2') { // status的值不等于“审核中”，就弹出提示
            this.$message.error('数据已发生改变或不存在，请刷新数据')
            this.refreshList()
          } else {
            this.todo(row)
          }
        })
      },
      // 审核或重新调整跳转
      todo (row) {
        let cUser = false
        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: '/cw/workClientInfo/WorkClientList'   // 数据处理后需要跳转的页面路径
            }
          })
        })
      },
      // 查询当前登录人是否是数据的审核人
      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
      }
    }
  }
</script>
