|
|
@@ -484,7 +484,7 @@
|
|
|
</div>
|
|
|
<div v-if="welcomeItem.type==='miniprogram'">
|
|
|
|
|
|
- <el-form-item label="选择课程">
|
|
|
+ <el-form-item label="选择课程" prop="miniprogramCourseId">
|
|
|
<el-select v-model="fileFrom.courseId" placeholder="请选择课程" style=" margin-right: 10px;" size="mini" @change="courseChange(fileFrom,welcomeItem.index,welcomeItem.itemIndex)">
|
|
|
<el-option
|
|
|
v-for="dict in courseList"
|
|
|
@@ -532,7 +532,7 @@
|
|
|
</div>
|
|
|
</el-form>
|
|
|
<div slot="footer" class="dialog-footer" style="text-align: center">
|
|
|
- <el-button type="primary" @click="confirmUpload">确定</el-button>
|
|
|
+ <el-button type="primary" @click="confirmUpload('fileFrom')">确定</el-button>
|
|
|
<el-button type="primary" @click="cancelUpload">取消</el-button>
|
|
|
</div>
|
|
|
</el-dialog>
|
|
|
@@ -593,6 +593,24 @@ export default {
|
|
|
linkTitle:[ { required: true, message: "图文标题不能为空", trigger: "submit" }],
|
|
|
linkUrl:[ { required: true, message: "图文链接不能为空", trigger: "submit" }],
|
|
|
miniprogramTitle:[ { required: true, message: "图文链接不能为空", trigger: "submit" }],
|
|
|
+ miniprogramCourseId:[
|
|
|
+ {
|
|
|
+ required: true,
|
|
|
+ validator: (rule, value, callback) => {
|
|
|
+ // 检查id是否为空
|
|
|
+ if (!this.fileFrom.courseId) {
|
|
|
+ return callback(new Error('请选择课程'));
|
|
|
+ }
|
|
|
+ // 检查ddId是否为空
|
|
|
+ if (!this.fileFrom.videoId) {
|
|
|
+ return callback(new Error('请选择小节'));
|
|
|
+ }
|
|
|
+ // 校验通过
|
|
|
+ callback();
|
|
|
+ },
|
|
|
+ trigger: 'change' // 下拉选择变化时触发校验
|
|
|
+ }
|
|
|
+ ]
|
|
|
},
|
|
|
|
|
|
|
|
|
@@ -999,72 +1017,79 @@ export default {
|
|
|
|
|
|
//提交附件
|
|
|
confirmUpload(fileFrom) {
|
|
|
- const { type, index, itemIndex } = this.welcomeItem;
|
|
|
- let attachment = {};
|
|
|
- if (type === 'image') {
|
|
|
- attachment = {
|
|
|
- msgtype: 'image',
|
|
|
- image: {
|
|
|
- pic_url: this.fileFrom.imagePicUrl
|
|
|
- }
|
|
|
- };
|
|
|
- } else if (type === 'video') {
|
|
|
- attachment = {
|
|
|
- msgtype: 'video',
|
|
|
- video: {
|
|
|
- url:this.fileFrom.videoUrl,
|
|
|
- }
|
|
|
- };
|
|
|
- } else if (type === 'link') {
|
|
|
- attachment = {
|
|
|
- msgtype: 'link',
|
|
|
- link: {
|
|
|
- title: this.fileFrom.linkTitle,
|
|
|
- picurl: this.fileFrom.linkPicUrl,
|
|
|
- desc: this.fileFrom.linkDesc,
|
|
|
- url: this.fileFrom.linkUrl,
|
|
|
- courseId:this.fileFrom.courseId,
|
|
|
- videoId:this.fileFrom.videoId,
|
|
|
- expiresDays:this.fileFrom.expiresDays,
|
|
|
- }
|
|
|
- };
|
|
|
- }else if (type==='miniprogram'){
|
|
|
- attachment = {
|
|
|
- msgtype: 'miniprogram',
|
|
|
- miniprogram: {
|
|
|
- title: this.fileFrom.miniprogramTitle,
|
|
|
- pic_media_id: "待查询",
|
|
|
- appid: "wx73f85f8d62769119",
|
|
|
- page: this.fileFrom.miniprogramPage,
|
|
|
- courseId:this.fileFrom.courseId,
|
|
|
- videoId:this.fileFrom.videoId,
|
|
|
- expiresDays:this.fileFrom.expiresDays,
|
|
|
- }
|
|
|
- };
|
|
|
- }
|
|
|
-
|
|
|
- if (itemIndex === -1) {
|
|
|
- // 默认欢迎语附件处理
|
|
|
- if (index < this.form.attachments.length) {
|
|
|
- // 存在附件则更新
|
|
|
- this.form.attachments.splice(index, 1, attachment);
|
|
|
- } else {
|
|
|
- // 不存在附件则插入
|
|
|
- this.form.attachments.push(attachment);
|
|
|
- }
|
|
|
-
|
|
|
- } else {
|
|
|
- // 分时段欢迎语附件处理
|
|
|
- if (index < this.form.daypartingItemlist[itemIndex].attachments.length) {
|
|
|
- // 存在附件则更新
|
|
|
- this.form.daypartingItemlist[itemIndex].attachments.splice(index, 1, attachment);
|
|
|
- } else {
|
|
|
- // 不存在附件则插入
|
|
|
- this.form.daypartingItemlist[itemIndex].attachments.push(attachment);
|
|
|
- }
|
|
|
- }
|
|
|
+ this.$refs[fileFrom].validate((valid) => {
|
|
|
+ if (valid) {
|
|
|
+ const { type, index, itemIndex } = this.welcomeItem;
|
|
|
+ let attachment = {};
|
|
|
+ if (type === 'image') {
|
|
|
+ attachment = {
|
|
|
+ msgtype: 'image',
|
|
|
+ image: {
|
|
|
+ pic_url: this.fileFrom.imagePicUrl
|
|
|
+ }
|
|
|
+ };
|
|
|
+ } else if (type === 'video') {
|
|
|
+ attachment = {
|
|
|
+ msgtype: 'video',
|
|
|
+ video: {
|
|
|
+ url:this.fileFrom.videoUrl,
|
|
|
+ }
|
|
|
+ };
|
|
|
+ } else if (type === 'link') {
|
|
|
+ attachment = {
|
|
|
+ msgtype: 'link',
|
|
|
+ link: {
|
|
|
+ title: this.fileFrom.linkTitle,
|
|
|
+ picurl: this.fileFrom.linkPicUrl,
|
|
|
+ desc: this.fileFrom.linkDesc,
|
|
|
+ url: this.fileFrom.linkUrl,
|
|
|
+ courseId:this.fileFrom.courseId,
|
|
|
+ videoId:this.fileFrom.videoId,
|
|
|
+ expiresDays:this.fileFrom.expiresDays,
|
|
|
+ }
|
|
|
+ };
|
|
|
+ }else if (type==='miniprogram'){
|
|
|
+ attachment = {
|
|
|
+ msgtype: 'miniprogram',
|
|
|
+ miniprogram: {
|
|
|
+ title: this.fileFrom.miniprogramTitle,
|
|
|
+ pic_media_id: "待查询",
|
|
|
+ appid: "wx73f85f8d62769119",
|
|
|
+ page: this.fileFrom.miniprogramPage,
|
|
|
+ courseId:this.fileFrom.courseId,
|
|
|
+ videoId:this.fileFrom.videoId,
|
|
|
+ expiresDays:this.fileFrom.expiresDays,
|
|
|
+ }
|
|
|
+ };
|
|
|
+ }
|
|
|
|
|
|
- this.resetFileFrom();
|
|
|
+ if (itemIndex === -1) {
|
|
|
+ // 默认欢迎语附件处理
|
|
|
+ if (index < this.form.attachments.length) {
|
|
|
+ // 存在附件则更新
|
|
|
+ this.form.attachments.splice(index, 1, attachment);
|
|
|
+ } else {
|
|
|
+ // 不存在附件则插入
|
|
|
+ this.form.attachments.push(attachment);
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+ // 分时段欢迎语附件处理
|
|
|
+ if (index < this.form.daypartingItemlist[itemIndex].attachments.length) {
|
|
|
+ // 存在附件则更新
|
|
|
+ this.form.daypartingItemlist[itemIndex].attachments.splice(index, 1, attachment);
|
|
|
+ } else {
|
|
|
+ // 不存在附件则插入
|
|
|
+ this.form.daypartingItemlist[itemIndex].attachments.push(attachment);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.resetFileFrom();
|
|
|
+ } else {
|
|
|
+ console.log('error submit!!');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
},
|
|
|
|
|
|
//取消附件
|