Ver código fonte

优化若干问题

学习?学个屁 3 dias atrás
pai
commit
61ed4ee8e0

+ 13 - 4
src/views/businessManagement/courses/index.vue

@@ -10,16 +10,16 @@
           @click="router.push({ name: 'businessManagement-publishcourses', query: { type: 0 } })"
           preIcon="ant-design:plus-outlined"
         >
-          新增</a-button
-        >
+          新增
+        </a-button>
       </template>
       <!--操作栏-->
       <template #action="{ record }">
         <TableAction :actions="getTableAction(record)" :dropDownActions="getDropDownAction(record)" />
       </template>
       <!--字段回显插槽-->
-      <template v-slot:bodyCell="{ column, record, index, text }"> </template>
-      <template #price="{ record }"> {{ record.sellingPrice }}/{{ record.originalPrice }} </template>
+      <template v-slot:bodyCell="{ column, record, index, text }"></template>
+      <template #price="{ record }"> {{ record.sellingPrice }}/{{ record.originalPrice }}</template>
       <template #priceType="{ record }">
         <Switch v-model:checked="record.rackingStatus" :checked-value="0" :un-checked-value="1" @change="handleSwich(record)"></Switch>
       </template>
@@ -49,6 +49,7 @@
   import { useUserStore } from '/@/store/modules/user';
   import { useMessage } from '/@/hooks/web/useMessage';
   import { useRouteTabText } from '/@/hooks/web/useRouteTab';
+
   const queryParam = reactive<any>({});
   const userStore = useUserStore();
   const { createMessage } = useMessage();
@@ -83,15 +84,18 @@
   });
 
   const [registerTable, { reload }, { rowSelection, selectedRowKeys }] = tableContext;
+
   /**
    * 编辑事件
    */
   function handleView(record: Recordable) {
     router.push({ name: 'businessManagement-publishcourses', query: { type: 2, id: record.id } });
   }
+
   function handleEdit(record: Recordable) {
     router.push({ name: 'businessManagement-publishcourses', query: { type: 1, id: record.id } });
   }
+
   /**
    * 删除事件
    */
@@ -105,6 +109,7 @@
   function handleSuccess() {
     (selectedRowKeys.value = []) && reload();
   }
+
   /**
    * 操作栏
    */
@@ -123,6 +128,7 @@
       },
     ];
   }
+
   /**
    * 下拉操作栏
    */
@@ -144,6 +150,7 @@
       },
     ];
   }
+
   async function handleEditCourses(record) {
     const res = await queryCourseList({ coursesType: 1, id: record.id });
     openModal(true, {
@@ -152,7 +159,9 @@
       showFooter: true,
     });
   }
+
   useRouteTabText(['发布课程', '编辑课程', '查看课程']);
+
   async function handleSwich(record) {
     await updateStatus({ id: record.id, rackingStatus: record.rackingStatus });
   }

+ 26 - 12
src/views/safetyManagement/signingList/index.vue

@@ -3,7 +3,7 @@
     <!--引用表格-->
     <BasicTable @register="registerTable">
       <!--插槽:table标题-->
-      <template #tableTitle> </template>
+      <template #tableTitle></template>
       <!--操作栏-->
       <template #action="{ record }">
         <TableAction :actions="getTableAction(record)" />
@@ -11,12 +11,12 @@
     </BasicTable>
   </div>
   <!-- PDF预览弹窗 -->
-  <!-- <BasicModal v-model="previewVisible" title="合同预览" width="80%" :showOkBtn="false" @cancel="previewVisible = false">
-   
-  </BasicModal> -->
-  <div v-show="previewVisible" class="absolute left-9999999999999">
-    <iframe :src="url" id="pdfPreviewIframe" frameborder="0" width="100%" height="550px" scrolling="auto"></iframe>
-  </div>
+<!--  <BasicModal v-model:visible="previewVisible" title="合同预览" width="80%" :showOkBtn="false" @cancel="previewVisible = false">-->
+<!--    <iframe :src="iframeSrc" id="pdfPreviewIframe" frameborder="0" width="100%" height="550px" scrolling="auto"> </iframe>-->
+<!--  </BasicModal>-->
+  <!--  <div v-show="previewVisible" class="absolute">-->
+  <!--    <iframe :src="url" id="pdfPreviewIframe" frameborder="0" width="100%" height="550px" scrolling="auto"></iframe>-->
+  <!--  </div>-->
 </template>
 
 <script lang="ts" setup>
@@ -28,6 +28,9 @@
   import { getViewUrl, list } from './signing.api';
   import { getToken } from '/@/utils/auth';
   import { useGlobSetting } from '/@/hooks/setting';
+  import { useMessage } from '/@/hooks/web/useMessage';
+
+  const { createMessage } = useMessage();
   const queryParam = reactive<any>({});
   const previewVisible = ref(false);
   const glob = useGlobSetting();
@@ -63,11 +66,22 @@
    * 编辑事件
    */
   async function handleEdit(record: Recordable) {
-    const res = await getViewUrl({ signFlowId: record.signFlowId });
-    if (res && res.length > 0 && res[0].downloadUrl) {
-      let iframe = document.getElementById('pdfPreviewIframe');
-      let json = { title: res[0].fileName, token: getToken(), url: res[0].downloadUrl };
-      iframe!.contentWindow.postMessage(json, '*');
+    try {
+      createMessage.loading('正在下载文件...', 0);
+      const res = await getViewUrl({ signFlowId: record.signFlowId });
+      if (res && res.length > 0 && res[0].downloadUrl) {
+        const downloadUrl = res[0].downloadUrl;
+        const link = document.createElement('a');
+        link.href = downloadUrl;
+        link.download = '';
+        link.click();
+        link.remove();
+        createMessage.success('文件下载成功');
+      }
+    } catch (error) {
+      createMessage.error('文件下载失败');
+    } finally {
+      createMessage.destroy();
     }
   }