<template>
  <div class="app-container">
    <div class="title-container">
      <breadcrumb id="breadcrumb-container" class="breadcrumb-container" />
    </div>
    <y-page-list-layout :page-list="pageData" :page-para="listQuery" :get-page-list="getPage">
      <template slot="left">
        <MoreSearchBar business="MAJOR_BUSINESS" @fliterSearch="fliterSearch" @resetParams="resetParams"
          :listQuery="listQuery" :nodes="majorNodes" :ifSaveFileQuery="true">
          <template v-slot:otherButton>
            <el-button class="filter-item" round @click="showAllLabel()">显示全部列</el-button>
            <PermissionButton menu-code="_views_major_batch_commit_bookbinding_stamp" class-name="filter-item"
              type="danger" icon="el-icon-paperclip" :page-jump="false" round
              @click="openBatchCommitDialog('BOOKBINDING_STAMP')" />
            <PermissionButton menu-code="_views_major_batch_commit_recheck_archiving" class-name="filter-item"
              type="danger" icon="el-icon-paperclip" :page-jump="false" round
              @click="openBatchCommitDialog('RECHECK_ARCHIVING')" />
            <PermissionButton menu-code="_views_major_batch_commit_check_archiving" class-name="filter-item"
              type="danger" icon="el-icon-paperclip" :page-jump="false" round
              @click="openBatchCommitDialog('CHECK_ARCHIVING')" />
          </template>
        </MoreSearchBar>
      </template>
      <parentTable :data="pageData.records" slot="table" style="width: 100%;" @sortTable="sortTable"
        @headerClick="switchHeader">
        <el-table-column label="项目名称" align="center" width="250" v-if="!hiddenLabels.includes('productionName')"
          prop="productionName" show-overflow-tooltip>
          <template slot-scope="{row}">
            <span class="enableClick" @click="toDetail(row)">{{ row.productionName == null ? row.orderName :
              row.productionName
              }}</span>
          </template>
        </el-table-column>
        <el-table-column label="订单号" align="center" width="150" v-if="!hiddenLabels.includes('orderId')" prop="orderId">
          <template slot-scope="{row}">
            <span class="enableClick" @click="toDetail(row)" @contextmenu.prevent="$doCopy(row.orderId)">{{ row.orderId
              }}</span>
          </template>
        </el-table-column>
        <el-table-column label="价值意见书号" align="center" width="200" v-if="!hiddenLabels.includes('statementNo')"
          prop="statementNo" sortable>
          <template slot-scope="{row}">
            <span @contextmenu.prevent="$doCopy(row.statementNo)">{{ row.statementNo == null ? '-' : row.statementNo
              }}</span>
          </template>
        </el-table-column>
        <el-table-column label="报告号/复评函号" align="center" width="200" v-if="!hiddenLabels.includes('reportNo')"
          prop="reportNo" sortable>
          <template slot-scope="{row}">
            <span @contextmenu.prevent="$doCopy(row.reportNo)">{{ row.reportNo == null ? '-' : row.reportNo }}</span>
          </template>
        </el-table-column>
        <el-table-column label="评估对象类型" align="center" width="120" v-if="!hiddenLabels.includes('businessObjectType')"
          prop="businessObjectType">
          <template slot-scope="{row}">
            <span>{{ row.businessObjectType }}</span>
          </template>
        </el-table-column>
        <el-table-column label="待办人" align="center" v-if="!hiddenLabels.includes('handler')" prop="handler">
          <template slot-scope="{row}">
            <span>{{ row.handler }}</span>
          </template>
        </el-table-column>
        <el-table-column label="当前节点" align="center" width="140" v-if="!hiddenLabels.includes('nodeName')"
          prop="nodeName" sortable>
          <template slot-scope="{row}">
            <span>{{ row.nodeName }}</span>
          </template>
        </el-table-column>
        <el-table-column label="客户经理" align="center" v-if="!hiddenLabels.includes('clientManager')"
          prop="clientManager">
          <template slot-scope="{row}">
            <span>{{ row.clientManager }}</span>
          </template>
        </el-table-column>
        <el-table-column label="负责人" align="center" v-if="!hiddenLabels.includes('principal')" prop="principal">
          <template slot-scope="{row}">
            <span>{{ row.principal == null ? '-' : row.principal }}</span>
          </template>
        </el-table-column>
        <el-table-column label="评估对象类型" align="center" width="130" v-if="!hiddenLabels.includes('businessObjectType')"
          prop="businessObjectType">
          <template slot-scope="{row}">
            <span>{{ row.businessObjectType }}</span>
          </template>
        </el-table-column>
        <el-table-column label="客户名称" align="center" width="130" v-if="!hiddenLabels.includes('cclienteleName')"
          prop="cclienteleName">
          <template slot-scope="{row}">
            <span>{{ row.cclienteleName }}</span>
          </template>
        </el-table-column>
        <el-table-column label="业务来源" align="center" width="130" v-if="!hiddenLabels.includes('cclienteleSubName')"
          prop="cclienteleSubName">
          <template slot-scope="{row}">
            <span>{{ row.cclienteleSubName }}</span>
          </template>
        </el-table-column>
        <el-table-column label="客户联系人" align="center" width="130" v-if="!hiddenLabels.includes('cclienteleContactName')"
          prop="cclienteleContactName">
          <template slot-scope="{row}">
            <span>{{ row.cclienteleContactName }}</span>
          </template>
        </el-table-column>
        <el-table-column label="客户联系人电话" align="center" width="130" v-if="!hiddenLabels.includes('cmobile')"
          prop="cmobile">
          <template slot-scope="{row}">
            {{ row.cmobile }}
          </template>
        </el-table-column>
        <el-table-column label="下单时间" align="center" width="160" v-if="!hiddenLabels.includes('created')"
          prop="created">
          <template slot-scope="{row}">
            <span>{{ row.created }}</span>
          </template>
        </el-table-column>
        <el-table-column label="任务创建时间" align="center" width="160" v-if="!hiddenLabels.includes('taskCreated')"
          prop="taskCreated" sortable>
          <template slot-scope="{row}">
            <span>{{ row.taskCreated }}</span>
          </template>
        </el-table-column>
        <el-table-column label="操作" align="center" width="100" fixed="right">
          <template slot-scope="{row}">
            <el-button type="text" @click="toDetail(row)">办理</el-button>
            <el-button type="text" @click="transfer(row.taskId)">转交</el-button>
          </template>
        </el-table-column>
      </parentTable>
    </y-page-list-layout>
    <TransferDialog :transferDialogVisible="visible" @parentFalse="parentFalse()" @getPage="getPage()"
      :recordId="recordId">
    </TransferDialog>
    <el-dialog :visible.sync="batchCommitDialog" width="70%">
      <y-page-list-layout :page-list="batchCommitPageData" :page-para="batchCommitListQuery"
        :get-page-list="selectBatchCommitPage">
        <template slot="left">
          <el-input style="margin-left: 20px;width: 300px;float: left;" class="filter-item"
            v-model="batchCommitListQuery.keyWord" placeholder="项目编号/报告号/项目名称/业务来源" clearable>
          </el-input>
          <el-button class="filter-item" style="margin-left: 10px;float: left;" type="primary"
            @click="searchBatchCommitList()" round>搜索
          </el-button>
          <el-button class="filter-item" style="margin-left: 10px;float: left;" type="danger" @click="batchCommitNode()"
            round>提交选中流程
          </el-button>
        </template>
        <parentTable :clickRowToPick="true" ref="table" :data="batchCommitPageData.records" slot="table"
          style="width: 100%;height: 800px;" :selectionChange="handleSelectionChange">
          <el-table-column align="center" type="selection" claimOrders width="50" border="true">
          </el-table-column>
          <el-table-column label="项目名称" align="center" width="250" v-if="!hiddenLabels.includes('productionName')"
            prop="productionName" show-overflow-tooltip>
            <template slot-scope="{row}">
              <span class="enableClick" @click="toDetail(row)">{{ row.productionName == null ? row.orderName :
                row.productionName
                }}</span>
            </template>
          </el-table-column>
          <el-table-column label="订单号" align="center" width="150" v-if="!hiddenLabels.includes('orderId')"
            prop="orderId">
            <template slot-scope="{row}">
              <span class="enableClick" @click="toDetail(row)" @contextmenu.prevent="$doCopy(row.orderId)">{{
                row.orderId
                }}</span>
            </template>
          </el-table-column>
          <el-table-column label="价值意见书号" align="center" width="200" v-if="!hiddenLabels.includes('statementNo')"
            prop="statementNo" sortable>
            <template slot-scope="{row}">
              <span @contextmenu.prevent="$doCopy(row.statementNo)">{{ row.statementNo == null ? '-' : row.statementNo
                }}</span>
            </template>
          </el-table-column>
          <el-table-column label="报告号/复评函号" align="center" width="200" v-if="!hiddenLabels.includes('reportNo')"
            prop="reportNo" sortable>
            <template slot-scope="{row}">
              <span @contextmenu.prevent="$doCopy(row.reportNo)">{{ row.reportNo == null ? '-' : row.reportNo }}</span>
            </template>
          </el-table-column>
          <el-table-column label="评估对象类型" align="center" width="120" v-if="!hiddenLabels.includes('businessObjectType')"
            prop="businessObjectType">
            <template slot-scope="{row}">
              <span>{{ row.businessObjectType }}</span>
            </template>
          </el-table-column>
          <el-table-column label="待办人" align="center" v-if="!hiddenLabels.includes('handler')" prop="handler">
            <template slot-scope="{row}">
              <span>{{ row.handler }}</span>
            </template>
          </el-table-column>
          <el-table-column label="当前节点" align="center" width="140" v-if="!hiddenLabels.includes('nodeName')"
            prop="nodeName" sortable>
            <template slot-scope="{row}">
              <span>{{ row.nodeName }}</span>
            </template>
          </el-table-column>
          <el-table-column label="客户经理" align="center" v-if="!hiddenLabels.includes('clientManager')"
            prop="clientManager">
            <template slot-scope="{row}">
              <span>{{ row.clientManager }}</span>
            </template>
          </el-table-column>
          <el-table-column label="负责人" align="center" v-if="!hiddenLabels.includes('principal')" prop="principal">
            <template slot-scope="{row}">
              <span>{{ row.principal == null ? '-' : row.principal }}</span>
            </template>
          </el-table-column>
        </parentTable>
      </y-page-list-layout>
    </el-dialog>
    <el-dialog :visible.sync="allocationDialog" title="评估部退单，请领导重新分单。" center width="35%" top="15vh">
      <el-form :model="allocationForm">
        <el-row>
          <el-col :xs="24" :sm="12" :lg="24" :span="6">
            <el-form-item label="退单部门:">
              <el-input :value="allocationForm.departmentName + '-' + allocationForm.refuseUser" readonly  style="width: 80%;"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :xs="24" :sm="12" :lg="24" :span="6">
            <el-form-item label="退单时间:">
              <el-input :value="allocationForm.refuseTime" readonly  style="width: 80%;"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :xs="24" :sm="12" :lg="24" :span="6">
            <el-form-item label="退单原因:">
              <el-input :value="allocationForm.reason" readonly style="width: 80%;"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :xs="24" :sm="12" :lg="24" :span="6">
            <el-form-item label="接单部门:">
              <el-select v-model="allocationForm.departmentId" placeholder="请重新分配接单部门" clearable style="width: 80%;">
                <el-option v-for="(d, id) in allotDepartment" :label="d.name" :value="d.id"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :xs="24" :sm="12" :lg="24" :span="6">
            <el-form-item label="处理意见:">
              <el-input type="textarea" v-model="allocationForm.comments"  clearable style="width: 80%;" />
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="allocationDialog = false">取 消</el-button>
        <el-button type="primary" @click="saveAllocation()">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>
