From 475a352a4bfd7ac3a81e8c7c92d3bb64e2e01037 Mon Sep 17 00:00:00 2001
From: WXL <wl_5969728@163.com>
Date: 星期五, 27 二月 2026 15:48:37 +0800
Subject: [PATCH] 青岛维护提交

---
 src/views/business/assess/components/OrganAssessmentForm.vue |  462 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 450 insertions(+), 12 deletions(-)

diff --git a/src/views/business/assess/components/OrganAssessmentForm.vue b/src/views/business/assess/components/OrganAssessmentForm.vue
index 29e03e9..2ef0c11 100644
--- a/src/views/business/assess/components/OrganAssessmentForm.vue
+++ b/src/views/business/assess/components/OrganAssessmentForm.vue
@@ -1,56 +1,494 @@
-<!-- src/views/case/assessment/components/OrganAssessmentForm.vue -->
 <template>
   <div class="organ-assessment-form">
-    <el-form :model="organData" label-width="120px">
+    <el-form :model="assessmentData" label-width="120px">
       <el-form-item label="鍔熻兘鐘舵��">
-        <el-select v-model="organData.functionStatus" :disabled="readonly">
+        <el-select v-model="assessmentData.functionStatus">
           <el-option label="姝e父" value="1" />
           <el-option label="杞诲害寮傚父" value="2" />
           <el-option label="閲嶅害寮傚父" value="3" />
           <el-option label="鏃犳硶璇勪及" value="4" />
         </el-select>
       </el-form-item>
+
       <el-form-item label="璇勪及鎰忚">
         <el-input
           type="textarea"
-          v-model="organData.assessmentOpinion"
+          v-model="assessmentData.assessmentOpinion"
           :rows="4"
-          :disabled="readonly"
           placeholder="璇疯緭鍏ヨ瘎浼版剰瑙�"
         />
       </el-form-item>
+
+      <!-- 闄勪欢涓婁紶鍖哄煙 -->
+      <el-form-item label="鐩稿叧闄勪欢">
+        <div class="attachment-section">
+          <div class="attachment-header">
+            <i class="el-icon-paperclip"></i>
+            <span class="attachment-title">闄勪欢涓婁紶</span>
+            <span class="attachment-tip"
+              >鏀寔涓婁紶妫�楠屾姤鍛婂崟绛夋枃浠� (鏈�澶歿{ attachmentLimit }}涓�)</span
+            >
+          </div>
+
+          <!-- 浣跨敤 UploadAttachment 缁勪欢 -->
+          <UploadAttachment
+            ref="uploadAttachment"
+            :file-list="attachmentFileList"
+            :limit="attachmentLimit"
+            :accept="attachmentAccept"
+            :multiple="true"
+            @change="handleAttachmentChange"
+            @upload-success="handleUploadSuccess"
+            @upload-error="handleUploadError"
+            @remove="handleAttachmentRemove"
+          />
+
+          <!-- 闄勪欢鍒楄〃 -->
+          <div
+            class="attachment-list"
+            v-if="
+              assessmentData.attachments &&
+                assessmentData.attachments.length > 0
+            "
+          >
+            <div class="list-title">
+              宸蹭笂浼犻檮浠� ({{ assessmentData.attachments.length }})
+            </div>
+            <el-table
+              :data="assessmentData.attachments"
+              style="width: 100%"
+              size="small"
+            >
+              <el-table-column label="鏂囦欢鍚�" min-width="200">
+                <template slot-scope="scope">
+                  <i
+                    class="el-icon-document"
+                    :style="{ color: getFileIconColor(scope.row.fileName) }"
+                  ></i>
+                  <span class="file-name">{{ scope.row.fileName }}</span>
+                </template>
+              </el-table-column>
+              <el-table-column label="鏂囦欢绫诲瀷" width="100">
+                <template slot-scope="scope">
+                  <el-tag
+                    :type="getFileTagType(scope.row.fileName)"
+                    size="small"
+                  >
+                    {{ getFileTypeText(scope.row.fileName) }}
+                  </el-tag>
+                </template>
+              </el-table-column>
+              <el-table-column label="涓婁紶鏃堕棿" width="160">
+                <template slot-scope="scope">
+                  <span>{{ formatDateTime(scope.row.uploadTime) }}</span>
+                </template>
+              </el-table-column>
+              <el-table-column label="鏂囦欢澶у皬" width="100">
+                <template slot-scope="scope">
+                  <span>{{ formatFileSize(scope.row.fileSize) }}</span>
+                </template>
+              </el-table-column>
+              <el-table-column label="鎿嶄綔" width="266" fixed="right">
+                <template slot-scope="scope">
+                  <el-button
+                    size="mini"
+                    type="primary"
+                    @click="handlePreview(scope.row)"
+                    :disabled="!isPreviewable(scope.row.fileName)"
+                  >
+                    棰勮
+                  </el-button>
+                  <el-button
+                    size="mini"
+                    type="success"
+                    @click="handleDownload(scope.row)"
+                  >
+                    涓嬭浇
+                  </el-button>
+                  <el-button
+                    v-if="!readonly"
+                    size="mini"
+                    type="danger"
+                    @click="handleRemoveAttachment(scope.$index)"
+                  >
+                    鍒犻櫎
+                  </el-button>
+                </template>
+              </el-table-column>
+            </el-table>
+          </div>
+        </div>
+      </el-form-item>
+
       <el-form-item v-if="!readonly">
         <el-button type="primary" @click="handleSave">淇濆瓨璇勪及</el-button>
         <el-button @click="handleCancel">鍙栨秷</el-button>
