zhouwx
2024-08-05 4f6cdee3d3a9967b6955aacc354bf557430c0643
src/views/onlineEducation/courseManage/index.vue
@@ -1,12 +1,40 @@
<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 label="审核状态:" >
          <el-select v-model="data.queryParams.state" placeholder="请选择审核状态" clearable>
            <el-option
                v-for="item in data.stateList"
                :key="item.id"
                :label="item.name"
                :value="item.id">
            </el-option>
          </el-select>
        </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">
@@ -38,7 +66,16 @@
      <el-table-column label="提交单位" prop="companyName" align="center" />
      <el-table-column label="审核状态" prop="state" align="center" >
        <template #default="scope">
          <span>{{scope.row.state == 0?'待提交':scope.row.state == 1?'待审核':scope.row.state == 2?'审批通过':'审批不通过'}}</span>
          <el-tooltip
              v-if="scope.row.state == 3 && scope.row.message !=''"
              class="box-item"
              effect="dark"
              :content="scope.row.message"
              placement="top"
          >
            <span>审批不通过</span>
          </el-tooltip>
          <span v-else>{{scope.row.state == 0?'待提交':scope.row.state == 1?'待审核':scope.row.state == 2?'审批通过':'审批不通过'}}</span>
        </template>
      </el-table-column>
      <el-table-column label="创建时间" prop="createTime" align="center" width="180" />
@@ -71,17 +108,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">-->
@@ -120,10 +159,17 @@
    />
    <course-manage-dialog ref="dialogRef" @getList=getList></course-manage-dialog>
    <el-dialog v-model="data.appDialog" title="审批课程" width="30%" center align-center>
      <el-radio-group v-model="data.appoveForm.state" style="width: 100%">
        <el-radio :label="2" size="large" border>通过</el-radio>
        <el-radio :label="3" size="large" border>驳回</el-radio>
      </el-radio-group>
      <el-form>
        <el-form-item label="审批课程:">
          <el-radio-group v-model="data.appoveForm.state" style="width: 100%">
            <el-radio :label="2" size="large" border>通过</el-radio>
            <el-radio :label="3" size="large" border>驳回</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="审批意见:" v-if="data.appoveForm.state == 3">
          <el-input v-model="data.appoveForm.message"  type="textarea"  maxlength="50" show-word-limit placeholder="请输入审批意见"></el-input>
        </el-form-item>
      </el-form>
      <template #footer>
            <span class="dialog-footer">
              <el-button @click="data.appDialog = false">取消</el-button>
@@ -136,21 +182,25 @@
<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: '',
    state: null
  },
  total: 0,
  dataList: [],
@@ -158,13 +208,39 @@
  appDialog: false,
  appoveForm: {
    id: null,
    state: null
    state: null,
    message: ''
  },
  stateList: [
    {
      id: 0,
      name: '待提交'
    },
    {
      id: 1,
      name: '待审核'
    },
    {
      id: 2,
      name: '审批通过'
    },
    {
      id: 3,
      name: '审批不通过'
    },
  ]
});
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){
@@ -187,6 +263,7 @@
      return {
        ...item,
        logo: item.logo ?[import.meta.env.VITE_APP_BASE_API + "/" +  item.logo] : [],
        companyName: item.companyName ? item.companyName : '公开课'
      }
    })
    console.log("ddd",data.dataList)
@@ -203,7 +280,13 @@
/** 重置新增的表单以及其他数据  */
function reset() {
  proxy.resetForm("roleRef");
  data.queryParams = {
    pageNum: 1,
    pageSize: 10,
    name: '',
    state: null
  }
  getList()
}
const handleDelete = (val) => {
  ElMessageBox.confirm(
@@ -250,7 +333,8 @@
const openApprove  = (val) => {
  data.appoveForm = {
    id: null,
    state: null
    state: null,
    message: ''
  }
  data.appoveForm.id = val.id
  data.appDialog = true
@@ -288,7 +372,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>