<template>
  <div v-loading.fullscreen.lock="fullscreenLoading" class="main-content abnormal m20">
    <DetailHead result="受理界面" />
    <div class="content-body">
      <el-form ref="form" :model="fraudEntInfo" label-width="230px" label-position="right" :rules="formRules">
        <div class="form">
          <div class="tab">
            <div class="tab-title">
              <label>被投诉人信息</label>
            </div>
          </div>
          <div class="form-body">
            <el-row class="flex-row">
              <el-col :span="12">
                <el-form-item label="主体名称">
                  <span style="color: #8cc3fb;cursor: pointer;" class="span-content" @click="toEntDetail(entInfo.uniscid)">{{ entInfo.entname }}</span>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="统一社会信用代码/注册号">
                  <span class="span-content">{{ entInfo.uniscid || entInfo.regno }}</span>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row class="bt0 flex-row">
              <el-col :span="12">
                <el-form-item label="法定代表人">
                  <span class="span-content">{{ entInfo.lerep }}</span>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="联系方式">
                  <span class="span-content">{{ entInfo.phone }}</span>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row class="bt0">
              <el-form-item label="登记机关">
                <span class="span-content">{{ entInfo.regorgCn }}</span>
              </el-form-item>
            </el-row>
            <!-- <el-row class="bt0 p0">
              <el-form-item label="是否转现场核查" prop="isCase">
                <span style="display: inline-block">
                   <el-radio-group v-model="fraudEntInfo.isCase" @change="isCaseChangeEvent">
                     <el-radio label="1">是</el-radio>
                     <el-radio label="0">否</el-radio>
                   </el-radio-group>
                </span>
              </el-form-item>
            </el-row> -->
            <div v-if="fraudEntInfo.isCase === '1'">
              <el-row class="bt0 p0">
                <el-form-item label="重点核查内容">
                  <el-input
                    v-model="fraudEntInfo.content"
                    :autosize="{ minRows: 2 }"
                    type="textarea"
                    placeholder="请输入重点核查内容"
                  />
                </el-form-item>
              </el-row>
              <el-row class="bt0 p0">
                <el-form-item label="现场核查通知">
                  <el-button style="margin-right:20px" type="primary" size="mini" @click="openDialog">现场核查通知书模板</el-button>
                  <el-row style="border: unset">
                    <el-upload
                      :action="uploadPath"
                      :data="uploadBodyData(4)"
                      :on-remove="removeFile"
                      :on-success="uploadCallback"
                      :on-preview="previewFile"
                      :before-upload="beforeFileUpload"
                      :before-remove="beforeRemove"
                      accept=".doc,.docx,.xlsx,.xls,.pdf,.jpg,.zip,.rar,.7z,.png"
                      multiple
                      :disabled="onlyShow"
                      name="files"
                      :file-list="fileList0"
                      style="max-width:800px;display: inline-block"
                      class="uploadFileList"
                      :class="{disabled: onlyShow}"
                    >
                      <div v-if="!onlyShow" style="display: inline-block;">
                        <el-button style="display: inline-block;" size="mini" type="primary">点击上传</el-button>
                        <div slot="tip" style="display: inline-block;" class="el-upload__tip">只能上传jpg/png/pdf/doc/docx/xls/xlsx/rar/zip/7z文件，且单个文件不能超过20M</div>
                      </div>
                    </el-upload>
                  </el-row>

                  <!-- <el-input
                    v-model="fraudEntInfo.notice"
                    :autosize="{ minRows: 2 }"
                    type="textarea"
                    placeholder="请输入现场核查通知"
                  /> -->
                </el-form-item>
              </el-row>
              <el-row class="bt0 p0">
                <el-form-item label="备注">
                  <el-input
                    v-model="fraudEntInfo.remarks"
                    :autosize="{ minRows: 2 }"
                    type="textarea"
                    placeholder="请输入备注"
                  />
                </el-form-item>
              </el-row>
            </div>
          </div>
        </div>
        <div class="form">
          <div class="tab">
            <div class="tab-title">
              <label>投诉人信息</label>
            </div>
          </div>
          <div v-if="bizFraudInfo.complainerType === '0'" class="form-body">
            <el-row class="flex-row">
              <el-col :span="12">
                <el-form-item label="姓名">
                  <span class="span-content">{{ bizFraudInfo.complainerName }}</span>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="联系电话">
                  <span class="span-content">{{ bizFraudInfo.contactsPhone }}</span>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row class="bt0 flex-row">
              <el-col :span="12">
                <el-form-item label="证件类型">
                  <span class="span-content">{{ certype(bizFraudInfo.complainerCertType) }}</span>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="证件号码">
                  <span class="span-content">{{ bizFraudInfo.complainerCertNo }}</span>
                </el-form-item>
              </el-col>
            </el-row>
            <!-- <el-form-item label="投诉材料">
              <el-input v-model="form.uscc" :disabled="true" />
              <el-button type="primary" size="mini" @click="showEntbaseList">查看全部材料</el-button>
            </el-form-item> -->
          </div>
          <div v-else-if="bizFraudInfo.complainerType === '2'" class="form-body">
            <el-row class="flex-row">
              <el-col :span="12">
                <el-form-item label="来函单位名称">
                  <span class="span-content">{{ bizFraudInfo.complainerName }}</span>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="单位联系电话">
                  <span class="span-content">{{ bizFraudInfo.contactsPhone }}</span>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row class="bt0 flex-row">
              <el-col :span="24">
                <el-form-item label="单位联系人">
                  <span class="span-content">{{ bizFraudInfo.contacts }}</span>
                </el-form-item>
              </el-col>
            </el-row>
          </div>
          <div v-else class="form-body">
            <el-row class="flex-row">
              <el-col :span="12">
                <el-form-item label="统一社会信用代码">
                  <span class="span-content">{{ bizFraudInfo.complainerCertNo }}</span>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="主体名称">
                  <span class="span-content">{{ bizFraudInfo.complainerEntName }}</span>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row class="bt0 flex-row">
              <el-col :span="24">
                <el-form-item label="主体类型">
                  <span class="span-content">{{ bizFraudInfo.complainerCertType }}</span>
                </el-form-item>
              </el-col>

            </el-row>
            <el-row class="bt0 flex-row">
              <el-col :span="12">
                <el-form-item label="法定代表人">
                  <span class="span-content">{{ bizFraudInfo.complainerName }}</span>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="法定代表人联系电话">
                  <span class="span-content">{{ bizFraudInfo.complainerLegalPhone }}</span>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row class="bt0 flex-row">
              <el-col :span="12">
                <el-form-item label="联系人">
                  <span class="span-content">{{ bizFraudInfo.contacts }}</span>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="联系人电话">
                  <span class="span-content">{{ bizFraudInfo.contactsPhone }}</span>
                </el-form-item>
              </el-col>
            </el-row>
            <!-- <el-form-item label="投诉材料">
              <el-input v-model="form.uscc" :disabled="true" />
              <el-button type="primary" size="mini" @click="showEntbaseList">查看全部材料</el-button>
            </el-form-item> -->
          </div>
          <el-row class="bt0">
            <el-form-item :label="bizFraudInfo.complainerType === '2'?'来函文件':'投诉人身份信息'" class="upload">
              <el-upload
                :action="uploadPath"
                :data="uploadBodyData(0)"
                :on-remove="removeFile"
                :on-success="uploadCallback"
                :on-preview="previewFile"
                :before-upload="beforeFileUpload"
                :before-remove="beforeRemove"
                accept=".doc,.docx,.xlsx,.xls,.pdf,.jpg,.zip,.rar,.7z,.png"
                multiple
                :disabled="onlyShow"
                name="files"
                :file-list="fileList0"
                style="max-width:800px;display: inline-block"
                class="uploadFileList"
                :class="{disabled: onlyShow}"
              >
                <div v-if="!onlyShow" style="display: inline-block;">
                  <el-button style="display: inline-block;" size="mini" type="primary">点击上传</el-button>
                  <div slot="tip" style="display: inline-block;" class="el-upload__tip">只能上传jpg/png/pdf/doc/docx/xls/xlsx/rar/zip/7z文件，且单个文件不能超过20M</div>
                </div>
              </el-upload>
            </el-form-item>
          </el-row>
        </div>
        <div v-if="this.bizFraudInfo.businessType == '2'" class="form">
          <div class="tab">
            <div class="tab-title"><label>变更信息</label></div>
          </div>
          <div class="form-body history">
            <div v-if="eAlterRecoder.length == 0" class="none">暂无变更信息</div>
            <el-table v-if="eAlterRecoder.length !== 0" :data="eAlterRecoder">
              <el-table-column label="序号" prop="index" min-width="30" />
              <el-table-column label="变更事项" prop="altitemCn" min-width="100" show-overflow-tooltip />
              <el-table-column label="变更前" prop="altbe" min-width="150" show-overflow-tooltip />
              <el-table-column label="变更后" prop="altaf" show-overflow-tooltip />
              <el-table-column label="变更日期" prop="altdate" show-overflow-tooltip />
            </el-table>
          </div>
        </div>
        <div class="form">
          <div class="tab">
            <div class="tab-title"><label>处理意见</label></div>
          </div>
          <div class="form-body history">
            <div v-if="opinions.length == 0" class="none">暂无处理意见</div>
            <el-steps direction="vertical">
              <el-step v-for="(each,index) in opinions" :key="'historyLog'+index" :title="opiniontypeCN(each.opiniontype) + '人：' + each.handler + ' ' + opiniontypeCN(each.opiniontype) +'日期：' + each.handledate " :description=" each.opinioncontent " status="finish" />
            </el-steps>
          </div>
        </div>
        <div class="form">
          <div class="tab">
            <div class="tab-title">
              <label>撤销登记案件审批</label>
            </div>
          </div>
          <div class="form-body">
            <el-row class="flex-row">
              <el-col :span="12">
                <el-form-item label="投诉原因" prop="complaintReason">
                  <span v-if="onlyShow" class="span-content">{{ fraudEntInfo.complaintReason }}</span>
                  <el-select v-else v-model="fraudEntInfo.complaintReason" type="text">
                    <el-option value="冒用他人身份信息登记">冒用他人身份信息登记</el-option>
                    <el-option value="冒用地址信息登记">冒用地址信息登记</el-option>
                    <el-option value="冒用其他信息登记">冒用其他信息登记</el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="虚假登记时间">
                  <span v-if="onlyShow" class="span-content">{{ fraudEntInfo.regTime }}</span>
                  <el-date-picker
                    v-else
                    v-model="fraudEntInfo.regTime"
                    type="date"
                    value-format="yyyy-MM-dd"
                    placeholder="选择日期"
                  />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row class="bt0 flex-row">
              <el-col :span="24">
                <el-form-item label="虚假登记事项" prop="regItem">
                  <span v-if="onlyShow" class="span-content">{{ fraudEntInfo.regItem }}</span>
                  <el-input
                    v-else
                    v-model="fraudEntInfo.regItem"
                    :autosize="{ minRows: 2 }"
                    type="textarea"
                    placeholder="请输入虚假登记事项"
                  />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row class="bt0 flex-row">
              <el-col :span="12">
                <el-form-item label="登记机关">
                  <span class="span-content">{{ fraudEntInfo.regOrgCn }}</span>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="登记机关联系方式" prop="tel">
                  <span v-if="onlyShow" class="span-content">{{ fraudEntInfo.tel }}</span>
                  <el-input
                    v-else
                    v-model="fraudEntInfo.tel"
                    placeholder="请输入登记机关联系方式"
                  />
                </el-form-item>
              </el-col>
            </el-row>
            <!--            <el-row class="bt0 flex-row">-->
            <!--              <el-col :span="24">-->
            <!--                <el-form-item style="min-height: 100px" label="被投诉企业委托代理人信息" prop="fraudPersonInfo">-->
            <!--                  <div style="display: flex;">-->
            <!--                    <span style="flex-shrink: 0;width: 100px;text-align: right;">姓名：</span>-->
            <!--                    <span v-if="onlyShow" class="span-content">{{ fraudEntInfo.fraudPersonInfoName }}</span>-->
            <!--                    <el-input-->
            <!--                      v-else-->
            <!--                      v-model="fraudEntInfo.fraudPersonInfoName"-->
            <!--                      style="width: 222px;"-->
            <!--                      placeholder="请输入被投诉企业委托代理人姓名"-->
            <!--                    />-->
            <!--                  </div>-->
            <!--                  <div style="display: flex;">-->
            <!--                    <span style="flex-shrink: 0;width: 100px;text-align: right;">证件类型：</span>-->
            <!--                    <span v-if="onlyShow" class="span-content">{{ fraudEntInfo.fraudPersonInfoCertType }}</span>-->
            <!--                    <el-select v-else v-model="fraudEntInfo.fraudPersonInfoCertType" type="text">-->
            <!--                      <el-option v-for="item in certypeList" :key="item.value" :value="item.value" :label="item.label"></el-option>-->
            <!--                    </el-select>-->
            <!--                  </div>-->
            <!--                  <div style="display: flex;">-->
            <!--                    <span style="flex-shrink: 0;width: 100px;text-align: right;">证件号码：</span>-->
            <!--                    <span v-if="onlyShow" class="span-content">{{ fraudEntInfo.fraudPersonInfoCertNo }}</span>-->
            <!--                    <el-input-->
            <!--                      v-else-->
            <!--                      v-model="fraudEntInfo.fraudPersonInfoCertNo"-->
            <!--                      placeholder="请输入委托代理人证件号码"-->
            <!--                    />-->
            <!--                  </div>-->
            <!--                </el-form-item>-->
            <!--              </el-col>-->
            <!--            </el-row>-->
            <el-row class="bt0">
              <el-form-item label="投诉证据材料" class="upload">
                <el-upload
                  :action="uploadPath"
                  :data="uploadBodyData(1)"
                  :on-remove="removeFile"
                  :on-success="uploadCallback"
                  :on-preview="previewFile"
                  :before-upload="beforeFileUpload"
                  :before-remove="beforeRemove"
                  accept=".doc,.docx,.xlsx,.xls,.pdf,.jpg,.zip,.rar,.7z,.png"
                  multiple
                  :disabled="onlyShow"
                  name="files"
                  :file-list="fileList"
                  style="max-width:800px;display: inline-block"
                  class="uploadFileList"
                  :class="{disabled: onlyShow}"
                >
                  <div v-if="!onlyShow" style="display: inline-block;">
                    <el-button style="display: inline-block;" size="mini" type="primary">点击上传</el-button>
                    <div slot="tip" style="display: inline-block;" class="el-upload__tip">只能上传jpg/png/pdf/doc/docx/xls/xlsx/rar/zip/7z文件，且单个文件不能超过20M</div>
                  </div>
                </el-upload>
              </el-form-item>
            </el-row>
            <!-- <el-row v-for="item in opinions" :key="item.opinionid" class="bt0">
              <el-form-item :label="opiniontypeCN(item.opiniontype)">
                <span style="display: block;text-indent: 1em;">{{ item.opinioncontent }}</span>
                <el-col :span="8" :offset="16">
                  <label>{{ opiniontypeCN2(item.opiniontype) }}:</label>
                  <span>{{ item.handler }}</span>
                  <label
                    style="margin-left: 10px"
                  >日期:</label>
                  <span style="display: inline-block">{{ item.handledate | datetime }}</span>
                </el-col>
              </el-form-item>
            </el-row> -->
            <el-row class="bt0">
              <el-form-item v-if="!onlyShow" label="经办意见" prop="opinioncontent">
                <el-col :span="24" style="margin-bottom:10px">
                  <el-input
                    v-model="fraudEntInfo.opinioncontent"
                    :autosize="{ minRows: 2 }"
                    type="textarea"
                    placeholder="请输入意见"
                  />
                  <el-row style="border-left:0">
                    <el-col :span="12">
                      <label>常用语</label>
                      <el-select
                        v-model="opinion"
                        placeholder="请选择"
                        clearable
                        style="margin-left: 10px;width: 80%"
                        class="custom"
                      >
                        <el-option
                          v-for="item in opinionOptions"
                          :key="item.value"
                          :label="item.label"
                          :value="item.value"
                        />
                      </el-select>
                    </el-col>
                  </el-row>
                </el-col>

              </el-form-item>
            </el-row>
            <el-row v-if="!onlyShow" class="bt0">
              <el-form-item label="审核人" prop="nextPerformerIds">
                <el-select
                  v-model="fraudEntInfo.nextPerformerIds"
                  filterable
                  clearable
                  placeholder="请选择审核人"
                  class="custom"
                  value-key="primaryKey"
                >
                  <el-option
                    v-for="item in reviewer"
                    :key="'reviewer' + item.primaryKey"
                    :label="item.name"
                    :value="item"
                  />
                </el-select>
              </el-form-item>
            </el-row>
            <el-row v-if="!onlyShow">
              <el-form-item v-if="!onlyShow" label="操作" prop="nextNodeID">
                <span style="display: inline-block">
                  <el-radio
                    v-for="item in nextSequenceFlowList"
                    :key="item.id"
                    v-model="fraudEntInfo.nextNodeID"
                    :label="item.nextNode.id"
                  >{{ item.name }}</el-radio>
                </span>
              </el-form-item>
            </el-row>
          </div>
        </div>
      </el-form>
      <div class="submit-box">
        <el-button v-if="!onlyShow" type="primary" :loading="submitLoading" @click="callHandle(fraudEntInfo.nextNodeID)">提交</el-button>
        <el-button v-if="!onlyShow" type="primary" :loading="submitLoading" @click="temporarySave">暂存</el-button>
        <el-button @click="$router.back()">返回</el-button>
      </div>
    </div>
    <el-dialog
      title="现场核查通知书"
      :visible.sync="editDialog"
      :close-on-click-modal="false"
      width="60%"
      center
    >
      <Editor ref="editorDialog" v-model="editContent" :is-clear="isClear" :is-disable="editorDisable" @getTextVal="getTextVal" />
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" size="mini" :loading="loading" @click="saveTemplate(true,'notice')">保存</el-button>
        <el-button type="primary" size="mini" :loading="loading" @click="print">打印</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import DetailHead from '@/components/DetailHead'
