fuliqi
2024-06-06 0af507deb2a8b08a606b795d73c660d02ecb7f49
src/views/Manage/ClassManagement/Class.vue
@@ -15,19 +15,25 @@
                @click="handlerAdd"
              >新增班级</el-button>
            </div>
            <div
              class="flex"
              style="align-items:center"
            >
              <p style="margin-left:20px;margin-right: 10px;">所在单位</p>
<!--              <el-select v-model="searchData.deptId">-->
<!--                <el-option></el-option>-->
<!--              </el-select>-->
            </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-form-item>
              <el-form-item label="班级状态">
                <el-select v-model="searchForm.status" 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'}"
@@ -40,11 +46,16 @@
                  width="180px"
                ></el-table-column>
                <el-table-column
                  label="年级"
                  label="状态"
                  align="center"
                  width="80px"
                  prop="grade"
                ></el-table-column>
                  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"
@@ -83,9 +94,9 @@
                  <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="routersTo()" size="small" type="success">成员管理</el-button>
                    <el-button @click="remove(scope.row.id)" type="danger" size="small">删除</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>
                </el-table-column>
              </el-table>
@@ -103,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"
@@ -151,17 +180,27 @@
</template>
<script>
import { addClasses, editClasses, getClassess, deleteClassesById } from "@/api/classes";
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,
      title: "",
      value: "",
      searchForm: {
        className:'',
        status: '',
        subject: null,
        pageSize: 10,
        pageNum: 1
@@ -174,6 +213,12 @@
        startTime: null,
        endTime: null,
        remark: ""
      },
      notifyRules: {
        notifyContent: [
          { required: true, message: '请输入通知内容', trigger: 'blur' },
          { min: 1, max: 500, message: '长度在 1 到 500 个字符', trigger: 'blur' }
        ],
      },
      rules: {
        className: [
@@ -193,10 +238,38 @@
    };
  },
  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
        this.total = res.data.total
        this.loading = false
      })
    },
    resetForm() {
@@ -231,9 +304,9 @@
        }
      });
    },
    remove(id) {
      deleteClassesById(id).then(res => {
        this.$message.success("删除成功")
    dissolution(id) {
      dissolution(id).then(res => {
        this.$message.success(res.data.message)
        this.page()
      })
    },
@@ -250,10 +323,8 @@
      this.title = "新增班级"
    },
    // 跳转(查看班级人员情况)
    routersTo() {
      this.$router.push({
        name: "ClassStaff",
      });
    studentManager(classesId) {
      this.$router.push({ path: "class-management/Class-staff", query: { classesId: classesId } });
    },
    // 返回上一个页面
    goBack() {