<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: -18px; 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>
                    <span
                      v-show="formData.checkStatus == 0"
                      class="edit-wrapper"
                      style="margin-left: 100px"
                      @click="
                        auditField(
                          formData.courseCustomChapterModels[0]
                            .courseCustomLectureModelList[index],
                          'contentCheck'
                        )
                      "
                    >
                      <img
                        class="edit-img"
                        src="../../assets/image/phrase3/icon-pz.png"
                      />拒绝原因
                    </span>
                  </li>
                  <div
                    style="top: 29px"
                    v-show="
                      needShowAuditMsg &&
                      formData.courseCustomChapterModels[0]
                        .courseCustomLectureModelList[index].contentCheck &&
                      formData.checkStatus != 2
                    "
                    class="error-video"
                  >
                    <span>{{
                      formData.courseCustomChapterModels[0]
                        .courseCustomLectureModelList[index].contentCheck
                    }}</span>
                    <span
                      v-show="formData.checkStatus == 0"
                      class="cancle"
                      @click="
                        cancleAudit(
                          formData.courseCustomChapterModels[0]
                            .courseCustomLectureModelList[index],
                          'contentCheck'
                        )
                      "
                      >X</span
                    >
                  </div>
                </ul>
                <div class="video-name">
                  <span class="title">
                    <span style="color: red">*</span>
                    <span class="video-title">视频名称{{ index + 1 }}</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
                    style="top: 86px"
                    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="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>
                <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>

            <div v-if="formData.courseCustomDoctorModels[0]">
              <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="
                          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">尺寸：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>
            </div>

            <div v-if="formData.courseIntro">
              <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>
          </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 { getOSSImgUrl } from '@/utils/index'
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: '/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,
      rules: {
        courseName: [{ required: true, message: ' ' }],
        subjectIdList: [{ required: true, message: '请输入课程名称' }],
        shareType: [{ required: true, message: '请选择开放范围' }],
      },
      labelOptions: [],
      fileList: [],
      projectBanner: '/h5/images/cme/project-banner.png',
      doctorHeader: '/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: '/h5/images/cme/doctor-header.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: 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: '您已添加过「拒绝原因」，不能通过该课程',
          tip: '',
          confirmMsg: '我知道了',
          hideMsg: '',
        },
        refuseReasen: {
          title: '',
          message: '请填写拒绝原因',
          tip: '',
          confirmMsg: '我知道了',
          hideMsg: '',
        },
        confirmRefuse: {
          title: '确认拒绝',
          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: {
    // 获取OSS域名，用于显示图片
    getOSSDomain(url) {
      return getOSSImgUrl(url)
    },

    // 返回到列表页面
    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 ||
              '/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.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.courseCustomDoctorModels[0]) {
        if (
          cData.courseNameCheck ||
          cData.courseIntroCheck ||
          cData.courseIntroImageCheck ||
          cData.courseCustomDoctorModels[0].courseDoctorNameCheck ||
          cData.courseCustomDoctorModels[0].courseDoctorAvatarUrlCheck ||
          cData.courseCustomDoctorModels[0].courseDoctorHospitalCheck
        ) {
          flag = true
        }
      } else {
        if (
          cData.courseNameCheck ||
          cData.courseIntroCheck ||
          cData.courseIntroImageCheck
        ) {
          flag = true
        }
      }

      if (!flag) {
        let lectureList =
          cData.courseCustomChapterModels[0].courseCustomLectureModelList
        for (let i = 0; i < lectureList.length; i++) {
          if (lectureList[i].nameCheck || lectureList[i].contentCheck) {
            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.statusObj.pass.message = `确定“${this.createdDoctorName}”提交的「${this.formData.courseName}」课程已完成检测并通过审核`),
            (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 lang="scss" scoped>
.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: 40px;
            line-height: 40px;
            margin-bottom: 10px;
            .title {
              display: inline-block;
              width: 80px;
              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: 80px;
            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 lang="scss" scoped>
.review-access-wrap {
  .review-access {
    padding: 10px;
    background: #fff;
  }
  .top-124 {
    top: 124px !important;
  }
}
</style>
