| | |
| | | <template> |
| | | <div>课程分类</div> |
| | | <div class="app-container"> |
| | | <div style="margin-bottom: 10px"> |
| | | <el-form> |
| | | <el-form-item label="分类名称"> |
| | | <el-input style="width: 20%" v-model="data.queryParams.name "></el-input> |
| | | <el-button type="primary" style="margin-left: 30px" @click="getList">查询</el-button> |
| | | <el-button plain @click="reset">重置</el-button> |
| | | <el-button type="success" plain @click="openDialog('addFirst',{})">添加</el-button> |
| | | </el-form-item> |
| | | |
| | | </el-form> |
| | | </div> |
| | | <!-- 表格数据 --> |
| | | <el-table v-loading="loading" :data="dataList" :border="true" row-key="id"> |
| | | <el-table-column label="序号" type="index" align="center" width="80" /> |
| | | <el-table-column label="名称" > |
| | | <template #default="scope"> |
| | | <span>{{scope.row.name}}</span> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="排序" prop="sort" align="center" width="80" /> |
| | | <el-table-column label="状态" prop="status" align="center" width="80"> |
| | | <template #default="scope"> |
| | | <span>{{scope.row.status ==0 ? '正常' : '停用'}}</span> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="250" > |
| | | <template #default="scope"> |
| | | <el-button type="success" plain @click="openDialog('add',scope.row)">添加</el-button> |
| | | <el-button type="primary" plain @click="openDialog('edit',scope.row)">编辑</el-button> |
| | | <el-button type="danger" plain @click="handleDelete(scope.row.id)">删除</el-button> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | <class-dialog ref="areaRef" @getList="getList"></class-dialog> |
| | | </div> |
| | | </template> |
| | | |
| | | <script setup> |
| | | import {getCurrentInstance, onMounted, reactive, ref, toRefs} from "vue"; |
| | | import {ElMessage, ElMessageBox} from "element-plus"; |
| | | import classDialog from "./components/courseClassDialog.vue" |
| | | import {delArea, getArea} from "@/api/backManage/area"; |
| | | import {getDictList} from "@/api/backManage/evaluate"; |
| | | import {delMonitor} from "@/api/sysUsers"; |
| | | import {delClassification, getClassification} from "@/api/onlineEducation/courseClass"; |
| | | const { proxy } = getCurrentInstance(); |
| | | const loading = ref(false); |
| | | const areaRef = ref(); |
| | | const cityList = ref([]) |
| | | const data = reactive({ |
| | | queryParams: { |
| | | name: '', |
| | | pageNum: 1, |
| | | pageSize: 10, |
| | | }, |
| | | total: 0, |
| | | dataList: [ |
| | | ] |
| | | }); |
| | | |
| | | const { queryParams, total, dataList } = toRefs(data); |
| | | |
| | | //页面加载 |
| | | onMounted(() => { |
| | | getList(); |
| | | }); |
| | | const getList = async () => { |
| | | loading.value = true; |
| | | const res = await getClassification(data.queryParams); |
| | | if(res.code === 200){ |
| | | dataList.value = res.data |
| | | }else{ |
| | | ElMessage.warning(res.message) |
| | | } |
| | | loading.value = false; |
| | | } |
| | | |
| | | const openDialog = (type, value) => { |
| | | areaRef.value.openDialog(type, value); |
| | | } |
| | | |
| | | /** 重置新增的表单以及其他数据 */ |
| | | function reset() { |
| | | data.queryParams.name = ''; |
| | | data.queryParams.pageNum = 1; |
| | | getList(); |
| | | } |
| | | const handleDelete = (val) => { |
| | | ElMessageBox.confirm( |
| | | '确定删除此条数据?', |
| | | '提示', |
| | | { |
| | | confirmButtonText: '确定', |
| | | cancelButtonText: '取消', |
| | | type: 'warning', |
| | | }) |
| | | .then( async() => { |
| | | const res = await delClassification(val) |
| | | if(res.code == 200){ |
| | | ElMessage.success('数据删除成功') |
| | | await getList() |
| | | }else{ |
| | | ElMessage.warning(res.message) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | |
| | | </script> |
| | | |
| | | |
| | | |
| | | <style scoped lang="scss"> |
| | | |
| | | </style> |