<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="220px" 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="flex-row">
              <el-col :span="12">
                <el-form-item label="投诉原因">
                  <span class="span-content">{{ fraudEntInfo.complaintReason }}</span>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="冒名登记时间">
                  <span class="span-content">{{ fraudEntInfo.regTime }}</span>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <el-form-item label="冒名登记事项">
                  <span class="span-content">{{ fraudEntInfo.regItem }}</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">{{ fraudEntInfo.regOrgCn }}</span>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="登记机关联系方式">
                  <span class="span-content">{{ fraudEntInfo.tel }}</span>
                </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 class="span-content">{{ fraudEntInfo.fraudPersonInfoName }}</span>-->
            <!--                  </div>-->
            <!--                  <div style="display: flex;">-->
            <!--                    <span style="flex-shrink: 0;width: 100px;text-align: right;">证件类型：</span>-->
            <!--                    <span class="span-content">{{ certype(fraudEntInfo.fraudPersonInfoCertType) }}</span>-->
            <!--                  </div>-->
            <!--                  <div style="display: flex;">-->
            <!--                    <span style="flex-shrink: 0;width: 100px;text-align: right;">证件号码：</span>-->
            <!--                    <span class="span-content">{{ fraudEntInfo.fraudPersonInfoCertNo }}</span>-->
            <!--                  </div>-->
            <!--                </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="readOnly" 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="readOnly" class="span-content">{{ certype(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-select>
                  </div>
                  <div style="display: flex;">
                    <span style="flex-shrink: 0;width: 100px;text-align: right;">证件号码：</span>
                    <span v-if="readOnly" class="span-content">{{ fraudEntInfo.fraudPersonInfoCertNo }}</span>
                    <el-input
                      v-else
                      v-model="fraudEntInfo.fraudPersonInfoCertNo"
                      placeholder="请输入委托代理人证件号码"
                    />
                  </div>

                  <div style="display: flex;">
                    <span style="color:red">因虚假市场主体登记被撤销的市场主体,其直接责任人自市场主体登记被撤销之日起3 年内不得再次申请市场主体登记。登记机关应当通过国家企业信用信息公示系统予以公示</span>
                  </div>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row class="bt0">
              <el-form-item label="投诉证据材料">
                <el-upload
                  :action="uploadPath"
                  :on-preview="previewFile"
                  disabled
                  :file-list="fileList"
                  style="max-width:800px;display: inline-block"
                  class="uploadFileList disabled"
                />
              </el-form-item>
            </el-row>
            <el-row class="bt0">
              <el-col :span="12">
                <el-form-item label="公告期自">
                  <span class="span-content">{{ fraudEntInfo.noticeFrom }}</span>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="公告期至">

                  <span class="span-content">{{ fraudEntInfo.noticeTo }}</span>
                </el-form-item>
              </el-col>
            </el-row>
          </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">
              <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"
                :on-preview="previewFile"
                disabled
                :file-list="fileList0"
                style="max-width:800px;display: inline-block"
                class="uploadFileList disabled"
              />
            </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="'opinions'+index" :title="each.step + '人：' + each.handler + ' ' + each.step +'日期：' + 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="bt0">
              <el-form-item prop="handleReaCn" label-width="220px" label="处理原因：">
                <span v-if="readOnly" class="span-content">{{ fraudEntInfo.handleReaCn }}</span>
                <el-select
                  v-else
                  v-model="fraudEntInfo.handleReaCn"
                  placeholder="请选择"
                  clearable
                  style="width: 80%"
                  class="custom"
                  value-key="value"
                  @change="(item)=>{
                    fraudEntInfo.handleRea = item.value
                    fraudEntInfo.handleReaCn = item.label;
                  }"
                >
                  <el-option
                    v-for="item in handlreaList"
                    :key="item.value"
                    :label="item.label"
                    :value="item"
                  />
                </el-select>
              </el-form-item>
            </el-row>
            <el-row class="bt0">
              <el-form-item prop="handleResult" label-width="220px" label="处理结果：">
                <span v-if="readOnly" class="span-content">{{ fraudEntInfo.bizHandleResult }} </span>
                <el-radio-group v-else v-model="fraudEntInfo.bizHandleResult" class="custom" style="margin-bottom: 10px;width: 80%">
                  <el-radio :label="'撤销设立'">撤销设立</el-radio>
                  <el-radio :label="'撤销变更'">撤销变更</el-radio>
                  <el-radio :label="'撤销注销'">撤销注销</el-radio>
                  <el-radio :label="'终止撤销'">终止撤销</el-radio>
                  <el-radio :label="'不予撤销'">不予撤销</el-radio>
                </el-radio-group>
                <br>
                <span v-if="readOnly" class="span-content">{{ fraudEntInfo.handleResult }} </span>
                <el-input
                  v-else
                  v-model="fraudEntInfo.handleResult"
                  :autosize="{ minRows: 2 }"
                  type="textarea"
                  placeholder="请输入处理结果"
                />
              </el-form-item>
            </el-row>
            <el-row class="bt0">
              <el-form-item prop="judAuthCn" label-width="220px" label="作出决定机关">
                <span v-if="readOnly" class="span-content">{{ fraudEntInfo.judAuthCn }}</span>
                <el-select
                  v-else
                  v-model="fraudEntInfo.judAuthCn"
                  placeholder="请选择"
                  clearable
                  style="width: 80%"
                  class="custom"
                  value-key="value"
                  @change="(item)=>{
                    fraudEntInfo.judAuth = item.value
                    fraudEntInfo.judAuthCn = item.label;
                  }"
                >
                  <el-option
                    v-for="item in judauthList"
                    :key="item.value"
                    :label="item.label"
                    :value="item"
                  />
                </el-select>
              </el-form-item>
            </el-row>
            <el-row class="bt0">
              <el-col :span="24">
                <el-form-item prop="judDate" label="作出决定日期：">
                  <span v-if="readOnly" class="span-content">{{ fraudEntInfo.judDate }}</span>
                  <el-date-picker
                    v-else
                    v-model="fraudEntInfo.judDate"
                    style="display: inline-block"
                    :clearable="false"
                    value-format="yyyy-MM-dd"
                    format="yyyy-MM-dd"
                    size="small"
                    type="date"
                    placeholder="选择日期"
                    :picker-options="{
                      firstDayOfWeek: 1,
                      disabledDate: (date)=>{
                        return date.setHours(0,0,0,0) > (new Date()).setHours(0,0,0,0)
                      }
                    }"
                    @change="
                      (value)=>{
                        if(new Date().valueOf() - new Date(value).valueOf() > 1000*60*60*24*365 ){
                          $confirm(`您选择的日期为${$utils.parseTime(new Date(value), '{yyyy}年{mm}月{dd}日')}，请确认！`,{
                            showClose: false,
                            closeOnClickModal: false,
                            showCancelButton: false
                          })
                        }
                      }
                    "
                  />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row class="bt0">
              <el-form-item label-width="220px" label="公告内容：">
                <span v-if="readOnly" class="span-content">{{ fraudEntInfo.noticeContent }}</span>
                <el-input
                  v-else
                  v-model="fraudEntInfo.noticeContent"
                  :autosize="{ minRows: 2 }"
                  type="textarea"
                  placeholder="请输入公告内容"
                />
              </el-form-item>
            </el-row>
            <!--            <el-row class="bt0">-->
            <!--              <el-col :span="24">-->
            <!--                <el-form-item label="公告日期：">-->
            <!--                  <span v-if="readOnly" class="span-content">{{ fraudEntInfo.noticeDate }}</span>-->
            <!--                  <el-date-picker-->
            <!--                    v-else-->
            <!--                    v-model="fraudEntInfo.noticeDate"-->
            <!--                    style="display: inline-block"-->
            <!--                    :clearable="false"-->
            <!--                    value-format="yyyy-MM-dd"-->
            <!--                    format="yyyy-MM-dd"-->
            <!--                    size="small"-->
            <!--                    type="date"-->
            <!--                    placeholder="选择日期"-->
            <!--                    :picker-options="{-->
            <!--                      firstDayOfWeek: 1,-->
            <!--                      disabledDate: (date)=>{-->
            <!--                        return date.setHours(0,0,0,0) > (new Date()).setHours(0,0,0,0)-->
            <!--                      }-->
            <!--                    }"-->
            <!--                    @change="-->
            <!--                      (value)=>{-->
            <!--                        if(new Date().valueOf() - new Date(value).valueOf() > 1000*60*60*24*365 ){-->
            <!--                          $confirm(`您选择的日期为${$utils.parseTime(new Date(value), '{yyyy}年{mm}月{dd}日')}，请确认！`,{-->
            <!--                            showClose: false,-->
            <!--                            closeOnClickModal: false,-->
            <!--                            showCancelButton: false-->
            <!--                          })-->
            <!--                        }-->
            <!--                      }-->
            <!--                    "-->
            <!--                  />-->
            <!--                </el-form-item>-->
            <!--              </el-col>-->
            <!--            </el-row>-->
            <el-row v-if="fraudEntInfo.bizHandleResult" class="bt0">
              <el-form-item
                prop="fileList3"
                :label="{
                  '撤销设立': '撤销设立决定书',
                  '撤销变更': '撤销变更通知书',
                  '撤销注销': '撤销注销通知书',
                  '终止撤销': '终止撤销通知书',
                  '不予撤销': '不予受理通知书',
                }[fraudEntInfo.bizHandleResult]"
              >
                <el-upload
                  ref="fileList3"
                  :action="uploadPath"
                  :data="uploadBodyData(3)"
                  :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
                  name="files"
                  :file-list="fileList3"
                  style="max-width:800px;display: inline-block"
                  class="uploadFileList"
                  :disabled="readOnly"
                  :class="{disabled: readOnly}"
                >
                  <div v-if="!readOnly" 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-if="fraudEntInfo.bizHandleResult === '撤销设立' || fraudEntInfo.bizHandleResult === '撤销变更' || fraudEntInfo.bizHandleResult === '撤销注销' " class="bt0">
              <el-col :span="24">
                <el-form-item label="撤销文书号：" prop="canceldocno">
                  <span v-if="readOnly" class="span-content">{{ fraudEntInfo.canceldocno }}</span>
                  <div v-else class="canceldocno-input">
                    <el-input
                      v-model="canceldocno.left"
                      type="text"
                    />
                    〔
                    <el-input
                      v-model="canceldocno.middle"
                      type="text"
                    />
                    〕
                    <el-input
                      v-model="canceldocno.right"
                      type="text"
                    />
                    号
                  </div>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row v-if="fraudEntInfo.bizHandleResult === '撤销设立' || fraudEntInfo.bizHandleResult === '撤销变更' || fraudEntInfo.bizHandleResult === '撤销注销' " class="bt0 autoaddresslock">
              <el-form-item prop="autoaddresslock" label-width="220px" label="该次撤销的企业住所（地址）均是否属于虚假（住宅）地址：">
                <span v-if="readOnly" class="span-content">{{ fraudEntInfo.autoaddresslock === '1'? '是':'否' }}</span>
                <el-select
                  v-else
                  v-model="autoaddresslock"
                  style="width: 80%"
                  class="custom"
                >
                  <el-option
                    v-for="item in autoaddresslockList"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"
                  />
                </el-select>
              </el-form-item>
            </el-row>
            <el-row class="bt0">
              <el-form-item label="案件卷宗上传扫描件">
                <el-upload
                  :action="uploadPath"
                  :data="uploadBodyData(2)"
                  :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
                  name="files"
                  :file-list="fileList2"
                  style="max-width:800px;display: inline-block"
                  class="uploadFileList"
                  :disabled="readOnly"
                  :class="{disabled: readOnly}"
                >
                  <div v-if="!readOnly" 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 v-if="!readOnly" class="bt0 p0">
              <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="!readOnly" type="primary" :loading="submitLoading" @click="submitForm">提交</el-button>
        <el-button v-if="!readOnly" type="primary" :loading="submitLoading" @click="temporarySave">暂存</el-button>
        <el-button @click="$router.back()">返回</el-button>
      </div>
      <el-dialog
        title="提示"
        :visible.sync="msgVisible"
        append-to-body="true"
        width="30%"
      >
        <i class="el-icon-info" style="font-size: 18px;margin-right: 6px;" />
        <span style="line-height: 23px;">{{ msg }}</span>
        <span slot="footer" class="dialog-footer">
          <el-button @click="msgVisible = false">取消</el-button>
          <el-button type="primary" @click="msgClick">确定</el-button>
        </span>
      </el-dialog>
    </div>
  </div>
