Эх сурвалжийг харах

Merge branch 'dev' into 'test'

Dev

See merge request quanshu/mp-ui-pc!50
hunagwb 3 жил өмнө
parent
commit
d5640e36d8

+ 9 - 9
src/views/business/goods/components/spec.vue

@@ -17,7 +17,7 @@
           </el-col>
           </el-col>
         </el-row>
         </el-row>
         <el-row>
         <el-row>
-          <el-form-item :prop="`specList.${index}.vals`" :rules="{ required: true, message: '请完善规格值', trigger: 'blur' }">
+          <el-form-item :prop="`specList.${index}.vals`" :rules="{ required: true, message: '请完善规格值', trigger: ['blur', 'change'] }">
             <el-col :span="24">
             <el-col :span="24">
               <el-tag v-for="(tag, index) in spec.vals" :key="index" closable style="margin-right: 10px" @close="spec.vals.splice(index, 1)">{{ tag }}</el-tag>
               <el-tag v-for="(tag, index) in spec.vals" :key="index" closable style="margin-right: 10px" @close="spec.vals.splice(index, 1)">{{ tag }}</el-tag>
               <el-input v-if="spec.editVals" v-model="specValTmp" style="display: inline-block;width: 120px; margin-right: 10px" size="mini" @keyup.enter.native="checkSpecVal(spec)" />
               <el-input v-if="spec.editVals" v-model="specValTmp" style="display: inline-block;width: 120px; margin-right: 10px" size="mini" @keyup.enter.native="checkSpecVal(spec)" />
@@ -28,8 +28,8 @@
         </el-row>
         </el-row>
       </div>
       </div>
     </el-form>
     </el-form>
-    <el-button type="primary" size="small" plain @click="specList.push({ name: '', vals: [], edit: true, editVals: false })" style="margin-bottom: 10px">添加规格</el-button>
-    <el-button type="primary" size="small" style="margin-bottom: 10px;margin-left: 10px" :disabled="specList.length === 0" @click="genSku">重新生成SKU表格</el-button>
+    <el-button type="primary" size="small" plain @click="specList.push({ name: '', vals: [], edit: true, editVals: false })" :disabled="specList.find(item => item.edit)" style="margin-bottom: 10px">添加规格</el-button>
+    <el-button type="primary" size="small" style="margin-bottom: 10px;margin-left: 10px" :disabled="specList.length === 0 || specList.find(item => item.edit)" @click="genSku">重新生成SKU表格</el-button>
     <br>
     <br>
     <el-form ref="sku" :model="{ skuList }">
     <el-form ref="sku" :model="{ skuList }">
       <table v-if="skuList instanceof Array && skuList.length > 0" class="spec-table" border="1" bordercolor="#CCC">
       <table v-if="skuList instanceof Array && skuList.length > 0" class="spec-table" border="1" bordercolor="#CCC">
@@ -52,8 +52,8 @@
             {{ formatObj(sku.properties)[spec.name] }}
             {{ formatObj(sku.properties)[spec.name] }}
           </td>
           </td>
           <td>
           <td>
-            <el-form-item :prop="`skuList.${index}.picUrl`" :rules="{ required: true, message: '请上传SKU图片', trigger: 'blur' }">
-              <Upload v-model="sku.picUrl" :limit="1" :low="true" style="height: 40px;overflow: hidden" />
+            <el-form-item :prop="`skuList.${index}.picUrlArr`" :rules="{ required: true, message: '请上传SKU图片', trigger: 'blur' }">
+              <Upload v-model="sku.picUrlArr" :limit="1" :low="true" style="height: 40px;overflow: hidden" />
             </el-form-item>
             </el-form-item>
           </td>
           </td>
           <td>
           <td>
@@ -67,7 +67,7 @@
             </el-form-item>
             </el-form-item>
           </td>
           </td>
           <td>
           <td>
-            <el-form-item :prop="`skuList.${index}.exchangePrice`" :rules="exchangeRules">
+            <el-form-item :prop="`skuList.${index}.valueY`" :rules="exchangeRules">
               <p>{{ sku.valueY }}</p>
               <p>{{ sku.valueY }}</p>
             </el-form-item>
             </el-form-item>
           </td>
           </td>
