<template>
  <div class="main-content abnormal">
    <div class="content-body">
      <el-tabs v-model="activeName" type="border-card" class="tabs" style="font-size:unset">
        <el-tab-pane label="除名修复申请信息" name="first">
          <div class="table-title">
            <img src="../../../assets/images/icon01.png" alt="" style="width:24px;margin-right:10px">
            除名修复申请信息
          </div>
          <el-form ref="form" :model="form" label-width="190px" label-position="right" :rules="formRules">
            <div class="form">
              <div class="form-body">
                <table
                  width="100%"
                  class="apply-table"
                  style="border-collapse: collapse;"
                  border="1"
                  cellpadding="0"
                  cellspacing="0"
                >
                  <tr>
                    <th width="20%">注册号/企业统一信用代码</th>
                    <td>
                      <!-- @click="seeDetail(companyInfo.pripid)" -->
                      <el-link type="primary" style="font-size:16px">
                        {{ detailInfo.repairInfo?.uscc || '-' }}
                      </el-link>
                    </td>
                  </tr>
                  <tr><th>企业名称</th>
                    <td>
                      {{ detailInfo?.repairInfo?.entName || '-' }}
                    </td>
                  </tr>
                  <tr>
                    <th>申请时间</th>
                    <td colspan="2">{{ detailInfo?.repairInfo?.applyDate || '-' }}</td>
                  </tr>
                  <tr>
                    <th>法定代表人/经营者</th>
                    <td colspan="2">{{ detailInfo?.repairInfo?.lerepName || '-' }}</td>
                  </tr>
                  <tr>
                    <th><span style="color:red">*</span>申请人</th>
                    <td colspan="2">
                      <el-input v-model="contactName" placeholder="请输入申请人" />
                      <!-- {{ companyInfo.applicant }} -->
                    </td>
                  </tr>
                  <tr>
                    <th>除名时间</th>
                    <td>
                      {{ detailInfo?.repairInfo?.applyDate || '' }}
                    </td>
                  </tr>
                  <tr>
                    <th>除名机关</th>
                    <td>
                      {{ detailInfo?.repairInfo?.removeOrgName || '-' }}
                    </td>
                  </tr>
                  <tr>
                    <th>除名原因</th>
                    <td>
                      {{ detailInfo?.repairInfo?.removeReason || '' }}
                    </td>
                  </tr>
                </table>
                <!-- <table
                  width="100%"
                  class="apply-table"
                  style="border-collapse: collapse;"
                  border="1"
                  cellpadding="0"
                  cellspacing="0"
                >
                  <tr>
                    <th :rowspan="7" width="20%">证据材料</th>
                    <td>
                      <el-row style="border-left:0;">
                        <el-col :span="14">《除名修复申请书》</el-col>
                        <el-col :span="10">
                          <el-upload
                            :action="uploadUrl + '/attachment/saveTCLawFile.do'"
                            :on-preview="handlePreview"
                            :file-list="fileUri.file1"
                            accept=".pdf,.jpg,.png"
                            :data="uploadData(1)"
                            :before-upload="beforeUpload"
                            :on-success="handleSuccess(1)"
                            :on-remove="handleRemove(1)"
                          >
                            <el-button slot="trigger" type="primary">上传</el-button>
                          </el-upload>
                        </el-col>
                      </el-row>
                    </td>
                  </tr>
                  <tr>
                    <td v-if="fujianType === '未年报'">
                      <el-row style="border-left:0;">
                        <el-col :span="14">履行法定义务、纠正违法行为的相关材料</el-col>
                        <el-col :span="10">
                          <el-upload
                            :action="uploadUrl + '/attachment/saveTCLawFile.do'"
                            :on-preview="handlePreview"
                            :file-list="fileUri.file7"
                            accept=".pdf,.jpg,.png"
                            :data="uploadData(7)"
                            :before-upload="beforeUpload"
                            :on-success="handleSuccess(7)"
                            :on-remove="handleRemove(7)"
                          >
                            <el-button slot="trigger" type="primary">上传</el-button>
                          </el-upload>
                        </el-col>
                      </el-row>
                    </td>
                  </tr>
                  <tr>
                    <td v-if="fujianType === '实地查无'">
                      <el-row style="border-left:0;">
                        <el-col :span="14">履行法定义务、纠正违法行为的相关材料</el-col>
                        <el-col :span="10">
                          <el-upload
                            :action="uploadUrl + '/attachment/saveTCLawFile.do'"
                            :on-preview="handlePreview"
                            :file-list="fileUri.file2"
                            accept=".pdf,.jpg,.png"
                            :data="uploadData(2)"
                            :before-upload="beforeUpload"
                            :on-success="handleSuccess(2)"
                            :on-remove="handleRemove(2)"
                          >
                            <el-button slot="trigger" type="primary">上传</el-button>
                          </el-upload>
                        </el-col>
                      </el-row>
                    </td>
                  </tr>
                  <tr>
                    <td v-if="fujianType === '虚假公示'">
                      <el-row style="border-left:0;">
                        <el-col :span="10">
                          <el-upload
                            :action="uploadUrl + '/attachment/saveTCLawFile.do'"
                            :on-preview="handlePreview"
                            :file-list="fileUri.file9"
                            accept=".pdf,.jpg,.png"
                            :data="uploadData(9)"
                            :before-upload="beforeUpload"
                            :on-success="handleSuccess(9)"
                            :on-remove="handleRemove(9)"
                          >
                            <el-button slot="trigger" type="primary">上传</el-button>
                          </el-upload>
                        </el-col>
                      </el-row>
                    </td>
                  </tr>
                  <tr>
                    <td>
                      <el-row style="border-left:0;">
                        <el-col :span="14"> 补充材料</el-col>
                        <el-col :span="10">
                          <el-upload
                            :data="{
                              pripids:companyInfo.priPID,
                              bizseq:bizseq,
                              filetype:'99',
                              attachtype: '99'
                            }"
                            :action="uploadUrl + '/attachment/saveTCLawFile.do'"
                            :on-preview="handlePreview"
                            :on-remove="handleRemove(99)"
                            :on-success="handleSuccess(99)"
                            :file-list="fileUri.file99"
                            style="width:40%"
                          >
                            <el-button type="primary">点击上传</el-button>
                          </el-upload>
                        </el-col>
                      </el-row>
                    </td>
                  </tr>
                </table> -->

              </div>
            </div>
            <div v-if="htopinions.length > 0" class="form">
              <div class="form-body">
                <template v-if="htopinions && htopinions.length > 0">
                  <table
                    width="100%"
                    class="apply-table"
                    style="border-collapse: collapse;"
                    border="1"
                    cellpadding="0"
                    cellspacing="0"
                  >
                    <tr v-for="(each,index) in htopinions" :key="'historyLog'+index">
                      <th style="width: 20%;">历史退回原因</th>
                      <td colspan="3">
                        <span style="display: block;text-indent: 1em;min-height:80px">{{ each.opinioncontent }}</span>
                        <el-col :span="8" :offset="16">
                          <label style="font-size: 0.37333rem">{{ each.step }}人:</label>
                          <span>{{ each.handler }}</span>
                          <label
                            style="font-size: 0.37333rem; margin-left: 10px"
                          >{{ each.step }}日期:</label>
                          <span style="display: inline-block">{{ each.handledate }}</span>
                        </el-col>
                      </td>
                    </tr>
                  </table>
                </template>
              </div>
            </div>
            <table
              style="border-collapse: collapse;"
              border="1"
              cellpadding="0"
              cellspacing="0"
              width="100%"
              class="apply-table"
            >
              <tr>
                <th width="20%"><span style="color:red">*</span>材料审查</th>
                <td class="radio">
                  <el-radio v-model="isAccept" label="1">材料齐全</el-radio>
                  <el-radio v-model="isAccept" label="0">补正材料</el-radio>
                </td>
              </tr>
              <tr v-if="isAccept === '1'">
                <th><span style="color:red">*</span>是否予以除名修复</th>
                <td colspan="3" class="radio">
                  <el-radio v-model="isAgreeRepair" label="1" style="font-size: unset">受理</el-radio>
                  <el-radio v-model="isAgreeRepair" label="0" style="font-size: unset">不受理</el-radio>
                </td>
              </tr>
              <tr v-if="isAccept === '1' && isAgreeRepair === '1'">
                <th><span style="color:red">*</span>移出原因</th>
                <td colspan="3" class="radio">
                  <el-input v-model="repairReason" placeholder="请输入移出原因" type="textarea" />
                </td>u
              </tr>
              <tr v-if="isAgreeRepair === '0'">
                <th><span style="color:red">*</span>移出原因</th>
                <td colspan="3" class="radio">
                  <el-input v-model="repairReason" placeholder="请输入移出原因" type="textarea" />
                </td>
              </tr>
            </table>
            <div class="submit-btn-box">
              <el-button v-if="isAccept === '1'" type="primary" @click="$router.go(-1)">返回</el-button>
              <el-button v-if="isAccept === '1'" type="primary" @click="toSecond">确定</el-button>
            </div>
          </el-form>
        </el-tab-pane>
        <el-tab-pane :label="isAgreeRepair === '0'? '不予除名修复审批表':'除名修复审批表'" name="second" :disabled="apprDisable">
          <div class="table-title">
            <img src="../../../assets/images/icon01.png" alt="" style="width:24px;margin-right:10px">
            {{ isAgreeRepair === '0'? '不予除名修复审批表':'除名修复审批表' }}
          </div>
          <div>
            <table
              width="100%"
              class="apply-table"
              style="border-collapse: collapse;"
              border="1"
              cellpadding="0"
              cellspacing="0"
            >
              <tr>
                <th width="20%">名称/姓名</th>
                <td>{{ detailInfo?.repairInfo?.entName || '-' }}</td>
                <th width="20%">注册号/企业统一信用代码</th>
                <td>{{ detailInfo.repairInfo?.uscc || '-' }}</td>
              </tr>
              <tr>
                <th><span style="color:red">*</span>作出决定的事实、理由、依据及主要内容</th>
                <td colspan="3">
                  <el-input v-model="formData.remreasons" type="textarea" :autosize="{ minRows: 4}" maxlength="500" show-word-limit placeholder="请输入作出决定的事实、理由、依据及主要内容" style="width:100%" />
                </td>
              </tr>
              <template v-if="historyLog && historyLog.length > 0">
                <tr v-for="(each,index) in historyLog" :key="'historyLog'+index">
                  <th>{{ each.label }}</th>
                  <td colspan="3">
                    <span style="display: block;text-indent: 1em;min-height:80px">{{ each.opinioncontent }}</span>
                    <el-col :span="8" :offset="16">
                      <label style="font-size: 0.37333rem">{{ each.step }}人:</label>
                      <span>{{ each.handler }}</span>
                      <label
                        style="font-size: 0.37333rem; margin-left: 10px"
                      >{{ each.step }}日期:</label>
                      <span style="display: inline-block">{{ each.handledate }}</span>
                    </el-col>
                  </td>
                </tr>
              </template>
              <!-- 移出主体名单 -->
              <tr v-if="tranferRecord.length > 0">
                <th>转办记录</th>
                <td v-for="item,index in tranferRecord" :key="item.handler" colspan="3">
                  {{ item.operOpinion }}
                  <el-row style="text-align: right;border: unset">
                    转办人：<span style="display:inline-block;text-align: left;">{{ item.handler }}  </span>
                    转办机关：<span style="display:inline-block;text-align: left;">{{ orgName[index] }}  </span>
                    转办日期：<span style="display:inline-block;text-align: left;">{{ item.handledate }}  </span>
                  </el-row>
                </td>
              </tr>
              <tr>
                <th><span style="color:red">*</span>经办人意见</th>
                <td colspan="3">
                  <el-input v-model="formData.opinion" type="textarea" :autosize="{ minRows: 2}" placeholder="1000字内" style="width:100%" />
                </td>
              </tr>
              <tr>
                <th>备注</th>
                <td colspan="3">
                  <el-input v-model="remRemark" type="textarea" style="width:100%" />
                </td>
              </tr>
              <tr>
                <th><span style="color:red">*</span>审核人</th>
                <td colspan="3">
                  <el-select v-model="formData.nextPerformerids" placeholder="请选择审核人" filterable class="custom" style="width:30%">
                    <el-option
                      v-for="item in reviewer"
                      :key="'reviewer'+item.primaryKey"
                      :label="item.name"
                      :value="item.primaryKey"
                    />
                  </el-select>
                </td>
              </tr>

            </table>
            <div class="submit-btn-box">
              <el-button type="primary" :loading="submitLoading" @click="submitExamine">提交</el-button>
              <el-button @click="activeName = 'first'">返回</el-button>
            </div>
          </div>
        </el-tab-pane>
      </el-tabs>
    </div>
    <HandleDialog :show.sync="showEntbase" title="异常主体名单" style="width:50vw">
      <el-table
        :data="dataShow"
        tooltip-effect="dark"
        style="width: 1200px"
        :fit="true"
        height="500px"
        :row-class-name="tableRowClassName"
        :header-cell-style="{background:'#8cc3fb',color:'#fff'}"
        @selection-change="handleSelectionChange"
      >
        <el-table-column class="no" type="selection" min-width="20" />
        <el-table-column prop="index" label="序号" min-width="35" align="center" />
        <el-table-column prop="uscc" label="统一社会信用代码/注册号" min-width="150" align="left" />
        <el-table-column prop="entname" :show-overflow-tooltip="true" label="名称" min-width="150" align="left" />
        <el-table-column prop="estdate" :show-overflow-tooltip="true" label="成立时间" align="left" />
        <el-table-column prop="dom" :show-overflow-tooltip="true" label="经营地址" min-width="150" align="left" />
        <el-table-column prop="name" label="法定代表人" align="left" />
        <el-table-column prop="enttypeCn" :show-overflow-tooltip="true" label="企业类型" min-width="150" align="left" />
      </el-table>
      <div>
        <el-row class="bl0">
          <el-col>
            <el-pagination
              :current-page="currentPage"
              small
              layout="prev, pager, next"
              :total="total"
              @size-change="handleSizeChange"
              @current-change="handleCurrentChange"
            />
          </el-col>
        </el-row>
        <div class="dialog-box">
          <el-button type="primary" @click="showEntbaseList">确定</el-button>
        </div>
      </div>
    </HandleDialog>
  </div>
