<template>
  <div class="main-content credit">
    <!-- <div class="content-header">
      <span class="title">严重违法名录移出：经办</span>
      <el-button type="warning" icon="el-icon-caret-left" size="mini" class="back-btn" @click="$router.back()">返回上一层</el-button>
    </div> -->
    <div>
      <el-row style="background: #fff;border-bottom: 1px solid #E5E5E5;">
        <el-col :span="12">
          <div class="table-title">
            <img src="../../assets/images/icon01.png" alt="" style="width:24px;margin-right:10px">
            信用修复审批表
          </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">
        <table
          width="100%"
          class="apply-table"
          style="border-collapse: collapse;"
          border="1"
          cellpadding="0"
          cellspacing="0"
        >
          <tr>
            <th width="20%">名称/姓名</th>
            <td>{{ companyInfo.entName }}</td>
            <th width="20%">注册号/企业统一信用代码</th>
            <td>{{ companyInfo.regNO }}</td>
          </tr>
          <tr>
            <th>审批事项</th>
            <td colspan="3" class="radio" disabled>
              <el-radio v-model="repairType" disabled label="1" style="display:block;font-size: unset;margin-bottom:10px">经营异常名录</el-radio>
              <el-radio v-model="repairType" disabled label="2" style="display:block;font-size: unset;margin-bottom:10px">个体工商户经营异常状态</el-radio>
              <el-radio v-model="repairType" disabled label="3" style="display:block;font-size: unset;margin-bottom:10px">行政处罚信息</el-radio>
              <el-radio v-model="repairType" disabled label="4" style="display:block;font-size: unset;margin-bottom:10px">严重违法失信名单</el-radio>
            </td>
          </tr>
          <tr>
            <th>作出决定的事实、理由、依据及主要内容</th>
            <td colspan="3">
              <span style="display: block;text-indent: 1em;min-height:80px">{{ companyInfo.lostCreditExplainrem }}</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 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>
            <th>备注</th>
            <td colspan="3">
              <span>{{ companyInfo.remark }}</span>
            </td>
          </tr>
          <tr>
            <th>
              文书
            </th>
            <td colspan="3">
              <el-link v-if="isAccept === '0'" style="font-size: unset" @click="openDialog('disagreeDec')">不予受理决定书</el-link>
              <el-link v-if="isAgreeRepair === '0'" style="font-size: unset" @click="openDialog('noCreidtRepair')">不予信用修复决定书</el-link>
              <el-link v-if="isAgreeRepair === '1'" style="font-size: unset" @click="openDialog('creidtRepair')">准予信用修复决定书</el-link>
            </td>
          </tr>
          <!-- <tr>
            <th>审批人</th>
            <td colspan="3">
              <el-select v-model="formData.nextPerformerids" placeholder="请选择审批人" 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>
        <table
              width="100%"
              class="apply-table"
              style="border-collapse: collapse;"
              border="1"
              cellpadding="0"
              cellspacing="0"
              v-if="htopinions && htopinions.length > 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>
        <!-- <table
          width="100%"
          class="apply-table"
          style="border-collapse: collapse;"
          border="1"
          cellpadding="0"
          cellspacing="0"
        >
          <tr v-if="isAccept === '1'">
            <th>是否予以信用修复</th>
            <td colspan="2">
              <span>{{ this.isAgreeRepair ==='1'? '准予信用修复':'不予信用修复' }}</span>
            </td>
          </tr>
          <tr>
            <th>审批人意见</th>
            <td colspan="2">
              <el-input v-model="formData.opinion" type="textarea" placeholder="请输入审批人意见" :autosize="{minRows:4, maxRows: 8}" />
              <el-row style="margin:10px 0">
                <label>是否通过：</label>
                <el-radio-group v-model="formData.nextNodeID">
                  <el-radio label="endSerIllegal">通过</el-radio>
                  <el-radio label="overSerIllegal">不通过</el-radio>
                </el-radio-group>
              </el-row>
              <el-row style="margin:10px 0">
                <el-col :span="12">
                  <label>常用语：</label>
                  <el-select v-model="opinion" placeholder="请选择" class="custom">
                    <el-option
                      v-for="item in opinionOptions"
                      :key="item.value"
                      :label="item.label"
                      :value="item.value"
                    />
                  </el-select>
                </el-col>
              </el-row>
            </td>
          </tr>
        </table> -->
        <!--        <div class="submit-btn-box">-->
        <!--          <el-button type="primary" @click="submitExamine">提交</el-button>-->
        <!--        </div>-->

        <div class="submit-btn-box" v-if="isAppBackEnter">
          <el-button @click="$router.back()">返回</el-button>
          <el-button type="primary" @click="cancelBusiness">撤销业务</el-button>
        </div>
      </div>
    </div>
    <el-dialog
      :title="dialogTitle"
      :visible.sync="eidtDialog"
      :close-on-click-modal="false"
      width="60%"
      center
    >
      <div class="firstEnt">
        <el-form label-position="left" label-width="200px" :model="firstEnt" class="decForm">
          <el-row>
            <el-form-item label="主标题">
              <span>{{ user.orgName }}</span>
            </el-form-item>
          </el-row>
          <el-row>
            <el-form-item label="副标题">
              <span>{{ dialogTitle }}</span>
            </el-form-item>
          </el-row>
          <el-row>
            <el-form-item label="当事人">
              <span>{{ companyInfo.entName }}</span>
            </el-form-item>
          </el-row>
        </el-form>
      </div>
      <Editor ref="editorDialog" v-model="eidtContent" :is-clear="isClear" :is-disable="editorDisable" @getTextVal="getTextVal" @change="changeEditor" />
      <span slot="footer" class="dialog-footer">
        <el-button v-if="!editorDisable" type="primary" @click="saveTempalte">保存</el-button>
        <!-- <el-button size="mini" @click="getEditorText">输出纯文本</el-button> -->

      </span>
    </el-dialog>
    <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 width="20%">注册号/企业统一信用代码</th>
          <td>{{ companyInfo.regNO }}</td>
        </tr>
        <tr><th>企业名称</th><td>{{ companyInfo.entName }}</td></tr>
        <tr>
          <th>申请时间</th>
          <td colspan="2">{{ companyInfo.applyTime }}</td>
        </tr>
        <tr>
          <th>申请人</th>
          <td colspan="2">
            {{ companyInfo.applicant }}
          </td>
        </tr>
        <tr>
          <th>列入时间</th>
          <td>
            {{ tsSerIllegalList.abntime }}
          </td>
        </tr>
        <tr>
          <th>列入原因</th>
          <td>
            {{ tsSerIllegalList.lostcreditexplain }}
          </td>
        </tr>
        <tr>
          <th>列入单位</th>
          <td>
            {{ tsSerIllegalList.decorgCn }}
          </td>
        </tr>
      </table>
      <table
        width="100%"
        class="apply-table"
        style="border-collapse: collapse;"
        border="1"
        cellpadding="0"
        cellspacing="0"
      >
        <tr>
          <!--<th rowspan="5" width="20%">移出严重违法失信企业名单证据材料</th>-->
          <th rowspan="6" width="20%">证据材料</th>
          <td>
            <el-row>
              <el-col :span="14">1、信用修复申请书</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-button slot="trigger" type="primary" size="mini">上传</el-button> -->
                  <!-- <el-button style="margin-left: 10px;" size="mini" @click="downLoadTemp(1)">下载模版</el-button> -->
                </el-upload>
              </el-col>
            </el-row>
          </td>
        </tr>
        <tr>
          <td>
            <el-row>
              <el-col :span="14">2、守信承诺书</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-button slot="trigger" type="primary" size="mini">上传</el-button> -->
                  <!-- <el-button style="margin-left: 10px;" size="mini" @click="downLoadTemp(2)">下载模版</el-button> -->
                </el-upload>
              </el-col>
            </el-row>
          </td>
        </tr>
        <tr>
          <td>
            <el-row>
              <el-col :span="14">3、履行法定义务、纠正违法行为的相关材料</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-button slot="trigger" type="primary" size="mini">上传</el-button> -->
                </el-upload>
              </el-col>
            </el-row>
          </td>
        </tr>
