limengbo hace 5 años
padre
commit
dd43d71e18

+ 17 - 1
src/api/categoryList.js

@@ -28,7 +28,23 @@ export function addCategoryList(data) {
 // 获取专区课程列表
 export function getCategoryRelation(categoryId) {
   return request({
-    url: `cms/category/categoryRelation/${categoryId}`,
+    url: `/cms/category/categoryRelation/${categoryId}`,
     method: 'get'
   })
 }
+// 增加专区课程列表
+export function addCategoryRelation(data) {
+  return request({
+    url: `/cms/category/saveCategoryRelation`,
+    method: 'post',
+    data
+  })
+}
+// 修改专区课程列表
+export function setCategoryRelation(data) {
+  return request({
+    url: `/cms/category/updateCategoryRelation`,
+    method: 'put',
+    data
+  })
+}

+ 21 - 1
src/store/modules/categoryList.js

@@ -1,4 +1,4 @@
-import { getCategoryList, setCategoryList, addCategoryList, getCategoryRelation } from '@/api/categoryList'
+import { getCategoryList, setCategoryList, addCategoryList, getCategoryRelation, addCategoryRelation, setCategoryRelation } from '@/api/categoryList'
 
 const state = {
   getCategoryData: [],
@@ -66,6 +66,26 @@ const actions = {
         reject(error)
       })
     })
+  },
+  // 添加专区课程列表
+  addRelationList({ commit, state }, obj) {
+    return new Promise((resolve, reject) => {
+      addCategoryRelation(obj).then((res) => {
+        resolve()
+      }).catch(error => {
+        reject(error)
+      })
+    })
+  },
+  // 修改专区课程列表
+  setRelationList({ commit, state }, obj) {
+    return new Promise((resolve, reject) => {
+      setCategoryRelation(obj).then((res) => {
+        resolve()
+      }).catch(error => {
+        reject(error)
+      })
+    })
   }
 }
 

+ 37 - 90
src/views/categoryRelation/index.vue

@@ -9,32 +9,32 @@
         <el-table-column
           label="序号"
           width="60"
-          prop="sort"
+          prop="categoryRelation.sort"
         />
         <el-table-column
           label="id"
           width="160"
-          prop="id"
+          prop="course.id"
         />
         <el-table-column
           label="专区名称"
           width="200"
-          prop="title"
+          prop="course.title"
         />
         <el-table-column
-          label="专区类型"
+          label="播放状态"
           width="180"
         >
           <template slot-scope="scope">
-            <span>{{ targetCode(scope.row.code) }}</span>
+            <span>{{ scope.row.course.continuity === 'CONTINUOUS_PLAY' ? '连续' : ( scope.row.course.continuity === 'DISCONTINUOUS_PLAY' ? '不连续' : '循环') }}</span>
           </template>
         </el-table-column>
         <el-table-column
-          label="专题类型"
-          width="180"
+          label="icon"
+          width="100"
         >
           <template slot-scope="scope">
-            <span>{{ scope.row.courseType === 'KNOWLEDGE' ? '知识付费' : '图书馆' }}</span>
+            <img :src="scope.row.course.iconImg" width="65">
           </template>
         </el-table-column>
         <el-table-column
@@ -42,7 +42,7 @@
           width="80"
         >
           <template slot-scope="scope">
-            <span>{{ scope.row.status === 'ABNORMAL' ? '不正常' : '正常' }}</span>
+            <span>{{ scope.row.categoryRelation.status === 'ABNORMAL' ? '不正常' : '正常' }}</span>
           </template>
         </el-table-column>
         <el-table-column
@@ -50,7 +50,7 @@
           width="180"
         >
           <template slot-scope="scope">
-            <span>{{ newDate(scope.row.gmtCreated) }}</span>
+            <span>{{ newDate(scope.row.categoryRelation.gmtCreated) }}</span>
           </template>
         </el-table-column>
         <el-table-column
@@ -58,7 +58,7 @@
           width="180"
         >
           <template slot-scope="scope">
-            <span>{{ newDate(scope.row.gmtModified) }}</span>
+            <span>{{ newDate(scope.row.categoryRelation.gmtModified) }}</span>
           </template>
         </el-table-column>
         <el-table-column label="操作">
@@ -70,28 +70,14 @@
             <el-button
               size="mini"
               @click="handleUp(scope.$index, scope.row)"
-            >{{ scope.row.status === 'ABNORMAL' ? '正常' : '不正常' }}</el-button>
+            >{{ scope.row.categoryRelation.status === 'ABNORMAL' ? '正常' : '不正常' }}</el-button>
           </template>
         </el-table-column>
       </el-table>
-      <el-dialog title="专区" :visible.sync="dialogFormVisible">
+      <el-dialog title="专区课程" :visible.sync="dialogFormVisible">
         <el-form ref="ruleForm" :model="form" :rules="rules">
-          <el-form-item label="专区类型" :label-width="formLabelWidth" prop="code">
-            <el-select v-model="form.code" placeholder="请选择">
-              <el-option value="PAY" label="知识付费" />
-              <el-option value="PRESCHOOL" label="学前" />
-              <el-option value="PRIMARY" label="小学" />
-              <el-option value="MIDDLE" label="中学" />
-            </el-select>
-          </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="courseType">
-            <el-select v-model="form.courseType" placeholder="请选择">
-              <el-option value="KNOWLEDGE" label="知识付费" />
-              <el-option value="LIBRARY" label="图书馆" />
-            </el-select>
+          <el-form-item v-if="type === 'add'" label="courseId" :label-width="formLabelWidth" prop="courseId">
+            <el-input v-model="form.courseId" autocomplete="off" clearable />
           </el-form-item>
           <el-form-item label="排序" :label-width="formLabelWidth" prop="sort">
             <el-input v-model="form.sort" autocomplete="off" clearable />
