|
@@ -0,0 +1,263 @@
|
|
|
+/* eslint-disable no-duplicate-case */
|
|
|
+<template>
|
|
|
+ <div class="school-container">
|
|
|
+ <div class="topic">
|
|
|
+ <el-form :inline="true" :model="formInline" class="demo-form-inline">
|
|
|
+ <el-form-item label="课程id">
|
|
|
+ <el-input v-model="formInline.courseId" placeholder="courseId" clearable />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="code">
|
|
|
+ <el-input v-model="formInline.code" placeholder="code" clearable />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="名字">
|
|
|
+ <el-input v-model="formInline.title" placeholder="名字" clearable />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item>
|
|
|
+ <el-button type="primary" @click="onSubmit">查询</el-button>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ <el-button
|
|
|
+ type="primary"
|
|
|
+ style="position: absolute;right: 20px; top: 15px;"
|
|
|
+ @click="addTopic"
|
|
|
+ >添加</el-button>
|
|
|
+ <el-table
|
|
|
+ :data="getCourseWareData.list"
|
|
|
+ style="width: 100%"
|
|
|
+ >
|
|
|
+ <el-table-column
|
|
|
+ label="id"
|
|
|
+ width="180"
|
|
|
+ prop="id"
|
|
|
+ />
|
|
|
+ <el-table-column
|
|
|
+ label="code"
|
|
|
+ width="180"
|
|
|
+ prop="code"
|
|
|
+ />
|
|
|
+ <el-table-column
|
|
|
+ label="标题"
|
|
|
+ width="200"
|
|
|
+ prop="title"
|
|
|
+ />
|
|
|
+ <el-table-column
|
|
|
+ label="播放地址"
|
|
|
+ width="200"
|
|
|
+ prop="playUrl"
|
|
|
+ />
|
|
|
+ <el-table-column
|
|
|
+ label="免费"
|
|
|
+ width="60"
|
|
|
+ >
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <span style="margin-left: 10px">{{ scope.row.free === 'FREE' ? '否' : '是' }}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column
|
|
|
+ label="创建时间"
|
|
|
+ width="200"
|
|
|
+ >
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <i class="el-icon-time" />
|
|
|
+ <span style="margin-left: 10px">{{ newDate(scope.row.gmtCreated) }}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column
|
|
|
+ label="修改时间"
|
|
|
+ width="200"
|
|
|
+ >
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <i class="el-icon-time" />
|
|
|
+ <span style="margin-left: 10px">{{ newDate(scope.row.gmtModified) }}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="操作">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <!--
|
|
|
+ <el-button
|
|
|
+ size="mini"
|
|
|
+ @click="handleDel(scope.$index, scope.row)"
|
|
|
+ >{{ scope.row.status === 'NOT_ON_STOCK' ? '上架' : '下架' }}</el-button>
|
|
|
+ -->
|
|
|
+ <el-button
|
|
|
+ size="mini"
|
|
|
+ @click="handleSet(scope.$index, scope.row)"
|
|
|
+ >修改</el-button>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+ <el-dialog title="课件" :visible.sync="dialogFormVisible">
|
|
|
+ <el-form ref="ruleForm" :model="form" :rules="rules">
|
|
|
+ <el-form-item label="课程Id" :label-width="formLabelWidth" prop="courseId">
|
|
|
+ <el-input v-model="form.courseId" autocomplete="off" clearable />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="code" :label-width="formLabelWidth" prop="code">
|
|
|
+ <el-input v-model="form.code" autocomplete="off" clearable />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="名字" :label-width="formLabelWidth" prop="title">
|
|
|
+ <el-input v-model="form.title" autocomplete="off" clearable />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="收费" :label-width="formLabelWidth" prop="free">
|
|
|
+ <el-select v-model="form.free" placeholder="请选择状态">
|
|
|
+ <el-option label="是" value="UNFREE" />
|
|
|
+ <el-option label="否" value="FREE" />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="播放地址" :label-width="formLabelWidth" prop="playUrl">
|
|
|
+ <el-input v-model="form.playUrl" autocomplete="off" clearable />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="排序" :label-width="formLabelWidth" prop="sort">
|
|
|
+ <el-input v-model="form.sort" autocomplete="off" clearable />
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ <div slot="footer" class="dialog-footer">
|
|
|
+ <el-button @click="dialogFormVisible = false">取 消</el-button>
|
|
|
+ <el-button type="primary" @click="handOk('ruleForm')">确 定</el-button>
|
|
|
+ </div>
|
|
|
+ </el-dialog>
|
|
|
+ <el-pagination
|
|
|
+ background
|
|
|
+ layout="prev, pager, next"
|
|
|
+ :total="getCourseWareData.totalSize"
|
|
|
+ @current-change="handleCurrentChange"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import { mapGetters } from 'vuex'
|
|
|
+
|
|
|
+export default {
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ dialogFormVisible: false,
|
|
|
+ formInline: {
|
|
|
+ courseId: '',
|
|
|
+ code: '',
|
|
|
+ title: ''
|
|
|
+ },
|
|
|
+ form: {},
|
|
|
+ formLabelWidth: '120px',
|
|
|
+ rules: {
|
|
|
+ courseId: [{ required: true, message: '请输入课程id', trigger: 'blur' }],
|
|
|
+ code: [{ required: true, message: '请输入code', trigger: 'blur' }],
|
|
|
+ title: [{ required: true, message: '请输入名称', trigger: 'blur' }],
|
|
|
+ free: [{ required: true, message: '请选择状态', trigger: 'change' }],
|
|
|
+ playUrl: [{ required: true, message: '请输入播放地址', trigger: 'blur' }],
|
|
|
+ sort: [{ required: true, message: '请输入排序', trigger: 'blur' }]
|
|
|
+ },
|
|
|
+ page: 1,
|
|
|
+ type: ''
|
|
|
+ }
|
|
|
+ },
|
|
|
+ created() {
|
|
|
+ this.$store.dispatch('courseWareList/getCourseWareLists', {
|
|
|
+ page: this.page
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // eslint-disable-next-line vue/order-in-components
|
|
|
+ computed: {
|
|
|
+ ...mapGetters([
|
|
|
+ 'getCourseWareData'
|
|
|
+ ])
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ newDate(date) {
|
|
|
+ return new Date(date).toLocaleString()
|
|
|
+ },
|
|
|
+ onSubmit() {
|
|
|
+ this.$store.dispatch('courseWareList/getCourseWareLists', this.formInline)
|
|
|
+ },
|
|
|
+ handleDel(index, row) {
|
|
|
+ const id = row.id
|
|
|
+ const status = row.status === 'NOT_ON_STOCK' ? 'HAS_ON_STOCK' : 'NOT_ON_STOCK'
|
|
|
+ this.$store.dispatch('courseList/setCourseLists', {
|
|
|
+ id,
|
|
|
+ status
|
|
|
+ }).then(() => {
|
|
|
+ this.$store.dispatch('courseWareList/getCourseWareLists', {
|
|
|
+ page: this.page
|
|
|
+ })
|
|
|
+ })
|
|
|
+ },
|
|
|
+ handleSet(index, row) {
|
|
|
+ console.log(index, row)
|
|
|
+ this.dialogFormVisible = true
|
|
|
+ this.type = 'set'
|
|
|
+ this.form = {
|
|
|
+ id: row.id,
|
|
|
+ courseId: row.courseId,
|
|
|
+ code: row.code,
|
|
|
+ title: row.title,
|
|
|
+ playUrl: row.playUrl,
|
|
|
+ free: row.free,
|
|
|
+ sort: row.sort
|
|
|
+ }
|
|
|
+ },
|
|
|
+ handOk(formName) {
|
|
|
+ this.$refs[formName].validate((valid) => {
|
|
|
+ if (valid) {
|
|
|
+ if (this.type === 'add') {
|
|
|
+ console.log(this.form)
|
|
|
+ this.$store.dispatch('courseWareList/addCourseWareLists', this.form).then(() => {
|
|
|
+ this.dialogFormVisible = false
|
|
|
+ this.$store.dispatch('courseWareList/getCourseWareLists', {
|
|
|
+ page: this.page
|
|
|
+ })
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ this.$store.dispatch('courseWareList/setCourseWareLists', this.form).then(() => {
|
|
|
+ this.dialogFormVisible = false
|
|
|
+ this.$store.dispatch('courseWareList/getCourseWareLists', {
|
|
|
+ page: this.page
|
|
|
+ })
|
|
|
+ })
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ console.log('error submit!!')
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ addTopic() {
|
|
|
+ this.dialogFormVisible = true
|
|
|
+ this.type = 'add'
|
|
|
+ this.form = {
|
|
|
+ courseId: '',
|
|
|
+ code: '',
|
|
|
+ title: '',
|
|
|
+ playUrl: '',
|
|
|
+ free: '',
|
|
|
+ sort: ''
|
|
|
+ }
|
|
|
+ },
|
|
|
+ handleCurrentChange(val) {
|
|
|
+ console.log(val)
|
|
|
+ this.page = val
|
|
|
+ this.$store.dispatch('courseWareList/getCourseWareLists', {
|
|
|
+ page: this.page
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="scss" scoped>
|
|
|
+.topic {
|
|
|
+ margin-top: 20px;
|
|
|
+}
|
|
|
+.el-form {
|
|
|
+ width: 80%;
|
|
|
+}
|
|
|
+.el-input {
|
|
|
+ width: 250px;
|
|
|
+}
|
|
|
+.el-select>.el-input {
|
|
|
+ width: 250px;
|
|
|
+}
|
|
|
+.el-pagination {
|
|
|
+ text-align: center;
|
|
|
+ margin-top: 20px;
|
|
|
+}
|
|
|
+</style>
|