From c4ec0fac48c9bef59fadba87404ea3d4bf9e087c Mon Sep 17 00:00:00 2001
From: fuliqi <fuliqi@qq.com>
Date: 星期二, 11 二月 2025 16:05:42 +0800
Subject: [PATCH] 工单、报备,图片预览功能

---
 src/views/system/report/index.vue |   81 ++++++++++++++++++++++++++++++++--------
 1 files changed, 65 insertions(+), 16 deletions(-)

diff --git a/src/views/system/report/index.vue b/src/views/system/report/index.vue
index ed883e4..df53f4e 100644
--- a/src/views/system/report/index.vue
+++ b/src/views/system/report/index.vue
@@ -2,7 +2,7 @@
   <div class="app-container">
     <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch">
       <el-form-item label="鍏抽敭瀛�" prop="peopleId">
-        <el-input v-model="queryParams.keyword" placeholder="璇疯緭鍏ュ叧閿瓧" clearable @keyup.enter.native="handleQuery" />
+        <el-input v-model="queryParams.keyword" placeholder="鐐逛綅鍚嶆悳绱�" clearable @keyup.enter.native="handleQuery" @clear="handleQuery"/>
       </el-form-item>
       <el-form-item label="鎶ュ绫诲瀷" prop="reportType">
         <el-select v-model="queryParams.reportType" @change="handleQuery" placeholder="鎶ュ绫诲瀷" clearable>
@@ -11,7 +11,7 @@
         </el-select>
       </el-form-item>
       <el-form-item label="鏁呴殰绫诲瀷" prop="errorTypeList">
-        <el-select v-model="queryParams.errorTypeList" multiple @change="handleQuery" clearable @clear="handleQuery">
+        <el-select v-model="queryParams.errorTypeList" multiple @change="handleQuery" clearable>
           <el-option v-for="dict in dict.type.report_error_type" :value="dict.value" :key="dict.value" :label="dict.label" />
         </el-select>
       </el-form-item>
@@ -60,8 +60,17 @@
             <div class="info-item">
               <div class="info-label">鎶ュ鏉愭枡</div>
               <div class="info-list">
-                <div style="margin-bottom: 8px" v-for="file in formatFileList(scope.row.reportMaterials)" :key="file">
-                  <el-link type="primary" @click="handleDownload(file)">
+                <div style="margin-bottom: 8px" v-for="file in scope.row.reportMaterials!=null ? scope.row.reportMaterials.split(',') : scope.row.reportMaterials" :key="file">
+                  <el-image
+                    v-if="isImageFile(file)"
+                    :src="getPreview(file)"
+                    :preview-src-list="[getPreview(file)]"
+                    fit="cover"
+                    class="material-preview"
+                    style="width: 100px; height: 100px; margin: 5px;"
+                  >
+                  </el-image>
+                  <el-link v-else type="primary" @click="handleDownload(file)">
                     {{file.match(/\/([^\/]*)$/)[1]}}
                   </el-link>
                 </div>
@@ -137,7 +146,10 @@
               </el-select>
             </el-form-item>
             <el-form-item label="鎶ュ鏃堕棿" prop="daterangeCreateTime">
-              <el-date-picker v-model="form.daterangeCreateTime" type="datetimerange" value-format="yyyy-MM-dd HH:mm:ss"
+              <el-date-picker v-model="form.daterangeCreateTime"
+                              type="datetimerange"
+                              value-format="yyyy-MM-dd HH:mm:ss"
+                              format="yyyy-MM-dd HH:mm:ss"
                               range-separator="-" start-placeholder="寮�濮嬫棩鏈�" end-placeholder="缁撴潫鏃ユ湡"
                               ></el-date-picker>
             </el-form-item>
@@ -178,11 +190,22 @@
                     <div class="content" v-html="getHtmlContent(record.reportContent)"></div>
                   </el-descriptions-item>
                   <el-descriptions-item label="鎶ュ鏉愭枡">
-                    <el-link
+                    <div
                       v-for="item in record.reportMaterials != null ? record.reportMaterials.split(',') : record.reportMaterials"
