fuliqi
2024-10-17 0cefa99d2ae9ba43e60fe3e1beceb000dd186931
src/views/class-management/Class.vue
@@ -1,120 +1,128 @@
<!-- 班级管理 -->
<template>
  <div class="c">
    <div class="bg">
      <div class="main">
        <div class="main-1">
          <div
            class="main-btn flex"
            style="justify-content:space-between"
          >
            <div>
              <el-button
                type="primary"
                size="small"
                style="margin-right:20px;"
                @click="handlerAdd"
              >新增班级</el-button>
            </div>
            <el-form :inline="true" :model="searchForm" class="demo-form-inline">
              <el-form-item label="班级名称">
                <el-input v-model="searchForm.className" size="small" clearable @clear="page" placeholder="班级名称"></el-input>
              </el-form-item>
              <el-form-item label="班级状态">
                <el-select v-model="searchForm.status" size="small" clearable @change="page" placeholder="班级状态">
                  <el-option label="正常" value="normal"></el-option>
                  <el-option label="解散" value="dissolution"></el-option>
                </el-select>
              </el-form-item>
              <el-form-item>
                <el-button type="primary" @click="page">查询</el-button>
              </el-form-item>
            </el-form>
          </div>
          <div>
            <div>
              <el-table
                v-loading="loading"
                :data="tableData"
                border
                :row-style="{height:'42px'}"
                :cell-style="{padding: '0'}"
              >
                <el-table-column
                  align="center"
                  label="班级"
                  prop="className"
                  width="180px"
                ></el-table-column>
                <el-table-column
                  label="状态"
                  align="center"
                  width="80px"
                  prop="status"
                >
                  <template slot-scope="scope">
                    <el-tag v-if="scope.row.status === '正常'" type="success">{{scope.row.status}}</el-tag>
                    <el-tag v-if="scope.row.status === '解散'" type="danger">{{scope.row.status}}</el-tag>
                  </template>
                </el-table-column>
                <el-table-column
                  width="100px"
                  align="center"
                  label="单位"
                  prop="unit"
                ></el-table-column>
                <el-table-column
                  align="center"
                  width="100px"
                  label="教师"
                  prop="createUserName"
                ></el-table-column>
                <el-table-column
                  align="center"
                  width="120px"
                  label="联系电话"
                  prop="teacherPhone"
                ></el-table-column>
                <el-table-column
                  width="140px"
                  label="开班时间"
                  align="center"
                  prop="startTime"
                ></el-table-column>
                <el-table-column
                  width="140px"
                  label="结束时间"
                  align="center"
                  prop="endTime"
                ></el-table-column>
                <el-table-column
                  label="操作"
                  align="center"
                  fixed="right"
                >
                  <template slot-scope="scope">
                    <el-button v-if="scope.row.status !== '解散'" size="small" @click="handlerEdit(scope.row)" type="primary">修改</el-button>
                    <el-button v-if="scope.row.status !== '解散'" size="small" type="warning">班级验证</el-button>
                    <el-button v-if="scope.row.status !== '解散'" size="small" @click="handlerOpenNotify(scope.row)" type="info">通知</el-button>
                    <el-button v-if="scope.row.status !== '解散'" @click="studentManager(scope.row.id)" size="small" type="success">成员管理</el-button>
                    <el-button v-if="scope.row.status !== '解散'" @click="dissolution(scope.row.id)" type="danger" size="small">解散</el-button>
                  </template>
                </el-table-column>
              </el-table>
            </div>
            <div
              class="flex"
              style="justify-content:center;margin-top:20px;"
            >
              <pagination v-show="total>0" :total="total" :page.sync="searchForm.pageIndex" :limit.sync="searchForm.pageSize"
                          @pagination="page"/>
            </div>
          </div>
        </div>
  <div class="app-container">
    <div style="display: flex;flex-direction: row">
      <div style="margin-right:10px;">
        <el-button
          type="primary"
          size="small"
          @click="handlerAdd"
        >新增班级
        </el-button>
      </div>
    <div>
      <el-form :inline="true" :model="searchForm" class="demo-form-inline">
        <el-form-item label="班级名称">
          <el-input v-model="searchForm.className" size="small" clearable @clear="page"
                    placeholder="班级名称"></el-input>
        </el-form-item>
        <el-form-item label="班级状态">
          <el-select v-model="searchForm.status" size="small" clearable @change="page" placeholder="班级状态">
            <el-option label="正常" value="normal"></el-option>
            <el-option label="解散" value="dissolution"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="page">查询</el-button>
        </el-form-item>
      </el-form>
    </div>
    </div>
    <el-table
      v-loading="loading"
      :data="tableData"
      border
      :row-style="{height:'42px'}"
      :cell-style="{padding: '0'}"
    >
      <el-table-column
        align="center"
        label="班级"
        prop="className"
        width="180px"
      ></el-table-column>
      <el-table-column
        label="状态"
        align="center"
        width="80px"
        prop="status"
      >
        <template slot-scope="scope">
          <el-tag v-if="scope.row.status === '正常'" type="success">{{ scope.row.status }}</el-tag>
          <el-tag v-if="scope.row.status === '解散'" type="danger">{{ scope.row.status }}</el-tag>
        </template>
      </el-table-column>