<!--        <tr>-->
<!--          <td>-->
<!--            <el-row>-->
<!--              <el-col :span="14">4、委托人身份证</el-col>-->
<!--              <el-col :span="10">-->
<!--                <el-upload-->
<!--                  class="disabled-upload-remove"-->
<!--                  :action="uploadUrl + '/attachment/saveTCLawFile.do'"-->
<!--                  :on-preview="handlePreview"-->
<!--                  :file-list="fileUri.file5"-->
<!--                  accept=".pdf,.jpg,.png"-->
<!--                  :data="uploadData(5)"-->
<!--                  :before-upload="beforeUpload"-->
<!--                  :on-success="handleSuccess(5)"-->
<!--                  :on-remove="handleRemove(5)"-->
<!--                >-->
<!--                  &lt;!&ndash; <el-button slot="trigger" type="primary" size="mini">上传</el-button> &ndash;&gt;-->
<!--                </el-upload>-->
<!--              </el-col>-->
<!--            </el-row>-->
<!--          </td>-->
<!--        </tr>-->
        <tr>
          <td>
            <el-row>
              <el-col :span="14">4、信用修复委托书</el-col>
              <el-col :span="10">
                <el-upload
                  class="disabled-upload-remove"
                  :action="uploadUrl + '/attachment/saveTCLawFile.do'"
                  :on-preview="handlePreview"
                  :file-list="fileUri.file6"
                  accept=".pdf,.jpg,.png"
                  :data="uploadData(6)"
                  :before-upload="beforeUpload"
                  :on-success="handleSuccess(6)"
                  :on-remove="handleRemove(6)"
                >
                </el-upload>
              </el-col>
            </el-row>
          </td>
        </tr>
        <tr>
          <td>
            <el-row>
              <el-col :span="14">5、营业执照照片</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-upload>
              </el-col>
            </el-row>
          </td>
        </tr>
        <tr>
          <td>
            <el-row>
              <el-col :span="14">5、其他材料</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-button slot="trigger" type="primary" size="mini">上传</el-button> -->
                </el-upload>
              </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%"
            >
              <!-- <el-button size="small" type="primary">点击上传</el-button> -->
            </el-upload>
          </td>
        </tr>
        <!-- <tr v-if="historyLog && historyLog.length > 0">
                  <th>历史意见</th>
                  <td colspan="2">
                    <el-steps direction="vertical">
                      <el-step v-for="(each,index) in historyLog" :key="'historyLog'+index" :title="'处办人：' + each.handler + ' 处办日期：' + each.handledate" :description="each.opinioncontent" status="finish" />
                    </el-steps>
                  </td>
                </tr> -->
      </table>
    </el-dialog>
  </div>
