Browse Source

1、自动发送直播链接

yys 1 ngày trước cách đây
mục cha
commit
7732f05c8a

+ 172 - 35
src/views/qw/sopUserLogsInfo/sendMsgOpenTool.vue

@@ -309,6 +309,36 @@
                         </el-form-item>
                       </el-card>
                     </div>
+                    <div v-if="item.contentType == 20">
+                      <el-card class="box-card">
+                        <el-form-item label="直播间" >
+                          <el-select  v-model="item.liveId"
+                                      placeholder="请选择直播间" size="mini"
+                                      @change="liveChange(item)" >
+                            <el-option
+                              v-for="dict in liveList"
+                              :key="dict.liveId"
+                              :label="dict.liveName"
+                              :value="dict.liveId"
+                            />
+                          </el-select>
+                        </el-form-item>
+
+                        <el-form-item label="标题" prop="miniprogramTitle">
+                          <el-input v-model="item.miniprogramTitle" placeholder="请输入小程序消息标题,最长为64字节" :rows="2" maxlength="64"
+                                    type="textarea"   @input="checkLiveMiniprogramTitle(item)"/>
+                        </el-form-item>
+                        <el-form-item label="封面" prop="miniprogramPicUrl">
+                          <ImageUpload v-model="item.miniprogramPicUrl" type="image" :num="10" :width="150" :height="150" />
+                        </el-form-item>
+                        <el-form-item label="appid" prop="miniprogramAppid" v-show="false">
+                          <el-input v-model="item.miniprogramAppid='wxcfd4cd6e2375e42f' " disabled />
+                        </el-form-item>
+                        <el-form-item label="page路径" prop="miniprogramPage"  v-show="false" label-width="100px" style="margin-left: -30px">
+                          <el-input v-model="item.miniprogramPage" placeholder="小程序消息打开后的路径"  disabled />
+                        </el-form-item>
+                      </el-card>
+                    </div>
                     <div v-if="item.contentType == 14">
                       <el-card class="box-card">
                         <el-form-item label="福袋名称" >
@@ -331,6 +361,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 +455,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 +537,7 @@ export default {
         open:false,
         ids:null,
       },
+      smsTemplateList: [],
       // 表单参数
       form: {},
       setting:[{contentType:'1', value: '',}],
@@ -527,12 +580,13 @@ export default {
       this.courseList = response.list;
     });
 
-    // listToLiveNoEnd().then(response => {
-    //   this.liveList = response.rows;
-    // })
+    listToLiveNoEnd().then(response => {
+      this.liveList = response.rows;
+    })
     listReward(this.queryParams1).then(response => {
       this.luckyBagList = response.rows;
     });
+    this.loadSmsTemplates();
   },
   methods: {
     getLuckyBagStatus(content) {
@@ -545,6 +599,9 @@ export default {
       }
     },
 
+    checkLiveMiniprogramTitle(item) {
+      this.$forceUpdate();
+    },
     liveChange(content) {
       // content.liveId 是选中的直播间 ID(liveId)
       const selectedLive = this.liveList.find(live => live.liveId === content.liveId);
@@ -578,7 +635,6 @@ export default {
 
     },
     oneClickGroupSending(val,type,corpId){
-
       this.sendMsgOpen.open= true;
       this.msgForm.ids = val;
       this.msgForm.type = type;
@@ -904,6 +960,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)
@@ -912,28 +1016,25 @@ export default {
     },
 
     submitMsgForm(){
-
       this.$refs["msgForm"].validate(valid => {
         if (valid) {
 
+          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)
+            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 (!!jsonSetting[index] && (jsonSetting[index].contentType == "12" || jsonSetting[index].contentType == "18" || jsonSetting[index].contentType == "19" || jsonSetting[index].contentType == "20")) {
                 if (!!hasLiveSetting) {
                   return this.$message.error("发送直播间只能一次只能发送一条");
                 }
@@ -1002,29 +1103,65 @@ export default {
               if ((this.setting[i].contentType == 12 || this.setting[i].contentType == 24) && (this.setting[i].liveId == null || this.setting[i].liveId == "")) {
                 return this.$message.error("直播间不能为空");
               }
+              if (this.setting[i].contentType == 20 && (this.setting[i].liveId == null || this.setting[i].liveId == "")) {
+                return this.$message.error("直播间不能为空");
+              }
+              if (this.setting[i].contentType == 20 && (this.setting[i].miniprogramTitle == null || this.setting[i].miniprogramTitle == "")) {
+                return this.$message.error("标题不能为空");
+              }
+              if (this.setting[i].contentType == 20 && (this.setting[i].miniprogramPicUrl == null || this.setting[i].miniprogramPicUrl == "")) {
+                return this.$message.error("封面不能为空");
+              }
+              // 短信模板验证
+              if (this.setting[i].contentType == 21 && (this.setting[i].smsTemplateId == null || this.setting[i].smsTemplateId === "")) {
+                return this.$message.error("短信模板不能为空")
+              }else {
+                if (this.setting[i].contentType == 21 && this.setting[i].smsTemplateId) {
+                  // 根据选中的短信模板ID查找对应的模板信息
+                  const selectedTemplate = this.smsTemplateList.find(template => template.tempId === this.setting[i].smsTemplateId);
+                  if (selectedTemplate) {
+                    // 设置短信模板的相关字段
+                    this.$set(this.setting[i], 'smsTemplateCode', selectedTemplate.tempCode || '');
+                    this.$set(this.setting[i], 'smsTemplateTitle', selectedTemplate.title || '');
+                  }
+                }
+              }
             }
-          }
-
-
-
-          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.msgForm.setting = JSON.stringify(this.setting)
+            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();
+            });
+          }
         }
       });
     },

