dingxin 6 年 前
コミット
d081c05039

+ 17
- 3
CODE/smart-community/property-api/src/main/java/com/community/huiju/service/impl/TpActivityServiceImpl.java ファイルの表示

@@ -23,6 +23,7 @@ import com.google.common.collect.Maps;
23 23
 import org.springframework.beans.BeanUtils;
24 24
 import org.springframework.beans.factory.annotation.Autowired;
25 25
 import org.springframework.stereotype.Service;
26
+import org.springframework.transaction.annotation.Transactional;
26 27
 
27 28
 import java.time.LocalDateTime;
28 29
 import java.util.List;
@@ -98,6 +99,7 @@ public class TpActivityServiceImpl extends ServiceImpl<TpActivityMapper, TpActiv
98 99
     }
99 100
 
100 101
     @Override
102
+    @Transactional(rollbackFor = Exception.class)
101 103
     public ResponseBean addActivity(String parameter, UserElement userElement) {
102 104
 
103 105
         ResponseBean responseBean = new ResponseBean();
@@ -106,6 +108,12 @@ public class TpActivityServiceImpl extends ServiceImpl<TpActivityMapper, TpActiv
106 108
         JSONArray jsonArray = jsonObject.getJSONArray("contentImg");
107 109
         String [] contentImgArray = jsonArray.toArray(new String[]{});
108 110
         TpActivity tpActivity = jsonObject.toJavaObject(TpActivity.class);
111
+
112
+        if (contentImgArray.length <= 0 && (null == tpActivity.getActivityContent() || "".equals(tpActivity.getActivityContent())) {
113
+            responseBean.addError("活动内容描述 和 活动配图至少要存在一个!");
114
+            return responseBean;
115
+        }
116
+
109 117
         tpActivity.setCommunityId(userElement.getCommunityId());
110 118
         tpActivity.setUpdateDate(LocalDateTime.now());
111 119
         tpActivity.setUpdateUser(userElement.getId());
@@ -149,13 +157,15 @@ public class TpActivityServiceImpl extends ServiceImpl<TpActivityMapper, TpActiv
149 157
     }
150 158
 
151 159
     @Override
160
+    @Transactional(rollbackFor = Exception.class)
152 161
     public ResponseBean updateActivity(String parameter, UserElement userElement) {
153 162
         ResponseBean responseBean = new ResponseBean();
154 163
         JSONObject jsonObject = JSONObject.parseObject(parameter);
164
+        TpActivity tpActivity = jsonObject.toJavaObject(TpActivity.class);
155 165
 
156 166
         // 活动配图
157
-        String [] contentImgArray = (String[]) jsonObject.get("contentImg");
158
-        TpActivity tpActivity = jsonObject.toJavaObject(TpActivity.class);
167
+        JSONArray jsonArray = jsonObject.getJSONArray("contentImg");
168
+        String [] contentImgArray = jsonArray.toArray(new String[]{});
159 169
 
160 170
         TpActivity selectTpActivity = tpActivityMapper.selectById(tpActivity.getId());
161 171
         if (null == selectTpActivity) {
@@ -201,9 +211,12 @@ public class TpActivityServiceImpl extends ServiceImpl<TpActivityMapper, TpActiv
201 211
         queryWrapper.eq("type", "activity");
202 212
         List<TdImages> imagesList = tdImagesMapper.selectList(queryWrapper);
203 213
 
214
+        // 转换, 只保留 imageUrl 字段
215
+        List<String> stringList = imagesList.stream().map(e->new String(e.getImageUrl())).collect(Collectors.toList());
216
+
204 217
         Map<String, Object> map = Maps.newHashMap();
205 218
         map.put("info", tpActivity);
206
-        map.put("contentImg", imagesList);
219
+        map.put("contentImg", stringList);
207 220
 
208 221
         responseBean.addSuccess(map);
209 222
 
@@ -211,6 +224,7 @@ public class TpActivityServiceImpl extends ServiceImpl<TpActivityMapper, TpActiv
211 224
     }
212 225
 
213 226
     @Override
227
+    @Transactional(rollbackFor = Exception.class)
214 228
     public ResponseBean updateStatusInvalid(List<Integer> ids, UserElement userElement) {
215 229
 
216 230
         ResponseBean responseBean = new ResponseBean();

+ 0
- 19
VUECODE/smart-property-manage/src/views/social/activity/add/index.vue ファイルの表示

@@ -105,25 +105,6 @@ export default {
105 105
     submitForm(formName) {
106 106
       this.$refs[formName].validate((valid) => {
107 107
         if (valid) {
108
-          if (this.ruleForm.activityContent.length <= 0 && this.ruleForm.contentImg.length <= 0) {
109
-            this.$message.error('活动内容描述 和 活动配图至少要存在一个!')
110
-            return false
111
-          }
112
-          this.ruleForm.status = 1 // 发布状态
113
-          this.$store.dispatch('AddAnnouncement', this.ruleForm).then((res) => {
114
-            if (res.code === '0') {
115
-              this.$message({
116
-                message: res.message,
117
-                type: 'success'
118
-              })
119
-              this.$router.push({ name: 'activity-index' })
120
-              loading.close()
121
-              return
122
-            }
123
-            this.$message.error(res.message)
124
-          }).catch(() => {
125
-            console.log('error AddActivity')
126
-          })
127 108
           this.addActivity(1)
128 109
         } else {
129 110
           console.log('error submit!!')

+ 22
- 5
VUECODE/smart-property-manage/src/views/social/activity/edi/index.vue ファイルの表示

@@ -24,6 +24,7 @@
24 24
           :on-preview="handlePictureCardPreview"
25 25
           :on-remove="handleRemove"
26 26
           :on-success="handleSuccessContentImg"
27
+          :file-list="activityContentList"
27 28
           name="uploadFiles"
28 29
           action="http://localhost:8086/property-api/uploadimage"
29 30
           list-type="picture-card">
@@ -56,7 +57,6 @@
56 57
         </div>
57 58
       </el-form-item>
58 59
       <el-form-item style="display: flex; justify-content: center;">
59
-        <el-button @click="resetForm('ruleForm')">存为草稿</el-button>
60 60
         <el-button type="primary" @click="submitForm('ruleForm')">发布</el-button>
61 61
       </el-form-item>
62 62
     </el-form>
@@ -64,11 +64,13 @@
64 64
 </template>
65 65
 
66 66
 <script>
67
+
67 68
 export default {
68 69
   name: 'Index',
69 70
   data() {
70 71
     return {
71 72
       ruleForm: {
73
+        id: '',
72 74
         activityTitle: '',
73 75
         activityCarouselImg: '', // 轮播图
74 76
         activityContent: '', // 活动内容详细
@@ -78,6 +80,7 @@ export default {
78 80
         sort: 1, // 权重
79 81
         status: '' // 状态 0 是已作废 1 是已发布   2 是草稿 3 是已修改
80 82
       },
83
+      activityContentList: [], // 活动配图预览列表
81 84
       imageUrl: '', // 轮播图预览
82 85
       dialogVisible: false, // 活动配图, 默认不显示 (以单张为单位)
83 86
       dialogImageUrl: '', // 活动配图, 图片链接 (以单张为单位)
@@ -101,6 +104,9 @@ export default {
101 104
       }
102 105
     }
103 106
   },
107
+  mounted() {
108
+    this.getById(this.$route.params.id)
109
+  },
104 110
   methods: {
105 111
     submitForm(formName) {
106 112
       // 加载框
@@ -117,7 +123,7 @@ export default {
117 123
             return false
118 124
           }
119 125
           this.ruleForm.status = 1 // 发布状态
120
-          this.$store.dispatch('AddActivity', this.ruleForm).then((res) => {
126
+          this.$store.dispatch('UpdateActivity', this.ruleForm).then((res) => {
121 127
             if (res.code === '0') {
122 128
               this.$message({
123 129
                 message: res.message,
@@ -139,9 +145,6 @@ export default {
139 145
       // 关闭加载框
140 146
       loading.close()
141 147
     },
142
-    resetForm(formName) {
143
-      this.$refs[formName].resetFields()
144
-    },
145 148
     handleAvatarSuccess(res, file) { // 轮播图上传回调
146 149
       this.ruleForm.activityCarouselImg = res.data[0]
147 150
       this.imageUrl = URL.createObjectURL(file.raw)
@@ -177,7 +180,21 @@ export default {
177 180
     sortHandleChange(value) { // 权重值
178 181
       this.ruleForm.sort = value
179 182
       console.log(value)
183
+    },
184
+    getById(id) { // 根据ID获取活动信息
185
+      this.$store.dispatch('ActivityById', id).then((res) => {
186
+        const resData = res.data
187
+        this.imageUrl = resData.info.activityCarouselImg
188
+        this.ruleForm = resData.info
189
+
190
+        const imgArr = resData.contentImg
191
+        this.ruleForm.contentImg = imgArr
192
+        for (let i = 0; i < imgArr.length; i++) {
193
+          this.activityContentList.push({ url: imgArr[i] })
194
+        }
195
+      })
180 196
     }
197
+
181 198
   }
182 199
 }
183 200
 </script>

+ 24
- 5
VUECODE/smart-property-manage/src/views/social/activity/index.vue ファイルの表示

@@ -40,7 +40,11 @@
40 40
       <el-table-column
41 41
         prop="activityTitle"
42 42
         label="标题"
43
-        align="center"/>
43
+        align="center">
44
+        <template slot-scope="scope">
45
+          <span style="color: #409EFF;cursor: pointer" @click="infoActivity(scope.row.id)" >{{ scope.row.activityTitle }}</span>
46
+        </template>
47
+      </el-table-column>
44 48
       <el-table-column
45 49
         prop="viewCount"
46 50
         label="阅读量"
@@ -116,6 +120,7 @@ export default {
116 120
       },
117 121
       total: 0, // 数据总数
118 122
       list: [],
123
+      deleteIds: [], // 选择的id集合
119 124
       listLoading: true // 表格加载框
120 125
     }
121 126
   },
@@ -134,7 +139,12 @@ export default {
134 139
       this.listQuery.activityTitle = ''
135 140
       this.activityList()
136 141
     },
137
-    handleSelectionChange(val) { // 表格选择
142
+    handleSelectionChange(data) { // 表格选择
143
+      // 设置为 空
144
+      this.deleteIds = []
145
+      for (let i = 0; i < data.length; i++) {
146
+        this.deleteIds.push(data[i].id)
147
+      }
138 148
     },
139 149
     handleSizeChange(val) {
140 150
       console.log(`每页 ${val} 条`)
@@ -196,10 +206,19 @@ export default {
196 206
       this.$router.push({ name: 'activity-add' })
197 207
     },
198 208
     ediActivity() { // 修改活动
199
-      this.$router.push({ name: 'activity-edi' })
209
+      const ids = this.deleteIds
210
+      if (ids.length > 1) {
211
+        this.$message.error('只能选择一行数据进行修改!')
212
+        return
213
+      }
214
+      if (ids < 1) {
215
+        this.$message.error('请选择一行数据进行修改!')
216
+        return
217
+      }
218
+      this.$router.push({ name: 'activity-edi', params: { id: ids[0] }})
200 219
     },
201
-    infoActivity() { // 查看活动
202
-      this.$router.push({ name: 'activity-info' })
220
+    infoActivity(id) { // 查看活动
221
+      this.$router.push({ name: 'activity-info', params: { id: id }})
203 222
     }
204 223
   }
205 224
 }

+ 86
- 2
VUECODE/smart-property-manage/src/views/social/activity/info/index.vue ファイルの表示

@@ -1,5 +1,26 @@
1 1
 <template>
2
-  <div>查看</div>
2
+  <div id="root">
3
+    <span class="activityTile">活动标题</span>
4
+    <img src="http://jingcheng-h5temp.oss-cn-shanghai.aliyuncs.com/1543484412841.png" width="700" height="500">
5
+    <div class="activityContext">
6
+      尊敬的业主/住户:
7
+      为丰富小区入住业主/住户的社区文化活动,增进各业主/住户间的联系,现物业服务中心特协调银城旗下分公司南京锦城佳业营销策划有限公司举办为期两个月的暑期露天电影节活动!详情请关注通知及各幢大堂的公告通知,下周六11月24日晚将进行第一场活动!更多细节敬请期待!
8
+    </div>
9
+    <div class="activityContextImg">
10
+      <img src="http://jingcheng-h5temp.oss-cn-shanghai.aliyuncs.com/1543484412841.png" width="700" height="500">
11
+      <img src="http://jingcheng-h5temp.oss-cn-shanghai.aliyuncs.com/1543484412841.png" width="700" height="500">
12
+    </div>
13
+    <div class="progress">
14
+      <div class="text-progress">
15
+        <span class="people-number">已报名人数100</span>
16
+        <div class="outer-layer"/>
17
+        <div class="inner-layer"/>
18
+      </div>
19
+      <div class="circular"/>
20
+      <div class="people-limit">限制100人</div>
21
+      <el-button type="primary" style="float: left;">查看报名名单</el-button>
22
+    </div>
23
+  </div>
3 24
 </template>
4 25
 
5 26
 <script>
@@ -9,5 +30,68 @@ export default {
9 30
 </script>
10 31
 
11 32
 <style scoped>
12
-
33
+#root {
34
+  display: flex;
35
+  flex-flow: column;
36
+  width: 700px;
37
+  margin-top: 50px;
38
+  margin-left: auto;
39
+  margin-right: auto;
40
+}
41
+.activityTile{
42
+  text-align: center;
43
+  font-size: 30px;
44
+  margin-bottom: 10px;
45
+}
46
+.activityContext{
47
+  margin-top: 20px;
48
+  margin-bottom: 20px;
49
+  font-size: 20px;
50
+  justify-items: center;
51
+}
52
+.progress {
53
+  display: flex;
54
+  justify-content: space-between;
55
+  margin-top: 20px;
56
+  margin-bottom: 20px;
57
+}
58
+.text-progress {
59
+  width: 500px;
60
+  float: left;
61
+  align-content: center;
62
+  position: absolute;
63
+  margin-top: 12px;
64
+}
65
+.people-number {
66
+  position: relative;
67
+  margin-left: 180px;
68
+}
69
+.outer-layer {
70
+  background-color: gainsboro;
71
+  height: 3px;
72
+  width: 450px;
73
+  margin-top: -10px;
74
+  position: relative;
75
+}
76
+.inner-layer {
77
+  background-color: aquamarine;
78
+  height: 6px;
79
+  width: 100px;
80
+  position: relative;
81
+  margin-top: -4px;
82
+}
83
+.circular {
84
+  border: 1px #001528 solid;
85
+  border-radius: 10px;
86
+  /*background-color: chartreuse;*/
87
+  width: 20px;
88
+  height: 20px;
89
+  position: relative;
90
+  margin-left: 452px;
91
+  margin-top: 11px;
92
+  float: left;
93
+}
94
+.people-limit {
95
+  margin-top: 13px;
96
+}
13 97
 </style>