zhouwx
2024-07-23 bfa061edf56598f05b5817565bf181c64b149f99
src/views/onlineEducation/courseManage/index.vue
@@ -1,12 +1,30 @@
<template>
  <div class="app-container">
    <div style="margin-bottom: 10px">
      <el-button
          type="primary"
          plain
          icon="Plus"
          @click="openDialog('add',{})"
      >新增</el-button>
    <div style="display: flex;justify-content: space-between">
      <el-form :inline="true" style="display: flex;align-items: center;flex-wrap: wrap;" >
        <el-form-item>
          <el-button
              type="primary"
              plain
              icon="Plus"
              @click="openDialog('add',{})"
          >新增</el-button>
        </el-form-item>
        <el-form-item label="课程名称:" >
          <el-input v-model="data.queryParams.name" placeholder="请输入课程名称"></el-input>
        </el-form-item>
        <el-form-item >
          <el-button
              type="primary"
              @click="getList"
          >查询</el-button>
          <el-button
              type="primary"
              plain
              @click="reset"
          >重置</el-button>
        </el-form-item>
      </el-form>
    </div>
    <!-- 表格数据 -->
    <el-table v-loading="loading" :data="dataList" :border="true">
@@ -71,17 +89,19 @@
              <el-button link type="primary" @click="toChapters(scope.row)">章节</el-button>
              <el-button link type="danger" @click="handleDelete(scope.row)">删除</el-button>
            </div>
            <div v-else>--</div>
            <div v-else><el-button link type="primary" @click="toChapters(scope.row)">章节</el-button></div>
          </div>
          <div v-else-if="!data.isAdmin">
            <div v-if="scope.row.state !== 2">
              <el-button link type="primary" v-if="scope.row.state == 0 || scope.row.state == 3" @click="submitApprove(scope.row)">提交审核</el-button>
              <el-button link type="primary" v-if="scope.row.state == 1" @click="submitApprove(scope.row)">取消审核</el-button>
              <el-button link type="primary" v-if="scope.row.state !== 1" @click="openDialog('edit',scope.row)" >编辑</el-button>
              <el-button link type="primary" v-if="scope.row.state !== 1" @click="toChapters(scope.row)">章节</el-button>
              <el-button link type="primary"  @click="toChapters(scope.row)">章节</el-button>
              <el-button link type="danger" v-if="scope.row.state !== 1" @click="handleDelete(scope.row)">删除</el-button>
            </div>
            <div v-else>--</div>
            <div v-else>
              <el-button link type="primary"  @click="toChapters(scope.row)">章节</el-button>
            </div>
          </div>
<!--          <div v-if="scope.row.state == 2">-->
@@ -136,21 +156,24 @@
<script setup>
import {getCurrentInstance, onMounted, onUnmounted, reactive, ref, toRefs} from "vue";
import {ElMessage, ElMessageBox} from "element-plus";
import {delCompany, getCompany} from "@/api/onlineEducation/company";
import courseManageDialog from  './components/courseManageDialog.vue'
import {delBanner, getBanner} from "@/api/onlineEducation/banner";
import {useRouter} from 'vue-router'
import {useRoute, useRouter} from 'vue-router'
import Cookies from "js-cookie";
import {changeCourseStatus, delCourse, doCourse, getCourse} from "@/api/onlineEducation/courseManage";
const { proxy } = getCurrentInstance();
const router = useRouter()
const loading = ref(false);
const dialogRef = ref();
const route = useRoute()
const data = reactive({
  queryParams: {
    pageNum: 1,
    pageSize: 10,
    name: ''
  },
  total: 0,
  dataList: [],
@@ -165,6 +188,13 @@
const { queryParams, total, dataList } = toRefs(data);
onMounted(async ()=>{
  if(route.query.val){
    const val = JSON.parse(route.query.val)
    if(val){
      data.queryParams.pageNum = val.pageNum;
      data.queryParams.pageSize = val.pageSize;
    }
  }
  const userInfo = JSON.parse(Cookies.get('userInfo'))
  console.log("userInfo",userInfo)
  if(userInfo.userType === 0){
@@ -203,7 +233,12 @@
/** 重置新增的表单以及其他数据  */
function reset() {
  proxy.resetForm("roleRef");
  data.queryParams = {
    pageNum: 1,
    pageSize: 10,
    name: ''
  }
  getList()
}
const handleDelete = (val) => {
  ElMessageBox.confirm(
@@ -288,7 +323,10 @@
  }
}
const toChapters = (val) => {
  router.push({ path: "/chapters", query: { courseId: val.id } });
  val.pageNum = data.queryParams.pageNum;
  val.pageSize = data.queryParams.pageSize
  const v = JSON.stringify(val)
  router.push({ path: "/chapters", query: { val: v } });
}
</script>