<template>
  <div class="main-content credit">
    <el-row style="background: #fff;">
      <el-col :span="12">
        <div class="table-title">
          <img src="../../../assets/images/icon01.png" alt="" style="width:24px;margin-right:10px">
          {{ acceptStatus === '1'? '除名撤销审批表':'不予除名撤销审批表' }}
        </div>
      </el-col>
      <el-col :span="12">
        <div class="title-btn">
          <el-button type="primary" @click="entInfoDialog = true">企业填报信息</el-button>
        </div>
      </el-col>
    </el-row>
    <div class="content-body">
      <div>
        <table
          width="100%"
          class="apply-table"
          style="border-collapse: collapse;"
          border="1"
          cellpadding="0"
          cellspacing="0"
        >
          <tr>
            <th width="20%">名称/姓名</th>
            <td>{{ companyInfo?.revokeInfo?.entName || '-' }}</td>
            <th width="20%">注册号/企业统一信用代码</th>
            <td>{{ companyInfo?.revokeInfo?.uscc || '-' }}</td>
          </tr>
          <tr>
            <th>作出决定的事实、理由、依据及主要内容</th>
            <td colspan="3">
              <span style="display: block;text-indent: 1em;min-height:80px">{{ companyInfo?.revokeInfo?.situation || '-' }}</span>
            </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>{{ each.step }}人:</label>
                  <span>{{ each.handler }}</span>
                  <label
                    style="margin-left: 10px"
                  >{{ each.step }}日期:</label>
                  <span style="display: inline-block">{{ each.handledate }}</span>
                </el-col>
              </td>
            </tr>
          </template>
        </table>

        <div v-if="specauseType === 'nb'" class="form">
          <div class="table-title">
            <img src="../../../assets/images/icon01.png" alt="" style="width:24px;margin-right:10px">
            年报记录
          </div>
          <div class="form-body history">
            <div v-if="aicepsList.length == 0" class="none">暂无年报记录</div>
            <el-table v-else :data="aicepsList" border style="width: 100%">
              <el-table-column type="index" label="序号" width="80" align="center" />
              <el-table-column prop="entname" label="市场主体名称" min-width="100" />
              <el-table-column prop="registno" label="社会统一信用代码/注册号" min-width="200" />
              <el-table-column prop="reportyear" label="填报年份" min-width="100" />
              <el-table-column prop="registdate" label="填报时间" min-width="100" />
            </el-table>
          </div>
        </div>

        <div v-if="specauseType === 'sd'" class="form">
          <div class="table-title">
            <img src="../../../assets/images/icon01.png" alt="" style="width:24px;margin-right:10px">
            变更记录
          </div>
          <div class="form-body history">
            <div v-if="eGtAlterRecoderList.length == 0" class="none">暂无变更记录</div>
            <el-table v-else :data="eGtAlterRecoderList" border style="width: 100%">
              <el-table-column type="index" label="序号" width="80" align="center" />
              <el-table-column prop="altitemCn" label="变更事项" min-width="100" />
              <el-table-column prop="altbe" label="变更前" min-width="200" />
              <el-table-column prop="altaf" label="变更后" min-width="100" />
              <el-table-column prop="altdate" label="变更时间" min-width="100" />
            </el-table>
          </div>
        </div>

        <table
          width="100%"
          class="apply-table"
          style="border-collapse: collapse;"
          border="1"
          cellpadding="0"
          cellspacing="0"
        >
          <tr>
            <th><span style="color:red">*</span>经办机构负责人意见</th>
            <td colspan="3">
              <el-row style="margin-bottom:10px">
                <el-col :span="24" style="margin-bottom:10px">
                  <el-input v-model="formData.opinion" type="textarea" :autosize="{ minRows: 2}" placeholder="请输入审核意见" style="width:100%" />
                </el-col>
                <el-col :span="12">
                  <label>常用语：</label>
                  <el-select v-model="opinion" size="mini" placeholder="请选择" class="custom">
                    <el-option
                      v-for="item in opinionOptions"
                      :key="item.value"
                      :label="item.label"
                      :value="item.value"
                    />
                  </el-select>
                </el-col>
                <el-col :span="11" :offset="1">
                  <label>审核人:</label>
                  <span>{{ user.nickname }}</span>
                  <label
                    style="margin-left: 10px"
                  >审核日期:</label>
                  <el-date-picker
                    v-model="formData.handledate"
                    style="display: inline-block"
                    :clearable="false"
                    value-format="yyyy-MM-dd HH:mm:ss"
                    format="yyyy-MM-dd HH:mm:ss"
                    size="small"
                    type="datetime"
                    placeholder="选择日期"
                  />
                </el-col>
              </el-row>
            </td>
          </tr>
          <tr>
            <th>备注</th>
            <td colspan="3">
              <span>{{ companyInfo?.revokeInfo?.remark || '-' }}</span>
            </td>
          </tr>
          <tr>
            <th>
              <span style="color:red">*</span>是否审核通过
            </th>
            <td colspan="3">
              <el-radio-group v-model="formData.nextNodeId">
                <el-radio label="approvelist">通过</el-radio>
                <el-radio label="exptlistEnter">回退</el-radio>
              </el-radio-group>
            </td>
          </tr>
          <tr v-if="formData.nextNodeId === 'approvelist'">
            <th><span style="color:red">*</span>审批人</th>
            <td colspan="3">
              <el-select v-model="formData.nextPerformerIds" placeholder="请选择审批人" filterable 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>
        </div>
      </div>
    </div>
    <el-dialog
      title="企业填报信息"
      :visible.sync="entInfoDialog"
      :close-on-click-modal="false"
      width="60%"
      class="infoDialog"
    >
      <table
        width="100%"
        class="apply-table"
        style="border-collapse: collapse;"
        border="1"
        cellpadding="0"
        cellspacing="0"
      >
        <tr><th>企业名称</th><td>{{ companyInfo?.revokeInfo?.entName || '-' }}</td></tr>
        <tr>
          <th width="20%">统一社会信用代码/注册号</th>
          <td>{{ companyInfo?.revokeInfo?.uscc || '-' }}</td>
        </tr>
        <tr>
          <th width="20%">法定代表人（负责人、经营者）</th>
          <td>{{ companyInfo?.revokeInfo?.lerepName || '-' }}</td>
        </tr>
        <tr>
          <th width="20%">住所（经营场所）</th>
          <td>{{ companyInfo?.revokeInfo?.address || '-' }}</td>
        </tr>
        <tr>
          <th>申请时间</th>
          <td colspan="2">{{ companyInfo?.revokeInfo?.applyDate || '-' }}</td>
        </tr>
        <tr>
          <th>申请人</th>
          <td colspan="2">
            {{ companyInfo?.revokeInfo?.contactName || '-' }}
          </td>
        </tr>
        <tr>
          <th>联系电话</th>
          <td colspan="2">
            {{ companyInfo?.revokeInfo?.contactPhone || '-' }}
          </td>
        </tr>
        <tr>
          <th>决定除名时间</th>
          <td>
            {{ companyInfo?.revokeInfo?.removeDate || '-' }}
          </td>
        </tr>
        <tr>
          <th>决定除名机关</th>
          <td>
            {{ companyInfo?.revokeInfo?.removeOrgName || '-' }}
          </td>
        </tr>
        <tr>
          <th>决定除名原因</th>
          <td>
            {{ companyInfo?.revokeInfo?.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
                  class="disabled-upload-remove"
                  :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-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
                  class="disabled-upload-remove"
                  :action="uploadUrl + '/attachment/saveTCLawFile.do'"
                  :on-preview="handlePreview"
                  :file-list="fileUri.file8"
                  accept=".pdf,.jpg,.png"
                  :data="uploadData(8)"
                  :before-upload="beforeUpload"
                  :on-success="handleSuccess(8)"
                  :on-remove="handleRemove(8)"
                />
              </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
                  class="disabled-upload-remove"
                  :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-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
                  class="disabled-upload-remove"
                  :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-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
                  class="disabled-upload-remove"
                  :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-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
                  class="disabled-upload-remove"
                  :action="uploadUrl + '/attachment/saveTCLawFile.do'"
                  :on-preview="handlePreview"
                  :file-list="fileUri.file3"
                  accept=".pdf,.jpg,.png"
                  :data="uploadData(3)"
                  :before-upload="beforeUpload"
                  :on-success="handleSuccess(3)"
                  :on-remove="handleRemove(3)"
                />
              </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
                  class="disabled-upload-remove"
                  :action="uploadUrl + '/attachment/saveTCLawFile.do'"
                  :on-preview="handlePreview"
                  :file-list="fileUri.file4"
                  accept=".pdf,.jpg,.png"
                  :data="uploadData(4)"
                  :before-upload="beforeUpload"
                  :on-success="handleSuccess(4)"
                  :on-remove="handleRemove(4)"
                />
              </el-col>
            </el-row>
          </td>
        </tr>
        <tr>
          <th>补充材料</th>
          <td>
            <el-upload
              class="disabled-upload-remove"
              :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%"
            />
          </td>
        </tr>
      </table>
    </el-dialog>
  </div>
</template>

<script>
import { removeAttachementById, listAttachmentByBizseq, uploadFile } from '@/api/attachment'
import { checknb
  // getaicepsYbList, geteGtAlterRecoderList
} from '@/api/abnormal'
import { getUsersWithPermission } from '@/api/user'
import { getNewestOpinion, saveOrUpdateContent } from '@/api/credit'
import { taskOpinion } from '@/api/task'
import { getConstant } from '@/api/system'
import { isMenHu } from '@/utils/utils'
import { checkPyBlacklist } from '@/api/pyBlacklist'
import { expelledRevokeNextBiz, expelledRevokeGetBiz } from '@/api/除名公告'

export default {
  data() {
    return {
      revokeType: '1',
      remRemark: '',
      entInfoDialog: false,
      isAccept: '',
      firstEnt: {},
      editorDisable: true,
      eidtDialog: false,
      isClear: false,
      eidtContent: '',
      dialogTitle: '',
      uploadUrl: process.env.VUE_APP_BASE_API,
      showEntbase: false,
      bizseq: '',
      workflowId: '',
      tasklistid: '',
      opinion: '',
      reason: '',
      acceptStatus: '',
      companyInfo: {},
      aicepsList: [], // 年报记录
      eGtAlterRecoderList: [], // 变更记录
      formData: {
        nextNodeId: 'approvelist',
        opinion: '',
        handledate: this.$moment().format('YYYY-MM-DD HH:mm:ss')
      },
      reasonOptions: [],
      opinionOptions: [{
        value: 0,
        label: '拟同意'
      }, {
        value: 1,
        label: '同意'
      }, {
        value: 2,
        label: '不同意'
      }],
      historyLog: [],
      exmainerOptions: [],
      fileUri: {},
      fileList: [],
      user: JSON.parse(sessionStorage.getItem('user')),
      reviewer: [],
      submitLoading: false,
      tswrittemplate: {
        bizseq: '',
        writsType: '',
        isTemplate: ''
      },
      isAgreeRevoke: '',
      // 意见-经办人
      handleOpinion: {
        handler: '',
        handleDate: '',
        opinionContent: ''
      },
      // 意见-审核人
      reviewOpinion: {
        handler: '',
        handleDate: '',
        opinionContent: ''
      },
      // 意见-审批人
      approvalOpinion: {
        handler: '',
        handleDate: '',
        opinionContent: ''
      },
      specause: '',
      fujianType: '',
      specauseType: '',
      nb: '否',
      tsabnlist: ''
    }
  },
  computed: {
    uploadData() {
      return (index) => {
        return {
          filetype: index,
          attachtype: index,
          bizseq: this.bizseq,
          pripids: this.companyInfo.priPID
        }
      }
    }
  },
  watch: {
    // 意见渲染
    opinion() {
      let name = ''
      this.opinionOptions.forEach(each => {
        if (this.opinion === each.value) {
          name = each.label
        }
      })
      this.$set(this.formData, 'opinion', name)
    },
    specauseType() {
      if (this.specauseType === 'nb') {
        this.$set(this, 'fujianType', '未年报')
      } else if (this.specauseType === 'sd') {
        this.$set(this, 'fujianType', '实地查无')
      } else if (this.specauseType === 'xj') {
        this.$set(this, 'fujianType', '虚假公示')
      }
    }
  },
  async mounted() {
    this.bizseq = this.$route.query.bizSeq // 获取跳转携带的参数bizseq
    this.workflowId = this.$route.query.workflowId
    this.tasklistid = this.$route.query.taskId
    this.type = this.$route.query.type
    expelledRevokeGetBiz(this.bizseq).then(res => {
      this.companyInfo = res.data
      this.acceptStatus = res.data.revokeInfo.acceptStatus
    })
    // 加载企业移出原因
    getConstant('CD74').then(res => {
      if (res.code === 0) {
        const list = []
        res.data.forEach(each => {
          list.push({
            value: each.code,
            label: each.name
          })
        })
        this.reasonOptions = list
      }
    })
    // // 加载处办记录
    taskOpinion(this.workflowId).then(res => {
      if (res.code === 0) {
        res.data.forEach(each => {
          switch (each.opiniontype) {
            case '9':
              each.step = '经办'
              each.label = '经办人意见'
              break
            case '0':
              each.step = '经办'
              each.label = '经办人意见'
              break
            case '1':
              each.step = '审核'
              each.label = '部门负责人意见'
              break
            case '2':
              each.step = '审批'
              each.label = '经办机构负责人意见'
              break
          }
          this.historyLog.push(each)
          // if (each.opiniontype !== '9') {
          //   this.historyLog.push(each)
          // }
        })
      } else {
        this.$message.error('加载意见记录失败')
      }
    })
    // 加载待移出主体名单及 事实理由
    // getBizRemInfo(this.bizseq).then(res => {
    //   if (res.code === 0) {
    //     const list = []
    //     let i = 1
    //     const pageStart = (this.currentPage - 1) * this.pageSize
    //     res.data.bizList.forEach(each => {
    //       each.index = pageStart + i++
    //       each.uscc = each.uniscid ? each.uniscid : each.regno // 有统一码显示统一码 没有用注册号
    //       list.push(each)
    //     })
    //     this.entbase = list
    //     this.tsabnlist = res.data.tsAbnList
    //     const bizInfo = res.data.bizRemListMOdel
    //     this.companyInfo = res.data.bizRemListMOdel
    //     this.isAccept = bizInfo.isAccept
    //     this.isAgreeRevoke = bizInfo.isAgreeRevoke
    //     this.entname = bizInfo.entname
    //     this.specause = bizInfo.specause
    //     this.remRemark = bizInfo.remRemark
    //     this.specauseType = bizInfo.specauseType
    //     this.total = this.entbase.length

    //     this.check_py(this.tsabnlist.uniscid)
    //   } else {
    //     this.$message.error('加载异常名录主体信息失败')
    //   }
    // })

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

    // 获取主体年报记录
    // getaicepsYbList(this.bizseq).then(res => {
    //   if (res.code === 0) {
    //     this.aicepsList = res.data
    //   } else {
    //     this.$message.error('加载年报记录失败')
    //   }
    // })

    // // 获取变更记录
    // geteGtAlterRecoderList(this.bizseq).then(res => {
    //   if (res.code === 0) {
    //     this.eGtAlterRecoderList = res.data
    //   } else {
    //     this.$message.error('加载变更记录失败')
    //   }
    // })
  },
  methods: {
    // 番禺启示录
    async check_py(uscc) {
      ['2', '3', '4'].forEach(value => {
        checkPyBlacklist({
          uniscid: uscc,
          tagType: value
        }).then(({ data }) => {
          if (data) {
            this.$notify({
              title: '警示',
              message: data,
              type: 'warning',
              duration: 0
            })
          }
        })
      })
    },
    isnb(abnlistid) {
      checknb(abnlistid).then(res => {
        if (res.data) {
          this.nb = '是'
        }
      })
    },
    // 加载附件清单
    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.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'].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.operOpinion = res.data.operOpinion
          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')
        }
      })
    },
    // 获取最新审核意见
    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')
          this.$nextTick(() => {
            this.$set(this.formData, 'opinion', res.data.opinioncontent)
            this.$set(this.formData, 'handledate', res.data.handledate)
          })
        }
      })
    },
    // 获取最新审批意见
    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
          // if (this.currentNode === 'approveRevCancel') {
          //   this.$nextTick(() => {
          //     this.$set(this.form, 'opinion', res.data.opinioncontent)
          //     this.$set(this.form, 'handledate', res.data.handledate)
          //   })
          // }
        }
      })
    },
    // 保存模板编辑内容
    saveTempalte() {
      // console.log(this.hearingNoticeInfo)
      this.tswrittemplate.content = this.eidtContent
      saveOrUpdateContent(this.tswrittemplate).then(res => {
        if (res.data === true) {
          this.eidtDialog = false
          this.$message.success('保存成功')
          // this.getHearingNotice()
        } else {
          this.$message.error('保存失败')
        }
      })
    },
    openDialog(type) {
      var title = ''
      if (type === 'disagreeDec') {
        title = '不予受理决定书'
        this.eidtDialog = true
        this.$nextTick(() => {
          this.clearEditorContent(type)
          this.eidtContent = this.tswrittemplate.content
          this.editorDialogType = type
          if (this.editorDisable) {
            this.$refs.editorDialog.$emit('disable')
          }
        })
      } else if (type === 'noCreidtRevoke') {
        title = '不予信用撤销决定书'
        this.eidtDialog = true
        this.$nextTick(() => {
          this.clearEditorContent(type)
          this.eidtContent = this.tswrittemplate.content
          this.editorDialogType = type
          if (this.editorDisable) {
            this.$refs.editorDialog.$emit('disable')
          }
        })
      } else if (type === 'creidtRevoke') {
        title = '准予信用撤销决定书'
        this.eidtDialog = true
        this.$nextTick(() => {
          this.clearEditorContent(type)
          this.eidtContent = this.tswrittemplate.content
          this.editorDialogType = type
          if (this.editorDisable) {
            this.$refs.editorDialog.$emit('disable')
          }
        })
      }
      this.dialogTitle = title
    },
    async clearEditorContent(type) {
      if (type !== this.editorDialogType) {
        await this.$refs.editorDialog.$emit('clear')
      }
    },
    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)) {
        // this.$hevueImgPreview(file.url)
        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
          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)
          }
        })
      }
    },
    // 接收子组件的传参
    changeEditor(val) {
    //   console.log(val)
    //   this.eidtContent = val
    },
    getTextVal(res) {
      const list = []
      res.forEach(each => {
        console.log(each)
      })
    },
    // 点击上传文件
    clickUpload(index) {
      this.$refs[`file${index}`].click()
    },
    // 文件上传
    fileUpload(index) {
      const el = this.$refs[`file${index}`]
      if (el.values === '') return
      const cur = this
      uploadFile({
        filetype: index,
        attachtype: index,
        bizseq: this.bizseq,
        pripids: this.companyInfo.priPID
      }, el.files[0]).then(res => {
        el.values = ''
        if (res.code === 0) {
          this.$message.success('上传成功')
          cur.$set(cur.fileUri, `file${index}`, res.data[0].temppath)
        } else {
          this.$message.error('上传失败')
        }
      })
    },
    // 查看附件
    openFile(index) {
      window.open(this.fileUri['file' + index])
    },
    // 提交审核
    submitExamine() {
      this.submitLoading = true
      if (this.$util.isEmpty(this.formData.opinion)) {
        this.submitLoading = false
        return this.$message.error('请输入经办机构负责人意见')
      }
      if (this.formData.nextNodeId === 'approvelist' && this.$util.isEmpty(this.formData.nextPerformerIds)) {
        this.submitLoading = false
        return this.$message.error('请选择审批人')
      }
      let name = ''
      const userId = this.formData.nextPerformerIds
      this.reviewer.forEach(each => {
        if (userId === each.primaryKey) {
          name = each.name
        }
      })
      this.formData.isagree = '1'
      if (this.formData.nextNodeId === 'exptlistEnter') {
        this.formData.nextPerformerIds = ''
        this.formData.isagree = '2'
      }
      for (const i in this.reviewer) {
        if (this.reviewer[i].primaryKey === this.formData.nextPerformerIds) {
          this.formData.nextPerformerNames = this.reviewer[i].name
        }
      }
      this.formData.bizId = this.bizseq
      this.formData.workflowid = this.workflowId
      this.formData.taskId = this.tasklistid
      this.formData.handler = this.user.nickname
      expelledRevokeNextBiz({
        bizId: this.bizseq,
        taskId: this.tasklistid,
        nextNodeId: this.formData.nextNodeId,
        nextPerformerIds: this.formData.nextPerformerIds,
        nextPerformerNames: this.formData.nextPerformerNames,
        applyInfoQuery: {
          ...this.companyInfo.revokeInfo
        },
        opinionQuery: {
          bizseq: this.bizseq,
          workflowid: this.workflowId,
          handler: this.user.nickname,
          handlerid: this.user.primaryKey,
          opiniontype: '1',
          isagree: this.formData.isagree,
          opinioncontent: this.formData.opinion,
          handledate: this.formData.handledate
        }
      }).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)
        }
      })
    },
    // 移除文件回调
    removeFile(file) {
      removeAttachementById(file.response.data.attachmentid).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
        }
      })
    },
    // 下载模版
    downLoadTemp(type) {
      let path = ''
      switch (parseInt(type)) {
        case 2: path = '/credit/revoke/printRemoveApply'; break // 严重违法失信企业信用撤销申请表
        case 3: path = '/credit/revoke/printPromise'; break // 企业信用承诺书
        case 4: path = '/credit/revoke/printRemoveExamine'; break // 严重违法失信企业信用撤销审批表
      }
      const { href } = this.$router.resolve({ path: path, query: {
        bizseq: this.bizseq,
        workflowId: this.workflowId,
        tasklistid: this.tasklistid
      }})
      window.open(href)
    }
  }
}
</script>

