<template>
  <div class="edit-course-wrapper dialog-title-border">
    <el-dialog
      ref="testDialogRef"
      title="上传课程"
      :visible="dialogVisible"
      @close="close"
      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"
          :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 class="edit-wrapper">
                  <img class="edit-img" src="../../../assets/image/phrase3/icon-pz.png" />修改信息
                </span> -->
              </span>
              <div v-show="needShowAuditMsg && formData.courseNameCheck" class="error">
                <span>错误信息错误信息错误信息错误信息错误信息错误信息息</span>
                <span class="cancle">X</span>
              </div>
            </el-col>
          </el-form-item>

          <el-form-item label="学科分类：" prop="subjectIdList" 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>
            </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">
            <span class="require">*</span>
            <el-form-item label="课程视频：" prop="range">
              <el-upload
                class="upload-video"
                action="#"
                :before-upload="beforeUploadVideo"
                :limit="3"
                :on-exceed="handleExceed"
                :show-file-list="false"
              >
                <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">
                      <ul class="video">
                        <li>
                          <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>
                      </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>
                    </li>
                    <span v-show="needShowUploadProcess" class="upload-process" :style="{'width': (uploadProgress/100 * 340) + 'px'}"></span>
                  </ul>
                  <span v-if="!formData.courseCustomChapterModels[0].courseCustomLectureModelList.length" v-show="needShowUploadProcess" class="upload-process" :style="{'width': (uploadProgress/100 * 340) + 'px'}"></span>
                </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="#"
                  :show-file-list="false"
                  :before-upload="beforeUploadListPic"
                  :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，只支持jpeg格式</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-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>
              </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="#"
                  :show-file-list="false"
                  :before-upload="beforeUploadListPic"
                  :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，只支持jpeg格式</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>
              </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>
              </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" size="small" 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>
    <DialogComponet :dialogObj="dialogObj" @hide="hideCancleTips" @confirm="dialogObj.visible=false"></DialogComponet>
    <PreviewVideo :dialogVisible="isPreviewVideo" :videoUrl="videoUrl" @close="isPreviewVideo=false"></PreviewVideo>
    <!-- <button @click="previewVideoAction">test video</button> -->
  </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 { mapActions } from 'vuex';
