<!-- 选择测试校准检定方法 --> <script lang="ts" setup name="SelectMethodDialog"> import { ElMessage } from 'element-plus' import { ref } from 'vue' import dayjs from 'dayjs' import type { DateModelType } from 'element-plus' import type { TableColumn } from '../../../../../components/NormalTable/table_interface' import type { deptType } from '@/global' import { getDictByCode } from '@/api/system/dict' import { getFileMethodList } from '@/api/resource/fileTechnology' const emits = defineEmits(['confirm']) const dialogFormVisible = ref(false) // 查询条件 const listQuery = ref({ labCode: '', groupCode: '', fileNo: '', // 文件编号 fileName: '', // 文件名 fileDistributeNo: '', // 文件发放号 activeDateStart: '', // activeDateEnd: '', noveltyStatus: '', offset: 1, limit: 20, }) // 多选选中的内容 const checkoutList = ref([]) const dateRange = ref<[DateModelType, DateModelType]>(['', ''])// 筛选时间段数据 const loadingTable = ref(false) const list = ref([]) // 表格数据 const total = ref(0) const columns = ref<TableColumn[]>([ { text: '实验室', value: 'labCodeName', align: 'center', width: '100' }, { text: '部门', value: 'groupCodeName', align: 'center', width: '150' }, { text: '文件发放号', value: 'fileDistributeNo', align: 'center', width: '180' }, { text: '文件编号', value: 'fileNo', align: 'center', width: '180' }, { text: '文件名称', value: 'fileName', align: 'center' }, { text: '启用时间', value: 'activeDateStr', align: 'center', width: '120' }, { text: '查新状态', value: 'noveltyStatusName', align: 'center', width: '160' }, { text: '最新查新时间', value: 'latestNoveltyDate', align: 'center', width: '120' }, ]) // -----------------------------------------字典-------------------------------------------------------------- const groupCodeList = ref<deptType[]>([]) // 部门 const labCodeList = ref<deptType[]>([]) // 实验室 const noveltyStatusList = ref<deptType[]>([]) // 查新状态 // 查询字典 const getDictFun = () => { // 实验室 getDictByCode('bizLabCode').then((response) => { labCodeList.value = response.data }) // 部门 getDictByCode('bizGroupCode').then((response) => { groupCodeList.value = response.data }) // 文件类型 getDictByCode('bizNoveltyStatus').then((response) => { noveltyStatusList.value = response.data }) } getDictFun() // ------------------------------------------------------------------------------------------------------- // 数据查询 function fetchData(isNowPage = false) { loadingTable.value = true if (!isNowPage) { // 是否显示当前页,否则跳转第一页 listQuery.value.offset = 1 } getFileMethodList(listQuery.value).then((response) => { if (response.code === 200) { list.value = response.data.rows.map((item: { activeDate: string }) => { return { ...item, activeDateStr: dayjs(item.activeDate).format('YYYY-MM-DD') !== 'Invalid Date' ? dayjs(item.activeDate).format('YYYY-MM-DD') : '', } }) total.value = parseInt(response.data.total) } loadingTable.value = false }).catch(() => { loadingTable.value = false }) } // 重置 const clearList = () => { listQuery.value = { labCode: '', groupCode: '', fileNo: '', // 文件编号 fileName: '', // 文件名 fileDistributeNo: '', // 文件发放号 activeDateStart: '', // activeDateEnd: '', noveltyStatus: '', offset: 1, limit: 20, } dateRange.value = ['', ''] fetchData() } // 搜索 const search = () => { fetchData(true) } // 多选选中 const handleSelectionChange = (val: any) => { checkoutList.value = val } // 页数发生变化后的操作,可能是页码变化,可能是每页容量变化,此函数必写 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 } search() } // 点击确定 const confirmSelect = () => { if (!checkoutList.value.length) { ElMessage.warning('请选择体系文件') } else { emits('confirm', checkoutList.value) dialogFormVisible.value = false } } // 取消 const resetForm = () => { dialogFormVisible.value = false clearList() } // 初始化 const initDialog = () => { dialogFormVisible.value = true fetchData() } watch(dateRange, (val) => { if (val) { listQuery.value.activeDateStart = dayjs(val[0]).format('YYYY-MM-DD HH:mm:ss') === 'Invalid Date' ? '' : dayjs(val[0]).format('YYYY-MM-DD HH:mm:ss') listQuery.value.activeDateEnd = dayjs(val[1]).format('YYYY-MM-DD HH:mm:ss') === 'Invalid Date' ? '' : dayjs(val[1]).format('YYYY-MM-DD HH:mm:ss') } else { listQuery.value.activeDateStart = '' listQuery.value.activeDateEnd = '' } }) // ------------------------------------------钩子------------------------------------------------ defineExpose({ initDialog }) </script> <template> <el-dialog v-if="dialogFormVisible" v-model="dialogFormVisible" title="选择测试校准检定方法" width="65%"> <!-- 筛选条件 --> <search-area :need-clear="true" @search="search" @clear="clearList"> <search-item width="162px"> <el-select v-model="listQuery.labCode" placeholder="实验室" clearable> <el-option v-for="item in labCodeList" :key="item.id" :value="item.value" :label="item.name" /> </el-select> </search-item> <search-item width="162px"> <el-select v-model="listQuery.groupCode" placeholder="部门" clearable> <el-option v-for="item in groupCodeList" :key="item.id" :value="item.value" :label="item.name" /> </el-select> </search-item> <search-item width="162px"> <el-input v-model="listQuery.fileDistributeNo" placeholder="文件发放号" clearable /> </search-item> <search-item width="162px"> <el-input v-model="listQuery.fileNo" placeholder="文件编号" clearable /> </search-item> <search-item width="162px"> <el-input v-model="listQuery.fileName" placeholder="文件名称" clearable /> </search-item> <search-item> <el-date-picker v-model="dateRange" type="daterange" start-placeholder="启用时间(开始)" end-placeholder="启用时间(结束)" /> </search-item> <search-item width="162px"> <el-select v-model="listQuery.noveltyStatus" placeholder="查新状态" clearable> <el-option v-for="item in noveltyStatusList" :key="item.id" :value="item.value" :label="item.name" /> </el-select> </search-item> </search-area> <!-- 查询结果Table显示 --> <div style="padding: 12px;"> <normal-table :data="list" :total="total" :columns="columns" :query="listQuery" is-showmulti-select :list-loading="loadingTable" :height="520" @change="changePage" @multi-select="handleSelectionChange" > <!-- 序号 --> <template #preColumns> <el-table-column label="#" width="55" align="center" fixed> <template #default="scope"> {{ (listQuery.offset - 1) * listQuery.limit + scope.$index + 1 }} </template> </el-table-column> </template> </normal-table> </div> <template #footer> <span class="dialog-footer"> <el-button type="primary" @click="confirmSelect">确认</el-button> <el-button @click="resetForm"> 取消 </el-button> </span> </template> </el-dialog> </template> <style lang="scss" scoped> :deep(.el-radio__label) { display: none; } </style>