<!-- 检测结果复查通知单 --> <script lang="ts" setup name="InspectionResultReviewNotice"> import { reactive, ref } from 'vue' import { ElMessage, ElMessageBox } from 'element-plus' import { getListPage } from '@/api/eqpt/MeasurementBusiness/detection' import { printJSON } from '@/utils/printUtils' const { proxy } = getCurrentInstance() as any const listQuery = reactive({ createTimeEnd: '', createTimeStart: '', createUserName: '', noticeNo: '', offset: 1, limit: 20, }) // 证书有效期开始结束时间 const datetimerange = ref() watch(() => datetimerange.value, (newVal) => { if (newVal.length) { listQuery.createTimeStart = `${newVal[0]} 00:00:00` listQuery.createTimeEnd = `${newVal[1]} 23:59:59` } else { listQuery.createTimeStart = '' listQuery.createTimeEnd = '' } }) const columns = ref([ { text: '通知单编号', value: 'noticeNo', align: 'center', }, { text: '通知单名称', value: 'noticeName', align: 'center', }, { text: '创建人', value: 'createUserName', align: 'center', }, { text: '创建时间', value: 'createTime', align: 'center', }, ]) const list = ref([]) const total = ref(0) const listLoading = ref(true) // 获取数据 const fetchData = (isNowPage = true) => { listLoading.value = true if (!isNowPage) { // 是否显示当前页,否则跳转第一页 listQuery.offset = 1 } getListPage(listQuery).then((response) => { list.value = response.data.rows total.value = parseInt(response.data.total) listLoading.value = false }) // list.value = [ // { // createTime: '2023-09-05', // 创建时间 // createUserId: '123', // 创建人id // createUserName: '张三', // 创建人名字 // customerId: '123', // 委托方id // customerName: '李四', // 委托方名称 // deviceModel: 'SQ001', // 送检设备型号 // deviceName: '测试设备', // 送检设备名称 // deviceNo: '112233', // 送检设备编号 // id: '123', // id // labCode: '1', // 实验室代码 // labCodeName: '海口实验室', // 实验室代码 // noticeDate: '2023-09-05', // 通知日期 // noticeName: '海口计量站', // 通知单名称 // noticeNo: '12345', // 通知单编号 // noticeUserId: '1', // 通知委托方用户id // noticeUserName: '王五', // 通知委托方用户名字 // returnDate: '2023-09-05', // 寄回日期 // submitDate: '2023-09-05', // 送检日期 // updateTime: '2023-09-05', // 更新时间 // }, // ] // listLoading.value = false } fetchData() // 查询数据 const search = () => { fetchData(false) } search() // 重置 const reset = () => { datetimerange.value = [] listQuery.createTimeEnd = '' listQuery.createTimeStart = '' listQuery.createUserName = '' listQuery.noticeNo = '' listQuery.offset = 1 listQuery.limit = 20 search() } // 页数发生变化后的操作,可能是页码变化,可能是每页容量变化,此函数必写 const changePage = (val: { size: number; page: number }) => { if (val && val.size) { listQuery.limit = val.size } if (val && val.page) { listQuery.offset = val.page } fetchData() } const $router = useRouter() // 新建编辑操作 const handler = (row: any, type: string) => { $router.push({ path: `/detection/${type}`, query: { row: JSON.stringify(row), id: row.id, }, }) } // 打印列表 const printList = () => { if (list.value.length) { const properties = columns.value.map((item) => { return { field: item.value, displayName: item.text, } }) printJSON(list.value, properties, '检测结果复查通知单') } else { ElMessage.warning('无可打印内容') } } </script> <template> <app-container> <!-- 筛选条件 --> <search-area :need-clear="true" @search="search" @clear="reset"> <search-item> <el-input v-model.trim="listQuery.noticeNo" placeholder="通知单编号" clearable /> </search-item> <search-item> <el-input v-model.trim="listQuery.createUserName" placeholder="创建人" clearable /> </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-area> <table-container> <template #btns-right> <icon-button icon="icon-print" title="打印" @click="printList" /> </template> <!-- 普通表格 --> <normal-table :data="list" :total="total" :columns="columns" :query="listQuery" :list-loading="listLoading" @change="changePage" > <template #columns> <el-table-column label="操作" width="160" align="center"> <template #default="scope"> <el-button link type="primary" size="small" @click="handler(scope.row, 'detail')"> 查看 </el-button> </template> </el-table-column> </template> </normal-table> </table-container> </app-container> </template>