DeviceModal.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. <template>
  2. <BasicModal :defaultFullscreen="defaultScreen" v-bind="$attrs" @register="registerModal" :title="title"
  3. :width="widthV" :showCancelBtn="false" :showOkBtn="false" :footer="null" destroyOnClose :mask-closable="false"
  4. @cancel="closeModalFn">
  5. <!-- 报表新增 -->
  6. <div v-if="addOredit == 'add'">
  7. <a-form :model="formState" :label-col="{ style: { width: '130px' } }" :wrapper-col="{ span: 14 }">
  8. <a-form-item label="文件名称:">
  9. <a-input v-model:value="formState.fileName" placeholder="请输入文件名称..." />
  10. </a-form-item>
  11. <a-form-item label="业务种类:">
  12. <JDictSelectTag v-model:value="formState.busKind" placeholder="请选择业务种类..." dictCode="reportBusKind"
  13. @change="changeKind" />
  14. </a-form-item>
  15. <a-form-item label="报表类型:">
  16. <JDictSelectTag v-if="kindType == 'ventSReport'" v-model:value="formState.reportType" placeholder="请选择报表类型..."
  17. dictCode="ventSReport" />
  18. <JDictSelectTag v-if="kindType == 'fireSReport'" v-model:value="formState.reportType" placeholder="请选择报表类型..."
  19. dictCode="fireSReport" />
  20. <JDictSelectTag v-if="kindType == 'dustSReport'" v-model:value="formState.reportType" placeholder="请选择报表类型..."
  21. dictCode="dustSReport" />
  22. <JDictSelectTag v-if="kindType == 'gasSReport'" v-model:value="formState.reportType" placeholder="请选择报表类型..."
  23. dictCode="gasSReport" />
  24. </a-form-item>
  25. <a-form-item label="选择模板:">
  26. <a-select v-model:value="formState.handTempid">
  27. <a-select-option v-for="item in optionList" :key="item.value">{{ item.label }}</a-select-option>
  28. </a-select>
  29. </a-form-item>
  30. <div class="footer">
  31. <a-button type="primary" style="margin-right: 20px" @click="save">保存</a-button>
  32. <a-button type="primar" @click="closeModalFn">取消</a-button>
  33. </div>
  34. </a-form>
  35. </div>
  36. <!--历史记录 -->
  37. <div v-else-if="addOredit == 'hisRecord'">
  38. <NormalHisTable :columns="columnsHis" :reportIds="reportId" :downLoad="hisdownload" :list="hisList"
  39. designScope="device-tabel" title="报表历史记录管理" :showTab="false" />
  40. </div>
  41. <!-- 报表编辑 -->
  42. <div v-else>
  43. <div id="fileEdit"></div>
  44. </div>
  45. </BasicModal>
  46. </template>
  47. <script lang="ts" setup>
  48. import { computed, unref, inject, reactive, ref, watch, defineProps } from 'vue';
  49. import NormalHisTable from '../comment/NormalHisTable.vue';
  50. import JDictSelectTag from '/@/components/Form/src/jeecg/components/JDictSelectTag.vue';
  51. import { BasicModal, useModalInner } from '/@/components/Modal';
  52. import { useUserStore } from '/@/store/modules/user';
  53. import { hisList, hisdownload } from '../reportManager.api';
  54. import { columnsHis } from '../reportManager.data';
  55. let props = defineProps({
  56. addOredit: {
  57. type: String,
  58. default: '',
  59. },
  60. editID: {
  61. type: String,
  62. default: '',
  63. },
  64. fileType: {
  65. type: String,
  66. default: '',
  67. },
  68. reportLogHis: {
  69. type: String,
  70. default: '',
  71. },
  72. reportId: {
  73. type: String,
  74. default: '',
  75. },
  76. optionLists: {
  77. type: Array,
  78. default: () => {
  79. return []
  80. }
  81. }
  82. });
  83. const remoteUrl = import.meta.env.DEV ? 'http://182.92.126.35' : 'http://' + window.location.hostname;
  84. const userStore = useUserStore(); //获取用户信息
  85. let userId = unref(userStore.getUserInfo).id;
  86. let userName = unref(userStore.getUserInfo).username;
  87. let formState = reactive({
  88. fileName: '',
  89. busKind: '',
  90. handTempid: '',
  91. reportType: '',
  92. });
  93. let kindType = ref('ventSReport')
  94. let optionList = ref<any[]>([])
  95. //设置标题
  96. let title = computed(() => {
  97. if (props.addOredit == 'add') {
  98. return '报表新增';
  99. } else if (props.addOredit == 'hisRecord') {
  100. return '历史记录';
  101. } else {
  102. return '报表编辑';
  103. }
  104. });
  105. //弹窗宽度
  106. let widthV = computed(() => {
  107. if (props.addOredit == 'add') {
  108. return '600px';
  109. } else {
  110. return '1000px';
  111. }
  112. });
  113. //弹窗是否全屏
  114. let defaultScreen = computed(() => {
  115. if (props.addOredit == 'add') {
  116. return false;
  117. } else {
  118. return true;
  119. }
  120. });
  121. // 声明Emits
  122. const emit = defineEmits(['saveOrUpdate', 'register']);
  123. //表单赋值
  124. const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
  125. //重置表单
  126. setModalProps({ confirmLoading: false });
  127. // Object.assign(deviceData, data.record);
  128. new DocsAPI.DocEditor(
  129. 'fileEdit', // 元素id
  130. {
  131. type: 'desktop',
  132. width: '100%',
  133. height: '860px',
  134. document: {
  135. title: '文档管理',
  136. url: remoteUrl + ':9999/ventanaly-device/safety/reportInfo/onlyOffice/read?id=' + props.editID + '&type=' + props.reportLogHis, //id表示文件id,后端接口用这个id来加载文件
  137. fileType: props.fileType == 'doc' ? 'docx' : props.fileType == 'xls' ? 'xlsx' : props.fileType == 'ppt' ? 'pptx' : props.fileType, //当文件类型为doc、xls、ppt时,对应用docx、xlsx、pptx否则会保存异常。
  138. key: '',
  139. lang: 'zh-CN',
  140. permissions: {
  141. download: true, //是否可下载
  142. edit: true,
  143. fillForms: true,
  144. print: true, //是否可打印
  145. },
  146. },
  147. editorConfig: {
  148. lang: 'zh-CN',
  149. mode: props.reportLogHis ? 'view' : 'edit', //view:只读且可复制内容,edit:可编辑
  150. callbackUrl: remoteUrl + ':9999/ventanaly-device/safety/reportInfo/onlyOffice/save?id=' + props.editID + '&type=' + props.reportLogHis, //id表示文件id,后端接口用这个id来加载文件
  151. coEditing: {
  152. mode: 'fast',
  153. change: true,
  154. },
  155. customization: {
  156. toolbarNoTabs: true,
  157. autosave: false, //是否自动保存
  158. forcesave: true, //定义保存按钮是否显示
  159. hideRightMenu: true,
  160. spellcheck: false,//ture打开拼写检查,false关闭拼写检查。(默认为ture)
  161. },
  162. //用户信息
  163. user: {
  164. id: userId, //用户ID
  165. name: userName, //用户名称
  166. },
  167. },
  168. }
  169. );
  170. });
  171. //业务种类下拉选项切换
  172. function changeKind(val) {
  173. kindType.value = `${val}Report`
  174. }
  175. //点击图标关闭弹框
  176. const closeModalFn = () => {
  177. formState.busKind=''
  178. formState.fileName=''
  179. formState.handTempid=''
  180. formState.reportType=''
  181. closeModal();
  182. };
  183. //新增保存
  184. let save = () => {
  185. emit('saveOrUpdate', formState);
  186. };
  187. watch(() => props.optionLists, (newV, oldV) => {
  188. optionList.value = newV
  189. }, { immediate: true, deep: true })
  190. </script>
  191. <style scoped lang="less">
  192. ::v-deep .suffix {
  193. height: 32px;
  194. line-height: 32px;
  195. margin-left: 5px;
  196. color: #fff;
  197. }
  198. ::v-deep .zxm-form {
  199. padding-top: 20px;
  200. }
  201. .footer {
  202. width: 100%;
  203. text-align: center;
  204. padding-top: 30px;
  205. }
  206. </style>