<style lang="scss" scoped>
  // 表单表头颜色
$font-size-label:#666;

.disabled-upload-remove{
  /deep/ .el-upload-list__item-status-label{
    display: none;
  }
  /deep/ .el-icon-close{
    display: none;
  }
  /deep/ .el-icon-close-tip{
    display: none!important;
  }
}
.main-content{
  background: #fff;
  padding: 20pt;
  .back-btn{
    position:absolute;
    right:40pt;
  }
  .content-header,.content-body{
    background: white;
    padding:20PX 10PX;
  }
  .content-header{
    height:60PX;
    .title{
      font-weight: 700;
      font-size: $font-size-sub-title;
    }
  }
  .content-body{
    padding:20pt;
      .tab{
        .tab-title{
          label{
            background: $color-primary;
            display:inline-block;
            color:white;
            padding:5px;
          }
        }
      }
    .form{
      margin-bottom: 20pt;
    }
  }
  .apply-table{
    padding:15px;
    margin-bottom: 30px;
    .table-title{
      padding:15px;
      font-size: 1.3rem;
      color:#243668
    }
    table{
      border-top: 1px solid $color-border;
      border-left: 1px solid $color-border;
    }
    tr{
      width:100%
    }
    th,td{
      border-top: 1px solid $color-border;
      border-left: 1px solid $color-border;
      border-right: 1px solid $color-border;
      border-bottom: 1px solid $color-border;
      padding:15px
    }
    th{
      color: $font-size-label;
      font-weight: normal;
      text-align: $text-algin-right;
      background: $color-form-label
    }
    td{
      text-align: $text-algin-left;
      color: #333!important;
    }
    .el-radio{
      color: #333!important;
    }
  }
}
.table-title{
  width: 100%;
  margin-top: 10px;
  padding: 15px;
  display: flex;
  align-items: center;
  font-weight: 600;
  background: #fff;
  font-size: $page-title-font-size;
  color:#333;
  border-bottom: 1px solid #E5E5E5;
}
.title-btn{
  margin-top: 15px;
  margin-right: 40px;
  text-align: right;
  background: #fff;
}
</style>
<style lang="scss">
.credit{
  .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: #1A77FF;
      border-color: #1A77FF;
    }
  }
  .el-dialog__header{
    background:#e4e4e4;
    .el-dialog__title {
      font-size: large;
    }
  }
  .decForm{
    .el-form-item {
      margin-bottom: 0;
      background: $color-form-label;
      .el-form-item__label {
        font-size: initial;
        padding-left: 20px;
        border-top: 1px solid $color-border;
        border-left: 1px solid $color-border;
      }
      .el-form-item__content {
        padding-left: 10px;
        font-size: initial;
        // line-height: normal;
        background: white;
        border-top: 1px solid $color-border;
        border-right: 1px solid $color-border;
        border-left: 1px solid $color-border;
      }
    }
  }
}
.infoDialog {
    .apply-table{
    padding:15px;
    margin-bottom: 30px;
    .table-title{
      padding:15px;
      font-size: 1.3rem;
      color:#243668
    }
    table{
      border-top: 1px solid $color-border;
      border-left: 1px solid $color-border;
    }
    tr{
      width:100%
    }
    th,td{
      border-top: 1px solid $color-border;
      border-left: 1px solid $color-border;
      border-right: 1px solid $color-border;
      border-bottom: 1px solid $color-border;
      padding:15px
    }
    th{
      color: $font-size-label;
      font-weight: normal;
      text-align: $text-algin-right;
      background: $color-form-label
    }
    td{
      text-align: $text-algin-left;
    }
  }
}
.submit-btn-box {
  text-align: center;
}
</style>