let vm = null;
export default {
  data() {
    let checkCourseName = (rule, value, callback) => {
      // 如果有审核的信息，则直接报错
      if (!value && this.needCheckField) {
        callback(new Error("请输入课程名称"));
      } else {
        callback();
      }
    };
    return {
      step: 1,
      needCheckField: false,
      needShowAuditMsg: false,
      needShowUploadProcess: false,
      disabled: false,
      formDataBase: {
        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: []
      },
      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: " " },
          { validator: checkCourseName }
        ],
        subjectIdList: [
          { required: true, message: "请输入课程名称" }
        ],
        shareType: [
          { required: true, message: "请选择开放范围" }
        ]
      },
      labelOptions: [],
      isShowOtherContent: false,
      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: "发布后,项目将进入审核中,待审核完成后学员可在云鹊医App上参加培训学习",
        tip: "",
        confirmMsg: "取 消",
        hideMsg: "确 定"
      },
    };
  },
  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);
        }
      }
    },
  },
  components: {
    PreviewVideo,
    PreviewEditCourse,
    DialogComponet,
  },
  created() {
    vm = this;
    // this.initAdd();
  },
  mounted() {
    this.getLabelList();
  },
  methods: {
    ...mapActions(['setKind']),

    // 创建课程页面的初始信息
    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;
    },

    // 添加时初始化
    initAdd() {
      console.log("in initAdd");
      this.step = 1;
      this.needShowAuditMsg = false;
      this.initOrgCourseInfo();
    },

    initModify() {
      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.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);
    },

    // 关闭当前弹框
    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;
    },

    // 上传视频
    beforeUploadVideo(file) {
      let fileType = file.type;
      // mp3: audio/mpeg; mp4: video/mp4;
      console.log('fileType', file);
      let fileLimit = {
        size: 0.5,
      };
      // TODO 上传之前要有各种判断  个人最大5G 每个文件是2G  limitModel
      // if (!isJPG && !isPNG) {
      //   vm.$message.error("图片不符合规范，请根据规范上传图片");
      //   return;
      // }
      // if (!isLt2M) {
      //   vm.$message.error("图片不符合规范，请根据规范上传图片 ");
      //   return;
      // }
      // return;
      // openLoading(vm);
      this.needShowUploadProcess = true;
      doUpload(vm, file, getFilePath(file, null), "preview4", "progress1").
        then( path => {
        // closeLoading(vm);
        console.log('vm.uploadProgress', vm.uploadProgress);
        console.log(path);
        let uploadResourceParam = {
          formatType: path.ext,
          name: path.name,
          qCloudUrl : path.fullPath,
          size : path.size,
          fileType : 1,
          status : "success",
          uid : new Date().getTime()
        }
        this.needShowUploadProcess = false;
        this.uploadProgress = 0;
        this.insertResourceAction(uploadResourceParam);
        // vm.$message.success("上传成功");

      });
    },

    // 上传资源（视频）后，生存对应的节
    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: {}
          }
          lectureObj.resourceModel = res.data && res.data.resourceModelList[0];
          this.formData.courseCustomChapterModels[0].courseCustomLectureModelList.push(lectureObj);
        }
      });      
    },

    //上传列表图片
    beforeUploadListPic(file) {
      let fileLimit = {
        width: 230,
        height: 172,
        size: 0.5,
        sizeText: "500K",
        key: "attachmentUrl",
        more: "attachmentMore1",
        show: "uploadImgMessage"
      };
      vm.beforeAvatarUpload(file, fileLimit);
    },

    //上传图片校验
    beforeAvatarUpload(file, fileLimit) {
      console.log();
      const isJPG = file.type === "image/jpeg";
      const isPNG = file.type === "image/png";
      const isLt2M = file.size / 1024 / 1024 < fileLimit.size;
      console.log("isJPG", isJPG, "isPNG", isPNG, "isLt2M", isLt2M);
      // if (!isJPG && !isPNG) {
      //   vm.$message.error("图片不符合规范，请根据规范上传图片");
      //   return;
      // }
      // if (!isLt2M) {
      //   vm.$message.error("图片不符合规范，请根据规范上传图片 ");
      //   return;
      // }
      let _img = new FileReader();
      _img.readAsDataURL(file);
      _img.onload = function(theFile) {
        let image = new Image();
        image.src = theFile.target.result;
        image.onload = function() {
          let _vm = this;
          if (
            false
            // true ||
            // _vm.width != fileLimit.width ||
            // _vm.height != fileLimit.height
          ) {
            vm.$message.error("图片不符合规范，请根据规范上传图片");
          } else {
            openLoading(vm);
            doUpload(
              vm,
              file,
              getFilePath(file, null),
              "preview4",
              "progress1"
              // 1
            ).then(function(path) {
              closeLoading(vm);
              console.log(path);
              if (fileLimit.show == "uploadImgMessage") {
                vm.uploadImgMessage = false;
              }
              // else if (fileLimit.show == "uploadImgMessage2") {
              //   vm.uploadImgMessage2 = false;
              // }
              vm.formData[fileLimit.key] = path.fullPath;
              vm.formData[fileLimit.more] = {
                attachmentName: path.name,
                attachmentExt: path.ext,
                attachmentSize: path.size
              };
              vm.$message.success("上传成功");
            });
          }
        };
      };
      return isJPG && isLt2M;
    },

    // 展开/收起 更多信息
    toggleOtherContent() {
      this.isShowOtherContent = !this.isShowOtherContent;
    },

    // 限制选择文件个数
    handleExceed(files, fileList) {
      this.$message.warning(`当前限制选择 100 个文件，您已经共选择了 ${files.length + fileList.length} 个文件！`);
    },

    // 删除按钮
    beforeRemove(file, fileList) {
      return this.$confirm(`确定移除 ${file.name}？`);
    },

    //表单校验
    submitForm(formName) {
      console.log("this.formData", this.formData);
      this.needShowAuditMsg = false;
      let flag = null;
      this.$refs[formName].validate(valid => {
        console.log("valid", valid);
        if (valid) {
          this.insertOrUpdate();
          //console.log("success");
          flag = true;
        } else {
          console.log("error submit!!");
          flag = false;
        }
      });
      return flag;
    },

    // 添加或修改课程
    insertOrUpdate() {
      console.log('in insertOrUpdate', this.formData);
      this.POST("contents/course/custom/info/insertOrUpdate", this.formData).then(res => {
        console.log(res);
        if (res.code == "000000") {
          if(this.courseId == 'add') {
            this.step = 2;
          } else {
            this.close();
            this.setKind(3);
          }
        }
      });
    },

    // 返回到
    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) {
      this.formData.courseCustomChapterModels[0].courseCustomLectureModelList.splice(index, 1);
    }
  }
};
</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: 480px;
        display: flex;
        flex-direction: column;
        border-radius: 3px;
        border: 1px solid rgba(228,231,237,1);
        padding: 20px;
        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: 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: 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;
        }
      }
      .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;
    }
  }
  .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>
