|
|
@@ -196,15 +196,12 @@
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
|
<el-form-item label="优惠券" prop="content" v-if="form.taskType == 5">
|
|
|
- <el-select v-model="form.content" placeholder="请选择优惠券" ref="selectCoupon" >
|
|
|
+ <el-select v-model="form.content" placeholder="请选择优惠券" ref="selectCoupon" filterable clearable>
|
|
|
<el-option v-for="i in couponOptions" :key="i.value" :label="i.label" :value="i.value"></el-option>
|
|
|
- <!-- 加载载中状态 -->
|
|
|
<div v-if="isLoading" class="loading-indicator">
|
|
|
<i class="el-icon-loading"></i>
|
|
|
<span>加载中...</span>
|
|
|
</div>
|
|
|
-
|
|
|
- <!-- 没有更多数据 -->
|
|
|
<div v-if="!hasMore && !isLoading" class="no-more">
|
|
|
没有更多数据了
|
|
|
</div>
|
|
|
@@ -240,7 +237,7 @@
|
|
|
<el-option v-for="i in redOptions" :key="i.value" :label="i.label" :value="i.value"></el-option>
|
|
|
</el-select>
|
|
|
<template v-else-if="item.rewardType == 5">
|
|
|
- <el-select v-model="item.rewardId" placeholder="请选择优惠券" style="width: 160px; margin-right: 8px;">
|
|
|
+ <el-select v-model="item.rewardId" placeholder="请选择优惠券" filterable clearable style="width: 180px; margin-right: 8px;">
|
|
|
<el-option v-for="i in couponOptions" :key="i.value" :label="i.label" :value="i.value"></el-option>
|
|
|
</el-select>
|
|
|
<el-input-number v-model="item.couponCount" :min="1" :max="99" controls-position="right" placeholder="数量" style="width: 110px; margin-right: 8px;"></el-input-number>
|
|
|
@@ -252,10 +249,10 @@
|
|
|
<el-button type="text" icon="el-icon-plus" @click="addSignReward">添加奖励</el-button>
|
|
|
</div>
|
|
|
</el-form-item>
|
|
|
- <el-form-item label="触发时间" prop="content">
|
|
|
+ <el-form-item label="触发时间" prop="triggerValue">
|
|
|
<el-time-picker
|
|
|
- default-value="2025-01-01 00:00:00"
|
|
|
v-model="form.triggerValue"
|
|
|
+ value-format="yyyy-MM-dd HH:mm:ss"
|
|
|
:picker-options="{
|
|
|
selectableRange: '00:00:00 - 23:59:59'
|
|
|
}"
|
|
|
@@ -519,7 +516,12 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
productNameFormatter(row, column, value){
|
|
|
- let content = JSON.parse(row.content)
|
|
|
+ let content = {};
|
|
|
+ try {
|
|
|
+ content = typeof row.content === 'string' ? JSON.parse(row.content || '{}') : (row.content || {});
|
|
|
+ } catch (e) {
|
|
|
+ return '--';
|
|
|
+ }
|
|
|
if(content.productName) {
|
|
|
return content.productName
|
|
|
}
|
|
|
@@ -752,26 +754,29 @@ export default {
|
|
|
});
|
|
|
},
|
|
|
addCouponList() {
|
|
|
- if(this.haveData.coupon) return
|
|
|
- listLiveCouponOn(this.listParams).then(res => {
|
|
|
- if(res.rows.length > 0) {
|
|
|
- res.rows.forEach(item => {
|
|
|
- // 根据productName和goodsId组装成为label和value
|
|
|
- this.couponOptions.push({
|
|
|
- value: item.couponId,
|
|
|
- label: item.title
|
|
|
- })
|
|
|
- })
|
|
|
+ if (this.haveData.coupon) {
|
|
|
+ return Promise.resolve();
|
|
|
+ }
|
|
|
+ return listLiveCouponOn(this.listParams).then(res => {
|
|
|
+ const rows = res.rows || [];
|
|
|
+ if (rows.length > 0) {
|
|
|
+ rows.forEach(item => {
|
|
|
+ if (!this.couponOptions.some(o => Number(o.value) === Number(item.couponId))) {
|
|
|
+ this.couponOptions.push({
|
|
|
+ value: item.couponId,
|
|
|
+ label: item.title
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
this.listParams.pageNum++;
|
|
|
- // 判断是否还有更多数据
|
|
|
- this.hasMore = this.couponOptions.length < res.total;
|
|
|
+ // 按页递归拉全量,保证下拉可选券与原先一致
|
|
|
+ this.hasMore = (this.listParams.pageNum - 1) * this.listParams.pageSize < Number(res.total || 0);
|
|
|
if (this.hasMore) {
|
|
|
- this.addCouponList();
|
|
|
- } else {
|
|
|
- this.haveData.coupon = true
|
|
|
+ return this.addCouponList();
|
|
|
}
|
|
|
+ this.haveData.coupon = true;
|
|
|
} else {
|
|
|
- this.haveData.coupon = true
|
|
|
+ this.haveData.coupon = true;
|
|
|
this.hasMore = false;
|
|
|
}
|
|
|
});
|
|
|
@@ -861,8 +866,22 @@ export default {
|
|
|
}
|
|
|
const id = row.id || this.ids
|
|
|
getTask(id).then(async response => {
|
|
|
- this.form = response.data;
|
|
|
- let content = JSON.parse( response.data.content)
|
|
|
+ const data = response.data || {};
|
|
|
+ let content = {};
|
|
|
+ try {
|
|
|
+ content = typeof data.content === 'string' ? JSON.parse(data.content || '{}') : (data.content || {});
|
|
|
+ } catch (e) {
|
|
|
+ content = {};
|
|
|
+ }
|
|
|
+ // 统一回填,保证 rewards 等字段具备响应式
|
|
|
+ this.form = {
|
|
|
+ ...data,
|
|
|
+ content: data.content,
|
|
|
+ goodsId: null,
|
|
|
+ goodsStatus: null,
|
|
|
+ rewards: [],
|
|
|
+ triggerValue: this.normalizeTriggerValue(data.triggerValue)
|
|
|
+ };
|
|
|
if (this.form.taskType == 1) {
|
|
|
this.form.content = content.goodsId;
|
|
|
}else if (this.form.taskType == 2) {
|
|
|
@@ -872,8 +891,8 @@ export default {
|
|
|
}else if(this.form.taskType == 5){
|
|
|
this.form.content = content.couponId;
|
|
|
}else if(this.form.taskType == 6){
|
|
|
- this.form.goodsId = content.goodsId;
|
|
|
- this.form.goodsStatus = content.status;
|
|
|
+ this.$set(this.form, 'goodsId', content.goodsId);
|
|
|
+ this.$set(this.form, 'goodsStatus', content.status);
|
|
|
}else if(this.form.taskType == 7){
|
|
|
await this.preloadAllSignRewardOptions();
|
|
|
const rewards = [];
|
|
|
@@ -884,11 +903,17 @@ export default {
|
|
|
if (r.rewardType == 2) rewardId = r.reward.redId;
|
|
|
else if (r.rewardType == 5) rewardId = r.reward.couponId;
|
|
|
}
|
|
|
+ // 已触发任务的积分红包可能不在 listOn 中,补进下拉选项
|
|
|
+ if (r.rewardType == 2 && rewardId != null) {
|
|
|
+ this.ensureRedOption(rewardId, r.reward);
|
|
|
+ } else if (r.rewardType == 5 && rewardId != null) {
|
|
|
+ this.ensureCouponOption(rewardId, r.reward);
|
|
|
+ }
|
|
|
rewards.push({
|
|
|
rewardType: r.rewardType != null ? Number(r.rewardType) : null,
|
|
|
- rewardId: rewardId,
|
|
|
+ rewardId: rewardId != null ? Number(rewardId) : null,
|
|
|
couponCount: r.couponCount > 0 ? Number(r.couponCount) : 1,
|
|
|
- amount: r.amount != null ? r.amount : null
|
|
|
+ amount: r.amount != null ? String(r.amount) : null
|
|
|
});
|
|
|
});
|
|
|
} else if (content.rewardType != null) {
|
|
|
@@ -898,19 +923,56 @@ export default {
|
|
|
if (content.rewardType == 2) rewardId = content.reward.redId;
|
|
|
else if (content.rewardType == 5) rewardId = content.reward.couponId;
|
|
|
}
|
|
|
+ if (content.rewardType == 2 && rewardId != null) {
|
|
|
+ this.ensureRedOption(rewardId, content.reward);
|
|
|
+ } else if (content.rewardType == 5 && rewardId != null) {
|
|
|
+ this.ensureCouponOption(rewardId, content.reward);
|
|
|
+ }
|
|
|
rewards.push({
|
|
|
rewardType: Number(content.rewardType),
|
|
|
- rewardId: rewardId,
|
|
|
+ rewardId: rewardId != null ? Number(rewardId) : null,
|
|
|
couponCount: content.couponCount > 0 ? Number(content.couponCount) : 1,
|
|
|
- amount: content.amount != null ? content.amount : null
|
|
|
+ amount: content.amount != null ? String(content.amount) : null
|
|
|
});
|
|
|
}
|
|
|
- this.form.rewards = rewards.length ? rewards : [{ rewardType: null, rewardId: null, couponCount: 1, amount: null }];
|
|
|
+ this.$set(this.form, 'rewards', rewards.length ? rewards : [{ rewardType: null, rewardId: null, couponCount: 1, amount: null }]);
|
|
|
}
|
|
|
this.open = true;
|
|
|
this.title = "修改直播间自动化任务配置";
|
|
|
});
|
|
|
},
|
|
|
+ normalizeTriggerValue(val) {
|
|
|
+ if (!val) return null;
|
|
|
+ if (val instanceof Date) return this.parseTime(val, '{y}-{m}-{d} {h}:{i}:{s}');
|
|
|
+ if (typeof val === 'number') {
|
|
|
+ const date = new Date(String(val).length === 10 ? val * 1000 : val);
|
|
|
+ return this.parseTime(date, '{y}-{m}-{d} {h}:{i}:{s}');
|
|
|
+ }
|
|
|
+ if (typeof val === 'string') {
|
|
|
+ // 仅时分秒时补默认日期,供 value-format 使用
|
|
|
+ if (/^\d{2}:\d{2}:\d{2}$/.test(val)) {
|
|
|
+ return '2000-01-01 ' + val;
|
|
|
+ }
|
|
|
+ return val;
|
|
|
+ }
|
|
|
+ return val;
|
|
|
+ },
|
|
|
+ ensureRedOption(rewardId, reward) {
|
|
|
+ const id = Number(rewardId);
|
|
|
+ if (!id || this.redOptions.some(o => Number(o.value) === id)) return;
|
|
|
+ this.redOptions.unshift({
|
|
|
+ value: id,
|
|
|
+ label: (reward && (reward.desc || reward.Desc)) || ('积分红包#' + id)
|
|
|
+ });
|
|
|
+ },
|
|
|
+ ensureCouponOption(rewardId, reward) {
|
|
|
+ const id = Number(rewardId);
|
|
|
+ if (!id || this.couponOptions.some(o => Number(o.value) === id)) return;
|
|
|
+ this.couponOptions.unshift({
|
|
|
+ value: id,
|
|
|
+ label: (reward && (reward.title || reward.Title)) || ('优惠券#' + id)
|
|
|
+ });
|
|
|
+ },
|
|
|
/** 提交按钮 */
|
|
|
submitForm() {
|
|
|
this.form.liveId = this.liveId;
|