From c832bf2e80ac465e71b7a1c1f7a59d4252030989 Mon Sep 17 00:00:00 2001
From: 张含笑 <zhx18749296735@163.com>
Date: Tue, 05 Aug 2025 17:33:08 +0800
Subject: [PATCH] feat:事件工单滚动条

---
 src/views/system/helpCenter.vue |   50 ++++++++++++++++++++++++++++++++++++--------------
 1 files changed, 36 insertions(+), 14 deletions(-)

diff --git a/src/views/system/helpCenter.vue b/src/views/system/helpCenter.vue
index 2075a23..2fae289 100644
--- a/src/views/system/helpCenter.vue
+++ b/src/views/system/helpCenter.vue
@@ -18,14 +18,17 @@
         <el-table-column prop="createTime" label="上传时间" />
         <el-table-column label="操作" width="150" align="center">
           <template #default="scope">
-            <span class="look" @click="clickDetail(scope.row)">查看</span>
+            <span class="look" @click="clickDetail(scope.row)" v-if="permission.helpCenterLook"
+              >查看</span
+            >
             <el-upload
               style="display: inline-block"
               :show-file-list="false"
-               :before-upload="(file) => onUploadFileBefore(file, scope.row)"
+              :before-upload="file => onUploadFileBefore(file, scope.row)"
               :limit="1"
+              accept=".pdf"
             >
-              <span class="uploads">上传</span>
+              <span class="uploads" v-if="permission.helpCenterUpload">上传</span>
             </el-upload>
           </template>
         </el-table-column>
@@ -37,9 +40,12 @@
 <script setup>
 import { uploadFileAPI, listDataAPI, updataDataAPI } from '@/api/helpCenter/helpCenter';
 import { ElMessage } from 'element-plus';
-import { onMounted } from 'vue';
+import { computed, onMounted } from 'vue';
 const helpData = ref([]);
 
+import { useStore } from 'vuex';
+const store = useStore();
+const permission = computed(() => store.state.user.permission);
 // 表格隔行变色
 const tableRowClassName = ({ row, rowIndex }) => {
   if (rowIndex % 2 === 1) {
@@ -51,35 +57,51 @@
 const getlistDataAPI = () => {
   listDataAPI().then(res => {
     helpData.value = res.data.data;
- 
   });
 };
 // 查看
-const clickDetail = (val) => {
-  const filePath = val.filePath
-   if (!val.filePath) {
+// const clickDetail = row => {
+//   if (!row.filePath) {
+//     ElMessage.warning('没有可预览的文件');
+//     return;
+//   }
+//   fetch(row.filePath)
+//     .then(response => response.blob())
+//     .then(res => {
+//       let blob = new Blob([res], { type: 'application/pdf' });
+//       // pdfurl即转化后的结果
+//       let pdfurl = window.URL.createObjectURL(blob);
+//       // 新标签页打开,即可预览并下载
+//       window.open(pdfurl);
+//     });
+// };
+const clickDetail = val => {
+  const filePath = val.filePath;
+  if (!val.filePath) {
     ElMessage.warning('没有可预览的文件');
     return;
   }
   window.open(filePath, '_blank');
 };
 // 文件上传
-const onUploadFileBefore = (file,row) => {
-const params={
-  id:row.id,
-  filePath:row.filePath
-}
+const onUploadFileBefore = (file, row) => {
   const fileFormat = file.name?.split('.')[1];
   if (fileFormat !== 'pdf') return ElMessage.error('请上传pdf格式的文件');
   const formData = new FormData();
   formData.append('file', file, file.name);
+
   uploadFileAPI(formData).then(res => {
     if (res.data.code === 200) {
+      const params = {
+        id: row.id,
+        filePath: res.data.data.link,
+      };
       ElMessage.success('上传成功');
-      updataDataAPI(params)
+      updataDataAPI(params);
     } else {
       ElMessage.error('上传失败');
     }
+    getlistDataAPI();
   });
 };
 onMounted(() => {

--
Gitblit v1.9.3