<!-- 选择证书 --> <script lang="ts" setup name="SelectCertDialog"> import { ElMessage } from 'element-plus' import type { Ref } from 'vue' import { ref } from 'vue' import dayjs from 'dayjs' import type { DateModelType } from 'element-plus' import type { TableColumn } from '@/components/NormalTable/table_interface' import { SCHEDULE } from '@/utils/scheduleDict' import { getCertList } from '@/api/business/certManage/cert' const emits = defineEmits(['confirm']) const dialogFormVisible = ref(false) // 查询条件 const listQuery = ref({ approvalStatus: '0', // 审批状态类型code // 选择审批通过的 certificateReportName: '', // 证书报告名称 certificateReportNo: '', // 证书报告编号 createTimeEnd: '', // 创建结束时间 createTimeStart: '', // 创建开始时间 customerName: '', // 委托方名字 formId: SCHEDULE.CERTIFICATE_PRINT_APPROVAL, // formId printStatus: '', // 打印状态(未打印传1,其他状态不传) sampleName: '', // 受检设备名称 sampleNo: '', // 样品编号 offset: 1, limit: 20, }) const checkoutList = ref([]) // 多选选中的内容 const loadingTable = ref(false) const list = ref([]) // 表格数据 const total = ref(0) const columns = ref<TableColumn[]>([ { text: '证书编号', value: 'certificateNo', width: '160', align: 'center' }, { text: '证书名称', value: 'certificateName', align: 'center' }, { text: '任务单编号', value: 'orderNo', width: '160', align: 'center' }, { text: '委托方', value: 'customerName', align: 'center' }, { text: '被检设备统一编号', value: 'sampleNo', align: 'center', width: '160' }, { text: '被检设备名称', value: 'sampleName', align: 'center' }, { text: '创建时间', value: 'createTime', width: '180', align: 'center' }, { text: '打印状态', value: 'printStatusName', width: '85', align: 'center' }, ]) const dateRange = ref<[DateModelType, DateModelType]>(['', ''])// 筛选时间段数据 // 数据查询 function fetchData(isNowPage = false) { loadingTable.value = true if (!isNowPage) { // 是否显示当前页,否则跳转第一页 listQuery.value.offset = 1 } getCertList(listQuery.value).then((response) => { list.value = response.data.rows total.value = parseInt(response.data.total) loadingTable.value = false }).catch(() => { loadingTable.value = false }) } // 重置 const clearList = () => { listQuery.value = { approvalStatus: '0', // 审批状态类型code // 选择审批通过的 certificateReportName: '', // 证书报告名称 certificateReportNo: '', // 证书报告编号 createTimeEnd: '', // 创建结束时间 createTimeStart: '', // 创建开始时间 customerName: '', // 委托方名字 formId: SCHEDULE.CERTIFICATE_PRINT_APPROVAL, // formId printStatus: '', // 打印状态(未打印传1,其他状态不传) sampleName: '', // 受检设备名称 sampleNo: '', // 样品编号 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.createTimeStart = `${val[0]}` listQuery.value.createTimeEnd = `${val[1]}` } else { listQuery.value.createTimeStart = '' listQuery.value.createTimeEnd = '' } }) 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> <el-input v-model.trim="listQuery.certificateReportNo" placeholder="证书编号" class="short-input" clearable /> </search-item> <search-item> <el-input v-model.trim="listQuery.certificateReportName" placeholder="证书名称" class="short-input" clearable /> </search-item> <search-item> <el-input v-model.trim="listQuery.customerName" placeholder="委托方" clearable class="short-input" /> </search-item> <search-item> <el-input v-model.trim="listQuery.sampleNo" placeholder="被检设备统一编号" clearable class="short-input" /> </search-item> <search-item> <el-input v-model.trim="listQuery.sampleName" placeholder="被检设备名称" clearable class="short-input" /> </search-item> <search-item> <el-date-picker v-model="dateRange" type="datetimerange" range-separator="至" format="YYYY-MM-DD HH:mm:ss" value-format="YYYY-MM-DD HH:mm:ss" start-placeholder="创建时间(开始)" end-placeholder="创建时间(结束)" /> </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" :is-multi="false" :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>