zhouwx
2025-06-10 c8c99bf1f753e27c4d99a0ff6058ce16f973f9c4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<template>
  <div class="app-container">
    <div>
      <el-form style="display: flex;flex-wrap: wrap">
        <el-form-item>
          <el-button type="primary" plain @click="openDialog('addFirst',{})" icon="Plus"> 添加</el-button>
        </el-form-item>
      </el-form>
    </div>
<!--    <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: '',
  },
  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>