|
|
@@ -1,6 +1,10 @@
|
|
|
<template>
|
|
|
<div class="message-notify-container">
|
|
|
- <el-table style="width: 100%; margin-top: 20px" border :data="formData">
|
|
|
+ <el-table
|
|
|
+ style="width: 100%; margin-top: 20px"
|
|
|
+ border
|
|
|
+ :data="localFormData"
|
|
|
+ >
|
|
|
<el-table-column prop="id" label="序号" width="120" align="center">
|
|
|
<template slot-scope="scope">
|
|
|
{{ scope.$index + 1 }}
|
|
|
@@ -34,13 +38,13 @@
|
|
|
<el-pagination
|
|
|
background
|
|
|
layout="total, sizes, prev, pager, next"
|
|
|
- :current-page="pagination.currentPage"
|
|
|
+ :current-page="internalPagination.currentPage"
|
|
|
:page-sizes="[10, 20, 30, 50]"
|
|
|
- :page-size="pagination.pageSize"
|
|
|
- :total="pagination.total"
|
|
|
+ :page-size="internalPagination.pageSize"
|
|
|
+ :total="internalPagination.total"
|
|
|
style="margin-top: 20px; text-align: right"
|
|
|
- @current-change="$emit('handle-page-change', $event)"
|
|
|
- @size-change="$emit('handle-size-change', $event)"
|
|
|
+ @current-change="handleCurrentChange"
|
|
|
+ @size-change="handleSizeChange"
|
|
|
/>
|
|
|
</div>
|
|
|
</template>
|
|
|
@@ -62,10 +66,74 @@
|
|
|
default: () => ({ currentPage: 1, pageSize: 10, total: 0 }),
|
|
|
},
|
|
|
},
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ internalPagination: {
|
|
|
+ currentPage: 1,
|
|
|
+ pageSize: 10,
|
|
|
+ total: 0,
|
|
|
+ },
|
|
|
+ localFormData: [],
|
|
|
+ }
|
|
|
+ },
|
|
|
+ watch: {
|
|
|
+ pagination: {
|
|
|
+ handler(newVal) {
|
|
|
+ if (newVal) {
|
|
|
+ this.internalPagination = {
|
|
|
+ currentPage: newVal.currentPage || 1,
|
|
|
+ pageSize: newVal.pageSize || 10,
|
|
|
+ total: newVal.total || 0,
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ immediate: true,
|
|
|
+ deep: true,
|
|
|
+ },
|
|
|
+ formData: {
|
|
|
+ handler(newVal) {
|
|
|
+ this.localFormData = newVal || []
|
|
|
+ },
|
|
|
+ immediate: true,
|
|
|
+ deep: true,
|
|
|
+ },
|
|
|
+ id: {
|
|
|
+ handler(newVal) {
|
|
|
+ if (newVal) {
|
|
|
+ // 重置到第一页并重新加载
|
|
|
+ this.internalPagination.currentPage = 1
|
|
|
+ this.getNoticeList()
|
|
|
+ }
|
|
|
+ },
|
|
|
+ immediate: false,
|
|
|
+ },
|
|
|
+ },
|
|
|
mounted() {
|
|
|
+ // 初始化分页数据
|
|
|
+ if (this.pagination) {
|
|
|
+ this.internalPagination = {
|
|
|
+ currentPage: this.pagination.currentPage || 1,
|
|
|
+ pageSize: this.pagination.pageSize || 10,
|
|
|
+ total: this.pagination.total || 0,
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (this.formData) {
|
|
|
+ this.localFormData = this.formData
|
|
|
+ }
|
|
|
this.getNoticeList()
|
|
|
},
|
|
|
methods: {
|
|
|
+ // 处理页码变化
|
|
|
+ handleCurrentChange(page) {
|
|
|
+ this.internalPagination.currentPage = page
|
|
|
+ this.getNoticeList()
|
|
|
+ },
|
|
|
+ // 处理每页条数变化
|
|
|
+ handleSizeChange(size) {
|
|
|
+ this.internalPagination.pageSize = size
|
|
|
+ this.internalPagination.currentPage = 1 // 重置到第一页
|
|
|
+ this.getNoticeList()
|
|
|
+ },
|
|
|
// 获取消息通知列表
|
|
|
async getNoticeList() {
|
|
|
if (!this.id) {
|
|
|
@@ -74,30 +142,40 @@
|
|
|
this.$emit('update:loading', true)
|
|
|
const params = {
|
|
|
taskId: this.id,
|
|
|
- pageNum: this.pagination.currentPage,
|
|
|
- pageSize: this.pagination.pageSize,
|
|
|
+ pageNum: this.internalPagination.currentPage,
|
|
|
+ pageSize: this.internalPagination.pageSize,
|
|
|
}
|
|
|
try {
|
|
|
const res = await sendMessage(params)
|
|
|
- console.log('消息通知', res)
|
|
|
+ console.log('消息通知123', res)
|
|
|
if (res && res.code === 200 && res.value) {
|
|
|
+ this.localFormData = res.value.records || []
|
|
|
+ this.internalPagination.total = res.value.total || 0
|
|
|
+ // 同步更新到父组件
|
|
|
this.$emit('update:formData', res.value.records || [])
|
|
|
this.$emit('update:pagination', {
|
|
|
- ...this.pagination,
|
|
|
- total: res.value.total || 0,
|
|
|
+ currentPage: this.internalPagination.currentPage,
|
|
|
+ pageSize: this.internalPagination.pageSize,
|
|
|
+ total: this.internalPagination.total,
|
|
|
})
|
|
|
} else {
|
|
|
+ this.localFormData = []
|
|
|
+ this.internalPagination.total = 0
|
|
|
this.$emit('update:formData', [])
|
|
|
this.$emit('update:pagination', {
|
|
|
- ...this.pagination,
|
|
|
+ currentPage: this.internalPagination.currentPage,
|
|
|
+ pageSize: this.internalPagination.pageSize,
|
|
|
total: 0,
|
|
|
})
|
|
|
}
|
|
|
} catch (err) {
|
|
|
console.error('获取消息通知失败', err)
|
|
|
+ this.localFormData = []
|
|
|
+ this.internalPagination.total = 0
|
|
|
this.$emit('update:formData', [])
|
|
|
this.$emit('update:pagination', {
|
|
|
- ...this.pagination,
|
|
|
+ currentPage: this.internalPagination.currentPage,
|
|
|
+ pageSize: this.internalPagination.pageSize,
|
|
|
total: 0,
|
|
|
})
|
|
|
} finally {
|