zhouwx
2024-06-27 ae43feac8c6b2372f5a061ead68e71027e8877e1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
<template>
  <el-dialog
    :visible.sync="dialogVisible"
    :modal-append-to-body="false"
    :close-on-click-modal="false"
    width="600px"
    :before-close="handleClose"
  >
    <div style="margin:  0 25px">
      <div style="display: flex;flex-direction: column">
        <div style="display: flex;align-items: center;justify-content: space-between">
          <span style="font-size: 20px;font-weight: 550">课程大纲</span>
          <span style="color: #1890ff;cursor: pointer;" @click="clickOpen">收起/展开</span>
        </div>
        <div :class="{'open':isClose}" style="overflow: hidden">
          <div v-for="(item,index) in courseList" :key="index" style="font-size: 16px;margin: 20px 35px">
            <span>{{item.chapterName}}</span>
            <div v-if="item.children">
              <div v-for="(child,index) in item.children" :key="index"  style="font-size: 16px;margin: 20px 8px">
                <span>{{child.chapterName}}</span>
              </div>
            </div>
 
          </div>
        </div>
 
      </div>
      <div style="display: flex;flex-direction: column">
        <span style="font-size: 20px;font-weight: 550">课程章节资源</span>
        <el-table
          :data="courseTable"
          style="width: 80%;margin: 20px 35px">
          <el-table-column
            prop="chapterCode"
            label="章节UUID">
          </el-table-column>
          <el-table-column
            prop="chapterName"
            label="章节名称">
          </el-table-column>
          <el-table-column
            label="资源类别"
            prop="resourceType">
          </el-table-column>
          <el-table-column
            label="章节学时"
            prop="lessonNum">
          </el-table-column>
          <el-table-column label="预览" align="center" class-name="small-padding fixed-width">
            <template #default="scope">
              <el-button
                size="mini"
                type="text"
                style="color: #1890ff"
                @click="openUrl(scope.row.url)"
              >预览课程</el-button>
            </template>
          </el-table-column>
        </el-table>
 
      </div>
 
    </div>
  </el-dialog>
</template>
 
<script >
export default {
  name: 'addUser',
  components: {
  },
  data() {
    return {
      isClose:false,
      dialogVisible: false,
      dialogStatus: '',
      dataForm: {},
      courseTable: [],
      courseList: []
    }
  },
  created() {
  },
  methods: {
    openDialog (data) {
      this.dialogVisible = true;
      this.courseList = data.outline
      this.courseTable = this.recursion(data.outline)
      console.log('courseTable',this.courseTable)
    },
    recursion (data) {
      let tmp = []
      if(data && data.length > 0){
        for (let i = 0; i < data.length; i++) {
          let item = data[i]
          // children为空
          if (item.children && item.children.length==0) {
            // 有children
          } else {
            item.children.forEach(child => {
              tmp.push({
                chapterCode: child.chapterCode,
                chapterName: child.chapterName,
                resourceType: child.haveResource == 0 ? '视频' : '音频' ,
                lessonNum: child.lessonNum,
                url: child.url,
                children: this.recursion(child.children)
              })
            })
          }
        }
      }
      return tmp;
    },
    openUrl(url) {
      window.open(url,'_blank')
    },
    clickOpen() {
      this.isClose = !this.isClose
    },
    handleClose() {
      this.dialogVisible = false;
      this.$emit("getList");
    },
    onSubmit() {
 
              this.$emit("getList");
              this.dialogVisible = false;
 
 
    },
 
  }
}
 
</script>
<style scoped>
.open{
  height: 15px;
}
</style>