xiangpei
2024-06-06 7b4983738f986bf28cb12c9a30dcbc4d593ad6a5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
<!-- 班级管理 -->
<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"
                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-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'}"
                :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 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>
            </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>
 
    </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: "",
      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: [
 
      ],
    };
  },
  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() {
      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>
 
<style scoped lang="scss">
.flex {
  display: flex;
}
.mian-1-top {
  margin: 10px 0;
  align-items: center;
  & input {
    height: 30px;
    width: 200px;
    margin-right: 20px;
  }
}
 
.main {
  &-title {
    border-left: 5px solid rgb(16, 71, 247);
    padding-left: 10px;
    margin: 30px 0;
    & p {
      font-weight: 700;
    }
  }
  &-1 {
    width: 1227px;
    // height: 784px;
    background: white;
    box-shadow: 1px 1px 1px 1px rgba(0, 0, 0, 0.1);
    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);
  }
}
</style>