<template>
  <div>
    <dialog-edit :visible.sync="dialogVisible" :editModel="editModel" :form="form"
                 :appendToBody="appendToBody" width="1480px"
                 :title="$t('enterpriseInfoManage.supplierInfoManage.coreCompanyView')" labelWidth="80px"
                 :api="api">
      <el-row>
        <el-col :span="24" align="right">
          <span class="date-title-class">{{$t('enterpriseInfoManage.supplierInfoManage.lastUpdateTime')}}{{basicForm.lastRefreshTime | formatDate}}</span>
        </el-col>
      </el-row>
      <div class="enterprise-info">
        <el-divider></el-divider>
      </div>
      <el-form class="dymForm" :model="basicForm" label-width="130px" ref="basicForm">
        <el-row>
          <!--企业名称-->
          <el-col :md="24" :lg="8" :xl="8">
            <el-form-item prop="enterpriseName" :class="{detail: basicForm.showEnterpriseNameRedFlag}" :label="$t('enterpriseInfoManage.supplierInfoManage.enterpriseName')">
              <el-input  :disabled="true" v-model="basicForm.enterpriseName" maxlength="100"></el-input>
            </el-form-item>
          </el-col>
          <!--核心企业简称-->
          <el-col :md="24" :lg="8" :xl="8">
            <el-form-item prop="shortName" :class="{detail: basicForm.showRedFlag}"  :label="$t('enterpriseInfoManage.coreEnterpriseInfoManage.coreEnterpriseShortName')">
              <el-input :disabled="true" v-model="basicForm.shortName" maxlength="20"></el-input>
            </el-form-item>
          </el-col>
          <!--曾用名-->
          <el-col :md="24" :lg="8" :xl="8">
            <el-form-item prop="historyNames" :label="$t('enterpriseInfoManage.supplierInfoManage.usedName')">
              <el-input v-model="basicForm.historyNames" :disabled="true"></el-input>
            </el-form-item>
          </el-col>
          <!--营业执照核准日期-->
          <el-col :md="24" :lg="8" :xl="8">
            <el-form-item prop="approvedTime" :label="$t('enterpriseInfoManage.supplierInfoManage.yyzzApprovedDate')">
              <el-input v-model="basicForm.approvedTime" :disabled="true"></el-input>
            </el-form-item>
          </el-col>
          <!--企业性质-->
          <el-col :md="24" :lg="8" :xl="8">
            <el-form-item prop="enterpriseNature" :label="$t('enterpriseInfoManage.supplierInfoManage.enterpriseProperty')">
              <!--<select-dictionary v-model="basicForm.fincrmEnterpriseInfoDto.enterpriseNature" :disabled="true" :dictTypeCode="''" :store="$store"-->
              <!--:placeholder="''">-->
              <!--</select-dictionary>-->
              <select-dictionary v-model="basicForm.enterpriseNature" :disabled="true" :dictTypeCode="'enterprise_nature'" :store="$store"
                                 :placeholder="''">
              </select-dictionary>
              <!--<el-input v-model="basicForm.enterpriseNature" :disabled="true"-->
              <!--:placeholder="''"></el-input>-->
            </el-form-item>
          </el-col>
          <!-- 盖章方式-->
          <el-col :md="24" :lg="8" :xl="8">
            <el-form-item prop="stampWay" :label="$t('enterpriseInfoManage.supplierInfoManage.sealWay')">
              <select-dictionary v-model="basicForm.stampWay" :disabled="true" :dictTypeCode="'sealing_method'" :store="$store"
                                 :placeholder="''">
              </select-dictionary>
            </el-form-item>
          </el-col>
          <!-- 未申请电子章原因-->
          <el-col :md="24" :lg="8" :xl="8">
            <el-form-item prop="noElectronicReason" :label="$t('enterpriseInfoManage.supplierInfoManage.noApplyReason')">
              <el-input v-model="basicForm.noElectronicReason" :disabled="true"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <!--<el-form :model="basicForm" label-width="130px" ref="basicForm">-->
      <!--<dym-form :componentList="componentList" :formValue.sync="basicForm"></dym-form>-->
      <!--</el-form>-->
      <el-tabs type="card">
        <!-- 业务操作信息 -->
        <el-tab-pane :label="$t('enterpriseInfoManage.supplierInfoManage.businessOperateInfo')">
          <core-enterbusiness-operate-info ref="operate"></core-enterbusiness-operate-info>
        </el-tab-pane>
        <!-- 企业工商信息 -->
        <el-tab-pane :label="$t('enterpriseInfoManage.supplierInfoManage.businessInfo')">
          <business-info ref="business"></business-info>
        </el-tab-pane>
      </el-tabs>
    </dialog-edit>
  </div>
