﻿<template>
  <el-dialog
    :title="!dataForm.id ? '新增' : isDetail ? '详情' : formType == 1 ? '编辑' : '案件处理'"
    :close-on-click-modal="false"
    :visible.sync="visible"
    class="NCC-dialog NCC-dialog_center"
    lock-scroll
    width="60%"
    v-loading="loading"
    :modal="false"
  >
    <el-row :gutter="15" class="NCC-dialog-content" v-show="!isDetail">
      <el-form
        ref="elForm"
        :model="dataForm"
        size="small"
        label-width="180px"
        label-position="right"
        :disabled="!!isDetail"
        :rules="rules"
      >
        <el-col :span="24" v-if="false">
          <el-form-item label="主键" prop="id">
            <el-input v-model="dataForm.id" placeholder="请输入" clearable />
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="来源登记" prop="sourceRegistration">
            <el-input v-model="dataForm.sourceRegistration" placeholder="请输入来源登记" clearable :disabled="formType != 0"/>
          </el-form-item>
        </el-col>
        <!-- <el-col :span="24">
          <el-form-item label="来源登记" prop="sourceRegistration">
            <el-input v-model="dataForm.sourceRegistration" placeholder="请输入来源登记" clearable :disabled="formType != 0"/>
          </el-form-item>
        </el-col> -->
        <el-col :span="24">
          <el-form-item label="运营主体/个人" prop="registeredEntity">
            <CompanySelect v-model="dataForm.registeredEntity" @change="(val, type) => companyChange(val, type)"></CompanySelect>
            <!-- <el-select
              ref="companySelect"
              v-model="dataForm.registeredEntity"
              placeholder="请选择运营主体/个人"
              clearable
              filterable 
              style="width: 100%"
              @blur.native.capture="selectCompanyBlur"
              @visible-change="visibleNameCompanyChange"
              @change="(val) => companyChange(val, 'change')"
              :disabled="formType != 0"
              v-selectLoadMore="moreCompanyList"
              :loading="name_loading"
              :teleported="false"
              :filter-method="filterMethod"
            >
              <el-option
                v-for="item in companyOptions.slice(0, company_currentPage)"
                :key="item.id"
                :label="item.companyName"
                :value="item.id"
              >
              </el-option>
            </el-select> -->
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="案件名称" prop="systemName">
			      <el-select
              ref="select"
 			        v-model="dataForm.systemName"
 			        filterable
 			        remote
 			        reserve-keyword
 			        placeholder="请输入案件名称"
 			        @blur.native.capture="selectBlur"
              @visible-change="visibleNameChange"
              @change="(val) => platformNameChange(val, 'change')"
              :disabled="formType != 0 || !dataForm.registeredEntity"
              v-selectLoadMore="moreSystemList"
              :teleported="false"
 			        :loading="system_loading">
 			        <el-option v-for="item in systemOption.slice(0, system_currentPage)" :key="item.value" :label="item.systemName" :value="item.id" />
 			      </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="应用类别" prop="category">
            <el-radio-group v-model="dataForm.category" :disabled="formType != 0">
              <el-radio v-for="(item, index) in platformTypeOptions" :key="index" :label="item.Id">{{ item.FullName }}</el-radio>
            </el-radio-group>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="备案号" prop="recordNumber">
            <el-input v-model="dataForm.recordNumber" placeholder="请输入备案号" clearable :disabled="formType == 2"/>
          </el-form-item>
        </el-col>
        <el-col :span="24" v-if="isSHILevel">
          <el-form-item label="所属区县" prop="districtCounty">
              <el-radio-group
                v-model="dataForm.districtCounty"
                placeholder="请选择所属区县"
                style="line-height: 22px"
                :disabled="formType == 2"
              >
                <el-radio v-for="v in areaOptions" :key="v.id" :label="v.id">{{
                  v.fullName
                }}</el-radio>
              </el-radio-group>
            </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="违法原因" prop="illegalReasons">
            <el-input type="textarea" v-model="dataForm.illegalReasons" placeholder="请输入违法原因" clearable maxlength="200" :disabled="formType == 2"/>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="处罚要求" prop="punishmentRequirements">
            <el-input type="textarea" v-model="dataForm.punishmentRequirements" placeholder="请输入处罚要求" clearable maxlength="200" :disabled="formType == 2"/>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="处罚内容" prop="punishmentContent">
            <el-input type="textarea" v-model="dataForm.punishmentContent" placeholder="请输入处罚内容" clearable maxlength="200" :disabled="formType == 2"/>
          </el-form-item>
        </el-col>
        <el-col :span="24" v-if="isSHILevel">
          <el-form-item label="执法方式" prop="enforceType">
            <el-radio-group v-model="dataForm.enforceType">
              <el-radio label="柔性执法">柔性执法</el-radio>
              <el-radio label="行政执法">行政执法</el-radio>
            </el-radio-group>
          </el-form-item>
        </el-col>
        <el-col :span="24" v-if="!isSHILevel && formType == 2">
          <el-form-item label="执法说明" prop="enforcecontent">
            <el-input type="textarea" v-model="dataForm.enforcecontent" placeholder="请输入执法说明" clearable maxlength="200"/>
          </el-form-item>
        </el-col>
        <!-- 立案审批、调查（询问）笔录、案件处理意见、执法约谈、行政处罚意见告知、行政处罚决定、行政处罚结案报告、其他（每个流程都为填空+上传附件，非必填） -->
        <template v-if="formType == 2">
          <el-col :span="24">
            <el-form-item label="立案审批" prop="registerApproval">
              <el-input type="textarea" v-model="dataForm.registerApproval" placeholder="请输入立案审批" clearable maxlength="200"/>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="立案审批附件" prop="registerApprovalFileModel">
              <NCC-UploadFz v-model="dataForm.registerApprovalFileModel" :fileSize="5" sizeUnit="MB" :limit="9" buttonText="点击上传" />
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="调查（询问）笔录" prop="record">
              <el-input type="textarea" v-model="dataForm.record" placeholder="请输入调查（询问）笔录" clearable maxlength="200"/>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="调查（询问）笔录附件" prop="recordFileModel">
              <NCC-UploadFz v-model="dataForm.recordFileModel" :fileSize="5" sizeUnit="MB" :limit="9" buttonText="点击上传" />
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="案件处理意见" prop="caseHandlingOpinions">
              <el-input type="textarea" v-model="dataForm.caseHandlingOpinions" placeholder="请输入案件处理意见示例" clearable maxlength="200"/>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="案件处理意见附件" prop="caseHandlingOpinionsFileModel">
              <NCC-UploadFz v-model="dataForm.caseHandlingOpinionsFileModel" :fileSize="5" sizeUnit="MB" :limit="9" buttonText="点击上传" />
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="执法约谈" prop="enforcementRecords">
              <el-input type="textarea" v-model="dataForm.enforcementRecords" placeholder="请输入执法约谈" clearable maxlength="200"/>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="执法约谈附件" prop="enforcementRecordsFileModel">
              <NCC-UploadFz v-model="dataForm.enforcementRecordsFileModel" :fileSize="5" sizeUnit="MB" :limit="9" buttonText="点击上传" />
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="行政处罚意见告知" prop="noticeLetter">
              <el-input type="textarea" v-model="dataForm.noticeLetter" placeholder="请输入行政处罚意见告知" clearable maxlength="200"/>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="行政处罚意见告知附件" prop="noticeLetterFileModel">
              <NCC-UploadFz v-model="dataForm.noticeLetterFileModel" :fileSize="5" sizeUnit="MB" :limit="9" buttonText="点击上传" />
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="行政处罚决定" prop="punishmentDecision">
              <el-input type="textarea" v-model="dataForm.punishmentDecision" placeholder="请输入行政处罚决定" clearable maxlength="200"/>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="行政处罚决定附件" prop="punishmentDecisionFileModel">
              <NCC-UploadFz v-model="dataForm.punishmentDecisionFileModel" :fileSize="5" sizeUnit="MB" :limit="9" buttonText="点击上传" />
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="行政处罚结案报告" prop="closingReport">
              <el-input type="textarea" v-model="dataForm.closingReport" placeholder="请输入行政处罚结案报告" clearable maxlength="200"/>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="行政处罚结案报告附件" prop="closingReportFileModel">
              <NCC-UploadFz v-model="dataForm.closingReportFileModel" :fileSize="5" sizeUnit="MB" :limit="9" buttonText="点击上传" />
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="其他" prop="other">
              <el-input type="textarea" v-model="dataForm.other" placeholder="请输入其他" clearable maxlength="200"/>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="其他附件" prop="otherFileModel">
              <NCC-UploadFz v-model="dataForm.otherFileModel" :fileSize="5" sizeUnit="MB" :limit="9" buttonText="点击上传" />
            </el-form-item>
          </el-col>
        </template>
      </el-form>
    </el-row>
    <el-row v-show="!!isDetail">
      <el-col class="form-item">
        <div class="label w-180">来源登记：</div>
        <div class="text">{{ dataForm.sourceRegistration || '--' }}</div>
      </el-col>
      <el-col class="form-item">
        <div class="label w-180">案件名称：</div>
        <div class="text">{{ dataForm.systemNameStr || '--' }}</div>
      </el-col>
      <el-col class="form-item">
        <div class="label w-180">运营主体/个人：</div>
        <div class="text">{{ dataForm.registeredEntityStr || '--' }}</div>
      </el-col>
      <el-col class="form-item">
        <div class="label w-180">应用类别：</div>
        <div class="text">{{ dataForm.categoryName || '--' }}</div>
      </el-col>
      <el-col class="form-item">
        <div class="label w-180">备案号：</div>
        <div class="text">{{ dataForm.recordNumber || '--' }}</div>
      </el-col>
      <el-col class="form-item">
        <div class="label w-180">所属区县：</div>
        <div class="text">{{ dataForm.districtCountyName }}</div>
      </el-col>
      <el-col class="form-item">
        <div class="label w-180">违法原因：</div>
        <p class="text">{{ dataForm.illegalReasons || '--' }}</p>
      </el-col>
      <el-col class="form-item">
        <div class="label w-180">处罚要求：</div>
        <p class="text">{{ dataForm.punishmentRequirements || '--' }}</p>
      </el-col>
      <el-col class="form-item">
        <div class="label w-180">处罚内容：</div>
        <p class="text">{{ dataForm.punishmentContent || '--' }}</p>
      </el-col>
      <el-col class="form-item" v-if="dataForm.enforceType">
        <div class="label w-180">执法方式：</div>
        <p class="text">{{ dataForm.enforceType || '--' }}</p>
      </el-col>
      <el-col class="form-item" v-if="dataForm.enforcecontent">
        <div class="label w-180">执法说明：</div>
        <p class="text">{{ dataForm.enforcecontent || '--' }}</p>
      </el-col>
      <template v-if="dataForm.enforcecontent">
        <el-col class="form-item">
          <div class="label w-180">立案审批：</div>
          <p class="text">{{ dataForm.registerApproval || '--' }}</p>
        </el-col>
        <el-col class="form-item">
            <div class="label w-180">立案审批附件:</div>
            <div class="text" style="width: calc(100% - 180px);">
              <NCC-UploadFz v-model="dataForm.registerApprovalFileModel" :fileSize="5" sizeUnit="MB" :limit="9" buttonText="点击上传" disabled/>
            </div>
        </el-col>
        <el-col class="form-item">
          <div class="label w-180">调查（询问）笔录：</div>
          <p class="text">{{ dataForm.record || '--' }}</p>
        </el-col>
        <el-col class="form-item">
            <div class="label w-180">调查（询问）笔录附件:</div>
            <div class="text" style="width: calc(100% - 180px);">
              <NCC-UploadFz v-model="dataForm.recordFileModel" :fileSize="5" sizeUnit="MB" :limit="9" buttonText="点击上传" disabled/>
            </div>
        </el-col>
        <el-col class="form-item">
          <div class="label w-180">案件处理意见：</div>
          <p class="text">{{ dataForm.caseHandlingOpinions || '--' }}</p>
        </el-col>
        <el-col class="form-item">
            <div class="label w-180">案件处理意见附件:</div>
            <div class="text" style="width: calc(100% - 180px);">
              <NCC-UploadFz v-model="dataForm.caseHandlingOpinionsFileModel" :fileSize="5" sizeUnit="MB" :limit="9" buttonText="点击上传" disabled/>
            </div>
        </el-col>
        <el-col class="form-item">
          <div class="label w-180">执法约谈：</div>
          <p class="text">{{ dataForm.enforcementRecords || '--' }}</p>
        </el-col>
        <el-col class="form-item">
            <div class="label w-180">执法约谈附件:</div>
            <div class="text" style="width: calc(100% - 180px);">
              <NCC-UploadFz v-model="dataForm.enforcementRecordsFileModel" :fileSize="5" sizeUnit="MB" :limit="9" buttonText="点击上传" disabled/>
            </div>
        </el-col>
        <el-col class="form-item">
          <div class="label w-180">行政处罚意见告知：</div>
          <p class="text">{{ dataForm.noticeLetter || '--' }}</p>
        </el-col>
        <el-col class="form-item">
            <div class="label w-180">行政处罚意见告知附件:</div>
            <div class="text" style="width: calc(100% - 180px);">
              <NCC-UploadFz v-model="dataForm.noticeLetterFileModel" :fileSize="5" sizeUnit="MB" :limit="9" buttonText="点击上传" disabled/>
            </div>
        </el-col>
        <el-col class="form-item">
          <div class="label w-180">行政处罚决定：</div>
          <p class="text">{{ dataForm.punishmentDecision || '--' }}</p>
        </el-col>
        <el-col class="form-item">
            <div class="label w-180">行政处罚决定附件:</div>
            <div class="text" style="width: calc(100% - 180px);">
              <NCC-UploadFz v-model="dataForm.punishmentDecisionFileModel" :fileSize="5" sizeUnit="MB" :limit="9" buttonText="点击上传" disabled/>
            </div>
        </el-col>
        <el-col class="form-item">
          <div class="label w-180">行政处罚结案报告：</div>
          <p class="text">{{ dataForm.closingReport || '--' }}</p>
        </el-col>
        <el-col class="form-item">
            <div class="label w-180">行政处罚结案报告附件:</div>
            <div class="text" style="width: calc(100% - 180px);">
              <NCC-UploadFz v-model="dataForm.closingReportFileModel" :fileSize="5" sizeUnit="MB" :limit="9" buttonText="点击上传" disabled/>
            </div>
        </el-col>
        <el-col class="form-item">
          <div class="label w-180">其他：</div>
          <p class="text">{{ dataForm.other || '--' }}</p>
        </el-col>
        <el-col class="form-item">
            <div class="label w-180">其他附件:</div>
            <div class="text" style="width: calc(100% - 180px);">
              <NCC-UploadFz v-model="dataForm.otherFileModel" :fileSize="5" sizeUnit="MB" :limit="9" buttonText="点击上传" disabled/>
            </div>
        </el-col>
      </template>
    </el-row>
    <span slot="footer" class="dialog-footer">
      <el-button @click="visible = false">取 消</el-button>
      <template  v-if="!isDetail">
        <el-button type="primary" v-if="!isDetail && formType != '2'" @click="submit(1)" :loading="btnLoading">{{isSHILevel ? '下 发' : '上 报'}}</el-button>
        <el-button type="info" v-if="!isDetail && formType != '2'" @click="submit(0)" :loading="btnLoading">保 存</el-button>
      </template>
      <template v-if="!isDetail">
        <el-button type="primary" v-if="!isDetail && formType == '2'" @click="handle(1)" :loading="btnLoading">办 结</el-button>
        <el-button type="info" v-if="!isDetail && formType == '2'" @click="handle(0)" :loading="btnLoading">保 存</el-button>
      </template>
    </span>
  </el-dialog>
