Explorar el Código

修改课件和添加项可以选择

limengbo hace 5 años
padre
commit
b6c1f8bcf7

+ 0 - 1
src/api/courseWareList.js

@@ -9,7 +9,6 @@ export function getCourseWareList(params) {
 }
 // 新增课程列表
 export function addCourseWareList(data) {
-  debugger
   return request({
     url: '/cms/courseWare',
     method: 'post',

+ 3 - 2
src/router/index.js

@@ -181,8 +181,9 @@ export const constantRoutes = [
       path: 'courseWareList',
       name: 'CourseWareList',
       component: () => import('@/views/courseWareList/index'),
-      meta: { title: '课件列表', icon: 'dashboard' }
-    }]
+      meta: { title: '课件列表' }
+    }],
+    hidden: true
   },
   {
     path: '/memberList',

+ 1 - 1
src/store/modules/courseList.js

@@ -26,7 +26,7 @@ const actions = {
       }).then((res) => {
         const list = res.data
         commit('GET_COURSE', list)
-        resolve()
+        resolve(list)
       }).catch(error => {
         reject(error)
       })

+ 1 - 1
src/store/modules/topicList.js

@@ -28,7 +28,7 @@ const actions = {
       }).then((res) => {
         const list = res.data
         commit('GET_TOPIC', list)
-        resolve()
+        resolve(list)
       }).catch(error => {
         reject(error)
       })

+ 13 - 0
src/views/courseList/index.vue

@@ -95,6 +95,10 @@
               size="mini"
               @click="handleSet(scope.$index, scope.row)"
             >修改</el-button>
+            <el-button
+              size="mini"
+              @click="handleDetail(scope.$index, scope.row)"
+            >课件</el-button>
           </template>
         </el-table-column>
       </el-table>
@@ -301,6 +305,15 @@ export default {
       this.$store.dispatch('courseList/getCourseLists', {
         page: this.page
       })
+    },
+    handleDetail(index, row) {
+      console.log(index, row)
+      this.$router.push({
+        path: '/courseWareList/courseWareList',
+        query: {
+          id: row.id
+        }
+      })
     }
   }
 }

+ 16 - 12
src/views/courseWareList/index.vue

@@ -3,9 +3,6 @@
   <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>
@@ -46,6 +43,14 @@
           prop="playUrl"
         />
         <el-table-column
+          label="状态"
+          width="100"
+        >
+          <template slot-scope="scope">
+            <span style="margin-left: 10px">{{ scope.row.status === 'NOT_ON_STOCK' ? '未上架' : '已上架' }}</span>
+          </template>
+        </el-table-column>
+        <el-table-column
           label="免费"
           width="60"
         >
@@ -73,12 +78,10 @@
         </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)"
@@ -88,9 +91,6 @@
       </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>