import Editor from '@/components/editor.vue'
import { removeAttachementById, listFile } from '@/api/attachment'
import { getConstant, getEntBaseInfoByCode, getBusFraudInfo, temporarySave, processControl, getTempInfo, getFraudEntBybizSeq } from '@/api/personate'
import { validBeforeUpload } from '@/api/fileUpload'
import { saveOrUpdateRevContent, getRevContentsWithBizseq } from '@/api/revoke'
import { getUsersWithPermission } from '@/api/user'
import { queryEAlterByEntNo } from '@/api/comprehensive'
import { checkIdNum } from '@/utils/rules'

export default {
  components: {
    Editor: Editor,
    DetailHead
    // HandleDialog: HandleDialog
  },
  data() {
    return {
      tempSaveId: '',
      fullscreenLoading: false,
      onlyShow: false,
      nowDate: new Date(),
      uploadPath: `${process.env.VUE_APP_BASE_API}/fraudReg/process/upload`,
      showEntbase: false,
      bizseq: '',
      workflowId: '',
      tasklistid: '',
      personateid: '',
      entInfo: {},
      form: {
        uniScId: '',
        regNo: '',
        searchCode: '',
        entName: '',
        certype: '',
        handlrea: '',
        judauth: '',
        regOrgCn: '',
        noticefrom: '',
        noticeto: '',
        juddate: '',
        cerno: '',
        complaintType: '', // 投诉类型
        complaintReason: '', // 投诉是由
        opinion: '', // 意见
        operation: '', // 后续操作
        nextNodeID: '',
        handledate: ''
      },
      opinion: '',
      // 意见-经办人
      handleOpinion: {
        handler: '',
        handleDate: '',
        opinionContent: ''
      },
      // 意见-审核人
      reviewOpinion: {
        handler: '',
        handleDate: '',
        opinionContent: ''
      },
      // 意见-审批人
      approvalOpinion: {
        handler: '',
        handleDate: '',
        opinionContent: ''
      },
      nextSequenceFlowList: [],
      formRules: {
        complaintType: [
          { required: true, message: '请选择投诉类型', trigger: 'blur' }
        ],
        complaintReason: [
          { required: true, message: '请选择投诉原因', trigger: 'change' }
        ],
        regItem: [
          { required: true, message: '请输入虚假登记事项', trigger: 'blur' }
        ],
        tel: [
          { required: true, message: '请输入登记机关联系方式', trigger: 'blur' }
        ],
        opinioncontent: [
          { required: true, message: '请输入经办意见', trigger: 'blur' }
        ],
        nextPerformerIds: [
          { required: true, message: '请选择审核人' }
        ],
        fraudPersonInfo: [
          { required: true, validator: (rule, value, callback) => {
            if (!this.fraudEntInfo.fraudPersonInfoName) {
              callback('请输入被投诉企业委托代理人姓名')
            } else if (!this.fraudEntInfo.fraudPersonInfoCertType) {
              callback('请选择委托代理人证件类型')
            } else if (!this.fraudEntInfo.fraudPersonInfoCertNo) {
              callback('请输入委托代理人证件号码')
            } else if (this.fraudEntInfo.fraudPersonInfoCertType === '中华人民共和国居民身份证') {
              checkIdNum(rule, this.fraudEntInfo.fraudPersonInfoCertNo, callback)
            } else {
              callback()
            }
          } }
        ],
        isCase: [
          { required: true, message: '请选择是否发起现场核查', trigger: 'blur' }
        ]
      },
      opinionOptions: [],
      certypeList: [],
      historyLog: [],
      exmainerOptions: [],
      fileList: [],
      fileList0: [],
      user: JSON.parse(sessionStorage.getItem('user')),
      reviewer: [],
      submitLoading: false,
      bizFraudInfo: {},
      fraudEntInfo: {},
      fraudPersonInfo: {},
      fraudCheckInfo: {},
      opinions: [],
      eAlterRecoder: [],
      pripid: '',
      dialogTitle: '',
      editDialog: false,
      editContent: '',
      tswrittemplate: {
        content: '',
        bizseq: '',
        writsType: '',
        isTemplate: '',
        needTemplate: ''
      },
      isClear: false, // 清除富文本编辑器内容
      editorDisable: false,
      loading: false,
      printContent: ''
    }
  },
  computed: {
    certype() {
      return (value) => {
        const target = this.certypeList.find((item) => {
          return item.value === value
        })
        return target ? target.label : ''
      }
    },
    uploadBodyData() {
      return (attachType) => {
        return {
          attachType,
          id: this.bizseq
        }
      }
    },
    // opiniontypeCN() {
    //   return (value) => {
    //     return {
    //       '1': '经办意见',
    //       '2': '审核人意见',
    //       '3': '审批人意见'
    //     }[value]
    //   }
    // },
    opiniontypeCN() {
      return (value) => {
        return {
          '1': '经办',
          '2': '审核',
          '3': '审批'
        }[value]
      }
    }
  },
  watch: {
    // 意见渲染
    opinion() {
      let name = ''
      this.opinionOptions.forEach(each => {
        if (this.opinion === each.value) {
          name = each.label
        }
      })
      if (this.$util.isNotEmpty(name)) {
        this.$set(this.fraudEntInfo, 'opinioncontent', name)
        this.$refs.form.validateField('opinioncontent')
      }
    }
  },
  mounted() {
    this.bizseq = this.$route.query.bizseq // 获取跳转携带的参数bizseq
    this.workflowId = this.$route.query.workflowId
    this.tasklistid = this.$route.query.tasklistid
    this.onlyShow = this.$route.query.onlyShow === 'true'
    // 加载常用语
    this.opinionOptions = this.$util.getCommonWordsWithModule(this.user.primaryKey, '撤销登记案件')
    // 加载证件类型
    const p1 = getConstant('CB16').then(res => {
      if (res.code === 0) {
        const list = []
        res.data.forEach(each => {
          list.push({
            value: each.code,
            label: each.name
          })
        })
        this.certypeList = list
      }
    })

    const p2 = getBusFraudInfo({
      bizSeq: this.bizseq,
      workflowId: this.$route.query.workflowId,
      readOnly: this.onlyShow ? '1' : '0'
    }).then(res => {
      if (res.code === 0) {
        this.bizFraudInfo = res.data.bizFraudInfo || {}
        this.fraudPersonInfo = res.data.fraudPersonInfo || {}
        this.fraudCheckInfo = res.data.fraudCheckInfo || {}
        this.fraudEntInfo = {
          ...res.data.fraudEntInfo,
          complaintReason: this.bizFraudInfo.complaintReason,
          fraudPersonInfoName: this.fraudPersonInfo.name,
          fraudPersonInfoCertType: this.fraudPersonInfo.certType,
          fraudPersonInfoCertNo: this.fraudPersonInfo.certNo,
          isCase: this.bizFraudInfo.isCase,
          content: this.fraudCheckInfo.content,
          notice: this.fraudCheckInfo.notice,
          remarks: this.fraudCheckInfo.remarks
        }
        this.$nextTick(() => {
          this.$refs.form.clearValidate()
        })
        this.opinions = res.data.opinions
        this.nextSequenceFlowList = (res.data.nextSequenceFlowList || []).map((item) => {
          return {
            ...item,
            loading: false
          }
        })
        return getEntBaseInfoByCode({
          code: this.fraudEntInfo.uniScId
        })
      }
    }).then((res) => {
      this.entInfo = res.data
      this.fraudEntInfo.complainantCertype = this.$util.enumFormatter(this.certypeList, res.data.complainantCertype)
      this.fraudEntInfo.handledate = this.fraudEntInfo.handledate || this.$util.formatDate.format(new Date(), 'yyyy-MM-dd hh:mm:ss')

      getTempInfo(this.bizseq, '撤销登记案件', '登记-待受理').then(res => {
        if (res.data) {
          const tempInfo = JSON.parse(res.data.dataJson)
          console.log(tempInfo)
          this.fraudEntInfo.isCase = tempInfo.isCase
          this.fraudEntInfo.complaintReason = tempInfo.complaintReason
          this.fraudEntInfo.regTime = tempInfo.regTime
          this.fraudEntInfo.regItem = tempInfo.regItem
          this.fraudEntInfo.content = tempInfo.content
          this.fraudEntInfo.remarks = tempInfo.remarks
          this.fraudEntInfo.regOrgCn = tempInfo.regOrgCn
          this.fraudEntInfo.tel = tempInfo.tel
          this.tempSaveId = res.data.id
          this.$set(this.fraudEntInfo, 'opinioncontent', tempInfo.opinioncontent)
          console.log(this.fraudEntInfo)
        }
      })
    })
    const p3 = this.loadReviewer()

    const p4 = listFile({
      attachType: '0',
      id: this.bizseq
    }).then(({ data }) => {
      this.fileList0 = data.map((item) => {
        return {
          ...item,
          id: item.attachmentid,
          name: item.filename,
          url: `${process.env.VUE_APP_BASE_API}/attachment/download?id=${item.id}`
        }
      })
    })
    const p5 = listFile({
      attachType: '1',
      id: this.bizseq
    }).then(({ data }) => {
      this.fileList = data.map((item) => {
        return {
          ...item,
          id: item.attachmentid,
          name: item.filename,
          url: `${process.env.VUE_APP_BASE_API}/attachment/download?id=${item.id}`
        }
      })
    })

    const p6 = getFraudEntBybizSeq({
      bizSeq: this.bizseq
    }).then(res => {
      queryEAlterByEntNo(
        res.data.pripid
      ).then(resa => {
        const data = resa.data
        const list = []
        let index = 0
        data.forEach(each => {
          each.index = ++index
          list.push(each)
        })
        this.eAlterRecoder = list
        return true
      })
    })

    this.fullscreenLoading = true
    Promise.all([p1, p2, p3, p4, p5, p6]).finally(() => {
      this.fullscreenLoading = false
    })
  },
  methods: {
    // 打印
    print() {
      const html = '<div id="printPaper" class="printPaper">' + this.tswrittemplate.content + '</div>'
      const printHtml = html// 获取到要打印的节点内容
      window.document.body.innerHTML = printHtml// 把打印内容赋值给页面内容

      window.print()// 调用打印方法
      window.location.reload()// 打印之后页面重新加载
    },
    // 获取现场核查通知书
    getCaseReport() {
      this.tswrittemplate.bizseq = this.bizseq
      this.tswrittemplate.writsType = '42'
      this.tswrittemplate.needTemplate = '1'
      return getRevContentsWithBizseq(this.tswrittemplate).then(res => {
        if (res.code === 0) {
          this.$nextTick(() => {
            this.$set(this.tswrittemplate, 'content', res.data.content.replace(new RegExp('{{complainerName}}', 'g'), this.bizFraudInfo.complainerName)
              .replace(new RegExp('{{entName}}', 'g'), this.fraudEntInfo.entName)
              .replace(new RegExp('{{dom}}', 'g'), this.entInfo.dom)
              .replace(new RegExp('{{orgName}}', 'g'), this.user.orgName))
            this.$set(this.tswrittemplate, 'isTemplate', res.data.isTemplate)
          })
        }
      })
    },
    // 保存模板编辑内容
    async saveTemplate(alertMsg, type) {
      // console.log(this.hearingNoticeInfo)
      this.loading = true
      let resData = false
      if (type === 'notice') {
        this.tswrittemplate.content = this.editContent
        await saveOrUpdateRevContent(this.tswrittemplate).then(res => {
          resData = res.data
          this.tswrittemplate.isTemplate = resData ? '0' : '1'
        })
      }
      this.loading = false
      if (resData === true) {
        this.editDialog = false
        if (alertMsg) {
          this.$message.success('保存成功')
        }
      } else {
        if (alertMsg) {
          return this.$message.error('保存失败')
        } else {
          return false
        }
      }
    },
    getEditorText() {
      this.$refs.editorDialog.$emit('getText')
    },
    getTextVal(res) {
      this.printContent = res
      console.log(this.printContent)
    },
    async clearEditorContent(type) {
      if (this.$refs.editorDialog && type !== this.editorDialogType) {
        await this.$refs.editorDialog.$emit('clear')
      }
    },
    openDialog() {
      this.editDialog = true
      // this.clearEditorContent()
      this.$nextTick(() => {
        this.editContent = this.tswrittemplate.content
      })
    },
    toEntDetail(uniscid) {
      this.$router.push({
        path: '/comprehensive/details',
        query: {
          pripid: this.entInfo.pripid
        }
      })
    },
    // 移除文件前
    beforeRemove(file, fileList) {
      if (file && file.status === 'success') {
        return this.$confirm(`确定移除 ${file.name} ？`)
      }
    },
    // 上传文件之前校验大小
    beforeFileUpload(file) {
      var that = this
      return validBeforeUpload(file, that)
    },
    // 上传文件预览
    previewFile(file) {
      window.open(`${process.env.VUE_APP_BASE_API}/attachment/download?id=${file.id}`, '_blank')
    },
    uploadCallback(res, file) {
      if (res.code === 0) {
        file.id = res.data[0].attachmentid
        file.name = res.data[0].filename
        file.url = `${process.env.VUE_APP_BASE_API}/attachment/download?id=${res.data[0].id}`
        this.$message.success('上传成功')
      }
    },
    // 移除文件回调
    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('handleCancel', this.user.orgId, null).then(res => {
        if (res.code === 0) {
          this.reviewer = res.data
        }
      })
    },
    temporarySave() {
      const tempData = {
        isCase: this.fraudEntInfo.isCase,
        complaintReason: this.fraudEntInfo.complaintReason,
        regTime: this.fraudEntInfo.regTime,
        regItem: this.fraudEntInfo.regItem,
        content: this.fraudEntInfo.content,
        remarks: this.fraudEntInfo.remarks,
        regOrgCn: this.fraudEntInfo.regOrgCn,
        tel: this.fraudEntInfo.tel,
        opinioncontent: this.fraudEntInfo.opinioncontent
      }
      const param = {
        id: this.tempSaveId,
        bizseq: this.bizseq,
        module: '撤销登记案件',
        flow: '登记-待受理',
        data: tempData,
        creator: this.user.nickname,
        creator_id: this.user.primaryKey
      }
      temporarySave(param).then((res) => {
        if (res.code === 0) {
          this.tempSaveId = res.data
          this.$message.success('提交成功')
        } else {
          throw res
        }
      })
    },
    callHandle(nextId) {
      if (nextId == 'handleCancel') {
        this.handleCancel(nextId)
      } else if (nextId == 'cancelCase') {
        this.cancelCase(nextId)
      } else {
        this.$message.error('未找到响应的流程处理器')
      }
      // if (typeof this[handleName] === 'function') {
      //   this[handleName](item)
      // } else {
      //   this.$message.error('未找到响应的流程处理器')
      // }
    },
    isCaseChangeEvent() {
      if (this.fraudEntInfo.isCase === '1') {
        this.getCaseReport()
      }
    },
    cancelCase(item) {
      this.$confirm('是否确认提交？', '提示', {
        beforeClose: (action, instance, done) => {
          if (action === 'confirm') {
            instance.confirmButtonLoading = true
            processControl({
              nextNodeID: item,
              complaintReason: '无效参数',
              bizSeq: this.bizseq
            }).then((res) => {
              if (res.code === 0) {
                this.$message.success('提交成功')
                this.$router.push('/todo/list')
              } else {
                throw res
              }
            }).finally(() => {
              instance.confirmButtonLoading = false
              done()
            })
          } else if (!instance.confirmButtonLoading) {
            done()
          }
        }
      })
    },
    handleCancel(item) {
      this.$refs.form.validate((valid, rules) => {
        if (!valid) {
          this.$message.warning(rules[Object.keys(rules)[0]][0].message)
          return
        }
        this.$confirm('是否确认提交？', '提示', {
          beforeClose: (action, instance, done) => {
            if (action === 'confirm') {
              instance.confirmButtonLoading = true
              processControl({
                fraudEntInfo: this.fraudEntInfo,
                fraudCheckInfo: {
                  content: this.fraudEntInfo.content,
                  notice: this.fraudEntInfo.notice,
                  remarks: this.fraudEntInfo.remarks
                },
                fraudPersonInfo: {
                  ...this.fraudPersonInfo,
                  name: this.fraudEntInfo.fraudPersonInfoName,
                  certType: this.fraudEntInfo.fraudPersonInfoCertType,
                  certNo: this.fraudEntInfo.fraudPersonInfoCertNo
                },
                nextNodeID: item,
                complaintReason: this.fraudEntInfo.complaintReason,
                bizSeq: this.bizseq,
                opinion: {
                  opiniontype: '1',
                  opinioncontent: this.fraudEntInfo.opinioncontent
                },
                nextPerformerIds: [this.fraudEntInfo.nextPerformerIds.primaryKey],
                nextPerformerNames: [this.fraudEntInfo.nextPerformerIds.name],
                isCase: this.fraudEntInfo.isCase
              }).then((res) => {
                if (res.code === 0) {
                  this.$message.success('提交成功')
                  this.$router.push('/todo/list')
                } else {
                  throw res
                }
              }).finally(() => {
                instance.confirmButtonLoading = false
                done()
              })
            } else if (!instance.confirmButtonLoading) {
              done()
            }
          }
        })
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.el-row.flex-row{
  display: flex;
  .el-col{
    display: flex;
    .el-form-item{
      width: 100%;
      display: flex;
      /deep/ .el-form-item__label{
        flex-shrink: 0;
      }
      /deep/ .el-form-item__content{
        width: 100%;
        min-height: 60px;
        margin-left: 0px!important;
      }
    }
  }
}
.uploadFileList.disabled{
  /deep/ .el-upload{
    display: none;
  }
}
.main-content{
  font-size: $table-content-font-size;
  /deep/ .el-form-item__content{
    padding: 5px;
  }
  .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: $font-size-sub-title;
    }
  }
  .content-body{
    padding:20pt;
      .tab{
        .tab-title{
          text-align: left;
          padding-left: 20px;
          label{
            color: #000;
            font-weight: bold;
            display:inline-block;
          }
        }
      }
    .form{
      margin-bottom: 20pt;
    }
  }
  .span-content{
    display: block;
    text-indent: 1em;
  }
}
.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;
  }
}
</style>
<style lang="scss">
.main-content.abnormal{
  .el-form-item{
    margin-bottom:0;
    background: $color-form-label;
    .el-form-item__label{
      padding: 10px;
      border-top: 1px solid $color-border;
      font-size: $table-content-font-size;
      /* border-left: 1px solid $color-border; */
    }
    .el-form-item__content{
      font-size: 16px;
      background: white;
      font-size: $table-content-font-size;
      border-top: 1px solid $color-border;
      border-right: 1px solid $color-border;
      border-left: 1px solid $color-border;
      padding: 10px;
      // min-height: 60px;
    }
  }
  .el-form-item:last-child{
    border-bottom: 1px solid $color-border;
  }
  .form-body.history{
    padding:15px;
    border:1px solid $color-border;
  }
  .form-body.history .none{
    font-size: 14px;
  }

  .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.is-disabled .el-input__inner

  .el-input__inner{
    width: 50%;
  }
  .uploadFileList{
    .el-upload-list__item{
      display: inline-block;
      width: auto;
    }
  }
}
@media print{
/* 浏览区域 */
  .preview-box{
      background-color:#e6e6e6;
       text-align:center;
       border:1PX solid #eee;
       min-height:800PX;
       overflow: hidden;
    }
    .paper-box{
        display: inline-block;
        margin-top:10PX
    }
    .paper{
        width:630PX;
        min-height:891PX;
        background:white;
        // border:1PX solid #ccc;
        padding:40PX 50PX;

    }
/* 表格 */
.paper-table>div{border:1PX solid black;border-bottom: none;}
.paper-table>div:last-child{border-bottom:1PX solid black}
.row-field:not(:first-child){border-top:1PX solid black}
.field{min-height: 45PX;border-left:1PX solid black}
.paper-table td,.paper-table th{
    .right{
        text-align: right;
    }
    font-weight: normal;
    padding: 5PX 5PX;
    }
/* 标题 */
.paper-header{text-align: center; line-height: 35PX;}
.paper-header>h3{font-weight:600;margin:0}
/* 换行 */
.enter{margin-top:20PX}
.enter:before{content:''}
.right_down{
    text-align: right;
    line-height: 30px;
}
.printPaper{
    width:700PX;
    min-height:891PX;
    background:white;
    // border:1PX solid #ccc;
    padding:40PX 50PX;
}
.line2{
      border-top: 0px;
    td,th{
        .right{
            text-align: right;
        }
        font-weight: normal;
        padding: 15PX 5PX;
    }
    .mr20 {
        margin-right: 20px;
    }
}
  .paper-content{
 .firstLine{
        text-align: left;
    }
 .name{
    display: inline-block;
    }
 .downLine{
     border-bottom: solid 1px;
 }
}
p {
    // text-indent: 2em;
    text-align: left;
    line-height: 40px; //行间距
    font-size: 24px
    // span{
    //     border-bottom: solid 1px;
    // }
}
.mr20 {
  margin-right: 20px;
}
.printPaper{
        min-height:891PX;
        background:white;
        padding:40PX 50PX;
       .el-divider--horizontal {
            margin: 8px 0;
            background: 0 0;
            border-top: 1px dashed #18191a;
        }
    }
@page {
    size: auto;
    margin: 0mm;
}
}
</style>
