<template>
  <browser :component-loading="componentLoading"
           class="enterpriseInfo"
           style="height: 600px;"
           :api-config="apiConfig"
           :table-config="tableConfig"
           :permissions="permissions"
           :dialog-config="dialogConfig"
           :actions="actions"
           :customQuery="true"
           @custom-query="customQuery"
           @update:actions="actions = $event"
           @update:dialog-config="dialogConfig = $event">
    <el-table-column prop="industryType" label="行业类别" min-width="150"/>
    <el-table-column prop="unitName" label="生产经营单位名称" min-width="350"/>
    <el-table-column prop="unifiedSocialCode" label="社会统一信用代码" min-width="220"/>
    <el-table-column prop="legalRepresentative" label="法人" min-width="150"/>
    <el-table-column prop="opLocAddress" label="经营地址" min-width="180"/>
  </browser>
</template>

<script setup>
import {reactive, toRefs, watch, computed, ref} from 'vue'
import {useUserStore} from '@/stores/modules/user'
import statisticsApi from '@/api/lawenforcement/Statistics.js'
import Browser from '@/components/Browser.vue'

const userStore = useUserStore()

const props = defineProps({
  dialogData: {type: Object, default: () => ({})},
  tag: {
    type: String,
    default: ''
  },
})

const state = reactive({
  componentLoading: false,
  permissions: {
    query: false,
    add: false,
    modify: false,
    detail: true,
    delete: false,
    importFile: false,
    exportFile: false,
    exportSelectFile: false,
    downloadTemp: false
  },
  tableConfig: {
    hasControlColumn: false,
    controlWidth: '100',
    multipleSelect: false,
    defaultSort: {
      prop: 'industryType',
      order: 'descending'
    }
  },
  apiConfig: {
    api: statisticsApi,
    modelId: ''
  },
  dialogConfig: {
    show: false,
    mode: 'detail',
    loading: false,
    baseTitle: '企业信息',
    formLabelWidth: '90px',
    showFooter: false
  },
  actions: {
  },
  queryParams: {},
})

const {
  componentLoading,
  permissions,
  tableConfig,
  apiConfig,
  dialogConfig,
  actions,
  queryParams
} = toRefs(state)

function customQuery(params) {

  let query = Object.assign({}, params, props.dialogData)
  if(props.tag==='jcqys'){
    tableConfig.value.tableLoading = true
    apiConfig.value.api.getPageJcqk(query).then(res => {
      tableConfig.value.tableLoading = false
      if (res.success) tableConfig.value.tableData = res
    }).catch(() => {
      tableConfig.value.tableLoading = false
    })
  }
  if(props.tag==='jgqy'){
    tableConfig.value.tableLoading = true
    apiConfig.value.api.getPagezbbjgqyDetail(query).then(res => {
      tableConfig.value.tableLoading = false
      if (res.success) tableConfig.value.tableData = res
    }).catch(() => {
      tableConfig.value.tableLoading = false
    })
  }
  if(props.tag==='jcqyszbb'){
    tableConfig.value.tableLoading = true
    apiConfig.value.api.getPagejcqyqkByindustryTypeDetail(query).then(res => {
      tableConfig.value.tableLoading = false
      if (res.success) tableConfig.value.tableData = res
    }).catch(() => {
      tableConfig.value.tableLoading = false
    })
  }
  if(props.tag==='lajsszbb'){
    tableConfig.value.tableLoading = true
    apiConfig.value.api.getPagelaqkByindustryTypeDetail(query).then(res => {
      tableConfig.value.tableLoading = false
      if (res.success) tableConfig.value.tableData = res
    }).catch(() => {
      tableConfig.value.tableLoading = false
    })
  }
  if(props.tag==='ytqy'){
    tableConfig.value.tableLoading = true
    apiConfig.value.api.getPagelaytqyByindustryTypeDetail(query).then(res => {
      tableConfig.value.tableLoading = false
      if (res.success) tableConfig.value.tableData = res
    }).catch(() => {
      tableConfig.value.tableLoading = false
    })
  }
  if(props.tag==='zkzz'){
    tableConfig.value.tableLoading = true
    apiConfig.value.api.getPagelazkzzqyByindustryTypeDetail(query).then(res => {
      tableConfig.value.tableLoading = false
      if (res.success) tableConfig.value.tableData = res
    }).catch(() => {
      tableConfig.value.tableLoading = false
    })
  }
  if(props.tag==='tczd'){
    tableConfig.value.tableLoading = true
    apiConfig.value.api.getPagelatczdqyByindustryTypeDetail(query).then(res => {
      tableConfig.value.tableLoading = false
      if (res.success) tableConfig.value.tableData = res
    }).catch(() => {
      tableConfig.value.tableLoading = false
    })
  }
  if(props.tag==='gb'){
    tableConfig.value.tableLoading = true
    apiConfig.value.api.getPagelagbqyByindustryTypeDetail(query).then(res => {
      tableConfig.value.tableLoading = false
      if (res.success) tableConfig.value.tableData = res
    }).catch(() => {
      tableConfig.value.tableLoading = false
    })
  }

}



</script>

<style lang="scss">

.enterpriseInfo .el-dialog {
  margin-bottom: 0;
}

.enterprise-dialog {
  margin-bottom: 0 !important;
}

</style>
