<!-- 审批提醒列表页 --> <script name="WorkList" setup lang="ts"> import { ElLoading, ElMessage, ElMessageBox } from 'element-plus' import type { DateModelType } from 'element-plus' import dayjs from 'dayjs' import { useChangePage } from './useChangePage' import { formIdUrl } from '@/utils/scheduleDict' import type { TableColumn } from '@/components/NormalTable/table_interface' import { getDictByCode } from '@/api/system/dict' import type { dictType } from '@/global' import { getREADApprovalListPage, getUNREADApprovalListPage, updateApprovalStatus } from '@/api/workBench/message' import useUserStore from '@/store/modules/user' const $router = useRouter() const messageSourceModuleList = ref<dictType[]>([]) // 来源模块 const messageSourceModuleDict = ref({}) as any // 来源模块map const labCode = ref('') // 实验室 const groupCode = ref('') as any // 部门 const isAdministrator = ref('0') // 是不是超级管理员 const emptyDisc = ref('') // 描述文字 const user = useUserStore() // 用户信息 const timeRange = ref<[DateModelType, DateModelType]>(['', '']) const messageTitleList = [ { id: '0', name: '全部', value: '0', }, { id: '1', name: '待审批通知', value: '1', }, { id: '2', name: '结果通知', value: '2', }, ] // 查询条件 const listQuery = ref({ endTime: '', // 结束时间 messageContent: '', // 详细信息 messageTitle: '0', // 主题 sourceModule: '', // 来源模块(字典code) startTime: '', // 开始时间 limit: 20, offset: 1, }) const selectMessageTitle = ref('') const total = ref(0) // 数据条数 const loadingTable = ref(false) // 表格loading const showEmpty = ref(false) const list = ref([]) // 表格数据 // 筛选时间段数据 // 表头 const columns = ref<TableColumn[]>([ { text: '主题', value: 'messageTitle', align: 'center', width: '180' }, { text: '来源模块', value: 'sourceModuleName', align: 'center', width: '180' }, { text: '详细信息', value: 'messageContent', align: 'center' }, { text: '处理情况', value: 'readStatusName', align: 'center', width: '90', styleFilter: (row: { readStatusName: string }) => { return row.readStatusName == '未处理' ? 'color: red' : 'color: #1aa034' } }, { text: '创建时间', value: 'createTime', align: 'center', width: '180' }, ]) // -------------------------------------标签-------------------------------------------------- const radioMenus = ref([ // 标签内容 { name: '未处理', value: 0 }, { name: '已处理', value: 1 }, ]) const current = ref(0) // 选择的tab 默认基本信息 // --------------------------------------------------------------------------------------- // 获取审批提醒列表页 function fetchData(isNowPage = false) { loadingTable.value = true if (!isNowPage) { // 是否显示当前页,否则跳转第一页 listQuery.value.offset = 1 } listQuery.value.messageTitle = !selectMessageTitle.value ? '0' : selectMessageTitle.value if (current.value === 0) { getUNREADApprovalListPage(listQuery.value).then((res) => { list.value = res.data.rows.map((item: { createTime: string; readStatus: string;sourceModule: string;formId: string;sourceModuleName: string }) => { return { ...item, createTime: dayjs(item.createTime).format('YYYY-MM-DD HH:mm'), readStatusName: `${item.readStatus}` === '1' ? '已处理' : '未处理', // 由于对编号为XXX证书/报告的补充件、合同执行变更登记表两个模块后台返回的模块号均为64,所以在此用formId区分 sourceModuleName: item.formId === 'jljdywzsbcj' ? '对编号为XXX证书/报告的补充件' : item.formId === 'zyglhtzxbgdjb' ? '合同执行变更登记表' : `${item.sourceModule}` ? messageSourceModuleDict.value[item.sourceModule] : item.sourceModuleName, // 来源模块 } }) total.value = res.data.total loadingTable.value = false }).catch(() => { loadingTable.value = false }) } else if (current.value === 1) { getREADApprovalListPage(listQuery.value).then((res) => { list.value = res.data.rows.map((item: { formId: string; createTime: string; readStatus: string }) => { return { ...item, createTime: dayjs(item.createTime).format('YYYY-MM-DD HH:mm'), readStatusName: `${item.readStatus}` === '1' ? '已处理' : '未处理', // 由于对编号为XXX证书/报告的补充件、合同执行变更登记表两个模块后台返回的模块号均为64,所以在此用formId区分 sourceModuleName: item.formId === 'jljdywzsbcj' ? '对编号为XXX证书/报告的补充件' : item.formId === 'zyglhtzxbgdjb' ? '合同执行变更登记表' : `${item.sourceModule}` ? messageSourceModuleDict.value[item.sourceModule] : item.sourceModuleName, // 来源模块 } }) total.value = res.data.total loadingTable.value = false }).catch(() => { loadingTable.value = false }) } } // 搜索 const searchList = () => { fetchData(false) } // 重置 const reset = () => { listQuery.value = { endTime: '', // 结束时间 messageContent: '', // 详细信息 messageTitle: '0', // 主题 sourceModule: '', // 来源模块(字典code) startTime: '', // 开始时间 limit: 20, offset: 1, } selectMessageTitle.value = '' timeRange.value = ['', ''] fetchData(true) } // 页数发生变化后的操作,可能是页码变化,可能是每页容量变化,此函数必写 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 getDict = async () => { // 来源模块 const response = await getDictByCode('approvalSourceModule') messageSourceModuleList.value = response.data response.data.forEach((item: { value: string; name: string }) => { messageSourceModuleDict.value[`${item.value}`] = item.name }) } // 跳转详情页 const detail = (row: any) => { const formId = row.formId useChangePage($router, formIdUrl[formId], row) } // 时间变更 watch(timeRange, (val) => { if (val) { listQuery.value.startTime = `${val[0]}` listQuery.value.endTime = `${val[1]}` } else { listQuery.value.startTime = '' listQuery.value.endTime = '' } }) watch(() => current.value, (newValue) => { fetchData() }) const $route = useRoute() // 路由参数 onMounted(async () => { listQuery.value.messageTitle = $route.query.messageTitle === '待审批通知' ? '1' : $route.query.messageTitle === '审批结果通知' ? '2' : '0' listQuery.value.sourceModule = $route.query.sourceModule ? $route.query.sourceModule as string : '' listQuery.value.messageContent = $route.query.messageContent ? $route.query.messageContent as string : '' if ($route.query.messageTitle === '待审批通知') { selectMessageTitle.value = '1' } if ($route.query.messageTitle === '审批结果通知') { selectMessageTitle.value = '2' } await getDict() // 获取字典 isAdministrator.value = user.roleTips.includes('administrator') ? '1' : '0' // 是否是超级管理员 console.log('是否是超级管理员', user.roleTips, isAdministrator.value) if (isAdministrator.value === '1') { // 超级管理员 labCode.value = '' // 有实验室就默认本人实验室+ groupCode.value = '' // 超级管理员默认查看全部 fetchData() } else { // 不是超级管理员 if (!user.bizLabCode) { // 没有实验室 emptyDisc.value = '此用户非超级管理员且无实验室,无权限查看' showEmpty.value = true } else if (!user.groupNo) { // 有实验室但没有组 emptyDisc.value = '此用户非超级管理员且无部门,无权限查看' showEmpty.value = true } else { // 有实验室且有组 showEmpty.value = false if (user.groupNo === 'GL') { // 综合管理组 labCode.value = user.bizLabCode // 实验室 // 综合管理组默认查实验室下面的所有数据,不筛选部门 groupCode.value = '' } else { // 其他组 labCode.value = user.bizLabCode // 实验室 // 其他组默认筛选自己组 groupCode.value = user.groupNo } fetchData() } } }) </script> <template> <div class="workBench-radio-menu"> <h4 style="padding: 0;margin: 0;"> 审批提醒 </h4> <el-radio-group v-model="current"> <el-radio-button v-for="item in radioMenus" :key="item.value" :label="item.value"> {{ item.name }} </el-radio-button> </el-radio-group> </div> <!-- 布局 --> <app-container v-if="!showEmpty"> <!-- 筛选条件 --> <search-area :need-clear="true" @search="searchList" @clear="reset"> <search-item> <el-select v-model="selectMessageTitle" style="width: 160px;" placeholder="请选择主题" clearable filterable> <el-option v-for="item in messageTitleList" :key="item.id" :label="item.name" :value="item.value" /> </el-select> </search-item> <search-item> <el-select v-model="listQuery.sourceModule" style="width: 280px;" placeholder="来源模块" clearable filterable> <el-option v-for="item in messageSourceModuleList" :key="item.value" :label="item.name" :value="item.value" /> </el-select> </search-item> <search-item> <el-input v-model.trim="listQuery.messageContent" placeholder="详细信息" clearable /> </search-item> <search-item> <el-date-picker v-model="timeRange" type="datetimerange" format="YYYY-MM-DD HH:mm" value-format="YYYY-MM-DD HH:mm" range-separator="至" start-placeholder="创建时间(开始)" end-placeholder="创建时间(结束)" clearable /> </search-item> </search-area> <table-container> <normal-table :data="list" :total="total" :columns="columns" :query="listQuery" :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 label="操作" align="center" fixed="right" width="90"> <template #default="{ row }"> <el-button size="small" link type="primary" @click="detail(row)"> 详情 </el-button> </template> </el-table-column> </template> </normal-table> </table-container> </app-container> <el-empty v-if="showEmpty" style="margin: 0 auto;" :description="emptyDisc" :image-size="50" /> </template> <style lang="scss" scoped> .workBench-radio-menu { width: 100%; display: flex; justify-content: space-between; background-color: #fff; padding: 10px; } </style>