xiangpei
2024-06-06 0f823d771d6a876c8990ad5b7dd80c835c38c53f
src/views/Manage/ClassManagement/Class.vue
@@ -3,36 +3,37 @@
  <div class="c">
    <div class="bg">
      <div class="main">
        <TitleIndex title='班级管理' />
        <div class="main-1">
          <div
            class="main-btn flex"
            style="justify-content:space-between"
          >
            <div>
              <s-button
                colorType="deepBlue"
              <el-button
                type="primary"
                style="margin-right:20px;"
                @click="$router.push('/manage/class-management/Class-staff')"
              >新增班级</s-button>
                @click="handlerAdd"
              >新增班级</el-button>
            </div>
            <div
              class="flex"
              style="align-items:center"
            >
              <p style="padding-right:10px">排序方式</p>
              <el-select>
                <el-option></el-option>
              </el-select>
              <p style="margin-left:20px;margin-right: 10px;">所在单位</p>
              <el-select>
                <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'}"
@@ -41,15 +42,20 @@
                <el-table-column
                  align="center"
                  label="班级"
                  prop="class"
                  width="80px"
                  prop="className"
                  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"
@@ -60,48 +66,37 @@
                  align="center"
                  width="100px"
                  label="教师"
                  prop="teacher"
                  prop="createUserName"
                ></el-table-column>
                <el-table-column
                  align="center"
                  width="120px"
                  label="联系电话"
                  prop="phone"
                  prop="teacherPhone"
                ></el-table-column>
                <el-table-column
                  width="140px"
                  label="电子邮件"
                  align="center"
                  prop="email"
                ></el-table-column>
                <el-table-column
                  width="90px"
                  label="开班时间"
                  align="center"
                  prop="openingTime"
                  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>班级验证</el-button>
                    <el-button>通知</el-button>
                    <el-button @click="routersTo()">成员管理</el-button>
                    <el-button>添加成员</el-button>
                    <el-select
                      v-model="value"
                      style="width:74px;margin-left: 10px;"
                      placeholder="选择"
                    >
                      <el-option
                        v-for="item in options"
                        :key="item.value"
                        :label="item.label"
                        :value="item.value"
                      >
                      </el-option>
                    </el-select>
                    <el-button size="small" @click="handlerEdit(scope.row)" type="primary">修改</el-button>
                    <el-button size="small" type="warning">班级验证</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>
@@ -110,135 +105,234 @@
              class="flex"
              style="justify-content:center;margin-top:20px;"
            >
              <el-pagination
                background
                layout="prev, pager, next"
                :total="1000"
              >
              </el-pagination>
              <pagination v-show="total>0" :total="total" :page.sync="searchForm.pageIndex" :limit.sync="searchForm.pageSize"
                          @pagination="page"/>
            </div>
          </div>
        </div>
      </div>
    </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"
      :visible.sync="open"
      width="700px"
      :before-close="handleClose">
      <el-form :model="form" :rules="rules" ref="form" label-width="100px" class="demo-ruleForm">
        <el-form-item label="班级名称" prop="className">
          <el-input v-model="form.className" size="small"></el-input>
        </el-form-item>
        <el-form-item label="班级时间" required>
          <el-col :span="11">
            <el-form-item prop="startTime">
              <el-date-picker
                v-model="form.startTime"
                type="date"
                value-format="yyyy-MM-dd"
                placeholder="开始日期">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col class="line" :span="2">-</el-col>
          <el-col :span="11">
            <el-form-item prop="endTime">
              <el-date-picker
                v-model="form.endTime"
                type="date"
                value-format="yyyy-MM-dd"
                placeholder="结束日期">
              </el-date-picker>
            </el-form-item>
          </el-col>
        </el-form-item>
        <el-form-item label="备注信息" prop="remark">
          <el-input type="textarea" v-model="form.remark" size="small"></el-input>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="handleClose">取 消</el-button>
        <el-button type="primary" @click="submitForm">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>
