Browse Source

通告更改

gks 1 year ago
parent
commit
bba1592951
2 changed files with 16 additions and 15 deletions
  1. 1 3
      src/api/system/notice.js
  2. 15 12
      src/views/system/notice/index.vue

+ 1 - 3
src/api/system/notice.js

@@ -19,10 +19,8 @@ export function getNotice(noticeId) {
 
 // 新增公告
 export function addNotice(data) {
-  let dataStr = data.noticeContent;
-  data.noticeContent = null;
   return request({
-    url: "/system/notice/add?noticeContent=" + dataStr,
+    url: "/system/notice/add",
     method: "post",
     data: data,
   });

+ 15 - 12
src/views/system/notice/index.vue

@@ -289,7 +289,7 @@ export default {
           { required: true, message: "公告类型不能为空", trigger: "change" },
         ],
       },
-      IP:"",
+      IP: "",
     };
   },
   created() {
@@ -349,24 +349,27 @@ export default {
       this.reset();
       const noticeId = row.noticeId || this.ids;
       getNotice(noticeId).then((response) => {
+        this.title = "修改公告";
         let str = response.data.noticeContent;
-        const pattern = /\\"\/dev-api/;
-        const result = str.replace(pattern, this.IP);
-         
-        const pattern1 = /\\"/g;
-        const res = result.replace(pattern1, "");
-        
         this.form = response.data;
-        this.open = true;
-        this.title = "修改公告";
         this.$set(this.form, "noticeContent");
-        this.form.noticeContent = res;
-        
+
+        if (str) {
+          const pattern = /\\"\/dev-api/;
+          const result = str.replace(pattern, this.IP);
+
+          const pattern1 = /\\"/g;
+          const res = result.replace(pattern1, "");
+          this.form.noticeContent = res;
+        }
+
+        this.open = true;
+        this.form.noticeContent = response.data.noticeContent;
       });
     },
     /** 提交按钮 */
     submitForm: function () {
-      console.log(this.form.noticeContent);
+      
       this.$refs["form"].validate((valid) => {
         if (valid) {
           if (this.form.noticeId != undefined) {