<!--      <el-table-column-->
<!--        width="100px"-->
<!--        align="center"-->
<!--        label="单位"-->
<!--        prop="unit"-->
<!--      ></el-table-column>-->
      <el-table-column
        align="center"
        width="100px"
        label="教师"
        prop="createUserName"
      ></el-table-column>
<!--      <el-table-column-->
<!--        align="center"-->
<!--        width="120px"-->
<!--        label="联系电话"-->
<!--        prop="teacherPhone"-->
<!--      ></el-table-column>-->
      <el-table-column
        width="140px"
        label="开班时间"
        align="center"
        prop="startTime"
      ></el-table-column>
      <el-table-column
        width="140px"
        label="结束时间"
        align="center"
        prop="endTime"
      ></el-table-column>
      <el-table-column
        label="操作"
        align="center"
        fixed="right"
      >
        <template slot-scope="scope">
          <el-button v-if="scope.row.status !== '解散'" size="small" @click="handlerEdit(scope.row)"
                     type="primary">修改
          </el-button>
          <el-button v-if="scope.row.status !== '解散'" size="small" type="warning">班级验证</el-button>
          <el-button v-if="scope.row.status !== '解散'" size="small" @click="handlerOpenNotify(scope.row)"
                     type="info">通知
          </el-button>
          <el-button v-if="scope.row.status !== '解散'" @click="studentManager(scope.row.id)" size="small"
                     type="success">成员管理
          </el-button>
          <el-popconfirm
            class="confirm"
            title="确定要解散该班级?"
            @confirm="dissolution(scope.row.id)"
          >
            <el-button slot="reference" v-if="scope.row.status !== '解散'" type="danger"
                       size="small">解散
            </el-button>
          </el-popconfirm>
          <el-popconfirm
            class="confirm"
            title="确定要恢复该班级吗?"
            @confirm="recover(scope.row.id)"
          >
            <el-button slot="reference" v-if="scope.row.status === '解散'" type="success"
                       size="small">恢复正常
            </el-button>
          </el-popconfirm>
        </template>
      </el-table-column>
    </el-table>
      <pagination v-show="total>0" :total="total" :page.sync="searchForm.pageIndex"
                  :limit.sync="searchForm.pageSize"
                  @pagination="page"/>
    <el-dialog
      title="班级通知"
      :visible.sync="notifyOpen"
@@ -122,7 +130,7 @@
      :before-close="handleClose">
      <el-form :model="notifyForm" :rules="notifyRules" ref="notifyForm" label-width="100px" class="demo-ruleForm">
        <el-form-item label="通知班级:" prop="className">
          <span>{{notifyForm.className}}</span>
          <span>{{ notifyForm.className }}</span>
        </el-form-item>
        <el-form-item label="通知内容:" prop="notifyContent">
          <el-input type="textarea" v-model="notifyForm.notifyContent" size="small"></el-input>
