<!-- 文件发放通知单 --> <script name="SysDocFileGrantList" lang="ts" setup> import { onMounted, ref } from 'vue' import dayjs from 'dayjs' import { ElLoading, ElMessage } from 'element-plus' import type { TableColumn } from '@/components/NormalTable/table_interface' import useUserStore from '@/store/modules/user' import { getFileGrantNoticeList } from '@/api/resource/fileGrantNotice' const props = defineProps({ fileNo: String, // id }) const flowFormId = 'zyglwjfftzd' // 资源管理 - 文件发放通知单 // 查询条件 const listQuery = ref({ approvalStatus: '0', // 审批状态类型code,导出接口不用传 beginTime: '', // 开始时间 createUserName: '', // 创建人 distributor: '', // 发放人员 endTime: '', // 结束时间 fileApprovalCodes: '', // 文件审批编号 formId: flowFormId, // 表单id(流程定义对应的表单id,等价于业务id),导出接口不用传 formName: '', // 文件名称 formNo: '', // 文件编号 grantFileName: '', // 发放文件名称 grantFileNo: props.fileNo, // 发放文件编号(可用于体系文件详情中查询文件发放通知单列表) groupCode: '', // 部门 labCode: '', // 实验室 offset: 1, limit: 20, }) const loadingTable = ref(false) // 表格loading const user = useUserStore() // 用户信息 const total = ref(0) // 数据总条数 const list = ref([]) // 表格数据 const columns = ref<TableColumn[]>([ // 表头 { text: '实验室', value: 'labCodeName', align: 'center' }, { text: '部门', value: 'groupCodeName', align: 'center' }, { text: '文件编号', value: 'formNo', align: 'center' }, { text: '文件名称', value: 'formName', align: 'center' }, { text: '文件审批编号', value: 'fileApprovalCodes', align: 'center' }, { text: '发放人员', value: 'distributorNames', align: 'center' }, { text: '发放文件', value: 'fileName', align: 'center' }, { text: '创建人', value: 'createUserName', align: 'center' }, { text: '创建时间', value: 'createTime', align: 'center', width: '180' }, ]) // -----------------------------------------方法-------------------------------------------------- // 数据查询 function fetchData(isNowPage = false) { loadingTable.value = true if (!isNowPage) { // 是否显示当前页,否则跳转第一页 listQuery.value.offset = 1 } getFileGrantNoticeList(listQuery.value).then((response) => { if (response.code === 200) { list.value = response.data.rows.map((item: { createTime: string; fileList: { fileName: string }[] }) => { return { ...item, grantFileName: Array.isArray(item.fileList) && item.fileList.length ? item.fileList.map(i => i.fileName).join(',') : `${item.fileList}`, } }) 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 detail = (row: any) => { $router.push({ query: { id: row.id, status: '0', }, path: '/file/grantNotice/approved/detail', }) } // -------------------------------------------钩子------------------------------------------------ watch(() => props.fileNo, (newValue) => { if (props.fileNo) { listQuery.value.grantFileNo = newValue fetchData() } }, { immediate: true }) </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" > <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> <template #columns> <el-table-column fixed="right" label="操作" align="center" width="130"> <template #default="{ row }"> <el-button size="small" type="primary" link @click="detail(row)"> 查看 </el-button> </template> </el-table-column> </template> </normal-table> </detail-block> </template>