| | |
| | | <template> |
| | | <div>课程管理</div> |
| | | <div class="app-container"> |
| | | <div style="margin-bottom: 10px"> |
| | | <el-button |
| | | type="primary" |
| | | plain |
| | | icon="Plus" |
| | | @click="openDialog('add',{})" |
| | | >新增</el-button> |
| | | </div> |
| | | <!-- 表格数据 --> |
| | | <el-table v-loading="loading" :data="dataList" :border="true"> |
| | | <el-table-column label="序号" type="index" align="center" width="80" /> |
| | | <el-table-column label="封面" prop="logo" align="center" > |
| | | <template #default="scope"> |
| | | <div class="demo-image__preview" v-if="scope.row.logo && scope.row.logo.length>0"> |
| | | <el-image |
| | | style="width: 100px; height: 100px" |
| | | :src= "scope.row.logo[0]" |
| | | :zoom-rate="1.2" |
| | | :max-scale="7" |
| | | :min-scale="0.2" |
| | | :preview-src-list="scope.row.logo" |
| | | :initial-index="0" |
| | | fit="cover" |
| | | :preview-teleported=true |
| | | /> |
| | | </div> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="课程名称" prop="name" align="center" /> |
| | | <el-table-column label="课程分类" prop="categoryName" align="center" /> |
| | | <el-table-column label="要求课时" prop="period" align="center" /> |
| | | <el-table-column label="提交单位" prop="companyName" align="center" /> |
| | | <el-table-column label="审核状态" prop="state" align="center" > |
| | | <template #default="scope"> |
| | | <span>{{scope.row.state == 1?'待审核':scope.row.state == 2?'审批通过':'审批不通过'}}</span> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="创建时间" prop="createTime" align="center" width="180" /> |
| | | <el-table-column label="状态" prop="status" align="center" > |
| | | |
| | | <template #default="scope" v-if="data.isAdmin"> |
| | | <el-switch |
| | | v-if="scope.row.state == 2" |
| | | v-model="scope.row.status" |
| | | :active-value="0" |
| | | :inactive-value="1" |
| | | inline-prompt |
| | | active-text="正常" |
| | | inactive-text="停用" |
| | | @change="switchStatus($event,scope.row)" |
| | | /> |
| | | <span v-else>--</span> |
| | | </template> |
| | | <template #default="scope" v-else> |
| | | <span v-if="scope.row.state == 2">{{scope.row.status == 1? '停用' : '正常'}}</span> |
| | | <span v-else>--</span> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="180"> |
| | | <template #default="scope"> |
| | | <div v-if="scope.row.state == 2"> |
| | | <div v-if="data.isAdmin"> |
| | | <el-button link type="primary" @click="openDialog('edit',scope.row)">编辑</el-button> |
| | | <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> |
| | | <div v-else-if="scope.row.state == 1" > |
| | | <el-button link type="primary" @click="openDialog('edit',scope.row)">编辑</el-button> |
| | | <el-button link type="primary" v-if="data.isAdmin" @click="openApprove(scope.row)">审核</el-button> |
| | | <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-if="scope.row.state == 3" > |
| | | <div v-if="data.isAdmin">--</div> |
| | | <div v-else> |
| | | <el-button link type="primary" @click="openDialog('edit',scope.row)">编辑</el-button> |
| | | <el-button link type="primary" @click="submitApprove(scope.row)">提交审核</el-button> |
| | | <el-button link type="primary" @click="toChapters(scope.row)">章节</el-button> |
| | | <el-button link type="danger" @click="handleDelete(scope.row)">删除</el-button> |
| | | </div> |
| | | </div> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | |
| | | <pagination |
| | | v-show="total > 0" |
| | | :total="total" |
| | | v-model:page="queryParams.pageNum" |
| | | v-model:limit="queryParams.pageSize" |
| | | @pagination="getList" |
| | | /> |
| | | <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> |
| | | <template #footer> |
| | | <span class="dialog-footer"> |
| | | <el-button @click="data.appDialog = false">取消</el-button> |
| | | <el-button type="primary" @click="confirmApproval">确认</el-button> |
| | | </span> |
| | | </template> |
| | | </el-dialog> |
| | | </div> |
| | | </template> |
| | | |
| | | <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 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 data = reactive({ |
| | | queryParams: { |
| | | pageNum: 1, |
| | | pageSize: 10, |
| | | }, |
| | | total: 0, |
| | | dataList: [], |
| | | isAdmin: false, |
| | | appDialog: false, |
| | | appoveForm: { |
| | | id: null, |
| | | state: null |
| | | }, |
| | | }); |
| | | |
| | | const { queryParams, total, dataList } = toRefs(data); |
| | | |
| | | onMounted(async ()=>{ |
| | | const userInfo = JSON.parse(Cookies.get('userInfo')) |
| | | console.log("userInfo",userInfo) |
| | | if(userInfo.userType === 0){ |
| | | data.isAdmin = true; |
| | | }else { |
| | | data.isAdmin = false; |
| | | } |
| | | await getList() |
| | | }) |
| | | |
| | | onUnmounted(()=>{ |
| | | |
| | | }) |
| | | |
| | | const getList = async () => { |
| | | loading.value = true |
| | | const res = await getCourse(data.queryParams) |
| | | if(res.code == 200){ |
| | | data.dataList = res.data.list.map(item => { |
| | | return { |
| | | ...item, |
| | | logo: item.logo ?[import.meta.env.VITE_APP_BASE_API + "/" + item.logo] : [], |
| | | } |
| | | }) |
| | | console.log("ddd",data.dataList) |
| | | data.total = res.data.total |
| | | }else{ |
| | | ElMessage.warning(res.message) |
| | | } |
| | | loading.value = false |
| | | } |
| | | |
| | | const openDialog = (type, value) => { |
| | | dialogRef.value.openDialog(type, value); |
| | | } |
| | | |
| | | /** 重置新增的表单以及其他数据 */ |
| | | function reset() { |
| | | proxy.resetForm("roleRef"); |
| | | } |
| | | const handleDelete = (val) => { |
| | | ElMessageBox.confirm( |
| | | '确定删除此条数据?', |
| | | '提示', |
| | | { |
| | | confirmButtonText: '确定', |
| | | cancelButtonText: '取消', |
| | | type: 'warning', |
| | | }) |
| | | .then( async() => { |
| | | const res = await delCourse(val.id) |
| | | if(res.code == 200){ |
| | | ElMessage.success('数据删除成功') |
| | | await getList() |
| | | }else{ |
| | | ElMessage.warning(res.message) |
| | | } |
| | | }) |
| | | } |
| | | const switchStatus = (e,val) => { |
| | | ElMessageBox.confirm( |
| | | '确定修改该课程当前状态?', |
| | | '提示', |
| | | { |
| | | confirmButtonText: '确定', |
| | | cancelButtonText: '取消', |
| | | type: 'warning', |
| | | }) |
| | | .then( async() => { |
| | | const res = await changeCourseStatus({id: val.id,status: e}) |
| | | if(res.code == 200){ |
| | | ElMessage.success('状态修改成功') |
| | | await getList() |
| | | }else{ |
| | | ElMessage.warning(res.message) |
| | | } |
| | | }) |
| | | .catch(() => { |
| | | getList() |
| | | }) |
| | | |
| | | } |
| | | const openApprove = (val) => { |
| | | data.appoveForm = { |
| | | id: null, |
| | | state: null |
| | | } |
| | | data.appoveForm.id = val.id |
| | | data.appDialog = true |
| | | } |
| | | const confirmApproval = async () =>{ |
| | | if(data.appoveForm.state !== null){ |
| | | const res = await doCourse(data.appoveForm) |
| | | if(res.code == 200){ |
| | | ElMessage.success('审批成功') |
| | | await getList() |
| | | data.appDialog = false |
| | | }else{ |
| | | ElMessage.warning(res.message) |
| | | } |
| | | } |
| | | } |
| | | const submitApprove = async (val) => { |
| | | const param = { |
| | | id: val.id, |
| | | state: 1 |
| | | } |
| | | const res = await doCourse(param) |
| | | if(res.code == 200){ |
| | | ElMessage.success('提交成功') |
| | | await getList() |
| | | }else{ |
| | | ElMessage.warning(res.message) |
| | | } |
| | | } |
| | | const toChapters = (val) => { |
| | | router.push({ path: "/chapters", query: { courseId: val.id } }); |
| | | } |
| | | |
| | | </script> |
| | | |
| | | |
| | | |
| | | <style scoped lang="scss"> |
| | | |
| | | </style> |