@@ -124,14 +110,8 @@ export default {
       formLabelWidth: '120px',
       type: '',
       rules: {
-        code: [
-          { required: true, message: '请选择专区类型', trigger: 'change' }
-        ],
-        title: [
-          { required: true, message: '请输入排序', trigger: 'blur' }
-        ],
-        courseType: [
-          { required: true, message: '请选择专题', trigger: 'change' }
+        courseId: [
+          { required: true, message: '请输入courseId', trigger: 'blur' }
         ],
         status: [
           { required: true, message: '请选择状态', trigger: 'change' }
@@ -157,34 +137,15 @@ export default {
     newDate(date) {
       return new Date(date).toLocaleString()
     },
-    targetCode(type) {
-      let target = ''
-      switch (type) {
-        case 'PRESCHOOL':
-          target = '学前'
-          break
-        case 'PAY':
-          target = '知识付费课程'
-          break
-        case 'PRIMARY':
-          target = '小学'
-          break
-        case 'MIDDLE':
-          target = '中学'
-          break
-      }
-      return target
-    },
     handleEdit(index, row) {
       console.log(index, row)
       this.dialogFormVisible = true
       this.type = 'set'
       this.form = {
         id: '',
-        code: '',
-        title: '',
+        categoryId: '',
+        courseId: '',
         status: '',
-        courseType: '',
         sort: ''
       }
       this.setForm(row)
@@ -192,12 +153,10 @@ export default {
     handleUp(index, row) {
       console.log(index, row)
       this.setForm(row)
-      this.form.status = row.status === 'NORMAL' ? 'ABNORMAL' : 'NORMAL'
-      this.$store.dispatch('categoryList/setBlockList', this.form).then(() => {
-        this.dialogFormVisible = false
-        this.$store.dispatch('categoryList/getBlockList', {
-          blockType: '',
-          page: this.page
+      this.form.status = row.categoryRelation.status === 'NORMAL' ? 'ABNORMAL' : 'NORMAL'
+      this.$store.dispatch('categoryList/setRelationList', this.form).then(() => {
+        this.$store.dispatch('categoryList/getRelationList', {
+          categoryId: this.$route.query.categoryId
         })
       })
     },
@@ -206,19 +165,17 @@ export default {
         if (valid) {
           if (this.type === 'set') {
             console.log(this.form)
-            this.$store.dispatch('categoryList/setBlockList', this.form).then(() => {
+            this.$store.dispatch('categoryList/setRelationList', this.form).then(() => {
               this.dialogFormVisible = false
-              this.$store.dispatch('categoryList/getBlockList', {
-                blockType: '',
-                page: this.page
+              this.$store.dispatch('categoryList/getRelationList', {
+                categoryId: this.$route.query.categoryId
               })
             })
           } else {
-            this.$store.dispatch('categoryList/addBlockList', this.form).then(() => {
+            this.$store.dispatch('categoryList/addRelationList', this.form).then(() => {
               this.dialogFormVisible = false
-              this.$store.dispatch('categoryList/getBlockList', {
-                blockType: '',
-                page: this.page
+              this.$store.dispatch('categoryList/getRelationList', {
+                categoryId: this.$route.query.categoryId
               })
             })
           }
@@ -232,28 +189,18 @@ export default {
       this.dialogFormVisible = true
       this.type = 'add'
       this.form = {
-        code: '',
-        title: '',
-        status: '',
-        courseType: '',
+        categoryId: this.$route.query.categoryId,
+        courseId: '',
         sort: ''
       }
     },
-    handleCurrentChange(val) {
-      console.log(val)
-      this.page = val
-      this.$store.dispatch('categoryList/getBlockList', {
-        blockType: '',
-        page: this.page
-      })
-    },
     setForm(data) {
-      this.form.id = data.id
-      this.form.courseType = data.courseType
-      this.form.title = data.title
-      this.form.code = data.code
-      this.form.sort = data.sort
-      this.form.status = data.status
+      console.log(data.course)
+      this.form.id = data.categoryRelation.id
+      this.form.categoryId = this.$route.query.categoryId
+      this.form.courseId = data.course.id
+      this.form.sort = data.categoryRelation.sort
+      this.form.status = data.categoryRelation.status
     }
   }
 }

+ 1 - 1
src/views/dashboard/index.vue

@@ -12,7 +12,7 @@
         />
         <el-table-column
           label="icon"
-          width="180"
+          width="100"
         >
           <template slot-scope="scope">
             <img :src="scope.row.icon">

+ 1 - 1
src/views/dashboardRowItem/index.vue

@@ -23,7 +23,7 @@
         />
         <el-table-column
           label="项目icon"
-          width="180"
+          width="230"
         >
           <template slot-scope="scope">
             <img :src="scope.row.icon" style="width: 100%">

+ 2 - 2
src/views/memberList/index.vue

@@ -50,10 +50,10 @@
         </el-table-column>
         <el-table-column
           label="头像"
-          width="120"
+          width="76"
         >
           <template slot-scope="scope">
-            <img :src="scope.row.avatar">
+            <img :src="scope.row.avatar" width="66" style="border-radius: 50%">
           </template>
         </el-table-column>
         <el-table-column