</template>

<script>
import * as format from '@/filters/index.js'
import { DialogEdit, dymForm, authButton, SelectDictionary, validate } from 'newepoch-components'
// import storage from '@/utils/storage'
// 业务操作信息
import coreEnterbusinessOperateInfo from '@/pages/cyjg/financialRegionInfo/coreEnterbusinessOperateInfo.vue'
// 企业工商信息
import BusinessInfo from '@/pages/cyjg/financialRegionInfo/businessInfo.vue'
import supplierInfoManageApi from '@/api/enterpriseInfoManage/supplierInfoManageApi.js'
import BaseEdit from '@/pages/baseEditPage.js'
export default {
  extends: new BaseEdit(),
  name: 'coreEnterbusinessOperateInfo.vue',
  components: {
    DialogEdit,
    dymForm,
    authButton,
    SelectDictionary,
    validate,
    coreEnterbusinessOperateInfo,
    BusinessInfo
  },
  data () {
    return {
      appendToBody: true,
      handleFlag: false,
      refreshFlag: false,
      refreshModel: '',
      item: {},
      queryParas: {
        keyId: '',
        tagCode: '60'
      },
      basicForm: {},
      formRules: {
        enterpriseName: [{ required: true, message: this.$i18n.messages[this.$i18n.locale].regMsg.enterpriseInfoManage.enterpriseName, trigger: 'blur' },
          { validator: validate.enterpriseNameValidate, trigger: 'blur' }],
        shortName: [{ required: true, message: this.$i18n.messages[this.$i18n.locale].regMsg.enterpriseInfoManage.coreEnterpriseShortName, trigger: 'blur' },
          { validator: validate.enterpriseNameValidate, trigger: 'blur' }]
      }
    }
  },
  computed: {
    api () {
      return supplierInfoManageApi.enterpriseModified
    }
  },
  methods: {
    // 查询
    handleFilter () {
      let $this = this
      supplierInfoManageApi.enterpriseModified.getEnterpriseModified(this.queryParas).then(res => {
        if (res && res.data) {
          $this.basicForm = res.data
          $this.basicForm.approvedTime = format.formatDateNull($this.basicForm.approvedTime)
          $this.basicForm.enterpriseNature = format.formatDictDefoultNew($this.basicForm.enterpriseNature)
        }
      })
    }
  },
  watch: {
    visible (val) {
      let $this = this
      if (val) {
        this.$nextTick(() => {
          let operate = this.$refs.operate
          let business = this.$refs.business
          operate.pa = this.form
          business.pa = this.form
          let pa = this.form
          if (operate.currentId !== pa.enterpriseId.toString()) {
            this.sourceData = []
          }
          this.$set(operate.searchForm, 'enterpriseId', pa.enterpriseId.toString())
          this.$set(operate.searchForm, 'tagCode', pa.tagCode.toString())
          operate.handleFilter()
          business.getNetWork()
        })
        this.queryParas.keyId = this.form.enterpriseId
        $this.handleFilter()
      }
    }
  }
}
</script>

<style scoped>

</style>