+ 143 - 7
src/views/qw/sopUserLogsInfo/sopUserLogsInfoDetails.vue

@@ -407,7 +407,7 @@
                         placeholder="输入要转为语音的内容" style="width: 90%;margin-top: 10px;"
                         @input="handleInputVideoText(item.value,item)"/>
                     </div>
-                    <div v-if="item.contentType == 12 || item.contentType == 24">
+                    <div v-if="item.contentType == 12 || item.contentType == 24 || item.contentType == 18 || item.contentType == 19">
                       <!--                                           <div >-->
                       <el-card class="box-card">
                         <el-form-item label="直播间" >
@@ -439,6 +439,36 @@
                         </el-form-item>
                       </el-card>
                     </div>
+                    <div v-if="item.contentType == 20">
+                      <el-card class="box-card">
+                        <el-form-item label="直播间" >
+                          <el-select  v-model="item.liveId"
+                                      placeholder="请选择直播间" size="mini"
+                                      @change="liveChange(item)" >
+                            <el-option
+                              v-for="dict in liveList"
+                              :key="dict.liveId"
+                              :label="dict.liveName"
+                              :value="dict.liveId"
+                            />
+                          </el-select>
+                        </el-form-item>
+
+                        <el-form-item label="标题" prop="miniprogramTitle">
+                          <el-input v-model="item.miniprogramTitle" placeholder="请输入小程序消息标题,最长为64字节" :rows="2" maxlength="64"
+                                    type="textarea"    @input="checkLiveMiniprogramTitle(item)" />
+                        </el-form-item>
+                        <el-form-item label="封面" prop="miniprogramPicUrl">
+                          <ImageUpload v-model="item.miniprogramPicUrl" type="image" :num="10" :width="150" :height="150" />
+                        </el-form-item>
+                        <el-form-item label="appid" prop="miniprogramAppid" v-show="false">
+                          <el-input v-model="item.miniprogramAppid='wxcfd4cd6e2375e42f' " disabled />
+                        </el-form-item>
+                        <el-form-item label="page路径" prop="miniprogramPage"  v-show="false" label-width="100px" style="margin-left: -30px">
+                          <el-input v-model="item.miniprogramPage" placeholder="小程序消息打开后的路径"  disabled />
+                        </el-form-item>
+                      </el-card>
+                    </div>
                     <div v-if="item.contentType == 8">
                       <el-button type="primary"
                                  style="margin-bottom: 1%"
@@ -501,6 +531,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>
 
                   <el-form-item label="添加短链" v-if="item.contentType == 1 || item.contentType == 15"  >
@@ -631,6 +682,7 @@ import userVideo from "@/views/qw/userVideo/userVideo.vue";
 import PaginationMore from "../../../components/PaginationMore/index.vue";
 import {listToLiveNoEnd} from "@/api/live/live";
 import {listReward} from "@/api/qw/luckyBag";
