123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 |
- <template>
- <div class="course-manage">
- <div class="part-box part-box-filter part-box-flex">
- <el-form ref="FilterForm" label-position="left" label-width="85px" inline>
- <el-form-item label="课程名称:">
- <el-input
- style="width: 142px;"
- v-model.trim="filter.courseName"
- placeholder="请输入内容"
- clearable
- ></el-input>
- </el-form-item>
- <el-form-item label="课程编码:">
- <el-input
- style="width: 142px;"
- v-model.trim="filter.courseCode"
- placeholder="请输入内容"
- clearable
- ></el-input>
- </el-form-item>
- <el-form-item>
- <el-button type="primary" icon="icon icon-search" @click="toPage(1)"
- >查询</el-button
- >
- </el-form-item>
- </el-form>
- <div class="part-box-action">
- <el-button type="warning" icon="icon icon-plus" @click="toAdd"
- >新增课程</el-button
- >
- </div>
- </div>
- <div class="part-box">
- <el-table ref="TableList" :data="courses" border stripe>
- <el-table-column prop="courseName" label="课程名称"></el-table-column>
- <el-table-column prop="courseCode" label="课程编码"></el-table-column>
- <el-table-column label="操作" align="center" width="120px">
- <template slot-scope="scope">
- <el-button
- class="btn-table-icon"
- type="text"
- icon="icon icon-edit"
- @click="toEdit(scope.row)"
- title="编辑"
- ></el-button>
- <el-button
- class="btn-table-icon"
- type="text"
- icon="icon icon-delete"
- @click="toDelete(scope.row)"
- title="删除"
- ></el-button>
- </template>
- </el-table-column>
- </el-table>
- <div class="part-page">
- <el-pagination
- background
- layout="prev, pager, next"
- :current-page="current"
- :total="total"
- :page-size="size"
- @current-change="toPage"
- >
- </el-pagination>
- </div>
- </div>
- <modify-course
- :instance="curCourse"
- @modified="getList"
- ref="ModifyCourse"
- ></modify-course>
- </div>
- </template>
- <script>
- import { courseListPage, deleteCourse } from "../api";
- import ModifyCourse from "../components/ModifyCourse";
- export default {
- name: "course-manage",
- components: { ModifyCourse },
- data() {
- return {
- filter: {
- courseName: "",
- courseCode: ""
- },
- current: 1,
- size: this.GLOBAL.pageSize,
- total: 0,
- courses: [],
- curCourse: {}
- };
- },
- created() {
- this.getList();
- },
- methods: {
- async getList() {
- const datas = {
- ...this.filter,
- pageNumber: this.current,
- pageSize: this.size
- };
- const data = await courseListPage(datas);
- this.courses = data.records;
- this.total = data.total;
- },
- toPage(page) {
- this.current = page;
- this.getList();
- },
- toAdd() {
- this.curCourse = {};
- this.$refs.ModifyCourse.open();
- },
- toEdit(row) {
- this.curCourse = row;
- this.$refs.ModifyCourse.open();
- },
- toDelete(row) {
- this.$confirm("确定要删除当前课程吗?", "提示", {
- cancelButtonClass: "el-button--danger is-plain",
- confirmButtonClass: "el-button--primary",
- type: "warning"
- }).then(async () => {
- await deleteCourse(row.id);
- this.$message.success("删除成功!");
- this.deletePageLastItem();
- });
- }
- }
- };
- </script>
|