<!-- 符合要求情况分析报告弹窗 --> <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 { ConnectFileUrl, getListByUrl } from '@/api/quality/prevent/index' const emits = defineEmits(['add']) const dialogFormVisible = ref(false) const moduleType = ref('') // 模块类型 prevent预防 correct纠正 const fileTypesList = ref<{ id: string; value: string; name: string }[]>()// 输入来源 // 查询条件 const listQuery = ref({ fileTypes: '', fileCode: '', fileName: '', offset: 1, limit: 5, }) // 列表数据 const tableList = ref([]) const total = ref(0) const loadingTable = ref(false) // 列 const columns = ref<TableColumn[]>([ { text: '文件编号', value: 'fileCode', align: 'center' }, { text: '文件名称', value: 'fileName', align: 'center' }, { text: '实验室', value: 'bizLabCodeName', align: 'center' }, { text: '部门', value: 'deptName', align: 'center' }, ]) // 获取url const url = ref<any[]>([]) const getURl = () => { ConnectFileUrl({}).then((res) => { url.value = res.data }) } getURl() // 数据查询 function fetchData(isNowPage = false) { loadingTable.value = true if (!isNowPage) { // 是否显示当前页,否则跳转第一页 listQuery.value.offset = 1 } const params = { fileName: listQuery.value.fileName, fileCode: listQuery.value.fileCode, 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, } const 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 getListByUrl(params, path).then((response) => { tableList.value = response.data.rows.map((item: any, index: number) => { if (params.formId === 'zlhdbfhyqqkfxbg') { // 不符合要求情况分析报告 console.log('=============', moduleType.value === 'correct'); if (moduleType.value === 'correct') { // 纠正 if (item.correctiveRecords.length && item.correctiveActionFiles && item.correctiveActionFiles.length) { item.radioDisabled = true // 已经选过的不符合报告不能再选 } else { item.radioDisabled = false } } else if (moduleType.value === 'prevent') { // 预防 if (item.preventRecords.length) { item.radioDisabled = true // 已经选过的不符合报告不能再选 } else { item.radioDisabled = false } } } return item }) console.log('0000000000tableList.value', tableList.value) 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('corrective_file_type').then((res) => { fileTypesList.value = res.data if (res.data.length) { listQuery.value.fileTypes = res.data[0].value searchList() } }) } 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) 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 }]) dialogFormVisible.value = false } else { ElMessage.warning('请先选择文件') } } // 取消 const resetForm = () => { dialogFormVisible.value = false } // 初始化 const initDialog = (moduleTypeParam = '') => { moduleType.value = moduleTypeParam dialogFormVisible.value = true select.value = -1 } defineExpose({ initDialog }) watch(() => listQuery.value.fileTypes, (newVal) => { if (newVal) { fetchData(true) } }) </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 fileTypesList" :key="item.id" :label="item.name" :value="item.value" /> </el-select> </search-item> <search-item> <el-input v-model="listQuery.fileCode" 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" :disabled="scope.row.radioDisabled" :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> </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>