reportInfo.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <template>
  2. <BasicModal
  3. @register="registerModal"
  4. :defaultFullscreen="true"
  5. title="报表导出"
  6. width="1000px"
  7. v-bind="$attrs"
  8. :footer="null"
  9. :showCancelBtn="false"
  10. :showOkBtn="false"
  11. destroyOnClose
  12. :mask-closable="false"
  13. >
  14. <div id="fileEdit"></div>
  15. </BasicModal>
  16. </template>
  17. <script lang="ts" setup>
  18. import { computed, unref, inject, reactive, ref, watch, defineProps } from 'vue';
  19. import { BasicModal, useModalInner } from '/@/components/Modal';
  20. import { useUserStore } from '/@/store/modules/user';
  21. let props = defineProps({
  22. editID: {
  23. type: String,
  24. default: () => {
  25. return '';
  26. },
  27. },
  28. fileType: {
  29. type: String,
  30. default: () => {
  31. return '';
  32. },
  33. },
  34. });
  35. const remoteUrl = import.meta.env.DEV ? 'http://182.92.126.35' : 'http://' + window.location.hostname;
  36. const userStore = useUserStore(); //获取用户信息
  37. let userId = unref(userStore.getUserInfo).id;
  38. let userName = unref(userStore.getUserInfo).username;
  39. // const emit = defineEmits(['register']);
  40. let [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
  41. //重置表单
  42. setModalProps({ confirmLoading: false });
  43. // Object.assign(deviceData, data.record);
  44. });
  45. watch(
  46. () => props.editID,
  47. (newV, oldV) => {
  48. console.log(newV, 'newV----------');
  49. new DocsAPI.DocEditor(
  50. 'fileEdit', // 元素id
  51. {
  52. type: 'desktop',
  53. width: '100%',
  54. height: '860px',
  55. document: {
  56. title: '文档管理',
  57. url: remoteUrl + ':9999/ventanaly-device/safety/reportInfo/onlyOffice/read?id=' + props.editID + '&type=' + '', //id表示文件id,后端接口用这个id来加载文件
  58. fileType: props.fileType == 'doc' ? 'docx' : props.fileType == 'xls' ? 'xlsx' : props.fileType == 'ppt' ? 'pptx' : props.fileType, //当文件类型为doc、xls、ppt时,对应用docx、xlsx、pptx否则会保存异常。
  59. key: '',
  60. lang: 'zh-CN',
  61. permissions: {
  62. download: true, //是否可下载
  63. edit: true,
  64. fillForms: true,
  65. print: true, //是否可打印
  66. },
  67. },
  68. editorConfig: {
  69. lang: 'zh-CN',
  70. mode: 'view', //view:只读且可复制内容,edit:可编辑
  71. callbackUrl: remoteUrl + ':9999/ventanaly-device/safety/reportInfo/onlyOffice/save?id=' + props.editID + '&type=' + '', //id表示文件id,后端接口用这个id来加载文件
  72. coEditing: {
  73. mode: 'fast',
  74. change: true,
  75. },
  76. customization: {
  77. toolbarNoTabs: true,
  78. autosave: false, //是否自动保存
  79. forcesave: true, //定义保存按钮是否显示
  80. hideRightMenu: true,
  81. },
  82. //用户信息
  83. user: {
  84. id: userId, //用户ID
  85. name: userName, //用户名称
  86. },
  87. },
  88. }
  89. );
  90. }
  91. );
  92. </script>
  93. <style lang="less" scoped></style>