123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- import { getCategoryList, setCategoryList, addCategoryList, getCategoryRelation } from '@/api/categoryList'
- const state = {
- getCategoryData: [],
- getCategoryDataLength: 0,
- getCategoryRelationData: []
- }
- const mutations = {
- GET_CATEGORY: (state, data) => {
- state.getCategoryData = data
- },
- CATEGORY_LENGTH: (state, length) => {
- state.getCategoryDataLength = length
- },
- CATEGORY_RELATION: (state, data) => {
- state.getCategoryRelationData = data
- }
- }
- const actions = {
- // 获取课程表专区
- getBlockList({ commit, state }, obj) {
- const blockType = obj.blockType
- const page = (obj.page - 1) * 10
- return new Promise((resolve, reject) => {
- getCategoryList(blockType).then((res) => {
- const list = res.data
- commit('CATEGORY_LENGTH', list.length)
- commit('GET_CATEGORY', list.splice(page, 10))
- resolve()
- }).catch(error => {
- reject(error)
- })
- })
- },
- // 修改课程表专区
- setBlockList({ commit, state }, obj) {
- return new Promise((resolve, reject) => {
- setCategoryList(obj).then((res) => {
- resolve()
- }).catch(error => {
- reject(error)
- })
- })
- },
- // 添加课程表专区
- addBlockList({ commit, state }, obj) {
- return new Promise((resolve, reject) => {
- addCategoryList(obj).then((res) => {
- resolve()
- }).catch(error => {
- reject(error)
- })
- })
- },
- // 获取专区课程列表
- getRelationList({ commit, state }, obj) {
- const categoryId = obj.categoryId
- return new Promise((resolve, reject) => {
- getCategoryRelation(categoryId).then((res) => {
- const list = res.data
- commit('CATEGORY_RELATION', list)
- resolve()
- }).catch(error => {
- reject(error)
- })
- })
- }
- }
- export default {
- namespaced: true,
- state,
- mutations,
- actions
- }
|