xiangpei
2024-06-12 6aa908b81913d780d4dda66cab1c5a1ffbf14752
src/views/Manage/ClassManagement/Class.vue
@@ -11,16 +11,17 @@
            <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" clearable @clear="page" placeholder="班级名称"></el-input>
                <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" clearable @change="page" placeholder="班级状态">
                <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>
@@ -92,10 +93,10 @@
                  fixed="right"
                >
                  <template slot-scope="scope">
                    <el-button size="small" @click="handlerEdit(scope.row)" type="primary">修改</el-button>
                    <el-button size="small" type="warning">班级验证</el-button>
                    <el-button size="small" type="info">通知</el-button>
                    <el-button @click="studentManager(scope.row.id)" size="small" type="success">成员管理</el-button>
                    <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>
@@ -114,6 +115,24 @@
    </div>
    <el-dialog
      title="班级通知"
      :visible.sync="notifyOpen"
      width="600px"
      :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>
        </el-form-item>
        <el-form-item label="通知内容:" prop="notifyContent">
          <el-input type="textarea" v-model="notifyForm.notifyContent" size="small"></el-input>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="handleNotifyClose">取 消</el-button>
        <el-button type="primary" @click="submitNotifyForm">确 定</el-button>
      </span>
    </el-dialog>
    <el-dialog
      :title="title"
@@ -163,11 +182,18 @@
<script>
import { addClasses, editClasses, getClassess, dissolution } from "@/api/classes";
import { addClassesNotify } from "@/api/classesNotify";
import Pagination from "@/components/Pagination"
export default {
  components: {Pagination},
  data() {
    return {
      notifyOpen: false,
      notifyForm: {
        className: '',
        notifyContent: '',
        classesId: null
      },
      loading: true,
      total: 0,
      open: false,
@@ -189,6 +215,12 @@
        endTime: null,
        remark: ""
      },
      notifyRules: {
        notifyContent: [
          { required: true, message: '请输入通知内容', trigger: 'blur' },
          { min: 1, max: 500, message: '长度在 1 到 500 个字符', trigger: 'blur' }
        ],
      },
      rules: {
        className: [
          { required: true, message: '请输入班级名称', trigger: 'blur' },
@@ -207,6 +239,33 @@
    };
  },
  methods: {
    handlerOpenNotify(row) {
      this.notifyOpen = true
      this.notifyForm.className = row.className
      this.notifyForm.classesId = row.id
    },
    submitNotifyForm() {
      this.$refs['notifyForm'].validate((valid) => {
        if (valid) {
          let _this = this
          addClassesNotify(_this.notifyForm).then(res => {
            this.$message.success(res.data.message)
            this.notifyOpen = false
            this.clearNotifyForm()
          })
        }
      })
    },
    clearNotifyForm() {
      this.notifyForm = {
        className: '',
        notifyContent: ''
      }
    },
    handleNotifyClose() {
      this.notifyOpen = false
      this.clearNotifyForm()
    },
    page() {
      getClassess(this.searchForm).then(res => {
        this.tableData = res.data.data
@@ -233,12 +292,14 @@
              this.$message.success("修改成功")
              this.resetForm()
              this.open = false
              this.page()
            })
          } else {
            addClasses(this.form).then(res => {
              this.$message.success("添加班级成功")
              this.resetForm()
              this.open = false
              this.page()
            })
          }
        } else {