+import { getSmsTempList } from "@/api/company/companySmsTemp";
 
 export default {
   name: "sopUserLogsInfoDetails",
@@ -708,6 +760,7 @@ export default {
 
       tagGroupList: [],
 
+      smsTemplateList: [],
       tagTotal:0,
 
       //标签
@@ -792,9 +845,7 @@ export default {
       this.luckyBagList = response.rows;
     });
 
-
-    console.log("listToLiveNoEnd",this.projectFrom);
-
+    this.loadSmsTemplates();
   },
   methods: {
     getLuckyBagStatus(content) {
@@ -807,6 +858,9 @@ export default {
       }
     },
 
+    checkLiveMiniprogramTitle(item) {
+      this.$forceUpdate();
+    },
     liveChange(content) {
       // content.liveId 是选中的直播间 ID(liveId)
       const selectedLive = this.liveList.find(live => live.liveId === content.liveId);
@@ -1021,7 +1075,7 @@ export default {
               }
             }
 
-            if (this.setting[i].contentType == 4 || this.setting[i].contentType == 17){
+            if (this.setting[i].contentType == 4 || this.setting[i].contentType == 17|| this.setting[i].contentType == 23){
               this.$set(this.setting[i], 'miniprogramTitle', selectedVideo.dictLabel);
 
               if (this.projectFrom == 'sxjz' && selectedVideo.dictImgUrl) {
@@ -1326,6 +1380,8 @@ export default {
 
     resetSendMsgSop() {
       this.msgForm = {
+        liveId:null,
+        // liveMsgType:null,
         videoId:null,
         courseId:null,
         courseType:null,
@@ -1366,6 +1422,53 @@ export default {
       this.resetForm("queryForm");
       this.handleQuery();
     },
+    // 获取短信模板信息(类似福袋的处理方式)
+    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)
@@ -1403,14 +1506,31 @@ export default {
           this.msgForm.corpId=this.queryParams.corpIdParam;
           this.msgForm.filterMode=this.queryParams.filterMode;
 
+          let hasLiveSetting = false;
+          let jsonSetting = JSON.parse(this.msgForm.setting);
+          for(let index=0;index < jsonSetting.length;index++){
+           if(!!jsonSetting[index] && (jsonSetting[index].contentType == "12" || jsonSetting[index].contentType == "20") ) {
+            if(!!hasLiveSetting){
+               return this.$message.error("发送直播间只能一次只能发送一条");
+            }
+            hasLiveSetting = true;
+           }
+          }
+          if(!!hasLiveSetting && (this.msgForm.courseId!=null && this.msgForm.courseId!='')){
+              return this.$message.error("直播间不能选取课程");
+          }
+          if(!!hasLiveSetting && (this.msgForm.videoId!=null && this.msgForm.videoId!='')){
+              return this.$message.error("直播间不能选取课节");
+          }
+
           if (this.setting.length <= 0) {
             return this.$message.error("请添加规则")
           }
-          if (this.msgForm.courseId===null || this.msgForm.courseId===''){
+          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===''){
+          if ((this.msgForm.videoId===null || this.msgForm.videoId==='') && !hasLiveSetting && this.msgForm.liveId===null){
             return this.$message.error("课节不能为空")
           }
 
@@ -1452,9 +1572,25 @@ export default {
             }
             if (this.setting[i].contentType == 7 && (this.setting[i].value == null || this.setting[i].value == "")) {
               return this.$message.error("语音不能为空")
+            }// 短信模板验证
+            if (this.setting[i].contentType == 21 && (this.setting[i].smsTemplateId == null || this.setting[i].smsTemplateId === "")) {
+              return this.$message.error("短信模板不能为空")
+            }else {
+              if (this.setting[i].contentType == 21 && this.setting[i].smsTemplateId) {
+                // 根据选中的短信模板ID查找对应的模板信息
+                const selectedTemplate = this.smsTemplateList.find(template => template.tempId === this.setting[i].smsTemplateId);
+                if (selectedTemplate) {
+                  // 设置短信模板的相关字段
+                  this.$set(this.setting[i], 'smsTemplateCode', selectedTemplate.tempCode || '');
+                  this.$set(this.setting[i], 'smsTemplateTitle', selectedTemplate.title || '');
+                }
+              }
             }
           }
 
+          // 重新序列化处理后的数据
+          this.msgForm.setting=JSON.stringify(this.setting)
+
           this.sendMsgOpen.open = false;
 
           const loading = this.$loading({