<!-- 质量监督记录列表 --> <script name="QualityRecord" lang="ts" setup> import { ElLoading, ElMessage, ElMessageBox } from 'element-plus' import filePreview from './components/filePreviewSingle.vue' import { getDictByCode } from '@/api/system/dict' import type { TableColumn } from '@/components/NormalTable/table_interface' import { deleteQualityRecord, exportQualityRecord, exportQualityRecordZip, getQualityRecordList, getSearchDept } from '@/api/quality/supervise/record' import { getUserList } from '@/api/system/user' import type { userType } from '@/views/system/user/user-interface' import pdfFileItem from '@/views/quality/supervise/record/components/pdfFileItem.vue' import { exportFile } from '@/utils/exportUtils' import { getQualityReportFile } from '@/api/quality/supervise/report' import { getQualityNoReportFile } from '@/api/quality/supervise/analysis' import useUserStore from '@/store/modules/user' import { uniqueMultiArray } from '@/utils/Array' const labelList = ref<{ id: string; value: string; name: string }[]>()// 实验室代码 const userList = ref<userType[]>([]) // 可使用人列表 const deptList = ref<{ deptName: string; deptId: string }[]>([]) // 部门列表 const deptAllList = ref<{ deptName: string; deptId: string }[]>([]) // 部门列表 const userStore = useUserStore() const active = ref<string>('全部') // 查询条件 const listQuery = ref({ bizLabCode: '', // 实验室代码 creator: '', // 创建者 deptId: '', // 被监督实验室 supervisionTimeStart: '', supervisionTimeEnd: '', isNonConformance: '0', status: active.value === '0' ? '1' : '0', // 状态(0,草稿 1公开) offset: 1, limit: 20, }) // 开始结束时间 const datetimerange = ref() watch(() => datetimerange.value, (newVal) => { listQuery.value.supervisionTimeStart = '' listQuery.value.supervisionTimeEnd = '' if (Array.isArray(newVal)) { if (newVal.length) { listQuery.value.supervisionTimeStart = `${newVal[0]} 00:00:00` listQuery.value.supervisionTimeEnd = `${newVal[1]} 23:59:59` } } }) // 列表数据 const tableList = ref([]) const total = ref(0) const loadingTable = ref(true) const checkoutList = ref<string[]>([])// 选中的内容 // 列 const columns = ref<TableColumn[]>([ { text: '文件编号', value: 'fileCode', align: 'center' }, { text: '文件名称', value: 'fileName', align: 'center' }, { text: '质量监督员', value: 'createName', align: 'center' }, { text: '实验室', value: 'bizLabCodeName', align: 'center' }, { text: '部门', value: 'deptName', align: 'center' }, ]) // 数据查询 function fetchData(isNowPage = false) { loadingTable.value = true if (!isNowPage) { // 是否显示当前页,否则跳转第一页 listQuery.value.offset = 1 } getQualityRecordList(listQuery.value).then((response) => { tableList.value = response.data.rows total.value = parseInt(response.data.total) loadingTable.value = false }).catch(() => { loadingTable.value = false }) } // 搜索 const searchList = () => { if (active.value === '1') { listQuery.value.creator = userStore.id } fetchData(true) } // 重置查询条件 const clearList = () => { datetimerange.value = [] listQuery.value = { bizLabCode: '', // 实验室代码 creator: '', // 创建者 deptId: '', // 被监督实验室 supervisionTimeStart: '', supervisionTimeEnd: '', isNonConformance: '0', status: active.value === '0' ? '1' : '0', // 状态(0,草稿 1公开) offset: 1, limit: 20, } searchList() } // 多选发生改变时 function handleSelectionChange(e: any) { checkoutList.value = e.map((item: { id: string }) => item.id) } // 页数发生变化后的操作,可能是页码变化,可能是每页容量变化,此函数必写 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 buttonBoxActive = 'QualityRecord' const menu = ref<any[]>([]) // 查询字典 const getDict = async () => { // loadingTable.value = true // 审批状态 const res = await getDictByCode('approvalStatus') // 制作右上角的菜单 const tempMenu = ['全部', '草稿箱'] tempMenu.forEach((item) => { const tempFindData = res.data.find((e: { name: string; value: string }) => e.name === item) if (tempFindData) { menu.value.push({ name: tempFindData.name, id: `${tempFindData.value}`, }) // active.value = tempFindData } }) // 获取实验室代码字典 getDictByCode('bizLabCode').then((res) => { labelList.value = res.data }) // getUserList({ offset: 1, limit: 99999 }).then((res) => { // userList.value = res.data.rows // }) getQualityRecordList({ offset: 1, limit: 99999, status: '1' }).then((res) => { const data = res.data.rows.map((item: any) => ({ name: item.createName, id: item.creator })) userList.value = uniqueMultiArray(data, 'name') }) getSearchDept({ labCode: '' }).then((res) => { deptList.value = res.data deptAllList.value = res.data }) } watch(() => listQuery.value.bizLabCode, (newVal) => { if (newVal) { listQuery.value.deptId = '' getSearchDept({ labCode: newVal }).then((res) => { deptList.value = res.data }) } else { deptList.value = deptAllList.value } }, { deep: true, }) const changeCurrentButton = (val: string) => { active.value = val window.sessionStorage.setItem(buttonBoxActive, val) clearList() // 刷新 if (val === '0') { listQuery.value.status = '1' } else { listQuery.value.status = '0' } // searchList() } // 新建 const $router = useRouter() const handler = (type: string, row: any) => { $router.push({ path: `/superviserecord/${type}`, query: { status: active.value, statusName: menu.value.filter((item: { name: string; id: string }) => item.id === active.value)[0].name, id: row.id, }, }) } // 删除 const deleteRow = (row: any) => { ElMessageBox.confirm( '确定要删除吗?', '确认操作', { confirmButtonText: '确定', cancelButtonText: '取消', type: 'warning', }, ).then((res) => { deleteQualityRecord({ id: row.id }).then((res) => { ElMessage.success('操作成功') fetchData(true) }) }) } // 导出 const exportList = () => { if (!tableList.value.length) { ElMessage.warning('暂无导出数据') return } const params = { ...listQuery.value, ids: checkoutList.value, } const loading = ElLoading.service({ lock: true, text: '下载中请稍后', background: 'rgba(255, 255, 255, 0.8)', }) exportQualityRecordZip(params).then((res) => { const blob = new Blob([res.data]) loading.close() exportFile(blob, '证书监督记录.zip') }).catch(() => { loading.close() }) } // 点击质量监督报告的详情 const getQualityReportFileItem = (id: string, fun: any) => { getQualityReportFile({ id, pdf: true }).then((res) => { fun(res.data) }).catch(() => { fun() ElMessage.error('文件获取失败') }) } // 点击不符合要求情况分析报告的详情 // const getQualityNoReportFileItem = (id: string, fun: any) => { // getQualityNoReportFile({ id, pdf: true }).then((res) => { // fun(res.data) // }).catch(() => { // fun() // ElMessage.error('文件获取失败') // }) // } const routePage = (row: any, title: string) => { let path = '' if (title === '不符合要求情况分析报告') { path = `/superviseanalysis/detail/${row.id}` } else if (title === '纠正') { path = `/correcthandle/detail/${row.id}` } else if (title === '预防') { path = `/preventhandle/detail/${row.id}` } $router.push({ path, query: { approvalStatusName: '全部', processId: row.processId, // 流程实例id taskId: row.taskId, // 任务id id: row.id, row: JSON.stringify({ ...row, approvalStatus: '1', approvalStatusName: '全部' }), }, }) } onMounted(async () => { await getDict() if (window.sessionStorage.getItem(buttonBoxActive)) { active.value = window.sessionStorage.getItem(buttonBoxActive)! } else { active.value = menu.value.find(item => item.name === '全部')!.id as string // 全部 } }) const { proxy } = getCurrentInstance() as any </script> <template> <app-container> <!-- 右上角按钮集合 --> <button-box :active="active" :menu="menu" @change-current-button="changeCurrentButton" /> <search-area :need-clear="true" @search="searchList" @clear="clearList"> <search-item> <el-select v-model="listQuery.bizLabCode" placeholder="实验室" class="short-input" filterable clearable > <el-option v-for="item in labelList" :key="item.id" :label="item.name" :value="item.value" /> </el-select> </search-item> <search-item> <el-select v-model="listQuery.deptId" placeholder="部门" class="short-input" filterable clearable > <el-option v-for="item in deptList" :key="item.deptId" :label="item.deptName" :value="item.deptId" /> </el-select> </search-item> <search-item v-if="active !== '1'"> <el-select v-model="listQuery.creator" filterable clearable placeholder="质量监督员" style="width: 100%;"> <el-option v-for="(item) in userList" :key="item.id" :label="item.name" :value="item.id"> <span style="float: left;">{{ item.name }}</span> <span style="float: right; color: #8492a6; font-size: 13px;">{{ item.deptName }}</span> </el-option> </el-select> </search-item> <search-item> <el-date-picker v-model="datetimerange" type="daterange" value-format="YYYY-MM-DD" format="YYYY-MM-DD" range-separator="至" start-placeholder="监督开始时间" end-placeholder="监督结束时间" clearable /> </search-item> <search-item style="margin-left: 15px;"> <el-checkbox v-model="listQuery.isNonConformance" true-label="1" false-label="0"> 有不符合要求情况 </el-checkbox> </search-item> </search-area> <table-container> <template v-if="active === '0'" #btns-right> <icon-button icon="icon-add" title="新建" type="primary" @click="handler('create', {})" /> <icon-button icon="icon-export" title="导出" type="primary" @click="exportList" /> </template> <normal-table :data="tableList" :total="total" :columns="columns" :query="listQuery" :list-loading="loadingTable" is-showmulti-select @change="changePage" @multi-select="handleSelectionChange" > <template #preColumns> <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 #columns> <el-table-column v-if="active === '0'" label="质量监督报告" align="center" width="250" > <template #default="{ row }"> <div class="container"> <div v-for="(item, index) in row.rep || []" :key="item.id" :class="`${index === 0 ? '' : 'item'}`"> <!-- <file-preview :minio-file-name="item.fileName" :minio-file-path="item.filePath || ''" /> --> <pdf-file-item :item="item" @get-file="getQualityReportFileItem" /> </div> </div> </template> </el-table-column> <el-table-column v-if="active === '0'" label="不符合要求情况分析报告" align="center" width="250" > <template #default="{ row }"> <div class="container"> <div v-for="(item, index) in row.nonConformanceRep || []" :key="item.id" :class="`${index === 0 ? '' : 'item'}`"> <!-- <file-preview :minio-file-name="item.fileName" :minio-file-path="item.filePath || ''" /> --> <!-- <pdf-file-item :item="item" @get-file="getQualityNoReportFileItem" /> --> <!-- <file-preview :url="`/superviseanalysis/detail/${item.id}`" :minio-file-name="`${item.fileName}-${item.fileCode}`" /> --> <el-link style="margin-right: 10px;color: #3d7eff;" @click="routePage(item, '不符合要求情况分析报告')" > {{ `${item.fileName}-${item.fileCode}` }} </el-link> </div> </div> </template> </el-table-column> <el-table-column label="不符合标准" align="center" > <template #default="{ row }"> {{ row.standard }} </template> </el-table-column> <el-table-column v-if="active === '0'" label="处理措施" align="center" > <template #default="{ row }"> <div class="container"> <div v-for="(item, index) in row.correctiveDTO?.correctiveRecords || []" :key="item.id" :class="`${index === 0 ? '' : 'item'}`"> <!-- <file-preview :minio-file-name="item.fileCode" :minio-file-path="item.filePath || ''" /> --> <el-link style="margin-right: 10px;color: #3d7eff;" @click="routePage(item, '纠正')" > {{ `${item.fileName}-${item.fileCode}` }} </el-link> </div> <div v-for="(item, index) in row.correctiveDTO?.preventRecords || []" :key="item.id" :class="`${index === 0 ? '' : 'item'}`"> <!-- <file-preview :minio-file-name="item.fileCode" :minio-file-path="item.filePath || ''" /> --> <el-link style="margin-right: 10px;color: #3d7eff;" @click="routePage(item, '预防')" > {{ `${item.fileName}-${item.fileCode}` }} </el-link> </div> </div> </template> </el-table-column> <el-table-column label="监督时间" align="center" width="180" > <template #default="{ row }"> {{ row.supervisionTime }} </template> </el-table-column> <el-table-column label="操作" align="center" fixed="right" > <template #default="{ row }"> <el-button v-if="active !== '1'" size="small" type="primary" link @click="handler('detail', row)" > 详情 </el-button> <el-button v-if="proxy.hasPerm('/quality/supervise/record/update')" size="small" type="primary" link :disabled="row.creator !== userStore.id" @click="handler('update', row)" > 编辑 </el-button> <el-button v-if="active === '1' && proxy.hasPerm('/quality/supervise/record/delete')" size="small" type="danger" link @click="deleteRow(row)" > 删除 </el-button> </template> </el-table-column> </template> </normal-table> </table-container> </app-container> </template> <style lang="scss" scope> .container { // display: flex; width: 100%; .item { float: left; border-top: 1px solid #ebeef5; text-align: center; width: 100%; } } </style>