提交 916ea0c9 编写于 作者: guangjun.yang's avatar guangjun.yang

剪裁及bug修改等

上级 b4b9422a
<template> <template>
<div class="rc-cropper" v-if="originImg"> <div class="rc-cropper" v-if="originImg">
<el-row> <div class="rc-cropper__canvasCrop2">
<el-col> <img :src="originImg" v-if="!cropper">
<div class="rc-cropper__canvasCrop2"> <canvas :id="originImg" ref="canvas"/>
<img :src="originImg" v-if="!cropper"> <div class="rc-cropper__iconCrop">
<canvas :id="originImg" ref="canvas"/> <el-tooltip content="确认裁剪" placement="right" v-if="cropper">
<div class="rc-cropper__iconCrop"> <el-button type="success" size="mini" @click="sureCropper()"><i class="el-icon-check"></i></el-button>
<el-tooltip content="确认裁剪" placement="right" v-if="cropper"> </el-tooltip>
<el-button type="success" size="mini" @click="sureCropper()"><i class="el-icon-check"></i></el-button> </div>
</el-tooltip> </div>
</div>
</div>
</el-col>
<!-- <el-col :span="10">
<div class="rc-cropper__previewImg">
<img :src="previewImg" id="previewImg"/>
</div>
</el-col> -->
</el-row>
</div> </div>
</template> </template>
<script> <script>
...@@ -47,6 +38,9 @@ export default { ...@@ -47,6 +38,9 @@ export default {
mounted () { mounted () {
this.drawImg() this.drawImg()
}, },
destroyed() {
this.cropper && this.cropper.destroy();
},
methods: { methods: {
// 在canvas上绘制图片 // 在canvas上绘制图片
drawImg () { drawImg () {
...@@ -54,8 +48,8 @@ export default { ...@@ -54,8 +48,8 @@ export default {
this.$nextTick(() => { this.$nextTick(() => {
let canvas = document.getElementById(this.originImg) let canvas = document.getElementById(this.originImg)
if (canvas) { if (canvas) {
canvas.width = 720 canvas.width = 1000
canvas.height = 480 canvas.height = 800
let ctx = canvas.getContext('2d') let ctx = canvas.getContext('2d')
ctx.clearRect(0, 0, canvas.width, canvas.height) ctx.clearRect(0, 0, canvas.width, canvas.height)
let img = new Image() let img = new Image()
...@@ -74,8 +68,20 @@ export default { ...@@ -74,8 +68,20 @@ export default {
this.cropper = new Cropper(this.$refs.canvas, { this.cropper = new Cropper(this.$refs.canvas, {
checkCrossOrigin: true, checkCrossOrigin: true,
viewMode: 3, viewMode: 3,
zoomOnWheel: false, // 是否可以通过移动鼠标来放大图像 zoomOnWheel: true, // 是否可以通过移动鼠标来放大图像
aspectRatio: 3 / 2, dragMode: 'move',
// autoCropArea: 0.6,
// center: true,
// autoCrop: true,
restore: false,
modal: true,
guides: true,
highlight: true,
cropBoxMovable: true,
cropBoxResizable: false,
toggleDragModeOnDblclick: false,
// aspectRatio: 75/42,
// aspectRatio: 5/3,
ready: () => { ready: () => {
this.cropper.setData({ this.cropper.setData({
x: this.cropOption.offset_x, x: this.cropOption.offset_x,
...@@ -83,19 +89,28 @@ export default { ...@@ -83,19 +89,28 @@ export default {
width: this.cropOption.width, width: this.cropOption.width,
height: this.cropOption.height height: this.cropOption.height
}) })
} // this.cropper.zoomTo(1);
},
// zoom: function (event) {
// // Keep the image in its natural size
// if (event.detail.oldRatio === 1) {
// event.preventDefault();
// }
// },
}) })
// this.cropper = cropper
}, },
// 确认裁剪 // 确认裁剪
sureCropper () { sureCropper () {
let _this = this let _this = this
const cropParam = this.cropper.getData() const cropParam = this.cropper.getData()
console.log('cropParam', cropParam);
this.cropper.getCroppedCanvas().toBlob(function (blob) { this.cropper.getCroppedCanvas().toBlob(function (blob) {
let files = new window.File([blob], 'cropper.jpg');
console.log(files);
let oFileReader = new FileReader() let oFileReader = new FileReader()
oFileReader.onloadend = function (e) { oFileReader.onloadend = function (e) {
let base64 = e.target.result let base64 = e.target.result
_this.$emit('getCropImg', base64, cropParam) _this.$emit('getCropImg', base64, cropParam, files, _this.cropper)
} }
oFileReader.readAsDataURL(blob) oFileReader.readAsDataURL(blob)
}, 'image/jpeg') }, 'image/jpeg')
...@@ -103,11 +118,16 @@ export default { ...@@ -103,11 +118,16 @@ export default {
} }
} }
</script> </script>
<style > <style scoped lang="scss">
.rc-cropper {
position: relative; // .rc-cropper {
margin-top: 20px; // position: relative;
} // margin-top: 10px;
// img {
// width: 100%;
// height: 100%;
// }
// }
/* img { /* img {
width: 100%; width: 100%;
...@@ -115,14 +135,16 @@ export default { ...@@ -115,14 +135,16 @@ export default {
} */ } */
.rc-cropper__canvasCrop2 { .rc-cropper__canvasCrop2 {
width: 900px; /* border: 1px solid red; */
height: 760px; width: 800px;
height: 540px;
} }
.rc-cropper__iconCrop { .rc-cropper__iconCrop {
position: absolute; position: absolute;
left: 45%; /* left: 8%; */
top: 0%; left: 46%;
top: 10%;
} }
.el-tooltip { .el-tooltip {
...@@ -131,8 +153,4 @@ export default { ...@@ -131,8 +153,4 @@ export default {
z-index: 10000; z-index: 10000;
} }
.rc-cropper__previewImg {
width: 600px;
height: 400px;
}
</style> </style>
<template>
<div class="edit-course-wrapper dialog-title-border">
<el-dialog
ref="testDialogRef"
title="上传课程"
:visible="dialogVisible"
@close="backToOrgCourse"
center
:close-on-click-modal="false"
:close-on-press-escape="false"
width="800px"
>
<div slot="title" style="text-align: left;">
<span style="font-weight: 700;">上传课程</span>
<span style="font-size: 12px;color: #ED3131;margin-left: 4px;">上传信息需要审核,请认真核对上传内容,一旦提交后将不能修改</span>
</div>
<div v-show="step == 1" class="course-content">
<el-form
ref="formDataRef"
:model="formData"
label-width="120px"
class="basic-form"
>
<div class="basic-item-icon">
<span class="require">*</span>
<el-form-item label="课程名称:" class="valid-msg">
<el-col :span="20">
<el-input
size="small"
v-model="formData.courseName"
placeholder="请输入课程名称"
style="width: 360px"
maxlength="25"
:disabled="disabled"
></el-input>
<span class="word-num">
{{(formData.courseName || '').replace(/\s+/g,"").length}}/25
</span>
<div v-show="!needShowAuditMsg && noCouseName" class="error" style="maring-top:2px">
<span>请输入课程名称</span>
</div>
<div v-show="needShowAuditMsg && formData.courseNameCheck" class="error" style="maring-top:2px">
<span>{{formData.courseNameCheck}}</span>
</div>
</el-col>
</el-form-item>
</div>
<div class="basic-item-icon">
<span class="require">*</span>
<el-form-item label="学科分类:" class="valid-msg">
<el-col :span="18">
<!-- :props="{ expandTrigger: 'hover' }" -->
<el-cascader
style="width: 360px"
v-model="formData.subjectIdList"
:options="labelOptions"
:props="{ value: 'id', label: 'name', children: 'subList'}"
>
</el-cascader>
<div v-show="!needShowAuditMsg && noLabel" class="error" style="margin-top:4px;">
<span>请选择学科分类</span>
</div>
</el-col>
</el-form-item>
</div>
<div class="basic-item-icon">
<span class="require">*</span>
<el-form-item label="开放范围:">
<el-radio-group v-model="formData.shareType">
<el-radio :label="1">机构共享</el-radio>
</el-radio-group>
</el-form-item>
</div>
<div class="basic-item-icon">
<span class="require">*</span>
<el-form-item label="课程视频:" prop="range" class="valid-msg">
<el-upload
class="upload-video"
:class="{'disabled': needShowUploadProcess || (formData.courseCustomChapterModels[0].courseCustomLectureModelList.length >= orgCourseInfo.limitModel.maxLimitVideoCount)}"
action="#"
:before-upload="beforeUploadVideo"
:limit="3"
:on-exceed="handleExceed"
:show-file-list="false"
:disabled="needShowUploadProcess || (formData.courseCustomChapterModels[0].courseCustomLectureModelList.length >= orgCourseInfo.limitModel.maxLimitVideoCount)"
>
<el-button size="small" type="primary">点击上传</el-button>
<div slot="tip" class="el-upload__tip">
<span class="upload-tips">只支持MP4格式,课程视频最多上传100个,单文件最大2G</span>
<ul v-show="formData.courseCustomChapterModels[0].courseCustomLectureModelList.length" class="custom-list">
<li v-for="(lecture, index) in formData.courseCustomChapterModels[0].courseCustomLectureModelList" :key="index" class="valid-msg">
<ul class="video">
<li style="height: 46px;line-height:48px;">
<span class="title">视频{{index + 1}}</span>
<img src="../../../assets/image/phrase3/icon-pin.png" />
<span class="name" @click="previewVideoAction(lecture)">{{lecture.resourceModel.name}}</span>
</li>
<li>
<img @click="deleteLecture(index)" class="delete" src="../../../assets/image/phrase3/close.png" />
</li>
<div style="color:red;;position:absolute;top:22px;" v-show="needShowAuditMsg && formData.courseCustomChapterModels[0].courseCustomLectureModelList[index].contentCheck" class="error-video">
<span>{{formData.courseCustomChapterModels[0].courseCustomLectureModelList[index].contentCheck}}</span>
</div>
</ul>
<div class="video-name">
<span class="title">
<span >*</span>
<span class="video-title">视频名称</span>
</span>
<el-input
size="small"
v-model="lecture.name"
placeholder="请输入课程名称"
style="width: 260px"
maxlength="25"
:disabled="disabled"
></el-input>
<span class="word-num">
{{(lecture.name || '').replace(/\s+/g,"").length}}/25
</span>
</div>
<div v-show="needShowAuditMsg && formData.courseCustomChapterModels[0].courseCustomLectureModelList[index].nameCheck" class="error-video">
<span>{{formData.courseCustomChapterModels[0].courseCustomLectureModelList[index].nameCheck}}</span>
</div>
</li>
<!-- <span v-show="needShowUploadProcess" class="upload-process" :style="{'width': (uploadProgress/100 * 340) + 'px'}"></span> -->
</ul>
<div style="color:red;position:absolute;top:60px;" v-if="noLecture && !formData.courseCustomChapterModels[0].courseCustomLectureModelList.length">请上传课程视频</div>
<!-- <span v-if="!formData.courseCustomChapterModels[0].courseCustomLectureModelList.length" v-show="needShowUploadProcess" class="upload-process" :style="{'width': (uploadProgress/100 * 340) + 'px'}"></span> -->
<div v-show="needShowUploadProcess" style="position:absolute;top:10px;left:90px;display:flex;width: 380px">
<div style="width:360px"><span class="upload-process" :style="{'width': (uploadProgress/100 * 340) + 'px'}"></span></div>
<img @click="cancleUpload" style="widht:16px;height:16px;margin-top:3px;margin-left:8px;" src="../../../assets/image/phrase3/close.png" />
</div>
</div>
</el-upload>
</el-form-item>
</div>
<div class="other-content valid-msg" v-show="isShowOtherContent">
<div class="tips">注:以下信息为非必填项,您也可以根据实际情况修改</div>
<div class="basic-item-icon">
<!-- <span class="require">*</span> -->
<el-form-item label="课程封面:">
<el-upload
v-model="formData.courseIntroImage"
class="bg-uploader"
action="#"
accept="image/*"
:show-file-list="false"
:before-upload="beforeUploadForCourse"
:disabled="disabled"
>
<div class="bg-img-wrapper">
<img
v-if="formData.courseIntroImage"
@mouseover.stop="imgMouseOver=true"
:src="getOSSDomain(formData.courseIntroImage)"
class="bg-img"
/>
<img
v-if="!formData.courseIntroImage"
class="bg-img"
src="../../../assets/image/small.png"
/>
</div>
</el-upload>
<div class="limit-text">尺寸:750*420,只支持jpg、jpeg格式</div>
<!-- <div style="color:red;position:absolute;top:104px;" class="error">
课程难度课程难度
</div> -->
<div style="color:red;position:absolute;top:102px;" v-show="needShowAuditMsg && formData.courseCustomDoctorModels[0].courseIntroImageCheck" class="error">
<span>{{formData.courseCustomDoctorModels[0].courseIntroImageCheck}}</span>
</div>
</el-form-item>
<!-- <p class="upload-message" v-if="uploadImgMessage">请选择列表图片</p> -->
</div>
<el-form-item label="课程难度:">
<el-radio-group v-model="formData.difficultyLevel">
<el-radio :label="1">初级</el-radio>
<el-radio :label="2">中级</el-radio>
<el-radio :label="3">高级</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="讲师名称:" class="valid-msg">
<el-col :span="18">
<el-autocomplete
size="small"
style="width: 360px"
      class="inline-input"
      v-model="formData.courseCustomDoctorModels[0].courseDoctorName"
      placeholder="请输入内容"
      :fetch-suggestions="querySearch"
:trigger-on-focus="true"
      @select="handleSelect">   
</el-autocomplete>
<span
class="word-num"
>{{(formData.courseCustomDoctorModels[0] && formData.courseCustomDoctorModels[0].courseDoctorName || '').replace(/\s+/g,"").length}}/25</span>
<div v-show="needShowAuditMsg && formData.courseCustomDoctorModels[0].courseDoctorNameCheck" class="error">
<span>{{formData.courseCustomDoctorModels[0].courseDoctorNameCheck}}</span>
<span v-show="formData.checkStatus == 0" class="cancle" @click="cancleAudit(formData.courseCustomDoctorModels[0], 'courseDoctorNameCheck')">X</span>
</div>
</el-col>
</el-form-item>
<div class="basic-item-icon">
<el-form-item label="讲师头像:">
<el-upload
v-model="formData.courseCustomDoctorModels[0].courseDoctorAvatarUrl"
class="bg-uploader"
action="#"
accept="image/*"
:show-file-list="false"
:before-upload="beforeUploadForLecture"
:disabled="disabled"
>
<div class="bg-img-wrapper">
<img
v-if="formData.courseCustomDoctorModels && formData.courseCustomDoctorModels[0].courseDoctorAvatarUrl || ''"
@mouseover.stop="imgMouseOver=true"
:src="getOSSDomain(formData.courseCustomDoctorModels[0].courseDoctorAvatarUrl)"
class="bg-img-doctor"
/>
<img
v-if="!(formData.courseCustomDoctorModels && formData.courseCustomDoctorModels[0].courseDoctorAvatarUrl || '')"
class="bg-img-doctor"
src="../../../assets/image/small.png"
/>
</div>
</el-upload>
<div class="limit-text" style="top: 76px;">尺寸:88*88,只支持jpg、jpeg格式</div>
<!-- <div class="error" style="position:absolute;top: 94px;">
所属机构所属机构:所属机构:
</div> -->
<div v-show="needShowAuditMsg && formData.courseCustomDoctorModels[0].courseDoctorAvatarUrlCheck" class="error" style="position:absolute;top: 102px;">
<span>{{formData.courseCustomDoctorModels[0].courseDoctorAvatarUrlCheck}}</span>
<span v-show="formData.checkStatus == 0" class="cancle" @click="cancleAudit(formData.courseCustomDoctorModels[0], 'courseDoctorAvatarUrlCheck')">X</span>
</div>
</el-form-item>
<!-- <p class="upload-message" v-if="uploadImgMessage">请选择列表图片</p> -->
</div>
<el-form-item label="所属机构:">
<el-col :span="18">
<el-input
size="small"
v-model="formData.courseCustomDoctorModels[0].courseDoctorHospital"
placeholder="请输入所属机构"
style="width: 360px"
maxlength="25"
:disabled="disabled"
></el-input>
<span
class="word-num"
>{{(formData.courseCustomDoctorModels && formData.courseCustomDoctorModels[0].courseDoctorHospital || '').replace(/\s+/g,"").length}}/25</span>
<!-- <div class="error">
所属机构所属机构:所属机构:
</div> -->
<div v-show="needShowAuditMsg && formData.courseCustomDoctorModels[0].courseDoctorHospitalCheck" class="error">
<span>{{formData.courseCustomDoctorModels[0].courseDoctorHospitalCheck}}</span>
</div>
</el-col>
</el-form-item>
<el-form-item label="课程简介:">
<el-col :span="18">
<el-input
size="small"
type="textarea"
maxlength="200"
:autosize="{ minRows: 5}"
placeholder="请输入课程简介"
v-model="formData.courseIntro"
style="width:90%;"
></el-input>
<span
class="word-num"
>{{(formData.courseIntro || '').replace(/\s+/g,"").length}}/200</span>
<!-- <div class="error-area">
所属机构所属机构:所属机构:
</div> -->
<div v-show="needShowAuditMsg && formData.courseIntroCheck" class="error-area">
<span>{{formData.courseIntroCheck}}</span>
</div>
</el-col>
</el-form-item>
</div>
<!-- 更多信息 -->
<div class="separator-line">
<span class="line-left"></span>
<div @click="toggleOtherContent" class="center">
<span>展开更多信息</span>
<img v-show="isShowOtherContent" src="../../../assets/image/phrase3/arrow-up.png" />
<img v-show="!isShowOtherContent" src="../../../assets/image/phrase3/arrow-down.png" />
</div>
<span class="line-right"></span>
</div>
</el-form>
</div>
<div v-show="step == 2" class="course-content-step2">
<img class="success-img" src="../../../assets/image/phrase3/icon-audit-success.png" />
<span class="tips-1">您上传的课程已成功提交,预计在3-5个工作日内完成审核</span>
<span class="tips-2">审核通过后,您才可以选择课程完成项目配置。如有任何疑问可联系云鹊医400-920-8877</span>
<el-button type="primary" icon="el-icon-back" @click="backToOrgCourse">返回机构课程</el-button>
</div>
<div v-show="step == 1" slot="footer" class="dialog-footer">
<el-button @click="dialogObj.visible=true">取 消</el-button>
<el-button type="primary" @click="submitForm('formDataRef')">提交审核</el-button>
</div>
</el-dialog>
<!-- // fetch-suggestions 是一个返回输入建议的方法属性 -->
<!-- //  false = >输入后匹配输入建议  true => 激活即列出输入建议 -->
<!-- // 点击选中建议项时触发  handleSelect -->
<DialogComponet :dialogObj="dialogObj" @hide="hideCancleTips" @confirm="dialogObj.visible=false"></DialogComponet>
<PreviewVideo :dialogVisible="isPreviewVideo" :videoUrl="videoUrl" @close="isPreviewVideo=false"></PreviewVideo>
</div>
</template>
<script>
import PreviewVideo from "@/components/education/custom-resource/preview-video";
import PreviewProtocol from "@/components/education/custom-resource/preview-protocol";
import PreviewEditCourse from "@/components/education/custom-resource/edit-course-dialog";
import DialogComponet from "@/components/education/template/dialog";
import { doUpload, getFilePath } from "@/utils/qiniu-util";
import { openLoading, closeLoading, getQiniuToken1 } from "@/utils/utils";
import { isEmptyUtils, getOSSImgUrl } from "@/utils/index";
import { mapActions } from 'vuex';
import { ossUpload, getFilePathForOSS } from "@/utils/oss/ossUtil";
let vm = null;
export default {
data() {
return {
step: 1,
needCheckField: false,
needShowAuditMsg: false, // TODO
needShowUploadProcess: false,
disabled: false,
formDataBase: {
checkStatus: 0,
courseCustomChapterModels: [
{
courseCustomLectureModelList: [],
id: null,
name: "视频课程"
}
],
courseCustomDoctorModels: [
{
courseDoctorAvatarUrl: "/h5/images/cme/doctor-header.png",
courseDoctorAvatarUrlCheck: "",
courseDoctorHospital: "",
courseDoctorHospitalCheck: "",
courseDoctorName: "",
courseDoctorNameCheck: "",
id: null
}
],
courseId: null,
courseIntro: "",
courseIntroCheck: "",
courseIntroImage: "/h5/images/cme/project-banner.png",
courseIntroImageCheck: "",
courseName: "",
courseNameCheck: "",
deleteCustomLectureIds: [],
difficultyLevel: 1,
shareType: 1,
subjectIdList: []
},
formData: {
checkStatus: 0,
courseCustomChapterModels: [
{
courseCustomLectureModelList: [],
id: null,
name: "视频课程"
}
],
courseCustomDoctorModels: [
{
courseDoctorAvatarUrl: "/h5/images/cme/doctor-header.png",
courseDoctorAvatarUrlCheck: "",
courseDoctorHospital: "",
courseDoctorHospitalCheck: "",
courseDoctorName: "",
courseDoctorNameCheck: "",
id: null
}
],
courseId: null,
courseIntro: "",
courseIntroCheck: "",
courseIntroImage: "/h5/images/cme/project-banner.png",
courseIntroImageCheck: "",
courseName: "",
courseNameCheck: "",
deleteCustomLectureIds: [],
difficultyLevel: 1,
shareType: 1,
subjectIdList: []
},
// uploadImgMessage: false,
imgMouseOver: false,
labelOptions: [],
isShowOtherContent: false,
fileList: [
],
doctorNameList: [
// { courseDoctorName: "333", show: true, seleted: false },
],
isShowDoctorList: false,
isPreviewVideo: false,
videoUrl: "",
orgCourseInfo: {
defaultDoctor: {
courseDoctorAvatarUrl: "/h5/images/cme/project-banner.png",
courseDoctorAvatarUrlCheck: "",
courseDoctorHospital: "",
courseDoctorHospitalCheck: "",
courseDoctorName: "",
courseDoctorNameCheck: "",
id: null
},
doctorModelList: [
{
courseDoctorAvatarUrl: "/h5/images/cme/doctor-header.png",
courseDoctorAvatarUrlCheck: "",
courseDoctorHospital: "",
courseDoctorHospitalCheck: "",
courseDoctorName: "",
courseDoctorNameCheck: "",
id: null
}
],
limitModel: {
maxLimitOneVideoSize: 2147483648,
maxLimitVideoCount: 100,
maxStorageSpace: 5368709120,
usedStorageSpace: 1021842989
}
},
uploadProgress: 0,
dialogObj: {
visible: false,
title: "确定取消吗?",
message: "取消后,将不保存该页面已填写的内容",
tip: "",
confirmMsg: "取 消",
hideMsg: "确 定"
},
noLecture: true, // 没有上传视频
noCouseName: true, // 没有课程名称
noLabel: true, // 没有选择分类
};
},
props: {
dialogVisible: {
type: Boolean,
default: false
},
courseId: {
type: String | Number,
default: 0
}
},
computed: {},
watch: {
dialogVisible(isVisible) {
this.formData = JSON.parse(JSON.stringify(this.formDataBase));
if (isVisible) {
if (this.courseId == 0) {
this.initAdd(this.courseId);
} else {
this.initModify(this.courseId);
}
}
this.noLecture = false;
this.noCouseName = false;
this.noLabel = false;
},
},
components: {
PreviewVideo,
PreviewEditCourse,
DialogComponet,
},
created() {
vm = this;
// this.initAdd();
},
mounted() {
this.getLabelList();
},
methods: {
...mapActions(['setKind']),
cancleUpload() {
console.log('1')
if(window.QNSubscription) {
console.log('2')
window.QNSubscription.unsubscribe();
window.QNSubscription = null;
}
},
querySearch(queryString, cb) {
// this.doctorNameList;
let doctorNameList = JSON.parse(JSON.stringify(this.doctorNameList));
if(!queryString) {
cb(doctorNameList);
return;
}
let backList = [];
doctorNameList.forEach( item => {
if(item.courseDoctorName.indexOf(queryString) >= 0) {
backList.push(item);
}
})
cb(backList);
},
// 选择其中一个
handleSelect(selDoctor) {
this.formData.courseCustomDoctorModels[0] = selDoctor
},
// 创建课程页面的初始信息
initOrgCourseInfo() {
vm.GET("contents/course/custom/info/init", { setEntry: true }).then(
res => {
if (res.code == "000000") {
this.orgCourseInfo = res.data;
this.formData.courseCustomDoctorModels[0] = this.orgCourseInfo.defaultDoctor;
this.formData.courseCustomDoctorModels[0].courseDoctorAvatarUrl =
this.orgCourseInfo.defaultDoctor.courseDoctorAvatarUrl || "/h5/images/cme/doctor-header.png";
this.doctorNameList = this.convertDNameToSelectOpt(
this.orgCourseInfo.doctorModelList
);
+this.courseId && this.getCourseInfoById(this.courseId);
}
}
);
},
// 将医生名称进行处理
convertDNameToSelectOpt(doctorModelList) {
doctorModelList.forEach(item => {
item.value = item.courseDoctorName
item.show = true;
item.seleted = false;
});
return doctorModelList;
},
// 添加时初始化
initAdd() {
console.log("in initAdd");
this.step = 1;
this.needShowAuditMsg = false;
this.initOrgCourseInfo();
},
initModify() {
this.step = 1;
this.needShowAuditMsg = true;
console.log("in initModify");
this.initOrgCourseInfo();
},
// 创建课程页面的初始信息
getCourseInfoById(courseId) {
vm.GET(`contents/course/custom/info/${courseId}`)
.then( res => {
if ( res.code == "000000") {
this.formData = res.data;
}
}
);
},
// 过滤医生信息
filterDoctorName(value) {
this.doctorNameList.forEach(item => {
if (value) {
if ((item.value + "").indexOf(value) == -1) {
item.show = false;
} else {
item.show = true;
}
if (item.value == value) {
item.seleted = true;
} else {
item.seleted = false;
}
} else {
item.show = true;
}
});
},
// 当选择医生的焦点失去时,要反选医生信息
doctorNameInputBlur() {
setTimeout(() => {
this.$nextTick( item => {
this.isShowDoctorList = false;
this.selectDoctorByName(
this.formData.courseCustomDoctorModels[0].courseDoctorName
);
})
}, 200);
},
// 根据姓名反选医生信息
// TODO 尝试找到完全匹配的医生
selectDoctorByName(name) {
// let lectureObj = {};
let originDoctorModelList = JSON.parse(JSON.stringify(this.orgCourseInfo.doctorModelList));
let index = originDoctorModelList.findIndex( item => {
return item.courseDoctorName == name;
});
// debugger
if(index >= 0) {
this.formData.courseCustomDoctorModels[0] = this.orgCourseInfo.doctorModelList[index];
}
// this.$forceUpdate();
},
// 选择其中一个
selectDoctor(name) {
console.log(name);
this.formData.courseCustomDoctorModels[0].courseDoctorName = name;
this.selectDoctorByName(name);
},
// 关闭当前弹框
close() {
this.$emit("close");
},
// 获取学科列表
getLabelList() {
let req = {};
this.GET("aggregate/content/labelList", req).then(res => {
if (res.code == "000000") {
this.convertLabelList(res.data);
}
});
},
// 将所有子分类中的“全部”去掉
convertLabelList(labelList) {
let newLabelList = [];
labelList.forEach(item => {
item.subList = item.subList.slice(1);
});
this.labelOptions = labelList;
},
// 上传视频(mp4)
beforeUploadVideo(file) {
// this.$message({
// showClose: false,
// message: '您上传的文件大小已超限制,无法继续上传。如有疑问可拨打云鹊医电话咨询400-920-7788',
// type: 'error',
// duration: 10000
// });
// return;
console.log(file);
const isMP4 = file.type === "video/mp4";
const isGt = file.size > this.orgCourseInfo.limitModel.maxLimitOneVideoSize;
const isGtMaxNum = this.formData.courseCustomChapterModels[0].courseCustomLectureModelList.length >= 100;
const usedGtMaxStore = this.orgCourseInfo.limitModel.usedStorageSpace + file.size > this.orgCourseInfo.limitModel.maxStorageSpace;
if (isGtMaxNum || !isMP4) {
this.$message.error("视频不符合规范,请根据规范上传视频");
return;
}
if(usedGtMaxStore || isGt) {
this.$message({
showClose: true,
message: '您上传的文件大小已超限制,无法上传。如有疑问可拨打云鹊医电话:400-920-7788',
type: 'error',
duration: 10000
});
return;
}
// 直接上传
this.needShowUploadProcess = true;
doUpload(vm, file, getFilePath(file, null), "preview4", "progress", "")
.then(function(path) {
console.log(path);
let cName = path.name;
cName = cName.substr(0, cName.lastIndexOf('.'));
cName = cName.substring(0, 21);
let uploadResourceParam = {
formatType: path.ext,
name: cName + path.ext, //path.name,
qCloudUrl : path.fullPath,
size : path.size,
fileType : 1,
status : "success",
uid : new Date().getTime()
}
vm.needShowUploadProcess = false;
vm.uploadProgress = 0;
vm.insertResourceAction(uploadResourceParam);
});
},
// 上传资源(视频)后,生存对应的节
insertResourceAction(uploadResourceParam) {
this.POST("contents/course/custom/info/insertResource", [uploadResourceParam]).then(res => {
if (res.code == "000000") {
let cName = res.data.resourceModelList[0].name;
cName = cName.substr(0, cName.lastIndexOf('.'));
let lectureObj = {
id: null,
name: cName,
nameCheck: "",
contentCheck: "",
resourceModel: {}
}
this.orgCourseInfo.limitModel = res.data.limitModel;
lectureObj.resourceModel = res.data && res.data.resourceModelList[0];
this.formData.courseCustomChapterModels[0].courseCustomLectureModelList.push(lectureObj);
}
});
},
// 展开/收起 更多信息
toggleOtherContent() {
this.isShowOtherContent = !this.isShowOtherContent;
},
// 限制选择文件个数
handleExceed(files, fileList) {
this.$message.warning(`当前限制选择 100 个文件,您已经共选择了 ${files.length + fileList.length} 个文件!`);
},
// 表单校验
// TODO
submitForm(formName) {
this.needShowAuditMsg = false;
this.noCouseName = false;
this.noLecture = false;
this.noLabel = false;
let hasLecture = this.formData.courseCustomChapterModels[0].courseCustomLectureModelList.length > 0;
if(!hasLecture) {
this.noLecture = true;
}
if(!this.formData.courseName) {
this.noCouseName = true;
}
if(!this.formData.subjectIdList.length) {
this.noLabel = true;
}
if(this.noCouseName || this.noLabel || this.noLecture) {
return;
}
this.insertOrUpdate();
},
// 添加或修改课程(kind = 3)
insertOrUpdate() {
let formData = JSON.parse(JSON.stringify(this.formData));
if(!formData.courseCustomDoctorModels[0].courseDoctorName
&& !formData.courseCustomDoctorModels[0].courseDoctorHospital) {
formData.courseCustomDoctorModels = [];
}
this.POST("contents/course/custom/info/insertOrUpdate", formData).then(res => {
if (res.code == "000000") {
this.step = 2;
} else {
this.$message.error(res.message);
}
});
},
// 返回到课程选择页面(kind = 3)
backToOrgCourse() {
console.log('backToOrgCourse');
this.close();
this.setKind(3);
},
// 关闭(“取消”按钮弹出来的)弹框
hideCancleTips() {
this.dialogObj.visible = false;
this.close();
},
// 预览视频
previewVideoAction(lecture) {
this.videoUrl = lecture.resourceModel.filePath;
this.isPreviewVideo = true;
},
// 删除本节视频
deleteLecture(index) {
let lectureId = this.formData.courseCustomChapterModels[0].courseCustomLectureModelList[index].id;
if(lectureId) {
this.formData.deleteCustomLectureIds.push(lectureId);
}
this.formData.courseCustomChapterModels[0].courseCustomLectureModelList.splice(index, 1);
},
// 上传课程封面图片
beforeUploadForCourse(file) {
const isJPG = file.type === 'image/jpeg'
if(!isJPG) {
this.$message.error('只支持jpg、jpeg格式')
return;
}
var _img = new FileReader()
_img.readAsDataURL(file)
_img.onload = function(theFile) {
let image = new Image()
image.src = theFile.target.result
image.onload = function() {
let _this = this
if(_this.width != 750 || _this.height != 420) {
vm.$message.info("上传图片尺寸大小不合适,请重新上传")
}else {
vm.doUploadOSS(file, 1); //封面图片
}
}
}
},
// 上传讲师图片
beforeUploadForLecture(file) {
// const isLt50kb = file.size / 1024 < 50;
const isJPG = file.type === 'image/jpeg'
if(!isJPG) {
this.$message.error('只支持jpg、jpeg格式')
return;
}
var _img = new FileReader()
_img.readAsDataURL(file)
_img.onload = function(theFile) {
let image = new Image()
image.src = theFile.target.result
image.onload = function() {
let _this = this
if(_this.width != 88 || _this.height != 88) {
vm.$message.info("上传图片尺寸大小不合适,请重新上传")
}else {
vm.doUploadOSS(file, 2); //封面图片
}
}
}
},
getOSSDomain(url) {
return getOSSImgUrl(url);
},
// (调用OSS API)开始上传
doUploadOSS(file, index) {
let self = this;
//上传 指定文件名
ossUpload(self, file, getFilePathForOSS(file), null, null, null).
then(function(path) {
console.log(path);
let list = [{}];
// list[0].name = file.name;
// list[0].url = localStorage.getItem("resource_url") + path;
// getOSSImgUrl(path)
if (index === 1) {
self.formData.courseIntroImage = path;
} else if (index === 2) {
self.formData.courseCustomDoctorModels[0].courseDoctorAvatarUrl = path;
}
self.$message.success("上传成功");
});
return false;
},
}
};
</script>
<style scoped lang="scss">
.edit-course-wrapper {
.course-content {
// color: red;
.basic-item-icon {
position: relative;
margin-top: 20px;
.require {
position: absolute;
left: 40px;
top: 11px;
color: #f56c6c;
}
.upload-message {
position: absolute;
left: 160px;
top: 105px;
font-size: 12px;
color: #f56c6c;
}
.img-delete {
position: absolute;
left: 0px;
top: 0px;
width: 84px;
height: 100px;
background: #000;
opacity: 0.7;
z-index: 999;
i {
color: #fff;
margin-top: 39px;
margin-left: 0px;
}
}
.upload-tips {
width: 100%;
position: relative;
top: -10px;
font-size: 12px;
color: #979899;
// display: inline-block;
}
.custom-list {
// width: 100%;
width: 520px;
display: flex;
flex-direction: column;
border-radius: 3px;
border: 1px solid rgba(228,231,237,1);
padding: 20px;
padding-top: 5px;
font-size: 14px;
& > li {
margin: 10px 0;
}
.video {
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
.title {
display: inline-block;
width: 70px;
text-align: right;
margin-right: 10px;
}
.name {
cursor: pointer;
color: #5890DD;
}
img {
width: 12px;
height: 12px;
}
.delete {
position: relative;
top: 2px;
cursor: pointer;
width: 16px;
height: 16px;
}
}
.video-name {
.title {
display: inline-block;
width: 70px;
text-align: right;
margin-right: 10px;
}
}
}
}
.word-num {
font-size: 12px;
color: #999;
padding-top: 5px;
}
.bg-uploader {
img {
float: left;
}
.bg-img-wrapper {
.bg-img {
display: block;
width: 160px;
height: 90px;
}
.bg-img-doctor {
display: block;
width: 88px;
height: 88px;
}
}
.bg-video {
float: left;
width: 84px;
height: 100px;
}
}
.limit-text {
position: absolute;
top: 86px;
left: 0px;
font-size: 12px;
color: #979899;
}
.separator-line {
width: 100%;
display: flex;
flex-direction: row;
align-content: center;
align-items: center;
justify-content: space-between;
.center {
cursor: pointer;
width: 130px;
color: #666666;
img {
width: 12px;
}
}
.line-left,
.line-right {
// display: inline-block;
// width: 100%;
flex: 1;
border-bottom: 1px dashed #e4e7ed;
}
}
.tips {
width: 100%;
height: 32px;
line-height: 32px;
padding-left: 12px;
background: rgba(254, 250, 245, 1);
border-radius: 3px;
color: #e6a23c;
}
.valid-msg {
position: relative;
.error {
width: 370px;
position: absolute;
display: flex;
justify-content: space-between;
top: 29px;
font-size: 13px;
color: #ed3131;
.text {
flex: 1;
}
.cancle {
cursor: pointer;
width: 20px;
}
}
.error-area {
position: absolute;
bottom: -32px;
font-size: 13px;
color: #ed3131;
.cancle {
width: 20px;
margin-left: 20px;
cursor: pointer;
}
}
.error-video {
position: absolute;
top: 76px;
left: 82px;
font-size: 13px;
color: #ed3131;
.cancle {
width: 20px;
margin-left: 20px;
cursor: pointer;
}
}
.edit-wrapper {
color: #449284;
.edit-img {
position: relative;
top: 2px;
width: 12px;
margin: 0 2px 0 4px;
}
}
.doctor-select-list {
width: 200px;
// max-height: 100px;
position: absolute;
z-index: 100;
background: #fff;
box-shadow: 0 0 6px rgba(0, 0, 0, 0.3);
-webkit-box-shadow: 0 0 6px rgba(0, 0, 0, 0.3);
// margin: 10px;
li {
padding-left: 20px;
cursor: pointer;
&:hover {
background: #f4f7fd;
}
&.doctor-selected {
background: #f4f7fd;
}
}
}
}
.upload-process {
margin: 10px 0 10px 10px;
display: block;
// width: 310px;
height: 4px;
background: #449284;
border-radius: 2px;
}
.upload-video.disabled {
.el-button--primary {
color: #bcbec2 !important;
background-color: #f4f4f5 !important;
border-color: #e9e9eb !important;
cursor: not-allowed !important;
}
// color: red;
}
}
.course-content-step2 {
display: flex;
flex-direction: column;
text-align: center;
align-items: center;
.success-img {
width: 60px;
height: 60px;
}
.tips-1 {
margin-top: 30px;
font-size: 18px;
color: #303133;
}
.tips-2 {
margin-top: 4px;
margin-bottom: 40px;
font-size: 14px;
color: #999999;
}
}
}
</style>
...@@ -78,28 +78,38 @@ ...@@ -78,28 +78,38 @@
<span class="require">*</span> <span class="require">*</span>
<el-form-item label="课程视频:" prop="range" class="valid-msg"> <el-form-item label="课程视频:" prop="range" class="valid-msg">
<el-upload <el-upload
ref="uploadFileCom"
class="upload-video" class="upload-video"
:class="{'disabled': needShowUploadProcess || (formData.courseCustomChapterModels[0].courseCustomLectureModelList.length >= orgCourseInfo.limitModel.maxLimitVideoCount)}" :class="{'disabled': needShowUploadProcess || (formData.courseCustomChapterModels[0].courseCustomLectureModelList.length >= orgCourseInfo.limitModel.maxLimitVideoCount)}"
action="#" action="#"
:before-upload="beforeUploadVideo" :before-upload="beforeUploadVideo"
:limit="3"
:on-exceed="handleExceed"
:show-file-list="false" :show-file-list="false"
:disabled="needShowUploadProcess || (formData.courseCustomChapterModels[0].courseCustomLectureModelList.length >= orgCourseInfo.limitModel.maxLimitVideoCount)" :disabled="needShowUploadProcess || (formData.courseCustomChapterModels[0].courseCustomLectureModelList.length >= orgCourseInfo.limitModel.maxLimitVideoCount)"
> >
<el-button size="small" type="primary">点击上传</el-button> <el-button slot="trigger" ref="uploadFileBtn" size="small" type="primary">点击上传</el-button>
<div slot="tip" class="el-upload__tip"> <div slot="tip" class="el-upload__tip">
<span class="upload-tips">只支持MP4格式,课程视频最多上传100个,单文件最大2G</span> <span class="upload-tips">只支持MP4格式,课程视频最多上传100个,单文件最大2G</span>
<ul v-show="formData.courseCustomChapterModels[0].courseCustomLectureModelList.length" class="custom-list"> <ul v-show="formData.courseCustomChapterModels[0].courseCustomLectureModelList.length" class="custom-list">
<li v-for="(lecture, index) in formData.courseCustomChapterModels[0].courseCustomLectureModelList" :key="index" class="valid-msg"> <li v-for="(lecture, index) in formData.courseCustomChapterModels[0].courseCustomLectureModelList" :key="index" class="valid-msg video-wrappe">
<ul class="video"> <ul class="video">
<li style="height: 46px;line-height:48px;"> <li style="height: 46px;line-height:48px;">
<span class="title">视频{{index + 1}}</span> <span class="title">视频{{index + 1}}</span>
<img src="../../../assets/image/phrase3/icon-pin.png" /> <img src="../../../assets/image/phrase3/icon-pin.png" />
<span class="name" @click="previewVideoAction(lecture)">{{lecture.resourceModel.name}}</span> <span class="name" @click="previewVideoAction(lecture)">{{lecture.resourceModel.name}}</span>
</li> </li>
<li> <li class="other-action">
<img @click="deleteLecture(index)" class="delete" src="../../../assets/image/phrase3/close.png" /> <div>
<el-upload
ref="uploadFileCom"
class="upload-video"
action="#"
:before-upload="beforeUploadVideo"
:show-file-list="false"
>
<img @click="replaceLecture(index)" class="replace" src="../../../assets/image/phrase3/close.png" />
</el-upload>
</div>
<img @click="deleteLecture(index)" class="delete" src="../../../assets/image/phrase3/close.png" />
</li> </li>
<div style="color:red;;position:absolute;top:22px;" v-show="needShowAuditMsg && formData.courseCustomChapterModels[0].courseCustomLectureModelList[index].contentCheck" class="error-video"> <div style="color:red;;position:absolute;top:22px;" v-show="needShowAuditMsg && formData.courseCustomChapterModels[0].courseCustomLectureModelList[index].contentCheck" class="error-video">
<span>{{formData.courseCustomChapterModels[0].courseCustomLectureModelList[index].contentCheck}}</span> <span>{{formData.courseCustomChapterModels[0].courseCustomLectureModelList[index].contentCheck}}</span>
...@@ -107,8 +117,8 @@ ...@@ -107,8 +117,8 @@
</ul> </ul>
<div class="video-name"> <div class="video-name">
<span class="title"> <span class="title">
<span >*</span> <span style="color:red;">*</span>
<span class="video-title">视频名称</span> <span class="video-title">视频名称{{index + 1}}</span>
</span> </span>
<el-input <el-input
size="small" size="small"
...@@ -122,17 +132,20 @@ ...@@ -122,17 +132,20 @@
{{(lecture.name || '').replace(/\s+/g,"").length}}/25 {{(lecture.name || '').replace(/\s+/g,"").length}}/25
</span> </span>
</div> </div>
<div v-show="needShowAuditMsg && formData.courseCustomChapterModels[0].courseCustomLectureModelList[index].nameCheck" class="error-video"> <div v-show="lecture.name && needShowAuditMsg && formData.courseCustomChapterModels[0].courseCustomLectureModelList[index].nameCheck" class="error-video">
<span>{{formData.courseCustomChapterModels[0].courseCustomLectureModelList[index].nameCheck}}</span> <span>{{formData.courseCustomChapterModels[0].courseCustomLectureModelList[index].nameCheck}}</span>
</div>
<div v-show="!lecture.name" class="error-video">
请输入视频名称
</div> </div>
</li> </li>
<!-- <span v-show="needShowUploadProcess" class="upload-process" :style="{'width': (uploadProgress/100 * 340) + 'px'}"></span> -->
</ul> </ul>
<div style="color:red;position:absolute;top:60px;" v-if="noLecture && !formData.courseCustomChapterModels[0].courseCustomLectureModelList.length">请上传课程视频</div> <div style="color:red;position:absolute;top:60px;" v-if="noLecture && !formData.courseCustomChapterModels[0].courseCustomLectureModelList.length">请上传课程视频</div>
<!-- <span v-if="!formData.courseCustomChapterModels[0].courseCustomLectureModelList.length" v-show="needShowUploadProcess" class="upload-process" :style="{'width': (uploadProgress/100 * 340) + 'px'}"></span> -->
<div v-show="needShowUploadProcess" style="position:absolute;top:10px;left:90px;display:flex;"> <div v-show="needShowUploadProcess" style="position:absolute;top:10px;left:90px;display:flex;">
<span style="flex:1;" class="upload-process" :style="{'width': (uploadProgress/100 * 340) + 'px'}"></span> <div style="flex:1;width: 360px;">
<!-- <img @click="cancleUpload" style="widht:16px;height:16px;margin-top:3px;margin-left:8px;" src="../../../assets/image/phrase3/close.png" /> --> <span class="upload-process" :style="{'width': (uploadProgress/100 * 300) + 'px'}"></span>
</div>
<img @click="cancleUpload" style="widht:16px;height:16px;margin-top:3px;margin-left:8px;" src="../../../assets/image/phrase3/close.png" />
</div> </div>
</div> </div>
</el-upload> </el-upload>
...@@ -232,11 +245,11 @@ ...@@ -232,11 +245,11 @@
/> />
</div> </div>
</el-upload> </el-upload>
<div class="limit-text" style="top: 76px;">尺寸:88*88,只支持jpg、jpeg格式</div> <div class="limit-text" style="top: 80px;">尺寸:88*88,只支持jpg、jpeg格式</div>
<!-- <div class="error" style="position:absolute;top: 94px;"> <!-- <div class="error" style="position:absolute;top: 94px;">
所属机构所属机构:所属机构: 所属机构所属机构:所属机构:
</div> --> </div> -->
<div v-show="needShowAuditMsg && formData.courseCustomDoctorModels[0].courseDoctorAvatarUrlCheck" class="error" style="position:absolute;top: 102px;"> <div v-show="needShowAuditMsg && formData.courseCustomDoctorModels[0].courseDoctorAvatarUrlCheck" class="error" style="position:absolute;top: 98px;">
<span>{{formData.courseCustomDoctorModels[0].courseDoctorAvatarUrlCheck}}</span> <span>{{formData.courseCustomDoctorModels[0].courseDoctorAvatarUrlCheck}}</span>
<span v-show="formData.checkStatus == 0" class="cancle" @click="cancleAudit(formData.courseCustomDoctorModels[0], 'courseDoctorAvatarUrlCheck')">X</span> <span v-show="formData.checkStatus == 0" class="cancle" @click="cancleAudit(formData.courseCustomDoctorModels[0], 'courseDoctorAvatarUrlCheck')">X</span>
</div> </div>
...@@ -317,6 +330,22 @@ ...@@ -317,6 +330,22 @@
<DialogComponet :dialogObj="dialogObj" @hide="hideCancleTips" @confirm="dialogObj.visible=false"></DialogComponet> <DialogComponet :dialogObj="dialogObj" @hide="hideCancleTips" @confirm="dialogObj.visible=false"></DialogComponet>
<PreviewVideo :dialogVisible="isPreviewVideo" :videoUrl="videoUrl" @close="isPreviewVideo=false"></PreviewVideo> <PreviewVideo :dialogVisible="isPreviewVideo" :videoUrl="videoUrl" @close="isPreviewVideo=false"></PreviewVideo>
<el-dialog
title="图片裁剪"
:visible.sync="showCropper"
width="900px"
center>
<div slot="title" style="text-align: left;">
<span style="font-weight: 700;">图片裁剪</span>
</div>
<div v-if="showCropper" style="margin-bottom: 20px;">
<CropperImg
:cropOption="currentOption"
@getCropImg="getCropImg(arguments)"
:originImg="slide2.oriUrl"
/>
</div>
</el-dialog>
</div> </div>
</template> </template>
<script> <script>
...@@ -324,6 +353,7 @@ import PreviewVideo from "@/components/education/custom-resource/preview-video"; ...@@ -324,6 +353,7 @@ import PreviewVideo from "@/components/education/custom-resource/preview-video";
import PreviewProtocol from "@/components/education/custom-resource/preview-protocol"; import PreviewProtocol from "@/components/education/custom-resource/preview-protocol";
import PreviewEditCourse from "@/components/education/custom-resource/edit-course-dialog"; import PreviewEditCourse from "@/components/education/custom-resource/edit-course-dialog";
import DialogComponet from "@/components/education/template/dialog"; import DialogComponet from "@/components/education/template/dialog";
import CropperImg from '@/components/common/cropper-img.vue'
import { doUpload, getFilePath } from "@/utils/qiniu-util"; import { doUpload, getFilePath } from "@/utils/qiniu-util";
import { openLoading, closeLoading, getQiniuToken1 } from "@/utils/utils"; import { openLoading, closeLoading, getQiniuToken1 } from "@/utils/utils";
import { isEmptyUtils, getOSSImgUrl } from "@/utils/index"; import { isEmptyUtils, getOSSImgUrl } from "@/utils/index";
...@@ -333,9 +363,33 @@ let vm = null; ...@@ -333,9 +363,33 @@ let vm = null;
export default { export default {
data() { data() {
return { return {
slide2: {
oriUrl: '', // 原图
},
showCropper: false,
currentOption: {
offset_x: 120,
offset_y: 185,
width: 750,
height: 420
},
cropOption: {
offset_x: 120,
offset_y: 185,
width: 750,
height: 420
},
cropOption2: {
offset_x: 450,
offset_y: 350,
width: 88,
height: 88
},
isReplaceUpload: false,
replaceLectureIndex: 0,
step: 1, step: 1,
needCheckField: false, needCheckField: false,
needShowAuditMsg: false, // TODO needShowAuditMsg: false,
needShowUploadProcess: false, needShowUploadProcess: false,
disabled: false, disabled: false,
formDataBase: { formDataBase: {
...@@ -456,6 +510,7 @@ export default { ...@@ -456,6 +510,7 @@ export default {
noLecture: true, // 没有上传视频 noLecture: true, // 没有上传视频
noCouseName: true, // 没有课程名称 noCouseName: true, // 没有课程名称
noLabel: true, // 没有选择分类 noLabel: true, // 没有选择分类
currentUploadType: 1,// 1: 封面图片; 2: 讲师头像
}; };
}, },
props: { props: {
...@@ -479,6 +534,8 @@ export default { ...@@ -479,6 +534,8 @@ export default {
this.initModify(this.courseId); this.initModify(this.courseId);
} }
} }
this.isShowOtherContent = false;
this.isReplaceUpload = false;
this.noLecture = false; this.noLecture = false;
this.noCouseName = false; this.noCouseName = false;
this.noLabel = false; this.noLabel = false;
...@@ -488,10 +545,10 @@ export default { ...@@ -488,10 +545,10 @@ export default {
PreviewVideo, PreviewVideo,
PreviewEditCourse, PreviewEditCourse,
DialogComponet, DialogComponet,
CropperImg
}, },
created() { created() {
vm = this; vm = this;
// this.initAdd();
}, },
mounted() { mounted() {
this.getLabelList(); this.getLabelList();
...@@ -499,11 +556,33 @@ export default { ...@@ -499,11 +556,33 @@ export default {
methods: { methods: {
...mapActions(['setKind']), ...mapActions(['setKind']),
// 重新上传(替换视频)
replaceLecture(index) {
this.isReplaceUpload = true;
this.replaceLectureIndex = index;
},
// 获取裁剪的图片数据
getCropImg(argument) {
this.showCropper = false;
this.cropData = argument[1]
vm.doUploadOSS(argument[2], this.currentUploadType); //封面图片
argument[3] && argument[3].destroy();
},
//
// closeCropper() {
// this.showCropper = false;
// },
// 取消上传
cancleUpload() { cancleUpload() {
console.log('in cancleUpload');
if(window.QNSubscription) { if(window.QNSubscription) {
console.log('QNSubscription', QNSubscription);
window.QNSubscription.unsubscribe(); window.QNSubscription.unsubscribe();
window.QNSubscription = null; window.QNSubscription = null;
} }
this.$refs.uploadFileCom.abort();
}, },
querySearch(queryString, cb) { querySearch(queryString, cb) {
...@@ -558,16 +637,15 @@ export default { ...@@ -558,16 +637,15 @@ export default {
// 添加时初始化 // 添加时初始化
initAdd() { initAdd() {
console.log("in initAdd");
this.step = 1; this.step = 1;
this.needShowAuditMsg = false; this.needShowAuditMsg = false;
this.initOrgCourseInfo(); this.initOrgCourseInfo();
}, },
// 编辑时初始化
initModify() { initModify() {
this.step = 1; this.step = 1;
this.needShowAuditMsg = true; this.needShowAuditMsg = true;
console.log("in initModify");
this.initOrgCourseInfo(); this.initOrgCourseInfo();
}, },
...@@ -582,60 +660,6 @@ export default { ...@@ -582,60 +660,6 @@ export default {
); );
}, },
// 过滤医生信息
filterDoctorName(value) {
this.doctorNameList.forEach(item => {
if (value) {
if ((item.value + "").indexOf(value) == -1) {
item.show = false;
} else {
item.show = true;
}
if (item.value == value) {
item.seleted = true;
} else {
item.seleted = false;
}
} else {
item.show = true;
}
});
},
// 当选择医生的焦点失去时,要反选医生信息
doctorNameInputBlur() {
setTimeout(() => {
this.$nextTick( item => {
this.isShowDoctorList = false;
this.selectDoctorByName(
this.formData.courseCustomDoctorModels[0].courseDoctorName
);
})
}, 200);
},
// 根据姓名反选医生信息
// TODO 尝试找到完全匹配的医生
selectDoctorByName(name) {
// let lectureObj = {};
let originDoctorModelList = JSON.parse(JSON.stringify(this.orgCourseInfo.doctorModelList));
let index = originDoctorModelList.findIndex( item => {
return item.courseDoctorName == name;
});
// debugger
if(index >= 0) {
this.formData.courseCustomDoctorModels[0] = this.orgCourseInfo.doctorModelList[index];
}
// this.$forceUpdate();
},
// 选择其中一个
selectDoctor(name) {
console.log(name);
this.formData.courseCustomDoctorModels[0].courseDoctorName = name;
this.selectDoctorByName(name);
},
// 关闭当前弹框 // 关闭当前弹框
close() { close() {
this.$emit("close"); this.$emit("close");
...@@ -690,6 +714,7 @@ export default { ...@@ -690,6 +714,7 @@ export default {
} }
// 直接上传 // 直接上传
this.needShowUploadProcess = true; this.needShowUploadProcess = true;
vm.uploadProgress = 0;
doUpload(vm, file, getFilePath(file, null), "preview4", "progress", "") doUpload(vm, file, getFilePath(file, null), "preview4", "progress", "")
.then(function(path) { .then(function(path) {
console.log(path); console.log(path);
...@@ -717,8 +742,14 @@ export default { ...@@ -717,8 +742,14 @@ export default {
if (res.code == "000000") { if (res.code == "000000") {
let cName = res.data.resourceModelList[0].name; let cName = res.data.resourceModelList[0].name;
cName = cName.substr(0, cName.lastIndexOf('.')); cName = cName.substr(0, cName.lastIndexOf('.'));
let lectureObjId = null;
if(this.isReplaceUpload) {
lectureObjId = this.formData.courseCustomChapterModels[0].courseCustomLectureModelList[this.replaceLectureIndex].id;
console.log('in isReplaceUpload', lectureObjId);
}
let lectureObj = { let lectureObj = {
id: null, id: lectureObjId,
name: cName, name: cName,
nameCheck: "", nameCheck: "",
contentCheck: "", contentCheck: "",
...@@ -726,7 +757,16 @@ export default { ...@@ -726,7 +757,16 @@ export default {
} }
this.orgCourseInfo.limitModel = res.data.limitModel; this.orgCourseInfo.limitModel = res.data.limitModel;
lectureObj.resourceModel = res.data && res.data.resourceModelList[0]; lectureObj.resourceModel = res.data && res.data.resourceModelList[0];
this.formData.courseCustomChapterModels[0].courseCustomLectureModelList.push(lectureObj); if(this.isReplaceUpload) {
this.formData.courseCustomChapterModels[0].courseCustomLectureModelList.splice(this.replaceLectureIndex, 1, lectureObj);
} else {
this.formData.courseCustomChapterModels[0].courseCustomLectureModelList.push(lectureObj);
}
// 重置是否替换视频的参数
this.isReplaceUpload = false;
this.replaceLectureIndex = 0;
} }
}); });
}, },
...@@ -736,19 +776,22 @@ export default { ...@@ -736,19 +776,22 @@ export default {
this.isShowOtherContent = !this.isShowOtherContent; this.isShowOtherContent = !this.isShowOtherContent;
}, },
// 限制选择文件个数
handleExceed(files, fileList) {
this.$message.warning(`当前限制选择 100 个文件,您已经共选择了 ${files.length + fileList.length} 个文件!`);
},
// 表单校验 // 表单校验
// TODO
submitForm(formName) { submitForm(formName) {
this.needShowAuditMsg = false; this.needShowAuditMsg = false;
this.noCouseName = false; this.noCouseName = false;
this.noLecture = false; this.noLecture = false;
this.noLabel = false; this.noLabel = false;
let hasLecture = this.formData.courseCustomChapterModels[0].courseCustomLectureModelList.length > 0; let hasLecture = this.formData.courseCustomChapterModels[0].courseCustomLectureModelList.length > 0;
let flag = false;
let lectureList = this.formData.courseCustomChapterModels[0].courseCustomLectureModelList;
for(let i = 0; i < lectureList.length; i ++) {
if(!lectureList[i].name) {
flag = true;
break;
}
}
console.log('flag', flag);
if(!hasLecture) { if(!hasLecture) {
this.noLecture = true; this.noLecture = true;
} }
...@@ -758,9 +801,10 @@ export default { ...@@ -758,9 +801,10 @@ export default {
if(!this.formData.subjectIdList.length) { if(!this.formData.subjectIdList.length) {
this.noLabel = true; this.noLabel = true;
} }
if(this.noCouseName || this.noLabel || this.noLecture) { if(this.noCouseName || this.noLabel || this.noLecture || flag) {
return; return;
} }
this.insertOrUpdate(); this.insertOrUpdate();
}, },
...@@ -816,18 +860,23 @@ export default { ...@@ -816,18 +860,23 @@ export default {
return; return;
} }
vm.currentUploadType = 1;
vm.currentOption = vm.cropOption;
var _img = new FileReader() var _img = new FileReader()
_img.readAsDataURL(file) _img.readAsDataURL(file)
_img.onload = function(theFile) { _img.onload = function(theFile) {
let image = new Image() let image = new Image()
image.src = theFile.target.result image.src = theFile.target.result
vm.slide2.oriUrl = theFile.target.result;
image.onload = function() { image.onload = function() {
let _this = this let _this = this
// 图片大小不正常,则进行裁剪
if(_this.width != 750 || _this.height != 420) { if(_this.width != 750 || _this.height != 420) {
vm.$message.info("上传图片尺寸大小不合适,请重新上传") vm.showCropper = true;
// 图片大小正常,则直接上传
}else { }else {
vm.doUploadOSS(file, 1); //封面图片 vm.doUploadOSS(file, 1); //封面图片
} }
} }
} }
}, },
...@@ -840,15 +889,19 @@ export default { ...@@ -840,15 +889,19 @@ export default {
this.$message.error('只支持jpg、jpeg格式') this.$message.error('只支持jpg、jpeg格式')
return; return;
} }
vm.currentUploadType = 2;
vm.currentOption = vm.cropOption2;
var _img = new FileReader() var _img = new FileReader()
_img.readAsDataURL(file) _img.readAsDataURL(file)
_img.onload = function(theFile) { _img.onload = function(theFile) {
let image = new Image() let image = new Image()
image.src = theFile.target.result image.src = theFile.target.result
vm.slide2.oriUrl = theFile.target.result;
image.onload = function() { image.onload = function() {
let _this = this let _this = this
if(_this.width != 88 || _this.height != 88) { if(_this.width != 88 || _this.height != 88) {
vm.$message.info("上传图片尺寸大小不合适,请重新上传") vm.showCropper = true;
// vm.$message.info("上传图片尺寸大小不合适,请重新上传")
}else { }else {
vm.doUploadOSS(file, 2); //封面图片 vm.doUploadOSS(file, 2); //封面图片
} }
...@@ -928,8 +981,9 @@ export default { ...@@ -928,8 +981,9 @@ export default {
// display: inline-block; // display: inline-block;
} }
.custom-list { .custom-list {
// width: 100%; position: relative;
width: 520px; left: -78px;
width: 580px;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
border-radius: 3px; border-radius: 3px;
...@@ -940,37 +994,64 @@ export default { ...@@ -940,37 +994,64 @@ export default {
& > li { & > li {
margin: 10px 0; margin: 10px 0;
} }
.video { .video-wrappe {
display: flex; &:nth-child(n+2)::before {
flex-direction: row; position: absolute;
justify-content: space-between; top: -4px;
align-items: center; display: block;
.title { content: "";
display: inline-block; height: 0;
width: 70px; width: 100%;
text-align: right; border-top: 1px dashed #E4E7ED;
margin-right: 10px; }
.video {
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
.title {
display: inline-block;
width: 80px;
text-align: right;
margin-right: 10px;
}
.name {
cursor: pointer;
color: #5890DD;
}
img {
width: 12px;
height: 12px;
}
.other-action {
width: 80px;
display: flex;
align-items: center;
text-align: right;
justify-content: flex-end;
.replace {
position: relative;
top: 5px;
margin-right: 20px;
cursor: pointer;
width: 16px;
height: 16px;
}
.delete {
position: relative;
top: 2px;
cursor: pointer;
width: 16px;
height: 16px;
}
}
} }
.name {
cursor: pointer;
color: #5890DD;
}
img {
width: 12px;
height: 12px;
}
.delete {
position: relative;
top: 2px;
cursor: pointer;
width: 16px;
height: 16px;
}
} }
.video-name { .video-name {
.title { .title {
display: inline-block; display: inline-block;
width: 70px; width: 80px;
text-align: right; text-align: right;
margin-right: 10px; margin-right: 10px;
} }
...@@ -1074,8 +1155,8 @@ export default { ...@@ -1074,8 +1155,8 @@ export default {
} }
.error-video { .error-video {
position: absolute; position: absolute;
top: 76px; top: 74px;
left: 82px; left: 93px;
font-size: 13px; font-size: 13px;
color: #ed3131; color: #ed3131;
.cancle { .cancle {
......
...@@ -9,12 +9,14 @@ ...@@ -9,12 +9,14 @@
<el-form ref="auditForm" :model="auditForm" label-width="120px"> <el-form ref="auditForm" :model="auditForm" label-width="120px">
<el-form-item label="拒绝原因:"> <el-form-item label="拒绝原因:">
<el-radio-group v-model="auditForm.label"> <el-radio-group v-model="auditForm.label">
<div style="padding-top: 12px;"> <div v-for="item in refuseReasonList" :key="item">
<el-radio :label="refuseReasonList[0]"></el-radio> <div style="padding-top: 12px;">
<el-radio :label="item"></el-radio>
</div>
</div> </div>
<div style="padding-top: 16px;"> <!-- <div style="padding-top: 16px;">
<el-radio :label="refuseReasonList[1]"></el-radio> <el-radio :label="refuseReasonList[1]"></el-radio>
</div> </div> -->
<div style="padding-top: 16px;"> <div style="padding-top: 16px;">
<el-radio label="其他"></el-radio> <el-radio label="其他"></el-radio>
</div> </div>
......
...@@ -119,7 +119,7 @@ export const getFilePathForOSS = (file, fileName, folder) => { ...@@ -119,7 +119,7 @@ export const getFilePathForOSS = (file, fileName, folder) => {
} }
//文件类型 //文件类型
let ext = file.type; let ext = file.type || 'image/jpeg';
//后缀名 //后缀名
let suffix = file.name.substring(file.name.lastIndexOf(".") + 1); let suffix = file.name.substring(file.name.lastIndexOf(".") + 1);
//若为空则从name中获取---对wps格式的文件获取不到file.type //若为空则从name中获取---对wps格式的文件获取不到file.type
......
import {isEmptyUtils, isNotEmptyUtils, subString} from "./utils";
import fetchQiniu from './fetch-qiniu.js';
import { getQiniuToken1, uploadVideo, uploadImg } from './index'
let fileApiUrl = getQiniuToken1()
//该对象有一个 unsubscribe 方法取消订阅,同时终止上传行为。
let subscription = null;
//上传返回结果
let result = {
key: null,//文件保存在空间中的资源名
path: null,//保存到db的路径(不带域名)
fullPath: null,//文件网络路径(文件url)
size: null,//资源尺寸,单位为字节
name: null,//原始文件名
ext: null//上传资源的后缀名,通过自动检测的mimeType 或者原文件的后缀来获取
};
//上传状态
// var status = false;
//FIXME 请注意vue里面不要使用全局变量
let domain = uploadVideo() // 视频
let domain1 = uploadImg() // 图片
let errorCode = new Map([
[298,'部分操作执行成功'],
[400,'请求报文格式错误'],
[401,'认证授权失败'],
[403,'权限不足,拒绝访问。'],
[404,'资源不存在'],
[405,'请求方式错误'],
[406,'上传的数据 CRC32 校验错误'],
[413,'请求资源大小大于指定的最大值'],
[419,'用户账号被冻结'],
[478,'镜像回源失败'],
[502,'错误网关'],
[503,'服务端不可用'],
[504,'服务端操作超时'],
[573,'单个资源访问频率过高'],
[579,'上传成功但是回调失败'],
[599,'服务端操作失败'],
[608,'资源内容被修改'],
[612,'指定资源不存在或已被删除'],
[614,'目标资源已存在'],
[630,'已创建的空间数量达到上限,无法创建新空间。'],
[631,'指定空间不存在'],
[640,'调用列举资源(list)接口时,指定非法的marker参数。'],
[701,'在断点续上传过程中,后续上传接收地址不正确或ctx信息已过期。']
]);
let qiniuErrorCheck = function (code) {
errorCode.forEach(function (value, key, map) {
if (code === key){
console.error(key+':'+value)
}
})
}
//用来限制上传文件类型,为 null 时表示不对文件类型限制;限制类型放到数组里: ["image/png", "image/jpeg", "image/gif"]
let mimeTypeArray = null;
export const createFilePath = (file, fileName) => {
if (isEmptyUtils(file)) {
return null;
}
let arr = fileName.split('_');
if(arr.length != 4){
alert('上传视频文件名格式不正确');
return null;
}
let arr4 = arr[3].split('.');
//文件全路径(文件路径 + 文件名) 扩展名​/年/月/日/
let filePath = arr[0] + "/" + arr[1] + "/" + arr[2] + "_" + arr4[0] + '.'+arr4[1];
console.log(filePath);
return filePath;
};
/**
* 获取七牛上传凭证
*
* @return {Promise} token 七牛上传凭证
* */
const doQiniuAction1 = (fileType) => {
console.log('send---'+fileApiUrl);
return new Promise(function (resolve, reject) {
// if(isEmptyUtils(localStorage.getItem('qiniuToken'))){
fetchQiniu(fileApiUrl, {"fileType": fileType}, 'GET').then(function (result) {
let token = null;
if (isNotEmptyUtils(result) && result.code == "000000") {
token = result.data.qiniuToken;
resolve(token);
console.log('七牛临时授权成功');
localStorage.setItem('qiniuToken',token);
} else {
reject(result);
console.error('七牛临时授权失败:', result);
}
}).catch(function (error) {
reject();
console.error('七牛临时授权失败:', error);
});
// }else{
// console.log('从localStorage获取token:'+localStorage.getItem('qiniuToken'))
// resolve(localStorage.getItem('qiniuToken'));
// }
});
};
/**
*
* @param self
* @param file
* @param filePath
* @param previewId
* @param progressId
* @returns {Promise}
*/
export const qiniuUpload = (self, file, filePath, previewId, progressId) => {
// var deferred = $q.defer();
return new Promise(function (resolve, reject) {
if (isEmptyUtils(file) || isEmptyUtils(filePath)) {
console.error('七牛上传失败:非法参数');
reject();
}
let key = filePath ? filePath : getFilePath(file);
//修改状态为上传
self.qiniuUploadStatus = true;
// let token = "BRVB4TpxVFA5Wo6lIpfltmWKOltzGar46tvC3BlR:UHn0LDElwjP4jEZTXdq_1qV6_hw=:eyJzY29wZSI6InBpY2EtdGVzdCIsInJldHVybkJvZHkiOiJ7XCJrZXlcIjpcIiQoa2V5KVwiLFwiaGFzaFwiOlwiJChldGFnKVwiLFwiYnVja2V0XCI6XCIkKGJ1Y2tldClcIixcImZzaXplXCI6JChmc2l6ZSksXCJmbmFtZVwiOiQoZm5hbWUpLFwiZXh0XCI6JChleHQpfSIsImRlYWRsaW5lIjoxNTI5NDk0MTc1fQ==";
doQiniuAction().then(function (token) {
let putExtra = {
fname: file.name, //原文件名
params: {}, //用来放置自定义变量
mimeType: mimeTypeArray || null //null || array,用来限制上传文件类型,为 null 时表示不对文件类型限制;限制类型放到数组里: ["image/png", "image/jpeg", "image/gif"]
};
let config = {
useCdnDomain: true, //表示是否使用 cdn 加速域名,为布尔值,true 表示使用,默认为 false。
region: null //选择上传域名区域;当为 null 或 undefined 时,自动分析上传域名区域
};
/*
* qiniu.upload 返回一个 observable 对象用来控制上传行为,observable 对像通过 subscribe 方法可以被 observer 所订阅,
* 订阅同时会开始触发上传,同时返回一个 subscription 对象,该对象有一个 unsubscribe 方法取消订阅,同时终止上传行为。
* */
let observable = qiniu.upload(file, key, token, putExtra, config);
/**
* 接收上传进度信息,res 参数是一个带有 total 字段的 object,包含loaded、total、percent三个属性,提供上传进
* total.loaded: number,已上传大小,单位为字节。
* total.total: number,本次上传的总量控制信息,单位为字节,注意这里的 total 跟文件大小并不一致。
* total.percent: number,当前上传进度,范围:0~100
* */
let next = function (res) {
//res值{"total":{"loaded":18184,"size":18185,"percent":99.99450096233159}}
//获取百分比进度
let progress = res.total.percent.toFixed(2);
self.uploadProgress = Number(progress);
console.log('Progress1: ' + progress);
//如果有进度条
/*if (isNotEmptyUtils(progressId)) {
let obj = $("#" + progressId);
//开始上传时,显示进度条
if (isNotEmptyUtils(obj.parent())) {
//修改状态为上传
// status = true;
self.qiniuUploadStatus = true;
obj.parent().removeClass("hidden");
obj.fadeIn("fast");
}
obj.css("width", progress + '%');
obj.text(progress + '%');
//上传完成,2秒后淡出进度条
if (progress === "100.00") {
//修改状态为非上传
// status = false;
self.qiniuUploadStatus = true;
obj.fadeOut(2000);
}
}*/
};
/**
* 接收上传完成后的后端返回信息,res 参数为一个 object, 为上传成功后后端返回的信息
* ,具体返回结构取决于后端sdk的配置,可参考上传策略(https://developer.qiniu.com/kodo/manual/1206/put-policy)
* */
let complete = function (res) {
console.log("七牛上传完成");
setTimeout(function(){
result.key = res.key;
result.path = '/' + res.key;
result.fullPath = domain + '/' + res.key + '?v=' + new Date().getTime();
result.size = res.fsize;
result.name = res.fname ;
result.ext = res.ext;
// deferred.resolve(result);
resolve(result);
// self.model.qCloudUrl = result.fullPath;
// $("#introVideoLecture").attr("src", self.model.qCloudUrl);
//修改状态为非上传
// status = false;
self.qiniuUploadStatus = false;
if (isNotEmptyUtils(previewId)) {
let address = domain + result.path;
console.log('文件路径: ' + address);
//显示图片
let $img = $('<img>').attr("src", address);
let obj = $("#" + previewId);
obj.empty().append($img);
obj.css('max-width', '100%');
}
},2000);
};
/**
* 上传错误后触发,当不是 xhr 请求错误时,会把当前错误产生原因直接抛出,诸如 JSON 解析异常等;当产生 xhr 请求错误时,参数 err 为一个包含 code、message、isRequestError 三个属性的 object:
* err.isRequestError: 用于区分是否 xhr 请求错误;当 xhr 请求出现错误并且后端通过 HTTP 状态码返回了错误信息时,该参数为 true;否则为 undefined 。
* err.reqId: string,xhr请求错误的 X-Reqid。
* err.code: number,请求错误状态码,只有在 err.isRequestError 为 true 的时候才有效,可查阅码值对应说明。
* err.message: string,错误信息,包含错误码,当后端返回提示信息时也会有相应的错误信息。
* */
let error = function (err) {
//修改状态为非上传
// status = false;
self.qiniuUploadStatus = false
localStorage.removeItem('qiniuToken');
console.log("七牛上传失败,详细信息请参考:https://developer.qiniu.com/kodo/api/3928/error-responses");
//输出简略错误信息
if (err.isRequestError){
qiniuErrorCheck(err.code)
}else {
console.error(err);
}
/*modalClick("提示", "上传失败!", "确定", function () {
$('#model-modify').modal('hide');
}, "", null);*/
// deferred.reject(new Error('七牛上传失败'));
// return deferred.promise;
return reject(new Error('七牛上传失败'));
};
// 上传开始
subscription = observable.subscribe(next, error, complete);
});
console.log(22222);
window.QNSubscription = subscription;
// return deferred.promise;
});
};
/**
* 获取时间戳
* @param {Date} [date]日期对象,为空时,返回当前时间戳
* @return {String} timeStamp时间戳 格式:yyyyMMddhhmmssS
*/
const timeStamp = (date) => {
if (isEmptyUtils(date)) {
return new Date().format('yyyyMMddhhmmssS');
}
return date.format('yyyyMMddhhmmssS');
}
/**
* 获取全局唯一标识符(GUID,Globally Unique Identifier)
* @return {String} guid
*/
const guid = () => {
/**
* @return {String}
*/
function S4() {
return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
}
return (S4() + S4() + "-" + S4() + "-" + S4() + "-" + S4() + "-" + S4() + S4() + S4());
};
/**
* 文件重命名--七牛图片 2018 11
* @param {File} [file] 上传文件对象
* @param {String} [fileName] 指定文件名
* @param {String} [folder] 指定文件夹
* @return {String} fileName
*/
export const getFilePath = (file,fileName,folder) => {
if (isEmptyUtils(file)) {
return null;
}
//文件类型
var ext = file.type;
//后缀名
var suffix = file.name.substring(file.name.lastIndexOf(".") + 1);
//若为空则从name中获取---对wps格式的文件获取不到file.type
if (isEmptyUtils(ext)) {
ext = suffix;
}
//获取当前日期对象
var date = new Date();
if (isEmptyUtils(fileName)) {
//重命名后的文件名
fileName = timeStamp(date) + "-" + subString(guid(), 8) + "." + suffix;
}
//文件全路径(文件路径 + 文件名) 扩展名​/年/月/日/
// var filePath = ext + "/" + date.format('yyyy/MM/dd') + "/" + (isEmptyUtils(folder) ? "" : (folder + "/")) + fileName;
//var filePath = ext + "/" + "common/" + file.name.split('.')[0] + '-' + timeStamp(date) + "." + suffix;
var filePath = ext + "/" + "protal/project/" + timeStamp(date) + "." + suffix;
console.log('filePath==============',filePath);
return filePath;
}
/**
*七牛上传图片、视频、文件 2018 11 hws
* @param self
* @param file
* @param filePath
* @param previewId
* @param progressId
* @param fileType 1--图片和文件 空为视频
* @returns {Promise}
*/
export const doUpload = (self, file, filePath, previewId, progressId, fileType) => {
// var deferred = $q.defer();
return new Promise(function (resolve, reject) {
if (isEmptyUtils(file) || isEmptyUtils(filePath)) {
console.error('七牛上传失败:非法参数');
reject();
}
let key = filePath ? filePath : getFilePath(file);
//修改状态为上传
self.qiniuUploadStatus = true;
// let token = "BRVB4TpxVFA5Wo6lIpfltmWKOltzGar46tvC3BlR:UHn0LDElwjP4jEZTXdq_1qV6_hw=:eyJzY29wZSI6InBpY2EtdGVzdCIsInJldHVybkJvZHkiOiJ7XCJrZXlcIjpcIiQoa2V5KVwiLFwiaGFzaFwiOlwiJChldGFnKVwiLFwiYnVja2V0XCI6XCIkKGJ1Y2tldClcIixcImZzaXplXCI6JChmc2l6ZSksXCJmbmFtZVwiOiQoZm5hbWUpLFwiZXh0XCI6JChleHQpfSIsImRlYWRsaW5lIjoxNTI5NDk0MTc1fQ==";
doQiniuAction1(fileType).then(function (token) {
let putExtra = {
fname: file.name, //原文件名
params: {}, //用来放置自定义变量
mimeType: mimeTypeArray || null //null || array,用来限制上传文件类型,为 null 时表示不对文件类型限制;限制类型放到数组里: ["image/png", "image/jpeg", "image/gif"]
};
let config = {
useCdnDomain: true, //表示是否使用 cdn 加速域名,为布尔值,true 表示使用,默认为 false。
region: null //选择上传域名区域;当为 null 或 undefined 时,自动分析上传域名区域
};
/*
* qiniu.upload 返回一个 observable 对象用来控制上传行为,observable 对像通过 subscribe 方法可以被 observer 所订阅,
* 订阅同时会开始触发上传,同时返回一个 subscription 对象,该对象有一个 unsubscribe 方法取消订阅,同时终止上传行为。
* */
let observable = qiniu.upload(file, key, token, putExtra, config);
/**
* 接收上传进度信息,res 参数是一个带有 total 字段的 object,包含loaded、total、percent三个属性,提供上传进
* total.loaded: number,已上传大小,单位为字节。
* total.total: number,本次上传的总量控制信息,单位为字节,注意这里的 total 跟文件大小并不一致。
* total.percent: number,当前上传进度,范围:0~100
* */
let next = function (res) {
//res值{"total":{"loaded":18184,"size":18185,"percent":99.99450096233159}}
//获取百分比进度
let progress = res.total.percent.toFixed(2);
self.uploadProgress = Number(progress);
if(progressId == 'uploadProgress1') {
self.uploadProgress1 = Number(progress);
}
if(progressId == 'uploadProgress2') {
self.uploadProgress2 = Number(progress);
}
console.log('Progress2: ' + progress);
//如果有进度条
/*if (isNotEmptyUtils(progressId)) {
let obj = $("#" + progressId);
//开始上传时,显示进度条
if (isNotEmptyUtils(obj.parent())) {
//修改状态为上传
// status = true;
self.qiniuUploadStatus = true;
obj.parent().removeClass("hidden");
obj.fadeIn("fast");
}
obj.css("width", progress + '%');
obj.text(progress + '%');
//上传完成,2秒后淡出进度条
if (progress === "100.00") {
//修改状态为非上传
// status = false;
self.qiniuUploadStatus = true;
obj.fadeOut(2000);
}
}*/
};
/**
* 接收上传完成后的后端返回信息,res 参数为一个 object, 为上传成功后后端返回的信息
* ,具体返回结构取决于后端sdk的配置,可参考上传策略(https://developer.qiniu.com/kodo/manual/1206/put-policy)
* */
let complete = function (res) {
console.log("七牛上传完成");
setTimeout(function(){
result.key = res.key;
result.path = '/' + res.key;
// result.fullPath = domain + '/' + res.key + '_' + new Date().getTime();
if(!fileType) { // 图片 文件
console.log('---domain-------',domain)
result.fullPath = domain + '/' + res.key;
}else{ // 视频
console.log('----domain1------',domain1)
result.fullPath = domain1 + '/' + res.key;
}
result.size = res.fsize;
result.name = res.fname ;
result.ext = res.ext;
// deferred.resolve(result);
resolve(result);
// self.model.qCloudUrl = result.fullPath;
// $("#introVideoLecture").attr("src", self.model.qCloudUrl);
//修改状态为非上传
// status = false;
self.qiniuUploadStatus = false;
},500);
};
/**
* 上传错误后触发,当不是 xhr 请求错误时,会把当前错误产生原因直接抛出,诸如 JSON 解析异常等;当产生 xhr 请求错误时,参数 err 为一个包含 code、message、isRequestError 三个属性的 object:
* err.isRequestError: 用于区分是否 xhr 请求错误;当 xhr 请求出现错误并且后端通过 HTTP 状态码返回了错误信息时,该参数为 true;否则为 undefined 。
* err.reqId: string,xhr请求错误的 X-Reqid。
* err.code: number,请求错误状态码,只有在 err.isRequestError 为 true 的时候才有效,可查阅码值对应说明。
* err.message: string,错误信息,包含错误码,当后端返回提示信息时也会有相应的错误信息。
* */
let error = function (err) {
//修改状态为非上传
// status = false;
self.qiniuUploadStatus = false
localStorage.removeItem('qiniuToken');
console.log("七牛上传失败,详细信息请参考:https://developer.qiniu.com/kodo/api/3928/error-responses");
//输出简略错误信息
if (err.isRequestError){
qiniuErrorCheck(err.code)
}else {
console.error(err);
}
return reject(new Error('七牛上传失败'));
};
// 上传开始
subscription = observable.subscribe(next, error, complete);
});
// 保存到全局对象
window.QNSubscription = subscription;
// return deferred.promise;
});
};
...@@ -341,23 +341,15 @@ export const getFilePath = (file,fileName,folder) => { ...@@ -341,23 +341,15 @@ export const getFilePath = (file,fileName,folder) => {
* @returns {Promise} * @returns {Promise}
*/ */
export const doUpload = (self, file, filePath, previewId, progressId, fileType) => { export const doUpload = (self, file, filePath, previewId, progressId, fileType) => {
// var deferred = $q.defer();
return new Promise(function (resolve, reject) { return new Promise(function (resolve, reject) {
if (isEmptyUtils(file) || isEmptyUtils(filePath)) { if (isEmptyUtils(file) || isEmptyUtils(filePath)) {
console.error('七牛上传失败:非法参数'); console.error('七牛上传失败:非法参数');
reject(); reject();
} }
let key = filePath ? filePath : getFilePath(file); let key = filePath ? filePath : getFilePath(file);
//修改状态为上传 //修改状态为上传
self.qiniuUploadStatus = true; self.qiniuUploadStatus = true;
// let token = "BRVB4TpxVFA5Wo6lIpfltmWKOltzGar46tvC3BlR:UHn0LDElwjP4jEZTXdq_1qV6_hw=:eyJzY29wZSI6InBpY2EtdGVzdCIsInJldHVybkJvZHkiOiJ7XCJrZXlcIjpcIiQoa2V5KVwiLFwiaGFzaFwiOlwiJChldGFnKVwiLFwiYnVja2V0XCI6XCIkKGJ1Y2tldClcIixcImZzaXplXCI6JChmc2l6ZSksXCJmbmFtZVwiOiQoZm5hbWUpLFwiZXh0XCI6JChleHQpfSIsImRlYWRsaW5lIjoxNTI5NDk0MTc1fQ==";
doQiniuAction1(fileType).then(function (token) { doQiniuAction1(fileType).then(function (token) {
let putExtra = { let putExtra = {
fname: file.name, //原文件名 fname: file.name, //原文件名
...@@ -396,27 +388,6 @@ export const doUpload = (self, file, filePath, previewId, progressId, fileType) ...@@ -396,27 +388,6 @@ export const doUpload = (self, file, filePath, previewId, progressId, fileType)
self.uploadProgress2 = Number(progress); self.uploadProgress2 = Number(progress);
} }
console.log('Progress2: ' + progress); console.log('Progress2: ' + progress);
//如果有进度条
/*if (isNotEmptyUtils(progressId)) {
let obj = $("#" + progressId);
//开始上传时,显示进度条
if (isNotEmptyUtils(obj.parent())) {
//修改状态为上传
// status = true;
self.qiniuUploadStatus = true;
obj.parent().removeClass("hidden");
obj.fadeIn("fast");
}
obj.css("width", progress + '%');
obj.text(progress + '%');
//上传完成,2秒后淡出进度条
if (progress === "100.00") {
//修改状态为非上传
// status = false;
self.qiniuUploadStatus = true;
obj.fadeOut(2000);
}
}*/
}; };
/** /**
...@@ -428,7 +399,6 @@ export const doUpload = (self, file, filePath, previewId, progressId, fileType) ...@@ -428,7 +399,6 @@ export const doUpload = (self, file, filePath, previewId, progressId, fileType)
setTimeout(function(){ setTimeout(function(){
result.key = res.key; result.key = res.key;
result.path = '/' + res.key; result.path = '/' + res.key;
// result.fullPath = domain + '/' + res.key + '_' + new Date().getTime();
if(!fileType) { // 图片 文件 if(!fileType) { // 图片 文件
console.log('---domain-------',domain) console.log('---domain-------',domain)
result.fullPath = domain + '/' + res.key; result.fullPath = domain + '/' + res.key;
...@@ -436,32 +406,12 @@ export const doUpload = (self, file, filePath, previewId, progressId, fileType) ...@@ -436,32 +406,12 @@ export const doUpload = (self, file, filePath, previewId, progressId, fileType)
console.log('----domain1------',domain1) console.log('----domain1------',domain1)
result.fullPath = domain1 + '/' + res.key; result.fullPath = domain1 + '/' + res.key;
} }
result.size = res.fsize; result.size = res.fsize;
result.name = res.fname ; result.name = res.fname ;
result.ext = res.ext; result.ext = res.ext;
// deferred.resolve(result);
resolve(result); resolve(result);
// self.model.qCloudUrl = result.fullPath;
// $("#introVideoLecture").attr("src", self.model.qCloudUrl);
//修改状态为非上传
// status = false;
self.qiniuUploadStatus = false; self.qiniuUploadStatus = false;
// if (isNotEmptyUtils(previewId)) {
// let address = domain + result.path;
// console.log('文件路径: ' + address);
// //显示图片
// let uplodImg = $('<img>').attr("src", address);
// let obj = $("#" + previewId);
// obj.empty().append(uplodImg);
// obj.css('max-width', '100%');
// }
},500); },500);
}; };
/** /**
...@@ -483,12 +433,6 @@ export const doUpload = (self, file, filePath, previewId, progressId, fileType) ...@@ -483,12 +433,6 @@ export const doUpload = (self, file, filePath, previewId, progressId, fileType)
}else { }else {
console.error(err); console.error(err);
} }
/*modalClick("提示", "上传失败!", "确定", function () {
$('#model-modify').modal('hide');
}, "", null);*/
// deferred.reject(new Error('七牛上传失败'));
// return deferred.promise;
return reject(new Error('七牛上传失败')); return reject(new Error('七牛上传失败'));
}; };
...@@ -497,11 +441,7 @@ export const doUpload = (self, file, filePath, previewId, progressId, fileType) ...@@ -497,11 +441,7 @@ export const doUpload = (self, file, filePath, previewId, progressId, fileType)
}); });
console.log(33333); // 保存到全局对象
window.QNSubscription = subscription; window.QNSubscription = subscription;
// return deferred.promise;
}); });
}; };
<template>
<div class="review-access-wrap">
<bread-crumb :curmbFirst="curmbFirst" :curmbSecond="curmbSecond"></bread-crumb>
<div class="edit-course-wrapper review-access screenSet" id="screenSet">
<div class="course-content">
<el-form
ref="formDataRef"
:model="formData"
:rules="rules"
label-width="120px"
class="basic-form"
>
<el-form-item label="课程名称:" prop="courseName" class="valid-msg">
<el-col :span="20">
<el-input
size="small"
v-model="formData.courseName"
placeholder="请输入课程名称"
style="width: 360px"
maxlength="25"
:disabled="disabled"
></el-input>
<span class="word-num">
{{(formData.courseName || '').replace(/\s+/g,"").length}}/25
<span v-show="formData.checkStatus == 0" class="edit-wrapper" @click="auditField(formData, 'courseNameCheck')">
<img class="edit-img" src="../../assets/image/phrase3/icon-pz.png" />拒绝原因
</span>
</span>
<div v-show="needShowAuditMsg && formData.courseNameCheck && formData.checkStatus != 2" class="error">
<span>{{formData.courseNameCheck}}</span>
<span v-show="formData.checkStatus == 0" class="cancle" @click="cancleAudit(formData, 'courseNameCheck')">X</span>
</div>
</el-col>
</el-form-item>
<el-form-item label="学科分类:" prop="subjectIdList" class="valid-msg">
<el-col :span="18">
<el-cascader
style="width: 360px"
v-model="formData.subjectIdList"
:options="labelOptions"
:props="{ value: 'id', label: 'name', children: 'subList'}"
:disabled="disabled"
>
</el-cascader>
</el-col>
</el-form-item>
<el-form-item label="开放范围:" prop="shareType" class="valid-msg">
<el-radio-group v-model="formData.shareType">
<el-radio :label="1">机构共享</el-radio>
</el-radio-group>
</el-form-item>
<div class="basic-item-icon" style="margin-top: 0; padding-top: 0;">
<ul v-show="formData.courseCustomChapterModels[0].courseCustomLectureModelList.length" class="custom-list">
<li v-for="(lecture, index) in formData.courseCustomChapterModels[0].courseCustomLectureModelList" :key="index" class="valid-msg">
<ul class="video">
<li class="video-wapper">
<span class="title">视频{{index + 1}}</span>
<img src="../../assets/image/phrase3/icon-pin.png" />
<span class="name" @click="previewVideoAction(lecture)">{{lecture.resourceModel && lecture.resourceModel.name}}</span>
</li>
</ul>
<div class="video-name">
<span class="title">
<span style="color: red;">*</span>
<span class="video-title">视频名称</span>
</span>
<el-input
size="small"
v-model="lecture.name"
placeholder="请输入课程名称"
style="width: 380px"
maxlength="25"
:disabled="disabled"
></el-input>
<span class="word-num">
{{(lecture.name || '').replace(/\s+/g,"").length}}/25
<span v-show="formData.checkStatus == 0" class="edit-wrapper" @click="auditField(formData.courseCustomChapterModels[0].courseCustomLectureModelList[index], 'nameCheck')">
<img class="edit-img" src="../../assets/image/phrase3/icon-pz.png" />拒绝原因
</span>
</span>
<div v-show="needShowAuditMsg && formData.courseCustomChapterModels[0].courseCustomLectureModelList[index].nameCheck && formData.checkStatus != 2" class="error-video">
<span>{{formData.courseCustomChapterModels[0].courseCustomLectureModelList[index].nameCheck}}</span>
<span v-show="formData.checkStatus == 0" class="cancle" @click="cancleAudit(formData.courseCustomChapterModels[0].courseCustomLectureModelList[index], 'nameCheck')">X</span>
</div>
</div>
</li>
<span v-show="needShowUploadProcess" class="upload-process" :style="{'width': (uploadProgress/100 * 340) + 'px'}"></span>
</ul>
</div>
<div class="other-content valid-msg">
<div class="tips">注:以下信息为非必填项,您也可以根据实际情况修改</div>
<div class="basic-item-icon">
<!-- <span class="require">*</span> -->
<el-form-item label="课程封面:">
<el-upload
v-model="formData.courseIntroImage"
class="bg-uploader"
action="#"
:show-file-list="false"
:disabled="disabled"
>
<div class="bg-img-wrapper">
<img
v-if="formData.courseIntroImage"
@mouseover.stop="imgMouseOver=true"
:src="formData.courseIntroImage"
class="bg-img"
/>
<img
v-if="!formData.courseIntroImage"
class="bg-img"
src="../../assets/image/small.png"
/>
</div>
</el-upload>
<div class="limit-text">尺寸:750*420,只支持jpg、jpeg格式</div>
<span class="word-num">
<span v-show="formData.checkStatus == 0" class="edit-wrapper" @click="auditField(formData, 'courseIntroImageCheck')">
<img class="edit-img" src="../../assets/image/phrase3/icon-pz.png" />拒绝原因
</span>
</span>
<div v-show="needShowAuditMsg && formData.courseIntroImageCheck" class="error" :class="{'top-124': formData.checkStatus == 0}" style="position:absolute;top:103px;">
<span>{{formData.courseIntroImageCheck}}</span>
<span v-show="formData.checkStatus == 0" class="cancle" @click="cancleAudit(formData, 'courseIntroImageCheck')">X</span>
</div>
</el-form-item>
<p class="upload-message" v-if="uploadImgMessage">请选择列表图片</p>
</div>
<el-form-item label="课程难度:">
<el-radio-group v-model="formData.difficultyLevel" :disabled="disabled">
<el-radio :label="1">初级</el-radio>
<el-radio :label="2">中级</el-radio>
<el-radio :label="3">高级</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="讲师名称:" class="valid-msg">
<el-col :span="18">
<el-input
size="small"
v-model="formData.courseCustomDoctorModels[0].courseDoctorName"
placeholder="请输入讲师名称"
style="width: 360px"
maxlength="25"
@focus="isShowDoctorList=true"
@input="filterDoctorName"
@blur="doctorNameInputBlur"
:disabled="disabled"
></el-input>
<ul v-show="isShowDoctorList" class="doctor-select-list">
<li
v-for="(item, index) in doctorNameList"
:key="index"
@click="selectDoctor(item.courseDoctorName, index)"
:class="{'doctor-selected': item.seleted}"
>
<span v-show="item.show">{{item.courseDoctorName || '测试名'}}</span>
</li>
</ul>
<span class="word-num">
{{(formData.courseCustomDoctorModels[0] && formData.courseCustomDoctorModels[0].courseDoctorName || '').replace(/\s+/g,"").length}}/25
<span v-show="formData.checkStatus == 0" class="edit-wrapper" @click="auditField(formData.courseCustomDoctorModels[0], 'courseDoctorNameCheck')">
<img class="edit-img" src="../../assets/image/phrase3/icon-pz.png" />拒绝原因
</span>
</span>
<div v-show="needShowAuditMsg && formData.courseCustomDoctorModels[0].courseDoctorNameCheck && formData.checkStatus != 2" class="error">
<span>{{formData.courseCustomDoctorModels[0].courseDoctorNameCheck}}</span>
<span v-show="formData.checkStatus == 0" class="cancle" @click="cancleAudit(formData.courseCustomDoctorModels[0], 'courseDoctorNameCheck')">X</span>
</div>
</el-col>
</el-form-item>
<div class="basic-item-icon">
<el-form-item label="讲师头像:" class="valid-msg">
<el-upload
v-model="formData.courseCustomDoctorModels[0].courseDoctorAvatarUrl"
class="bg-uploader"
action="#"
:show-file-list="false"
:disabled="disabled"
>
<div class="bg-img-wrapper">
<img
v-if="formData.courseCustomDoctorModels && formData.courseCustomDoctorModels[0].courseDoctorAvatarUrl || ''"
@mouseover.stop="imgMouseOver=true"
:src="formData.courseCustomDoctorModels[0].courseDoctorAvatarUrl"
class="bg-img-doctor"
/>
<img
v-if="!(formData.courseCustomDoctorModels && formData.courseCustomDoctorModels[0].courseDoctorAvatarUrl || '')"
class="bg-img-doctor"
src="../../assets/image/small.png"
/>
</div>
</el-upload>
<div class="limit-text">尺寸:88*88,只支持jpg、jpeg格式</div>
<span class="word-num">
<span v-show="formData.checkStatus == 0" class="edit-wrapper" @click="auditField(formData.courseCustomDoctorModels[0], 'courseDoctorAvatarUrlCheck')">
<img class="edit-img" src="../../assets/image/phrase3/icon-pz.png" />拒绝原因
</span>
</span>
<div v-show="needShowAuditMsg && formData.courseCustomDoctorModels[0].courseDoctorAvatarUrlCheck" class="error" :class="{'top-124': formData.checkStatus == 0}" style="position:absolute;top: 102px;">
<span>{{formData.courseCustomDoctorModels[0].courseDoctorAvatarUrlCheck}}</span>
<span v-show="formData.checkStatus == 0" class="cancle" @click="cancleAudit(formData.courseCustomDoctorModels[0], 'courseDoctorAvatarUrlCheck')">X</span>
</div>
</el-form-item>
<p class="upload-message" v-if="uploadImgMessage">请选择列表图片</p>
</div>
<el-form-item label="所属机构:" class="valid-msg">
<el-col :span="18">
<el-input
size="small"
v-model="formData.courseCustomDoctorModels[0].courseDoctorHospital"
placeholder="请输入所属机构"
style="width: 360px"
maxlength="25"
:disabled="disabled"
></el-input>
<span class="word-num">
{{(formData.courseCustomDoctorModels && formData.courseCustomDoctorModels[0].courseDoctorHospital || '').replace(/\s+/g,"").length}}/25
<!-- <span class="edit-wrapper"> -->
<span v-show="formData.checkStatus == 0" class="edit-wrapper" @click="auditField(formData.courseCustomDoctorModels[0], 'courseDoctorHospitalCheck')">
<img class="edit-img" src="../../assets/image/phrase3/icon-pz.png" />拒绝原因
</span>
</span>
<div v-show="needShowAuditMsg && formData.courseCustomDoctorModels[0].courseDoctorHospitalCheck && formData.checkStatus != 2" class="error">
<span>{{formData.courseCustomDoctorModels[0].courseDoctorHospitalCheck}}</span>
<span v-show="formData.checkStatus == 0" class="cancle" @click="cancleAudit(formData.courseCustomDoctorModels[0], 'courseDoctorHospitalCheck')">X</span>
</div>
</el-col>
</el-form-item>
<el-form-item label="课程简介:" class="valid-msg">
<el-col :span="14">
<el-input
style="width:420px"
size="small"
type="textarea"
maxlength="200"
:autosize="{ minRows: 5}"
placeholder="请输入课程简介"
v-model="formData.courseIntro"
:disabled="disabled"
/>
<span class="word-num">
{{(formData.courseIntro || '').replace(/\s+/g,"").length}}/200
<span v-show="formData.checkStatus == 0" class="edit-wrapper" @click="auditField(formData, 'courseIntroCheck')">
<img class="edit-img" src="../../assets/image/phrase3/icon-pz.png" />拒绝原因
</span>
</span>
<div v-show="needShowAuditMsg && formData.courseIntroCheck && formData.checkStatus != 2" class="error-area">
<span>{{formData.courseIntroCheck}}</span>
<span v-show="formData.checkStatus == 0" class="cancle" @click="cancleAudit(formData, 'courseIntroCheck')">X</span>
</div>
</el-col>
</el-form-item>
</div>
</el-form>
</div>
<footer style="padding: 30px;padding-bottom: 50px;">
<el-button style="margin-left: 20px" @click="backToListPage">返回列表</el-button>
<el-button v-if="formData.checkStatus == 0" style="margin-left: 100px" type="primary" @click="passOrRefuse(2)">通 过</el-button>
<el-button v-if="formData.checkStatus == 0" type="primary" @click="passOrRefuse(1)">拒 绝</el-button>
</footer>
</div>
<DialogComponet :dialogObj="dialogObj" @hide="passOrRefuseAction" @confirm="dialogObj.visible=false"></DialogComponet>
<PreviewVideo :dialogVisible="isPreviewVideo" :videoUrl="videoUrl" @close="isPreviewVideo=false"></PreviewVideo>
<RejectReasonDialog :refuseReasonList="refuseReasonList" :dialogVisible="auditVisible" @close="auditVisible=false" @checkInfo="checkInfo"></RejectReasonDialog>
</div>
</template>
<script>
import PreviewVideo from "@/components/education/custom-resource/preview-video";
import PreviewProtocol from "@/components/education/custom-resource/preview-protocol";
import DialogComponet from "@/components/education/template/dialog";
import RejectReasonDialog from "@/components/education/custom-resource/reject-reason-dialog";
import { openLoading, closeLoading } from "@/utils/utils";
import BreadCrumb from "../../components/breadcrumb.vue";
import * as commonUtil from "../../utils/utils";
let vm = null;
export default {
data() {
return {
curmbFirst: "CME",
curmbSecond: "外部资源管理",
auditVisible: false,
needCheckField: false,
needShowAuditMsg: false,
needShowUploadProcess: false,
disabled: true,
formData: {
checkStatus: 0,
courseCustomChapterModels: [
{
courseCustomLectureModelList: [],
id: null,
name: "视频课程"
}
],
courseCustomDoctorModels: [
{
courseDoctorAvatarUrl:
"https://test1-file.yunqueyi.com/image/png/common/2020062015265063.png",
courseDoctorAvatarUrlCheck: "",
courseDoctorHospital: "",
courseDoctorHospitalCheck: "",
courseDoctorName: "",
courseDoctorNameCheck: "",
id: null
}
],
courseId: null,
courseIntro: "",
courseIntroCheck: "",
courseIntroImage:
"https://test1-file.yunqueyi.com/image/png/common/202006201528136.png",
courseIntroImageCheck: "",
courseName: "",
courseNameCheck: "",
deleteCustomLectureIds: [],
difficultyLevel: 1,
shareType: 1,
subjectIdList: []
},
uploadImgMessage: false,
imgMouseOver: false,
rules: {
courseName: [
{ required: true, message: " " },
],
subjectIdList: [
{ required: true, message: "请输入课程名称" }
],
shareType: [
{ required: true, message: "请选择开放范围" }
]
},
labelOptions: [],
fileList: [
],
projectBanner:
"https://file.yunqueyi.com/h5/images/cme/project-banner.png",
doctorHeader: "https://file.yunqueyi.com/h5/images/cme/doctor-header.png",
doctorNameList: [
{ courseDoctorName: "333", show: true, seleted: false },
{ courseDoctorName: "334", show: true, seleted: false },
{ courseDoctorName: "335", show: true, seleted: false },
{ courseDoctorName: "336", show: true, seleted: false }
],
isShowDoctorList: false,
isPreviewVideo: false,
videoUrl: "",
orgCourseInfo: {
defaultDoctor: {
courseDoctorAvatarUrl:
"https://test1-file.yunqueyi.com/image/png/common/2020062015265063.png",
courseDoctorAvatarUrlCheck: "",
courseDoctorHospital: "",
courseDoctorHospitalCheck: "",
courseDoctorName: "",
courseDoctorNameCheck: "",
id: null
},
doctorModelList: [
{
courseDoctorAvatarUrl:
"https://test1-file.yunqueyi.com/image/png/common/2020062015265063.png",
courseDoctorAvatarUrlCheck: "",
courseDoctorHospital: "",
courseDoctorHospitalCheck: "",
courseDoctorName: "",
courseDoctorNameCheck: "",
id: null
}
],
limitModel: {
maxLimitOneVideoSize: 0,
maxLimitVideoCount: 0,
maxStorageSpace: 0,
usedStorageSpace: 0
}
},
uploadProgress: 0,
dialogObj: {
visible: false,
title: "确定取消吗?",
message: "确定课程已完成检测并通过审核?",
tip: "",
// confirmMsg: "取 消",
// hideMsg: "确 定"
},
statusObj: {
pass: {
title: "确认通过",
message: "确定课程已完成检测并通过审核?",
// message: "确定“云小鹊”提交的「高血压治疗规范」课程已完成检测并通过审核?",
tip: "",
confirmMsg: "取 消",
hideMsg: "确 定"
},
refuse: {
title: "",
message: "您已添加过「拒绝原因」,不能通过该课程",
// message: "确定“云小鹊”提交的「高血压治疗规范」课程已完成检测并通过审核?",
tip: "",
confirmMsg: "我知道了",
hideMsg: ""
},
refuseReasen: {
title: "",
message: "请填写拒绝原因",
// message: "确定“云小鹊”提交的「高血压治疗规范」课程已完成检测并通过审核?",
tip: "",
confirmMsg: "取 消",
hideMsg: "确 定"
},
confirmRefuse: {
title: "确认拒绝",
message: "确定“云小鹊”提交的「高血压治疗规范」课程审核为拒绝",
// message: "确定“云小鹊”提交的「高血压治疗规范」课程已完成检测并通过审核?",
tip: "",
confirmMsg: "取 消",
hideMsg: "确 定"
},
},
courseId: 0,
currentModifiedOrg: {},
currentFieldName: '',
refuseReasonList: [],
createdDoctorName: ''
};
},
computed: {},
components: {
BreadCrumb,
PreviewVideo,
DialogComponet,
RejectReasonDialog
},
created() {
vm = this;
this.courseId = this.$route && this.$route.query && this.$route.query.courseId || 0;
this.createdDoctorName = this.$route && this.$route.query && this.$route.query.createdDoctorName || '';
vm.initModify();
},
mounted() {
this.getLabelList();
this.getRefuseList();
commonUtil.resizeHeight();
},
methods: {
// 返回到列表页面
backToListPage() {
this.$router.back(-1)
},
// 创建课程页面的初始信息
initOrgCourseInfo() {
vm.GET("contents/course/custom/info/init", { setEntry: true }).then(
res => {
if (res.code == "000000") {
this.orgCourseInfo = res.data;
this.formData.courseCustomDoctorModels[0] = this.orgCourseInfo.defaultDoctor;
this.formData.courseCustomDoctorModels[0].courseDoctorAvatarUrl =
this.orgCourseInfo.defaultDoctor.courseDoctorAvatarUrl ||
"https://test1-file.yunqueyi.com/image/png/common/2020062015265063.png";
this.doctorNameList = this.convertDNameToSelectOpt(
this.orgCourseInfo.doctorModelList
);
+this.courseId && this.getCourseInfoById(this.courseId);
}
}
);
},
// 将医生名称进行处理
convertDNameToSelectOpt(doctorModelList) {
doctorModelList.forEach(item => {
item.show = true;
item.seleted = false;
});
return doctorModelList;
},
// 初始化课程信息
initModify() {
this.needShowAuditMsg = true;
this.initOrgCourseInfo();
},
// 创建课程页面的初始信息
getCourseInfoById(courseId) {
vm.GET(`contents/course/custom/info/${courseId}`)
.then( res => {
if ( res.code == "000000") {
this.formData = res.data;
}
}
);
},
// 过滤医生信息
filterDoctorName(value) {
this.doctorNameList.forEach(item => {
if (value) {
if ((item.value + "").indexOf(value) == -1) {
item.show = false;
} else {
item.show = true;
}
if (item.value == value) {
item.seleted = true;
} else {
item.seleted = false;
}
} else {
item.show = true;
}
});
},
// 当选择医生的焦点失去时,要反选医生信息
doctorNameInputBlur() {
setTimeout(() => {
this.isShowDoctorList = false;
this.selectDoctorByName(
this.formData.courseCustomDoctorModels[0].courseDoctorName
);
}, 200);
},
// 根据姓名反选医生信息
// TODO 尝试找到完全匹配的医生
selectDoctorByName(name) {
},
// 选择其中一个
selectDoctor(name) {
console.log(name);
this.formData.courseCustomDoctorModels[0].courseDoctorName = name;
this.selectDoctorByName(name);
},
// 获取学科列表
getLabelList() {
let req = {};
this.GET("aggregate/content/labelList", req).then(res => {
if (res.code == "000000") {
this.convertLabelList(res.data);
}
});
},
// 将所有子分类中的“全部”去掉
convertLabelList(labelList) {
let newLabelList = [];
labelList.forEach(item => {
item.subList = item.subList.slice(1);
});
this.labelOptions = labelList;
},
// 查找是否有拒绝原因
hasAuditMsg(cData) {
let flag = false;
if(cData.courseNameCheck
|| cData.courseIntroCheck
|| cData.courseIntroImageCheck
|| cData.courseCustomDoctorModels[0].courseDoctorNameCheck
|| cData.courseCustomDoctorModels[0].courseDoctorAvatarUrlCheck
|| cData.courseCustomDoctorModels[0].courseDoctorHospitalCheck
) {
flag = true;
}
if(!flag) {
let lectureList = cData.courseCustomChapterModels[0].courseCustomLectureModelList;
for(let i = 0; i < lectureList.length; i ++) {
if(lectureList[i].nameCheck) {
flag = true;
break;
}
}
}
return flag;
},
// 添加或修改课程(kind = 3)
passOrRefuse(checkStatus) {
// checkStatus 1:拒绝的话,要有理由;2:通过的话,没有拒绝理由
// TODO 判断
this.currentCheckStatus = checkStatus;
let flag = this.hasAuditMsg(this.formData);
console.log('passOrRefuse', flag);
// 点击拒绝按钮
if(checkStatus == 1) {
if(flag) { // 有拒绝原因
vm.statusObj.confirmRefuse.message = `确定“${this.createdDoctorName}”提交的「${this.formData.courseName}」课程审核为拒绝`,
vm.dialogObj = Object.assign(
vm.dialogObj,
vm.statusObj.confirmRefuse
);
} else {
vm.dialogObj = Object.assign(
vm.dialogObj,
vm.statusObj.refuseReasen
);
}
// 点击通过按钮
} else {
if(flag) { // 有拒绝原因
vm.dialogObj = Object.assign(
vm.dialogObj,
vm.statusObj.refuse
);
} else {
vm.dialogObj = Object.assign(
vm.dialogObj,
vm.statusObj.pass
);
}
}
vm.dialogObj.visible = true;
},
passOrRefuseAction(){
this.formData.checkStatus = this.currentCheckStatus;
this.POST("contents/course/custom/check/v1/check", this.formData).then(res => {
if (res.code == "000000") {
this.backToListPage();
}
this.dialogObj.visible = false;
});
},
// 关闭(“取消”按钮弹出来的)弹框
hideCancleTips() {
this.dialogObj.visible = false;
},
// 预览视频
previewVideoAction(lecture) {
this.videoUrl = lecture.resourceModel.filePath;
this.isPreviewVideo = true;
},
// 对特定字段进行修改
auditField(modifiedOrg, fieldName) {
this.currentModifiedOrg = modifiedOrg;
this.currentFieldName = fieldName;
this.auditVisible = true;
},
// 对特定字段进行重置
cancleAudit(modifiedOrg, fieldName) {
modifiedOrg[fieldName] = '';
},
// 获取到审核结果
checkInfo(info) {
this.currentModifiedOrg[this.currentFieldName] = info;
console.log(info);
},
// 获取默认的拒绝原因列表
getRefuseList() {
this.GET("contents/course/custom/check/v1/refuse/list", {}).then(res => {
if (res.code == "000000") {
this.refuseReasonList = res.data || [];
}
});
},
}
};
</script>
<style scoped lang="scss">
.edit-course-wrapper {
.course-content {
// color: red;
padding-top: 30px;
.basic-item-icon {
position: relative;
margin-top: 20px;
.require {
position: absolute;
left: 40px;
top: 11px;
color: #f56c6c;
}
.upload-message {
position: absolute;
left: 160px;
top: 105px;
font-size: 12px;
color: #f56c6c;
}
.img-delete {
position: absolute;
left: 0px;
top: 0px;
width: 84px;
height: 100px;
background: #000;
opacity: 0.7;
z-index: 999;
i {
color: #fff;
margin-top: 39px;
margin-left: 0px;
}
}
.upload-tips {
width: 100%;
position: relative;
top: -10px;
font-size: 12px;
color: #979899;
// display: inline-block;
}
.custom-list {
// width: 100%;
width: 800px;
display: flex;
flex-direction: column;
// border-radius: 3px;
// border: 1px solid rgba(228,231,237,1);
padding: 20px;
padding-top: 0px;
font-size: 12px;
color: #606266;
& > li {
margin: 10px 0;
}
.video {
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
.video-wapper {
height: 28px;
line-height: 28px;
.title {
display: inline-block;
width: 70px;
text-align: right;
margin-right: 10px;
}
.name {
cursor: pointer;
color: #5890DD;
}
img {
width: 12px;
height: 12px;
}
}
// .delete {
// position: relative;
// top: 4px;
// cursor: pointer;
// width: 16px;
// height: 16px;
// }
}
.video-name {
.title {
display: inline-block;
width: 70px;
text-align: right;
margin-right: 10px;
}
}
}
}
.word-num {
font-size: 12px;
color: #999;
padding-top: 5px;
}
.bg-uploader {
img {
float: left;
}
.bg-img-wrapper {
.bg-img {
display: block;
width: 160px;
height: 90px;
}
.bg-img-doctor {
display: block;
width: 88px;
height: 88px;
}
}
.bg-video {
float: left;
width: 84px;
height: 100px;
}
}
.limit-text {
position: absolute;
top: 86px;
left: 0px;
font-size: 12px;
color: #979899;
}
.separator-line {
width: 100%;
display: flex;
flex-direction: row;
align-content: center;
align-items: center;
justify-content: space-between;
.center {
cursor: pointer;
width: 130px;
color: #666666;
img {
width: 12px;
}
}
.line-left,
.line-right {
// display: inline-block;
// width: 100%;
flex: 1;
border-bottom: 1px dashed #e4e7ed;
}
}
.tips {
width: 500px;
height: 32px;
line-height: 32px;
margin-left: 38px;
padding-left: 12px;
background: rgba(254, 250, 245, 1);
border-radius: 3px;
color: #e6a23c;
}
.valid-msg {
position: relative;
.error {
width: 370px;
position: absolute;
display: flex;
justify-content: space-between;
top: 29px;
font-size: 13px;
color: #ed3131;
.text {
flex: 1;
}
.cancle {
width: 20px;
margin-left: 20px;
cursor: pointer;
}
}
.error-area {
position: absolute;
bottom: -32px;
font-size: 13px;
color: #ed3131;
.cancle {
width: 20px;
margin-left: 20px;
cursor: pointer;
}
}
.error-video {
position: absolute;
top: 64px;
left: 82px;
font-size: 13px;
color: #ed3131;
.cancle {
width: 20px;
margin-left: 20px;
cursor: pointer;
}
}
.edit-wrapper {
cursor: pointer;
color: #449284;
.edit-img {
position: relative;
top: 2px;
width: 12px;
margin: 0 2px 0 4px;
}
}
.doctor-select-list {
width: 200px;
// max-height: 100px;
position: absolute;
z-index: 100;
background: #fff;
box-shadow: 0 0 6px rgba(0, 0, 0, 0.3);
-webkit-box-shadow: 0 0 6px rgba(0, 0, 0, 0.3);
// margin: 10px;
li {
padding-left: 20px;
cursor: pointer;
&:hover {
background: #f4f7fd;
}
&.doctor-selected {
background: #f4f7fd;
}
}
}
}
.upload-process {
margin: 10px 0 10px 10px;
display: block;
// width: 310px;
height: 4px;
background: #449284;
border-radius: 2px;
}
}
}
</style>
<style scoped lang="scss">
.review-access-wrap {
.review-access {
padding: 10px;
background: #fff;
}
.top-124 {
top: 124px !important;
}
}
</style>
\ No newline at end of file
...@@ -72,7 +72,7 @@ ...@@ -72,7 +72,7 @@
<div class="video-name"> <div class="video-name">
<span class="title"> <span class="title">
<span style="color: red;">*</span> <span style="color: red;">*</span>
<span class="video-title">视频名称</span> <span class="video-title">视频名称{{index + 1}}</span>
</span> </span>
<el-input <el-input
size="small" size="small"
...@@ -608,7 +608,7 @@ export default { ...@@ -608,7 +608,7 @@ export default {
if(!flag) { if(!flag) {
let lectureList = cData.courseCustomChapterModels[0].courseCustomLectureModelList; let lectureList = cData.courseCustomChapterModels[0].courseCustomLectureModelList;
for(let i = 0; i < lectureList.length; i ++) { for(let i = 0; i < lectureList.length; i ++) {
if(lectureList[i].nameCheck) { if(lectureList[i].nameCheck || lectureList[i].contentCheck) {
flag = true; flag = true;
break; break;
} }
...@@ -776,7 +776,7 @@ export default { ...@@ -776,7 +776,7 @@ export default {
margin-bottom: 10px; margin-bottom: 10px;
.title { .title {
display: inline-block; display: inline-block;
width: 70px; width: 80px;
text-align: right; text-align: right;
margin-right: 10px; margin-right: 10px;
} }
...@@ -801,7 +801,7 @@ export default { ...@@ -801,7 +801,7 @@ export default {
.video-name { .video-name {
.title { .title {
display: inline-block; display: inline-block;
width: 70px; width: 80px;
text-align: right; text-align: right;
margin-right: 10px; margin-right: 10px;
} }
......
<template>
<div class="edit-custom-wrap">
<bread-crumb
:curmbFirst="curmbFirst"
:curmbSecond="curmbSecond"
:curmbThird="curmbThird"
:jumPathThird="jumPathThird"
></bread-crumb>
<div class="add-content-new screenSet" id="screenSet">
<div class="step-content-new">
<el-col style="width: 530px;">
<el-steps :active="active" simple class>
<span class="step-num" v-bind:class="{ 'on-step': active==0 }">1</span>
<el-step title="选择项目课程">1</el-step>
<span class="step-num" v-bind:class="{ 'on-step': active==1 }">2</span>
<el-step title="填写项目信息">2</el-step>
<span class="step-num" v-bind:class="{ 'on-step': active==2 }">3</span>
<el-step title="选择学员范围">3</el-step>
</el-steps>
</el-col>
<div>
<div v-if="!canNext" class="dis-btn">下一步</div>
<el-button class="dis-btn-b" v-if="active != 0 && projectStatus == 1 && isPreview != 1" size="small" @click="save">暂存</el-button>
<el-button class="dis-btn-b" v-if="active !== 2 && canNext" size="small" type="primary" @click="nextStep">下一步</el-button>
<el-button class="dis-btn-b" v-if="active == 2" size="small" type="primary" @click="complete">完成</el-button>
</div>
</div>
<!-- 模板列表
<div v-if="active == 0" class="tpl-main">
<template-list @checkFn="checkFn"></template-list>
</div>-->
<!-- 选择课程 -->
<div v-if="active == 0" class="tpl-main">
<SelectCourseComp @showOrgCourse="showOrgCourse"></SelectCourseComp>
</div>
<!-- 填写项目信息-->
<!-- <template-message -->
<custom-baseinfo
ref="CustomBaseinfo"
v-if="active == 1"
:openTemplateId="openTemplateId"
:projectId="projectId"
:editor="editor"
@next="next"
@backSelectVue="backSelectVue"
@hideSave="hideSave"
@setStatus4Flag="setStatus4Flag"
/>
<!-- 设定行政范围与设定机构 -->
<div class="three-step" v-if="active === 2">
<el-tabs v-model="activeName" @tab-click="handleClickTabs">
<el-tab-pane label="设定行政范围" name="first">
<select-region ref="selectRegion" :projectId="projectId" :status4Flag="status4Flag"></select-region>
</el-tab-pane>
<el-tab-pane label="设定机构" name="second">
<set-organization
ref="setOrganization"
:projectId="projectId"
:status4Flag="status4Flag"
></set-organization>
</el-tab-pane>
</el-tabs>
</div>
</div>
<dialog-componet :dialogObj="dialogObj" @hide="hide"></dialog-componet>
<dialog-componet :dialogObj="sendObj" @hide="hidefn" @confirm="confirmFn"></dialog-componet>
<PreviewEditCourse
:dialogVisible="isPreviewEditCourse"
:addOrUpdate="addOrUpdate"
@close="closeEditCourse"
/>
<PreviewProtocol
:dialogVisible="isPreviewProtocol"
:protocolId="protocolId"
:protocolContent="protocolContent"
@close="closeProtocol"
/>
</div>
</template>
<script>
import BreadCrumb from "@/components/breadcrumb.vue";
// import CustomBaseinfo from "@/components/education/template/CustomBaseinfo";
import CustomBaseinfo from "@/components/education/custom/custom-baseinfo";
import selectTemplate from "@/components/education/template/selectTemplate";
import selectRegion from "@/components/education/template/selectRegion";
import setOrganization from "@/components/education/template/setOrganization";
import SelectCourseComp from "@/components/education/custom/select-course-comp";
import dialog from "@/components/education/template/dialog";
import PreviewEditCourse from "@/components/education/custom-resource/edit-course-dialog";
import PreviewProtocol from "@/components/education/custom-resource/preview-protocol";
import { openLoading, closeLoading, resizeHeight } from "@/utils/utils";
import { mapGetters, mapActions } from "vuex";
let vm = null;
export default {
data() {
return {
curmbFirst: "教培项目",
curmbSecond: "项目管理",
jumPathThird: "item-manager",
curmbThird: "发起项目",
active: 0,
formTemplate: {
component: [],
configure: 2,
certificate: ""
},
activeName: "first",
canNext: false,
openTemplateId: 0, // 开放模板ID
projectId: "", // 项目id
status: 10, // 0正常10没有加入机构11审核中12审核失败20存在进行中项目21数量已达上限
editor: false, // 是否为编辑状态
dialogObj: {
visible: false,
title: "",
message: "",
tip: "",
hideMsg: ""
},
statusObj: {
status_10: {
title: "您暂未加入机构",
message: "请前往云鹊医APP-个人中心-我的资料-填写工作所属机构。加入机构后,可创建项目",
tip: "",
hideMsg: "我知道了"
},
status_11: {
title: "您创建的机构正在审核中",
message: "请前往云鹊医APP-个人中心-我的资料-填写工作所属机构。加入机构后,可创建项目",
tip: "",
hideMsg: "我知道了"
},
status_12: {
title: "您创建的机构审核不通过",
message: "请前往云鹊医APP-个人中心-我的资料-填写工作所属机构。加入机构后,可创建项目",
tip: "",
hideMsg: "我知道了"
},
status_20: {
title: "该项目正在进行中",
message: "不能重复创建,请选择其他模版或者下架正在进行中的项目",
hideMsg: "确定"
},
status_21: {
title: "自定义项目创建数量已达上限",
message: "本年度免费创建自定义项目数已达20次,不能继续创建",
hideMsg: "确定"
}
},
sendObj: {
// 发布
visible: false,
title: "确定发布吗?",
message:
"发布后,项目将进入审核中,待审核完成后学员可在云鹊医App上参加培训学习",
tip: "",
confirmMsg: "取消",
hideMsg: "确定发布"
},
projectStatus: 1, //1.草稿 2.未上架 3.审核中/待审核 4.已上架 5.已下架 6.已拒绝/未上架
status4Flag: 0, //0表示没有上过架,1表示上过架
isPreview: 0, // 1表示是查看信息
maxLimitCreatedCustomProjectCountInYear: 20, // 同一个用户每年能够创建的项目数
allSubList: [],
isPreviewEditCourse: false,
addOrUpdate: 'add',
isPreviewProtocol: false,
protocolId: 22,
protocolContent: '',
};
},
computed: {
...mapGetters(["searchParam", "searchParamOrg", "cartList", "kind"])
},
watch: {
kind(newKind) {
let searchParam = newKind == 0 ? this.searchParam : this.searchParamOrg;
this.getCourseList(searchParam);
},
searchParam: {
handler(val) {
this.getCourseList(val);
},
deep: true
},
searchParamOrg: {
handler(val) {
this.getCourseList(val);
},
deep: true
},
cartList(val) {
this.canNext = val.length > 0;
}
},
components: {
BreadCrumb,
CustomBaseinfo,
selectTemplate,
selectRegion,
setOrganization,
dialogComponet: dialog,
SelectCourseComp,
PreviewEditCourse,
PreviewProtocol
},
created() {
vm = this;
vm.isEditorFn();
vm.isPreviewFn();
},
mounted() {
resizeHeight();
this.getLabelList();
this.initPageParams();
// this.initPageParams();
},
methods: {
...mapActions([
"setSearchParam",
"setSearchParamOrg",
"setCartList",
"setCourseList",
"setAllLabelList",
"setSubLabelList",
"setAllLabelListOrg",
"setSubLabelListOrg",
"setCourseLimitCount",
]),
initPageParams(labelIdList) {
// let searchParam = {
// kind: 0,
// orderBy: 2,
// dir: 1,
// grade: 0,
// pageNo: 1,
// pageSize: 10,
// labelIdList: labelIdList || []
// };
this.setCartList([]);
this.setCourseList([]);
this.setAllLabelList([]);
this.setSubLabelList([]);
this.courseLimitCount();
// this.getLabelList();
// this.getCourseList(searchParam);
},
// 自定义项目--选择课程个数限制(-1表示不限制)
courseLimitCount() {
vm.GET("portal/portalCustom/courseLimitCount", {}).then(res => {
if (res.code == "000000") {
this.setCourseLimitCount(res.data);
}
});
},
// 获取所有标签(一级及二级),交做相应处理
// TODO
getLabelList() {
vm.GET("contents/diseases/labelList", {}).then(res => {
if (res.code == "000000") {
// 先将所有的标签添加checked字段
let labelList = res.data;
// let labelListOrg = res.data;
let allSubList = [];
let allSubListOrg = [];
let labelIdList = [];
let labelIdListOrg = [];
labelList.forEach((item, index) => {
item.checked = false;
item.subList.forEach((sub, subIndex) => {
sub.parentIndex = index;
sub.checked = true;
if (subIndex == 0) {
sub.id = `subid-${index}`; // 将二级中的“全部”id改为可以识别的
} else {
allSubList.push(sub);
labelIdList.push(sub.id);
}
});
});
// 构建其子标签
allSubList.unshift({
name: "全部",
checked: true,
id: 'parentid-0'
});
// 添加一级的“全部”标签,并构建其子标签
labelList.unshift({
name: "全部",
checked: true,
subList: allSubList
});
this.setAllLabelList(labelList);
this.setSubLabelList(allSubList);
this.setAllLabelListOrg(JSON.parse(JSON.stringify(labelList)));
this.setSubLabelListOrg(JSON.parse(JSON.stringify(allSubList)));
let searchParam = {
kind: 0,
orderBy: 2,
dir: 1,
grade: 0,
pageNo: 1,
pageSize: 10,
labelIdList: labelIdList || []
};
this.setSearchParam(Object.assign({}, searchParam));
searchParam.kind = 1;
this.setSearchParamOrg(Object.assign({}, searchParam));
}
});
},
// (根据条件)查询课程
getCourseList(searchParam) {
vm.GET("contents/diseases/courseListForPortal", searchParam).then(res => {
if (res.code == "000000") {
let courseList = res.data, cartIndex = -1;
courseList.list.forEach(item => {
cartIndex = vm.cartList.findIndex( current => {
return current.courseId == item.courseId;
})
if(cartIndex >= 0) {
item.checked = true;
} else {
item.checked = false;
}
});
this.setCourseList(courseList);
}
});
},
// 判断是否为编辑状态
isEditorFn() {
if (vm.$route.query.projectId) {
vm.projectId = vm.$route.query.projectId;
vm.editor = true;
vm.active = 1;
vm.canNext = true;
}
},
// 判断是否为预览状态
isPreviewFn() {
if (vm.$route.query.isPreview == 1 && vm.$route.query.projectId) {
vm.projectId = vm.$route.query.projectId;
vm.isPreview = vm.$route.query.isPreview;
vm.active = 1;
vm.canNext = true;
}
},
// 按钮点击下一步
nextStep() {
if (vm.active == 0) {
vm.checkSelectCustomCourse();
// vm.checkSelectTemplate()
return;
}
if (vm.active == 1) {
// 查看时,点击下一步直接跳
if (vm.isPreview == 1) {
vm.active = 2;
return;
}
// 调用项目信息中的下一步操作
vm.$refs.CustomBaseinfo.nextStep();
return;
}
},
// 填写项目信息组件的下一步回调(获取项目id)
next(id) {
vm.projectId = id;
vm.active = 2;
},
// 暂存
save() {
if (vm.active == 1) {
vm.$refs.CustomBaseinfo.save(false);
} else if (vm.active == 2) {
vm.regionComplete();
}
},
confirmFn() {
vm.sendObj.visible = false;
},
// 完成
complete() {
// 4不弹框
if (vm.projectStatus != 4 && vm.isPreview != 1) {
vm.sendObj.visible = true;
} else {
// 查看时,点击完成直接跳到列表页
if (vm.isPreview == 1) {
let query = {};
if (vm.$route.query.pageNum) {
query = { pageNum: vm.$route.query.pageNum };
}
vm.$router.push({ path: "item-manager", query: query });
return;
}
vm.hidefn();
}
},
// 完成触发的接口
hidefn() {
vm.regionComplete(vm.changeStatus);
},
// 选择学元范围暂存
regionComplete(fishFn) {
let req = {
projectId: vm.projectId,
scopeOfAdministrative: vm.$refs.selectRegion.setScope(),
scopeOfDepartment: 99999999,
flag: fishFn ? 3 : 1 //0:下一步 1:暂存
};
openLoading(vm);
vm.POST("portal/new/scope", req)
.then(res => {
closeLoading(vm);
if (res.code == "000000" && fishFn) {
fishFn();
}
if (!fishFn) {
vm.$message({
type: "info",
message: res.message
});
}
})
.catch(() => {
vm.$message({
type: "warning",
message: res.message
});
});
},
// 完成后更改状态
changeStatus() {
let req = {
projectId: vm.projectId,
changeStatus: 3 //待审核
};
vm.POST("portal/portalInfo/changeStatus", req)
.then(res => {
vm.sendObj.visible = false;
if (res.code == "000000") {
let query = {};
if (vm.$route.query.pageNum) {
query = { pageNum: vm.$route.query.pageNum };
}
console.log("vm.$router.push");
vm.$router.push({ path: "item-manager", query: query });
} else {
vm.$message({
type: "warning",
message: res.message
});
}
})
.catch(() => {
vm.$message({
type: "warning",
message: res.message
});
});
},
//切换tabs
handleClickTabs(tab, event) {
if (tab.name == "second") {
vm.setRegion();
}
},
// 模板列表选中
checkFn(id) {
vm.canNext = true;
vm.openTemplateId = id;
},
//选中自定义课程后点击下一步时检测(机构和进行中的项目)
checkSelectCustomCourse() {
openLoading(vm);
vm.GET(`portal/portalCustom/checkBeforeCreateCustomProject`)
.then(res => {
closeLoading(vm);
if (res.code == "000000") {
if (res.data.status == 0) {
vm.maxLimitCreatedCustomProjectCountInYear =
res.data.maxLimitCreatedCustomProjectCountInYear;
vm.active = 1;
return;
} else {
if(res.data.status == 21) {
vm.statusObj.status_21.message = `本年度免费创建自定义项目数已达${res.data.maxLimitCreatedCustomProjectCountInYear}次,不能继续创建`;
}
vm.dialogObj = Object.assign(vm.dialogObj, vm.statusObj[`status_${res.data.status}`]);
vm.dialogObj.visible = true;
return;
}
} else {
vm.$message.info(res.message);
}
})
.catch(err => {
closeLoading(vm);
vm.$message.warning("请稍后重试");
});
},
//选中模板后点击下一步时检测(机构和进行中的项目)
checkSelectTemplate() {
openLoading(vm);
vm.GET(
`portal/openTemplateProject/checkAfterSelectOneOpenTemplate/${vm.openTemplateId}`
)
.then(res => {
closeLoading(vm);
if (res.code == "000000") {
if (res.data.status == 0) {
vm.active = 1;
return;
} else {
vm.dialogObj = Object.assign(
vm.dialogObj,
vm.statusObj[`status_${res.data.status}`]
);
vm.dialogObj.visible = true;
return;
}
} else {
vm.$message.info(res.message);
}
})
.catch(err => {
closeLoading(vm);
vm.$message.warning("请稍后重试");
});
},
// 隐藏弹框
hide() {
vm.dialogObj.visible = false;
},
// 获取行政范围
setRegion() {
vm.getOrganizationList(vm.$refs.selectRegion.getScope());
},
// 查询行政范围的设定机构列表
getOrganizationList(r) {
vm.$refs.setOrganization.init();
vm.$refs.setOrganization.getOrganization(r);
},
// 返回选择模板页
backSelectVue() {
vm.active = 0;
},
// 是否隐藏暂存按钮
hideSave(num) {
this.projectStatus = num;
},
// 从子组件(项目信息)获取项目状态是否为上架
setStatus4Flag(s) {
vm.status4Flag = s;
},
/*
展示添加机构课程弹框
如果已经加入机构,1:没有同意过协议,则打开协议弹框;2:已经加入,时直接打开添加弹框
如果没有加入机构,则直接弹出提示(我知道了)
*/
showOrgCourse(addOrUpdate) {
// this.checkProtocol();
this.checkHospital();
this.addOrUpdate = addOrUpdate
},
// 创建机构课程前校验机构
// TODO 各个状态与数据结构
checkHospital() {
openLoading(vm);
let req = {
setEntry: true
}
vm.GET(`portal/portalCustom/checkHospital`, req)
.then(res => {
closeLoading(vm);
if (res.code == "000000") {
console.log(res);
if (res.data == 0) {
this.checkProtocol();
} else {
vm.dialogObj = Object.assign(
vm.dialogObj,
vm.statusObj[`status_${res.data}`]
);
vm.dialogObj.visible = true;
}
} else {
vm.$message.info(res.message);
}
})
.catch(err => {
closeLoading(vm);
vm.$message.warning("请稍后重试");
});
},
// 判断用户是否签署了最新版协议
// 如果没有签署,则打开协议签署弹框
checkProtocol() {
// openLoading(vm);
let req = {
setEntry: true,
type: this.protocolId
}
vm.GET(`smartcontract/protocol/sign/check`, req)
.then(res => {
// closeLoading(vm);
if (res.code == "000000") {
if(!res.data) { // 没有签署,打开协议签署弹框
this.getProtocolInfoById();
} else {
this.isPreviewEditCourse = true;
}
} else {
vm.$message.info(res.message);
}
})
.catch(err => {
closeLoading(vm);
vm.$message.warning("请稍后重试");
});
},
// 根据协议获取内容
getProtocolInfoById() {
let req = {
type: this.protocolId
};
// this.GET("smartcontract/protocolManage/protocol", req).then(res => {
this.GET("smartcontract/protocol/content", req).then(res => {
if (res.code == "000000") {
// this.protocolContent = res.data.contents;
this.protocolContent = res.data;
this.isPreviewProtocol = true;
} else {
vm.$message.info(res.message);
}
}).catch(err => {
vm.$message.warning("请稍后重试");
});
},
// 关闭编辑课程弹框
closeEditCourse() {
this.isPreviewEditCourse = false;
},
// 关闭预览协议弹框
closeProtocol(needShowAdd) {
if( needShowAdd ) {
this.isPreviewEditCourse = true;
}
this.isPreviewProtocol = false;
},
}
}
</script>
<style lang="scss">
.edit-custom-wrap {
::-webkit-scrollbar {
width: 10px;
height: 10px;
background-color: #fff;
}
/*定义滚动条轨道 内阴影+圆角*/
::-webkit-scrollbar-track {
// box-shadow: inset 0 0 3px rgba(0,0,0,0.3);
// -webkit-box-shadow: inset 0 0 3px rgba(0,0,0,0.3);
border-radius: 10px;
background-color: #fff;
}
/*定义滑块 内阴影+圆角*/
::-webkit-scrollbar-thumb {
border-radius: 6px;
// box-shadow: inset 0 0 3px rgba(0,0,0,.3);
// -webkit-box-shadow: inset 0 0 3px rgba(0,0,0,.3);
background-color: #C7C8C9;
}
.el-step.is-simple:not(:last-of-type) .el-step__title {
max-width: 100%;
}
.top-lin {
position: fixed;
height: 30px;
background: #f0f2f5;
right: 30px;
left: 285px;
z-index: 1001;
top: 125px;
}
.step-content-new {
min-width: 1125px;
display: flex;
justify-content: space-between;
align-items: center;
// min-width: 1300px;
background: #fff;
background: #fff;
overflow: hidden;
height: 54px;
// line-height: 54px;
// padding: 15px 0 50px 0;
padding: 0 30px;
border-bottom: 1px solid #efefef;
background: #fff;
.is-text {
display: none;
}
.el-steps--simple {
background: #fff;
padding: 13px 0;
align-items: center;
}
.button-green {
color: #ffffff;
background: #449284;
border-color: #bfdad5;
border-radius: 2px;
}
.button-white {
color: #606266;
background: #ffffff;
border-color: #ecedf1;
border-radius: 2px;
}
.step-num {
display: block;
font-size: 12px;
border: 1px solid #999 !important;
border-radius: 50%;
width: 25px;
height: 18px;
line-height: 16px;
text-align: center;
color: #999;
}
.el-step__title.is-wait {
color: #999;
}
.el-step__title.is-process {
color: #449284;
}
.is-finish {
color: #999 !important;
}
.on-step {
color: #449284;
border: 1px solid #449284 !important;
}
.dis-btn {
width: 78px;
height: 34px;
background: rgba(240, 242, 245, 1);
border-radius: 3px;
font-size: 14px;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: rgba(144, 147, 153, 1);
line-height: 34px;
text-align: center;
cursor: pointer;
}
.dis-btn-b {
position: relative;
left: 5px;
// bottom: 10px;
}
}
.add-content-new {
background: #fff;
}
.three-step {
padding-top: 64px;
margin: 10px 0 0 20px;
.area-p {
margin-bottom: 15px;
font-size: 14px;
}
.span_ecology {
line-height: 45px;
margin-left: 8px;
}
.dialog-p {
text-align: center;
span {
color: #449284;
}
}
//隐藏树展开
.table-empty {
img {
width: 100px;
}
p {
margin-top: -50px;
}
}
.el-tree-node__expand-icon {
display: none;
}
.department {
margin-top: 20px;
border: 1px solid #dddddd;
}
.el-tabs__nav-wrap::after {
display: none;
}
.el-tabs__active-bar {
display: none;
}
#tab-first,
#tab-second,
#tab-third {
padding-right: 0px;
}
#tab-first::after {
color: #c7cbd2;
margin-left: 20px;
content: "•";
}
.el-tabs__item.is-active {
color: #fff;
}
.el-tag {
margin: 0 10px 10px 0;
border: 1.3px solid #48a8fe;
color: #1e92fe;
background-color: #e7f6fe;
.el-icon-close {
width: 13px;
height: 13px;
line-height: 13px;
font-size: 12px;
background-color: #0486fe;
border-radius: 50%;
color: #d4edfe;
}
}
.down-button {
margin-left: 10px;
}
.down-button-close {
margin-left: 100px;
float: left;
}
.dialog-success {
p {
text-align: center;
.upload-text {
color: #449284;
}
}
}
.dialog-fail {
.fail-type {
p {
margin-top: 10px;
}
.fail-num {
color: #db3f52;
}
.fail-notice {
color: #e3e3e3;
font-size: 13px;
}
.fail-link {
text-align: center;
color: #449284;
cursor: pointer;
}
}
}
}
.tpl-main {
// padding-top: 64px;
}
}
</style>
<template>
<div class="edit-custom-wrap">
<bread-crumb
:curmbFirst="curmbFirst"
:curmbSecond="curmbSecond"
:curmbThird="curmbThird"
:jumPathThird="jumPathThird"
></bread-crumb>
<div class="add-content-new screenSet" id="screenSet">
<div class="step-content-new">
<el-col style="width: 530px;">
<el-steps :active="active" simple class>
<span class="step-num" v-bind:class="{ 'on-step': active==0 }">1</span>
<el-step title="选择项目课程">1</el-step>
<span class="step-num" v-bind:class="{ 'on-step': active==1 }">2</span>
<el-step title="填写项目信息">2</el-step>
<span class="step-num" v-bind:class="{ 'on-step': active==2 }">3</span>
<el-step title="选择学员范围">3</el-step>
</el-steps>
</el-col>
<div>
<div v-if="!canNext" class="dis-btn">下一步</div>
<el-button class="dis-btn-b" v-if="active != 0 && projectStatus == 1 && isPreview != 1" size="small" @click="save">暂存</el-button>
<el-button class="dis-btn-b" v-if="active !== 2 && canNext" size="small" type="primary" @click="nextStep">下一步</el-button>
<el-button class="dis-btn-b" v-if="active == 2" size="small" type="primary" @click="complete">完成</el-button>
</div>
</div>
<!-- 模板列表
<div v-if="active == 0" class="tpl-main">
<template-list @checkFn="checkFn"></template-list>
</div>-->
<!-- 选择课程 -->
<div v-if="active == 0" class="tpl-main">
<SelectCourseComp @showOrgCourse="showOrgCourse"></SelectCourseComp>
</div>
<!-- 填写项目信息-->
<!-- <template-message -->
<custom-baseinfo
ref="CustomBaseinfo"
v-if="active == 1"
:openTemplateId="openTemplateId"
:projectId="projectId"
:editor="editor"
@next="next"
@backSelectVue="backSelectVue"
@hideSave="hideSave"
@setStatus4Flag="setStatus4Flag"
/>
<!-- 设定行政范围与设定机构 -->
<div class="three-step" v-if="active === 2">
<el-tabs v-model="activeName" @tab-click="handleClickTabs">
<el-tab-pane label="设定行政范围" name="first">
<select-region ref="selectRegion" :projectId="projectId" :status4Flag="status4Flag"></select-region>
</el-tab-pane>
<el-tab-pane label="设定机构" name="second">
<set-organization
ref="setOrganization"
:projectId="projectId"
:status4Flag="status4Flag"
></set-organization>
</el-tab-pane>
</el-tabs>
</div>
</div>
<dialog-componet :dialogObj="dialogObj" @hide="hide"></dialog-componet>
<dialog-componet :dialogObj="sendObj" @hide="hidefn" @confirm="confirmFn"></dialog-componet>
<PreviewEditCourse
:dialogVisible="isPreviewEditCourse"
:addOrUpdate="addOrUpdate"
@close="closeEditCourse"
/>
<PreviewProtocol
:dialogVisible="isPreviewProtocol"
:protocolId="protocolId"
:protocolContent="protocolContent"
@close="closeProtocol"
/>
</div>
</template>
<script>
import BreadCrumb from "@/components/breadcrumb.vue";
// import CustomBaseinfo from "@/components/education/template/CustomBaseinfo";
import CustomBaseinfo from "@/components/education/custom/custom-baseinfo";
import selectTemplate from "@/components/education/template/selectTemplate";
import selectRegion from "@/components/education/template/selectRegion";
import setOrganization from "@/components/education/template/setOrganization";
import SelectCourseComp from "@/components/education/custom/select-course-comp";
import dialog from "@/components/education/template/dialog";
import PreviewEditCourse from "@/components/education/custom-resource/edit-course-dialog";
import PreviewProtocol from "@/components/education/custom-resource/preview-protocol";
import { openLoading, closeLoading, resizeHeight } from "@/utils/utils";
import { mapGetters, mapActions } from "vuex";
let vm = null;
export default {
data() {
return {
curmbFirst: "教培项目",
curmbSecond: "项目管理",
jumPathThird: "item-manager",
curmbThird: "发起项目",
active: 0,
formTemplate: {
component: [],
configure: 2,
certificate: ""
},
activeName: "first",
canNext: false,
openTemplateId: 0, // 开放模板ID
projectId: "", // 项目id
status: 10, // 0正常10没有加入机构11审核中12审核失败20存在进行中项目21数量已达上限
editor: false, // 是否为编辑状态
dialogObj: {
visible: false,
title: "",
message: "",
tip: "",
hideMsg: ""
},
statusObj: {
status_10: {
title: "您暂未加入机构",
message: "请前往云鹊医APP-个人中心-我的资料-填写工作所属机构。加入机构后,可创建项目",
tip: "",
hideMsg: "我知道了"
},
status_11: {
title: "您创建的机构正在审核中",
message: "请前往云鹊医APP-个人中心-我的资料-填写工作所属机构。加入机构后,可创建项目",
tip: "",
hideMsg: "我知道了"
},
status_12: {
title: "您创建的机构审核不通过",
message: "请前往云鹊医APP-个人中心-我的资料-填写工作所属机构。加入机构后,可创建项目",
tip: "",
hideMsg: "我知道了"
},
status_20: {
title: "该项目正在进行中",
message: "不能重复创建,请选择其他模版或者下架正在进行中的项目",
hideMsg: "确定"
},
status_21: {
title: "自定义项目创建数量已达上限",
message: "本年度免费创建自定义项目数已达20次,不能继续创建",
hideMsg: "确定"
}
},
sendObj: {
// 发布
visible: false,
title: "确定发布吗?",
message:
"发布后,项目将进入审核中,待审核完成后学员可在云鹊医App上参加培训学习",
tip: "",
confirmMsg: "取消",
hideMsg: "确定发布"
},
projectStatus: 1, //1.草稿 2.未上架 3.审核中/待审核 4.已上架 5.已下架 6.已拒绝/未上架
status4Flag: 0, //0表示没有上过架,1表示上过架
isPreview: 0, // 1表示是查看信息
maxLimitCreatedCustomProjectCountInYear: 20, // 同一个用户每年能够创建的项目数
allSubList: [],
isPreviewEditCourse: false,
addOrUpdate: 'add',
isPreviewProtocol: false,
protocolId: 22,
protocolContent: '',
};
},
computed: {
...mapGetters(["searchParam", "searchParamOrg", "cartList", "kind"])
},
watch: {
kind(newKind) {
let searchParam = newKind == 0 ? this.searchParam : this.searchParamOrg;
this.getCourseList(searchParam);
},
searchParam: {
handler(val) {
this.getCourseList(val);
},
deep: true
},
searchParamOrg: {
handler(val) {
this.getCourseList(val);
},
deep: true
},
cartList(val) {
this.canNext = val.length > 0;
}
},
components: {
BreadCrumb,
CustomBaseinfo,
selectTemplate,
selectRegion,
setOrganization,
dialogComponet: dialog,
SelectCourseComp,
PreviewEditCourse,
PreviewProtocol
},
created() {
vm = this;
vm.isEditorFn();
vm.isPreviewFn();
},
mounted() {
resizeHeight();
this.getLabelList();
this.initPageParams();
// this.initPageParams();
},
methods: {
...mapActions([
"setSearchParam",
"setSearchParamOrg",
"setCartList",
"setCourseList",
"setAllLabelList",
"setSubLabelList",
"setAllLabelListOrg",
"setSubLabelListOrg",
"setCourseLimitCount",
]),
initPageParams(labelIdList) {
// let searchParam = {
// kind: 0,
// orderBy: 2,
// dir: 1,
// grade: 0,
// pageNo: 1,
// pageSize: 10,
// labelIdList: labelIdList || []
// };
this.setCartList([]);
this.setCourseList([]);
this.setAllLabelList([]);
this.setSubLabelList([]);
this.courseLimitCount();
// this.getLabelList();
// this.getCourseList(searchParam);
},
// 自定义项目--选择课程个数限制(-1表示不限制)
courseLimitCount() {
vm.GET("portal/portalCustom/courseLimitCount", {}).then(res => {
if (res.code == "000000") {
this.setCourseLimitCount(res.data);
}
});
},
// 获取所有标签(一级及二级),交做相应处理
// TODO
getLabelList() {
vm.GET("contents/diseases/labelList", {}).then(res => {
if (res.code == "000000") {
// 先将所有的标签添加checked字段
let labelList = res.data;
// let labelListOrg = res.data;
let allSubList = [];
let allSubListOrg = [];
let labelIdList = [];
let labelIdListOrg = [];
labelList.forEach((item, index) => {
item.checked = false;
item.subList.forEach((sub, subIndex) => {
sub.parentIndex = index;
sub.checked = true;
if (subIndex == 0) {
sub.id = `subid-${index}`; // 将二级中的“全部”id改为可以识别的
} else {
allSubList.push(sub);
labelIdList.push(sub.id);
}
});
});
// 构建其子标签
allSubList.unshift({
name: "全部",
checked: true,
id: 'parentid-0'
});
// 添加一级的“全部”标签,并构建其子标签
labelList.unshift({
name: "全部",
checked: true,
subList: allSubList
});
this.setAllLabelList(labelList);
this.setSubLabelList(allSubList);
this.setAllLabelListOrg(JSON.parse(JSON.stringify(labelList)));
this.setSubLabelListOrg(JSON.parse(JSON.stringify(allSubList)));
let searchParam = {
kind: 0,
orderBy: 2,
dir: 1,
grade: 0,
pageNo: 1,
pageSize: 10,
labelIdList: labelIdList || []
};
this.setSearchParam(Object.assign({}, searchParam));
searchParam.kind = 1;
this.setSearchParamOrg(Object.assign({}, searchParam));
}
});
},
// (根据条件)查询课程
getCourseList(searchParam) {
vm.GET("contents/diseases/courseListForPortal", searchParam).then(res => {
if (res.code == "000000") {
let courseList = res.data, cartIndex = -1;
courseList.list.forEach(item => {
cartIndex = vm.cartList.findIndex( current => {
return current.courseId == item.courseId;
})
if(cartIndex >= 0) {
item.checked = true;
} else {
item.checked = false;
}
});
this.setCourseList(courseList);
}
});
},
// 判断是否为编辑状态
isEditorFn() {
if (vm.$route.query.projectId) {
vm.projectId = vm.$route.query.projectId;
vm.editor = true;
vm.active = 1;
vm.canNext = true;
}
},
// 判断是否为预览状态
isPreviewFn() {
if (vm.$route.query.isPreview == 1 && vm.$route.query.projectId) {
vm.projectId = vm.$route.query.projectId;
vm.isPreview = vm.$route.query.isPreview;
vm.active = 1;
vm.canNext = true;
}
},
// 按钮点击下一步
nextStep() {
if (vm.active == 0) {
vm.checkSelectCustomCourse();
// vm.checkSelectTemplate()
return;
}
if (vm.active == 1) {
// 查看时,点击下一步直接跳
if (vm.isPreview == 1) {
vm.active = 2;
return;
}
// 调用项目信息中的下一步操作
vm.$refs.CustomBaseinfo.nextStep();
return;
}
},
// 填写项目信息组件的下一步回调(获取项目id)
next(id) {
vm.projectId = id;
vm.active = 2;
},
// 暂存
save() {
if (vm.active == 1) {
vm.$refs.CustomBaseinfo.save(false);
} else if (vm.active == 2) {
vm.regionComplete();
}
},
confirmFn() {
vm.sendObj.visible = false;
},
// 完成
complete() {
// 4不弹框
if (vm.projectStatus != 4 && vm.isPreview != 1) {
vm.sendObj.visible = true;
} else {
// 查看时,点击完成直接跳到列表页
if (vm.isPreview == 1) {
let query = {};
if (vm.$route.query.pageNum) {
query = { pageNum: vm.$route.query.pageNum };
}
vm.$router.push({ path: "item-manager", query: query });
return;
}
vm.hidefn();
}
},
// 完成触发的接口
hidefn() {
vm.regionComplete(vm.changeStatus);
},
// 选择学元范围暂存
regionComplete(fishFn) {
let req = {
projectId: vm.projectId,
scopeOfAdministrative: vm.$refs.selectRegion.setScope(),
scopeOfDepartment: 99999999,
flag: fishFn ? 3 : 1 //0:下一步 1:暂存
};
openLoading(vm);
vm.POST("portal/new/scope", req)
.then(res => {
closeLoading(vm);
if (res.code == "000000" && fishFn) {
fishFn();
}
if (!fishFn) {
vm.$message({
type: "info",
message: res.message
});
}
})
.catch(() => {
vm.$message({
type: "warning",
message: res.message
});
});
},
// 完成后更改状态
changeStatus() {
let req = {
projectId: vm.projectId,
changeStatus: 3 //待审核
};
vm.POST("portal/portalInfo/changeStatus", req)
.then(res => {
vm.sendObj.visible = false;
if (res.code == "000000") {
let query = {};
if (vm.$route.query.pageNum) {
query = { pageNum: vm.$route.query.pageNum };
}
console.log("vm.$router.push");
vm.$router.push({ path: "item-manager", query: query });
} else {
vm.$message({
type: "warning",
message: res.message
});
}
})
.catch(() => {
vm.$message({
type: "warning",
message: res.message
});
});
},
//切换tabs
handleClickTabs(tab, event) {
if (tab.name == "second") {
vm.setRegion();
}
},
// 模板列表选中
checkFn(id) {
vm.canNext = true;
vm.openTemplateId = id;
},
//选中自定义课程后点击下一步时检测(机构和进行中的项目)
checkSelectCustomCourse() {
openLoading(vm);
vm.GET(`portal/portalCustom/checkBeforeCreateCustomProject`)
.then(res => {
closeLoading(vm);
if (res.code == "000000") {
if (res.data.status == 0) {
vm.maxLimitCreatedCustomProjectCountInYear =
res.data.maxLimitCreatedCustomProjectCountInYear;
vm.active = 1;
return;
} else {
if(res.data.status == 21) {
vm.statusObj.status_21.message = `本年度免费创建自定义项目数已达${res.data.maxLimitCreatedCustomProjectCountInYear}次,不能继续创建`;
}
vm.dialogObj = Object.assign(vm.dialogObj, vm.statusObj[`status_${res.data.status}`]);
vm.dialogObj.visible = true;
return;
}
} else {
vm.$message.info(res.message);
}
})
.catch(err => {
closeLoading(vm);
vm.$message.warning("请稍后重试");
});
},
//选中模板后点击下一步时检测(机构和进行中的项目)
checkSelectTemplate() {
openLoading(vm);
vm.GET(
`portal/openTemplateProject/checkAfterSelectOneOpenTemplate/${vm.openTemplateId}`
)
.then(res => {
closeLoading(vm);
if (res.code == "000000") {
if (res.data.status == 0) {
vm.active = 1;
return;
} else {
vm.dialogObj = Object.assign(
vm.dialogObj,
vm.statusObj[`status_${res.data.status}`]
);
vm.dialogObj.visible = true;
return;
}
} else {
vm.$message.info(res.message);
}
})
.catch(err => {
closeLoading(vm);
vm.$message.warning("请稍后重试");
});
},
// 隐藏弹框
hide() {
vm.dialogObj.visible = false;
},
// 获取行政范围
setRegion() {
vm.getOrganizationList(vm.$refs.selectRegion.getScope());
},
// 查询行政范围的设定机构列表
getOrganizationList(r) {
vm.$refs.setOrganization.init();
vm.$refs.setOrganization.getOrganization(r);
},
// 返回选择模板页
backSelectVue() {
vm.active = 0;
},
// 是否隐藏暂存按钮
hideSave(num) {
this.projectStatus = num;
},
// 从子组件(项目信息)获取项目状态是否为上架
setStatus4Flag(s) {
vm.status4Flag = s;
},
/*
展示添加机构课程弹框
如果已经加入机构,1:没有同意过协议,则打开协议弹框;2:已经加入,时直接打开添加弹框
如果没有加入机构,则直接弹出提示(我知道了)
*/
showOrgCourse(addOrUpdate) {
// this.checkProtocol();
this.checkHospital();
this.addOrUpdate = addOrUpdate
},
// 创建机构课程前校验机构
// TODO 各个状态与数据结构
checkHospital() {
openLoading(vm);
let req = {
setEntry: true
}
vm.GET(`portal/portalCustom/checkHospital`, req)
.then(res => {
closeLoading(vm);
if (res.code == "000000") {
console.log(res);
if (res.data == 0) {
this.checkProtocol();
} else {
vm.dialogObj = Object.assign(
vm.dialogObj,
vm.statusObj[`status_${res.data}`]
);
vm.dialogObj.visible = true;
}
} else {
vm.$message.info(res.message);
}
})
.catch(err => {
closeLoading(vm);
vm.$message.warning("请稍后重试");
});
},
// 判断用户是否签署了最新版协议
// 如果没有签署,则打开协议签署弹框
checkProtocol() {
// openLoading(vm);
let req = {
setEntry: true,
type: this.protocolId
}
vm.GET(`smartcontract/protocol/sign/check`, req)
.then(res => {
// closeLoading(vm);
if (res.code == "000000") {
if(!res.data) { // 没有签署,打开协议签署弹框
this.getProtocolInfoById();
} else {
this.isPreviewEditCourse = true;
}
} else {
vm.$message.info(res.message);
}
})
.catch(err => {
closeLoading(vm);
vm.$message.warning("请稍后重试");
});
},
// 根据协议获取内容
getProtocolInfoById() {
let req = {
type: this.protocolId
};
// this.GET("smartcontract/protocolManage/protocol", req).then(res => {
this.GET("smartcontract/protocol/content", req).then(res => {
if (res.code == "000000") {
// this.protocolContent = res.data.contents;
this.protocolContent = res.data;
this.isPreviewProtocol = true;
} else {
vm.$message.info(res.message);
}
}).catch(err => {
vm.$message.warning("请稍后重试");
});
},
// 关闭编辑课程弹框
closeEditCourse() {
this.isPreviewEditCourse = false;
},
// 关闭预览协议弹框
closeProtocol(needShowAdd) {
if( needShowAdd ) {
this.isPreviewEditCourse = true;
}
this.isPreviewProtocol = false;
},
}
}
</script>
<style lang="scss">
.edit-custom-wrap {
::-webkit-scrollbar {
width: 10px;
height: 10px;
background-color: #fff;
}
/*定义滚动条轨道 内阴影+圆角*/
::-webkit-scrollbar-track {
// box-shadow: inset 0 0 3px rgba(0,0,0,0.3);
// -webkit-box-shadow: inset 0 0 3px rgba(0,0,0,0.3);
border-radius: 10px;
background-color: #fff;
}
/*定义滑块 内阴影+圆角*/
::-webkit-scrollbar-thumb {
border-radius: 6px;
// box-shadow: inset 0 0 3px rgba(0,0,0,.3);
// -webkit-box-shadow: inset 0 0 3px rgba(0,0,0,.3);
background-color: #C7C8C9;
}
.el-step.is-simple:not(:last-of-type) .el-step__title {
max-width: 100%;
}
.top-lin {
position: fixed;
height: 30px;
background: #f0f2f5;
right: 30px;
left: 285px;
z-index: 1001;
top: 125px;
}
.step-content-new {
min-width: 1125px;
display: flex;
justify-content: space-between;
align-items: center;
// min-width: 1300px;
background: #fff;
background: #fff;
overflow: hidden;
height: 54px;
// line-height: 54px;
// padding: 15px 0 50px 0;
padding: 0 30px;
border-bottom: 1px solid #efefef;
background: #fff;
.is-text {
display: none;
}
.el-steps--simple {
background: #fff;
padding: 13px 0;
align-items: center;
}
.button-green {
color: #ffffff;
background: #449284;
border-color: #bfdad5;
border-radius: 2px;
}
.button-white {
color: #606266;
background: #ffffff;
border-color: #ecedf1;
border-radius: 2px;
}
.step-num {
display: block;
font-size: 12px;
border: 1px solid #999 !important;
border-radius: 50%;
width: 25px;
height: 18px;
line-height: 16px;
text-align: center;
color: #999;
}
.el-step__title.is-wait {
color: #999;
}
.el-step__title.is-process {
color: #449284;
}
.is-finish {
color: #999 !important;
}
.on-step {
color: #449284;
border: 1px solid #449284 !important;
}
.dis-btn {
width: 78px;
height: 34px;
background: rgba(240, 242, 245, 1);
border-radius: 3px;
font-size: 14px;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: rgba(144, 147, 153, 1);
line-height: 34px;
text-align: center;
cursor: pointer;
}
.dis-btn-b {
position: relative;
left: 5px;
// bottom: 10px;
}
}
.add-content-new {
background: #fff;
}
.three-step {
padding-top: 64px;
margin: 10px 0 0 20px;
.area-p {
margin-bottom: 15px;
font-size: 14px;
}
.span_ecology {
line-height: 45px;
margin-left: 8px;
}
.dialog-p {
text-align: center;
span {
color: #449284;
}
}
//隐藏树展开
.table-empty {
img {
width: 100px;
}
p {
margin-top: -50px;
}
}
.el-tree-node__expand-icon {
display: none;
}
.department {
margin-top: 20px;
border: 1px solid #dddddd;
}
.el-tabs__nav-wrap::after {
display: none;
}
.el-tabs__active-bar {
display: none;
}
#tab-first,
#tab-second,
#tab-third {
padding-right: 0px;
}
#tab-first::after {
color: #c7cbd2;
margin-left: 20px;
content: "•";
}
.el-tabs__item.is-active {
color: #fff;
}
.el-tag {
margin: 0 10px 10px 0;
border: 1.3px solid #48a8fe;
color: #1e92fe;
background-color: #e7f6fe;
.el-icon-close {
width: 13px;
height: 13px;
line-height: 13px;
font-size: 12px;
background-color: #0486fe;
border-radius: 50%;
color: #d4edfe;
}
}
.down-button {
margin-left: 10px;
}
.down-button-close {
margin-left: 100px;
float: left;
}
.dialog-success {
p {
text-align: center;
.upload-text {
color: #449284;
}
}
}
.dialog-fail {
.fail-type {
p {
margin-top: 10px;
}
.fail-num {
color: #db3f52;
}
.fail-notice {
color: #e3e3e3;
font-size: 13px;
}
.fail-link {
text-align: center;
color: #449284;
cursor: pointer;
}
}
}
}
.tpl-main {
// padding-top: 64px;
}
}
</style>
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册