<!-- 到期提醒 --> <script lang="ts" setup name="RemindList"> import { reactive, ref } from 'vue' import { ElLoading, ElMessage, ElMessageBox } from 'element-plus' import { exportRemind, getRemindList } from '@/api/eqpt/device/remind' import { getDictByCode } from '@/api/system/dict' import { exportFile } from '@/utils/exportUtils' const { proxy } = getCurrentInstance() as any const listQuery = reactive({ certificateValidEnd: '', certificateValidStart: '', equipmentName: '', equipmentNo: '', usePosition: '', usageStatus: '', offset: 1, limit: 20, }) const columns = ref([ { text: '统一编号', value: 'equipmentNo', align: 'center', }, { text: '设备名称', value: 'equipmentName', align: 'center', }, { text: '型号规格', value: 'model', align: 'center', }, { text: '出厂编号', value: 'manufactureNo', align: 'center', }, { text: '使用岗位', value: 'usePosition', align: 'center', }, { text: '计量标识', value: 'meterIdentifyName', align: 'center', }, { text: '检定周期', value: 'checkCycle', align: 'center', }, { text: '证书有效期', value: 'certificateValid', align: 'center', }, { text: '使用状态', value: 'usageStatusName', align: 'center', }, { text: '备注', value: 'remark', 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 } getRemindList(listQuery).then((response) => { list.value = response.data.rows total.value = parseInt(response.data.total) listLoading.value = false }) } fetchData() // 查询数据 const search = () => { fetchData(false) } const range = ref() watch(() => range.value, (newVal) => { if (newVal.length) { listQuery.certificateValidStart = `${newVal[0]} 00:00:00` listQuery.certificateValidEnd = `${newVal[1]} 23:59:59` } else { listQuery.certificateValidStart = '' listQuery.certificateValidEnd = '' } }, { deep: true, }) const reset = () => { range.value = [] listQuery.certificateValidEnd = '' listQuery.certificateValidStart = '' listQuery.equipmentName = '' listQuery.equipmentNo = '' listQuery.usePosition = '' listQuery.usageStatus = '' 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 selectList = ref<any[]>([]) // 表格多选 const multiSelect = (row: any[]) => { selectList.value = row } const $router = useRouter() const detail = (row: any) => { $router.push({ path: '/dremindlist/detail', query: { row: JSON.stringify(row), id: row.id, statusName: '全部', equipmentType: '1', }, }) } // 提醒 const remind = () => { ElMessageBox.confirm( '确认提醒吗?', '确认', { confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning', }, ).then((res) => { }) } // 导出列表 const exportList = () => { if (list.value.length) { const loading = ElLoading.service({ lock: true, text: 'Loading', background: 'rgba(255, 255, 255, 0.8)', }) const data = { ...listQuery, offset: undefined, limit: undefined, ids: selectList.value.map(item => item.id), } exportRemind(data).then((res) => { exportFile(res.data, '到期提醒') loading.close() }) .catch((_) => { loading.close() }) } else { ElMessage.warning('无可导出内容') } } // 设备使用状态 const useStatusList = ref<{ id: string; value: string; name: string }[]>() // 使用状态 const fetchStatusList = () => { getDictByCode('eqptDeviceUseStatus').then((res) => { useStatusList.value = res.data }) } fetchStatusList() </script> <template> <app-container> <!-- 筛选条件 --> <search-area :need-clear="true" @search="search" @clear="reset"> <search-item> <el-input v-model.trim="listQuery.equipmentNo" placeholder="统一编号" clearable /> </search-item> <search-item> <el-input v-model.trim="listQuery.equipmentName" placeholder="设备名称" clearable /> </search-item> <search-item> <el-input v-model.trim="listQuery.usePosition" placeholder="所属岗位" clearable /> </search-item> <search-item> <!-- <el-input v-model.trim="listQuery.usageStatus" placeholder="使用状态" clearable /> --> <el-select v-model="listQuery.usageStatus" placeholder="使用状态" clearable style="width: 100%;"> <el-option v-for="item in useStatusList" :key="item.id" :label="item.name" :value="item.value" /> </el-select> </search-item> <search-item> <el-date-picker v-model="range" 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-export" title="导出" @click="exportList" /> </template> <!-- 普通表格 --> <normal-table :data="list" :total="total" :columns="columns" :query="listQuery" :list-loading="listLoading" :is-showmulti-select="true" :is-multi="true" @change="changePage" @multi-select="multiSelect" > <template #columns> <el-table-column label="操作" width="140" align="center"> <template #default="scope"> <el-button link type="primary" size="small" @click="detail(scope.row)"> 查看 </el-button> <!-- <el-button link type="primary" size="small" @click="remind(scope.row)"> 提醒 </el-button> --> </template> </el-table-column> </template> </normal-table> </table-container> </app-container> </template>