Просмотр исходного кода

通知、通告 全部已读、部分已读功能开发

user5 2 лет назад
Родитель
Сommit
90423984f4
2 измененных файлов с 60 добавлено и 2 удалено
  1. 15 0
      src/api/notify/NotifyService.js
  2. 45 2
      src/views/modules/notify/MyNotifyList.vue

+ 15 - 0
src/api/notify/NotifyService.js

@@ -91,4 +91,19 @@ export default class NotifyService {
       params: {id: id}
     })
   }
+
+  portionRead (ids) {
+    return request({
+      url: '/notify/portionRead',
+      method: 'post',
+      params: {ids: ids}
+    })
+  }
+
+  readAll () {
+    return request({
+      url: '/notify/readAll',
+      method: 'post'
+    })
+  }
 }

+ 45 - 2
src/views/modules/notify/MyNotifyList.vue

@@ -14,8 +14,8 @@
 
          <vxe-toolbar :refresh="{query: refreshList}" custom>
            <template #buttons>
-             <el-button type="primary" size="small">全部标记已读</el-button>
-             <el-button type="primary"  size="small">标记为已读</el-button>
+             <el-button type="primary" size="small" @click="readAll()">全部标记已读</el-button>
+             <el-button :disabled="$refs.notifyTable && $refs.notifyTable.getCheckboxRecords().length === 0" type="warning" size="small" @click="portionRead()">标记为已读</el-button>
            </template>
          </vxe-toolbar>
 
@@ -164,6 +164,49 @@
       resetSearch () {
         this.$refs.searchForm.resetFields()
         this.refreshList()
+      },
+
+      // 全部已读
+      readAll () {
+        this.$confirm(`确定将全部通告标记为已读吗?`, '提示', {
+          confirmButtonText: '确定',
+          cancelButtonText: '取消',
+          type: 'warning'
+        }).then(() => {
+          this.loading = true
+          this.notifyService.readAll().then(({data}) => {
+            this.loading = false
+            this.$message({
+              message: data,
+              type: 'success',
+              duration: 1500
+            })
+            this.refreshList()
+          })
+        })
+      },
+
+      // 部分已读
+      portionRead (id) {
+        let ids = id || this.$refs.notifyTable.getCheckboxRecords().map(item => {
+          return item.id
+        }).join(',')
+        this.$confirm(`确定将选定通告标记为已读吗?`, '提示', {
+          confirmButtonText: '确定',
+          cancelButtonText: '取消',
+          type: 'warning'
+        }).then(() => {
+          this.loading = true
+          this.notifyService.portionRead(ids).then(({data}) => {
+            this.loading = false
+            this.$message({
+              message: data,
+              type: 'success',
+              duration: 1500
+            })
+            this.refreshList()
+          })
+        })
       }
     }
   }