licailing 3 лет назад
Родитель
Сommit
95c6608738

+ 3 - 3
src/main/java/com/izouma/nineth/service/ShowroomService.java

@@ -142,9 +142,9 @@ public class ShowroomService {
         }
         int maxCollection = 1;
         if ("COMPANY".equals(type)) {
-            if (showroomRepo.findByUserIdAndType(user.getId(), "COMPANY").isPresent()) {
-                throw new BusinessException("已创建过展厅");
-            }
+//            if (showroomRepo.findByUserIdAndType(user.getId(), "COMPANY").isPresent()) {
+//                throw new BusinessException("已创建过展厅");
+//            }
             maxCollection = sysConfigService.getInt("max_collection");
         }
 

+ 54 - 5
src/main/vue/src/views/company/CompanyRoomEdit.vue

@@ -84,7 +84,9 @@
                                 </template>
                             </el-table-column>
                         </el-table>
-                        <el-button @click="addCollection" size="mini">添加</el-button>
+                        <el-button @click="addCollection" size="mini" v-if="formData.maxCollection > collectionSize"
+                            >添加</el-button
+                        >
                     </el-form-item>
                     <div class="inline-wrapper">
                         <el-form-item prop="heats" label="热力值">
@@ -133,6 +135,15 @@
                     <el-button type="primary" size="mini" @click="saveCollection">确定</el-button>
                 </div>
             </el-dialog>
+
+            <el-dialog title="添加盲盒" :visible.sync="showBoxDialog" width="500px">
+                <div style="margin-bottom: 10px">输入盲盒ID</div>
+                <el-input placeholder="请输入盲盒ID" v-model="boxId" style="width: 220px"></el-input>
+                <div slot="footer">
+                    <el-button @click="showBoxDialog = false">取消</el-button>
+                    <el-button type="primary" size="mini" @click="saveBox">确定</el-button>
+                </div>
+            </el-dialog>
         </div>
     </div>
 </template>
@@ -146,6 +157,7 @@ export default {
                 .get('showroom/get/' + this.$route.query.id)
                 .then(res => {
                     this.formData = res;
+                    this.collectionSize = res.collections.length;
                 })
                 .catch(e => {
                     console.log(e);
@@ -190,7 +202,10 @@ export default {
             settings: [],
             collections: [],
             showCollectionDialog: false,
-            collectionId: ''
+            collectionId: '',
+            showBoxDialog: false,
+            boxId: '',
+            collectionSize: 0
         };
     },
     computed: {
@@ -256,10 +271,15 @@ export default {
             this.formData.showroomBg = data.description;
         },
         addCollection() {
-            if (this.formData.collections.length >= this.formData.maxCollection) {
+            if (this.collectionSize >= this.formData.maxCollection) {
                 this.$message.error('最多只能添加' + this.formData.maxCollection + '个!');
             } else {
-                this.showCollectionDialog = true;
+                if (this.formData.type === 'COMPANY_BOX') {
+                    this.showBoxDialog = true;
+                } else {
+                    this.showCollectionDialog = true;
+                }
+
                 if (this.$refs.collectionForm) {
                     this.$nextTick(() => {
                         this.$refs.collectionForm.clearValidate();
@@ -269,8 +289,9 @@ export default {
         },
         delCollection(index) {
             this.formData.collections.splice(index, 1);
+            this.collectionSize = this.formData.collections.length;
         },
-        saveCollection(res) {
+        saveCollection() {
             this.$refs.collectionForm
                 .validate()
                 .then(() => {
@@ -292,12 +313,40 @@ export default {
                             });
                         }
                         this.showCollectionDialog = false;
+                        this.collectionSize = this.formData.collections.length;
                     } else {
                         this.$message.error('请勿重复添加');
                     }
                 })
                 .catch(() => {});
         },
+        saveBox() {
+            this.$http
+                .get('collection/get/' + this.boxId)
+                .then(res => {
+                    if (res.type !== 'BLIND_BOX') {
+                        this.$message.error('此为藏品ID,请添加盲盒ID');
+                        return;
+                    }
+                    this.formData.collections.push({
+                        showroomId: this.formData.id,
+                        collectionId: res.id,
+                        pic: res.pic[0].url,
+                        name: res.name
+                    });
+                    this.collectionSize = this.formData.collections.length;
+                    this.showBoxDialog = false;
+                })
+                .catch(e => {
+                    if (e.error === '无记录') {
+                        this.$message.error('没有此盲盒,请核对盲盒ID');
+                    } else {
+                        this.$message.error(e.error);
+                    }
+                    this.showBoxDialog = false;
+                    console.log(e);
+                });
+        },
         preview() {
             let url = '/9th/hall?id=' + this.formData.id;
             window.open(url);