Parcourir la source

"我的企微客户"增加短信发送课程链接的功能

cgp il y a 1 mois
Parent
commit
ce1b514136

+ 9 - 0
src/api/qw/externalContact.js

@@ -332,3 +332,12 @@ export function companyTransfer(data) {
     data: data
   })
 }
+
+//发送课程链接短信
+export function sendCourseLinkMsg(data) {
+  return request({
+    url: '/qw/smsLinkRemindCourse/sendCourseLinkMsg',
+    method: 'post',
+    data: data
+  })
+}

+ 131 - 1
src/views/qw/externalContact/myExternalContact.vue

@@ -369,6 +369,7 @@
           </el-button>
           <el-button v-show="!scope.row.isHavePhone && scope.row.fsUserId" size="mini" type="text"
             @click="handleBindUserPhone(scope.row)" v-hasPermi="['his:user:binPhone']">绑定手机号</el-button>
+          <el-button v-show="scope.row.isHavePhone && scope.row.fsUserId" size="mini" type="text" icon="el-icon-message" @click="handleSendSms(scope.row)">发送短信</el-button>
         </template>
       </el-table-column>
     </el-table>
@@ -376,6 +377,36 @@
     <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
       @pagination="getList" />
 
+    <!-- 发送课程链接短信弹窗 -->
+    <el-dialog title="发送课程链接短信" :visible.sync="sendSmsDialog.open" width="800px" append-to-body>
+      <el-form ref="sendSmsForm" :model="sendSmsForm" :rules="sendSmsRules" label-width="120px">
+        <el-form-item label="课程" prop="courseId">
+          <el-select v-model="sendSmsForm.courseId" placeholder="请选择课程" style=" margin-right: 10px;" size="mini" @change="sendMsgCourseChange(sendSmsForm)">
+            <el-option
+              v-for="dict in courseList"
+              :key="dict.dictValue"
+              :label="dict.dictLabel"
+              :value="parseInt(dict.dictValue)"
+            />
+          </el-select>
+        </el-form-item>
+        <el-form-item label="小节" prop="videoId">
+          <el-select v-model="sendSmsForm.videoId" placeholder="请选择小节" size="mini" style=" margin-right: 10px;" @change="videoIdChange(sendSmsForm)">
+            <el-option
+              v-for="dict in videoList"
+              :key="dict.dictValue"
+              :label="dict.dictLabel"
+              :value="parseInt(dict.dictValue)"
+            />
+          </el-select>
+        </el-form-item>
+      </el-form>
+      <div slot="footer" class="dialog-footer">
+        <el-button @click="cancelSendSms">取 消</el-button>
+        <el-button type="primary" @click="submitSendSms">确 定</el-button>
+      </div>
+    </el-dialog>
+
     <!-- 添加或修改初诊单对话框 -->
     <el-dialog title="初诊单" :visible.sync="diagnosisOpen" width="1000px" append-to-body>
       <el-form ref="diagnosisForm" :model="diagnosisForm" :rules="diagnosisRules" label-width="110px">
@@ -924,7 +955,7 @@ import {
   setCustomerCourseSop,
   getCustomerCourseSop,
   setCustomerCourseSopList,
-  syncMyExternalContact, unBindUserId, updateExternalContactCall, exportMyExternalContact, updateExternalContactStatus, getWatchLogList
+  syncMyExternalContact, unBindUserId, updateExternalContactCall, exportMyExternalContact, updateExternalContactStatus, getWatchLogList,sendCourseLinkMsg
 } from '@/api/qw/externalContact'
 
 import { listPatient } from "@/api/store/patient";
@@ -959,6 +990,30 @@ export default {
   components: { PaginationMore, mycustomer, customerDetails, SopDialog, selectUser, info, Collection, userDetails, addUserAddress, addPatient },
   data() {
     return {
+      //发送短信弹窗相关数据
+      sendSmsDialog: {
+        open: false,
+        title: "发送课程链接短信",
+      },
+      //发送短信表单数据
+      sendSmsForm: {
+        fsUserId: null,
+        userId: null,
+        externalId: null,
+        courseId: null,
+        videoId: null,
+        corpId: null,
+      },
+      //发送短信表单验证规则
+      sendSmsRules: {
+        courseId: [
+          { required: true, message: "请选择课程", trigger: "change" }
+        ],
+        videoId: [
+          { required: true, message: "请选择小节", trigger: "change" }
+        ]
+      },
+
       //绑定会员手机号----
       bindUserPhone: {
         open: false
@@ -1054,6 +1109,7 @@ export default {
       },
       projectOptions: [],
       courseLists: [],
+      courseList: [],
       videoList: [],
       //重粉记录的参数
       log: {
@@ -2530,6 +2586,80 @@ export default {
       })
 
     },
+
+    //打开发送短信弹窗
+    handleSendSms(row) {
+      // 重置表单和验证
+      this.resetForm("sendSmsForm");
+      // 清空弹窗内的下拉列表
+      this.courseList = [];
+      this.videoList = [];
+      // 初始化表单数据,从当前行获取必要参数
+      this.sendSmsForm.fsUserId = row.fsUserId;
+      this.sendSmsForm.userId = row.userId;
+      this.sendSmsForm.externalId = row.id;
+      this.sendSmsForm.corpId = row.corpId;
+      // 打开弹窗
+      this.sendSmsDialog.open = true;
+      courseList().then(response => {
+        // 确保 response.list 存在且是一个数组
+        if (response && Array.isArray(response.list)) {
+          this.courseList = response.list;
+        } else {
+          // 可以选择显示一个提示信息给用户
+          this.$message.error("获取课程列表失败,请稍后重试。");
+        }
+      }).catch(error => {
+        this.$message.error("网络错误,获取课程列表失败。");
+      });
+    },
+
+    //课程选择变化时的处理
+    sendMsgCourseChange(form) {
+      // 清空 videoId 选择
+      this.$set(form, 'videoId', null);
+      // 清空 videoList
+      this.videoList = [];
+
+      if (form.courseId != null) {
+        // 获取新的 videoList
+        videoList(form.courseId).then(response => {
+          this.videoList = response.list;
+        });
+      }
+    },
+
+    //小节选择变化时的处理
+    videoIdChange(form) {
+
+    },
+
+    //提交发送课程链接短信
+    submitSendSms() {
+      this.$refs["sendSmsForm"].validate((valid) => {
+        if (valid) {
+          // 调用API发送短信
+          sendCourseLinkMsg(this.sendSmsForm).then(response => {
+            if (response.code === 200) {
+              this.msgSuccess("短信发送成功");
+              this.sendSmsDialog.open = false; // 关闭弹窗
+            } else {
+              this.msgError(response.msg || "短信发送失败");
+            }
+          }).catch(err => {
+            console.error("发送短信请求失败:", err);
+            this.msgError("请求失败,请稍后重试");
+          });
+        }
+      });
+    },
+
+    //取消发送短信
+    cancelSendSms() {
+      this.sendSmsDialog.open = false;
+      this.resetForm("sendSmsForm");
+    },
+
   }
 };
 </script>