Browse Source

今晚合并

dingxin 6 years ago
parent
commit
d081c05039

+ 17
- 3
CODE/smart-community/property-api/src/main/java/com/community/huiju/service/impl/TpActivityServiceImpl.java View File

23
 import org.springframework.beans.BeanUtils;
23
 import org.springframework.beans.BeanUtils;
24
 import org.springframework.beans.factory.annotation.Autowired;
24
 import org.springframework.beans.factory.annotation.Autowired;
25
 import org.springframework.stereotype.Service;
25
 import org.springframework.stereotype.Service;
26
+import org.springframework.transaction.annotation.Transactional;
26
 
27
 
27
 import java.time.LocalDateTime;
28
 import java.time.LocalDateTime;
28
 import java.util.List;
29
 import java.util.List;
98
     }
99
     }
99
 
100
 
100
     @Override
101
     @Override
102
+    @Transactional(rollbackFor = Exception.class)
101
     public ResponseBean addActivity(String parameter, UserElement userElement) {
103
     public ResponseBean addActivity(String parameter, UserElement userElement) {
102
 
104
 
103
         ResponseBean responseBean = new ResponseBean();
105
         ResponseBean responseBean = new ResponseBean();
106
         JSONArray jsonArray = jsonObject.getJSONArray("contentImg");
108
         JSONArray jsonArray = jsonObject.getJSONArray("contentImg");
107
         String [] contentImgArray = jsonArray.toArray(new String[]{});
109
         String [] contentImgArray = jsonArray.toArray(new String[]{});
108
         TpActivity tpActivity = jsonObject.toJavaObject(TpActivity.class);
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
         tpActivity.setCommunityId(userElement.getCommunityId());
117
         tpActivity.setCommunityId(userElement.getCommunityId());
110
         tpActivity.setUpdateDate(LocalDateTime.now());
118
         tpActivity.setUpdateDate(LocalDateTime.now());
111
         tpActivity.setUpdateUser(userElement.getId());
119
         tpActivity.setUpdateUser(userElement.getId());
149
     }
157
     }
150
 
158
 
151
     @Override
159
     @Override
160
+    @Transactional(rollbackFor = Exception.class)
152
     public ResponseBean updateActivity(String parameter, UserElement userElement) {
161
     public ResponseBean updateActivity(String parameter, UserElement userElement) {
153
         ResponseBean responseBean = new ResponseBean();
162
         ResponseBean responseBean = new ResponseBean();
154
         JSONObject jsonObject = JSONObject.parseObject(parameter);
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
         TpActivity selectTpActivity = tpActivityMapper.selectById(tpActivity.getId());
170
         TpActivity selectTpActivity = tpActivityMapper.selectById(tpActivity.getId());
161
         if (null == selectTpActivity) {
171
         if (null == selectTpActivity) {
201
         queryWrapper.eq("type", "activity");
211
         queryWrapper.eq("type", "activity");
202
         List<TdImages> imagesList = tdImagesMapper.selectList(queryWrapper);
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
         Map<String, Object> map = Maps.newHashMap();
217
         Map<String, Object> map = Maps.newHashMap();
205
         map.put("info", tpActivity);
218
         map.put("info", tpActivity);
206
-        map.put("contentImg", imagesList);
219
+        map.put("contentImg", stringList);
207
 
220
 
208
         responseBean.addSuccess(map);
221
         responseBean.addSuccess(map);
209
 
222
 
211
     }
224
     }
212
 
225
 
213
     @Override
226
     @Override
227
+    @Transactional(rollbackFor = Exception.class)
214
     public ResponseBean updateStatusInvalid(List<Integer> ids, UserElement userElement) {
228
     public ResponseBean updateStatusInvalid(List<Integer> ids, UserElement userElement) {
215
 
229
 
216
         ResponseBean responseBean = new ResponseBean();
230
         ResponseBean responseBean = new ResponseBean();

+ 0
- 19
VUECODE/smart-property-manage/src/views/social/activity/add/index.vue View File

105
     submitForm(formName) {
105
     submitForm(formName) {
106
       this.$refs[formName].validate((valid) => {
106
       this.$refs[formName].validate((valid) => {
107
         if (valid) {
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
           this.addActivity(1)
108
           this.addActivity(1)
128
         } else {
109
         } else {
129
           console.log('error submit!!')
110
           console.log('error submit!!')

+ 22
- 5
VUECODE/smart-property-manage/src/views/social/activity/edi/index.vue View File

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

+ 24
- 5
VUECODE/smart-property-manage/src/views/social/activity/index.vue View File

40
       <el-table-column
40
       <el-table-column
41
         prop="activityTitle"
41
         prop="activityTitle"
42
         label="标题"
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
       <el-table-column
48
       <el-table-column
45
         prop="viewCount"
49
         prop="viewCount"
46
         label="阅读量"
50
         label="阅读量"
116
       },
120
       },
117
       total: 0, // 数据总数
121
       total: 0, // 数据总数
118
       list: [],
122
       list: [],
123
+      deleteIds: [], // 选择的id集合
119
       listLoading: true // 表格加载框
124
       listLoading: true // 表格加载框
120
     }
125
     }
121
   },
126
   },
134
       this.listQuery.activityTitle = ''
139
       this.listQuery.activityTitle = ''
135
       this.activityList()
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
     handleSizeChange(val) {
149
     handleSizeChange(val) {
140
       console.log(`每页 ${val} 条`)
150
       console.log(`每页 ${val} 条`)
196
       this.$router.push({ name: 'activity-add' })
206
       this.$router.push({ name: 'activity-add' })
197
     },
207
     },
198
     ediActivity() { // 修改活动
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 View File

1
 <template>
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
 </template>
24
 </template>
4
 
25
 
5
 <script>
26
 <script>
9
 </script>
30
 </script>
10
 
31
 
11
 <style scoped>
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
 </style>
97
 </style>