Bladeren bron

:memo: 限制分类图片数量、增加商品视频

Twelve615 1 jaar geleden
bovenliggende
commit
d8c58343a4

+ 1 - 1
jlsb-vue/src/views/aa/modules/AaCommodityFlModal.vue

@@ -11,7 +11,7 @@
     <a-spin :spinning="confirmLoading">
       <a-form-model ref="form" :model="model" :rules="validatorRules">
         <a-form-model-item label="分类图片" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="pic">
-          <j-image-upload isMultiple  v-model="model.pic" ></j-image-upload>
+          <j-image-upload isMultiple :number="2"  v-model="model.pic" ></j-image-upload>
         </a-form-model-item>
         <a-form-model-item label="分类名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="name">
           <a-input v-model="model.name" placeholder="请输入分类名称" ></a-input>

+ 15 - 2
jlsb-vue/src/views/aa/modules/AaCommodityForm.vue

@@ -18,17 +18,22 @@
               <a-input v-model="model.nameGerman" placeholder="请输入名称"  ></a-input>
             </a-form-model-item>
           </a-col>-->
-          <a-col :span="24">
+<!--          <a-col :span="24">
             <a-form-model-item label="防伪码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="securityCode">
               <a-input v-model="model.securityCode" placeholder="请输入防伪码"  ></a-input>
             </a-form-model-item>
-          </a-col>
+          </a-col>-->
           <a-col :span="24">
             <a-form-model-item label="图片" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="pic">
               <j-image-upload isMultiple  v-model="model.pic" ></j-image-upload>
             </a-form-model-item>
           </a-col>
           <a-col :span="24">
+            <a-form-model-item label="视频" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="video">
+              <j-upload v-model="model.video" :reNewFile="true" :multiple="false" :beforeUpload="this.beforeUploadHandler" ></j-upload>
+            </a-form-model-item>
+          </a-col>
+          <a-col :span="24">
             <a-form-model-item label="价格" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="price">
               <a-input-number v-model="model.price" placeholder="请输入价格" style="width: 100%" />
             </a-form-model-item>
@@ -211,6 +216,14 @@
 
         })
       },
+      beforeUploadHandler(file) {
+        let fileType = file.type;
+        if(fileType.indexOf('video')<0){
+          this.$message.warning('请上传视频文件');
+          return false;
+        }
+        return true;
+      },
     }
   }
 </script>

+ 17 - 2
jlsb/jeecg-boot-module-system/src/main/java/org/jeecg/modules/aa/controller/APIIndexenterController.java

@@ -316,6 +316,7 @@ public class APIIndexenterController {
         try {
             AaCommodity byId = aaCommodityService.getById( aaCommodityDTO.getId() );
             byId.setPic( host + "/sys/common/static/"+byId.getPic() );
+            byId.setVideo( host + "/sys/common/static/"+byId.getVideo() );
             result.setMessage( "获取商品详细成功" );
             result.setResult( byId );
             result.setCode( 200 );
@@ -504,8 +505,22 @@ public class APIIndexenterController {
             query.eq( "pid",0 );
             List<AaCommodityFl> list = aaCommodityFlService.list(query);
             for (int i = 0;i<list.size();i++){
-                list.get( i ).setPic( host + "/sys/common/static/"+list.get( i ).getPic() );
-                list.get( i ).setAssets( host + "/sys/common/static/"+list.get( i ).getAssets() );
+                AaCommodityFl aaCommodityFl = list.get(i);
+                String pic = aaCommodityFl.getPic();
+                if (!Strings.isNullOrEmpty(pic)) {
+                    if (pic.contains(",")) {
+                        String[] split = pic.split(",");
+                        if (split.length >=2){
+                            aaCommodityFl.setPic(host + "/sys/common/static/"+split[0]);
+                            aaCommodityFl.setPic2(host + "/sys/common/static/"+split[1]);
+                        } else if (split.length == 1){
+                            aaCommodityFl.setPic(host + "/sys/common/static/"+split[0]);
+                        }
+                    } else {
+                        aaCommodityFl.setPic(host + "/sys/common/static/"+aaCommodityFl.getPic());
+                    }
+                }
+                aaCommodityFl.setAssets( host + "/sys/common/static/"+ aaCommodityFl.getAssets() );
             }
             result.setMessage( "获取商品一级分类成功" );
             result.setResult( list );

+ 4 - 0
jlsb/jeecg-boot-module-system/src/main/java/org/jeecg/modules/aa/entity/AaCommodity.java

@@ -51,6 +51,10 @@ public class AaCommodity implements Serializable {
 	@Excel(name = "图片", width = 15)
     @ApiModelProperty(value = "图片")
     private String pic;
+    /**视频*/
+    @Excel(name = "视频", width = 15)
+    @ApiModelProperty(value = "视频")
+    private String video;
 	/**价格*/
 	@Excel(name = "价格", width = 15)
     @ApiModelProperty(value = "价格")

+ 4 - 0
jlsb/jeecg-boot-module-system/src/main/java/org/jeecg/modules/aa/entity/AaCommodityFl.java

@@ -43,6 +43,10 @@ public class AaCommodityFl implements Serializable {
 	@Excel(name = "分类图片", width = 15)
     @ApiModelProperty(value = "分类图片")
     private String pic;
+    /**分类图片*/
+    @ApiModelProperty(value = "分类图片2")
+    @TableField(exist = false)
+    private String pic2;
 
     /**系列详情页顶部视频或动图*/
     @Excel(name = "系列详情页顶部视频或动图", width = 15)