|
|
@@ -331,6 +331,27 @@
|
|
|
</el-card>
|
|
|
</div>
|
|
|
|
|
|
+ <div v-if="item.contentType == 21">
|
|
|
+ <el-card class="box-card">
|
|
|
+ <el-form-item label="短信模板" >
|
|
|
+ <el-select v-model="item.smsTemplateId"
|
|
|
+ placeholder="请选择短信模板" size="mini"
|
|
|
+ @change="getSmsTemplateInfo(item)" >
|
|
|
+ <el-option
|
|
|
+ v-for="template in smsTemplateList"
|
|
|
+ :key="template.tempId"
|
|
|
+ :label="template.title"
|
|
|
+ :value="template.tempId"
|
|
|
+ />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="内容预览" v-if="item.smsTemplateContent">
|
|
|
+ <div style="color: #666; font-size: 12px; padding: 8px; border: 1px solid #eee; border-radius: 4px; background-color: #f9f9f9; max-height: 100px; overflow-y: auto;">
|
|
|
+ {{ item.smsTemplateContent }}
|
|
|
+ </div>
|
|
|
+ </el-form-item>
|
|
|
+ </el-card>
|
|
|
+ </div>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
@@ -404,6 +425,7 @@ import {courseList, videoList} from "@/api/qw/sop";
|
|
|
import userVideo from "@/views/qw/userVideo/userVideo";
|
|
|
import {listToLiveNoEnd} from "@/api/live/live";
|
|
|
import {listReward} from "@/api/qw/luckyBag";
|
|
|
+import { getSmsTempList } from "@/api/company/companySmsTemp";
|
|
|
|
|
|
|
|
|
export default {
|
|
|
@@ -485,6 +507,7 @@ export default {
|
|
|
open:false,
|
|
|
ids:null,
|
|
|
},
|
|
|
+ smsTemplateList: [],
|
|
|
// 表单参数
|
|
|
form: {},
|
|
|
setting:[{contentType:'1', value: '',}],
|
|
|
@@ -533,6 +556,7 @@ export default {
|
|
|
listReward(this.queryParams1).then(response => {
|
|
|
this.luckyBagList = response.rows;
|
|
|
});
|
|
|
+ this.loadSmsTemplates();
|
|
|
},
|
|
|
methods: {
|
|
|
getLuckyBagStatus(content) {
|
|
|
@@ -906,6 +930,54 @@ export default {
|
|
|
};
|
|
|
this.resetForm("msgForm");
|
|
|
},
|
|
|
+
|
|
|
+ // 获取短信模板信息(类似福袋的处理方式)
|
|
|
+ getSmsTemplateInfo(content) {
|
|
|
+ // 如果短信模板列表为空,先加载数据
|
|
|
+ if (this.smsTemplateList.length === 0) {
|
|
|
+ getSmsTempList().then(response => {
|
|
|
+ this.smsTemplateList = response.rows || response.data || [];
|
|
|
+ // 加载完成后再次调用自身来处理选中项
|
|
|
+ this.processSelectedSmsTemplate(content);
|
|
|
+ }).catch(error => {
|
|
|
+ console.error('加载短信模板失败:', error);
|
|
|
+ this.$message.error('加载短信模板失败');
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ // 直接处理选中项
|
|
|
+ this.processSelectedSmsTemplate(content);
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ // 处理选中的短信模板
|
|
|
+ processSelectedSmsTemplate(content) {
|
|
|
+ const selectedTemplate = this.smsTemplateList.find(item => item.tempId === content.smsTemplateId);
|
|
|
+ if (selectedTemplate) {
|
|
|
+ // 自动填充模板内容预览
|
|
|
+ this.$set(content, 'smsTemplateContent', selectedTemplate.content || selectedTemplate.templateContent || '');
|
|
|
+ } else {
|
|
|
+ // 清空相关内容
|
|
|
+ this.$set(content, 'smsTemplateContent', '');
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ // 加载短信模板列表
|
|
|
+ loadSmsTemplates() {
|
|
|
+ if (this.smsTemplateList.length > 0) {
|
|
|
+ return; // 如果已经有数据,不再重复加载
|
|
|
+ }
|
|
|
+
|
|
|
+ getSmsTempList().then(response => {
|
|
|
+ this.smsTemplateList = response.rows || response.data || [];
|
|
|
+ if (this.smsTemplateList.length === 0) {
|
|
|
+ this.$message.info('暂无可用的短信模板');
|
|
|
+ }
|
|
|
+ }).catch(error => {
|
|
|
+ console.error('加载短信模板失败:', error);
|
|
|
+ this.$message.error('加载短信模板失败');
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
// 多选框选中数据
|
|
|
handleSelectionChange(selection) {
|
|
|
this.ids = selection.map(item => item.id)
|
|
|
@@ -920,40 +992,40 @@ export default {
|
|
|
|
|
|
|
|
|
|
|
|
- if (this.msgForm.draftStrategy==1){
|
|
|
+ if (this.msgForm.draftStrategy==1) {
|
|
|
|
|
|
- if(!!hasLiveSetting && (this.msgForm.courseId!=null && this.msgForm.courseId!='')){
|
|
|
+ if (!!hasLiveSetting && (this.msgForm.courseId != null && this.msgForm.courseId != '')) {
|
|
|
return this.$message.error("直播间不能选取课程");
|
|
|
- }
|
|
|
- if(!!hasLiveSetting && (this.msgForm.videoId!=null && this.msgForm.videoId!='')){
|
|
|
+ }
|
|
|
+ if (!!hasLiveSetting && (this.msgForm.videoId != null && this.msgForm.videoId != '')) {
|
|
|
return this.$message.error("直播间不能选取课节");
|
|
|
- }
|
|
|
-
|
|
|
- this.msgForm.setting=JSON.stringify(this.setting)
|
|
|
+ }
|
|
|
|
|
|
- let jsonSetting = JSON.parse(this.msgForm.setting);
|
|
|
- let hasLiveSetting = false;
|
|
|
- console.log(jsonSetting)
|
|
|
- for(let index=0;index < jsonSetting.length;index++){
|
|
|
- if(!!jsonSetting[index] && (jsonSetting[index].contentType == "12" || jsonSetting[index].contentType == "18" || jsonSetting[index].contentType == "19") ) {
|
|
|
- if(!!hasLiveSetting){
|
|
|
- return this.$message.error("发送直播间只能一次只能发送一条");
|
|
|
+ this.msgForm.setting = JSON.stringify(this.setting)
|
|
|
+
|
|
|
+ let jsonSetting = JSON.parse(this.msgForm.setting);
|
|
|
+ let hasLiveSetting = false;
|
|
|
+ console.log(jsonSetting)
|
|
|
+ for (let index = 0; index < jsonSetting.length; index++) {
|
|
|
+ if (!!jsonSetting[index] && (jsonSetting[index].contentType == "12" || jsonSetting[index].contentType == "18" || jsonSetting[index].contentType == "19")) {
|
|
|
+ if (!!hasLiveSetting) {
|
|
|
+ return this.$message.error("发送直播间只能一次只能发送一条");
|
|
|
+ }
|
|
|
+ hasLiveSetting = true;
|
|
|
+ }
|
|
|
}
|
|
|
- hasLiveSetting = true;
|
|
|
- }
|
|
|
- }
|
|
|
if (this.setting.length <= 0) {
|
|
|
return this.$message.error("请添加规则")
|
|
|
}
|
|
|
- if ((this.msgForm.courseId===null || this.msgForm.courseId==='') && !hasLiveSetting && this.msgForm.liveId===null){
|
|
|
+ if ((this.msgForm.courseId === null || this.msgForm.courseId === '') && !hasLiveSetting && this.msgForm.liveId === null) {
|
|
|
return this.$message.error("课程不能为空")
|
|
|
}
|
|
|
|
|
|
- if ((this.msgForm.videoId===null || this.msgForm.videoId==='') && !hasLiveSetting && this.msgForm.liveId===null){
|
|
|
+ if ((this.msgForm.videoId === null || this.msgForm.videoId === '') && !hasLiveSetting && this.msgForm.liveId === null) {
|
|
|
return this.$message.error("课节不能为空")
|
|
|
}
|
|
|
|
|
|
- if (this.msgForm.courseType===null || this.msgForm.courseType===''){
|
|
|
+ if (this.msgForm.courseType === null || this.msgForm.courseType === '') {
|
|
|
return this.$message.error("消息类型不能为空")
|
|
|
}
|
|
|
|
|
|
@@ -964,16 +1036,16 @@ export default {
|
|
|
if (this.setting[i].contentType == 2 && (this.setting[i].imgUrl == null || this.setting[i].imgUrl == "")) {
|
|
|
return this.$message.error("图片不能为空")
|
|
|
}
|
|
|
- if ((this.setting[i].contentType == 3 || this.setting[i].contentType == 9 ) && (this.setting[i].linkTitle == null || this.setting[i].linkTitle == "")) {
|
|
|
+ if ((this.setting[i].contentType == 3 || this.setting[i].contentType == 9) && (this.setting[i].linkTitle == null || this.setting[i].linkTitle == "")) {
|
|
|
return this.$message.error("链接标题不能为空")
|
|
|
}
|
|
|
- if ((this.setting[i].contentType == 3 || this.setting[i].contentType == 9 ) && (this.setting[i].linkDescribe == null || this.setting[i].linkDescribe == "")) {
|
|
|
+ if ((this.setting[i].contentType == 3 || this.setting[i].contentType == 9) && (this.setting[i].linkDescribe == null || this.setting[i].linkDescribe == "")) {
|
|
|
return this.$message.error("链接描述不能为空")
|
|
|
}
|
|
|
- if ((this.setting[i].contentType == 3 || this.setting[i].contentType == 9 ) && (this.setting[i].linkImageUrl == null || this.setting[i].linkImageUrl == "")) {
|
|
|
+ if ((this.setting[i].contentType == 3 || this.setting[i].contentType == 9) && (this.setting[i].linkImageUrl == null || this.setting[i].linkImageUrl == "")) {
|
|
|
return this.$message.error("链接图片不能为空")
|
|
|
}
|
|
|
- if ((this.setting[i].contentType == 3 || this.setting[i].contentType == 9 )&& this.setting[i].type == 1 && (this.setting[i].linkUrl == null || this.setting[i].linkUrl == "")) {
|
|
|
+ if ((this.setting[i].contentType == 3 || this.setting[i].contentType == 9) && this.setting[i].type == 1 && (this.setting[i].linkUrl == null || this.setting[i].linkUrl == "")) {
|
|
|
return this.$message.error("链接地址不能为空")
|
|
|
}
|
|
|
|
|
|
@@ -1001,32 +1073,50 @@ export default {
|
|
|
if (this.setting[i].contentType == 14 && (this.setting[i].luckyBagId == null || this.setting[i].luckyBagId === "")) {
|
|
|
return this.$message.error("福袋不能为空")
|
|
|
}
|
|
|
- if(this.setting[i].contentType == 12 && (this.setting[i].liveId==null || this.setting[i].liveId == "")){
|
|
|
+ if (this.setting[i].contentType == 12 && (this.setting[i].liveId == null || this.setting[i].liveId == "")) {
|
|
|
return this.$message.error("直播间不能为空");
|
|
|
}
|
|
|
+ // 短信模板验证
|
|
|
+ if (item.contentType == 21 && (item.smsTemplateId == null || item.smsTemplateId === "")) {
|
|
|
+ return this.$message.error("短信模板不能为空")
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- this.sendMsgOpen.open = false;
|
|
|
-
|
|
|
- const loading = this.$loading({
|
|
|
- lock: true,
|
|
|
- text: '正在执行中请稍后~~请不要刷新页面!!',
|
|
|
- spinner: 'el-icon-loading',
|
|
|
- background: 'rgba(0, 0, 0, 0.7)'
|
|
|
- });
|
|
|
-
|
|
|
- sendMsgSopType(this.msgForm).then(response => {
|
|
|
- this.msgSuccess("一键群发成功");
|
|
|
- loading.close();
|
|
|
- this.setting=[];
|
|
|
- this.resetSendMsgSop();
|
|
|
- }).finally(()=>{
|
|
|
- loading.close();
|
|
|
- });
|
|
|
|
|
|
+ // 短信模板数据映射
|
|
|
+ for (let j = 0; j < processedSetting.length; j++) {
|
|
|
+ const item = processedSetting[j];
|
|
|
+ if (item.contentType == 21 && item.smsTemplateId) {
|
|
|
+ // 根据选中的短信模板ID查找对应的模板信息
|
|
|
+ const selectedTemplate = this.smsTemplateList.find(template => template.tempId === item.smsTemplateId);
|
|
|
+ if (selectedTemplate) {
|
|
|
+ // 设置短信模板的相关字段
|
|
|
+ this.$set(item, 'smsTemplateCode', selectedTemplate.tempCode || '');
|
|
|
+ this.$set(item, 'smsTemplateTitle', selectedTemplate.title || '');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 重新序列化处理后的数据
|
|
|
+ this.msgForm.setting = JSON.stringify(processedSetting);
|
|
|
+
|
|
|
+
|
|
|
+ this.sendMsgOpen.open = false;
|
|
|
+
|
|
|
+ const loading = this.$loading({
|
|
|
+ lock: true,
|
|
|
+ text: '正在执行中请稍后~~请不要刷新页面!!',
|
|
|
+ spinner: 'el-icon-loading',
|
|
|
+ background: 'rgba(0, 0, 0, 0.7)'
|
|
|
+ });
|
|
|
+
|
|
|
+ sendMsgSopType(this.msgForm).then(response => {
|
|
|
+ this.msgSuccess("一键群发成功");
|
|
|
+ loading.close();
|
|
|
+ this.setting = [];
|
|
|
+ this.resetSendMsgSop();
|
|
|
+ }).finally(() => {
|
|
|
+ loading.close();
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
});
|
|
|
},
|