瀏覽代碼

feat:商品添加规格型号时,限制内容必填

Moss 1 年之前
父節點
當前提交
4692ec806c
共有 1 個文件被更改,包括 36 次插入21 次删除
  1. 36 21
      src/views/mallManagement/goods/goods_add/index.vue

+ 36 - 21
src/views/mallManagement/goods/goods_add/index.vue

@@ -160,7 +160,7 @@
             highlight-current-row
             stripe
             style="margin-bottom: 20px">
-            <el-table-column align="center" label="大类" prop="mainId" min-width="120">
+            <el-table-column align="center" label="*大类" prop="mainId" min-width="120">
               <template slot-scope="scope">
                 <el-select
                   size="small"
@@ -178,7 +178,7 @@
                 </el-select>
               </template>
             </el-table-column>
-            <el-table-column align="center" label="小类" prop="smallId" min-width="120">
+            <el-table-column align="center" label="*小类" prop="smallId" min-width="120">
               <template slot-scope="scope">
                 <el-select
                   size="small"
@@ -196,7 +196,7 @@
                 </el-select>
               </template>
             </el-table-column>
-            <el-table-column align="center" label="商品名称" prop="specValue" min-width="180">
+            <el-table-column align="center" label="*规格名称" prop="specValue" min-width="180">
               <template slot-scope="scope">
                 <el-input size="small" v-model="scope.row.specValue" :disabled="scope.row.goodsCode != ''"></el-input>
               </template>
@@ -224,12 +224,12 @@
                 {{scope.row.unit | unitFilter}}
               </template>
             </el-table-column>
-            <el-table-column align="center" label="销售价格" prop="price" min-width="120">
+            <el-table-column align="center" label="*销售价格" prop="price" min-width="120">
               <template slot-scope="scope">
                 <el-input size="small" v-model="scope.row.price"></el-input>
               </template>
             </el-table-column>
-            <el-table-column align="center" label="划线价格" prop="orgPrice" min-width="120">
+            <el-table-column align="center" label="*划线价格" prop="orgPrice" min-width="120">
               <template slot-scope="scope">
                 <el-input size="small" v-model="scope.row.orgPrice"></el-input>
               </template>
@@ -239,17 +239,17 @@
                 {{scope.row.costAmount}}
               </template>
             </el-table-column>
-            <el-table-column align="center" label="佣金" prop="shareAmount" min-width="120">
+            <el-table-column align="center" label="*佣金" prop="shareAmount" min-width="120">
               <template slot-scope="scope">
                 <el-input size="small" v-model="scope.row.shareAmount"></el-input>
               </template>
             </el-table-column>
-            <el-table-column align="center" label="内部佣金" prop="innerShareAmount" min-width="120">
+            <el-table-column align="center" label="*内部佣金" prop="innerShareAmount" min-width="120">
               <template slot-scope="scope">
                 <el-input size="small" v-model="scope.row.innerShareAmount"></el-input>
               </template>
             </el-table-column>
-            <el-table-column align="center" label="商品库存" prop="stockNum" min-width="120">
+            <el-table-column align="center" label="*商品库存" prop="stockNum" min-width="120">
               <template slot-scope="scope">
                 <el-input size="small" v-model="scope.row.stockNum"></el-input>
               </template>
@@ -259,7 +259,7 @@
                 {{scope.row.stockQty || 0}}
               </template>
             </el-table-column>
-            <el-table-column align="center" label="规格图片" prop="imgUrl" min-width="120">
+            <el-table-column align="center" label="*规格图片" prop="imgUrl" min-width="120">
               <template slot-scope="scope">
                 <el-image
                   v-if="scope.row.imgUrl"