@@ -133,14 +133,13 @@ export default {
     return {
       dialogFormVisible: false,
       formInline: {
-        courseId: '',
+        courseId: this.$route.query.id,
         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' }],
@@ -153,6 +152,7 @@ export default {
   },
   created() {
     this.$store.dispatch('courseWareList/getCourseWareLists', {
+      courseId: this.$route.query.id,
       page: this.page
     })
   },
@@ -172,11 +172,12 @@ export default {
     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', {
+      this.$store.dispatch('courseWareList/setCourseWareLists', {
         id,
         status
       }).then(() => {
         this.$store.dispatch('courseWareList/getCourseWareLists', {
+          courseId: this.$route.query.id,
           page: this.page
         })
       })
@@ -203,6 +204,7 @@ export default {
             this.$store.dispatch('courseWareList/addCourseWareLists', this.form).then(() => {
               this.dialogFormVisible = false
               this.$store.dispatch('courseWareList/getCourseWareLists', {
+                courseId: this.$route.query.id,
                 page: this.page
               })
             })
@@ -210,6 +212,7 @@ export default {
             this.$store.dispatch('courseWareList/setCourseWareLists', this.form).then(() => {
               this.dialogFormVisible = false
               this.$store.dispatch('courseWareList/getCourseWareLists', {
+                courseId: this.$route.query.id,
                 page: this.page
               })
             })
@@ -224,7 +227,7 @@ export default {
       this.dialogFormVisible = true
       this.type = 'add'
       this.form = {
-        courseId: '',
+        courseId: this.$route.query.id,
         code: '',
         title: '',
         playUrl: '',
@@ -236,6 +239,7 @@ export default {
       console.log(val)
       this.page = val
       this.$store.dispatch('courseWareList/getCourseWareLists', {
+        courseId: this.$route.query.id,
         page: this.page
       })
     }

+ 128 - 5
src/views/dashboardRowItem/index.vue

@@ -82,6 +82,7 @@
           </template>
         </el-table-column>
       </el-table>
+      <!--添加和修改表单 -->
       <el-dialog title="首页项列表" :visible.sync="dialogFormVisible">
         <el-form ref="ruleForm" :model="form" :rules="rules">
           <el-form-item label="项目名称" :label-width="formLabelWidth">
@@ -101,15 +102,25 @@
               <el-option value="PAY" label="知识付费" />
               <el-option value="TOPIC" label="专题" />
               <el-option value="SCHEDULE" label="课程表" />
-              <el-option value="URL" label="URL" />
+              <!--<el-option value="URL" label="URL" />-->
             </el-select>
           </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-item v-if="type === 'add'" label="跳转地址" :label-width="formLabelWidth">
-            <el-input v-model="form.targetContent" autocomplete="off" clearable />
-            <el-tag type="danger">请输入Code</el-tag>
+            <el-select v-if="form.targetType === 'SCHEDULE'" v-model="form.targetContent" placeholder="请选择">
+              <el-option value="PRIMARY_FIRST_GRADE" label="小学一年级" />
+              <el-option value="PRIMARY_SECOND_GRADE" label="小学二年级" />
+              <el-option value="PRIMARY_THREE_GRADE" label="小学三年级" />
+              <el-option value="PRIMARY_SENIOR_GRADE" label="小学四年级" />
+              <el-option value="KINDERGARTEN" label="爱上幼儿园" />
+              <el-option value="PRESCHOOL" label="学前领先班" />
+            </el-select>
+            <div v-else>
+              <el-button @click="selectList">选择跳转</el-button>
+              <span>{{ form.targetContent }}</span>
+            </div>
           </el-form-item>
           <el-form-item v-if="type === 'add'" label="状态" :label-width="formLabelWidth" prop="status">
             <el-select v-model="form.status" placeholder="请选择">
@@ -123,6 +134,56 @@
           <el-button type="primary" @click="handOk('ruleForm')">确 定</el-button>
         </div>
       </el-dialog>
+      <!-- 选择课程表格 -->
+      <el-dialog :title="form.targetType === 'TOPIC' ? '选择专题' : '选择课程' " :visible.sync="dialogTableVisible">
+        <el-table
+          ref="singleTable"
+          :data="tableData"
+          highlight-current-row
+          style="width: 100%"
+          height="500"
+          @current-change="handleCurrentChange"
+        >
+          <el-table-column
+            label="id"
+            width="180"
+            prop="id"
+          />
+          <el-table-column
+            label="code"
+            width="180"
+            prop="code"
+          />
+          <el-table-column
+            label="icon"
+            width="140"
+          >
+            <template slot-scope="scope">
+              <img :src="scope.row.iconImg" width="75">
+            </template>
+          </el-table-column>
+          <el-table-column
+            label="标题"
+            width="200"
+            prop="title"
+          />
+          <el-table-column
+            v-if="form.targetType !== 'TOPIC'"
+            label="类型"
+            width="100"
+          >
+            <template slot-scope="scope">
+              <span style="margin-left: 10px">{{ scope.row.courseType === 'KNOWLEDGE' ? '知识付费' : '图书馆' }}</span>
+            </template>
+          </el-table-column>
+        </el-table>
+        <el-pagination
+          background
+          layout="prev, pager, next"
+          :total="totalSize"
+          @current-change="handleTableChange"
+        />
+      </el-dialog>
     </div>
   </div>
 </template>
@@ -136,6 +197,7 @@ export default {
     return {
       form: {},
       dialogFormVisible: false,
+      dialogTableVisible: false,
       type: '',
       formLabelWidth: '120px',
       rules: {
@@ -149,9 +211,12 @@ export default {
         sort: [
           { required: true, message: '请输入排序', trigger: 'blur' }
         ],
-        targetContent: [{ required: true, message: '请输入项目Code', trigger: 'blur' }],
+        targetContent: [{ required: true, message: '请选择', trigger: 'blur' }],
         status: [{ required: true, message: '请选择状态', trigger: 'change' }]
-      }
+      },
+      tableData: [],
+      totalSize: 0,
+      tablePage: 1
     }
   },
   created() {
@@ -273,6 +338,26 @@ export default {
         'status': ''
       }
     },
+    selectList() {
+      this.dialogTableVisible = true
+      if (this.form.targetType === 'TOPIC') {
+        this.$store.dispatch('topicList/getTopicLists', {
+          page: this.tablePage
+        }).then(res => {
+          console.log(res)
+          this.tableData = res.list
+          this.totalSize = res.totalSize
+        })
+      } else {
+        this.$store.dispatch('courseList/getCourseLists', {
+          page: this.tablePage
+        }).then(res => {
+          console.log(res)
+          this.tableData = res.list
+          this.totalSize = res.totalSize
+        })
+      }
+    },
     handleUp(index, row) {
       console.log(index, row)
       this.setForm(row)
@@ -295,6 +380,7 @@ export default {
               })
             })
           } else {
+            console.log(this.form)
             this.$store.dispatch('dashboard/addRowItemList', this.form).then(() => {
               this.dialogFormVisible = false
               this.$store.dispatch('dashboard/getRowItemList', {
@@ -320,6 +406,43 @@ export default {
         'sort': data.sort,
         'status': data.status
       }
+    },
+    handleCurrentChange(val) {
+      console.log(val)
+      if (val) {
+        this.form.targetContent = val.id
+        this.dialogTableVisible = false
+        this.$message({
+          message: '选择成功',
+          type: 'success'
+        })
+      }
+      // this.currentRow = val
+    },
+    handleTableChange(val) {
+      console.log(val)
+      this.tablePage = val
+      if (this.form.targetType === 'TOPIC') {
+        this.$store.dispatch('topicList/getTopicLists', {
+          page: this.tablePage
+        }).then(res => {
+          console.log(res)
+          this.tableData = res.list
+          this.totalSize = res.totalSize
+        })
+      } else {
+        this.$store.dispatch('courseList/getCourseLists', {
+          page: this.tablePage
+        }).then(res => {
+          console.log(res)
+          this.tableData = res.list
+          this.totalSize = res.totalSize
+        })
+      }
+      // this.page = val
+      // this.$store.dispatch('courseList/getCourseLists', {
+      //   page: this.page
+      // })
     }
   }
 }