|
@@ -16,6 +16,7 @@
|
16
|
16
|
<div v-for="item in schoolInfo.children" :key="item.id">
|
17
|
17
|
<div
|
18
|
18
|
:class="[
|
|
19
|
+ 'class_item',
|
19
|
20
|
curClass.id === item.id && curClass.type === item.type
|
20
|
21
|
? 'active'
|
21
|
22
|
: ''
|
|
@@ -25,6 +26,10 @@
|
25
|
26
|
>
|
26
|
27
|
{{ item.name }}
|
27
|
28
|
</div>
|
|
29
|
+ <span
|
|
30
|
+ @click="toOpenMenu(item, $event)"
|
|
31
|
+ class="ivu-icon iconfont icon-sandian"
|
|
32
|
+ ></span>
|
28
|
33
|
</div>
|
29
|
34
|
</div>
|
30
|
35
|
</div>
|
|
@@ -138,6 +143,45 @@
|
138
|
143
|
></Page>
|
139
|
144
|
</div>
|
140
|
145
|
</div>
|
|
146
|
+ <!-- 更多菜单弹窗 -->
|
|
147
|
+ <div
|
|
148
|
+ class="more_menu"
|
|
149
|
+ ref="moreMenuRef"
|
|
150
|
+ @mousedown.stop
|
|
151
|
+ @contextmenu.stop.prevent
|
|
152
|
+ @mousewheel.stop
|
|
153
|
+ >
|
|
154
|
+ <div @click="toSelectMenuItem(1)" class="menu_group">编辑</div>
|
|
155
|
+ <div @click="toSelectMenuItem(2)" class="menu_group">删除</div>
|
|
156
|
+ </div>
|
|
157
|
+ <!-- 编辑班级 -->
|
|
158
|
+ <Modal
|
|
159
|
+ v-model="classInfo.show"
|
|
160
|
+ :mask-closable="false"
|
|
161
|
+ class="modal_tip"
|
|
162
|
+ title="编辑"
|
|
163
|
+ >
|
|
164
|
+ <Form
|
|
165
|
+ v-if="classInfo.show"
|
|
166
|
+ ref="classInfo"
|
|
167
|
+ :model="classInfo"
|
|
168
|
+ :rules="rules"
|
|
169
|
+ :label-width="110"
|
|
170
|
+ >
|
|
171
|
+ <FormItem label="班级名称" prop="classname">
|
|
172
|
+ <Input
|
|
173
|
+ v-model.trim="classInfo.classname"
|
|
174
|
+ placeholder="请输入班级名称"
|
|
175
|
+ ></Input>
|
|
176
|
+ </FormItem>
|
|
177
|
+ </Form>
|
|
178
|
+ <div slot="footer" style="text-align: right">
|
|
179
|
+ <Button @click="exitInfo.show = false">取消</Button>
|
|
180
|
+ <Button @click="saveclassInfo()" type="primary" class="primary_btn"
|
|
181
|
+ >保存</Button
|
|
182
|
+ >
|
|
183
|
+ </div>
|
|
184
|
+ </Modal>
|
141
|
185
|
<!-- 已存在列表 -->
|
142
|
186
|
<Modal
|
143
|
187
|
v-model="exitInfo.show"
|
|
@@ -321,6 +365,8 @@
|
321
|
365
|
|
322
|
366
|
<script>
|
323
|
367
|
import {
|
|
368
|
+ class_delete,
|
|
369
|
+ class_edit,
|
324
|
370
|
class_list,
|
325
|
371
|
user_care,
|
326
|
372
|
user_delete,
|
|
@@ -333,9 +379,26 @@ import {
|
333
|
379
|
} from "@/api/school";
|
334
|
380
|
import { user_add, user_edit } from "@/api/school";
|
335
|
381
|
import { exportToExcel } from "@/utils/exportToExcel";
|
336
|
|
-import { generateRandomString, pwdCheck, reg} from "@/utils";
|
|
382
|
+import { generateRandomString, pwdCheck, reg } from "@/utils";
|
337
|
383
|
export default {
|
338
|
384
|
data() {
|
|
385
|
+ const classnameCheck = async (rule, value, callback) => {
|
|
386
|
+ if (value) {
|
|
387
|
+ let flag = this.schoolInfo.children.some((v) => {
|
|
388
|
+ return (
|
|
389
|
+ v.name === this.classInfo.classname &&
|
|
390
|
+ v.id != this.classInfo.classid
|
|
391
|
+ );
|
|
392
|
+ });
|
|
393
|
+ if (flag) {
|
|
394
|
+ return callback(new Error("班级名称已存在!"));
|
|
395
|
+ } else {
|
|
396
|
+ callback();
|
|
397
|
+ }
|
|
398
|
+ } else {
|
|
399
|
+ return callback(new Error("班级名称不能为空!"));
|
|
400
|
+ }
|
|
401
|
+ };
|
339
|
402
|
// 重复密码验证
|
340
|
403
|
const pwdAgainCheck = async (rule, value, callback) => {
|
341
|
404
|
if (!reg.test(value)) {
|
|
@@ -417,6 +480,13 @@ export default {
|
417
|
480
|
cardid: ""
|
418
|
481
|
},
|
419
|
482
|
rules: {
|
|
483
|
+ classname: [
|
|
484
|
+ {
|
|
485
|
+ required: true,
|
|
486
|
+ validator: classnameCheck,
|
|
487
|
+ trigger: "blur"
|
|
488
|
+ }
|
|
489
|
+ ],
|
420
|
490
|
username: [
|
421
|
491
|
{
|
422
|
492
|
required: true,
|
|
@@ -508,6 +578,8 @@ export default {
|
508
|
578
|
align: "center"
|
509
|
579
|
}
|
510
|
580
|
],
|
|
581
|
+ classInfo: {},
|
|
582
|
+ selectedModel: {},
|
511
|
583
|
schoolInfo: {
|
512
|
584
|
children: [],
|
513
|
585
|
name: ""
|
|
@@ -527,6 +599,91 @@ export default {
|
527
|
599
|
this.searchList();
|
528
|
600
|
},
|
529
|
601
|
methods: {
|
|
602
|
+ saveclassInfo() {
|
|
603
|
+ this.$refs.classInfo.validate((valid) => {
|
|
604
|
+ if (valid) {
|
|
605
|
+ this.showLoading = true;
|
|
606
|
+ class_edit({
|
|
607
|
+ classid: this.classInfo.classid,
|
|
608
|
+ classname: this.classInfo.classname,
|
|
609
|
+ rversion: this.classInfo.rversion
|
|
610
|
+ }).then((res) => {
|
|
611
|
+ this.showLoading = false;
|
|
612
|
+ if (res.code === 0) {
|
|
613
|
+ if (this.classInfo.classid === this.curClass.id) {
|
|
614
|
+ this.curClass.name = this.classInfo.classname;
|
|
615
|
+ }
|
|
616
|
+ this.classInfo.show = false;
|
|
617
|
+ this.init();
|
|
618
|
+ this.$Message.success(res.msg);
|
|
619
|
+ } else {
|
|
620
|
+ this.$Message.error(res.msg);
|
|
621
|
+ }
|
|
622
|
+ });
|
|
623
|
+ }
|
|
624
|
+ });
|
|
625
|
+ },
|
|
626
|
+ toSelectMenuItem(type) {
|
|
627
|
+ this.removeMoreMenu();
|
|
628
|
+ //type 1编辑 2删除
|
|
629
|
+ if (type === 1) {
|
|
630
|
+ this.classInfo = {
|
|
631
|
+ show: true,
|
|
632
|
+ classid: this.selectedModel.id,
|
|
633
|
+ rversion: this.selectedModel.rversion,
|
|
634
|
+ classname: this.selectedModel.name
|
|
635
|
+ };
|
|
636
|
+ } else {
|
|
637
|
+ this.$Modal.confirm({
|
|
638
|
+ title: "提示",
|
|
639
|
+ content: "您确定删除【" + this.selectedModel.name + "】吗?",
|
|
640
|
+ onOk: () => {
|
|
641
|
+ class_delete({
|
|
642
|
+ classid: this.selectedModel.id,
|
|
643
|
+ rversion: this.selectedModel.rversion
|
|
644
|
+ }).then((res) => {
|
|
645
|
+ if (res.code === 0) {
|
|
646
|
+ this.init();
|
|
647
|
+ this.$Message.success(res.msg);
|
|
648
|
+ } else {
|
|
649
|
+ this.$Message.error(res.msg);
|
|
650
|
+ }
|
|
651
|
+ });
|
|
652
|
+ },
|
|
653
|
+ onCancel: () => {}
|
|
654
|
+ });
|
|
655
|
+ }
|
|
656
|
+ },
|
|
657
|
+ // 打开弹窗菜单
|
|
658
|
+ toOpenMenu(Item, event) {
|
|
659
|
+ this.selectClass(Item);
|
|
660
|
+ if (!this.$refs.moreMenuRef) {
|
|
661
|
+ return;
|
|
662
|
+ }
|
|
663
|
+ this.selectedModel = Item;
|
|
664
|
+ let _clientX = event.clientX;
|
|
665
|
+ let _clientY = event.clientY;
|
|
666
|
+ this.$refs.moreMenuRef.style.display = `block`;
|
|
667
|
+ this.$nextTick(() => {
|
|
668
|
+ let _bodyHeight = document.body.clientHeight;
|
|
669
|
+ let _domHeight = this.$refs.moreMenuRef.getBoundingClientRect().height;
|
|
670
|
+ this.$refs.moreMenuRef.style.left = `${_clientX - 105}px`;
|
|
671
|
+ if (_clientY + _domHeight > _bodyHeight) {
|
|
672
|
+ this.$refs.moreMenuRef.style.top = `${_bodyHeight - _domHeight}px`;
|
|
673
|
+ } else {
|
|
674
|
+ this.$refs.moreMenuRef.style.top = `${_clientY}px`;
|
|
675
|
+ }
|
|
676
|
+ });
|
|
677
|
+ },
|
|
678
|
+ // 隐藏弹窗菜单
|
|
679
|
+ removeMoreMenu() {
|
|
680
|
+ if (!this.$refs.moreMenuRef) {
|
|
681
|
+ return;
|
|
682
|
+ }
|
|
683
|
+ this.$refs.moreMenuRef.style.display = `none`;
|
|
684
|
+ this.$refs.moreMenuRef.style.left = `-9999px`;
|
|
685
|
+ this.$refs.moreMenuRef.style.top = `-9999px`;
|
|
686
|
+ },
|
530
|
687
|
classChange() {
|
531
|
688
|
if (this.schoolInfo.children.length === 0) {
|
532
|
689
|
return;
|
|
@@ -767,7 +924,9 @@ export default {
|
767
|
924
|
this.showLoading = false;
|
768
|
925
|
if (res.code === 0) {
|
769
|
926
|
this.schoolInfo = res.obj;
|
770
|
|
- this.curClass = res.obj;
|
|
927
|
+ if (!this.curClass.id) {
|
|
928
|
+ this.curClass = res.obj;
|
|
929
|
+ }
|
771
|
930
|
} else {
|
772
|
931
|
this.$Message.error(res.msg);
|
773
|
932
|
}
|
|
@@ -846,6 +1005,19 @@ export default {
|
846
|
1005
|
height: 30px;
|
847
|
1006
|
text-align: center;
|
848
|
1007
|
cursor: pointer;
|
|
1008
|
+ position: relative;
|
|
1009
|
+ .icon-sandian {
|
|
1010
|
+ display: none;
|
|
1011
|
+ }
|
|
1012
|
+ &:hover {
|
|
1013
|
+ .icon-sandian {
|
|
1014
|
+ display: block;
|
|
1015
|
+ position: absolute;
|
|
1016
|
+ top: 4px;
|
|
1017
|
+ right: 6px;
|
|
1018
|
+ font-size: 24px;
|
|
1019
|
+ }
|
|
1020
|
+ }
|
849
|
1021
|
}
|
850
|
1022
|
}
|
851
|
1023
|
.active {
|
|
@@ -945,4 +1117,20 @@ export default {
|
945
|
1117
|
}
|
946
|
1118
|
}
|
947
|
1119
|
}
|
|
1120
|
+.more_menu {
|
|
1121
|
+ width: 100px;
|
|
1122
|
+ text-align: center;
|
|
1123
|
+ background: #ffffff;
|
|
1124
|
+ box-shadow: 0 8px 30px 0 #bcc9e380;
|
|
1125
|
+ border-radius: 10px;
|
|
1126
|
+ border: none;
|
|
1127
|
+ .menu_group {
|
|
1128
|
+ height: 35px;
|
|
1129
|
+ line-height: 35px;
|
|
1130
|
+ cursor: pointer;
|
|
1131
|
+ &:hover {
|
|
1132
|
+ background-color: #dbeeffcc;
|
|
1133
|
+ }
|
|
1134
|
+ }
|
|
1135
|
+}
|
948
|
1136
|
</style>
|