@@ -764,7 +764,7 @@ export default {
       this.specList[index].mainName = item.mainName || '';
       this.specList[index].smallId = item.smallId || '';
       this.specList[index].smallName = item.smallName || '';
-      this.specList[index].specValue = item.goodsName || '';
+      this.specList[index].specValue = item.specsName || '';
       this.specList[index].specsName = item.specsName || '';
       this.specList[index].unit = item.unit || '';
       this.specList[index].costAmount = item.costAmount || '';
@@ -779,6 +779,21 @@ export default {
           // 验证第二步
           this.$refs.step2Form.validate((valid) => {
             if (valid) {
+
+              if(this.specList.length < 1) return this.$errorMsg('请添加规格类型')
+
+              for(let i=0; i<this.specList.length; i++) {
+                if(!this.specList[i].mainId)  return this.$errorMsg('请选择大类')
+                if(!this.specList[i].smallId)  return this.$errorMsg('请选择小类')
+                if(!this.specList[i].specValue)  return this.$errorMsg('请填写规格名称')
+                if(!this.specList[i].price)  return this.$errorMsg('请填写销售价格')
+                if(!this.specList[i].orgPrice)  return this.$errorMsg('请填写划线价格')
+                if(!this.specList[i].shareAmount)  return this.$errorMsg('请填写佣金')
+                if(!this.specList[i].innerShareAmount)  return this.$errorMsg('请填写内部佣金')
+                if(!this.specList[i].stockNum)  return this.$errorMsg('请填写商品库存')
+                if(!this.specList[i].imgUrl)  return this.$errorMsg('请上传规格图片')
+              }
+
               // 验证第三步
               this.$refs.step3Form.validate((valid) => {
                 if (valid) {
@@ -887,7 +902,7 @@ export default {
       const fileSuffix = file.name.substring(file.name.lastIndexOf(".") + 1);
       const whiteList = ['jpg', 'jpeg', 'png'];
       if (whiteList.indexOf(fileSuffix) === -1) {
-        this.$errorMsg('只支持上传jpg/png文件!');
+        this.$('请添加规格类型')('只支持上传jpg/png文件!');
         return false;
       }
     },
@@ -902,7 +917,7 @@ export default {
       const fileSuffix = file.name.substring(file.name.lastIndexOf(".") + 1);
       const whiteList = ['AVI', 'mov', 'rmvb', 'rm', 'FLV', 'mp4'];
       if (whiteList.indexOf(fileSuffix) === -1) {
-        this.$errorMsg('只支持上传视频文件!');
+        this.$('请添加规格类型')('只支持上传视频文件!');
         return false;
       }
     },
@@ -917,7 +932,7 @@ export default {
       const fileSuffix = file.name.substring(file.name.lastIndexOf(".") + 1);
       const whiteList = ['jpg', 'jpeg', 'png'];
       if (whiteList.indexOf(fileSuffix) === -1) {
-        this.$errorMsg('只支持上传jpg/png文件!');
+        this.$('请添加规格类型')('只支持上传jpg/png文件!');
         return false;
       }
     },
@@ -932,7 +947,7 @@ export default {
       const fileSuffix = file.name.substring(file.name.lastIndexOf(".") + 1);
       const whiteList = ['jpg', 'jpeg', 'png'];
       if (whiteList.indexOf(fileSuffix) === -1) {
-        this.$errorMsg('只支持上传jpg/png文件!');
+        this.$('请添加规格类型')('只支持上传jpg/png文件!');
         return false;
       }
     },
@@ -975,13 +990,13 @@ export default {
     // 富文本图片 - 上传失败
     uploadError4() {
       this.quillImgLoading = false;
-      this.$errorMsg('图片插入失败');
+      this.$('请添加规格类型')('图片插入失败');
     },
 
     // 轮播图 - 点击上传图片
     uploadImage(id) {
       if (this.step1Form.images.length >= 6) {
-        this.$errorMsg('最多上传6张轮播图');
+        this.$('请添加规格类型')('最多上传6张轮播图');
         return
       }
 
@@ -1002,7 +1017,7 @@ export default {
         this.$set(this.step1Form.images, index, res.data);
       } else {
         if (this.step1Form.images.length >= 6) {
-          return this.$errorMsg('最多上传6张轮播图');
+          return this.$('请添加规格类型')('最多上传6张轮播图');
         }
         this.step1Form.images.push(res.data);
       }
@@ -1010,7 +1025,7 @@ export default {
 
     // 轮播图 - 超出限制数量
     uploadExceed2(files, fileList) {
-      return this.$errorMsg('最多上传6张轮播图');
+      return this.$('请添加规格类型')('最多上传6张轮播图');
     },
 
     // 轮播图 - 上传前
@@ -1018,7 +1033,7 @@ export default {
       const fileSuffix = file.name.substring(file.name.lastIndexOf(".") + 1);
       const whiteList = ['jpg', 'jpeg', 'png'];
       if (whiteList.indexOf(fileSuffix) === -1) {
-        this.$errorMsg('只支持上传jpg/jpeg/png文件!');
+        this.$('请添加规格类型')('只支持上传jpg/jpeg/png文件!');
         return false;
       }
     },
@@ -1037,7 +1052,7 @@ export default {
         this.$set(this.step1Form.images, index, targetItem);
         this.$set(this.step1Form.images, index - 1, thisItem);
       } else {
-        this.$errorMsg('已经最前,无法前移');
+        this.$('请添加规格类型')('已经最前,无法前移');
       }
     },
 
@@ -1050,7 +1065,7 @@ export default {
         this.$set(this.step1Form.images, index, targetItem);
         this.$set(this.step1Form.images, index + 1, thisItem);
       } else {
-        this.$errorMsg('已经最后,无法后移');
+        this.$('请添加规格类型')('已经最后,无法后移');
       }
     },