<template>
  <div>
    <div class="from_box">
      <div class="from_left">
        <div style="height: 175px;overflow-y: hidden;">
          <MOSTY.Upload :width="'100%'" :limit="1" :nopicer="false" :isImg="true" :ShowfileList="false"
            v-model="dialogForm.videopic" :gsgfList="['jpg', 'png']" :disabled='!savebtn'>
          </MOSTY.Upload>
        </div>
        <span style="margin-left: 40px">课件封面图</span>
      </div>
      <el-form ref="frombt" :model="dialogForm" :rules="rules" label-width="120px" :disabled='!savebtn'>
        <el-form-item label="课件类型：" prop="videotype">
          <el-select class="pxdx_box" v-model="dialogForm.videotype" clearable style="width: 212px">
            <el-option v-for="item in D_TB_YWLX" :key="item" :label="item.label" :value="item.value" />
          </el-select>
        </el-form-item>
        <el-form-item label="学习类型：" prop="learntype">
          <el-select class="pxdx_box" v-model="dialogForm.learntype" clearable style="width: 212px"
            @change="learntypeChange">
            <el-option v-for="item in xxlxlist" :key="item" :label="item.label" :value="item.value" />
          </el-select>
        </el-form-item>
        <!-- <el-form-item v-if="filterqx('isSgs') == 1 || filterqx('isgs') == 1" label="仅本级查看：" prop="pubpriv">
          <div style="width: 215px">
            <MOSTY.DictRidioAndSelect :dictData="[{ label: '是', value: '01' }, { label: '否', value: '02' }]"
              v-model="dialogForm.pubpriv" selectType="radio" />
          </div>
        </el-form-item> -->
        <el-form-item label="课件名称：" prop="videoname">
          <el-input v-model="dialogForm.videoname" maxlength="50" autosize type="textarea" show-word-limit
            placeholder="不能超过50个字" style="width: 547px"></el-input>
        </el-form-item>
        <el-form-item label="课件简介：" prop="instro">
          <el-input style="width: 547px" v-model="dialogForm.instro" autosize type="textarea" row="10" />
        </el-form-item>
        <el-form-item ref="videoTimeRef" label="学时：" :prop="dialogForm.learntype == '2' ? '' : 'videotime'">
          <el-input v-model="dialogForm.videotime" type="Number" maxlength="30" @input="check" style="width: 547px"
            :disabled="dialogForm.learntype == '2'"></el-input>
        </el-form-item>
        <el-form-item label="课件附件：" prop="videourl" v-if='dialogForm.learntype == "1"'>
          <MOSTY.Upload width="547px" :limit="1" :nopicer="true" :isImg="false" :ShowfileList="true"
            :gsgfList="['pdf', 'ofd', 'doc', 'docx', 'xls', 'xlsx', 'wps']" v-model="dialogForm.videourl">
          </MOSTY.Upload>
        </el-form-item>
        <el-form-item label="视频上传：" prop="videourl" v-if='dialogForm.learntype == "2"'>
          <MOSTY.Upload width="547px" :limit="1" :nopicer="true" :isImg="false" :isVideosp="true" :ShowfileList="true"
            v-model="dialogForm.videourl" :delrow="delrow" :keys="keys">
          </MOSTY.Upload>
          <div style="margin-left:20%;color:red;"> <span> (仅支持视频格式文件上传)</span></div>
        </el-form-item>
      </el-form>
    </div>

    <div style="text-align: center;display: flex;justify-content: center;margin-top: 10px;"
      class="dialog-footer flex just-conter">
      <el-button @click="CloseEvent"><el-icon class="mr4">
          <DocumentDelete />
        </el-icon>关闭</el-button>
    </div>
  </div>

</template>

<script setup>
import { ref, defineProps, onBeforeMount, defineEmits, computed, getCurrentInstance } from 'vue';
import { getApi, postApi } from "@/api/tobAcco_api.js";
import * as MOSTY from "@/components/MyComponents/index";

import { ElMessage } from "element-plus"

const { proxy } = getCurrentInstance();
const { D_TB_YWLX } = proxy.$dict("D_TB_YWLX");



const emits = defineEmits(['close']);
const props = defineProps({
  /** 回传的数据 */
  Row: {
    type: Array,
    default: []
  },

});
const rules = ref([])
const xxlxlist = ref([
  { label: '附件', value: '1' },
  { label: '视频学习', value: '2' }
])
const dialogForm = ref({
  /** 是否本级 01 是 02 否 */
  pubpriv: '01' // 默认本级
});
const currRow = ref({})
const savebtn = ref(false)
// const zdlist = ref({ D_TB_YWLX, D_BZ_KTKYWLX, D_TB_KTTX, D_BZ_SF, D_BZ_PXSSCTFS, D_BZ_PXZYK })

const dialogVisible = ref(true);
//	查询数据详情
function getxqData(id) {
  getApi({ id }, "/mosty-jcgl/videoStudy/getInfo").then((res) => {
    dialogForm.value = res;
    // positionTime.value = res.currTime ? Number(res.currTime) : 0
  });
}
const CloseEvent = () => {
  emits('close')
};

onBeforeMount(() => {
  getxqData(props.Row?.id)
});
</script>

<style scoped lang="scss">
.el-dialog {
  .el-table {
    margin-top: 20px;
  }
}

.from_box {
  display: flex;
  justify-content: space-between;

  .from_left {
    width: 160px;
    flex-shrink: 0;

    >div {
      height: 150px;

      overflow: hidden;
    }
  }

  ::v-deep .el-form {
    flex-wrap: wrap;
  }
}
</style>
