<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:query-params="queryParams = $event"
           @update:actions="actions = $event"
           @update:dialog-config="dialogConfig = $event">
    <el-table-column header-align="center" prop="documentCode" label="文书编号" min-width="300"/>
    <el-table-column header-align="center" prop="documentName" label="文书名称" min-width="250"/>
    <el-table-column header-align="center" prop="documentDate" label="发件时间" min-width="200"/>
    <template #dialog="{ dialogConfig: dc }">
      <el-dialog :open="dc.show" :title="dc.title" :type="dc.type" v-if="dc.show" :show-footer="false" @update:open="dc.show = false" class="enterprise-dialog">
        <!-- 当存在 downloadUrl 时显示 PDF 文件 -->
        <iframe 
          v-if="dc.data.downloadUrl" 
          :src="`${dc.data.downloadUrl}#toolbar=0&navpanes=0&scrollbar=0`" 
          style="width: 100%; height: 600px; border: none;"
          frameborder="0"
        ></iframe>
        <!-- 原有的文书内容显示 -->
        <template v-else>
          <laspb v-if="dc.data.documentName === '立案审批表'" :documentCode="dc.data.documentCode" :documentNo="dc.data.documentNo" :documentName="dc.data.documentName" :caseInfo="dc.data.caseInfo" :documenContent="dc.data.documenContent"/>
          <ajysspb v-if="dc.data.documentName === '案件移送审批表'" :documentCode="dc.data.documentCode" :documentNo="dc.data.documentNo" :documentName="dc.data.documentName" :caseInfo="dc.data.caseInfo" :documenContent="dc.data.documenContent"/>
          <xcjcjl v-if="dc.data.documentName === '现场检查记录'" :documentCode="dc.data.documentCode" :documentNo="dc.data.documentNo" :documentName="dc.data.documentName" :caseInfo="dc.data.caseInfo" :documenContent="dc.data.documenContent"/>
          <cyqzpz v-if="dc.data.documentName === '抽样取证凭证'" :documentCode="dc.data.documentCode" :documentNo="dc.data.documentNo" :documentName="dc.data.documentName" :caseInfo="dc.data.caseInfo" :documenContent="dc.data.documenContent"/>
          <jdwts v-if="dc.data.documentName === '鉴定委托书'" :documentCode="dc.data.documentCode" :documentNo="dc.data.documentNo" :documentName="dc.data.documentName" :caseInfo="dc.data.caseInfo" :documenContent="dc.data.documenContent"/>
          <xcclcsjds v-if="dc.data.documentName === '现场处理措施决定书'" :documentCode="dc.data.documentCode" :documentNo="dc.data.documentNo" :documentName="dc.data.documentName" :caseInfo="dc.data.caseInfo" :documenContent="dc.data.documenContent"/>
          <zlxqzgzls v-if="dc.data.documentName === '责令限期整改指令书'" :documentCode="dc.data.documentCode" :documentNo="dc.data.documentNo" :documentName="dc.data.documentName" :caseInfo="dc.data.caseInfo" :documenContent="dc.data.documenContent"/>
          <xxdjbczjtzs v-if="dc.data.documentName === '先行登记保存证据通知书'" :documentCode="dc.data.documentCode" :documentNo="dc.data.documentNo" :documentName="dc.data.documentName" :caseInfo="dc.data.caseInfo" :documenContent="dc.data.documenContent"/>
          <xxdjbczjcljds v-if="dc.data.documentName === '先行登记保存证据处理决定书'" :documentCode="dc.data.documentCode" :documentNo="dc.data.documentNo" :documentName="dc.data.documentName" :caseInfo="dc.data.caseInfo" :documenContent="dc.data.documenContent"/>
          <xwtzs v-if="dc.data.documentName === '询问通知书'" :documentCode="dc.data.documentCode" :documentNo="dc.data.documentNo" :documentName="dc.data.documentName" :caseInfo="dc.data.caseInfo" :documenContent="dc.data.documenContent"/>
          <dcxwbl v-if="dc.data.documentName === '调查询问笔录'" :documentCode="dc.data.documentCode" :documentNo="dc.data.documentNo" :documentName="dc.data.documentName" :caseInfo="dc.data.caseInfo" :documenContent="dc.data.documenContent"/>
          <zgfcyjs v-if="dc.data.documentName === '整改复查意见书'" :documentCode="dc.data.documentCode" :documentNo="dc.data.documentNo" :documentName="dc.data.documentName" :caseInfo="dc.data.caseInfo" :documenContent="dc.data.documenContent"/>
          <ajdczjbg v-if="dc.data.documentName === '案件调查终结报告'" :documentCode="dc.data.documentCode" :documentNo="dc.data.documentNo" :documentName="dc.data.documentName" :caseInfo="dc.data.caseInfo" :documenContent="dc.data.documenContent"/>
          <fzshyjs v-if="dc.data.documentName === '行政执法决定法制审核意见书'" :documentCode="dc.data.documentCode" :documentNo="dc.data.documentNo" :documentName="dc.data.documentName" :caseInfo="dc.data.caseInfo" :documenContent="dc.data.documenContent"/>
          <xzcfgzs v-if="dc.data.documentName === '行政处罚告知书'" :documentCode="dc.data.documentCode" :documentNo="dc.data.documentNo" :documentName="dc.data.documentName" :caseInfo="dc.data.caseInfo" :documenContent="dc.data.documenContent"/>
          <tzhtzs v-if="dc.data.documentName === '行政处罚听证会通知书'" :documentCode="dc.data.documentCode" :documentNo="dc.data.documentNo" :documentName="dc.data.documentName" :caseInfo="dc.data.caseInfo" :documenContent="dc.data.documenContent"/>
          <tzbl v-if="dc.data.documentName === '听证笔录'" :documentCode="dc.data.documentCode" :documentNo="dc.data.documentNo" :documentName="dc.data.documentName" :caseInfo="dc.data.caseInfo" :documenContent="dc.data.documenContent"/>
          <tzhbgs v-if="dc.data.documentName === '听证会报告书'" :documentCode="dc.data.documentCode" :documentNo="dc.data.documentNo" :documentName="dc.data.documentName" :caseInfo="dc.data.caseInfo" :documenContent="dc.data.documenContent"/>
          <jttljl v-if="dc.data.documentName === '行政处罚集体讨论记录'" :documentCode="dc.data.documentCode" :documentNo="dc.data.documentNo" :documentName="dc.data.documentName" :caseInfo="dc.data.caseInfo" :documenContent="dc.data.documenContent"/>
          <ajclcpb v-if="dc.data.documentName === '案件处理呈批表'" :documentCode="dc.data.documentCode" :documentNo="dc.data.documentNo" :documentName="dc.data.documentName" :caseInfo="dc.data.caseInfo" :documenContent="dc.data.documenContent"/>
          <xzcfjds v-if="dc.data.documentName === '行政处罚决定书'" :documentCode="dc.data.documentCode" :documentNo="dc.data.documentNo" :documentName="dc.data.documentName" :caseInfo="dc.data.caseInfo" :documenContent="dc.data.documenContent"/>
          <xzcfjdlxcgs v-if="dc.data.documentName === '行政处罚决定履行催告书'" :documentCode="dc.data.documentCode" :documentNo="dc.data.documentNo" :documentName="dc.data.documentName" :caseInfo="dc.data.caseInfo" :documenContent="dc.data.documenContent"/>
          <yqjnfkpzs v-if="dc.data.documentName === '延期（分期）缴纳罚款批准书'" :documentCode="dc.data.documentCode" :documentNo="dc.data.documentNo" :documentName="dc.data.documentName" :caseInfo="dc.data.caseInfo" :documenContent="dc.data.documenContent"/>
          <wssdhz v-if="dc.data.documentName === '文书送达回执'" :documentCode="dc.data.documentCode" :documentNo="dc.data.documentNo" :documentName="dc.data.documentName" :caseInfo="dc.data.caseInfo" :documenContent="dc.data.documenContent"/>
          <jaspb v-if="dc.data.documentName === '结案审批表'" :documentCode="dc.data.documentCode" :documentNo="dc.data.documentNo" :documentName="dc.data.documentName" :caseInfo="dc.data.caseInfo" :documenContent="dc.data.documenContent"/>
          <jnbkb v-if="dc.data.documentName === '卷内备考表'" :documentCode="dc.data.documentCode" :documentNo="dc.data.documentNo" :documentName="dc.data.documentName" :caseInfo="dc.data.caseInfo" :documenContent="dc.data.documenContent"/>
        </template>
      </el-dialog>
    </template>
  </browser>
