puzhibing
6 天以前 0db8c9b94a9ac655549d5eba5c2a6c92ac386c06
culture/src/views/strainReportLibrary/reportLibraryOneTWO/components/approval/index.vue
@@ -1,7 +1,7 @@
<template>
    <el-dialog :title="dialogTitle" :visible.sync="visible" width="80%" @open="open" po :close-on-click-modal="false"
    <el-dialog :title="dialogTitle" :visible.sync="visible" width="94%" @open="open" :close-on-click-modal="false"
        @close="handleClose">
        <div class="approval-dialog" :style="{ height: obj?.isDetail ? '50vh' : '40vh' }">
        <div class="approval-dialog" :style="{ height: obj?.isDetail ? '68vh' : '60vh' }">
            <!-- 左侧审批内容 -->
            <div class="approval-content">
                <Card class="approval-content-card">
@@ -64,21 +64,19 @@
                                </div>
                            </div>
                            <el-form-item prop="name" style="margin-top: 38px">
                                <el-upload action="#" :file-list="fileList" :http-request="handleUpload"
                                    :before-upload="beforeUpload" :on-preview="handlePreview" :on-remove="handleRemove">
                                    <el-button size="small" type="primary">点击上传</el-button>
                                    <div slot="tip" class="el-upload__tip">支持任意格式文件上传</div>
                                <el-upload action="#" :file-list="fileList" disabled list-type="text" :on-preview="handlePreview">
                                    <span v-if="!fileList.length">暂无附件</span>
                                </el-upload>
                            </el-form-item>
                            <div class="header-title" style="width: 100%;">
                            <!-- <div class="header-title" style="width: 100%;">
                                <div class="header-title-left">
                                    <img src="@/assets/public/headercard.png" />
                                    <div>菌种实验员操作评定</div>
                                </div>
                            </div>
                            </div> -->
                            <div class="table" style="margin-top: 38px">
                            <!-- <div class="table" style="margin-top: 38px">
                                <el-table :data="assessmentTable" border style="width: 100%" :show-summary="true"
                                    :span-method="tableSpanMethod" :summary-method="getTableSummary">
                                    <el-table-column prop="category" label="菌种实验员专业能力考核项" width="180"></el-table-column>
@@ -110,7 +108,7 @@
                                        </template>
                                    </el-table-column>
                                </el-table>
                            </div>
                            </div> -->
@@ -151,7 +149,7 @@
        </div>
        <div slot="footer" class="dialog-footer">
            <el-button @click="handleClose">{{ obj.isDetail ? '关闭' : '取 消' }}</el-button>
            <el-button type="primary" @click="handleApprove" v-if="!obj.isDetail">通过</el-button>
            <el-button type="primary" @click="handleApprove" v-if="!obj.isDetail">审核</el-button>
        </div>
    </el-dialog>
</template>
@@ -160,6 +158,7 @@
import ApprovalProcess from '@/components/approvalProcess'
import AiEditor from '@/components/AiEditor'
import { getDetail } from '../../service';
import { getAllocateIp, getFullUrl, downloadFileByUrl, isImageFile, normalizeFileList } from '@/utils/utils';
export default {
@@ -208,7 +207,7 @@
                {
                    category: '1.该分题的菌种专业知识',
                    selectedScore: 0,
                    criteria: '1.1 能讲生物学基础,掌握各类微生物形态特性、生化特性及鉴定方法。1.2 菌种选育技术,了解掌握自然选育、诱变选育、基因工程育种。',
                    criteria: '1.1 微生物学基础,掌握各类微生物形态特性、生化特性及鉴定方法。1.2 菌种选育技术,了解掌握自然选育、诱变选育、基因工程育种。',
                    desc: '',
                    rule: ''
                },
@@ -246,6 +245,7 @@
            rules: {},
            status: "2",
            remark: "",
          roleType: JSON.parse(sessionStorage.getItem('userInfo')).roleType
        };
    },
    computed: {
@@ -257,11 +257,53 @@
        }
    },
    methods: {
        // 上传前校验
        beforeUpload(file) {
            // 获取文件扩展名
            const fileName = file.name || '';
            const fileExtension = fileName.substring(fileName.lastIndexOf('.') + 1).toLowerCase();
            // 禁止的文件类型
            const forbiddenExtensions = ['ppt', 'pptx', 'pdf', 'caj'];
            if (forbiddenExtensions.includes(fileExtension)) {
                this.$message.error(`不支持上传 ${fileExtension.toUpperCase()} 格式文件`);
                return false;
            }
            // 允许的文件类型
            // Word 格式
            const wordExtensions = ['doc', 'docx'];
            // Excel 格式
            const excelExtensions = ['xls', 'xlsx'];
            // 图片格式
            const imageExtensions = ['jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp', 'svg', 'ico', 'tiff', 'tif', 'heic', 'heif'];
            const allowedExtensions = [...wordExtensions, ...excelExtensions, ...imageExtensions];
            if (!allowedExtensions.includes(fileExtension)) {
                this.$message.error(`不支持上传 ${fileExtension.toUpperCase()} 格式文件,仅支持 Word、Excel 和图片格式`);
                return false;
            }
            return true;
        },
        handlePreview(file) {
            if (file.url) {
                window.open(file.url, '_blank');
            } else {
                this.$message.warning('无可预览地址');
            if (file && file.url) {
                // 判断是否为图片文件
                const isImage = isImageFile(file.url);
                if (isImage) {
                    // 图片文件:使用 window.open 预览
                    if (file.url && file.url.startsWith('http')) {
                        console.log('图片链接', file.url)
                        window.open(getFullUrl(file.url), '_blank');
                    } else {
                        window.open(getFullUrl(file.url), '_blank');
                    }
                } else {
                    // 非图片文件:使用下载方式
                    downloadFileByUrl(file.url, file.name);
                }
            }
        },
        open() {
@@ -278,8 +320,8 @@
                    processData: []
                };
                let arr = data.evaluate.split(',')
                this.fileList = (data.enclosureUrl ? JSON.parse(data.enclosureUrl) : [])
                let arr = (data.evaluate || '').split(',')
                this.fileList = normalizeFileList(data.enclosureUrl)
                this.assessmentTable = this.assessmentTable.map((item, index) => {
                    item.selectedScore = Number(arr[index])
                    return item
@@ -418,7 +460,7 @@
    .approval-flow {
        padding: 40px 20px;
        // width: 405px;
        flex: 2;
        flex: 1;
        background: #ffffff;
        box-shadow: 0px 4px 12px 4px rgba(0, 0, 0, 0.08);
        border-radius: 10px;
@@ -442,7 +484,7 @@
}
.approval-content-card {
    height: calc(100% - 100px) !important;
    height: calc(100% - 18px) !important;
    box-shadow: none !important;
}
@@ -601,4 +643,4 @@
        width: 150px;
    }
}
</style>
</style>