<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,
      title: "",
      value: "",
      searchData: {
      searchForm: {
        className:'',
        status: '',
        subject: null,
        pageSize: 10,
        pageNum: 1
      },
      form: {
        id: null,
        className: "",
        status: "",
        verifyStatus: "",
        startTime: null,
        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' },
          { min: 1, max: 30, message: '长度在 1 到 30 个字符', trigger: 'blur' }
        ],
        startTime: [
          { required: true, message: '请选择班级开始时间', trigger: 'change' },
        ],
        endTime: [
          { required: true, message: '请选择班级结束时间', trigger: 'change' },
        ],
      },
      tableData: [
        {
          class: "软件工程",
          grade: "2019级",
          unit: "螺丝部",
          teacher: "秋梨膏",
          phone: "182-9384-9302",
          email: "info@exaple.com",
          openingTime: "2022/3/29",
        },
        {
          class: "软件工程",
          grade: "2019级",
          unit: "螺丝部",
          teacher: "秋梨膏",
          phone: "182-9384-9302",
          email: "info@exaple.com",
          openingTime: "2022/3/29",
        },
        {
          class: "软件工程",
          grade: "2019级",
          unit: "螺丝部",
          teacher: "秋梨膏",
          phone: "182-9384-9302",
          email: "info@exaple.com",
          openingTime: "2022/3/29",
        },
        {
          class: "软件工程",
          grade: "2019级",
          unit: "螺丝部",
          teacher: "秋梨膏",
          phone: "182-9384-9302",
          email: "info@exaple.com",
          openingTime: "2022/3/29",
        },
        {
          class: "软件工程",
          grade: "2019级",
          unit: "螺丝部",
          teacher: "秋梨膏",
          phone: "182-9384-9302",
          email: "info@exaple.com",
          openingTime: "2022/3/29",
        },
        {
          class: "软件工程",
          grade: "2019级",
          unit: "螺丝部",
          teacher: "秋梨膏",
          phone: "182-9384-9302",
          email: "info@exaple.com",
          openingTime: "2022/3/29",
        },
        {
          class: "软件工程",
          grade: "2019级",
          unit: "螺丝部",
          teacher: "秋梨膏",
          phone: "182-9384-9302",
          email: "info@exaple.com",
          openingTime: "2022/3/29",
        },
        {
          class: "软件工程",
          grade: "2019级",
          unit: "螺丝部",
          teacher: "秋梨膏",
          phone: "182-9384-9302",
          email: "info@exaple.com",
          openingTime: "2022/3/29",
        },
        {
          class: "软件工程",
          grade: "2019级",
          unit: "螺丝部",
          teacher: "秋梨膏",
          phone: "182-9384-9302",
          email: "info@exaple.com",
          openingTime: "2022/3/29",
        },
      ],
      pageData: {
        size: 7,
        page: 1,
      },
    };
  },
  methods: {
    // // 查看详情
    // detailsTo() {
    //   this.$router.push({
    //     name: "teacherDetail",
    //   });
    // },
    // 跳转(查看班级人员情况)
    routersTo() {
      this.$router.push({
        name: "ClassStaff",
    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() {
      this.form = {
        id: null,
        className: "",
        status: "",
        verifyStatus: "",
        startTime: null,
        endTime: null,
        remark: ""
      }
    },
    submitForm() {
      this.$refs['form'].validate((valid) => {
        if (valid) {
          if (this.form.id) {
            editClasses(this.form).then(res => {
              this.$message.success("修改成功")
              this.resetForm()
              this.open = false
            })
          } else {
            addClasses(this.form).then(res => {
              this.$message.success("添加班级成功")
              this.resetForm()
              this.open = false
            })
          }
        } else {
          return false;
        }
      });
    },
    dissolution(id) {
      dissolution(id).then(res => {
        this.$message.success(res.data.message)
        this.page()
      })
    },
    handlerEdit(row) {
      this.form = row;
      this.open = true
    },
    handleClose() {
      this.open = false
      this.resetForm()
    },
    handlerAdd() {
      this.open = true
      this.title = "新增班级"
    },
    // 跳转(查看班级人员情况)
    studentManager(classesId) {
      this.$router.push({ path: "class-management/Class-staff", query: { classesId: classesId } });
    },
    // 返回上一个页面
    goBack() {
      this.$router.back();
    },
  },
  created() {
    this.page()
  },
};
</script>
@@ -287,4 +381,4 @@
    background-color: rgb(45, 92, 248);
  }
}
</style>
</style>