<!-- 智能模型台账信息详情 智能模型履历 --> <script name="StandardBookEquipmentHistory" lang="ts" setup> import { onMounted, ref } from 'vue' import dayjs from 'dayjs' import { ElLoading, ElMessage } from 'element-plus' import type { IMaintenanceRecord } from '../book-interface' import type { TableColumn } from '@/components/NormalTable/table_interface' import useUserStore from '@/store/modules/user' import { getEquipmentResumeList } from '@/api/equipment/info/book' const props = defineProps({ equipmentId: String, // 智能模型id }) // 查询条件 const listQuery = ref({ id: '', // 智能模型id offset: 1, limit: 20, }) const loadingTable = ref(false) // 表格loading const user = useUserStore() // 用户信息 const total = ref(0) // 数据总条数 const list = ref<IMaintenanceRecord[]>([]) // 表格数据 const originList = ref<IMaintenanceRecord[]>([]) // 表格数据记录 const columns = ref<TableColumn[]>([ // 表头 { text: '记录编号', value: 'recordNo_hide', align: 'center', width: '180', followLink: true }, { text: '记录名称', value: 'recordName', align: 'center', isFilters: true, filters: [{ text: '借出记录', value: '借出记录' }, { text: '异常情况记录', value: '异常情况记录' }, { text: '运输装箱记录', value: '运输装箱记录' }] }, { text: '记录部门', value: 'deptName', align: 'center' }, { text: '记录人', value: 'recordUserName', align: 'center' }, { text: '记录时间', value: 'recordTime', align: 'center', width: '180' }, ]) // -----------------------------------------方法-------------------------------------------------- // 数据查询 function fetchData(isNowPage = false) { loadingTable.value = true if (!isNowPage) { // 是否显示当前页,否则跳转第一页 listQuery.value.offset = 1 } listQuery.value.id = props.equipmentId! getEquipmentResumeList(listQuery.value).then((response) => { list.value = response.data.rows.map((item: { recordNo: string }) => { return { ...item, followLinkArr: [item.recordNo], } }) originList.value = list.value total.value = parseInt(response.data.total) loadingTable.value = false }).catch(() => { loadingTable.value = false }) } // 页数发生变化后的操作,可能是页码变化,可能是每页容量变化,此函数必写 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 $router = useRouter() // 点击记录编号 const handleClickFollowLink = (row: any, title: string) => { if (row.recordName === '智能模型借出登记表') { $router.push({ path: `/resume/lendDoc/detail/${row.id}`, query: { approvalStatusName: '全部', // 审批状态名称 returnStatus: row.returnStatus, // 是否归还 }, }) } else if (row.recordName === '智能模型运输装箱清单') { $router.push({ path: `/resume/encasementDoc/detail/${row.id}`, }) } else if (row.recordName === '智能模型异常及追溯情况报告单') { $router.push({ path: `/resume/errorDoc/detail/${row.id}`, query: { approvalStatusName: '全部', // 审批状态名称 row: { ...row } as any, applyType: row.applyType, }, }) } } // 筛选条件发生变化 const filterChange = (val: any) => { if (!val.recordName.length) { // 全部 list.value = originList.value } else { if (val.recordName[0] === '借出记录') { list.value = originList.value.filter(item => item.recordName === '智能模型借出登记表') } else if (val.recordName[0] === '异常情况记录') { list.value = originList.value.filter(item => item.recordName === '智能模型异常及追溯情况报告单') } else if (val.recordName[0] === '运输装箱记录') { list.value = originList.value.filter(item => item.recordName === '智能模型运输装箱清单') } } } // -------------------------------------------钩子------------------------------------------------ onMounted(async () => { fetchData() }) </script> <template> <detail-block title="智能模型履历"> <normal-table :data="list" :total="total" :columns="columns" :query="{ limit: listQuery.limit, offset: listQuery.offset }" :list-loading="loadingTable" @change="changePage" @handle-click-follow-link="handleClickFollowLink" @filter-change="filterChange" > <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> </normal-table> </detail-block> </template>