Ver Fonte

红德堂-多端分别设置红包金额

Long há 19 horas atrás
pai
commit
b2d052d0b6

+ 65 - 9
src/views/course/userCoursePeriod/batchRedPacket.vue

@@ -24,16 +24,48 @@
         align="center"
       />
       <el-table-column
-        label="金额"
+        label="小程序金额"
         align="center"
         width="200"
       >
         <template slot-scope="scope">
           <el-input-number
             v-model="scope.row.amount"
-            :min="0.1"
+            :min="0.0"
             :precision="2"
-            :step="0.01"
+            :step="0.1"
+            size="small"
+            style="width: 150px"
+          />
+        </template>
+      </el-table-column>
+      <el-table-column
+        label="APP金额"
+        align="center"
+        width="200"
+      >
+        <template slot-scope="scope">
+          <el-input-number
+            v-model="scope.row.appAmount"
+            :min="0.0"
+            :precision="2"
+            :step="0.1"
+            size="small"
+            style="width: 150px"
+          />
+        </template>
+      </el-table-column>
+      <el-table-column
+        label="H5金额"
+        align="center"
+        width="200"
+      >
+        <template slot-scope="scope">
+          <el-input-number
+            v-model="scope.row.h5Amount"
+            :min="0.0"
+            :precision="2"
+            :step="0.1"
             size="small"
             style="width: 150px"
           />