-                      :underline="false" type="primary" :key="item" @click="handleDownload(item)">
-                      {{ item.substring(item.lastIndexOf("/") + 1) }}
-                    </el-link>
+                      :key="item">
+                      <el-image
+                        v-if="isImageFile(item)"
+                        :src="getPreview(item)"
+                        :preview-src-list="[getPreview(item)]"
+                        fit="cover"
+                        style="width: 100px; height: 100px; margin: 5px;">
+                      </el-image>
+                      <el-link
+                        v-else
+                        :underline="false" type="primary" @click="handleDownload(item)">
+                        {{ item.substring(item.lastIndexOf("/") + 1) }}
+                      </el-link>
+                    </div>
                   </el-descriptions-item>
                 </el-descriptions>
               </el-card>
@@ -215,13 +238,13 @@
             <el-input v-model="auditingForm.reportType" disabled />
           </el-form-item>
           <el-form-item label="鏁呴殰绫诲瀷">
-            <el-input v-model="auditingForm.errorTypeList" disabled />
+            <el-input v-model="auditingForm.errorType" disabled />
           </el-form-item>
           <el-form-item label="鐢熸晥鏃堕棿">
-            <el-date-picker v-model="auditingForm.beginCreateTime" disabled />
+            <el-date-picker v-model="auditingForm.beginCreateTime" format="yyyy-MM-dd HH:mm:ss" disabled />
           </el-form-item>
           <el-form-item label="澶辨晥鏃堕棿">
-            <el-date-picker v-model="auditingForm.endCreateTime" disabled />
+            <el-date-picker v-model="auditingForm.endCreateTime" format="yyyy-MM-dd HH:mm:ss" disabled />
           </el-form-item>
           <el-form-item label="瀹℃牳缁撴灉">
             <el-radio-group v-model="auditingForm.auditingResult">
@@ -249,10 +272,24 @@
               <span v-html="auditingForm.reportContent"></span>
             </el-form-item>
             <el-form-item label="鎶ュ鏉愭枡">
-              <el-link
+                <!-- 娣诲姞绌鸿 -->
+                <div class="material-spacer">{{''}}</div>
+              <div
                 v-for="item in auditingForm.reportMaterials != null ? auditingForm.reportMaterials.split(',') : auditingForm.reportMaterials"
-                :underline="false" type="primary" :key="item" @click="handleDownload(item)">{{ item.substring(item.lastIndexOf("/") + 1)
-                }}</el-link>
+                :key="item">
+                <el-image
+                  v-if="isImageFile(item)"
+                  :src="getPreview(item)"
+                  :preview-src-list="[getPreview(item)]"
+                  fit="cover"
+                  style="width: 100px; height: 100px; margin: 5px;">
+                </el-image>
+                <el-link
+                  v-else
+                  :underline="false" type="primary" @click="handleDownload(item)">
+                  {{ item.substring(item.lastIndexOf("/") + 1) }}
+                </el-link>
+              </div>
             </el-form-item>
           </el-form>
         </div>
@@ -263,7 +300,6 @@
         <el-button type="primary" @click="auditingSubmit">瀹� 鏍�</el-button>
       </div>
     </el-dialog>
-
   </div>
 </template>
 
@@ -370,6 +406,16 @@
     this.getList();
   },
   methods: {
+    getPreview(url) {
+      // 浣跨敤鍏ㄥ眬閰嶇疆鐨勫浘鐗囧墠缂�
+      return this.$img + url;
+    },
+    isImageFile(url) {
+      const imageExtensions = ['.jpg', '.jpeg', '.png', '.gif', '.webp'];
+      return imageExtensions.some(ext =>
+        url.toLowerCase().endsWith(ext)
+      );
+    },
     getHtmlContent(content) {
       if (content) {
         return content
@@ -628,6 +674,9 @@
 </script>
 
 <style lang="scss" scoped>
+.material-spacer {
+  height: 50px; /* 鍙互璋冩暣绌鸿鐨勯珮搴� */
+}
 .content {
   height: 100px;
   max-height: 300px;

--
Gitblit v1.8.0