zhouwx
2024-10-16 3a5c117b8a89fbd9ae30154023286cbbf5d7fffb
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
<template>
  <el-dialog
    :visible.sync="dialogVisible"
    :modal-append-to-body="false"
    :close-on-click-modal="false"
    width="50%"
    :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
          border
          :data="courseTable"
          :span-method="objectSpanMethod"
          style="width: 100%;margin-top: 20px">
<!--          <el-table-column-->
<!--            prop="chapterParentCode"-->
<!--            label="章节UUID">-->
<!--          </el-table-column>-->
          <el-table-column
            prop="chapterParentName"
            label="章节" align="center">
          </el-table-column>
          <el-table-column
            prop="chapterName"
            label="小节名称" align="center">
          </el-table-column>
          <el-table-column
            prop="teacher"
            label="讲师" align="center">
            <template #default="scope">
              <span>{{scope.row.teacher ? scope.row.teacher : '--'}}</span>
            </template>
          </el-table-column>
          <el-table-column
            label="资源类别"
            prop="resourceType" align="center">
          </el-table-column>
          <el-table-column
            label="小节学时"
            prop="lessonNum" align="center">
          </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>
    <span slot="footer" class="dialog-footer" v-if="showBtn">
    <el-button type="primary" @click="examine('pass')">审核通过</el-button>
    <el-button type="warning" @click="examine('reject')">审核驳回</el-button>
    </span>
  </el-dialog>
</template>
 
<script >
import { checkCourse, listCourse } from '@/api/onlineEducation/course'
 
export default {
  name: 'addUser',
  components: {
  },
  data() {
    return {
      isClose:false,
      dialogVisible: false,
      dialogStatus: '',
      dataForm: {},
      courseTable: [],
      courseList: [],
      showBtn:false
    }
  },
  created() {
  },
  methods: {
    openDialog (data,type,courseType) {
      this.dialogVisible = true;
      this.dataForm = data;
      console.log('dataForm ',this.dataForm )
      if(type === 'course'){
        this.courseList = data.outline
        this.courseTable = this.recursion(data.outline,type)
 
        if(courseType == 'check'){
          this.showBtn = true
          console.log('this.showBtn ',this.showBtn )
        }
      }else {
        console.log('courseT2222222222able',data.chapterList)
        this.courseList = data.chapterList
        this.courseTable = this.recursion(data.chapterList,type)
      }
 
      console.log('coursee',this.courseTable)
    },
    recursion (data,type) {
      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 {
            if(type === 'course'){
              item.children.forEach(child => {
                tmp.push({
                  chapterParentCode: item.uuid,
                  chapterParentName: item.chapterName,
                  chapterCode: child.uuid,
                  chapterName: child.chapterName,
                  resourceType: child.haveResource == 0 ? '视频' : '音频' ,
                  lessonNum: child.lessonNum,
                  url: child.url,
                  children: this.recursion(child.children),
                  teacher: child.teacher
                })
              })
            }else {
              item.children.forEach(child => {
                tmp.push({
                  chapterParentCode: item.chapterUuid,
                  chapterParentName: item.chapterName,
                  chapterCode: child.chapterUuid,
                  chapterName: child.chapterName,
                  resourceType: child.haveResource == 0 ? '视频' : '音频' ,
                  lessonNum: child.lessonNum,
                  url: child.url,
                  children: this.recursion(child.children),
                  teacher: child.teacher
                })
              })
            }
 
          }
        }
      }
      return tmp;
    },
    openUrl(url) {
      window.open(url,'_blank')
    },
    clickOpen() {
      this.isClose = !this.isClose
    },
    handleClose() {
      this.showBtn = false
      this.dialogVisible = false;
      this.$emit("getList");
    },
    onSubmit() {
        this.$emit("getList");
        this.dialogVisible = false;
    },
    examine(type){
      let msg = '';
      const param = {
        id: this.dataForm.id,
        status: null
      }
      if(type === 'pass'){
        param.status = 2
        msg = '审核通过'
      }else {
        param.status = 3
        msg = '审核驳回'
      }
      this.$confirm(`确定${msg}该条数据?`, '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(async () => {
        checkCourse(param).then((res) => {
          if (res.code == 200) {
            this.$message({
              message: '成功',
              type: 'success'
            })
            this.handleClose()
          }else {
            this.$message({
              message: res.msg,
              type: 'warning'
            })
          }
        })
      })
    },
    objectSpanMethod({ row, column, rowIndex, columnIndex }) {
      if(columnIndex === 0) {
        const currentValue = row[column.property];
        // 获取上一行相同列的值
        const preRow = this.courseTable[rowIndex - 1];
        const preValue = preRow ? preRow[column.property] : null;
        // 如果当前值和上一行的值相同,则将当前单元格隐藏
        if (currentValue === preValue) {
          return { rowspan: 0, colspan: 0 };
        } else {
          // 否则计算当前单元格应该跨越多少行
          let rowspan = 1;
          for (let i = rowIndex + 1; i < this.courseTable.length; i++) {
            const nextRow = this.courseTable[i];
            const nextValue = nextRow[column.property];
            if (nextValue === currentValue) {
              rowspan++;
            } else {
              break;
            }
          }
          return { rowspan, colspan: 1 };
        }
        // if(rowIndex%2 === 0){
        //   return {
        //     rowspan: 2,
        //     colspan: 1
        //   }
        // }else {
        //   return {
        //     rowspan: 0,
        //     colspan: 0
        //   }
        // }
      }
    }
  }
}
 
 
</script>
<style scoped>
.open{
  height: 15px;
}
.dialog-footer{
  display: flex;
  align-items: center;
  justify-content: space-around;
}
</style>