@@ -89,15 +121,37 @@ export default {
     initTableData() {
       this.tableData = this.selectedData.map(item => ({
         ...item,
-        amount: 0.1
+        amount: 0.0,
+        appAmount: 0.0,
+        h5Amount: 0.0
       }))
     },
     // 保存
     handleSave() {
-      // 验证金额范围
-      const invalidItems = this.tableData.filter(item => item.amount < 0.1);
-      if (invalidItems.length > 0) {
-        this.$message.error('红包金额需要大于等于0.1元');
+      // 验证金额范围 - amount
+      const invalidAmountItems = this.tableData.filter(item =>
+        item.amount < 0 || (item.amount > 0 && item.amount < 0.1)
+      );
+      if (invalidAmountItems.length > 0) {
+        this.$message.error('小程序红包金额需要等于0元或者大于等于0.1元');
+        return;
+      }
+
+      // 验证金额范围 - appAmount
+      const invalidAppAmountItems = this.tableData.filter(item =>
+        item.appAmount < 0 || (item.appAmount > 0 && item.appAmount < 0.1)
+      );
+      if (invalidAppAmountItems.length > 0) {
+        this.$message.error('APP红包金额需要等于0元或者大于等于0.1元');
+        return;
+      }
+
+      // 验证金额范围 - h5Amount
+      const invalidH5AmountItems = this.tableData.filter(item =>
+        item.h5Amount < 0 || (item.h5Amount > 0 && item.h5Amount < 0.1)
+      );
+      if (invalidH5AmountItems.length > 0) {
+        this.$message.error('H5红包金额需要等于0元或者大于等于0.1元');
         return;
       }
 
@@ -109,7 +163,9 @@ export default {
         this.loading = true;
         const saveData = this.tableData.map(item => ({
           periodId: item.periodId,
-          redPacketMoney: item.amount
+          redPacketMoney: item.amount,
+          redPacketMoneyApp: item.appAmount,
+          redPacketMoneyH5: item.h5Amount
         }));
 
         batchSaveRedPacketByPeriod(saveData).then(response => {

+ 122 - 16
src/views/course/userCoursePeriod/redPacket.vue

@@ -68,13 +68,41 @@
         <el-table-column label="课程" prop="courseName" align="center" />
         <el-table-column label="小节" prop="videoName" align="center" />
         <el-table-column label="营期日期" prop="dayDate" align="center"/>
-        <el-table-column label="红包金额" width="200px" align="center">
+        <el-table-column label="小程序红包金额" width="200px" align="center">
           <template slot-scope="scope">
             <el-input-number
               v-model="scope.row.amount"
               :min="0.0"
               :precision="2"
-              :step="0.01"
+              :step="0.1"
+              size="small"
+              style="width: 150px"
+            >
+              <template slot="append">元</template>
+            </el-input-number>
+          </template>
+        </el-table-column>
+        <el-table-column label="APP红包金额" width="200px" align="center">
+          <template slot-scope="scope">
+            <el-input-number
+              v-model="scope.row.appAmount"
+              :min="0.0"
+              :precision="2"
+              :step="0.1"
+              size="small"
+              style="width: 150px"
+            >
+              <template slot="append">元</template>
+            </el-input-number>
+          </template>
+        </el-table-column>
+        <el-table-column label="H5红包金额" width="200px" align="center">
+          <template slot-scope="scope">
+            <el-input-number
+              v-model="scope.row.h5Amount"
+              :min="0.0"
+              :precision="2"
+              :step="0.1"
               size="small"
               style="width: 150px"
             >
@@ -90,21 +118,46 @@
     </el-dialog>
 
     <!-- 课程红包设置弹窗 -->
-    <el-dialog title="设置红包金额" :visible.sync="batchRedPacketDialog.visible" width="400px" append-to-body>
-      <el-form ref="batchRedPacketForm" :model="batchRedPacketDialog.form" label-width="100px">
-        <el-form-item label="红包金额" prop="amount" :rules="{required: true, message: '红包金额不能为空', trigger: 'blur'}">
+    <el-dialog title="设置红包金额" :visible.sync="batchRedPacketDialog.visible" width="500px" append-to-body>
+      <el-form ref="batchRedPacketForm" :model="batchRedPacketDialog.form" label-width="120px">
+        <el-form-item label="小程序红包金额" prop="amount" :rules="{required: true, message: '红包金额不能为空', trigger: 'blur'}">
           <div style="display: inline-flex; align-items: center">
             <el-input-number
               v-model="batchRedPacketDialog.form.amount"
-              :min="0.1"
+              :min="0.0"
+              :precision="2"
+              :step="0.1"
+              size="small"
+            >
+            </el-input-number>
+            <span style="margin-left: 10px">元</span>
+          </div>
+        </el-form-item>
+        <el-form-item label="APP红包金额" prop="appAmount" :rules="{required: true, message: '红包金额不能为空', trigger: 'blur'}">
+          <div style="display: inline-flex; align-items: center">
+            <el-input-number
+              v-model="batchRedPacketDialog.form.appAmount"
+              :min="0.0"
               :precision="2"
-              :step="0.01"
+              :step="0.1"
+              size="small"
+            >
+            </el-input-number>
+            <span style="margin-left: 10px">元</span>
+          </div>
+        </el-form-item>
+        <el-form-item label="H5红包金额" prop="h5Amount" :rules="{required: true, message: '红包金额不能为空', trigger: 'blur'}">
+          <div style="display: inline-flex; align-items: center">
+            <el-input-number
+              v-model="batchRedPacketDialog.form.h5Amount"
+              :min="0.0"
+              :precision="2"
+              :step="0.1"
               size="small"
             >
             </el-input-number>
             <span style="margin-left: 10px">元</span>
           </div>
-          <div style="color: rgba(169,88,18,0.9)">金额低于0.1元将自动置为0.1元</div>
         </el-form-item>
       </el-form>
       <div slot="footer" class="dialog-footer">
@@ -165,7 +218,9 @@ export default {
       batchRedPacketDialog: {
         visible: false,
         form: {
-          amount: 0.1
+          amount: 0.0,
+          appAmount: 0.0,
+          h5Amount: 0.0
         },
         saveLoading: false,
       }
@@ -254,35 +309,62 @@ export default {
     },
     // 获取课程列表
     getCourseList() {
+      this.redPacketList = []
       getPeriodRedPacketList({
         periodId: this.periodId,
         companyId: this.currentCompany.companyId
       }).then(response => {
         this.redPacketList = (response.data || []).map(item => ({
           ...item,
-          amount:item.amount ?? 0.1
+          amount:item.amount ?? 0,
+          appAmount: item.appAmount ?? 0,
+          h5Amount: item.h5Amount ?? 0,
         }));
       });
     },
     // 保存红包金额
     handleSave() {
       // 筛选出有金额的项目
-      const validAmountItems = this.redPacketList.filter(item => item.amount >= 0);
+      const validAmountItems = this.redPacketList.filter(item =>
+        item.amount >= 0 || item.appAmount >= 0 || item.h5Amount >= 0
+      );
       if (validAmountItems.length === 0) {
         this.$message.warning('请至少设置一个红包金额');
         return;
       }
 
-      // 验证金额范围
-      const invalidItems = validAmountItems.filter(item => item.amount < 0.0);
-      if (invalidItems.length > 0) {
-        this.$message.error('红包金额需要大于等于0元');
+      // 验证金额范围 - amount
+      const invalidAmountItems = validAmountItems.filter(item =>
+        item.amount < 0 || (item.amount > 0 && item.amount < 0.1)
+      );
+      if (invalidAmountItems.length > 0) {
+        this.$message.error('小程序红包金额需要等于0元或者大于等于0.1元');
+        return;
+      }
+
+      // 验证金额范围 - appAmount
+      const invalidAppAmountItems = validAmountItems.filter(item =>
+        item.appAmount < 0 || (item.appAmount > 0 && item.appAmount < 0.1)
+      );
+      if (invalidAppAmountItems.length > 0) {
+        this.$message.error('APP红包金额需要等于0元或者大于等于0.1元');
+        return;
+      }
+
+      // 验证金额范围 - h5Amount
+      const invalidH5AmountItems = validAmountItems.filter(item =>
+        item.h5Amount < 0 || (item.h5Amount > 0 && item.h5Amount < 0.1)
+      );
+      if (invalidH5AmountItems.length > 0) {
+        this.$message.error('H5红包金额需要等于0元或者大于等于0.1元');
         return;
       }
 
       const saveData = validAmountItems.map(item => ({
         companyId: this.currentCompany.companyId,
         redPacketMoney: item.amount,
+        redPacketMoneyApp: item.appAmount,
+        redPacketMoneyH5: item.h5Amount,
         videoId: item.videoId,
         periodId: this.periodId,
         dataType: 2
@@ -318,12 +400,36 @@ export default {
           this.$message.warning('请填写正确的红包金额')
           return;
         }
+
+        // 验证金额范围
+        const { amount, appAmount, h5Amount } = this.batchRedPacketDialog.form;
+
+        // 验证小程序红包金额
+        if (amount < 0 || (amount > 0 && amount < 0.1)) {
+          this.$message.error('小程序红包金额需要等于0元或者大于等于0.1元');
+          return;
+        }
+
+        // 验证APP红包金额
+        if (appAmount < 0 || (appAmount > 0 && appAmount < 0.1)) {
+          this.$message.error('APP红包金额需要等于0元或者大于等于0.1元');
+          return;
+        }
+
+        // 验证H5红包金额
+        if (h5Amount < 0 || (h5Amount > 0 && h5Amount < 0.1)) {
+          this.$message.error('H5红包金额需要等于0元或者大于等于0.1元');
+          return;
+        }
+
         this.batchRedPacketDialog.saveLoading = true
 
         const saveData = {
           periodId: this.periodId,
           companyIds: this.selectCompanyIds,
-          redPacketMoney: this.batchRedPacketDialog.form.amount
+          redPacketMoney: this.batchRedPacketDialog.form.amount,
+          redPacketMoneyApp: this.batchRedPacketDialog.form.appAmount,
+          redPacketMoneyH5: this.batchRedPacketDialog.form.h5Amount,
         }
         batchSaveRedPacketByCompany(saveData).then(response => {
           const {code, msg} = response