xiangpei
2024-06-06 0f823d771d6a876c8990ad5b7dd80c835c38c53f
src/views/Manage/ClassManagement/Class.vue
@@ -94,7 +94,7 @@
                  <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 size="small" @click="handlerOpenNotify(scope.row)" type="info">通知</el-button>
                    <el-button @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>
@@ -114,6 +114,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 +181,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 +214,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 +238,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