Browse Source

发送、撤回公告

qinchao 4 years ago
parent
commit
20bbc60a3e
1 changed files with 34 additions and 21 deletions
  1. 34 21
      src/modules/examwork/view/notice.vue

+ 34 - 21
src/modules/examwork/view/notice.vue

@@ -91,11 +91,11 @@
             </template>
           </el-table-column>
           <el-table-column
-            width
+            width="80"
             prop="publisher"
             label="发布者"
           ></el-table-column>
-          <el-table-column width="130" label="状态" sortable>
+          <el-table-column width="80" label="状态" sortable>
             <template slot-scope="scope">
               <div>
                 <span>{{ getPublishStatus(scope.row.publishStatus) }}</span>
@@ -108,7 +108,7 @@
             label="发送时间"
             sortable
           ></el-table-column>
-          <el-table-column label="操作">
+          <el-table-column label="操作" width="270">
             <div slot-scope="scope">
               <el-button
                 size="mini"
@@ -118,6 +118,22 @@
                 @click="viewNoticeDialog(scope.row)"
                 >详情</el-button
               >
+              <el-button
+                v-if="scope.row.publishStatus == 'DRAFT'"
+                size="mini"
+                type="warning"
+                icon="el-icon-message"
+                @click="sendMsg(scope.row.id, 'TO_BE_PUBLISHED')"
+                >发送</el-button
+              >
+              <el-button
+                v-if="scope.row.publishStatus == 'PUBLISHED'"
+                size="mini"
+                type="danger"
+                icon="el-icon-back"
+                @click="sendMsg(scope.row.id, 'DRAFT')"
+                >撤回</el-button
+              >
               <el-dropdown
                 style="margin-left: 10px"
                 :disabled="scope.row.publishStatus != 'DRAFT'"
@@ -283,14 +299,7 @@
               v-show="operateType != 'view'"
               type="primary"
               :loading="noticeFormLoading"
-              @click="saveNotice(2)"
-              >确认发送</el-button
-            >
-            <el-button
-              v-show="operateType != 'view'"
-              type="primary"
-              :loading="noticeFormLoading"
-              @click="saveNotice(1)"
+              @click="saveNotice"
               >保 存</el-button
             >
             <el-button @click="cancel">关 闭</el-button>
@@ -883,13 +892,20 @@ export default {
         });
       }
     },
-    saveNotice(option) {
-      if (option == 1) {
-        this.noticeForm.noticeStatus = "DRAFT";
-      } else {
-        this.noticeForm.noticeStatus = "TO_BE_PUBLISHED";
+    sendMsg(id, status) {
+      let msg = "发送成功";
+      if (status === "DRAFT") {
+        msg = "撤回成功";
       }
-
+      this.$httpWithMsg
+        .get(EXAM_WORK_API + "/notice/sendMsg/" + status + "/" + id)
+        .then(() => {
+          this.success(msg);
+          this.searchForm();
+        });
+    },
+    saveNotice() {
+      this.noticeForm.noticeStatus = "DRAFT";
       this.$refs["noticeForm"].validate((valid) => {
         if (valid) {
           if (
@@ -921,13 +937,12 @@ export default {
                 () => {
                   this.editNoticeDialogVisible = true;
                   this.noticeFormLoading = false;
-                  // this.searchForm();
-                  // this.editNoticeDialogVisible = false;
                 }
               );
           }
           //新增
           else {
+            this.noticeForm.noticeStatus = "DRAFT";
             this.$httpWithMsg
               .post(EXAM_WORK_API + "/notice/addNotice", this.noticeForm)
               .then(
@@ -940,8 +955,6 @@ export default {
                 () => {
                   this.editNoticeDialogVisible = true;
                   this.noticeFormLoading = false;
-                  // this.editNoticeDialogVisible = false;
-                  // return this.searchForm();
                 }
               );
           }