</template>
<script>
import infoMixin from "@/mixins/info";
import request from "@/utils/request";
import { getSystemDetail } from "@/api/baseData/info";
import { getCompanyInfoList, getCompanyInfoById } from "@/api/baseData/company";
import { dynamicTextUP } from "@/filters/index";

export default {
  mixins: [infoMixin],
  data() {
    return {
      visible: false,
      loading: false,
      isDetail: false,
      formType: false, //  0 新增 1 编辑 2 处理
      dataForm: {
		    id: undefined,
        sourceRegistration: undefined,
		    registrationTime: undefined,
		    systemName: undefined,
		    registeredEntity: undefined,
		    category: undefined,
		    recordNumber: undefined,
        registeredEntityStr: undefined,
		    districtCounty: undefined,
        systemNameStr: undefined,
		    illegalReasons: undefined,
		    punishmentRequirements: undefined,
		    punishmentContent: undefined,
		    state: undefined,
        enforceType: undefined,
        enforcecontent: undefined,
        isHaveSystem: undefined,
        registerApproval: undefined,
        registerApprovalFileModel: [],
        record: undefined,
        recordFileModel: [],
        caseHandlingOpinions: undefined,
        caseHandlingOpinionsFileModel: [],
        enforcementRecords: undefined,
        enforcementRecordsFileModel: [],
        noticeLetter: undefined,
        noticeLetterFileModel: [],
        punishmentDecision: undefined,
        punishmentDecisionFileModel: [],
        closingReport: undefined,
        closingReportFileModel: [],
        other: undefined,
        otherFileModel: [],
	    },
      rules: {
        sourceRegistration: [
          { required: true, message: "请输入来源登记", trigger: "bulr" }
        ],
        systemName: [
          { required: true, message: "请选择应用名称", trigger: "bulr" }
        ],
        registeredEntity: [
          { required: true, message: "请选择运营主体", trigger: "bulr" }
        ],
        districtCounty: [
          { required: true, message: "请选择所属区域", trigger: "change" }
        ],
        enforceType: [
          { required: true, message: "请选择执法方式", trigger: "bulr" }
        ],
        enforcecontent: [
          { required: true, message: "请填写执法说明", trigger: "bulr" }
        ],
      },
      systemOption: [],
      system_loading: false,
      areaOptions: [],
      btnLoading: false,
      companyOptions: [],
      platformTypeOptions: [],
      company_currentPage: 20,
      name_loading: false,
      system_currentPage: 20,
    };
  },
  computed: {
    isSHILevel() {
      // 判断角色是否为‘市级办公室’
      return this.$store.state.user.islader;
    },
  },
  watch: {},
  created() {
    this.getplatformTypeOptions();
    this.initSystemTypeList();
    this.initAreaTypeList();
    // this.initCompanyList();
  },
  mounted() {},
  methods: {
    async getplatformTypeOptions() {
      let list = this.$store.state.meta.system;
      !list && (list = await this.$store.dispatch("getTypeListByCode", "system"));
      this.platformTypeOptions = list;
    },
      // 请求公司列表
    // async initCompanyList() {
    //   request({
    //     url: `/Extend/basecomapnyinfo/GetNoPagingList`,
    //     method: "GET",
    //   }).then(({data}) => {
    //     this.companyOptions = data;
    //   })
    // },
    // moreCompanyList() {
    //   if(this.company_currentPage > this.companyOptions.length) return;
    //   this.company_currentPage += 10;
    // },
    // async filterMethod(val) {
    //   this.company_currentPage = 20;
    //   this.name_loading = true
    //   let companyRes = await request({
    //     url: `/Extend/basecomapnyinfo/GetNoPagingList`,
    //     method: "GET",
    //     params: {
    //       companyName: val
    //     }
    //   });
    //   this.companyOptions = companyRes.data;
    //   this.name_loading = false;
    // },
    // 获取系统列表
    getSystemSelect(companyId) {
      this.system_loading = true;
      request({
        url: "/Extend/basesysteminfo/GetNoPagingList",
        method: "get",
        params: { companyId }
      }).then(({data}) => {
        this.systemOption = data;
        this.system_loading = false;
      })
    },
    moreSystemList() {
      if(this.system_currentPage > this.systemOption.length) return;
      this.system_currentPage += 10;
    },
    async filterMethod_system(val) {
      this.system_currentPage = 0;
      this.system_loading = true;
      this.systemOption.filter.includes
      request({
        url: "/Extend/basesysteminfo/GetNoPagingList",
        method: "get",
        params: { 
          companyId: this.dataForm.registeredEntity,
          systemName: val,
        }
      }).then(({data}) => {
        this.systemOption = data;
        this.system_loading = false;
      })
    },
    selectBlur(e) {
      let value = e.target.value;
      if(!value) return;
      this.dataForm.systemName = e.target.value;
      this.platformNameChange(value, 'blur');
    },
    platformNameChange(val, type) {
      let obj = this.systemOption.find(v => type == 'blur' ? val == v.fullName : val == v.id);
      console.log(obj);
      this.dataForm.isHaveSystem = obj ? true : false;
      this.dataForm.systemName = obj ? obj.id : val;
      this.dataForm.category = obj ? this.platformTypeOptions.find(v => v.Id == obj.systemType || v.FullName == obj.systemType).Id : '';
      // this.dataForm.recordNumber = obj ? obj.platform : '';
    },
    // 系统名称改变
    systemChange(val) {
      getSystemDetail(val).then(({data}) => {
        this.dataForm.registeredEntity = data.companyId;
        this.dataForm.category = dynamicTextUP(data.systemType, this.systemTypeOptions);
        this.dataForm.recordNumber = data.specialRecordNumber || '--';
        this.dataForm.districtCounty = data.areaId;
      })
    },
    visibleNameChange(val) {
      if (val) return
      let input = this.$refs.select.$children[0].$refs.input;
      input.blur();
    },
    async companyChange(val, type) {
      switch (type) {
        case 'change':
          this.getSystemSelect(val)
          break;
        case 'blur':
          this.systemOption == [];
          this.dataForm.systemName = '';
          this.dataForm.category = '';
          break;
        default:
          break;
      }
    },
    // companyChange(val, type) {
    //   let obj = this.companyOptions.find(v => val == v.id);
    //   obj ? this.getSystemSelect(val) : (this.systemOption == []);
    //   this.dataForm.systemName = '';
    //   this.dataForm.category = '';
    // },
    // // 运营主体改变
    // selectCompanyBlur(e) {
    //   let value = e.target.value;
    //   if(!value) return;
    //   this.dataForm.registeredEntity = e.target.value;
    //   this.companyChange(value, 'blur');
    // },
    // visibleNameCompanyChange(val) {
    //   if (val) return
    //   let input = this.$refs.companySelect.$children[0].$refs.input;
    //   input.blur();
    // },
    goBack() {
      this.$emit("refresh");
    },
    init(id, isDetail, type) {
      // type 0 上报/下派 1 处理
      this.formType = type || '0';
      this.dataForm.id = id || undefined;
      this.isDetail = isDetail || false;
      this.visible = true;
      this.$nextTick(() => {
        this.$refs["elForm"].resetFields();
        if (this.dataForm.id) {
          this.loading = true;
          request({
            url: `/Extend/BaseCaseHandling/${this.dataForm.id}`,
            method: "GET",
          }).then(async (res) => {
            res.data.districtCountyName = this.areaOptions.find(item => item.id == res.data.districtCounty).fullName;
            res.data.categoryName = this.platformTypeOptions.find(v => v.Id == res.data.category || v.FullName == res.data.category).FullName;
            this.isEmpty(res.data.registerApproval) && (res.data.registerApproval = '');
            !res.data.registerApprovalFileModel && (res.data.registerApprovalFileModel = []);
            this.isEmpty(res.data.record) && (res.data.record = '');
            !res.data.recordFileModel && (res.data.recordFileModel = []);
            this.isEmpty(res.data.caseHandlingOpinions) && (res.data.caseHandlingOpinions = '');
            !res.data.caseHandlingOpinionsFileModel && (res.data.caseHandlingOpinionsFileModel = []);
            this.isEmpty(res.data.enforcementRecords) && (res.data.enforcementRecords = '');
            !res.data.enforcementRecordsFileModel && (res.data.enforcementRecordsFileModel = []);
            this.isEmpty(res.data.noticeLetter) && (res.data.noticeLetter = '');
            !res.data.noticeLetterFileModel && (res.data.noticeLetterFileModel = []);
            this.isEmpty(res.data.punishmentDecision) && (res.data.punishmentDecision = '');
            !res.data.punishmentDecisionFileModel && (res.data.punishmentDecisionFileModel = []);
            this.isEmpty(res.data.closingReport) && (res.data.closingReport = '');
            !res.data.closingReportFileModel && (res.data.closingReportFileModel = []);
            this.isEmpty(res.data.other) && (res.data.other = '');
            !res.data.otherFileModel && (res.data.otherFileModel = []);
            this.companyChange(res.data.registeredEntity, 'change');
            this.dataForm = res.data;
            this.loading = false;
          }).catch(() => {
            this.loading = false;
          });
        }
      });
    },
    isEmpty(val) {
      return !val || val == 'null'
    },
    // 上报/下派
    submit(type) {
      // type: 1 上报 0 保存
       // status 状态 0保存/1办结
      let obj = {
        ...this.dataForm,
        isReport: type,
      }
      
			this.$refs['elForm'].validate((valid) => {
        if(valid) {
          !this.dataForm.id ? this.toRequest('/Extend/BaseCaseHandling', 'POST', obj) : this.toRequest(`/Extend/BaseCaseHandling/${this.dataForm.id}`, 'PUT', obj);
        }
      })
    },
    // 处理
    handle(status) {
      this.$refs['elForm'].validate((valid) => {
        if(valid) {
          this.btnLoading = true;
          this.dataForm.status = status;
          request({
            url: `/Extend/basecasehandling/HandlingCase/${this.dataForm.id}`,
            method: "POST",
            data: this.dataForm,
          }).then((res) => {
            this.visible = false;
            this.$emit("refresh", true);
            this.$message({
              type: "success",
              message: res.msg,
            })
          }).catch(() => {
            this.btnLoading = false;
          })
        }
      })
    },
    toRequest(url, method, data) {
      this.btnLoading = true;
      request({
        url,
        method,
        data,
      }).then((res) => {
        this.$message({
          type: "success",
          message: res.msg,
          onClose: () => {
            this.visible = false;
            this.$emit("refresh", true);
          },
        });
      }).catch(() => {
        this.btnLoading = false;
      });
    }
  },
};
</script>
