Explorar el Código

通告添加评论功能

lizhenhao hace 2 años
padre
commit
e20b25bf50
Se han modificado 2 ficheros con 93 adiciones y 4 borrados
  1. 15 0
      src/api/notify/NotifyService.js
  2. 78 4
      src/views/modules/notify/NotifyForm.vue

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

@@ -60,4 +60,19 @@ export default class NotifyService {
       data: inputForm
     })
   }
+
+  addComment (param) {
+    return request({
+      url: '/notify/addComment',
+      method: 'post',
+      data: param
+    })
+  }
+  delComment (id) {
+    return request({
+      url: '/notify/delComment',
+      method: 'get',
+      params: {id: id}
+    })
+  }
 }

+ 78 - 4
src/views/modules/notify/NotifyForm.vue

@@ -183,7 +183,42 @@
         </el-form>
       </el-row>
     </el-form>
+<!--      附件-->
       <UpLoadComponent ref="uploadComponent"></UpLoadComponent>
+<!--      评论-->
+      <div v-if="method === 'view' || method === 'read'" style="margin-top: 30px">
+        <el-divider content-position="left"><i class="el-icon-document"></i>发表评论</el-divider>
+        <el-row>
+          <el-col style="margin-bottom: 20px">
+            <el-input v-model="inputForm.comment"
+                      type="textarea"
+                      :rows="5"
+                      maxlength="500"
+                      placeholder="请输入评论信息"
+                      show-word-limit>
+            </el-input>
+          </el-col>
+          <el-button style="float: right" type="primary" size="mini" @click="pushComment()" plain>
+            发表
+          </el-button>
+          <el-button style="float: right; margin-right: 20px" type="primary" size="mini" @click="cleanComment()" plain>
+            清空
+          </el-button>
+        </el-row>
+
+        <el-divider  content-position="left"><i class="el-icon-document"></i>全部评论({{inputForm.comments.length}}条)</el-divider>
+        <div v-for="(item, index) in inputForm.comments">
+          <el-divider></el-divider>
+          <div class="font_div" style="width: 100%; height:30px;"><span>{{item.userName}}</span></div>
+          <div style="margin-left: 20px; height:45px;"><span>{{item.comments}}</span></div>
+          <div style="width: 100%; height:30px;">
+            <span>{{item.deff}}</span>
+            <el-link v-if="$store.state.user.id === item.createId || isAdmin" style="float: right" type="text" size="mini" @click="delComment(item.id)">删除</el-link>
+          </div>
+        </div>
+      </div>
+
+
       <span slot="footer" class="dialog-footer">
       <el-button size="small" @click="close()" icon="el-icon-circle-close">关闭</el-button>
       <el-button size="small" v-if="method === 'edit'" type="primary" icon="el-icon-circle-check" @click="doSubmit()">确定</el-button>
@@ -245,12 +280,15 @@
           workAttachmentDtoList: [],
           pluginNotifyOfficesDTOList: [],
           pluginNotifyUserDTOList: [],
-          editorFilesDTOList: []
+          editorFilesDTOList: [],
+          comments: [],
+          comment: ''
         },
         keyWatch: '',
         tableKeyOffice: '',
         tableKeyUser: '',
-        visible: false
+        visible: false,
+        isAdmin: false
       }
     },
     computed: {
@@ -291,6 +329,12 @@
       this.userService = new UserService()
     },
     methods: {
+      // 查询当前用户是否是管理员用户
+      checkIsAdmin () {
+        this.userService.is().then(({data}) => {
+          this.isAdmin = data
+        })
+      },
       getKeyWatch (keyWatch) {
         this.keyWatch = keyWatch
       },
@@ -318,7 +362,9 @@
           workAttachmentDtoList: [],
           pluginNotifyOfficesDTOList: [],
           pluginNotifyUserDTOList: [],
-          editorFilesDTOList: []
+          editorFilesDTOList: [],
+          comments: [],
+          comment: ''
         }
         this.inputForm.id = id
         if (method === 'add') {
@@ -337,6 +383,7 @@
           this.loading = true
           this.$refs.contentEditor.clear()
           this.notifyService.query({id: this.inputForm.id, isSelf: method === 'read'}).then(({data}) => {
+            this.checkIsAdmin()
             this.$refs.uploadComponent.clearUpload()
             this.inputForm = this.recover(this.inputForm, data)
             this.inputForm = JSON.parse(JSON.stringify(this.inputForm))
@@ -471,7 +518,9 @@
           workAttachmentDtoList: [],
           pluginNotifyOfficesDTOList: [],
           pluginNotifyUserDTOList: [],
-          editorFilesDTOList: []
+          editorFilesDTOList: [],
+          comments: [],
+          comment: ''
         }
       },
       changeNotifyType () {
@@ -581,6 +630,31 @@
             })
           })
         }
+      },
+      pushComment () {
+        if (this.commonJS.isEmpty(this.inputForm.comment)) {
+          this.$message.error('请输入评论内容')
+          return
+        }
+        let param = {
+          notifyId: this.inputForm.id,
+          comments: this.inputForm.comment,
+          userId: this.$store.state.user.id
+        }
+        this.loading = true
+        this.notifyService.addComment(param).then(({data}) => {
+          this.init(this.method, this.inputForm.id)
+          this.$message.success(data)
+          this.loading = false
+        })
+      },
+      cleanComment () {
+        this.inputForm.comment = ''
+      },
+      delComment (id) {
+        this.notifyService.delComment(id).then(() => {
+          this.init(this.method, this.inputForm.id)
+        })
       }
     }
   }