</template>

<script setup>
import {reactive, toRefs} from 'vue'
import Browser from '@/components/Browser.vue'
import ElDialog from '@/components/ElDialog/index.vue'
import documents from '@/api/lawenforcement/Document.js'
import laspb from '@pages/xzzfgl/caseMan/laspb.vue'
import ajysspb from '@pages/xzzfgl/caseMan/ajysspb.vue'
import xcjcjl from '@pages/xzzfgl/caseMan/xcjcjl.vue'
import cyqzpz from '@pages/xzzfgl/caseMan/cyqzpz.vue'
import jdwts from '@pages/xzzfgl/caseMan/jdwts.vue'
import xcclcsjds from '@pages/xzzfgl/caseMan/xcclcsjds.vue'
import zlxqzgzls from '@pages/xzzfgl/caseMan/zlxqzgzls.vue'
import xxdjbczjtzs from '@pages/xzzfgl/caseMan/xxdjbczjtzs.vue'
import xxdjbczjcljds from '@pages/xzzfgl/caseMan/xxdjbczjcljds.vue'
import xwtzs from '@pages/xzzfgl/caseMan/xwtzs.vue'
import dcxwbl from '@pages/xzzfgl/caseMan/dcxwbl.vue'
import zgfcyjs from '@pages/xzzfgl/caseMan/zgfcyjs.vue'

