<!-- 符合要求情况分析报告弹窗 --> <script lang="ts" setup name="NonConformanceRep"> import { ElMessage } from 'element-plus' import axios from 'axios' import type { TableColumn } from '@/components/NormalTable/table_interface' import { getDictByCode } from '@/api/system/dict' import { SCHEDULE } from '@/utils/scheduleDict' // import { getQualityNoReportList } from '@/api/quality/supervise/analysis' // import { SCHEDULE } from '@/utils/scheduleDict' // import type { userType } from '@/views/system/user/user-interface' // import { getSearchDept } from '@/api/quality/supervise/record' import { getListByUrl } from '@/api/quality/prevent/index' import { ConnectFileUrl } from '@/api/quality/external/external' import filePreview from '@/views/quality/supervise/record/components/filePreviewMultiple.vue' const emits = defineEmits(['add']) const dialogFormVisible = ref(false) const fileTypesList = ref<{ id: string; value: string; name: string }[]>()// 输入来源 // 查询条件 const listQuery = ref({ sampleNo: '', fileTypes: '', offset: 1, limit: 5, }) // 列表数据 const tableList = ref([]) const total = ref(0) const loadingTable = ref(false) // 列 const columnsAll = ref<TableColumn[]>([ { text: '文件编号', value: 'fileCode', align: 'center' }, { text: '文件名称', value: 'fileName', align: 'center' }, { text: '实验室', value: 'bizLabCodeName', align: 'center' }, { text: '部门', value: 'deptName', align: 'center' }, ]) const columns = ref(columnsAll.value) const columnsCertificate = ref<TableColumn[]>([ { text: '证书名称', value: 'certificateName', align: 'center' }, { text: '证书编号', value: 'certificateNo', align: 'center' }, { text: '创建时间', value: 'createTime', align: 'center' }, ]) // 获取url const url = ref<any[]>([]) const getURl = () => { ConnectFileUrl({}).then((res) => { url.value = res.data.filter((item: any) => item.name !== '其他') url.value = [ ...url.value, { code: '8', formId: 'zlhdbfhyqqkfxbg', name: '体系文件', tips: '/resource/file/system/listPage', }, { code: '9', formId: 'zyglwjfftzd', name: '文件发放通知单', tips: '/resource/file/grantNotice/approval/listPage', }, { code: '10', formId: 'zyglwjggsq', name: '文件更改申请单', tips: '/resource/file/change/approval/listPage', }, { code: '11', formId: 'zyglwjshcddjb', name: '文件作废登记表', tips: '/resource/file/recallArchive/approval/listPage', }, { code: '12', formId: 'zyglrjxdsq', name: '软件修订申请', tips: '/resource/software/revisionApply/approval/listPage', }, ] }) } getURl() // 处理入参 const solveSendParams = (code: string) => { let params: any switch (code) { case '8': // 体系文件 params = { fileNo: '', fileName: '', fileDistributeNo: '', fileType: '', history: '0', labCode: '', groupCode: '', effectiveDateStart: '', effectiveDateEnd: '', promulgateTimeEnd: '', promulgateTimeStart: '', versionNo: '', offset: 1, limit: 20, } break case '9': // 文件发放通知单 params = { approvalStatus: '0', beginTime: '', createUserName: '', distributor: '', endTime: '', fileApprovalCodes: '', formId: 'zyglwjfftzd', formName: '', formNo: '', grantFileName: '', grantFileNo: '', groupCode: '', labCode: '', limit: 20, offset: 1, } break case '10': // 文件更改申请单 params = { approvalStatus: '0', beginTime: '', endTime: '', changeReason: '', createUserName: '', fileName: '', fileNo: '', fileType: '', formId: 'zyglwjggsq', formName: '', formNo: '', groupCode: '', labCode: '', offset: 1, limit: 20, } break case '11': // 文件作废登记表 params = { approvalStatus: '0', archiveReason: '', createTimeEnd: '', createTimeStart: '', createUserName: '', fileName: '', fileNo: '', fileType: '', formId: 'zyglwjshcddjb', formNo: '', groupCode: '', labCode: '', offset: 1, limit: 20, } break case '12': // 软件修订申请 params = { applyNo: '', softwareName: '', softwareVersion: '', createDept: '', createUserName: '', createTimeStart: '', createTimeEnd: '', approvalStatus: '0', formId: 'zyglrjxdsq', revisionReason: '', groupCode: '', labCode: '', offset: 1, limit: 20, } break case '14': // 软件修订申请 break default: // 质量里的 params = { fileName: listQuery.value.sampleNo, offset: listQuery.value.offset, limit: listQuery.value.limit, approvalStatus: '0', // formId: SCHEDULE.NONCONFORMITY_ANALYSIS_APPROVAL, formId: url.value.filter((item: any) => item.code === listQuery.value.fileTypes)[0].formId, } break } return params } // 数据查询 function fetchData(isNowPage = false) { loadingTable.value = true if (!isNowPage) { // 是否显示当前页,否则跳转第一页 listQuery.value.offset = 1 } const params = solveSendParams(listQuery.value.fileTypes) let path = '' if (listQuery.value.fileTypes !== '1' && listQuery.value.fileTypes !== '2' && listQuery.value.fileTypes !== '3' && listQuery.value.fileTypes !== '5' && listQuery.value.fileTypes !== '6' && listQuery.value.fileTypes !== '7') { path = url.value.filter((item: any) => item.code === listQuery.value.fileTypes)[0].tips } else { path = window.localStorage.getItem('baseURL')!.substring(0, window.localStorage.getItem('baseURL')!.length - 1) + url.value.filter((item: any) => item.code === listQuery.value.fileTypes)[0].tips if (path.includes('certificate')) { columns.value = columnsCertificate.value } else { columns.value = columnsAll.value } } getListByUrl(params, path).then((response) => { tableList.value = response.data.rows.map((item: any) => { return { ...item, fileCode: item.fileCode || item.fileNo, // 文件编号 bizLabCodeName: item.bizLabCodeName || item.labCodeName, // 实验室 deptName: item.deptName || item.groupCodeName, // 部门 } }) total.value = parseInt(response.data.total) loadingTable.value = false }).catch(() => { loadingTable.value = false }) } // 搜索 const searchList = () => { if (!listQuery.value.fileTypes.length) { ElMessage.warning('请先选择类型') return } fetchData(true) } // 获取字典值 const fetchDict = () => { getDictByCode('auditManagementFileType').then((res) => { fileTypesList.value = res.data }) } fetchDict() // 页数发生变化后的操作,可能是页码变化,可能是每页容量变化,此函数必写 const changePage = (val: { size?: number; page?: number }) => { if (val && val.size) { listQuery.value.limit = val.size } if (val && val.page) { listQuery.value.offset = val.page } fetchData(true) } // 点击保存 const select = ref(-1) watch(() => select.value, () => { console.log(tableList.value) }) const submitForm = () => { // 单选 if (select.value !== -1) { // const data // emits('add', [tableList.value[select.value]]) emits('add', { ...tableList.value[select.value] as any, fileType: listQuery.value.fileTypes, fileTypeName: url.value.filter((item: any) => item.code === listQuery.value.fileTypes)[0].name }) dialogFormVisible.value = false } else { ElMessage.warning('请先选择文件') } } // 取消 const resetForm = () => { dialogFormVisible.value = false } // 初始化 const initDialog = () => { dialogFormVisible.value = true select.value = -1 } defineExpose({ initDialog }) </script> <template> <el-dialog v-model="dialogFormVisible" title="选择文件" width="65%"> <!-- 筛选条件 --> <search-area @search="searchList"> <search-item> <el-select v-model="listQuery.fileTypes" placeholder="文件来源" class="short-input" filterable > <el-option v-for="item in url" :key="item.code" :label="item.name" :value="item.code" /> </el-select> </search-item> <search-item> <el-input v-model="listQuery.sampleNo" placeholder="文件编号" clearable /> </search-item> <!-- <search-item> <el-input v-model="listQuery.fileName" placeholder="文件名称" clearable /> </search-item> --> </search-area> <table-container> <normal-table :data="tableList" :total="total" :query="listQuery" :columns="columns" :list-loading="loadingTable" :is-showmulti-select="false" @change="changePage" > <template #preColumns> <el-table-column label="" width="55" align="center"> <template #default="scope"> <el-radio v-model="select" :label="scope.$index" class="radio" /> </template> </el-table-column> <el-table-column label="序号" width="55" align="center"> <template #default="scope"> {{ (listQuery.offset - 1) * listQuery.limit + scope.$index + 1 }} </template> </el-table-column> </template> <template v-if="columns.length === 3" #columns> <el-table-column label="证书"> <template #default="scope"> <file-preview :minio-file-name="[scope.row.certificateFile]" :minio-file-path="['']" /> </template> </el-table-column> </template> </normal-table> </table-container> <template #footer> <span class="dialog-footer"> <el-button type="primary" @click="submitForm">确认</el-button> <el-button @click="resetForm"> 取消 </el-button> </span> </template> </el-dialog> </template> <style lang="scss" scoped> .radio { :deep(.el-radio__label) { display: none !important; } } </style>