DeviceModal.vue 2.9 KB

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