<template> <div class="publicContainer"> <el-table v-loading="tableLoading" :data="tableData" max-height="350"> <el-table-column label="序号" type="index" width="55" /> <el-table-column label="通知消息" prop="noticeMsg" /> <el-table-column label="接收人" prop="noticeUserName" /> <el-table-column label="操作" width="100" class-name="small-padding fixed-width"> <template #default="scope"> <el-button v-if="scope.row.noticeState == 1" type="primary">已读</el-button> <el-button v-if="scope.row.noticeState == 0" type="warning" @click="handleUpdate(scope.row)">未读</el-button> </template> </el-table-column> </el-table> </div> </template> <script setup> import { projectNoticeUserEdit } from '@/api/publicService/index'; const tableLoading = ref(false); const tableList = ref({}); const emits = defineEmits(); defineExpose({ closed }); const { proxy } = getCurrentInstance(); const props = defineProps({ //数据 tableData: { type: Object, default: {}, }, }); watch( () => props.tableData, value => { // console.log(props.tableData, 'props.tableData'); tableList.value = props.tableData; }, { immediate: true } ); function handleUpdate(row) { let params = { noticeState: 1, id: row.id, }; projectNoticeUserEdit(params).then(response => { proxy.$modal.msgSuccess('消息已读成功!'); closed(); }); } function closed() { emits('handleClose'); } </script>