dingxin 6 jaren geleden
bovenliggende
commit
0d8cc22e84

+ 14
- 0
CODE/smart-community/property-api/src/main/java/com/community/huiju/controller/TpAnnouncementController.java Bestand weergeven

@@ -36,6 +36,7 @@ public class TpAnnouncementController extends BaseController {
36 36
         ResponseBean tpAnnouncementList=tpAnnouncementService.tpAnnouncemenList(paramets,userElement.getCommunityId());
37 37
         return tpAnnouncementList;
38 38
     }
39
+
39 40
     @ApiOperation(value = "添加公告",nickname ="添加公告")
40 41
     @ApiImplicitParams({
41 42
             @ApiImplicitParam(paramType = "body", dataType = "String", name = "paramets", value ="announcementTitle:公告标题," +
@@ -47,6 +48,7 @@ public class TpAnnouncementController extends BaseController {
47 48
         ResponseBean  addAnnouncement= tpAnnouncementService.addAnnouncement(paramets,userElement.getCommunityId(),userElement.getId());
48 49
         return addAnnouncement;
49 50
     }
51
+
50 52
     @ApiOperation(value = "查询公告详情",nickname ="查询公告详情")
51 53
     @ApiImplicitParams({
52 54
             @ApiImplicitParam(paramType = "body", dataType = "String", name = "paramets", value ="id:公告id")})
@@ -56,4 +58,16 @@ public class TpAnnouncementController extends BaseController {
56 58
         return tpAnnouncement;
57 59
     }
58 60
 
61
+    @ApiOperation(value = "查询公告详情",nickname ="查询公告详情")
62
+    @ApiImplicitParams({
63
+            @ApiImplicitParam(paramType = "body", dataType = "String", name = "paramets", value ="id:公告id,announcementTitle:公告标题," +
64
+                    "announcementCarouselImg:轮播图,announcementContent:内容,contentImg:内容图片,sort:权重值,status:'0 是已作废 1 是已发布   2 是草稿 3 是已修改',")})
65
+    @RequestMapping(value="/updateAnnouncement",method = RequestMethod.POST)
66
+    public ResponseBean updateAnnouncement(@RequestBody String paramets,HttpSession session){
67
+        UserElement userElement = getUserElement(session);
68
+        ResponseBean tpAnnouncement= tpAnnouncementService.updateAnnouncement(paramets,userElement.getCommunityId(),userElement.getId());
69
+        return tpAnnouncement;
70
+    }
71
+
72
+
59 73
 }

+ 7
- 0
CODE/smart-community/property-api/src/main/java/com/community/huiju/service/TpAnnouncementService.java Bestand weergeven

@@ -32,4 +32,11 @@ public interface TpAnnouncementService extends IService<TpAnnouncement> {
32 32
      * @return
33 33
      */
34 34
     ResponseBean announcementById(String paramets);
35
+
36
+    /**
37
+     * 添加公告
38
+      * @param paramets
39
+     * @return
40
+     */
41
+    ResponseBean updateAnnouncement(String paramets,Integer communityId,Integer userId);
35 42
 }

+ 38
- 1
CODE/smart-community/property-api/src/main/java/com/community/huiju/service/impl/TpAnnouncementServiceImpl.java Bestand weergeven

@@ -124,7 +124,6 @@ private  TpAnnouncementMapper tpAnnouncementMapper;
124 124
             tdImages.setCreateUser(userId);
125 125
             imagesMapper.insert(tdImages);
126 126
         }
127
-            //添加内容图片
128 127
             return response;
129 128
     }
130 129
         @Override
@@ -148,4 +147,42 @@ private  TpAnnouncementMapper tpAnnouncementMapper;
148 147
             response.addSuccess(map);
149 148
             return response;
150 149
         }
