|
@@ -157,6 +157,89 @@
|
|
|
</el-form-item>
|
|
</el-form-item>
|
|
|
<el-form-item label="红包金额" prop="redPacketMoney">
|
|
<el-form-item label="红包金额" prop="redPacketMoney">
|
|
|
<el-input-number v-model="form.redPacketMoney" :min="0.1" :max="200" :step="0.1"></el-input-number>
|
|
<el-input-number v-model="form.redPacketMoney" :min="0.1" :max="200" :step="0.1"></el-input-number>
|
|
|
|
|
+ </el-form-item>
|
|
|
|
|
+ <!-- -->
|
|
|
|
|
+ <el-form-item label="随机红包金额" v-if="!!form.randomRedPacketRulesArr" >
|
|
|
|
|
+ <template >
|
|
|
|
|
+ <div v-for="(rule, index) in form.randomRedPacketRulesArr" :key="index" class="form-row">
|
|
|
|
|
+ <el-form-item
|
|
|
|
|
+ label="随机红包金额区间"
|
|
|
|
|
+ :prop="`randomRedPacketRulesArr.${index}.minAmount`"
|
|
|
|
|
+ :rules="[
|
|
|
|
|
+ { required: true, message: '请输入最小金额', trigger: 'blur' },
|
|
|
|
|
+ { validator: validateMinAmount, trigger: 'blur', index: index }
|
|
|
|
|
+ ]"
|
|
|
|
|
+ class="form-item-amount"
|
|
|
|
|
+ >
|
|
|
|
|
+ <el-input
|
|
|
|
|
+ v-model.number="rule.minAmount"
|
|
|
|
|
+ type="number"
|
|
|
|
|
+ :min="0.01"
|
|
|
|
|
+ :precision="2"
|
|
|
|
|
+ :step="0.01"
|
|
|
|
|
+ placeholder="最小金额"
|
|
|
|
|
+ size="small"
|
|
|
|
|
+ class="amount-input"
|
|
|
|
|
+ @input="handleAmountInput(rule, 'minAmount')"
|
|
|
|
|
+ ></el-input>
|
|
|
|
|
+ <span class="separator">-</span>
|
|
|
|
|
+ <el-input
|
|
|
|
|
+ v-model.number="rule.maxAmount"
|
|
|
|
|
+ type="number"
|
|
|
|
|
+ :min="rule.minAmount || 0.01"
|
|
|
|
|
+ :precision="2"
|
|
|
|
|
+ :step="0.01"
|
|
|
|
|
+ placeholder="最大金额"
|
|
|
|
|
+ size="small"
|
|
|
|
|
+ class="amount-input"
|
|
|
|
|
+ @input="handleAmountInput(rule, 'maxAmount')"
|
|
|
|
|
+ ></el-input>
|
|
|
|
|
+ <span class="suffix">元</span>
|
|
|
|
|
+ </el-form-item>
|
|
|
|
|
+ <el-form-item
|
|
|
|
|
+ label="随机权重"
|
|
|
|
|
+ :prop="`randomRedPacketRulesArr.${index}.weight`"
|
|
|
|
|
+ :rules="[
|
|
|
|
|
+ { required: true, message: '请输入权重', trigger: 'blur' },
|
|
|
|
|
+ { type: 'integer', message: '权重必须为整数', trigger: 'blur' },
|
|
|
|
|
+ ]"
|
|
|
|
|
+ class="form-item-weight"
|
|
|
|
|
+ >
|
|
|
|
|
+ <el-input
|
|
|
|
|
+ v-model.number="rule.weight"
|
|
|
|
|
+ type="number"
|
|
|
|
|
+ :min="1"
|
|
|
|
|
+ placeholder="权重"
|
|
|
|
|
+ size="small"
|
|
|
|
|
+ ></el-input>
|
|
|
|
|
+ </el-form-item>
|
|
|
|
|
+ <el-tooltip class="item" effect="dark" content="权重越高,被随机到的概率越大" placement="top">
|
|
|
|
|
+ <i class="el-icon-question"></i>
|
|
|
|
|
+ </el-tooltip>
|
|
|
|
|
+ <div class="action-buttons">
|
|
|
|
|
+ <el-button
|
|
|
|
|
+ icon="el-icon-plus"
|
|
|
|
|
+ size="mini"
|
|
|
|
|
+ type="text"
|
|
|
|
|
+ @click="addRule(index)"
|
|
|
|
|
+ class="add-btn"
|
|
|
|
|
+ >
|
|
|
|
|
+ 新增
|
|
|
|
|
+ </el-button>
|
|
|
|
|
+ <el-button
|
|
|
|
|
+ icon="el-icon-delete"
|
|
|
|
|
+ size="mini"
|
|
|
|
|
+ type="text"
|
|
|
|
|
+ @click="deleteRule(index)"
|
|
|
|
|
+ :disabled="form.randomRedPacketRulesArr.length <= 1"
|
|
|
|
|
+ class="delete-btn"
|
|
|
|
|
+ >
|
|
|
|
|
+ 删除
|
|
|
|
|
+ </el-button>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </template>
|
|
|
|
|
+
|
|
|
</el-form-item>
|
|
</el-form-item>
|
|
|
<el-form-item label="是否关联商品">
|
|
<el-form-item label="是否关联商品">
|
|
|
<el-radio v-model="form.isProduct" :label=0>否</el-radio>
|
|
<el-radio v-model="form.isProduct" :label=0>否</el-radio>
|
|
@@ -355,10 +438,21 @@ import {getByIds} from '@/api/course/courseQuestionBank'
|
|
|
import CourseWatchComment from "./courseWatchComment.vue";
|
|
import CourseWatchComment from "./courseWatchComment.vue";
|
|
|
import {getCateListByPid, getCatePidList} from '@/api/course/userCourseCategory'
|
|
import {getCateListByPid, getCatePidList} from '@/api/course/userCourseCategory'
|
|
|
import draggable from 'vuedraggable'
|
|
import draggable from 'vuedraggable'
|
|
|
|
|
+import { getConfigByKey } from '@/api/system/config'
|
|
|
|
|
|
|
|
export default {
|
|
export default {
|
|
|
name: "userCourseCatalog",
|
|
name: "userCourseCatalog",
|
|
|
components: {VideoUpload, QuestionBank, CourseWatchComment, CourseProduct, draggable},
|
|
components: {VideoUpload, QuestionBank, CourseWatchComment, CourseProduct, draggable},
|
|
|
|
|
+ watch:{
|
|
|
|
|
+ // 深度监听 rules 数组的变化,以更新总权重
|
|
|
|
|
+ "form.randomRedPacketRulesArr": {
|
|
|
|
|
+ handler(val) {
|
|
|
|
|
+ // this.calculateTotalWeight();
|
|
|
|
|
+ this.validateRules();
|
|
|
|
|
+ },
|
|
|
|
|
+ deep: true,
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
data() {
|
|
data() {
|
|
|
return {
|
|
return {
|
|
|
duration: null,
|
|
duration: null,
|
|
@@ -454,7 +548,15 @@ export default {
|
|
|
openVideoSort: false,
|
|
openVideoSort: false,
|
|
|
// 表单参数
|
|
// 表单参数
|
|
|
form: {
|
|
form: {
|
|
|
- courseProducts: []
|
|
|
|
|
|
|
+ courseProducts: [],
|
|
|
|
|
+ randomRedPacketRules:null,
|
|
|
|
|
+ randomRedPacketRulesArr:[
|
|
|
|
|
+ {
|
|
|
|
|
+ minAmount: 0.01,
|
|
|
|
|
+ maxAmount: 0.01,
|
|
|
|
|
+ weight: 100,
|
|
|
|
|
+ }
|
|
|
|
|
+ ]
|
|
|
},
|
|
},
|
|
|
updateBatchData: {
|
|
updateBatchData: {
|
|
|
open: false,
|
|
open: false,
|
|
@@ -477,12 +579,25 @@ export default {
|
|
|
videoId: null,
|
|
videoId: null,
|
|
|
title: ""
|
|
title: ""
|
|
|
},
|
|
},
|
|
|
|
|
+ enableRandomRedPacket:false
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
created() {
|
|
created() {
|
|
|
this.getDicts("sys_course_temp_type").then(response => {
|
|
this.getDicts("sys_course_temp_type").then(response => {
|
|
|
this.typeOptions = response.data;
|
|
this.typeOptions = response.data;
|
|
|
});
|
|
});
|
|
|
|
|
+ getConfigByKey('randomRedpacket:config').then(res=>{
|
|
|
|
|
+ let configData = res.data;
|
|
|
|
|
+ if(!!configData && !!configData.configValue){
|
|
|
|
|
+ let configValue = JSON.parse(configData.configValue);
|
|
|
|
|
+ if(!!configValue.enableRandomRedpacket){
|
|
|
|
|
+ this.enableRandomRedPacket = configValue.enableRandomRedpacket;
|
|
|
|
|
+ console.log("this.enableRandomRedPacket ::" + this.enableRandomRedPacket)
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }).catch(res=>{
|
|
|
|
|
+
|
|
|
|
|
+ })
|
|
|
},
|
|
},
|
|
|
methods: {
|
|
methods: {
|
|
|
getPickerOptions() {
|
|
getPickerOptions() {
|
|
@@ -713,6 +828,14 @@ export default {
|
|
|
isFirst: 0,
|
|
isFirst: 0,
|
|
|
listingStartTime: null,
|
|
listingStartTime: null,
|
|
|
listingEndTime: null,
|
|
listingEndTime: null,
|
|
|
|
|
+ randomRedPacketRules:null,
|
|
|
|
|
+ randomRedPacketRulesArr:[
|
|
|
|
|
+ {
|
|
|
|
|
+ minAmount: 0.01,
|
|
|
|
|
+ maxAmount: 0.01,
|
|
|
|
|
+ weight: 100,
|
|
|
|
|
+ }
|
|
|
|
|
+ ]
|
|
|
};
|
|
};
|
|
|
this.videoURL = '';
|
|
this.videoURL = '';
|
|
|
this.progress = 0;
|
|
this.progress = 0;
|
|
@@ -768,7 +891,12 @@ export default {
|
|
|
this.packageList = [];
|
|
this.packageList = [];
|
|
|
const videoId = row.videoId || this.ids
|
|
const videoId = row.videoId || this.ids
|
|
|
getUserCourseVideo(videoId).then(response => {
|
|
getUserCourseVideo(videoId).then(response => {
|
|
|
|
|
+ console.log(response);
|
|
|
this.form = response.data;
|
|
this.form = response.data;
|
|
|
|
|
+ if(!!this.form.randomRedPacketRules){
|
|
|
|
|
+ this.$set(this.form, 'randomRedPacketRulesArr', JSON.parse(this.form.randomRedPacketRules)) ;
|
|
|
|
|
+ // this.form.randomRedPacketRulesArr = JSON.parse(this.form.randomRedPacketRules);
|
|
|
|
|
+ }
|
|
|
if (response.data.videoUrl != null && response.data.videoUrl !== '') {
|
|
if (response.data.videoUrl != null && response.data.videoUrl !== '') {
|
|
|
this.videoUrl = response.data.videoUrl;
|
|
this.videoUrl = response.data.videoUrl;
|
|
|
}
|
|
}
|
|
@@ -813,7 +941,7 @@ export default {
|
|
|
});
|
|
});
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
- if (this.form.isProduct != null && this.form.isProduct == 1 && this.form.courseProducts.length < 1) {
|
|
|
|
|
|
|
+ if (this.form.isProduct != null && this.form.isProduct == 1 && (this.form.courseProducts == null || this.form.courseProducts.length < 1)) {
|
|
|
this.$message({
|
|
this.$message({
|
|
|
message: '请选择关联商品',
|
|
message: '请选择关联商品',
|
|
|
type: 'warning'
|
|
type: 'warning'
|
|
@@ -829,6 +957,11 @@ export default {
|
|
|
if (this.form.courseProducts != null) {
|
|
if (this.form.courseProducts != null) {
|
|
|
this.form.productId = this.form.courseProducts.map(item => item.id).join(',');
|
|
this.form.productId = this.form.courseProducts.map(item => item.id).join(',');
|
|
|
}
|
|
}
|
|
|
|
|
+ if(!!this.form.randomRedPacketRulesArr){
|
|
|
|
|
+ let rulesJson = JSON.stringify(this.form.randomRedPacketRulesArr);
|
|
|
|
|
+ this.form.randomRedPacketRules = rulesJson;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
if (this.form.videoId != null) {
|
|
if (this.form.videoId != null) {
|
|
|
updateUserCourseVideo(this.form).then(response => {
|
|
updateUserCourseVideo(this.form).then(response => {
|
|
|
this.msgSuccess("修改成功");
|
|
this.msgSuccess("修改成功");
|
|
@@ -981,7 +1114,15 @@ export default {
|
|
|
this.redData.loading = true;
|
|
this.redData.loading = true;
|
|
|
this.redData.queryParams.courseId = this.courseId;
|
|
this.redData.queryParams.courseId = this.courseId;
|
|
|
getVideoListByCourseId(this.redData.queryParams).then(response => {
|
|
getVideoListByCourseId(this.redData.queryParams).then(response => {
|
|
|
- this.redData.list = response.rows;
|
|
|
|
|
|
|
+ if(!!response.rows && response.rows.length >0){
|
|
|
|
|
+ for(let i = 0; i < response.rows.length; i++){
|
|
|
|
|
+ if(!!response.rows[i].randomRedPacketRules){
|
|
|
|
|
+ this.$set(response.rows[i], 'randomRedPacketRulesArr', JSON.parse(response.rows[i].randomRedPacketRules)) ;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ this.redData.list = response.rows;
|
|
|
|
|
+ console.log(this.redData.list);
|
|
|
this.redData.loading = false;
|
|
this.redData.loading = false;
|
|
|
});
|
|
});
|
|
|
},
|
|
},
|
|
@@ -998,6 +1139,80 @@ export default {
|
|
|
this.commentDialog.title = `查看评论 - ${row.title}`;
|
|
this.commentDialog.title = `查看评论 - ${row.title}`;
|
|
|
this.commentDialog.open = true;
|
|
this.commentDialog.open = true;
|
|
|
},
|
|
},
|
|
|
|
|
+ // 实时过滤金额输入,只允许两位小数
|
|
|
|
|
+ handleAmountInput(rule, field) {
|
|
|
|
|
+ let value = rule[field];
|
|
|
|
|
+ if (value === null || value === undefined) return;
|
|
|
|
|
+
|
|
|
|
|
+ // 转换为字符串处理
|
|
|
|
|
+ let str = value.toString();
|
|
|
|
|
+
|
|
|
|
|
+ // 移除除数字和小数点外的所有字符
|
|
|
|
|
+ str = str.replace(/[^0-9.]/g, '');
|
|
|
|
|
+
|
|
|
|
|
+ // 只保留一个小数点
|
|
|
|
|
+ const dotIndex = str.indexOf('.');
|
|
|
|
|
+ if (dotIndex !== -1) {
|
|
|
|
|
+ str = str.substring(0, dotIndex + 1) + str.substring(dotIndex + 1).replace(/\./g, '');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 限制小数点后最多两位
|
|
|
|
|
+ if (dotIndex !== -1 && str.length > dotIndex + 3) {
|
|
|
|
|
+ str = str.substring(0, dotIndex + 3);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 转换回数字并更新
|
|
|
|
|
+ rule[field] = parseFloat(str) || 0;
|
|
|
|
|
+ },
|
|
|
|
|
+ deleteRule(index) {
|
|
|
|
|
+ this.$confirm("确定要删除这个区间吗?", "提示", {
|
|
|
|
|
+ confirmButtonText: "确定",
|
|
|
|
|
+ cancelButtonText: "取消",
|
|
|
|
|
+ type: "warning",
|
|
|
|
|
+ }).then(() => {
|
|
|
|
|
+ this.form.randomRedPacketRulesArr.splice(index, 1);
|
|
|
|
|
+ this.$message({
|
|
|
|
|
+ type: "success",
|
|
|
|
|
+ message: "删除成功!",
|
|
|
|
|
+ });
|
|
|
|
|
+ });
|
|
|
|
|
+ },
|
|
|
|
|
+ addRule(index) {
|
|
|
|
|
+ // 在当前行的后面插入一个新行
|
|
|
|
|
+ this.form.randomRedPacketRulesArr.splice(index + 1, 0, {
|
|
|
|
|
+ minAmount: 0.01,
|
|
|
|
|
+ maxAmount: 0.01,
|
|
|
|
|
+ weight: 100,
|
|
|
|
|
+ });
|
|
|
|
|
+ },
|
|
|
|
|
+ // 自定义校验规则:确保最大金额大于最小金额
|
|
|
|
|
+ validateMinAmount(rule, value, callback) {
|
|
|
|
|
+ // debugger;
|
|
|
|
|
+ // const maxAmount = this.form29.rules[].maxAmount
|
|
|
|
|
+
|
|
|
|
|
+ const index = rule.index;
|
|
|
|
|
+ const maxAmount = this.form.randomRedPacketRulesArr[index].maxAmount;
|
|
|
|
|
+
|
|
|
|
|
+ if (value > maxAmount) {
|
|
|
|
|
+ callback(new Error("最小金额不能大于最大金额"));
|
|
|
|
|
+ } else {
|
|
|
|
|
+ callback();
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ validateRules() {
|
|
|
|
|
+ this.form.randomRedPacketRulesArr.forEach((rule) => {
|
|
|
|
|
+ if (rule.minAmount === undefined || rule.minAmount < 0.01) {
|
|
|
|
|
+ rule.minAmount = 0.01;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (rule.maxAmount === undefined || rule.maxAmount < rule.minAmount) {
|
|
|
|
|
+ rule.maxAmount = rule.minAmount;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (rule.weight === undefined || rule.weight < 1) {
|
|
|
|
|
+ rule.weight = 1;
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
</script>
|
|
</script>
|