<template>
  <BasicModal v-bind="$attrs" @register="registerModal" title="文件内容查看" :centered="true" width="60%" :useWrapper="true" :footer="null">
    <div style="background-color: #ececec; padding: 5px">
        <div :style="{ overflow: 'hidden', height: '85vh' }">
          <ShowFileCotent ref="refShowFileCotent"  :loading="loading"/>
        </div>
    </div>
  </BasicModal>
</template>

<script lang="ts" setup>
  import { ref, nextTick } from 'vue';
  import { BasicModal, useModalInner } from '/@/components/Modal';
  import ShowFileCotent from './ShowFileContent.vue';

  const refShowFileCotent = ref();
  const loading = ref(false);

  const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {  
    const { showFooter, record } = data || {}; 
    const { filepath } = record || {};  
   

    setModalProps({  
        confirmLoading: false,  
        showCancelBtn: !!showFooter,  
        showOkBtn: !!showFooter,  
    }); 

    if (filepath) {
        let docObj = {
          filePath:filepath,
          fileTp:"docx",
          fileName:filepath
        }
        refShowFileCotent.value.setDocFile(docObj);  
    } 
}); 


function getFileExtension(filename) {
  const index = filename.lastIndexOf('.');
  if (index === -1) return ''; 
  return filename.substring(index + 1);
}

</script>

<style lang="less" scoped>
  :deep(.ant-input-number) {
    width: 100%;
  }

  :deep(.ant-calendar-picker) {
    width: 100%;
  }
</style>