150
+
151
+    @Override
152
+    public ResponseBean updateAnnouncement(String paramets,Integer communityId,Integer userId) {
153
+                  ResponseBean response= new ResponseBean();
154
+         TpAnnouncement tpAnnouncement = JSONObject.parseObject(paramets, TpAnnouncement.class);
155
+//                        String announcementimg=tpAnnouncement.getAnnouncementCarouselImg();
156
+//                        tpAnnouncement.setAnnouncementCarouselImg( "".equals(announcementimg)?null:announcementimg);
157
+                        tpAnnouncement.setCommunityId(communityId);
158
+                        tpAnnouncement.setCreateDate(new Date());
159
+                        tpAnnouncement.setUpdateUser(userId);
160
+                        tpAnnouncement.setCreateUser(userId);
161
+                        tpAnnouncement.setUpdateDate(new Date());
162
+                        tpAnnouncementMapper.updateTpAnnouncement(tpAnnouncement);
163
+
164
+        JSONObject parseObject = JSONObject.parseObject(paramets);
165
+        //内容包含多个图转数组
166
+        JSONArray contentImg = parseObject.getJSONArray("contentImg");
167
+        Integer tdImagesUuid = parseObject.getInteger("id");
168
+        String[] contentImgArray = contentImg.toArray(new String[]{});
169
+        //修改图片时删除原来图片
170
+        if (contentImg.size()!=0){
171
+        QueryWrapper<TdImages> queryWrapper = new QueryWrapper<>();
172
+        queryWrapper.lambda().eq(TdImages::getUuid,tdImagesUuid);
173
+        queryWrapper.lambda().eq(TdImages::getType,"announcement");
174
+        imagesMapper.delete(queryWrapper);
175
+
176
+        for (String img:contentImgArray){
177
+            TdImages tdImages = new TdImages();
178
+            tdImages.setImageUrl(img);
179
+            tdImages.setType("announcement");
180
+            tdImages.setUuid(tpAnnouncement.getId());
181
+            tdImages.setCreateTime(LocalDateTime.now());
182
+            tdImages.setCreateUser(userId);
183
+            imagesMapper.insert(tdImages);
184
+            }
185
+        }
186
+        return response;
187
+    }
151 188
 }

+ 16
- 0
VUECODE/smart-property-manage/src/api/announcement.js Bestand weergeven

@@ -38,3 +38,19 @@ export function announcementById(data) {
38 38
     }
39 39
   })
40 40
 }
41
+// 修改公告
42
+export function updateannouncement(data) {
43
+  return request({
44
+    url: '/updateAnnouncement',
45
+    method: 'post',
46
+    data: {
47
+      id: data.id,
48
+      announcementTitle: data.announcementTitle,
49
+      announcementCarouselImg: data.announcementCarouselImg,
50
+      contentImg: data.contentImg,
51
+      announcementContent: data.announcementContent,
52
+      sort: data.sort,
53
+      status: data.status
54
+    }
55
+  })
56
+}

+ 13
- 1
VUECODE/smart-property-manage/src/store/modules/announcement.js Bestand weergeven

@@ -1,4 +1,4 @@
1
-import { listAnnouncement, addAnnouncement, announcementById } from '@/api/announcement'
1
+import { listAnnouncement, addAnnouncement, announcementById, updateannouncement } from '@/api/announcement'
2 2
 
3 3
 const announcement = {
4 4
   actions: {
@@ -37,6 +37,18 @@ const announcement = {
37 37
           reject(error)
38 38
         })
39 39
       })
40
+    },
41
+    /**
42
+     * 根据id查询公告
43
+     */
44
+    Updateannouncement({ commit }, data) {
45
+      return new Promise((resolve, reject) => {
46
+        updateannouncement(data).then(response => {
47
+          resolve(response)
48
+        }).catch(error => {
49
+          reject(error)
50
+        })
51
+      })
40 52
     }
41 53
   }
42 54
 }

+ 11
- 31
VUECODE/smart-property-manage/src/views/social/announcement/edit.vue Bestand weergeven

@@ -38,7 +38,6 @@
38 38
         <el-input-number v-model="ruleForm.sort" :min="1" :max="10" label="权重值" @change="sortHandleChange"/>
39 39
       </el-form-item>
40 40
       <el-form-item>