import xzcfgzs from '@pages/xzzfgl/caseMan/xzcfgzs.vue'
import tzhtzs from '@pages/xzzfgl/caseMan/tzhtzs.vue'
import tzbl from '@pages/xzzfgl/caseMan/tzbl.vue'
import tzhbgs from '@pages/xzzfgl/caseMan/tzhbgs.vue'
import jttljl from '@pages/xzzfgl/caseMan/jttljl.vue'
import ajclcpb from '@pages/xzzfgl/caseMan/ajclcpb.vue'
import xzcfjds from '@pages/xzzfgl/caseMan/xzcfjds.vue'
import xzcfjdlxcgs from '@pages/xzzfgl/caseMan/xzcfjdlxcgs.vue'
import yqjnfkpzs from '@pages/xzzfgl/caseMan/yqjnfkpzs.vue'
import wssdhz from '@pages/xzzfgl/caseMan/wssdhz.vue'
import jaspb from '@pages/xzzfgl/caseMan/jaspb.vue'
import jnbkb from '@pages/xzzfgl/caseMan/jnbkb.vue'


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

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: true,
    controlWidth: '100',
    multipleSelect: false
  },
  apiConfig: {
    api: documents,
    modelId: 'documentId'
  },
  dialogConfig: {
    type: 'max',
    show: false,
    mode: 'detail',
    loading: false,
    formLabelWidth: '90px',
    showFooter: false
  },
  actions: {
    detail: handleDetail
  },
  queryParams: {},
})

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

function customQuery(params) {
  tableConfig.value.tableLoading = true
  let query = Object.assign({}, params, props.dialogData)
  apiConfig.value.api.getDocuments(query).then(res => {
    tableConfig.value.tableLoading = false
    if (res.success) tableConfig.value.tableData = res
  }).catch(() => {
    tableConfig.value.tableLoading = false
  })
}

async function handleDetail(row) {
  dialogConfig.value.show = true
  dialogConfig.value.mode = 'detail'
  dialogConfig.value.title = row.documentName
  dialogConfig.value.data = Object.assign({}, row)
}

</script>

<style lang="scss">

</style>