<script>
import YPageListLayout from '@/components/YPageListLayout'
import Breadcrumb from '@/components/Breadcrumb'
import TransferDialog from '@/components/TaskTransferDialog'
import { getCookie, setCookie, removeCookie } from '@/utils/auth'
import MoreSearchBar from '@/components/MoreSearchBar'

export default {
  name: 'MajorTaskTodoList',
  components: {
    Breadcrumb,
    YPageListLayout,
    TransferDialog,
    MoreSearchBar
  },

  data() {
    return {
      pageData: { records: [] },
      listQuery: {
        page: 1,
        size: 10,
        keyword: null,
        descs: null,
        ascs: null,
        getNodeIsCheckArchiving: false
      },
      majorNodes: [],
      orderDate: '',
      pickerOptions: {
        shortcuts: [{
          text: '最近一周',
          onClick(picker) {
            const end = new Date();
            const start = new Date();
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
            picker.$emit('pick', [start, end]);
          }
        }, {
          text: '最近一个月',
          onClick(picker) {
            const end = new Date();
            const start = new Date();
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
            picker.$emit('pick', [start, end]);
          }
        }, {
          text: '最近三个月',
          onClick(picker) {
            const end = new Date();
            const start = new Date();
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
            picker.$emit('pick', [start, end]);
          }
        }]
      },
      visible: false,
      recordId: null,
      hiddenLabels: [],
      batchCommitDialog: false,
      workNodeCommits: [],
      batchCommitListQuery: {
        page: 1,
        size: 10,
        current: 1,
        keyWord: null,
        handlerId: this.$store.getters.userInfo.id,
        getNodeIsBookbindingStamp: false,
        getNodeIsRecheckArchiving: false,
        getNodeIsCheckArchiving: false
      },
      batchCommitPageData: { records: [] },
      allocationDialog: false,
      allocationForm: {
        id: null,
        departmentId: null,
        comments: null,
        departmentName:null,
        reason:null,
        refuseTime:null,
        refuseUser:null
      },
      allotDepartment: [],
      nodeCode:null,
    }
  },
  created() {
    if (getCookie("MajorTodoList-hiddenLabels") != undefined) {
      this.hiddenLabels = JSON.parse(getCookie("MajorTodoList-hiddenLabels"))
    }
    this.nodeCode = this.$route.query.nodeCode;
    if (this.nodeCode === 'LEADER_ALLOCATION'){
        this.getAllotDepartment();
        this.getRefuseReason(this.$route.query.businessId);
        this.allocationDialog = true;
        this.allocationForm.instanceNodeId = this.$route.query.currentNodeId;
        this.allocationForm.id = this.$route.query.businessId;
        this.allocationForm.departmentName = this.$route.query.departmentName;
    }
    this.getPage();
    this.getMajorNodes();
  },
  methods: {

    resetSearch() {
      this.$router.push({ query: {} });
      this.orderDate = '';
      this.listQuery = {
        current: 1,
        size: 10,
        descs: 'taskCreated',
      }
      this.getPage()
    },

    removeHandle(row) {
      // console.log(data)
      this.$confirm('确认删除当前记录吗?', '警告', {
        confirmButtonText: '确认',
        cancelButtonText: '取消',
        type: 'warning',
      })
        .then(async () => {
          this.$api.term.delete(row.id).then((res) => {
            if (res.code === 200) {
              this.$message({
                type: 'success',
                message: '删除成功',
              })
              this.getPage()
            }
          })
        })
        .catch((err) => {
          console.error(err)
        })
    },
    searchList() {
      // 重置分页
      this.listQuery.page = 1
      this.listQuery.size = 10
      if (this.orderDate) {
        this.listQuery.startDate = this.orderDate[0] + ' 00:00:00';
        this.listQuery.endDate = this.orderDate[1] + ' 23:59:59';
      }
      this.getPage()
    },
    getPage() {

      this.$api.workNodeTaskRecord.majorTaskTodoList(this.listQuery).then(res => {
        if (res.code === 200) {
          this.pageData = res.data;
        }
      })
    },
    // 当前用户待办分页查询
    selectBatchCommitPage() {
      this.$api.workNodeTaskRecord.majorTaskTodoList(this.batchCommitListQuery).then(res => {
        if (res.code === 200) {
          this.batchCommitPageData = res.data;
        }
      })
    },
    // 条件查询
    searchBatchCommitList() {
      // 重置分页
      this.batchCommitListQuery.page = 1
      this.batchCommitListQuery.size = 10
      this.selectBatchCommitPage()
    },
    openBatchCommitDialog(node) {
      if (node === 'BOOKBINDING_STAMP') {
        this.batchCommitListQuery.getNodeIsBookbindingStamp = true;
      }
      if (node === 'RECHECK_ARCHIVING') {
        this.batchCommitListQuery.getNodeIsRecheckArchiving = true;
      }
      if (node === 'CHECK_ARCHIVING') {
        this.batchCommitListQuery.getNodeIsCheckArchiving = true;
      }
      this.selectBatchCommitPage();
      this.batchCommitDialog = true;
    },
    handleSelectionChange(val) {
      let pickedCommits = [];
      for (let i in val) {
        let commit = new Object();
        commit.instanceNodeId = val[i].currentNodeId;
        commit.state = "PASS";
        commit.comments = "批量提交装订盖章节点";
        commit.businessSubId = val[i].statementNo;
        commit.businessMinId = val[i].reportNo;
        pickedCommits.push(commit);
      }
      this.workNodeCommits = pickedCommits;
    },
    deleteInfo(id) {
      const that = this
      that.$confirm('请确认是否删除该数据?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
        center: true
      }).then(() => {
        that.$api.item.delete(id).then(data => {
          that.loading = false
          if (data.code === 200) {
            that.getPage()
          } else {
            this.$message({
              type: 'error',
              message: data.msg
            })
          }
        })
      }).catch(() => {
      })
    },
    getMajorNodes() {
      this.$api.workNode.nodesByBusiness('MAJOR_BUSINESS').then(res => {
        if (res.code === 200) {
          this.majorNodes = res.data
        }
      })
    },
    parentFalse() {
      this.visible = false;
    },
    transfer(recordId) {
      this.visible = true;
      this.recordId = recordId;
    },
    toDetail(row) {
      let reportNo = row.reportNo;
      let statementNo = row.statementNo;
      if (row.nodeCode === 'REPORT_OUT_APPLY' || row.nodeCode === 'LETTER_OUT_APPLY') {
        this.$router.push(`/major/my/order?todoBusinessId=${row.businessId}&sNo=${statementNo}&rNo=${reportNo}&tId=${row.taskId}&cId=${row.currentNodeId}`)
        return;
      }
      if (row.nodeCode === 'REPORT_OUT_FINANCE_CHECK' || row.nodeCode === 'REPORT_OUT_DEPARTMENT_CHECK' || row.nodeCode === 'LETTER_OUT_FINANCE_CHECK' || row.nodeCode === 'LETTER_OUT_DEPARTMENT_CHECK') {
        this.$router.push(`/out/warehouse/check?todoBusinessId=${row.businessId}&sNo=${statementNo}&rNo=${reportNo}&tId=${row.taskId}&cId=${row.currentNodeId}&nCode=${row.nodeCode}&businessType=MAJOR_BUSINESS`)
        return;
      }
      if (row.nodeCode === 'BUSINESS_ARCHIVING') {
        this.$router.push(`/major/saveFile/waiting`)
        return;
      }
      if (row.nodeCode === 'STATEMENT_DELIVERY') {
        this.$router.push(`/major/my/order?todoBusinessId=${row.businessId}&sNo=${statementNo}&tId=${row.taskId}&cId=${row.currentNodeId}`)
        return;
      }
      if (row.nodeCode === 'STATEMENT_IN' || row.nodeCode === 'STATEMENT_OUT' ||
        row.nodeCode === 'REPORT_IN' || row.nodeCode === 'REPORT_OUT' ||
        row.nodeCode === 'LETTER_IN' || row.nodeCode === 'LETTER_OUT') {
        this.$router.push(`/major/production/in?openDialog=${true}`)
        return;
      }
      if (row.nodeCode === 'LEADER_ALLOCATION') {
        this.getAllotDepartment();
        this.getRefuseReason(row.businessId);
        this.allocationDialog = true;
        this.allocationForm.instanceNodeId = row.currentNodeId;
        this.allocationForm.id = row.businessId;
        this.allocationForm.departmentName = row.departmentName;
        return;
      }
      if (reportNo && statementNo) {
        this.$router.push(`/major/todo/detail?id=${row.businessId}&orderId=${row.orderId}&reportNo=${reportNo}&statementNo=${row.statementNo}&doWorkflow=${true}&currentNodeId=${row.currentNodeId}&currentNodeCode=${row.nodeCode}&back=${'/major/todo'}`)
      } else if (!reportNo && statementNo) {
        this.$router.push(`/major/todo/detail?id=${row.businessId}&orderId=${row.orderId}&statementNo=${row.statementNo}&doWorkflow=${true}&currentNodeId=${row.currentNodeId}&currentNodeCode=${row.nodeCode}&back=${'/major/todo'}`)
      } else if (reportNo && !statementNo) {
        this.$router.push(`/major/todo/detail?id=${row.businessId}&orderId=${row.orderId}&reportNo=${reportNo}&doWorkflow=${true}&currentNodeId=${row.currentNodeId}&currentNodeCode=${row.nodeCode}&back=${'/major/todo'}`)
      } else {
        this.$router.push(`/major/todo/detail?id=${row.businessId}&orderId=${row.orderId}&doWorkflow=${true}&currentNodeId=${row.currentNodeId}&currentNodeCode=${row.nodeCode}&back=${'/major/todo'}`)
      }
    },

    sortTable(sortParams) {
      this.listQuery.ascs = sortParams.ascs;
      this.listQuery.descs = sortParams.descs;
      this.$api.workNodeTaskRecord.majorTaskTodoList(this.listQuery).then(res => {
        if (res.code === 200) {
          this.pageData = res.data;
        }
      })
    },
    switchHeader(data) {
      this.hiddenLabels.push(data);
      setCookie("MajorTodoList-hiddenLabels", this.hiddenLabels);
    },
    showAllLabel() {
      removeCookie("MajorTodoList-hiddenLabels");
      location.reload();
    },
    fliterSearch(params) {
      this.$api.workNodeTaskRecord.majorTaskTodoList(this.listQuery).then(res => {
        if (res.code === 200) {
          this.pageData = res.data;
        }
      })
    },
    resetParams() {
      this.$router.push({ query: {} });
      this.listQuery = {
        current: 1,
        size: 10,
        descs: 'created',
      }
      this.getPage();
    },
    // 批量提交流程节点
    batchCommitNode() {
      if (this.workNodeCommits.length > 0) {
        this.$confirm('确认批量提交已选中流程?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          this.$api.workflow.batchCommit(this.workNodeCommits).then(res => {
            if (res.code === 200 && res.data) {
              this.$notify({
                title: '成功',
                message: '工作流节点批量提交成功。',
                type: 'success',
                duration: 2000
              });
              this.getPage();
              this.selectBatchCommitPage();
            } else {
              this.$notify({
                title: '失败',
                message: res.message,
                type: 'error',
                duration: 2000
              });
            }
          })
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消批量提交'
          });
        });
      } else {
        this.$notify.error({
          title: '错误',
          message: '请选择至少一条流程再提交!'
        });
      }
    },
    saveAllocation() {
      let major = new Object();
      major.id = this.allocationForm.id;
      major.departmentId = this.allocationForm.departmentId;
      let taskRecord = new Object();
      taskRecord.recordId = this.allocationForm.recordId;;
      taskRecord.taskData = major;
      this.$api.major.department(taskRecord).then(res=>{
        if (res.code === 200 && res.data){
            let commit = new Object();
            commit.instanceNodeId = this.allocationForm.instanceNodeId;
            commit.state = 'PASS';
            commit.nodeCode = 'LEADER_ALLOCATION';
            this.$api.workflow.commit(commit).then(res=>{
              if (res.code === 200 && res.data){
                this.$notify({
                    title: '成功',
                    message: '操作成功',
                    type: 'success',
                    duration: 2000
                });
                this.allocationDialog = false;
                this.getPage();
              }else{
                this.$notify({
                    title: '失败',
                    message: '操作失败',
                    type: 'error',
                    duration: 2000
                })
              }
            })
        }
      })
    },
    getAllotDepartment() {
      this.$api.department.allot('MAJOR_BUSINESS').then(res => {
        if (res.code === 200) {
          this.allotDepartment = res.data;
        }
      })
    },
    getRefuseReason(businessId){
       if (businessId){
          this.$api.workflowLog.getRefuse(businessId,'MAJOR_BUSINESS').then(res=>{
            if (res.code === 200 && res.data){
                this.allocationForm.reason = res.data.comments;
                this.allocationForm.refuseTime = res.data.created;
                this.allocationForm.refuseUser = res.data.handler;
                this.allocationForm.recordId = res.data.recordId;
            }
          })
       }
    }
  },

}



</script>
<style lang="scss" scoped>
.enableClick:hover {
  color: #1890ff;
  cursor: pointer;
}
</style>