41
-        <el-button @click="resetForm('ruleForm','2')">存为草稿</el-button>
42 41
         <el-button type="primary" @click="submitForm('ruleForm','1')">发布</el-button>
43 42
       </el-form-item>
44 43
     </el-form>
@@ -78,7 +77,6 @@ export default {
78 77
     }
79 78
   },
80 79
     mounted() {
81
-      console.log("123")
82 80
     this.getById(this.$route.params.id)
83 81
   },
84 82
   methods: {
@@ -95,10 +93,11 @@ export default {
95 93
         if (valid) {
96 94
           if (this.ruleForm.announcementContent.length <= 0 && this.ruleForm.contentImg.length <= 0) {
97 95
             this.$message.error('活动内容描述 和 活动配图至少要存在一个!')
96
+            loading.close()
98 97
             return 
99 98
           }
100 99
           this.ruleForm.status = status // 发布状态
101
-          this.$store.dispatch('AddAnnouncement', this.ruleForm).then((res) => {
100
+          this.$store.dispatch('Updateannouncement', this.ruleForm).then((res) => {
102 101
             if (res.code === '0') {
103 102
               this.$message({
104 103
                 message: res.message,
@@ -119,10 +118,8 @@ export default {
119 118
           return false
120 119
         }
121 120
       })
122
-    },
123
-    resetForm(formName,status) {
124
-      console.log(status)
125
-      this.submitForm(formName,status)
121
+       // 关闭加载框
122
+      loading.close()
126 123
     },
127 124
     handleAvatarSuccess(res, file) { // 轮播图上传回调
128 125
       this.ruleForm.announcementCarouselImg = res.data[0]
@@ -161,34 +158,17 @@ export default {
161 158
       console.log(value)
162 159
     },
163 160
     getById(id) { // 页面初始化后调用此方法根据ID获取活动信息
164
-     console.log("id:",id)
165 161
       this.ruleForm.id=this.$route.params.id
166
-      console.log("123id:",this.ruleForm.id)
167 162
       this.$store.dispatch('AnnouncementById', this.ruleForm).then((res) => {
168
-        const resData = res.data
169
-        this.ruleForm.announcementTitle=resData.tpAnnouncement.announcementTitle// 标题
170
-        this.ruleForm.announcementContent=resData.tpAnnouncement.announcementContent// 内容
171
-        this.Urlimage=resData.tpAnnouncement.announcementCarouselImg // 轮播图
172
-        this.ruleForm.sort=resData.tpAnnouncement.sort// 权重
163
+      const resData = res.data
164
+      this.ruleForm.announcementTitle=resData.tpAnnouncement.announcementTitle// 标题
165
+      this.ruleForm.announcementContent=resData.tpAnnouncement.announcementContent// 内容
166
+      this.Urlimage=resData.tpAnnouncement.announcementCarouselImg // 轮播图
167
+      this.ruleForm.sort=resData.tpAnnouncement.sort// 权重
173 168
         //多张图片进行遍历
174
-        const imgArr=resData.studentList
175
-        console.log("imgArr:",imgArr)
176
-        this.ruleForm.contentImg=imgArr// 内容图片
177
-        for (let i = 0; i < imgArr.length; i++) {
178
-          // this.contentImgList=resData.studentList[i].imageUrl
179
-          console.log("imgArr2.:",imgArr)
169
+        for (let i = 0; i < resData.studentList.length; i++) {
170
+          this.contentImgList.push({ url: resData.studentList[i].imageUrl })
180 171
         }
181
-        // console.log("this.ruleForm.contentImg",imgArr)
182
-        // const resData = res.data
183
-        // this.imageUrl = resData.info.activityCarouselImg
184
-        // this.ruleForm = resData.info
185
-
186
-        // const imgArr = resData.contentImg
187
-        // this.ruleForm.contentImg = imgArr
188
-        //多张图片进行遍历
189
-        // for (let i = 0; i < imgArr.length; i++) {
190
-        //   this.activityContentList.push({ url: imgArr[i] })
191
-        // }
192 172
       })
193 173
     }
194 174
   }