Browse Source

管理后台

licailing 4 years ago
parent
commit
507bc7513d

+ 6 - 2
src/main/java/com/izouma/nineth/web/ShowroomController.java

@@ -72,8 +72,12 @@ public class ShowroomController extends BaseController {
 
         Map<Long, Long> finalLikesMap = likesMap;
         return all.map(showroom -> {
-            collect.get(showroom.getId()).sort(Comparator.comparingInt(ShowCollection::getSort));
-            showroom.setCollections(collect.get(showroom.getId()));
+            List<ShowCollection> collections = collect.get(showroom.getId());
+            if (CollUtil.isNotEmpty(collections)) {
+                collections.sort(Comparator.comparingInt(ShowCollection::getSort));
+                showroom.setCollections(collections);
+            }
+
             showroom.setLiked(ObjectUtils.isNotEmpty(finalLikesMap.get(showroom.getId())));
             return showroom;
         });

+ 25 - 9
src/main/vue/src/views/company/CompanyRoomEdit.vue

@@ -69,13 +69,21 @@
                     <el-form-item prop="collections" label="藏品">
                         <el-table :data="formData.collections">
                             <el-table-column type="index" label="#"></el-table-column>
-                            <el-table-column prop="collection" label="ID" width="80"></el-table-column>
-                            <el-table-column prop="pic" label="图"></el-table-column>
+                            <el-table-column prop="collectionId" label="ID" width="110"></el-table-column>
+                            <el-table-column prop="pic" label="图">
+                                <template slot-scope="{ row }">
+                                    <el-image
+                                        style="width: 30px; height: 30px"
+                                        :src="row.pic"
+                                        fit="cover"
+                                    ></el-image>
+                                </template>
+                            </el-table-column>
                             <el-table-column width="80" align="center">
                                 <template v-slot="{ $index }">
-                                    <el-button type="danger" plain @click="delCollection($index)" size="mini">
+                                    <el-link type="danger" plain @click="delCollection($index)" size="mini">
                                         删除
-                                    </el-button>
+                                    </el-link>
                                 </template>
                             </el-table-column>
                         </el-table>
@@ -240,11 +248,19 @@ export default {
                 .then(() => {
                     if (!this.formData.collections.find(i => i.id === this.collectionId)) {
                         let data = this.collections.find(i => i.id === this.collectionId);
-                        this.formData.collections.push(item => {
-                            item.showroomId = this.formData.id;
-                            item.collectionId = data.id;
-                        });
-                        // console.log(this.formData.collections);
+                        if (data.pic[0].type == 'video/mp4') {
+                            this.formData.collections.push({
+                                showroomId: this.formData.id,
+                                collectionId: data.id,
+                                pic: data.pic[0].thumb
+                            });
+                        } else {
+                            this.formData.collections.push({
+                                showroomId: this.formData.id,
+                                collectionId: data.id,
+                                pic: data.pic[0].url
+                            });
+                        }
                         this.showCollectionDialog = false;
                     } else {
                         this.$message.error('请勿重复添加');