|
@@ -40,18 +40,43 @@
|
|
|
</div>
|
|
|
|
|
|
<div v-if="form.msgType=='3'">
|
|
|
- <el-form-item label="小程序标题:" prop="miniprogramTitle">
|
|
|
- <el-input v-model="form.miniprogramTitle" placeholder="请输入小程序消息标题,最长为21字" />
|
|
|
- </el-form-item>
|
|
|
- <el-form-item label="上传小程序封面:" prop="miniprogramPicUrl">
|
|
|
- <ImageUpload v-model="form.miniprogramPicUrl" type="image" :num="10" :width="150" :height="150" />
|
|
|
- </el-form-item>
|
|
|
- <el-form-item label="小程序appid:" prop="miniprogramAppid">
|
|
|
- <el-input v-model="form.miniprogramAppid" placeholder="请输入小程序appid,必须是关联到企业的小程序应用" />
|
|
|
- </el-form-item>
|
|
|
- <el-form-item label="小程序page路径:" prop="miniprogramPage">
|
|
|
- <el-input v-model="form.miniprogramPage" placeholder="请输入小程序page路径" />
|
|
|
+
|
|
|
+ <el-form-item label="选择课程" prop="videoId" >
|
|
|
+ <el-select v-model="form.courseId" placeholder="请选择课程" style=" margin-right: 10px;" size="mini" @change="courseChange(form)">
|
|
|
+ <el-option
|
|
|
+ v-for="dict in courseList"
|
|
|
+ :key="dict.dictValue"
|
|
|
+ :label="dict.dictLabel"
|
|
|
+ :value="parseInt(dict.dictValue)"
|
|
|
+ />
|
|
|
+ </el-select>
|
|
|
+ <el-select v-model="form.videoId" placeholder="请选择小节" size="mini" style=" margin-right: 10px;" @change="videoIdChange(form)" >
|
|
|
+ <el-option
|
|
|
+ v-for="dict in videoList"
|
|
|
+ :key="dict.dictValue"
|
|
|
+ :label="dict.dictLabel"
|
|
|
+ :value="parseInt(dict.dictValue)"
|
|
|
+ />
|
|
|
+ </el-select>
|
|
|
</el-form-item>
|
|
|
+
|
|
|
+ <div v-if="form.videoId!=null">
|
|
|
+ <el-form-item label="小程序标题:" prop="miniprogramTitle">
|
|
|
+ <el-input v-model="form.miniprogramTitle" :rows="2" maxlength="64" placeholder="请输入小程序消息标题,最长为64字节" @input="checkByteLength(form)" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="小程序封面:" prop="miniprogramPicUrl">
|
|
|
+ <img :src="form.miniprogramPicUrl" width="150px" height="150px">
|
|
|
+ </el-form-item>
|
|
|
+ <div v-if="form.videoId!=null">
|
|
|
+ <el-form-item label="小程序链接:" label-width="100px" >
|
|
|
+ <el-tag type="warning" v-model="form.miniprogramPage='待生成'">选择的课程小节 即为卡片小程序链接地址</el-tag>
|
|
|
+ </el-form-item>
|
|
|
+ </div>
|
|
|
+ <el-form-item label="appid" prop="miniprogramAppid" v-show="false" >
|
|
|
+ <el-input v-model="form.miniprogramAppid" disabled />
|
|
|
+ </el-form-item>
|
|
|
+ </div>
|
|
|
+
|
|
|
</div>
|
|
|
|
|
|
<div v-if="form.msgType=='4'">
|
|
@@ -97,7 +122,7 @@
|
|
|
</el-radio-group>
|
|
|
</el-form-item>
|
|
|
|
|
|
- <el-form-item label="是否定时发送" prop="isTimerSend">
|
|
|
+ <el-form-item label="是否定时发送" prop="isTimerSend" v-show="form.msgType!='3'">
|
|
|
<el-radio-group v-model="form.isTimerSend" size="medium">
|
|
|
<el-radio v-for="dict in allowSelectOptions" :label="dict.dictValue">{{dict.dictLabel}}</el-radio>
|
|
|
</el-radio-group>
|
|
@@ -221,6 +246,7 @@
|
|
|
<script>
|
|
|
import { listWelcome, getWelcome, delWelcome, addWelcome, updateWelcome, exportWelcome } from "@/api/qw/welcome";
|
|
|
import ImageUpload from "@/views/qw/material/ImageUpload";
|
|
|
+import {courseList, videoList} from "../../../api/qw/sop";
|
|
|
|
|
|
export default {
|
|
|
name: "Welcome",
|
|
@@ -228,6 +254,10 @@ export default {
|
|
|
|
|
|
data() {
|
|
|
return {
|
|
|
+
|
|
|
+ courseList:[],
|
|
|
+ videoList:[],
|
|
|
+
|
|
|
//上传地址
|
|
|
uploadUrl:process.env.VUE_APP_BASE_API+"/common/uploadOSS",
|
|
|
//放大图片
|
|
@@ -277,7 +307,11 @@ export default {
|
|
|
],
|
|
|
linkUrl:[
|
|
|
{required:true,message:"图文链接地址不能为空",trigger:"blur"}
|
|
|
+ ],
|
|
|
+ videoId: [
|
|
|
+ { required: true, message: '请选择小节', trigger: 'blur' }
|
|
|
]
|
|
|
+
|
|
|
}
|
|
|
};
|
|
|
},
|
|
@@ -285,9 +319,14 @@ export default {
|
|
|
|
|
|
//文本类型字典
|
|
|
this.getDicts("sys_qw_welcome_type").then(response => {
|
|
|
+ console.log("response",response)
|
|
|
this.groupMsgTextTypeOptions = response.data;
|
|
|
});
|
|
|
|
|
|
+ courseList().then(response => {
|
|
|
+ this.courseList = response.list;
|
|
|
+ });
|
|
|
+
|
|
|
// //全部客户还是部分客户
|
|
|
// this.getDicts("sys_qw_groupMsg_type").then(response => {
|
|
|
// this.groupMsgTypeOptions = response.data;
|
|
@@ -315,6 +354,83 @@ export default {
|
|
|
},
|
|
|
methods: {
|
|
|
|
|
|
+
|
|
|
+ courseChange(form){
|
|
|
+
|
|
|
+ // 清空 videoId 选择
|
|
|
+ this.$set(form, 'videoId', null);
|
|
|
+ // 清空 videoList
|
|
|
+ this.videoList = [];
|
|
|
+
|
|
|
+ if (form.courseId != null) {
|
|
|
+ // 查找选中的课程对应的 label 和 dictImgUrl
|
|
|
+ const selectedCourse = this.courseList.find(course => parseInt(course.dictValue) === form.courseId);
|
|
|
+
|
|
|
+ if (selectedCourse) {
|
|
|
+ // 设置 linkTitle 和 linkImageUrl
|
|
|
+ this.$set(form, 'miniprogramPicUrl', selectedCourse.dictImgUrl);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ // 获取新的 videoList
|
|
|
+ videoList(form.courseId).then(response => {
|
|
|
+ this.videoList = response.list;
|
|
|
+ });
|
|
|
+
|
|
|
+ }
|
|
|
+ },
|
|
|
+ videoIdChange(form){
|
|
|
+ //选择了课程小节则 默认绑上
|
|
|
+ if (form.videoId != null) {
|
|
|
+ // 根据 videoId 获取相关信息(假设有相关的 API 调用)
|
|
|
+ let selectedVideo = this.videoList.find(course => parseInt(course.dictValue) === form.videoId);
|
|
|
+ console.log("selectedVideo",selectedVideo)
|
|
|
+ if (selectedVideo && form.msgType==='3' ) {
|
|
|
+ this.$set(form, 'miniprogramTitle', this.truncateTextByByteLength(selectedVideo.dictLabel,64));
|
|
|
+ this.$set(form, 'expiresDays', 30);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+ // 检查字节长度
|
|
|
+ checkByteLength(form) {
|
|
|
+ const text = form.miniprogramTitle;
|
|
|
+ const byteLength = this.getByteLength(text); // 获取当前字节数
|
|
|
+
|
|
|
+ // 如果字节数超过64,截断输入内容
|
|
|
+ if (byteLength > 64) {
|
|
|
+ this.$set(form, 'miniprogramTitle', this.truncateTextByByteLength(text,64));
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ // 计算字符串的字节数
|
|
|
+ getByteLength(text) {
|
|
|
+ return new Blob([text]).size; // 使用 Blob 计算字节数
|
|
|
+ },
|
|
|
+
|
|
|
+ // 根据字节数截断字符串
|
|
|
+ truncateTextByByteLength(text, maxByteLength) {
|
|
|
+ let byteLength = 0;
|
|
|
+ let result = "";
|
|
|
+
|
|
|
+ for (let i = 0; i < text.length; i++) {
|
|
|
+ const char = text[i];
|
|
|
+ const charByteLength = this.getByteLength(char); // 获取当前字符的字节数
|
|
|
+
|
|
|
+ // 如果加上当前字符的字节数后不超过限制,则添加到结果中
|
|
|
+ if (byteLength + charByteLength <= maxByteLength) {
|
|
|
+ result += char;
|
|
|
+ byteLength += charByteLength;
|
|
|
+ } else {
|
|
|
+ break; // 超过限制时停止
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return result;
|
|
|
+ },
|
|
|
+
|
|
|
/** 表单验证 */
|
|
|
async validateChildForm() {
|
|
|
return new Promise((resolve, reject) => {
|