Browse Source

修复日程修改完数据不变化,删除备注无效果的bug

PrettyCat1 1 year ago
parent
commit
879070bea8
1 changed files with 23 additions and 13 deletions
  1. 23 13
      vue_project/src/components/indexBody.vue

+ 23 - 13
vue_project/src/components/indexBody.vue

@@ -2,7 +2,7 @@
   <FullCalendar :options="calendarOptions" class="calendar" id="calendar" />
 
   <!-- 备注修改框 -->
-  <el-dialog title="修改订单" center v-model="Visible">
+  <el-dialog title="添加备注" center v-model="Visible">
     <el-form :model="form" label-width="auto" style="max-width: 600px">
       <el-form-item label="备注名称">
         <el-input v-model="form.name" />
@@ -259,15 +259,16 @@ export default {
         allowHTML: true,
       });
     },
-    // 备注日程修改
+    // 备注日程修改 -- 改 删
     remarkControl(e) {
       this.GetInfo = e;
+      console.log(this.GetInfo);
       this.changeInfo = true;
     },
     // 备注日程修改取消
-    operateCancel(){
+    operateCancel() {
       this.GetInfo = "";
-      this.changeInfo = false
+      this.changeInfo = false;
     },
     // 拖拽表格时获取点击的起止时间
     deleteInfo(e) {
@@ -280,10 +281,18 @@ export default {
     },
     // 确认添加备注事件
     confirm() {
+      console.log(this.GetInfo.event.id);
       this.Visible = false;
       // 将备注加入日历中
+      let data = this.GetInfo == null || this.GetInfo == "" ? this.form.date[0] : this.GetInfo.event.id
+      const idx = this.calendarOptions.events.findIndex(
+        (item) => item.id == data
+      );
+      if (idx>-1) {
+        this.calendarOptions.events.splice(idx, 1);
+      }
       this.calendarOptions.events.push({
-        id: this.GetInfo == null || this.GetInfo =="" ? this.form.date[0] : this.GetInfo.event.id,
+        id:data,
         title: this.form.name,
         start: this.form.date[0],
         end: this.form.date[1],
@@ -295,7 +304,7 @@ export default {
         resource: "",
         desc: "",
       };
-      this.GetInfo=""
+      this.GetInfo = "";
     },
     // 取消添加备注
     cancel() {
@@ -310,6 +319,7 @@ export default {
     },
     // 进行操作选中
     operate(value) {
+      console.log(this.GetInfo.event.id);
       this.changeInfo = false;
       if (value == "delete") {
         this.$confirm("是否删除当前备注, 是否继续?", "提示", {
@@ -318,19 +328,19 @@ export default {
           type: "warning",
         })
           .then(() => {
-            this.GetInfo=""
-            console.log(this.calendarOptions.events);
+            console.log(this.GetInfo.event.id);
             const idx = this.calendarOptions.events.findIndex(
               (item) => item.id == this.GetInfo.event.id
             );
+            this.GetInfo = "";
             this.calendarOptions.events.splice(idx, 1);
             this.$message({
-              type: "error",
+              type: "success",
               message: "已删除",
             });
           })
           .catch(() => {
-            this.GetInfo=""
+            this.GetInfo = "";
             this.$message({
               type: "info",
               message: "已取消删除",
@@ -340,12 +350,12 @@ export default {
         this.Visible = true;
         this.form = {
           name: this.GetInfo.event.title,
-          date: [this.GetInfo.event.startStr,this.GetInfo.event.endStr],
+          date: [this.GetInfo.event.startStr, this.GetInfo.event.endStr],
           type: [],
           resource: "",
-          desc: ""
+          desc: "",
         };
-
+        console.log(this.GetInfo.event.id);
       }
     },
   },