@@ -235,10 +235,9 @@ export default {
         skuList[productsIndex] = {
         skuList[productsIndex] = {
           idx: productsIndex,
           idx: productsIndex,
           name: specifications.toString(),
           name: specifications.toString(),
-          picUrl: '',
-          exchangePrice: 0.00,
+          picUrlArr: [],
           valueY: 0.00,
           valueY: 0.00,
-          costY: 0.00,
+          costY: '',
           quantity: 0,
           quantity: 0,
           status: true,
           status: true,
           properties
           properties
@@ -278,6 +277,7 @@ export default {
             item.value = accMul(valueY, 100)
             item.value = accMul(valueY, 100)
             item.exchangePrice = item.value
             item.exchangePrice = item.value
             item.cost = accMul(costY, 100)
             item.cost = accMul(costY, 100)
+            item.picUrl = item.picUrlArr.map(item => { return item.fileName }).toString()
           })
           })
           this.$emit('valid', this.skuList)
           this.$emit('valid', this.skuList)
         } else {
         } else {

+ 78 - 34
src/views/business/ticket/create.vue

@@ -61,10 +61,7 @@
               <template slot="append">张</template>
               <template slot="append">张</template>
             </el-input>
             </el-input>
           </el-form-item>
           </el-form-item>
-          <el-form-item
-            label="每包张数"
-            prop="pkgUnit"
-          >
+          <el-form-item label="每包张数" prop="pkgUnit">
             <el-input
             <el-input
               v-model="form.pkgUnit"
               v-model="form.pkgUnit"
               style="width: 240px"
               style="width: 240px"
@@ -219,7 +216,7 @@
         />
         />
         <el-table-column label="商品ID" prop="goodsId" />
         <el-table-column label="商品ID" prop="goodsId" />
         <el-table-column label="商品图片">
         <el-table-column label="商品图片">
-          <template slot-scope="{row}">
+          <template slot-scope="{ row }">
             <div v-if="row.picUrl">
             <div v-if="row.picUrl">
               <el-image
               <el-image
                 style="width: 100px; height: 100px"
                 style="width: 100px; height: 100px"
@@ -463,35 +460,65 @@ export default {
       // 奖级列表
       // 奖级列表
       awardsList: [
       awardsList: [
         {
         {
-          name: "至尊级",
+          name: "奖品一",
           sort: 1,
           sort: 1,
           quantity: 0,
           quantity: 0,
           prizeList: [],
           prizeList: [],
         },
         },
         {
         {
-          name: "尊享款",
+          name: "奖品二",
           sort: 2,
           sort: 2,
           quantity: 0,
           quantity: 0,
           prizeList: [],
           prizeList: [],
         },
         },
         {
         {
-          name: "稀有款",
+          name: "奖品三",
           sort: 3,
           sort: 3,
           quantity: 0,
           quantity: 0,
           prizeList: [],
           prizeList: [],
         },
         },
         {
         {
-          name: "隐藏款",
+          name: "奖品四",
           sort: 4,
           sort: 4,
           quantity: 0,
           quantity: 0,
           prizeList: [],
           prizeList: [],
         },
         },
         {
         {
-          name: "普通款",
+          name: "奖品五",
           sort: 5,
           sort: 5,
           quantity: 0,
           quantity: 0,
           prizeList: [],
           prizeList: [],
         },
         },
+        {
+          name: "奖品六",
+          sort: 6,
+          quantity: 0,
+          prizeList: [],
+        },
+        {
+          name: "奖品七",
+          sort: 7,
+          quantity: 0,
+          prizeList: [],
+        },
+        {
+          name: "奖品八",
+          sort: 8,
+          quantity: 0,
+          prizeList: [],
+        },
+        {
+          name: "奖品九",
+          sort: 9,
+          quantity: 0,
+          prizeList: [],
+        },
+        {
+          name: "奖品十",
+          sort: 10,
+          quantity: 0,
+          prizeList: [],
+        },
       ],
       ],
 
 
       prizeIndex: null, // 奖级下标
       prizeIndex: null, // 奖级下标
@@ -580,23 +607,23 @@ export default {
 
 
     // 保存
     // 保存
     submitForm() {
     submitForm() {
-      const subForm = this.$refs["form"]
+      const subForm = this.$refs["form"];
       subForm.validate((valid) => {
       subForm.validate((valid) => {
         if (valid) {
         if (valid) {
-          let prizeIndex = this.awardsList.findIndex((item) => {
-            return !item.prizeList.length;
-          });
-          // 判断没有设置奖品的奖级
-          if (prizeIndex != -1) {
-            this.$message.error(
-              `请设置${this.awardsList[prizeIndex].name}的奖品!`
-            );
-            return;
-          }
+          // let prizeIndex = this.awardsList.findIndex((item) => {
+          //   return !item.prizeList.length;
+          // });
+          // // 判断没有设置奖品的奖级
+          // if (prizeIndex != -1) {
+          //   this.$message.error(
+          //     `请设置${this.awardsList[prizeIndex].name}的奖品!`
+          //   );
+          //   return;
+          // }
 
 
           if (this.form.quantity % this.form.pkgUnit != 0) {
           if (this.form.quantity % this.form.pkgUnit != 0) {
             this.$message.error("每包数量错误!");
             this.$message.error("每包数量错误!");
-            return
+            return;
           }
           }
 
 
           let quantityTotal = 0;
           let quantityTotal = 0;
@@ -605,12 +632,12 @@ export default {
           });
           });
           if (this.form.quantity != quantityTotal) {
           if (this.form.quantity != quantityTotal) {
             this.$message.error("盲票数量和奖品数量不一致!");
             this.$message.error("盲票数量和奖品数量不一致!");
-            return
+            return;
           }
           }
 
 
-          if(this.form.saleCommRate > 100){
+          if (this.form.saleCommRate > 100) {
             this.$message.error("分佣基数不能大于100!");
             this.$message.error("分佣基数不能大于100!");
-            return
+            return;
           }
           }
 
 
           this.awardsList.forEach((item) => {
           this.awardsList.forEach((item) => {
@@ -624,20 +651,27 @@ export default {
               };
               };
             });
             });
           });
           });
+
+          let filterArr = this.awardsList.filter(item=>{
+            return item.prizeList.length != 0
+          })
+
           let data = {
           let data = {
             ...this.form,
             ...this.form,
             picUrl: this.form.picUrl[0].fileName,
             picUrl: this.form.picUrl[0].fileName,
             facePrice: accMul(this.form.facePrice, 100),
             facePrice: accMul(this.form.facePrice, 100),
             salePrice: accMul(this.form.salePrice, 100),
             salePrice: accMul(this.form.salePrice, 100),
             pkgSalePrice: accMul(this.form.pkgSalePrice, 100),
             pkgSalePrice: accMul(this.form.pkgSalePrice, 100),
-            awardsList: this.awardsList,
+            awardsList: filterArr,
           };
           };
+
           const loading = this.$loading({
           const loading = this.$loading({
             lock: true,
             lock: true,
             text: "保存中",
             text: "保存中",
             spinner: "el-icon-loading",
             spinner: "el-icon-loading",
             background: "rgba(0, 0, 0, 0.4)",
             background: "rgba(0, 0, 0, 0.4)",
           });
           });
+
           ticketBoxCreate(data)
           ticketBoxCreate(data)
             .then((res) => {
             .then((res) => {
               loading.close();
               loading.close();
@@ -671,9 +705,11 @@ export default {
 
 
     // 奖级商品删除
     // 奖级商品删除
     handleDel(index, item) {
     handleDel(index, item) {
+      this.prizeIndex = item.sort - 1;
       let list = item.prizeList;
       let list = item.prizeList;
       list.splice(index, 1);
       list.splice(index, 1);
       this.$set(item, "prizeList", list);
       this.$set(item, "prizeList", list);
+      this.getQuantity();
     },
     },
 
 
     // 关闭弹框
     // 关闭弹框
@@ -708,19 +744,27 @@ export default {
 
 
     // 选中商品
     // 选中商品
     handleSelectionGoods(e) {
     handleSelectionGoods(e) {
-      this.selectGoodsList = e;
-      this.selectGoodsList.forEach((item) => {
-        item.prizeType = "goods";
-        item.quantity = 1;
+      this.selectGoodsList = e.map((item) => {
+        return {
+          prizeType: "goods",
+          quantity: 1,
+          goodsId: item.goodsId,
+          picUrl: item.picUrl,
+          title: item.title,
+        };
       });
       });
     },
     },
 
 
     // 选中卡券
     // 选中卡券
     handleSelectionCoupon(e) {
     handleSelectionCoupon(e) {
-      this.selectCouponList = e;
-      this.selectCouponList.forEach((item) => {
-        item.prizeType = "coupon";
-        item.quantity = 1;
+      this.selectCouponList = e.map((item) => {
+        return {
+          prizeType: "coupon",
+          quantity: 1,
+          couponId: item.couponId,
+          picUrl: item.picUrl,
+          title: item.title,
+        };
       });
       });
     },
     },