| | |
| | | <template> |
| | | <div class="organ-utilization-detail"> |
| | | <case-basic-info :case-id="caseId" :show-attachment="true" /> |
| | | <el-form :model="form" ref="form" :rules="rules" label-width="120px"> |
| | | <case-basic-info :case-id="caseId" :show-attachment="true":column="3" /> |
| | | <el-form :model="form" ref="form" :rules="rules" label-width="120px" class="paper-form"> |
| | | <!-- 基本信息 --> |
| | | <el-card class="detail-card"> |
| | | <el-card class="detail-card paper-card"> |
| | | <div slot="header" class="clearfix"> |
| | | <span class="detail-title">器官利用基本信息</span> |
| | | </div> |
| | | |
| | | <el-row :gutter="20"> |
| | | <el-col :span="6"> |
| | | <el-form-item label="负责人" prop="responsibleusername"> |
| | | <div class="form-row"> |
| | | <el-form-item label="负责人" prop="responsibleusername" class="col-1-3"> |
| | | <el-input |
| | | v-model="form.responsibleusername" |
| | | placeholder="请输入负责人姓名" |
| | | /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="6"> |
| | | <el-form-item label="协调员一" prop="coordinatedusernameo"> |
| | | <el-form-item label="协调员一" prop="coordinatedusernameo" class="col-1-3"> |
| | | <el-input |
| | | v-model="form.coordinatedusernameo" |
| | | placeholder="请输入协调员一姓名" |
| | | /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="6"> |
| | | <el-form-item label="协调员二" prop="coordinatedusernamet"> |
| | | <el-form-item label="协调员二" prop="coordinatedusernamet" class="col-1-3"> |
| | | <el-input |
| | | v-model="form.coordinatedusernamet" |
| | | placeholder="请输入协调员二姓名" |
| | | /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="6"> |
| | | <el-form-item label="完成时间" prop="completetime"> |
| | | <el-form-item label="完成时间" prop="completetime" class="col-1-3"> |
| | | <el-date-picker |
| | | v-model="form.completetime" |
| | | type="datetime" |
| | |
| | | style="width: 100%" |
| | | /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | </div> |
| | | |
| | | <!-- <el-row :gutter="20"> |
| | | <el-col :span="12"> |
| | |
| | | </el-col> |
| | | </el-row> --> |
| | | </el-card> |
| | | <el-card class="detail-card"> |
| | | <el-card class="detail-card paper-card"> |
| | | <div slot="header" class="clearfix"> |
| | | <span class="detail-title">遗体捐献信息</span> |
| | | </div> |
| | | <el-row :gutter="20"> |
| | | <el-col :span="6"> |
| | | <el-form-item align="left" label="遗体接收" prop="isbodydonation"> |
| | | <div class="form-row"> |
| | | <el-form-item align="left" label="遗体接收" prop="isbodydonation" class="col-1-3"> |
| | | <el-radio-group v-model="form.isbodydonation"> |
| | | <el-radio |
| | | v-for="dict in dict.type.sys_0_1 || []" |
| | |
| | | > |
| | | </el-radio-group> |
| | | </el-form-item> |
| | | </el-col> |
| | | |
| | | <el-col :span="8"> |
| | | <el-form-item align="left" label="接收家属" prop="relationname"> |
| | | <el-form-item align="left" label="接收家属" prop="relationname" class="col-1-3"> |
| | | <el-input |
| | | v-model="form.relationname" |
| | | placeholder="请输入接收家属" |
| | | /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="6"> |
| | | <el-form-item label="与捐献者关系" prop="signfamilyrelations"> |
| | | <el-form-item label="与捐献者关系" prop="signfamilyrelations" class="col-1-3"> |
| | | <el-select |
| | | v-model="form.signfamilyrelations" |
| | | placeholder="请选择与捐献者关系" |
| | |
| | | ></el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | </div> |
| | | </el-card> |
| | | </el-form> |
| | | <!-- 器官利用记录部分 - 整合受者详情 --> |
| | |
| | | <div class="recipient-header"> |
| | | <span class="recipient-title">受者详细信息</span> |
| | | <el-tag |
| | | v-if="scope.row.transplantstate === '1'" |
| | | v-if="scope.row.transplantstate == '1'" |
| | | type="success" |
| | | size="small" |
| | | > |
| | | 已移植 |
| | | </el-tag> |
| | | <el-tag |
| | | v-else-if="scope.row.transplantstate === '0'" |
| | | v-else-if="scope.row.transplantstate == '0'" |
| | | type="warning" |
| | | size="small" |
| | | > |
| | |
| | | <!-- 移植信息部分 --> |
| | | <div |
| | | class="form-section" |
| | | v-if="scope.row.transplantstate === '1'" |
| | | v-if="scope.row.transplantstate == '1'" |
| | | > |
| | | <h4 class="section-title">移植信息</h4> |
| | | <el-row :gutter="20"> |
| | |
| | | <!-- 未移植原因 --> |
| | | <div |
| | | class="form-section" |
| | | v-if="scope.row.transplantstate === '0'" |
| | | v-if="scope.row.transplantstate == '0'" |
| | | > |
| | | <h4 class="section-title">未移植信息</h4> |
| | | <el-row :gutter="20"> |
| | |
| | | <span class="detail-title">相关附件</span> |
| | | </div> |
| | | |
| | | <!-- 上传区域(无分类选择,由Tab控制) --> |
| | | <div class="upload-wrapper"> |
| | | <UploadAttachment |
| | | ref="uploadAttachment" |
| | | :file-list="attachmentFileList" |
| | | :limit="attachmentLimit" |
| | | :accept="attachmentAccept" |
| | | :multiple="true" |
| | | @change="handleAttachmentChange" |
| | | @upload-success="handleUploadSuccess" |
| | | @upload-error="handleUploadError" |
| | | @remove="handleAttachmentRemove" |
| | | /> |
| | | <div style="font-size:12px; color:#909399; margin-top:4px;"> |
| | | 当前上传分类:<el-tag size="small" type="info">{{ |
| | | activeTab === "未分类" ? "未分类" : activeTab |
| | | }}</el-tag> |
| | | (切换 Tab 可改变上传分类) |
| | | </div> |
| | | </div> |
| | | |
| | | <!-- 附件列表 - 分类Tab展示,支持修改分类 --> |
| | | <div class="attachment-list" v-if="attachments && attachments.length > 0"> |
| | | <el-tabs v-model="activeTab" type="border-card"> |
| | | <el-tab-pane |
| | | v-for="category in categories" |
| | |
| | | :label="category + '(' + getCategoryCount(category) + ')'" |
| | | :name="category" |
| | | > |
| | | <div style="margin-bottom: 10px; text-align: right;"> |
| | | <el-button |
| | | size="mini" |
| | | type="primary" |
| | | icon="el-icon-plus" |
| | | @click="openUploadDialog(category)" |
| | | > |
| | | 添加附件 |
| | | </el-button> |
| | | </div> |
| | | <el-table |
| | | :data="getCategoryFiles(category)" |
| | | style="width: 100%" |
| | |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | <div |
| | | v-if="getCategoryFiles(category).length == 0" |
| | | style="text-align:center; padding:20px; color:#909399;" |
| | | > |
| | | 暂无附件 |
| | | </div> |
| | | </el-tab-pane> |
| | | </el-tabs> |
| | | </div> |
| | | |
| | | <!-- 无附件时显示 --> |
| | | <div v-else style="text-align:center; padding:20px; color:#909399;"> |
| | | 暂无附件,请上传 |
| | | </div> |
| | | </el-card> |
| | | <div style="text-align: center; margin: 30px 0;"> |
| | | <el-button type="primary" @click="handleSave" :loading="saveLoading"> |
| | |
| | | 完成利用 |
| | | </el-button> |
| | | </div> |
| | | <!-- 上传对话框 --> |
| | | <el-dialog |
| | | :title="`上传${currentUploadCategory}附件`" |
| | | :visible.sync="uploadDialogVisible" |
| | | width="480px" |
| | | :close-on-click-modal="false" |
| | | > |
| | | <el-upload |
| | | ref="uploadRef" |
| | | class="upload-demo" |
| | | drag |
| | | :action="uploadAction" |
| | | :headers="headers" |
| | | multiple |
| | | :file-list="tempFileList" |
| | | :before-upload="beforeUpload" |
| | | :on-change="handleFileChange" |
| | | :on-remove="handleTempRemove" |
| | | :on-success="handleUploadSuccess" |
| | | :auto-upload="false" |
| | | > |
| | | <i class="el-icon-upload"></i> |
| | | <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div> |
| | | <div class="el-upload__tip" slot="tip"> |
| | | 支持上传pdf、jpg、png、doc、docx格式文件,单个文件不超过10MB |
| | | </div> |
| | | </el-upload> |
| | | |
| | | <span slot="footer" class="dialog-footer"> |
| | | <el-button @click="uploadDialogVisible = false">取消</el-button> |
| | | <el-button |
| | | type="primary" |
| | | @click="submitUpload" |
| | | :loading="uploadLoading" |
| | | :disabled="tempFileList.length == 0" |
| | | > |
| | | 确认上传 |
| | | </el-button> |
| | | </span> |
| | | </el-dialog> |
| | | |
| | | <!-- 文件预览对话框 --> |
| | | <FilePreviewDialog |
| | | :visible="filePreviewVisible" |
| | |
| | | completionadd, |
| | | completionedit |
| | | } from "@/api/businessApi"; |
| | | import UploadAttachment from "@/components/UploadAttachment"; // 新增导入 |
| | | import FilePreviewDialog from "@/components/FilePreviewDialog"; // 新增导入 |
| | | import FilePreviewDialog from "@/components/FilePreviewDialog"; |
| | | import CaseBasicInfo from "@/components/CaseBasicInfo"; |
| | | import dayjs from "dayjs"; // 新增导入,用于时间处理 |
| | | import { getToken } from "@/utils/auth"; |
| | | import dayjs from "dayjs"; |
| | | |
| | | export default { |
| | | name: "OrganUtilizationDetail", |
| | | components: { |
| | | UploadAttachment, |
| | | FilePreviewDialog, |
| | | CaseBasicInfo |
| | | }, |
| | |
| | | editDialogVisible: false, |
| | | currentRecord: {}, |
| | | currentEditIndex: -1, |
| | | // 附件相关配置 - 新增 |
| | | attachmentFileList: [], |
| | | attachmentLimit: 10, |
| | | attachmentAccept: |
| | | ".pdf,.jpg,.jpeg,.png,.doc,.docx,.xls,.xlsx,.ppt,.pptx,.txt", |
| | | // 上传相关 |
| | | uploadAction: process.env.VUE_APP_BASE_API + "/common/upload", |
| | | headers: { |
| | | Authorization: "Bearer " + getToken() |
| | | }, |
| | | uploadDialogVisible: false, |
| | | uploadLoading: false, |
| | | tempFileList: [], |
| | | currentUploadCategory: "", |
| | | |
| | | // 文件预览相关 - 新增 |
| | | // 文件预览相关 |
| | | filePreviewVisible: false, |
| | | currentPreviewFile: null, |
| | | currentFollowup: {}, |
| | |
| | | }, |
| | | categories() { |
| | | // 始终返回所有预设分类 + 未分类,即使没有数据也显示 |
| | | const allCategories = ['原表拍照', '接受确认书', '弃用说明', '捐献证书照片', '未分类']; |
| | | const allCategories = [ |
| | | "原表拍照", |
| | | "接受确认书", |
| | | "弃用说明", |
| | | "捐献证书照片", |
| | | "未分类" |
| | | ]; |
| | | return allCategories; |
| | | }, |
| | | // 已移植数量 |
| | | transplantedCount() { |
| | | if (!this.utilizationData.serviceDonatecomporganList) return 0; |
| | | return this.utilizationData.serviceDonatecomporganList.filter( |
| | | record => record.transplantstate === "1" |
| | | record => record.transplantstate == "1" |
| | | ).length; |
| | | }, |
| | | // 唯一医院数量 |
| | |
| | | created() { |
| | | this.initData(); |
| | | }, |
| | | watch: { |
| | | // 监听附件数据变化 - 新增 |
| | | attachments: { |
| | | handler(newAttachments) { |
| | | this.attachmentFileList = newAttachments.map(item => ({ |
| | | uid: item.id || Math.random(), |
| | | name: item.fileName, |
| | | fileSize: item.fileSize, |
| | | url: item.path || item.fileUrl, |
| | | uploadTime: item.uploadTime, |
| | | status: "success" |
| | | })); |
| | | }, |
| | | deep: true |
| | | } |
| | | }, |
| | | methods: { |
| | | // 初始化数据 |
| | | initData() { |
| | |
| | | }); |
| | | |
| | | targetNos.forEach(no => { |
| | | const existing = records.find(r => r.organno === no); |
| | | const existing = records.find(r => r.organno == no); |
| | | if (existing) { |
| | | if (existing.delFlag === 1) existing.delFlag = 0; |
| | | if (existing.delFlag == 1) existing.delFlag = 0; |
| | | } else { |
| | | // 使用创建方法,自动包含 delFlag:0 |
| | | this.createOrganRecord(no); |
| | |
| | | this.loading = true; |
| | | try { |
| | | const response = await completionList({ infoid: this.caseId }); |
| | | if ( |
| | | response.code === 200 && |
| | | response.data && |
| | | response.data.length > 0 |
| | | ) { |
| | | if (response.code == 200 && response.data && response.data.length > 0) { |
| | | const data = response.data[0]; |
| | | if (!data.completeState || data.completeState == 1) { |
| | | data.completeState = "2"; |
| | |
| | | ? data.serviceDonatecomporganList.map(record => ({ |
| | | ...record, |
| | | transplanttime: record.transplanttime || "", |
| | | transplantstate: record.transplantstate |
| | | transplantstate: |
| | | record.transplantstate != null |
| | | ? record.transplantstate.toString() |
| | | : "1" |
| | | })) |
| | |
| | | fileType: item.fileType || "" // 默认空字符串表示未分类 |
| | | })); |
| | | this.form.attachments = this.attachments; |
| | | // 同步 attachmentFileList |
| | | this.attachmentFileList = this.attachments.map(item => ({ |
| | | uid: item.id || Math.random(), |
| | | name: item.fileName, |
| | | url: item.path || item.fileUrl, |
| | | fileSize: item.fileSize, |
| | | uploadTime: item.uploadTime, |
| | | status: "success", |
| | | raw: item |
| | | })); |
| | | } else { |
| | | this.attachments = []; |
| | | this.attachmentFileList = []; |
| | | } |
| | | |
| | | this.$message.success("数据加载成功"); |
| | |
| | | |
| | | // 3. 新增或恢复记录(无需弹窗) |
| | | targetOrganNos.forEach(no => { |
| | | const existing = records.find(r => r.organno === no); |
| | | const existing = records.find(r => r.organno == no); |
| | | if (existing) { |
| | | if (existing.delFlag === 1) { |
| | | if (existing.delFlag == 1) { |
| | | existing.delFlag = 0; // 恢复显示 |
| | | } |
| | | } else { |
| | |
| | | const organName = this.getOrganLabel(organValue); |
| | | |
| | | this.utilizationData.serviceDonatecomporganList.push({ |
| | | infoid: this.caseId, |
| | | organname: organName, |
| | | organno: organValue, |
| | | caseNo: "", |
| | |
| | | |
| | | // 根据字典value获取label |
| | | getOrganLabel(organValue) { |
| | | const dictItem = this.organDict.find(item => item.value === organValue); |
| | | const dictItem = this.organDict.find(item => item.value == organValue); |
| | | return dictItem ? dictItem.label : organValue; |
| | | }, |
| | | |
| | | // 移植状态变化处理 |
| | | handleTransplantStatusChange(row, status) { |
| | | if (status === "0") { |
| | | if (status == "0") { |
| | | // 如果状态为未移植,清除相关字段 |
| | | // row.transplanttime = ""; |
| | | // row.transplantdoct = ""; |
| | | // row.hospitalno = ""; |
| | | // row.hospitalname = ""; |
| | | } else if (status === "1") { |
| | | } else if (status == "1") { |
| | | // 如果状态为已移植,自动设置移植时间为当前时间 |
| | | if (!row.transplanttime) { |
| | | row.transplanttime = new Date().toISOString().split("T")[0]; |
| | |
| | | // 器官行样式 |
| | | getOrganRowClassName({ row }) { |
| | | if ( |
| | | row.transplantstate === "1" && |
| | | row.transplantstate == "1" && |
| | | (!row.hospitalno || !row.name || !row.transplanttime) |
| | | ) { |
| | | return "warning-row"; |
| | | } |
| | | if (row.transplantstate === "0" && !row.abandonreason) { |
| | | if (row.transplantstate == "0" && !row.abandonreason) { |
| | | return "warning-row"; |
| | | } |
| | | return ""; |
| | |
| | | const apiMethod = this.form.id ? completionedit : completionadd; |
| | | const response = await apiMethod(saveData); |
| | | |
| | | if (response.code === 200) { |
| | | if (response.code == 200) { |
| | | this.$message.success("保存成功"); |
| | | if (!this.form.id && response.data && response.data.id) { |
| | | this.form.id = response.data.id; |
| | |
| | | async handleSaveUtilization() { |
| | | if ( |
| | | !this.utilizationData.serviceDonatecomporganList || |
| | | this.utilizationData.serviceDonatecomporganList.length === 0 |
| | | this.utilizationData.serviceDonatecomporganList.length == 0 |
| | | ) { |
| | | this.$message.warning("请先添加利用记录"); |
| | | return; |
| | |
| | | |
| | | const response = await completionedit(saveData); |
| | | |
| | | if (response.code === 200) { |
| | | if (response.code == 200) { |
| | | this.$message.success("利用记录保存成功"); |
| | | } else { |
| | | this.$message.error( |
| | |
| | | // 检查利用记录是否完整 |
| | | const incompleteRecords = this.utilizationData.serviceDonatecomporganList.filter( |
| | | record => { |
| | | if (record.transplantstate === "1") { |
| | | if (record.transplantstate == "1") { |
| | | return !record.hospitalno || !record.name || !record.transplanttime; |
| | | } else if (record.transplantstate === "0") { |
| | | } else if (record.transplantstate == "0") { |
| | | return !record.abandonreason; |
| | | } |
| | | return false; |
| | |
| | | |
| | | const response = await completionedit(saveData); |
| | | |
| | | if (response.code === 200) { |
| | | if (response.code == 200) { |
| | | this.$message.success("器官利用已完成"); |
| | | } else { |
| | | this.$message.error( |
| | |
| | | |
| | | // 获取器官名称 |
| | | const organRecord = this.utilizationData.serviceDonatecomporganList.find( |
| | | item => item.organno === this.currentFollowup.organNo |
| | | item => item.organno == this.currentFollowup.organNo |
| | | ); |
| | | const organName = organRecord ? organRecord.organname : ""; |
| | | |
| | |
| | | if (this.isEditingFollowup) { |
| | | // 更新现有记录 |
| | | const index = this.followupData.records.findIndex( |
| | | item => item.id === this.currentFollowup.id |
| | | item => item.id == this.currentFollowup.id |
| | | ); |
| | | if (index !== -1) { |
| | | this.followupData.records[index] = { |
| | |
| | | this.saveLoading = false; |
| | | }, 1000); |
| | | }, |
| | | /** 附件变化处理 */ |
| | | handleAttachmentChange(fileList) { |
| | | this.attachmentFileList = fileList; |
| | | // ==== 附件相关方法 ==== |
| | | // 打开上传对话框 |
| | | openUploadDialog(category) { |
| | | this.currentUploadCategory = category; |
| | | this.tempFileList = []; |
| | | this.uploadDialogVisible = true; |
| | | this.$nextTick(() => { |
| | | if (this.$refs.uploadRef) { |
| | | this.$refs.uploadRef.clearFiles(); |
| | | } |
| | | }); |
| | | }, |
| | | |
| | | /** 附件移除处理 */ |
| | | handleAttachmentRemove(file) { |
| | | if (file.url) { |
| | | const index = this.attachments.findIndex( |
| | | item => item.path === file.url || item.fileUrl === file.url |
| | | // 上传前校验 |
| | | beforeUpload(file) { |
| | | const allowedTypes = [ |
| | | "application/pdf", |
| | | "image/jpeg", |
| | | "image/png", |
| | | "application/msword", |
| | | "application/vnd.openxmlformats-officedocument.wordprocessingml.document" |
| | | ]; |
| | | const maxSize = 10 * 1024 * 1024; |
| | | const isTypeOk = |
| | | allowedTypes.includes(file.type) || |
| | | file.name.endsWith(".pdf") || |
| | | file.name.endsWith(".jpg") || |
| | | file.name.endsWith(".jpeg") || |
| | | file.name.endsWith(".png") || |
| | | file.name.endsWith(".doc") || |
| | | file.name.endsWith(".docx"); |
| | | if (!isTypeOk) { |
| | | this.$message.error( |
| | | "文件格式不支持,请上传pdf、jpg、png、doc或docx格式文件" |
| | | ); |
| | | if (index > -1) { |
| | | this.attachments.splice(index, 1); |
| | | this.$message.success("附件删除成功"); |
| | | return false; |
| | | } |
| | | if (file.size > maxSize) { |
| | | this.$message.error("文件大小不能超过10MB"); |
| | | return false; |
| | | } |
| | | return true; |
| | | }, |
| | | /** 上传成功处理 */ |
| | | handleUploadSuccess({ file, fileList, response }) { |
| | | if (response.code === 200) { |
| | | // 根据当前激活的 Tab 决定分类(未分类 Tab 对应空字符串) |
| | | const category = this.activeTab === "未分类" ? "" : this.activeTab; |
| | | |
| | | // 文件选择变化 |
| | | handleFileChange(file, fileList) { |
| | | this.tempFileList = fileList; |
| | | }, |
| | | |
| | | // 临时移除 |
| | | handleTempRemove(file, fileList) { |
| | | this.tempFileList = fileList; |
| | | }, |
| | | |
| | | // 上传成功处理 |
| | | handleUploadSuccess(response, file, fileList) { |
| | | if (response.code !== 200) { |
| | | this.$message.error(response.msg || "上传失败"); |
| | | return; |
| | | } |
| | | // 未分类对应空字符串,与展示/保存逻辑一致 |
| | | const category = |
| | | this.currentUploadCategory == "未分类" |
| | | ? "" |
| | | : this.currentUploadCategory; |
| | | const attachmentObj = { |
| | | fileName: file.name, |
| | | path: response.fileUrl || file.url, |
| | | fileUrl: response.fileUrl || file.url, |
| | | fileType: category, // 关键:记录分类 |
| | | path: response.fileUrl || response.url || response.data || file.url, |
| | | fileUrl: response.fileUrl || response.url || response.data || file.url, |
| | | fileType: category, |
| | | fileSize: file.size, |
| | | uploadTime: dayjs().format("YYYY-MM-DD HH:mm:ss") |
| | | }; |
| | | |
| | | if (!Array.isArray(this.attachments)) { |
| | | this.attachments = []; |
| | | } |
| | | this.attachments.push(attachmentObj); |
| | | this.attachmentFileList = fileList; // 保持同步 |
| | | this.$message.success("文件上传成功"); |
| | | } |
| | | this.uploadLoading = false; |
| | | this.uploadDialogVisible = false; |
| | | this.tempFileList = []; |
| | | }, |
| | | |
| | | // 提交上传 |
| | | submitUpload() { |
| | | if (this.tempFileList.length == 0) { |
| | | this.$message.warning("请先选择要上传的文件"); |
| | | return; |
| | | } |
| | | this.uploadLoading = true; |
| | | this.$refs.uploadRef.submit(); |
| | | }, |
| | | |
| | | // 获取某分类的文件数量 |
| | | getCategoryCount(category) { |
| | | return this.attachments.filter(item => { |
| | | const type = item.fileType || ""; |
| | | if (category === "未分类") { |
| | | if (category == "未分类") { |
| | | return !this.presetCategories.includes(type); |
| | | } |
| | | return type === category; |
| | | return type == category; |
| | | }).length; |
| | | }, |
| | | |
| | |
| | | getCategoryFiles(category) { |
| | | return this.attachments.filter(item => { |
| | | const type = item.fileType || ""; |
| | | if (category === "未分类") { |
| | | if (category == "未分类") { |
| | | return !this.presetCategories.includes(type); |
| | | } |
| | | return type === category; |
| | | return type == category; |
| | | }); |
| | | }, |
| | | |
| | | // 更新附件分类(下拉修改时触发) |
| | | updateAttachmentCategory(row, newVal) { |
| | | const target = this.attachments.find(item => item === row); |
| | | const target = this.attachments.find(item => item == row); |
| | | if (target) { |
| | | target.fileType = newVal; // 可能为空字符串 |
| | | // 同步更新 attachmentFileList |
| | | const fileItem = this.attachmentFileList.find( |
| | | f => f.raw === row || f.url === row.fileUrl |
| | | ); |
| | | if (fileItem) { |
| | | fileItem.raw.fileType = newVal; |
| | | fileItem.fileType = newVal || "未分类"; |
| | | } |
| | | // 如果当前激活的tab没有文件了,自动切换到第一个有文件的tab |
| | | target.fileType = newVal; |
| | | const currentTabHasFiles = |
| | | this.getCategoryFiles(this.activeTab).length > 0; |
| | | if (!currentTabHasFiles) { |
| | |
| | | |
| | | // 按文件对象删除(用于表格中的删除按钮) |
| | | handleRemoveAttachmentByFile(file) { |
| | | const index = this.attachments.findIndex(item => item === file); |
| | | this.$confirm("确定要删除这个附件吗?", "提示", { |
| | | confirmButtonText: "确定", |
| | | cancelButtonText: "取消", |
| | | type: "warning" |
| | | }) |
| | | .then(() => { |
| | | const index = this.attachments.findIndex(item => item == file); |
| | | if (index > -1) { |
| | | this.attachments.splice(index, 1); |
| | | // 同步删除 attachmentFileList |
| | | const fileIndex = this.attachmentFileList.findIndex( |
| | | f => f.raw === file || f.url === file.fileUrl |
| | | ); |
| | | if (fileIndex > -1) { |
| | | this.attachmentFileList.splice(fileIndex, 1); |
| | | } |
| | | this.$message.success("附件删除成功"); |
| | | } |
| | | }, |
| | | /** 上传错误处理 */ |
| | | handleUploadError({ file, fileList, error }) { |
| | | console.error("附件上传失败:", error); |
| | | this.$message.error("文件上传失败,请重试"); |
| | | }) |
| | | .catch(() => {}); |
| | | }, |
| | | |
| | | /** 手动删除附件 */ |
| | | handleRemoveAttachment(index) { |
| | | // 直接调用新的删除方法 |
| | | this.handleRemoveAttachmentByFile(file.raw || file); |
| | | }, |
| | | |
| | | /** 文件预览 */ |
| | | // 文件预览 |
| | | handlePreview(file) { |
| | | this.currentPreviewFile = { |
| | | fileName: file.fileName, |
| | |
| | | }; |
| | | this.filePreviewVisible = true; |
| | | }, |
| | | /** 文件下载 */ |
| | | |
| | | // 文件下载 |
| | | handleDownloadAttachment(file) { |
| | | const fileUrl = file.path || file.fileUrl; |
| | | const fileName = file.fileName; |
| | |
| | | |
| | | /** 格式化文件大小 */ |
| | | formatFileSize(bytes) { |
| | | if (!bytes || bytes === 0) return "0 B"; |
| | | 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)); |
| | |
| | | padding: 10px 15px; |
| | | } |
| | | } |
| | | |
| | | /* ===== 纸质表格网格样式 ===== */ |
| | | .paper-card >>> .el-card__body { |
| | | padding: 16px; |
| | | } |
| | | |
| | | .paper-form { |
| | | border-left: 1px solid #d0d3db; |
| | | background: #fff; |
| | | } |
| | | |
| | | .paper-form >>> .form-row { |
| | | display: flex; |
| | | width: 100%; |
| | | border-top: 1px solid #d0d3db; |
| | | } |
| | | |
| | | .paper-form >>> .el-form-item { |
| | | flex: 0 0 33.3333%; |
| | | display: flex; |
| | | margin: 0; |
| | | background: #fff; |
| | | border-right: 1px solid #d0d3db; |
| | | border-bottom: 1px solid #d0d3db; |
| | | } |
| | | .paper-form >>> .el-form-item::after, |
| | | .paper-form >>> .el-form-item::before { |
| | | display: none; |
| | | } |
| | | |
| | | .paper-form >>> .col-1-3 { flex: 0 0 33.3333%; } |
| | | .paper-form >>> .col-half { flex: 0 0 50%; } |
| | | .paper-form >>> .col-2-3 { flex: 0 0 66.6666%; } |
| | | .paper-form >>> .col-full { flex: 0 0 100%; } |
| | | |
| | | .paper-form >>> .el-form-item__label { |
| | | flex: 0 0 120px; |
| | | width: 120px !important; |
| | | float: none; |
| | | padding: 0 8px !important; |
| | | background: #ecf5ff; |
| | | border-right: 1px solid #d0d3db; |
| | | display: flex; |
| | | align-items: center; |
| | | justify-content: center; |
| | | text-align: center; |
| | | font-size: 13px; |
| | | font-weight: 600; |
| | | color: #2c3038; |
| | | line-height: 1.3; |
| | | white-space: normal; |
| | | word-break: break-all; |
| | | } |
| | | .paper-form >>> .el-form-item.is-required:not(.is-no-asterisk) > .el-form-item__label:before { |
| | | color: #f56c6c; |
| | | margin-right: 2px; |
| | | } |
| | | |
| | | .paper-form >>> .el-form-item__content { |
| | | flex: 1; |
| | | margin-left: 0 !important; |
| | | display: flex; |
| | | align-items: center; |
| | | flex-wrap: wrap; |
| | | padding: 6px 10px; |
| | | background: #fff; |
| | | min-height: 42px; |
| | | line-height: 1.4; |
| | | } |
| | | </style> |