+        <el-button
+          type="success"
+          @click="handleAddAssessment"
+          icon="el-icon-plus"
+        >
+          鏂板璇勪及璁板綍
+        </el-button>
       </el-form-item>
     </el-form>
+
+    <!-- 鏂囦欢棰勮寮圭獥 -->
+    <FilePreviewDialog
+      :visible="previewVisible"
+      :file="currentPreviewFile"
+      @close="previewVisible = false"
+      @download="handleDownload"
+    />
   </div>
 </template>
 
 <script>
+import UploadAttachment from "@/components/UploadAttachment";
+import FilePreviewDialog from "@/components/FilePreviewDialog";
+import dayjs from "dayjs";
+
 export default {
   name: "OrganAssessmentForm",
+  components: {
+    UploadAttachment,
+    FilePreviewDialog
+  },
   props: {
     organData: {
       type: Object,
       default: () => ({})
+    },
+    assessmentData: {
+      type: Object,
+      default: () => ({
+        functionStatus: "",
+        assessmentOpinion: "",
+        attachments: []
+      })
+    },
+    assessmentIndex: {
+      type: Number,
+      default: 0
     },
     readonly: {
       type: Boolean,
       default: false
     }
   },
+  data() {
+    return {
+      // 棰勮鐩稿叧
+      previewVisible: false,
+      currentPreviewFile: null,
+
+      // 闄勪欢鐩稿叧閰嶇疆
+      attachmentLimit: 10,
+      attachmentAccept:
+        ".pdf,.jpg,.jpeg,.png,.doc,.docx,.xls,.xlsx,.ppt,.pptx,.txt",
+      attachmentFileList: []
+    };
+  },
+  watch: {
+    organData: {
+      handler(newVal, oldVal) {
+        // 鍙湁褰撻檮浠舵暟鎹湡姝e彂鐢熷彉鍖栨椂鎵嶅垵濮嬪寲
+        if (
+          !oldVal ||
+          !oldVal.attachments ||
+          JSON.stringify(newVal.attachments) !==
+            JSON.stringify(oldVal.attachments)
+        ) {
+          this.initAttachmentList();
+        }
+      },
+      immediate: true,
+      deep: true
+    }
+  },
   methods: {
+    /** 鍒濆鍖栭檮浠跺垪琛� */
+    initAttachmentList() {
+      if (this.organData.attachments && this.organData.attachments.length > 0) {
+        this.assessmentData.attachments = [...this.organData.attachments];
+        this.attachmentFileList = this.organData.attachments.map(item => ({
+          uid: item.id || Math.random(),
+          name: item.fileName,
+          url: item.path || item.fileUrl,
+          status: "success"
+        }));
+      } else {
+        this.assessmentData.attachments = [];
+        this.attachmentFileList = [];
+      }
+    },
     handleSave() {
-      this.$emit('save', {
-        ...this.organData,
-        assessmentTime: new Date().toISOString(),
-        assessor: '褰撳墠鐢ㄦ埛'
+      const saveData = {
+        organData: this.organData,
+        assessmentData: this.assessmentData,
+        assessmentIndex: this.assessmentIndex
+      };
+      this.$emit("save", saveData);
+    },
+
+    handleCancel() {
+      this.$emit("cancel");
+    },
+
+    handleAddAssessment() {
+      this.$emit("add-assessment", {
+        organData: this.organData,
+        currentIndex: this.assessmentIndex
       });
     },
-    handleCancel() {
-      this.$emit('cancel');
+    /** 闄勪欢鍙樺寲澶勭悊 */
+    handleAttachmentChange(fileList) {
+      this.attachmentFileList = fileList;
+    },
+
+    /** 闄勪欢绉婚櫎澶勭悊 */
+    handleAttachmentRemove(file) {
+      if (file.url) {
+        const index = this.assessmentData.attachments.findIndex(
+          item => item.path === file.url || item.fileUrl === file.url
+        );
+        if (index > -1) {
+          this.assessmentData.attachments.splice(index, 1);
+        }
+      }
+    },
+
+    /** 鎵嬪姩鍒犻櫎闄勪欢 */
+    handleRemoveAttachment(index) {
+      this.assessmentData.attachments.splice(index, 1);
+      this.attachmentFileList.splice(index, 1);
+      this.$message.success("闄勪欢鍒犻櫎鎴愬姛");
+    },
+
+    /** 涓婁紶鎴愬姛澶勭悊 */
+    handleUploadSuccess({ file, fileList, response }) {
+      console.log(response);
+
+      if (response.code == 200) {
+        console.log(1);
+
+        const attachmentObj = {
+          // id:
+          //   response.data.fileId ||
+          //   Math.random()
+          //     .toString(36)
+          //     .substr(2),
+          fileName: file.name,
+          path: response.data.fileUrl || file.url,
+          fileUrl: response.data.fileUrl || file.url,
+          fileType: this.getFileExtension(file.name),
+          fileSize: file.size,
+          uploadTime: dayjs().format("YYYY-MM-DD HH:mm:ss"),
+          assessmentType: this.assessmentType,
+          organType: this.organData.organType
+        };
+        console.log(2,attachmentObj);
+
+        this.assessmentData.attachments.push(attachmentObj);
+        this.$message.success("鏂囦欢涓婁紶鎴愬姛");
+      }
+    },
+
+    /** 涓婁紶閿欒澶勭悊 */
+    handleUploadError({ file, fileList, error }) {
+      console.error("闄勪欢涓婁紶澶辫触:", error);
+      this.$message.error("鏂囦欢涓婁紶澶辫触锛岃閲嶈瘯");
+    },
+
+    /** 鏂囦欢棰勮 */
+    handlePreview(file) {
+      this.currentPreviewFile = {
+        fileName: file.fileName,
+        fileUrl: file.path || file.fileUrl,
+        fileType: this.getFileType(file.fileName)
+      };
+      this.previewVisible = true;
+    },
+
+    /** 鏂囦欢涓嬭浇 */
+    handleDownload(file) {
+      const fileUrl = file.path || file.fileUrl;
+      const fileName = file.fileName;
+
+      if (fileUrl) {
+        const link = document.createElement("a");
+        link.href = fileUrl;
+        link.download = fileName;
+        link.style.display = "none";
+        document.body.appendChild(link);
+        link.click();
+        document.body.removeChild(link);
+        this.$message.success("寮�濮嬩笅杞芥枃浠�");
+      } else {
+        this.$message.warning("鏂囦欢璺緞涓嶅瓨鍦紝鏃犳硶涓嬭浇");
+      }
+    },
+
+    /** 鑾峰彇鏂囦欢绫诲瀷 */
+    getFileType(fileName) {
+      if (!fileName) return "other";
+
+      const extension = fileName
+        .split(".")
+        .pop()
+        .toLowerCase();
+      const imageTypes = ["jpg", "jpeg", "png", "gif", "bmp", "webp"];
+      const pdfTypes = ["pdf"];
+      const officeTypes = ["doc", "docx", "xls", "xlsx", "ppt", "pptx"];
+
+      if (imageTypes.includes(extension)) return "image";
+      if (pdfTypes.includes(extension)) return "pdf";
+      if (officeTypes.includes(extension)) return "office";
+      return "other";
+    },
+
+    /** 鑾峰彇鏂囦欢鍥炬爣棰滆壊 */
+    getFileIconColor(fileName) {
+      const type = this.getFileType(fileName);
+      const colorMap = {
+        image: "#67C23A",
+        pdf: "#F56C6C",
+        office: "#409EFF",
+        other: "#909399"
+      };
+      return colorMap[type] || "#909399";
+    },
+
+    /** 鑾峰彇鏂囦欢鏍囩绫诲瀷 */
+    getFileTagType(fileName) {
+      const type = this.getFileType(fileName);
+      const typeMap = {
+        image: "success",
+        pdf: "danger",
+        office: "primary",
+        other: "info"
+      };
+      return typeMap[type] || "info";
+    },
+
+    /** 鑾峰彇鏂囦欢绫诲瀷鏂囨湰 */
+    getFileTypeText(fileName) {
+      const type = this.getFileType(fileName);
+      const textMap = {
+        image: "鍥剧墖",
+        pdf: "PDF",
+        office: "鏂囨。",
+        other: "鍏朵粬"
+      };
+      return textMap[type] || "鏈煡";
+    },
+
+    /** 妫�鏌ユ槸鍚﹀彲棰勮 */
+    isPreviewable(fileName) {
+      const type = this.getFileType(fileName);
+      return ["image", "pdf"].includes(type);
+    },
+
+    /** 鑾峰彇鏂囦欢鎵╁睍鍚� */
+    getFileExtension(filename) {
+      return filename
+        .split(".")
+        .pop()
+        .toLowerCase();
+    },
+
+    /** 鏍煎紡鍖栨枃浠跺ぇ灏� */
+    formatFileSize(bytes) {
+      if (!bytes || bytes === 0) return "0 B";
+      const k = 1024;
+      const sizes = ["B", "KB", "MB", "GB"];
+      const i = Math.floor(Math.log(bytes) / Math.log(k));
+      return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + " " + sizes[i];
+    },
+
+    /** 鏃ユ湡鏃堕棿鏍煎紡鍖� */
+    formatDateTime(dateTime) {
+      if (!dateTime) return "";
+
+      try {
+        const date = new Date(dateTime);
+        if (isNaN(date.getTime())) return dateTime;
+
+        const year = date.getFullYear();
+        const month = String(date.getMonth() + 1).padStart(2, "0");
+        const day = String(date.getDate()).padStart(2, "0");
+        const hours = String(date.getHours()).padStart(2, "0");
+        const minutes = String(date.getMinutes()).padStart(2, "0");
+
+        return `${year}-${month}-${day} ${hours}:${minutes}`;
+      } catch (error) {
+        return dateTime;
+      }
     }
   }
-}
+};
 </script>
+
+<style scoped>
+.organ-assessment-form {
+  padding: 20px;
+}
+
+.attachment-section {
+  border: 1px solid #ebeef5;
+  border-radius: 4px;
+  padding: 15px;
+  background: #fafafa;
+}
+
+.attachment-header {
+  display: flex;
+  align-items: center;
+  margin-bottom: 16px;
+  padding-bottom: 8px;
+  border-bottom: 1px solid #ebeef5;
+}
+
+.attachment-title {
+  font-weight: bold;
+  margin: 0 8px;
+  color: #303133;
+}
+
+.attachment-tip {
+  font-size: 12px;
+  color: #909399;
+  margin-left: auto;
+}
+
+.attachment-list {
+  margin-top: 16px;
+}
+
+.list-title {
+  font-weight: bold;
+  margin-bottom: 12px;
+  color: #303133;
+  font-size: 14px;
+}
+
+.file-name {
+  font-size: 13px;
+  margin-left: 8px;
+}
+
+::v-deep .el-upload__tip {
+  font-size: 12px;
+  color: #909399;
+  margin-top: 8px;
+}
+
+::v-deep .el-table .cell {
+  padding: 8px 12px;
+}
+
+::v-deep .el-button--mini {
+  padding: 5px 10px;
+  font-size: 12px;
+}
+</style>

--
Gitblit v1.9.3