DeviceModal.vue 3.5 KB

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