@@ -181,12 +189,13 @@
</template>
<script>
import { addClasses, editClasses, getClassess, dissolution } from "@/api/classes";
import { addClassesNotify } from "@/api/classesNotify";
import Pagination from "@/components/Pagination"
import { addClasses, editClasses, getClassess, dissolution, recover } from '@/api/classes'
import { addClassesNotify } from '@/api/classesNotify'
import Pagination from '@/components/Pagination'
export default {
  components: {Pagination},
  data() {
  components: { Pagination },
  data () {
    return {
      notifyOpen: false,
      notifyForm: {
@@ -197,10 +206,10 @@
      loading: true,
      total: 0,
      open: false,
      title: "",
      value: "",
      title: '',
      value: '',
      searchForm: {
        className:'',
        className: '',
        status: '',
        subject: null,
        pageSize: 10,
@@ -208,12 +217,12 @@
      },
      form: {
        id: null,
        className: "",
        status: "",
        verifyStatus: "",
        className: '',
        status: '',
        verifyStatus: '',
        startTime: null,
        endTime: null,
        remark: ""
        remark: ''
      },
      notifyRules: {
        notifyContent: [
@@ -233,18 +242,16 @@
          { required: true, message: '请选择班级结束时间', trigger: 'change' },
        ],
      },
      tableData: [
      ],
    };
      tableData: [],
    }
  },
  methods: {
    handlerOpenNotify(row) {
    handlerOpenNotify (row) {
      this.notifyOpen = true
      this.notifyForm.className = row.className
      this.notifyForm.classesId = row.id
    },
    submitNotifyForm() {
    submitNotifyForm () {
      this.$refs['notifyForm'].validate((valid) => {
        if (valid) {
          let _this = this
@@ -256,97 +263,108 @@
        }
      })
    },
    clearNotifyForm() {
    clearNotifyForm () {
      this.notifyForm = {
        className: '',
        notifyContent: ''
      }
    },
    handleNotifyClose() {
    handleNotifyClose () {
      this.notifyOpen = false
      this.clearNotifyForm()
    },
    page() {
    page () {
      getClassess(this.searchForm).then(res => {
        this.tableData = res.data.data
        this.total = res.data.total
        this.loading = false
      })
    },
    resetForm() {
    resetForm () {
      this.form = {
        id: null,
        className: "",
        status: "",
        verifyStatus: "",
        className: '',
        status: '',
        verifyStatus: '',
        startTime: null,
        endTime: null,
        remark: ""
        remark: ''
      }
    },
    submitForm() {
    submitForm () {
      this.$refs['form'].validate((valid) => {
        if (valid) {
          if (this.form.id) {
            editClasses(this.form).then(res => {
              this.$message.success("修改成功")
              this.$message.success('修改成功')
              this.resetForm()
              this.open = false
              this.page()
            })
          } else {
            addClasses(this.form).then(res => {
              this.$message.success("添加班级成功")
              this.$message.success('添加班级成功')
              this.resetForm()
              this.open = false
              this.page()
            })
          }
        } else {
          return false;
          return false
        }
      });
      })
    },
    dissolution(id) {
    dissolution (id) {
      dissolution(id).then(res => {
        this.$message.success(res.data.message)
        this.page()
      })
    },
    handlerEdit(row) {
      this.form = row;
    recover(id) {
      recover(id).then(res => {
        this.$message.success(res.data.message)
        this.page()
      })
    },
    handlerEdit (row) {
      this.form = row
      this.open = true
    },
    handleClose() {
    handleClose () {
      this.open = false
      this.resetForm()
    },
    handlerAdd() {
    handlerAdd () {
      this.open = true
      this.title = "新增班级"
      this.title = '新增班级'
    },
    // 跳转(查看班级人员情况)
    studentManager(classesId) {
      this.$router.push({ path: "class-management/Class-staff", query: { classesId: classesId } });
    studentManager (classesId) {
      this.$router.push({ path: '/classes/class-management/Class-staff', query: { classesId: classesId } })
    },
    // 返回上一个页面
    goBack() {
      this.$router.back();
    goBack () {
      this.$router.back()
    },
  },
  created() {
  created () {
    this.page()
  },
};
}
</script>
<style scoped lang="scss">
.confirm {
  margin-left: 5px;
}
.flex {
  display: flex;
}
.mian-1-top {
  margin: 10px 0;
  align-items: center;
  & input {
    height: 30px;
    width: 200px;
@@ -359,10 +377,12 @@
    border-left: 5px solid rgb(16, 71, 247);
    padding-left: 10px;
    margin: 30px 0;
    & p {
      font-weight: 700;
    }
  }
  &-1 {
    width: 1227px;
    // height: 784px;
@@ -371,15 +391,18 @@
    border-radius: 10px;
    padding: 32px 40px;
  }
  &-btn {
    padding-bottom: 10px;
    border-bottom: 3px solid rgb(16, 71, 247);
  }
}
.deepBlue {
  background: rgb(16, 71, 247);
  color: white;
  border: none;
  &:hover {
    background-color: rgb(45, 92, 248);
  }