</template>

<script>
import { removeAttachementById, listAttachmentByBizseq, uploadFile } from '@/api/attachment'
import { nextRemTask, listIllegalRem, queryHistorgBizRemInfo } from '@/api/illegal'
import { getUsersWithPermission } from '@/api/user'
import { getContentsWithBizseq, getNewestOpinion } from '@/api/credit'
import { taskOpinion, getProcessNodeList, getTaskList } from '@/api/task'
import editor from '@/components/editor.vue'
import { getConstant } from '@/api/system'
import { illRemCancelBusiness } from '@/api/abnormal'
export default {
  components: {
    Editor: editor
  },
  data() {
    return {
      htopinions: [], // 回退到移动端意见
      entInfoDialog: false,
      repairType: '4',
      isAccept: '',
      firstEnt: {},
      editorDisable: true,
      eidtDialog: false,
      isClear: false,
      eidtContent: '',
      dialogTitle: '',
      uploadUrl: process.env.VUE_APP_BASE_API,
      showEntbase: false,
      bizseq: '',
      workflowId: '',
      tasklistid: '',
      opinion: '',
      companyInfo: {},
      formData: {
        nextNodeID: '',
        handledate: this.$moment().format('YYYY-MM-DD HH:mm:ss'),
        opinion: '',
        remark: ''
      },
      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: ''
      },
      isAgreeRepair: '',
      // 意见-经办人
      handleOpinion: {
        handler: '',
        handleDate: '',
        opinionContent: ''
      },
      // 意见-审核人
      reviewOpinion: {
        handler: '',
        handleDate: '',
        opinionContent: ''
      },
      // 意见-审批人
      approvalOpinion: {
        handler: '',
        handleDate: '',
        opinionContent: ''
      },
      tsSerIllegalList: '',
      busstatus:'',
      nodeflow:[],
      currentnode:'',
      appOrPc:''
    }
  },
  computed: {
    uploadData() {
      return (index) => {
        return {
          filetype: index,
          attachtype: index,
          bizseq: this.bizseq,
          pripids: this.companyInfo.priPID
        }
      }
    },
    //是否为回退到第一步（移动端)
    isAppBackEnter() {
       console.log(this.appOrPc ,this.busstatus,this.currentnode, this.nodeflow[0])
       if(this.appOrPc === '0' && this.busstatus ==='5' && this.currentnode === 'serIllegalEnter' && this.nodeflow.length > 0 && this.nodeflow[0] === 'serIllegalEnter'){
          return true
        }
      return false
    }
  },
  watch: {
    // 意见渲染
    opinion() {
      let name = ''
      this.opinionOptions.forEach(each => {
        if (this.opinion === each.value) {
          name = each.label
        }
      })
      this.formData.opinion = name
    },
    // isAccept: {
    //   handler(newMsg, oldMsg) {
    //     if (newMsg === '1') {
    //       this.isAgreeRepair = '1'
    //     } else if (newMsg === '0') {
    //       this.isAgreeRepair = ''
    //       this.getDisagreeDecContent()
    //     }
    //   },
    //   immediate: true
    // },
    isAgreeRepair: {
      handler(newMsg, oldMsg) {
        if (this.workflowId) {
          if (newMsg === '1') {
            this.getRepairDecContent()
          } else if (newMsg === '0') {
            this.getNoRepairDecContent()
          }
        }
      }
    }
  },
  mounted() {
    this.bizseq = this.$route.query.bizseq // 获取跳转携带的参数bizseq
    this.workflowId = this.$route.query.workflowId
    this.tasklistid = this.$route.query.tasklistid

    if (this.workflowId) {
      // 加载严重违法主体
      listIllegalRem(this.bizseq).then(res => {
        if (res.code === 0) {
          this.tsSerIllegalList = res.data.tsSerIllegalList
          const tsbizserillegalrem = res.data.tsbizserillegalrem[0]
          this.companyInfo = tsbizserillegalrem
          this.isAccept = tsbizserillegalrem.isAccept
          this.isAgreeRepair = tsbizserillegalrem.isAgreeRepair
          this.appOrPc = tsbizserillegalrem.appOrPc
          this.companyInfo.remark = (this.$util.isEmpty(tsbizserillegalrem.remark) || tsbizserillegalrem.remark === 'null') ? '' : tsbizserillegalrem.remark
          let date = this.companyInfo.abnTime
          if (date) {
            date = date.split('-')
            this.companyInfo.abnTime = date[0] + '年' + date[1] + '月' + date[2] + '日'
          }
        } else {
          this.$message.error('加载严重违法主体信息失败')
        }
      })

      // 加载企业移出原因
      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 '0':
                each.step = '经办'
                each.label = '经办人意见'
                if (each.isagree === '2') this.htopinions.push(each)
                break
              case '1':
                each.step = '审核'
                each.label = '经办机构负责人意见'
                break
              case '2':
                each.step = '审批'
                each.label = '部门负责人意见'
                break
            }
            this.historyLog.push(each)
          })
        } else {
          this.$message.error('加载处办记录失败')
        }
      })

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

      // 加载附件清单
      this.loadAttachmentList()
      // this.getHandleOpinion(this.workflowId, '0')
      // this.getReviewOpinion(this.workflowId, '1')
      // this.getApprovalOpinion(this.workflowId, '2')

      //获取获取待办信息
      getTaskList(this.tasklistid).then(res => {
        if (res.code === 0) {
          this.busstatus=res.data.busstatus
        }
      })

      //获取流程节点信息
      getProcessNodeList(this.workflowId).then(res => {
          if (res.code === 0 && res.data.length>0) {
            this.nodeflow = res.data[0].nodeflow.split("_")
            this.currentnode = res.data[0].currentnode
          }
      })
    } else {
      queryHistorgBizRemInfo(this.bizseq).then(res => {
        this.tsSerIllegalList = res.data.tsSerIllegalList
        this.companyInfo = res.data.tsBizSerIllegalRem
        this.isAccept = '1'
        this.isAgreeRepair = '1'
        res.data.tsOpinions.forEach(each => {
          switch (each.opiniontype) {
            case '0':
              each.step = '经办'
              each.label = '经办人意见'
              if (each.isagree === '2') this.htopinions.push(each)
              break
            case '1':
              each.step = '审核'
              each.label = '经办机构负责人意见'
              break
            case '2':
              each.step = '审批'
              each.label = '部门负责人意见'
              break
          }
          this.historyLog.push(each)
        })
        const list = []
        res.data.tsAttachments.forEach(each => {
          if (each.attachtype !== '0') {
            each.id = each.attachmentid
            each.name = each.filename
            each.url = `${process.env.VUE_APP_DOWNLOAD_URL}/` + each.temppath
            list.push(each)
          }
        })
        this.fileUri.file4 = list
        this.tswrittemplate.content = res.data.content
      })
    }
  },
  methods: {
    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)
      } 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)
          }
        })
      }
    },
    // 加载附件清单
    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.file5.forEach(res => {
          this.fileUri.file4.push(res)
        })
        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.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}`
          }
        })
      })
    },
    // 保存模板编辑内容
    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('保存失败')
        }
      })
    },
    // 获取最新经办意见
    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')
        }
      })
    },
    // 获取最新审批意见
    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
          this.$nextTick(() => {
            this.$set(this.formData, 'opinion', res.data.opinioncontent)
            this.$set(this.formData, 'handledate', res.data.handledate)
          })
        }
      })
    },
    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 === 'noCreidtRepair') {
        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 === 'creidtRepair') {
        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')
      }
    },
    // 获取不予受理决定书内容
    getDisagreeDecContent() {
      this.tswrittemplate.bizseq = this.bizseq
      this.tswrittemplate.writsType = '51'
      getContentsWithBizseq(this.tswrittemplate).then(res => {
        if (res.code === 0) {
          this.tswrittemplate.content = res.data.content
        } else {
          this.$message.error(res.msg)
        }
      })
    },
    // 获取不予信用修复决定书内容
    getNoRepairDecContent() {
      this.tswrittemplate.bizseq = this.bizseq
      this.tswrittemplate.writsType = '52'
      getContentsWithBizseq(this.tswrittemplate).then(res => {
        if (res.code === 0) {
          this.tswrittemplate.content = res.data.content
        } else {
          this.$message.error(res.msg)
        }
      })
    },
    // 获取准予信用修复决定书内容
    getRepairDecContent() {
      this.tswrittemplate.bizseq = this.bizseq
      this.tswrittemplate.writsType = '53'
      getContentsWithBizseq(this.tswrittemplate).then(res => {
        if (res.code === 0) {
          this.tswrittemplate.content = res.data.content
        } else {
          this.$message.error(res.msg)
        }
      })
    },
    // 接收子组件的传参
    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() {
      if (this.$util.isEmpty(this.formData.opinion)) {
        return this.$message.error('请输入部门负责人意见')
      }
      // if (this.$util.isEmpty(this.formData.nextPerformerids)) {
      //   return this.$message.error('请选择后续处理人')
      // }
      // let name = ''
      // const userId = this.formData.nextPerformerids
      // this.reviewer.forEach(each => {
      //   if (userId === each.primaryKey) {
      //     name = each.name
      //   }
      // })
      nextRemTask({
        nextPerformerids: '',
        nextPerformerNames: this.user.username,
        nextNodeID: this.formData.nextNodeID,
        opiniontype: '2',
        opinioncontent: this.formData.opinion,
        handler: this.user.username,
        handlerid: this.user.primaryKey,
        handledate: this.formData.handledate,
        bizSeq: this.bizseq,
        tasklistid: this.tasklistid,
        workflowid: this.workflowId
      }).then(res => {
        if (res.code === 0) {
          this.$message.success('提交成功')
          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('approveSerIllegal', this.user.orgId).then(res => {
        if (res.code === 0) {
          this.reviewer = res.data
        }
      })
    },
    // 下载模版
    downLoadTemp(type) {
      let path = ''
      switch (parseInt(type)) {
        case 2: path = '/credit/repair/printRemoveApply'; break // 严重违法失信企业信用修复申请表
        case 3: path = '/credit/repair/printPromise'; break // 企业信用承诺书
        case 4: path = '/credit/repair/printRemoveExamine'; break // 严重违法失信企业信用修复审批表
      }
      const { href } = this.$router.resolve({ path: path, query: {
        bizseq: this.bizseq,
        workflowId: this.workflowId,
        tasklistid: this.tasklistid
      }})
      window.open(href)
    },
    cancelBusiness(){
      this.$confirm('是否确认撤销业务?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        illRemCancelBusiness(this.bizseq).then(res => {
          if (res.code === 0) {
            this.$message({
              type: 'success',
              message: '撤销成功'
            });
            this.$router.back()
          }else{
            this.$message.error('撤销失败');
          }
        })
      }).catch(() => {
      });
    }
  }
}
</script>

<style lang="scss" scoped>
div.submit-btn-box{
  text-align: center;
  padding:15px;
}
.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{
    padding: 20pt;
    background: #fff;
    .back-btn{
      position:absolute;
      right:40pt;
    }
    .content-header,.content-body{
      background: white;
      padding:20PX 10PX;
      /* border:1PX solid #eee; */
    }
    .content-header{
      height:60PX;
      .title{
        font-weight: 700;
        font-size: $table-title-font-size;
      }
    }
    .content-body{
      padding:20pt;
      .tab{
        .tab-title{
          label{
            display:inline-block;
          }
        }
      }
      .form{
        margin-bottom: 20pt;
      }
    }
    .apply-table{
      padding:15px;
      border-color: $color-border;
      margin-bottom: 30px;
      tr{
        width:100%
      }
      th,td{
        padding:15px
      }
      th{
        text-align: $text-algin-right;
        color: #5e5e5e;
        font-weight: normal;
        background: $color-form-label
      }
      td{
        text-align:$text-algin-left;
        color:$table-content-color;
        .el-radio{
          color:$table-content-color
        }
      }
    }

  }
  .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;

  }
  .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: #409EFF;
        border-color: #409EFF;
      }
    }
    .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;
        }
      }
    }
  }

</style>
