<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="fillingDate" label="立案日期" min-width="150"/>
    <el-table-column prop="unitName" label="生产经营单位名称" min-width="350"/>
    <el-table-column prop="unifiedSocialCode" label="社会统一信用代码" min-width="220"/>
  </browser>
</template>

<script setup>
import {reactive, toRefs, watch, computed, ref} from 'vue'
import {useUserStore} from '@/stores/modules/user'
import lawEnfPenaltyStat from '@/api/lawenforcement/LawEnfPenaltyStat'
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: lawEnfPenaltyStat,
    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==='las'){
    tableConfig.value.tableLoading = true
    apiConfig.value.api.getPagefxczflasDetail(query).then(res => {
      tableConfig.value.tableLoading = false
      if (res.success) tableConfig.value.tableData = res
    }).catch(() => {
      tableConfig.value.tableLoading = false
    })
  }
  if(props.tag==='cfs'){
    tableConfig.value.tableLoading = true
    apiConfig.value.api.getPagefxczfcfsDetail(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>
