<!-- 质量监督报告列表 --> <script name="QualityReport" lang="ts" setup> import { getDictByCode } from '@/api/system/dict' import type { TableColumn } from '@/components/NormalTable/table_interface' import { getQualityReportList } from '@/api/quality/supervise/report' import { getUserList } from '@/api/system/user' import type { userType } from '@/views/system/user/user-interface' import { getSearchDept } from '@/api/quality/supervise/record' const active = ref<string>('全部') const labelList = ref<{ id: string; value: string; name: string }[]>()// 实验室代码 const userList = ref<userType[]>([]) // 可使用人列表 const deptList = ref<{ deptName: string; deptId: string }[]>([]) // 部门列表 // 查询条件 const listQuery = ref({ approvalStatus: active.value, // 审批状态 bizLabCode: '', // 实验室代码 creator: '', // 创建者 deptId: '', // 被监督者实验室 fileCode: '', // 文件编号 groupNo: '', // 部门代码 isNonConformance: '0', // 是否包含不符合项(0 不包含 1 包含) subTimeEnd: '', subTimeStart: '', offset: 1, limit: 20, }) const isNonConformance = ref(false) watch(() => isNonConformance, (newVal) => { if (newVal) { listQuery.value.isNonConformance = '1' } else { listQuery.value.isNonConformance = '0' } }, { deep: true, }) // 开始结束时间 const datetimerange = ref() watch(() => datetimerange.value, (newVal) => { listQuery.value.subTimeStart = '' listQuery.value.subTimeEnd = '' if (Array.isArray(newVal)) { if (newVal.length) { listQuery.value.subTimeStart = `${newVal[0]} 00:00:00` listQuery.value.subTimeEnd = `${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: 'bizLabCode', align: 'center' }, { text: '部门', value: 'deptId', align: 'center' }, { text: '质量监督员', value: 'creator', align: 'center' }, { text: '不符合要求情况分析报告', value: 'reps', align: 'center' }, { text: '不符合标准', value: 'standard', align: 'center' }, { text: '提交时间', value: 'subTime', align: 'center' }, ]) // 数据查询 function fetchData(isNowPage = false) { loadingTable.value = true if (!isNowPage) { // 是否显示当前页,否则跳转第一页 listQuery.value.offset = 1 } getQualityReportList(listQuery.value).then((response) => { tableList.value = response.data.rows total.value = parseInt(response.data.total) loadingTable.value = false }).catch(() => { loadingTable.value = false }) } // 搜索 const searchList = () => { fetchData(true) } // 重置查询条件 const clearList = () => { datetimerange.value = [] isNonConformance.value = false listQuery.value = { approvalStatus: active.value, // 审批状态 bizLabCode: '', // 实验室代码 creator: '', // 创建者 deptId: '', // 被监督者实验室 fileCode: '', // 文件编号 groupNo: '', // 部门代码 isNonConformance: '0', // 是否包含不符合项(0 不包含 1 包含) subTimeEnd: '', subTimeStart: '', offset: 1, limit: 20, } fetchData(true) } watch(() => listQuery.value.bizLabCode, (newVal) => { if (newVal) { listQuery.value.deptId = '' getSearchDept({ labCode: newVal }).then((res) => { deptList.value = res.data }) } }, { deep: true, }) // 多选发生改变时 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 = 'QualityReport' 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 }) getSearchDept({ labCode: '' }).then((res) => { deptList.value = res.data }) } const changeCurrentButton = (val: string) => { active.value = val window.sessionStorage.setItem(buttonBoxActive, val) clearList() // 刷新 } // 新建 const $router = useRouter() const handler = (type: string, row: any) => { $router.push({ path: `/supervisereport/${type}`, }) } // 删除 const deleteRow = (row: any) => { } 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 // 全部 } }) </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 > <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 > <el-option v-for="item in deptList" :key="item.deptId" :label="item.deptName" :value="item.deptId" /> </el-select> </search-item> <search-item> <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="提交结束时间" /> </search-item> <search-item style="margin-left: 15px;"> <el-checkbox v-model="listQuery.isNonConformance"> 有不符合要求情况 </el-checkbox> </search-item> </search-area> <table-container> <template #btns-right> <icon-button icon="icon-add" title="新建" type="primary" @click="handler('create', {})" /> <icon-button icon="icon-export" title="导出" type="primary" /> </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" > <template #default="{ row }"> {{ row.approvalStatus }} </template> </el-table-column> <el-table-column label="操作" align="center" fixed="right" > <template #default="{ row }"> <el-button size="small" type="primary" link @click="handler('detail', row)" > 查看 </el-button> <el-button size="small" type="primary" link @click="handler('handler', row)" > 编辑 </el-button> <el-button size="small" type="danger" link @click="deleteRow(row)" > 删除 </el-button> </template> </el-table-column> </template> </normal-table> </table-container> </app-container> </template>