wangming 2 сар өмнө
parent
commit
bad0103f53

+ 64 - 2
src/pagesA/homeManage/homeManage.vue

@@ -8,7 +8,7 @@
                 <view class="itemOption"
                 <view class="itemOption"
                     ><view class="imgItem" @click="deleteGroup(item)"
                     ><view class="imgItem" @click="deleteGroup(item)"
                         ><image src="../../static/delete.png"></image></view
                         ><image src="../../static/delete.png"></image></view
-                    ><view class="imgItem"
+                    ><view class="imgItem" @click="editGroup(item)"
                         ><image src="../../static/edit.png"></image></view
                         ><image src="../../static/edit.png"></image></view
                     ><view class="imgItem"
                     ><view class="imgItem"
                         ><image src="../../static/shareTwo.png"></image></view
                         ><image src="../../static/shareTwo.png"></image></view
@@ -58,7 +58,14 @@
                         style="width: 100%"
                         style="width: 100%"
                         @click="$event.stopPropagation()"
                         @click="$event.stopPropagation()"
                     />
                     />
-                    <button class="btn link-btn" @click="sureAddGroup()">
+                    <button
+                        class="btn link-btn"
+                        @click="sureAddGroup()"
+                        v-if="!editFlag"
+                    >
+                        <text>确定</text>
+                    </button>
+                    <button class="btn link-btn" @click="sureEditGroup()">
                         <text>确定</text>
                         <text>确定</text>
                     </button>
                     </button>
                 </view>
                 </view>
@@ -75,6 +82,7 @@ export default {
             groupName: "",
             groupName: "",
             userId: uni.getStorageSync("userId"),
             userId: uni.getStorageSync("userId"),
             groupList: [],
             groupList: [],
+            editFlag: false,
         };
         };
     },
     },
     methods: {
     methods: {
@@ -82,6 +90,14 @@ export default {
             this.addGroupModle = true;
             this.addGroupModle = true;
         },
         },
         sureAddGroup() {
         sureAddGroup() {
+            if (this.groupName.trim() == "") {
+                uni.showToast({
+                    title: "请输入家庭名称",
+                    icon: "none",
+                    duration: 1500,
+                });
+                return;
+            }
             let groupAddParams = {
             let groupAddParams = {
                 userId: this.userId,
                 userId: this.userId,
                 groupName: this.groupName,
                 groupName: this.groupName,
@@ -156,6 +172,52 @@ export default {
                 },
                 },
             });
             });
         },
         },
+        editGroup(item) {
+            this.addGroupModle = true;
+            this.editFlag = true;
+            this.groupName = item.groupName;
+        },
+        sureEditGroup() {
+            if (this.groupName.trim() == "") {
+                uni.showToast({
+                    title: "请输入家庭名称",
+                    icon: "none",
+                    duration: 1500,
+                });
+                return;
+            }
+            let groupEditParams = {
+                groupUuid: this.groupList.find(
+                    (g) => g.groupName === this.groupName
+                ).groupUuid,
+                groupName: this.groupName,
+            };
+            this.$http
+                .post("wap/group/updateGroup", groupEditParams, {
+                    header: {
+                        "Content-Type": "application/json;charset=UTF-8",
+                    },
+                })
+                .then((res) => {
+                    if (res.data.code == 200) {
+                        uni.showToast({
+                            title: "编辑家庭成功",
+                            icon: "success",
+                            duration: 1500,
+                        });
+                        this.addGroupModle = false;
+                        this.groupName = "";
+                        this.editFlag = false;
+                    } else {
+                        uni.showToast({
+                            title: res.data.message,
+                            icon: "none",
+                            duration: 1500,
+                        });
+                    }
+                    this.getdevList();
+                });
+        },
     },
     },
     onShow() {
     onShow() {
         this.getdevList();
         this.getdevList();