</template>

<script>
import DetailHead from '@/components/DetailHead'
import { listFile, removeAttachementById } from '@/api/attachment'
import {
  getAllDepts,
  getBusFraudInfo,
  getConstant,
  getEntBaseInfoByCode,
  getSteps,
  processControl,
  temporarySave,
  getFraudEntBybizSeq,
  getTempInfo
} from '@/api/personate'
import { validBeforeUpload } from '@/api/fileUpload'
import { queryEAlterByEntNo } from '@/api/comprehensive'
import { checkIdNum } from '@/utils/rules'

export default {
  components: {
    DetailHead
  },
  data() {
    return {
      tempSaveId: '',
      fullscreenLoading: false,
      onlyShow: '',
      judauthList: [],
      handlreaList: [],
      uploadPath: `${process.env.VUE_APP_BASE_API}/fraudReg/process/upload`,
      showEntbase: false,
      bizseq: '',
      workflowId: '',
      tasklistid: '',
      personateid: '',
      form: {
        uniscid: '',
        regno: '',
        searchCode: '',
        entname: '',
        certype: '',
        handlrea: '',
        judauth: '',
        regorgCn: '',
        noticefrom: '',
        noticeto: '',
        judDate: '',
        cerno: '',
        opiniontype: '',
        complaintType: '', // 投诉事由
        reason: '', // 投诉是由
        opinion: '', // 意见
        nextNodeID: ''
      },
      opinion: '',
      // 意见-经办人
      handleOpinion: {
        handler: '',
        handleDate: '',
        opinionContent: ''
      },
      // 意见-审核人
      reviewOpinion: {
        handler: '',
        handleDate: '',
        opinionContent: ''
      },
      // 意见-审批人
      approvalOpinion: {
        handler: '',
        handleDate: '',
        opinionContent: ''
      },
      formRules: {
        handleReaCn: [
          { required: true, message: '请选择处理原因', trigger: 'blur' }
        ],
        handleResult: [
          { required: true, message: '请输入处理结果', trigger: 'blur' }
        ],
        judAuthCn: [
          { required: true, message: '请选择作出决定机关', trigger: 'blur' }
        ],
        judDate: [
          { required: true, message: '请选择作出决定日期', trigger: 'blur' }
        ],
        nextNodeID: [
          { required: true, message: '请选择下一步操作', trigger: 'blur' }
        ],
        fileList3: [
          { required: true, validator: this.validateFile }
        ],
        casePerformerId: [
          { required: true, message: '请选择检查接收人', trigger: 'blur' }
        ],
        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()
            }
          } }
        ],
        canceldocno: [
          { required: true, validator: (rule, value, callback) => {
            if (!this.canceldocno.left || !this.canceldocno.middle || !this.canceldocno.right) {
              callback('请输入撤销文书号')
            } else {
              callback()
            }
          } }
        ]
      },
      opinionOptions: [],
      eAlterRecoder: [],
      pripid: '',
      historyLog: [],
      certypeList: [],
      exmainerOptions: [],
      fileList: [],
      fileList0: [],
      fileList2: [],
      fileList3: [],
      user: JSON.parse(sessionStorage.getItem('user')),
      reviewer: [],
      submitLoading: false,
      complaintTypeStr: '',
      nextNodeID: '',
      nextSequenceFlowList: [],
      entInfo: {},
      bizFraudInfo: {},
      fraudEntInfo: {},
      opinions: [],
      readOnly: false,
      canceldocno: { // 撤销文书号拼接
        left: '',
        middle: '',
        right: ''
      },
      autoaddresslock: '0', // 该次撤销的企业住所（地址）均是否属于虚假（住宅）地址
      autoaddresslockList: [{
        value: '0',
        label: '否'
      }, {
        value: '1',
        label: '是'
      }
      ],
      msgVisible: false, // 撤销设立提示框显示控制
      msg: '' // 撤销设立提示信息
    }
  },
  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]
      }
    },
    opiniontypeCN2() {
      return (value) => {
        return {
          '1': '经办人',
          '2': '审核人',
          '3': '审批人'
        }[value]
      }
    }
  },
  watch: {
    // 监听通过单选框给表单nextNodeID赋值
    'nextNodeID': {
      handler(newVal, oldVal) {
        this.$set(this.form, 'nextNodeID', newVal)
        this.$refs.form.validateField('nextNodeID')
      },
      deep: true
    },
    // 意见渲染
    opinion() {
      let name = ''
      this.opinionOptions.forEach(each => {
        if (this.opinion === each.value) {
          name = each.label
        }
      })
      if (this.$util.isNotEmpty(name)) {
        this.$set(this.form, 'opinion', name)
        this.$refs.form.validateField('opinion')
      }
    }
  },
  mounted() {
    this.bizseq = this.$route.query.bizseq // 获取跳转携带的参数bizseq
    this.workflowId = this.$route.query.workflowId
    this.readOnly = this.$route.query.onlyShow === 'true'
    // 加载常用语
    this.opinionOptions = this.$util.getCommonWordsWithModule(this.user.primaryKey, '撤销登记案件')
    // 加载处理原因
    const p1 = getConstant('CD96').then(res => {
      if (res.code === 0) {
        const list = []
        res.data.forEach(each => {
          list.push({
            value: each.code,
            label: each.name
          })
        })
        this.handlreaList = list
      }
    })
    // 加载证件类型
    const p2 = 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 p3 = getAllDepts().then(res => {
      if (res.code === 0) {
        this.judauthList = res.data.map((item) => {
          return {
            value: item.code,
            label: item.name
          }
        })
        return getBusFraudInfo({
          bizSeq: this.bizseq,
          workflowId: this.$route.query.workflowId,
          readOnly: this.readOnly ? '1' : '0'
        })
      }
    }).then(res => {
      if (res.code === 0) {
        this.bizFraudInfo = res.data.bizFraudInfo || {}
        this.fraudPersonInfo = res.data.fraudPersonInfo || {}
        this.fraudEntInfo = {
          ...res.data.fraudEntInfo,
          _judAuth: {},
          bizHandleResult: this.bizFraudInfo.bizHandleResult,
          complaintReason: this.bizFraudInfo.complaintReason,
          fraudPersonInfoName: this.fraudPersonInfo.certNo ? this.fraudPersonInfo.name : '',
          fraudPersonInfoCertType: this.fraudPersonInfo.certType,
          fraudPersonInfoCertNo: this.fraudPersonInfo.certNo
        }

        if (!this.fraudEntInfo.judAuth) {
          const user = JSON.parse((sessionStorage.getItem('user')))
          const judAuth = this.judauthList.find((item) => {
            return item.label === user.orgName
          })
          if (judAuth) {
            this.$set(this.fraudEntInfo, 'judAuthCn', judAuth)
            this.fraudEntInfo.judAuth = judAuth.value
            this.fraudEntInfo.judAuthCn = judAuth.label
          }
        }

        getTempInfo(this.bizseq, '撤销登记案件', '立案经办').then(res => {
          if (res.data) {
            console.log(res.data)
            const tempInfo = JSON.parse(res.data.dataJson)
            console.log(tempInfo)
            this.fraudEntInfo.fraudPersonInfoName = tempInfo.fraudPersonInfoName
            this.fraudEntInfo.fraudPersonInfoCertType = tempInfo.fraudPersonInfoCertType
            this.fraudEntInfo.fraudPersonInfoCertNo = tempInfo.fraudPersonInfoCertNo
            this.fraudEntInfo.handleReaCn = tempInfo.handleReaCn
            this.fraudEntInfo.bizHandleResult = tempInfo.bizHandleResult
            this.fraudEntInfo.handleResult = tempInfo.handleResult
            this.fraudEntInfo.judAuth = tempInfo.judAuth
            this.fraudEntInfo.judAuthCn = tempInfo.judAuthCn
            this.fraudEntInfo.judDate = tempInfo.judDate
            this.fraudEntInfo.noticeContent = tempInfo.noticeContent
            this.fraudEntInfo.noticeDate = tempInfo.noticeDate
            this.fraudEntInfo.canceldocno = tempInfo.canceldocno
            // 撤销文书号
            this.canceldocno.left = tempInfo.canceldocnoLeft
            this.canceldocno.middle = tempInfo.canceldocnoMiddle
            this.canceldocno.right = tempInfo.canceldocnoRight
            // 该次撤销的企业住所（地址）均是否属于虚假（住宅）地址
            this.autoaddresslock = tempInfo.autoaddresslock ? tempInfo.autoaddresslock + '' : '0'
            this.tempSaveId = res.data.id
            console.log(this.fraudEntInfo)
          }
          // if(res.code === 0){
          //   let data =res.data.bizFraudInfo || {}
          // }
        })

        const opinionList = res.data.opinions || []
        if (opinionList.length > 0) {
          opinionList.forEach(each => {
            const atom = {
              handler: each.handler,
              handledate: each.handledate,
              opinioncontent: each.opinioncontent
            }
            switch (each.opiniontype) {
              case '1': atom.step = '经办'; break
              case '2': atom.step = '审核'; break
              case '3': atom.step = '审批'; break
            }
            this.opinions.push(atom)
          })
        }

        this.nextSequenceFlowList = (res.data.nextSequenceFlowList || []).map((item) => {
          return {
            ...item,
            loading: false
          }
        })
        return getEntBaseInfoByCode({
          code: this.fraudEntInfo.uniScId
        })
      }
    }).then((res) => {
      console.log(res, '3')
      if (res.code === 0) {
        this.entInfo = res.data
      }
      this.fraudEntInfo.complainantCertype = this.$util.enumFormatter(this.certypeList, res.data.complainantCertype)
    })

    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 = listFile({
      attachType: '2',
      id: this.bizseq
    }).then(({ data }) => {
      this.fileList2 = data.map((item) => {
        return {
          ...item,
          id: item.attachmentid,
          name: item.filename,
          url: `${process.env.VUE_APP_BASE_API}/attachment/download?id=${item.id}`
        }
      })
    })
    const p7 = listFile({
      attachType: '3',
      id: this.bizseq
    }).then(({ data }) => {
      this.fileList3 = data.map((item) => {
        return {
          ...item,
          id: item.attachmentid,
          name: item.filename,
          url: `${process.env.VUE_APP_BASE_API}/attachment/download?id=${item.id}`
        }
      })
    })
    const p8 = getSteps({ bizSeq: this.bizseq }).then(res => {
      const { data } = res
      if (data != null && data.status === '4') {
        this.$notify.info({
          title: '业务提示',
          message: '现场核查业务已办结',
          offset: 100,
          duration: 0
        })
      }
    })
    const p9 = 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, p7, p8, p9]).finally(() => {
      this.fullscreenLoading = false
    })
  },
  methods: {
    validateFile(rule, value, callback) {
      const files = this.$refs.fileList3.uploadFiles
      if (!files.length) {
        callback(new Error('请选择要上传的通知书!'))
      }
      callback()
    },
    toEntDetail(uniscid) {
      this.$router.push({
        path: '/comprehensive/details',
        query: {
          pripid: this.entInfo.pripid
        }
      })
    },
    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)
          }
        })
      }
    },
    beforeFileUpload(file) {
      return validBeforeUpload(file, this)
    },
    beforeRemove(file, fileList) {
      if (file && file.status === 'success') {
        return this.$confirm(`确定移除 ${file.name} ？`)
      }
    },
    previewFile(file) {
      window.open(`${process.env.VUE_APP_BASE_API}/attachment/download?id=${file.id}`, '_blank')
    },
    // 点击文件列表中已上传文件进行下载
    handlePreview(file) {
      var a = document.createElement('a')
      var event = new MouseEvent('click')
      a.download = file.name
      a.href = file.url
      a.dispatchEvent(event)
    },
    temporarySave() {
      const tempData = {
        fraudPersonInfoName: this.fraudEntInfo.fraudPersonInfoName,
        fraudPersonInfoCertType: this.fraudEntInfo.fraudPersonInfoCertType,
        fraudPersonInfoCertNo: this.fraudEntInfo.fraudPersonInfoCertNo,
        handleReaCn: this.fraudEntInfo.handleReaCn,
        bizHandleResult: this.fraudEntInfo.bizHandleResult,
        handleResult: this.fraudEntInfo.handleResult,
        judAuth: this.fraudEntInfo.judAuth,
        judAuthCn: this.fraudEntInfo.judAuthCn,
        judDate: this.fraudEntInfo.judDate,
        noticeContent: this.fraudEntInfo.noticeContent,
        noticeDate: this.fraudEntInfo.noticeDate,
        canceldocnoLeft: this.canceldocno.left,
        canceldocnoMiddle: this.canceldocno.middle,
        canceldocnoRight: this.canceldocno.right,
        autoaddresslock: this.autoaddresslock
      }
      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.$message.success('提交成功')
        } else {
          throw res
        }
      })
    },
    // 提交
    submitForm() {
      if (this.fraudEntInfo.nextNodeID == 'cancelCase') {
        this.$confirm('是否确认提交？', '提示', {
          beforeClose: (action, instance, done) => {
            if (action === 'confirm') {
              instance.confirmButtonLoading = true
              processControl({
                nextNodeID: this.fraudEntInfo.nextNodeID,
                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()
            }
          }
        })
      } else if (this.fraudEntInfo.nextNodeID == 'endCase') {
        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
                if (this.fraudEntInfo.bizHandleResult === '撤销设立' || this.fraudEntInfo.bizHandleResult === '撤销变更' || this.fraudEntInfo.bizHandleResult === '撤销注销') { // 撤销设立增加参数（撤销文书号 和 该次撤销的企业住所（地址）均是否属于虚假（住宅）地址）
                  this.fraudEntInfo.canceldocno = this.canceldocno.left + '〔' + this.canceldocno.middle + '〕' + this.canceldocno.right + '号'
                  this.fraudEntInfo.autoaddresslock = this.autoaddresslock
                }
                const user = JSON.parse(sessionStorage.getItem('user'))
                processControl({
                  fraudEntInfo: this.fraudEntInfo,
                  fraudPersonInfo: {
                    ...this.fraudPersonInfo,
                    name: this.fraudEntInfo.fraudPersonInfoName,
                    certType: this.fraudEntInfo.fraudPersonInfoCertType,
                    certNo: this.fraudEntInfo.fraudPersonInfoCertNo
                  },
                  nextNodeID: 'endCase',
                  complaintReason: this.fraudEntInfo.complaintReason,
                  bizHandleResult: this.fraudEntInfo.bizHandleResult,
                  bizSeq: this.bizseq,
                  nextPerformerIds: [user.primaryKey],
                  nextPerformerNames: [user.nickname]
                }).then((res) => {
                  if (res.code === 0) {
                    this.$message.success('提交成功')
                    this.$router.push('/todo/list')
                  } else {
                    if (this.fraudEntInfo.bizHandleResult === '撤销设立') {
                      this.msgVisible = true
                      this.msg = res.msg + '点击“确定”，结束流程；点击“取消”，关闭弹窗。'
                    } else {
                      throw res
                    }
                  }
                }).finally(() => {
                  instance.confirmButtonLoading = false
                  done()
                })
              } else if (!instance.confirmButtonLoading) {
                done()
              }
            }
          })
        })
      }
    },
    msgClick() { // 提示点击时事件
      this.msgVisible = false
      processControl({
        nextNodeID: 'cancelCase',
        complaintReason: '无效参数',
        bizSeq: this.bizseq
      }).then((res) => {
        if (res.code === 0) {
          this.$message.success('提交成功')
          this.$router.push('/todo/list')
        } else {
          throw res
        }
      })
    }

  }
}
</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;
      }
    }
  }
}
.uploadFileList.disabled{
  /deep/ .el-upload{
    display: none;
  }
}
.el-form-item{
  position: relative;
  /deep/ .el-form-item__label{
    line-height: 40px;
    height: 100%;
    position: absolute;
  }
}
.main-content{
  font-size: $table-content-font-size;
  .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: inline-block;
    text-indent: 1em;
  }
}
.canceldocno-input{
  /deep/ .el-input{
    width: 150px;
  }
  /deep/ .el-input__inner{
    border-radius: 0px;
    border-top-width: 0px;
    border-left-width: 0px;
    border-right-width: 0px;
    border-bottom-width: 1px;
  }
}
.autoaddresslock{
  /deep/ .el-form-item .el-form-item__label {
    position: inherit;
}
}
</style>
<style lang="scss">
.main-content.abnormal{
  .el-form-item{
    margin-bottom:0;
    background: $color-form-label;
    .el-form-item__label{
      padding-left: 20px;
      border-top: 1px solid $color-border;
      border-left: 1px solid $color-border;
      font-size: $table-content-font-size;
    }
    .el-form-item__content{
      font-size: 16px;
      background: white;
      padding: 10px;
      border-top: 1px solid $color-border;
      border-right: 1px solid $color-border;
      border-left: 1px solid $color-border;
      font-size: $table-content-font-size;
      // min-height: 60px;
    }
  }
  .el-form-item:last-child{
    border-bottom: 1px solid $color-border;
  }
  .form-body.history{
    padding:15px;
    border:1px solid $color-border;
  }

  .el-form-item.is-error .custom .el-input__inner{
    border-color:$color-border;
  }
  .el-table-column--selection .cell {
    padding-right: 0px;
  }
  .no {
    padding-left: 0px;
  }
  .el-table_9_column_61.is-left.is-leaf{
    .cell{
      padding-left: 0px;
      padding-right: 0px;
    }
  }
  .el-pagination{
    text-align: right;
  }
  .dialog-box{
    text-align: right;
  }
  .el-textarea.is-disabled .el-textarea__inner{
    color: #1c1e23;
  }
.el-input.is-disabled .el-input__inner

  .el-input__inner{
    margin-bottom: 5px;
    width: 50%;
  }
}
</style>
