DeviceModal.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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 { computed, unref, inject, 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 isUpdate = inject('isUpdate');
  39. const record = reactive({ strtype: '', strname: '' });
  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: 'http://47.94.222.6:9999/ventanaly-sharefile/fileServer/onlyOffice/read?id=' + props.editID, //id表示文件id,后端接口用这个id来加载文件
  54. fileType: props.fileType == 'doc' ? 'docx' : props.fileType == 'xls' ? 'xlsx' : props.fileType == 'ppt' ? 'pptx' : props.fileType, //当文件类型为doc、xls、ppt时,对应用docx、xlsx、pptx否则会保存异常。
  55. key: '',
  56. lang: 'zh-CN',
  57. permissions: {
  58. download: true, //是否可下载
  59. edit: true,
  60. fillForms: true,
  61. print: true, //是否可打印
  62. },
  63. },
  64. editorConfig: {
  65. lang: 'zh-CN',
  66. mode: 'edit', //view:只读且可复制内容,edit:可编辑
  67. callbackUrl: 'http://47.94.222.6:9999/ventanaly-sharefile/fileServer/onlyOffice/save?id=' + props.editID, //id表示文件id,后端接口用这个id来加载文件
  68. coEditing: {
  69. mode: 'fast',
  70. change: true,
  71. },
  72. customization: {
  73. toolbarNoTabs: true,
  74. autosave: false, //是否自动保存
  75. forcesave: true, //定义保存按钮是否显示
  76. hideRightMenu: true,
  77. },
  78. //用户信息
  79. user: {
  80. id: userId, //用户ID
  81. name: userName, //用户名称
  82. },
  83. },
  84. }
  85. );
  86. });
  87. onMounted(() => {});
  88. </script>
  89. <style scoped lang="less">
  90. ::v-deep .suffix {
  91. height: 32px;
  92. line-height: 32px;
  93. margin-left: 5px;
  94. color: #fff;
  95. }
  96. </style>