</template>

<script>
import HandleDialog from '@/components/HandleDialog'
import { removeAttachementById, listAttachmentByBizseq } from '@/api/attachment'
import { abnRemTransfer, bizRemoveNext, removeBizRemListBySplistid, getBizRemoveRecordList, returnToApplyer, addrRemovCheck, checknb, getaicepsYbList, geteGtAlterRecoderList
} from '@/api/abnormal'
import { getUsersWithPermission } from '@/api/user'
import { validBeforeUpload } from '@/api/fileUpload'
import { taskOpinion } from '@/api/task'
import { getNewestOpinion } from '@/api/credit'
import { expelledRepairNextBiz, expelledRepairGetBiz } from '@/api/除名公告'
import { isMenHu } from '@/utils/utils'

export default {
  components: {
    HandleDialog: HandleDialog
  },
  data() {
    return {
      detailInfo: {},
      contactName: '', // 申请人
      repairReason: '', // 移出原因
      orgName: [],
      tranferRecord: [],
      tranferData: {},
      tranferReason: '', // 转办原因
      transferOrg: '', // 转办机关码值
      htopinions: [], // 回退到移动端意见
      addrRemovFlag: '',
      row: '',
      fujianType: '',
      backProposal: '',
      remRemark: '',
      submitLoading: false,
      entname: '',
      removeRecordList: [],
      aicepsList: [], // 年报记录
      eGtAlterRecoderList: [], // 变更记录
      uploadPath: `${process.env.VUE_APP_BASE_API}/attachment/uploadAdvance`,
      uploadUrl: process.env.VUE_APP_BASE_API,
      showEntbase: false,
      bizseq: '',
      workflowId: '',
      tasklistid: '',
      entbase: [], // 主体名单列表
      totalPageData: [],
      // 共几页
      pageNum: '',
      // 每页显示数量
      pageSize: 10,
      // 当前显示页码
      currentPage: 1,
      // 总共多少条数据
      total: 1,
      // 当前要显示的数据
      dataShow: [],
      // 选中数组
      multipleSelection: [],
      form: {
        enterType: 'company',
        remreasons: '',
        repairReason: '',
        remRemark: '',
        opinion: ''
      },
      formRules: {
        repairReason: [
          { required: true, message: '请选择移出原因', trigger: 'blur' }
        ],
        opinion: [
          { required: true, message: '请输入经办意见', trigger: ['blur', 'change'] }
        ],
        reviewerId: [
          { required: true, message: '请选择审核人' }
        ]
      },
      reason: '',
      opinion: '',
      reasonOptions: [],
      inclueReasonOptions: [],
      opinionOptions: [],
      historyLog: [],
      exmainerOptions: [],
      fileList: [],
      user: JSON.parse(sessionStorage.getItem('user')),
      reviewer: [],
      activeName: 'first',
      isAgreeRepair: '',
      // 「材料审查结果」的标识：'1'= 材料齐全，'0'= 补正材料
      isAccept: '1',
      companyInfo: {},
      repairType: '',
      dialogTitle: '',
      type: '',
      firstEnt: {},
      isClear: false,
      eidtContent: '',
      tswrittemplate: {
        bizseq: '',
        writsType: '',
        isTemplate: '',
        type: ''
      },
      formData: {
        // lostCreditExplainrem: '根据《市场监督管理信用修复管理办法》第七条要求，当事人被列入严重违法失信名单满一年，且符合下列情形的，可以依照本办法规定申请信用修复：（一）已经自觉履行行政处罚决定中规定的义务；（二）已经主动消除危害后果和不良影响；（三）未再受到市场监督管理部门较重行政处罚。依照法律、行政法规规定，实施相应管理措施期限尚未届满的，不得申请提前移出。',
        lostCreditExplainrem: '',
        remRemark: '',
        operOpinion: '',
        opinion: '',
        nextPerformerids: '',
        remreasons: ''
      },
      // 意见-经办人
      handleOpinion: {
        handler: '',
        handleDate: '',
        opinionContent: ''
      },
      // 意见-审核人
      reviewOpinion: {
        handler: '',
        handleDate: '',
        opinionContent: ''
      },
      // 意见-审批人
      approvalOpinion: {
        handler: '',
        handleDate: '',
        opinionContent: ''
      },
      fileUri: {
        file1: []
      },
      specause: '',
      specauseType: '',
      applicant: '',
      contentText: '',
      endReason: '',
      nb: '否',
      tsabnlist: ''
    }
  },
  computed: {
    uploadData() {
      return (index) => {
        return {
          filetype: index,
          attachtype: index,
          bizseq: this.bizseq,
          pripids: this.companyInfo.priPID
        }
      }
    },
    apprDisable() {
      if (this.isAccept === '1') {
        if (this.$util.isNotEmpty(this.isAgreeRepair)) {
          if (this.isAgreeRepair === '0') {
            return false
          } else if (this.isAgreeRepair === '1') {
            if (this.$util.isNotEmpty(this.reason)) {
              return false
            }
          }
        }
      }
      return true
    }
  },
  watch: {
    isAccept: {
      handler(newMsg, oldMsg) {
        if (newMsg === '1') {
          this.isAgreeRepair = '1'
        } else if (newMsg === '0') {
          this.isAgreeRepair = ''
        }
      },
      immediate: true
    }
  },
  mounted() {
    this.bizId = this.$route.query.bizId
    expelledRepairGetBiz(this.bizId).then(res => {
      if (res.code === 0) {
        this.detailInfo = res.data
        console.log(res.data.tsTaskList)
        this.workflowId = res.data.tsTaskList.workflowid
        // 加载处办记录
        taskOpinion(this.workflowId).then(res => {
          if (res.code === 0) {
            res.data.forEach(each => {
              switch (each.opiniontype) {
                case '0':
                  each.step = '经办'
                  each.label = '经办人意见'
                  break
                case '1':
                  each.step = '审核'
                  each.label = '部门负责人意见'
                  break
                case '2':
                  each.step = '审批'
                  each.label = '经办机构负责人意见'
                  break
                case '9':
                  each.step = '经办'
                  each.label = '经办人意见'
                  break
              }
              if (each.opiniontype !== '9') {
                this.historyLog.push(each)
              } else {
                this.htopinions.push(each)
                this.historyLog.push(each)
              }
            })
          } else {
            this.$message.error('加载意见记录失败')
          }
        })
      }
    })

    // 加载审核人
    this.loadReviewer()

    this.loadAttachmentList()
  },
  methods: {
    isnb(abnlistid) {
      checknb(abnlistid).then(res => {
        if (res.data) {
          this.nb = '是'
        }
      })
    },
    // 跳转企业详情页面新窗口
    seeDetail(pripid) {
      if (window.parent) {
        window.open(window.parent.location.origin + '/aiccs/#/comprehensive/details?pripid=' + pripid + '&shrink=true', '_blank')
      }
    },
    toSecond() {
      if (this.$util.isEmpty(this.isAccept)) {
        return this.$message.warning('请选择材料审查结果')
      }
      if (this.$util.isEmpty(this.isAgreeRepair)) {
        return this.$message.warning('请选择是否予以信用修复')
      }
      if (this.$util.isEmpty(this.repairReason)) {
        return this.$message.warning('请选择移出原因')
      }
      if (this.$util.isEmpty(this.contactName)) {
        return this.$message.warning('请输入申请人')
      }
      this.activeName = 'second'
    },
    tableRowClassName({ row, rowIndex }) {
      if (rowIndex % 2 === 1) {
        return 'warning-row'
      }
    },
    downLoadTemp(type) {
      let name = ''
      switch (parseInt(type)) {
        case 1: name = 'repairApply1.pdf'; break
        case 2: name = 'repairApply2.pdf'; break
        case 3: name = 'repairApply3.pdf'; break
        case 4: name = 'repairApply4.pdf'; break
        case 5: name = 'repairApply5.pdf'; break
        case 7: name = 'repairApply7.pdf'; break
        case 8: name = 'repairApply8.pdf'; break
        case 10: name = 'repairApply10.pdf'; break
        case 11: name = 'repairApply11.pdf'; break
        case 20: name = 'repairApply20.pdf'; break
        case 21: name = 'repairApply21.pdf'; break
      }
      window.open(process.env.NODE_ENV === '"development"' ? `/${name}` : `/crss/${name}`)
    },
    // 加载附件清单
    loadAttachmentList() {
      listAttachmentByBizseq(this.bizseq).then(data => {
        this.fileUri.file1 = data.filter((item) => {
          return item.filetype === '1'
        }).map((item) => {
          return {
            ...item,
            id: item.attachmentid,
            name: item.filename,
            url: `${process.env.VUE_APP_DOWNLOAD_URL}/${item.temppath}`
          }
        })
        this.fileUri.file2 = data.filter((item) => {
          return item.filetype === '2'
        }).map((item) => {
          return {
            ...item,
            id: item.attachmentid,
            name: item.filename,
            url: `${process.env.VUE_APP_DOWNLOAD_URL}/${item.temppath}`
          }
        })
        this.fileUri.file3 = data.filter((item) => {
          return item.filetype === '3'
        }).map((item) => {
          return {
            ...item,
            id: item.attachmentid,
            name: item.filename,
            url: `${process.env.VUE_APP_DOWNLOAD_URL}/${item.temppath}`
          }
        })
        this.fileUri.file4 = data.filter((item) => {
          return item.filetype === '4'
        }).map((item) => {
          return {
            ...item,
            id: item.attachmentid,
            name: item.filename,
            url: `${process.env.VUE_APP_DOWNLOAD_URL}/${item.temppath}`
          }
        })
        this.fileUri.file5 = data.filter((item) => {
          return item.filetype === '5'
        }).map((item) => {
          return {
            ...item,
            id: item.attachmentid,
            name: item.filename,
            url: `${process.env.VUE_APP_DOWNLOAD_URL}/${item.temppath}`
          }
        })
        this.fileUri.file6 = data.filter((item) => {
          return item.filetype === '6'
        }).map((item) => {
          return {
            ...item,
            id: item.attachmentid,
            name: item.filename,
            url: `${process.env.VUE_APP_DOWNLOAD_URL}/${item.temppath}`
          }
        })
        this.fileUri.file7 = data.filter((item) => {
          return item.filetype === '7'
        }).map((item) => {
          return {
            ...item,
            id: item.attachmentid,
            name: item.filename,
            url: `${process.env.VUE_APP_DOWNLOAD_URL}/${item.temppath}`
          }
        })
        this.fileUri.file8 = data.filter((item) => {
          return item.filetype === '8'
        }).map((item) => {
          return {
            ...item,
            id: item.attachmentid,
            name: item.filename,
            url: `${process.env.VUE_APP_DOWNLOAD_URL}/${item.temppath}`
          }
        })
        this.fileUri.file9 = data.filter((item) => {
          return item.filetype === '9'
        }).map((item) => {
          return {
            ...item,
            id: item.attachmentid,
            name: item.filename,
            url: `${process.env.VUE_APP_DOWNLOAD_URL}/${item.temppath}`
          }
        })
        this.fileUri.file10 = data.filter((item) => {
          return item.filetype === '10'
        }).map((item) => {
          return {
            ...item,
            id: item.attachmentid,
            name: item.filename,
            url: `${process.env.VUE_APP_DOWNLOAD_URL}/${item.temppath}`
          }
        })
        this.fileUri.file88 = data.filter((item) => {
          return item.filetype === '88'
        }).map((item) => {
          return {
            ...item,
            id: item.attachmentid,
            name: item.filename,
            url: `${process.env.VUE_APP_DOWNLOAD_URL}/${item.temppath}`
          }
        })
        // 弄虚作假两类文件展示归为一类
        this.fileUri.file10.forEach(each => {
          this.fileUri.file9.push(each)
        })
        this.fileUri.file99 = data.filter((item) => {
          return !['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '88'].includes(item.filetype)
        }).map((item) => {
          return {
            ...item,
            id: item.attachmentid,
            name: item.filename,
            url: `${process.env.VUE_APP_DOWNLOAD_URL}/${item.temppath}`
          }
        })
      })
    },
    // 获取最新经办意见
    getHandleOpinion(workflowid, opinionType) {
      getNewestOpinion(workflowid, opinionType).then(res => {
        if (res.code === 0 && res.data !== null) {
          this.handleOpinion.opinionContent = res.data.opinioncontent
          this.handleOpinion.handler = res.data.handler
          this.handleOpinion.handleDate = this.$util.formatDate.format(new Date(Date.parse(res.data.handledate)), 'yyyy-MM-dd hh:mm:ss')
          this.$nextTick(() => {
            this.$set(this.formData, 'opinion', res.data.opinioncontent)
            this.$set(this.formData, 'handledate', res.data.handledate)
          })
        }
      })
    },
    // 获取最新审核意见
    getReviewOpinion(workflowid, opinionType) {
      getNewestOpinion(workflowid, opinionType).then(res => {
        if (res.code === 0 && res.data !== null) {
          this.reviewOpinion.opinionContent = res.data.opinioncontent
          this.reviewOpinion.handler = res.data.handler
          this.reviewOpinion.handleDate = this.$util.formatDate.format(new Date(Date.parse(res.data.handledate)), 'yyyy-MM-dd hh:mm:ss')
        }
      })
    },
    // 获取最新审批意见
    getApprovalOpinion(workflowid, opinionType) {
      getNewestOpinion(workflowid, opinionType).then(res => {
        if (res.code === 0 && res.data !== null) {
          this.approvalOpinion.handler = res.data.handler
          this.approvalOpinion.handleDate = this.$util.formatDate.format(new Date(Date.parse(res.data.handledate)), 'yyyy-MM-dd hh:mm:ss')
          this.approvalOpinion.opinionContent = res.data.opinioncontent
        }
      })
    },

    getTextVal(res) {
      this.contentText = res
    },
    backToApplyer() {
      this.submitLoading = true
      const data = {
        tasklistid: this.tasklistid,
        bizSeq: this.bizseq,
        backProposal: this.backProposal,
        handler: this.user.nickname,
        handlerid: this.user.primaryKey
      }
      returnToApplyer(data).then(res => {
        this.submitLoading = false
        if (res.data === true) {
          this.$message.success('提交成功')
          if (isMenHu()) {
            // 信创门户环境跳转回待办
            window.location.href = '/aiccs/#/todo/list'
          } else {
            this.$router.back()
          }
        } else {
          this.$message.error('提交失败，' + res.msg)
        }
      })
    },
    verificationPicFile(file) {
      const fileTypes = ['.jpg', '.png', '.pdf']
      if (file.name) {
        const fileEnd = file.name.substring(file.name.lastIndexOf('.'))
        return fileTypes.includes(fileEnd)
      } else {
        return false
      }
    },
    handleSuccess(index) {
      return (res, file) => {
        if (res.code === 0) {
          const data = res.data[0]
          file.id = data.attachmentid
          file.url = process.env.VUE_APP_DOWNLOAD_URL + '/' + data.temppath
          this.fileUri[`file${index}`].push(file)
        }
      // this.loadAttachmentList()
      }
    },
    beforeUpload(file) {
      if (!this.verificationPicFile(file)) {
        this.$message.error('上传格式不支持，请重新上传')
        return false
      } else {
        return true
      }
    },
    handlePreview(file) {
      if (['.jpg', '.png', '.jpeg', '.bmp'].includes(file.fileext)) {
        let fileList = []
        switch (file.filetype) {
          case '1': fileList = this.fileUri.file1; break
          case '2': fileList = this.fileUri.file2; break
          case '3': fileList = this.fileUri.file3; break
          case '4': fileList = this.fileUri.file4; break
          case '5': fileList = this.fileUri.file5; break
          case '6': fileList = this.fileUri.file6; break
          case '7': fileList = this.fileUri.file7; break
          case '8': fileList = this.fileUri.file8; break
          case '9': fileList = this.fileUri.file9; break
          case '10': fileList = this.fileUri.file10; break
          case '88': fileList = this.fileUri.file88; break
          default: fileList = this.fileUri.file99; break
        }
        const imges = []
        let index = 0
        let indextemporary = 0
        for (let i = 0; i < fileList.length; i++) {
          if (['.jpg', '.png', '.jpeg', '.bmp'].includes(fileList[i].fileext)) {
            imges.push(fileList[i].url)
            if (file.id === fileList[i].id) {
              index = indextemporary
            }
            // 下一张图片的下标
            indextemporary++
          }
        }
        this.$hevueImgPreview({
          multiple: true, // 开启多图预览模式
          nowImgIndex: index, // 多图预览，默认展示第几张图片
          imgList: imges
        })
      } else {
        window.open(file.url)
      }
    },
    handleRemove(index) {
      return (file, fileList) => {
        removeAttachementById(file.id).then(res => {
          if (res.code === 0) {
            this.$message.success('删除成功')
            this.fileUri[`file${index}`].splice(this.fileUri[`file${index}`].indexOf(file), 1)
          }
        })
      }
    },
    // 上传文件之前校验大小
    beforeFileUpload(file) {
      var that = this
      return validBeforeUpload(file, that)
    },
    // 移除文件前
    beforeRemove(file, fileList) {
      if (file && file.status === 'success') {
        return this.$confirm(`确定移除 ${file.name} ？`)
      }
    },
    // 计算页数
    calcPageData() {
      // 计算页数(根据后台数据的条数和每页显示数量算出一共几页,得0时设为1)
      if (this.entbase.length >= 1) {
        this.pageNum = Math.ceil(this.entbase.length / this.pageSize) || 1
      }
      // 数据分组
      for (let i = 0; i < this.pageNum; i++) {
        // 每一页都是一个数组 形如 [['第一页的数据'],['第二页的数据'],['第三页数据']]
        // 根据每页显示数量 将后台的数据分割到 每一页,假设pageSize为5， 则第一页是1-5条，即slice(0,5)，第二页是6-10条，即slice(5,10)...
        this.totalPageData[i] = this.entbase.slice(this.pageSize * i, this.pageSize * (i + 1))
      }
      // 获取到数据后显示第一页内容,数组下标是从0开始的，这里一定要减去1，不然会丢失一组数据
      this.dataShow = this.totalPageData[this.currentPage - 1]
    },
    // 每页条数发生变化
    handleSizeChange(newPageSize) {
      this.pageSize = newPageSize
      // 重新计算页数并分组
      this.calcPageData()
    },
    // 当前页码发生变化
    handleCurrentChange(newPageNum) {
      this.currentPage = newPageNum
      // 这里仍然不要忘记减去1
      this.dataShow = this.totalPageData[newPageNum - 1]
    },

    handleSelectionChange(val) {
      this.multipleSelection = val
    },

    // 上传文件预览
    previewFile(file) {
      window.open(file.url, '_blank')
    },
    tranferProcess() {
      this.submitLoading = true
      if (this.isAgreeRepair === '3') {
        if (this.$util.isEmpty(this.transferOrg)) {
          this.submitLoading = false
          return this.$message.error('请选择转办机关')
        }
        if (this.$util.isEmpty(this.tranferReason)) {
          this.submitLoading = false
          return this.$message.error('请输入结束原因')
        }
      }
      this.formData.remlistid = this.companyInfo.remlistid
      this.formData.enttype = this.tsabnlist.enttype
      this.formData.tasklistid = this.tasklistid
      this.formData.transferOrg = this.transferOrg
      this.formData.opinion = this.tranferReason
      abnRemTransfer(this.formData).then(res => {
        this.submitLoading = false
        if (res.code === 0) {
          if (res.data.flag == 'success') {
            this.$message.success('提交成功')
            if (isMenHu()) {
              // 信创门户环境跳转回待办
              console.log(res, 'hhh')
              window.location.href = '/aiccs/#/todo/list'
            } else {
              this.$router.back()
            }
          } else if (res.data.flag === 'error') {
            this.$message.error('提交失败，' + res.msg)
          }
        } else {
          this.$message.error('提交失败，' + res.msg)
        }
      })
    },
    submitExamine() {
      this.submitLoading = true
      if (this.isAccept === '0' && this.$util.isEmpty(this.backProposal)) {
        this.submitLoading = false
        return this.$message.error('请输入退回原因')
      }
      if (this.isAccept === '1' && this.$util.isEmpty(this.formData.remreasons)) {
        this.submitLoading = false
        return this.$message.error('请输入作出决定的事实、理由、依据及主要内容')
      }
      if (this.isAccept === '1' && this.formData.remreasons.length > 500) {
        this.submitLoading = false
        return this.$message.warning('作出决定的事实、理由长度不大于500！')
      }
      if (this.isAccept === '1' && this.$util.isEmpty(this.formData.opinion)) {
        this.submitLoading = false
        return this.$message.error('请输入经办人意见')
      }
      if (this.isAccept === '1' && this.$util.isEmpty(this.repairReason) && this.isAgreeRepair === '1') {
        this.submitLoading = false
        return this.$message.error('请选择移出原因')
      }
      if (this.isAccept === '1' && this.$util.isEmpty(this.formData.nextPerformerids)) {
        this.submitLoading = false
        return this.$message.error('请选择审核人')
      }
      if (this.isAccept === '0') {
        this.formData.nextPerformerids = this.user.primaryKey
        this.formData.nextPerformerNames = this.user.username
      } else {
        for (const i in this.reviewer) {
          if (this.reviewer[i].primaryKey === this.formData.nextPerformerids) {
            this.formData.nextPerformerNames = this.reviewer[i].name
          }
        }
      }
      this.formData.nextNodeID = 'handleExptlist'
      this.formData.opinioncontent = this.formData.opinion
      if (this.isAgreeRepair === '1') {
        this.formData.remexcpres = this.reason
      }
      if (this.$util.isNotEmpty(this.remRemark)) {
        this.formData.remRemark = this.remRemark
      } else {
        this.formData.remRemark = ''
      }
      const params = {
        bizId: this.bizId,
        taskId: this.detailInfo.tsTaskList.tasklistid,
        nextNodeId: 'handleExptlist',
        nextPerformerIds: this.formData.nextPerformerids,
        nextPerformerNames: this.formData.nextPerformerNames,
        repairApproveInfo: this.detailInfo.repairInfo,
        opinionQuery: {
          acceptStatus: this.isAccept,
          isAgreeRepair: this.isAgreeRepair,
          contactName: this.contactName,
          repairReason: this.repairReason,
          remreasons: this.formData.remreasons,
          opinion: this.formData.opinion,
          remRemark: this.remRemark
        }
      }
      expelledRepairNextBiz(params).then(res => {
        this.submitLoading = false
        if (res.code === 0) {
          this.$message.success('提交成功')
          if (isMenHu()) {
            // 信创门户环境跳转回待办
            window.location.href = '/aiccs/#/todo/list'
          } else {
            this.$router.back()
          }
        } else {
          this.$message.error('提交失败，' + res.msg)
        }
      }).catch(() => {
        this.submitLoading = false
      })
    },
    uploadCallback(res, file) {
      if (res.code === 0) {
        file.id = res.data.attachmentid
      }
    },
    // 查看异常主体名单
    showEntbaseList() {
      this.showEntbase = !this.showEntbase
    },
    // 移除文件回调
    removeFile(file) {
      if (file && file.status === 'success') {
        removeAttachementById(file.id).then(res => {
          if (res.code === 0) {
            this.$message.success('删除成功')
          } else {
            this.$message.error(res.msg)
          }
        })
      }
    },
    // 加载审核人
    loadReviewer() {
      getUsersWithPermission('', this.user.orgId).then(res => {
        if (res.code === 0) {
          this.reviewer = res.data
        }
      })
    }
  }
}
</script>
<style lang="scss">
.tabs {
  .el-tabs__item {
    font-size: initial;
  }
}
.reasonOptions {
  .el-scrollbar .el-select-dropdown__wrap {
   max-height: 300px;
 }
}
</style>
<style lang="scss" scoped>
/deep/.el-table .warning-row {
  background: #eaf4fe!important;
}
.el-upload{
  /deep/ .el-icon-close-tip{
    display: none!important;
  }
}
.table-title{
  width: 100%;
  margin-top: 10px;
  padding: 15px;
  display: flex;
  align-items: center;
  font-weight: 600;
  background: #fff;
  font-size: $table-title-font-size;
  color:#333;
  border-bottom: 1px solid #E5E5E5;
}
.main-content{
  padding: 10pt;
  font-size: $table-content-font-size;
  .back-btn{
    margin-top: 6px;
    position:absolute;
    right:40pt;
  }
  .content-body{
    background: white;
    border:1PX solid #eee;
  }
  .content-header{
    background: white;
    height:50PX;
    border:1PX solid #eee;
    display: flex;
    align-items: center;
    .title{
      font-weight: 600;
      font-size: 1rem;
    }
  }
  .content-body{
    .tab{
      .tab-title{
        label{
          background: $color-primary;
          display:inline-block;
          color:$color-title-color;
          padding:5px;
        }
      }
    }
    .form{
      margin-bottom: 20pt;
    }
  }
  .apply-table{
    padding:15px;
    margin-bottom: 30px;
    border-color: $color-border;
    tr{
      width:100%
    }
    th,td{
      font-size:$table-title-font-size;
      padding:15px
    }
    th{
      color: #666;
      font-weight: normal;
      background: $color-form-label;
      text-align: $text-algin-right;
      font-size:$table-title-font-size;
    }
    td{
      text-align: $text-algin-left;
    }
    .radio{
      .el-radio__label {
        font-size: unset;
      }
    }
  }
}
.el-row {
  border-left: 1px solid $color-border;
}
.bt0 {
  /deep/.el-form-item__label{
    border-top: 0!important;
  }
  /deep/.el-form-item__content{
    border-top: 0!important;
  }
}
.submit-btn-box {
  text-align: center;
}
</style>
<style lang="scss">
.main-content.abnormal{
  .el-form-item{
    margin-bottom:0;
    background: $color-form-label;
    .el-form-item__label{
      padding-left: 10px;
      border-top: 1px solid $color-border;
      font-size: $table-content-font-size;
    }
    .el-form-item__content{
      background: white;
      padding: 10px;
      font-size: $table-content-font-size;
      border-top: 1px solid $color-border;
      border-right: 1px solid $color-border;
      border-left: 1px solid $color-border;
    }
  }
  .el-form-item:last-child{
    border-bottom: 1px solid $color-border;
  }
  .form-body.history{
    padding:15px;
    border:1px solid $color-border;
  }
  .el-form-item.is-error .custom .el-input__inner{
    border-color:$color-border;
  }
  .el-table-column--selection .cell {
    padding-right: 0px;
  }
  .no {
    padding-left: 0px;
  }
  .el-table_9_column_61.is-left.is-leaf{
    .cell{
      padding-left: 0px;
      padding-right: 0px;
    }
  }
  .el-pagination{
    text-align: right;
  }
  .dialog-box{
    text-align: right;
  }
  .el-textarea.is-disabled .el-textarea__inner{
    color: #1c1e23;
  }
  .el-input__inner{
    margin-bottom: 5px;
  }
  .uploadFileList{
    .el-upload-list__item{
      display: inline-block;
      width: auto;
    }
  }
    .radio{
    .el-radio__label {
      font-size: unset;
    }
    .el-radio__input.is-disabled+span.el-radio__label {
      color: unset;
    }
    .el-radio__input.is-disabled.is-checked .el-radio__inner {
      background-color: #409EFF;
      border-color: #409EFF;
    }
  }
}
</style>
