Commit 183bfae83d23f29a1489b86e9c15b0fdeef4eac6
1 parent
191d5bfa
设备修改班级选择调整
Showing
1 changed file
with
33 additions
and
25 deletions
src/views/device/index.vue
@@ -462,7 +462,11 @@ | @@ -462,7 +462,11 @@ | ||
462 | clearable | 462 | clearable |
463 | v-model="form.classIds" | 463 | v-model="form.classIds" |
464 | :options="gradeList" | 464 | :options="gradeList" |
465 | - :props="{ expandTrigger: 'hover' }" | 465 | + :props="{ |
466 | + multiple: true, | ||
467 | + checkStrictly: false, | ||
468 | + }" | ||
469 | + collapse-tags | ||
466 | :show-all-levels="false" | 470 | :show-all-levels="false" |
467 | ></el-cascader> | 471 | ></el-cascader> |
468 | </el-col> | 472 | </el-col> |
@@ -559,7 +563,7 @@ export default { | @@ -559,7 +563,7 @@ export default { | ||
559 | sn: "", | 563 | sn: "", |
560 | frequency: "", | 564 | frequency: "", |
561 | pairingCode: "", | 565 | pairingCode: "", |
562 | - classIds: "", | 566 | + classIds: [], |
563 | roomName: "", | 567 | roomName: "", |
564 | }, | 568 | }, |
565 | formRules: { | 569 | formRules: { |
@@ -568,7 +572,7 @@ export default { | @@ -568,7 +572,7 @@ export default { | ||
568 | pairingCode: [ | 572 | pairingCode: [ |
569 | { required: true, message: "请输入配对码", trigger: "blur" }, | 573 | { required: true, message: "请输入配对码", trigger: "blur" }, |
570 | ], | 574 | ], |
571 | - classIds: [{ required: true, message: "请选择班级", trigger: "blur" }], | 575 | + // classIds: [{ required: true, message: "请选择班级", trigger: "blur" }], |
572 | }, | 576 | }, |
573 | tableData: [], | 577 | tableData: [], |
574 | total: 0, | 578 | total: 0, |
@@ -649,17 +653,29 @@ export default { | @@ -649,17 +653,29 @@ export default { | ||
649 | showClose: true, | 653 | showClose: true, |
650 | message: `成功(${res.data.success}) 失败(${res.data.error})`, | 654 | message: `成功(${res.data.success}) 失败(${res.data.error})`, |
651 | type: "success", | 655 | type: "success", |
652 | - duration:5000 | 656 | + duration: 5000, |
653 | }); | 657 | }); |
654 | this.diaUp = false; | 658 | this.diaUp = false; |
655 | this.page = 1; | 659 | this.page = 1; |
656 | this._QueryData(); | 660 | this._QueryData(); |
657 | }, | 661 | }, |
658 | - edit(obj) { | 662 | + edit(obj) {//修改设备 |
659 | this.isAdd = false; | 663 | this.isAdd = false; |
660 | for (let key in this.form) { | 664 | for (let key in this.form) { |
661 | if (key == "classIds") { | 665 | if (key == "classIds") { |
662 | - this.form[key] = obj.classList[0]?.classId; | 666 | + this.form[key]; |
667 | + let classIds = obj.classList.map((item) => { | ||
668 | + return item.classId; | ||
669 | + }); | ||
670 | + let checkClassData = []; | ||
671 | + this.gradeList.map((item) => { | ||
672 | + item.children.map((items) => { | ||
673 | + if (classIds.includes(items.value)) { | ||
674 | + checkClassData.push([item.value, items.value]); | ||
675 | + } | ||
676 | + }); | ||
677 | + }); | ||
678 | + this.form[key] = [...checkClassData]; | ||
663 | } else { | 679 | } else { |
664 | this.form[key] = obj[key]; | 680 | this.form[key] = obj[key]; |
665 | } | 681 | } |
@@ -723,7 +739,7 @@ export default { | @@ -723,7 +739,7 @@ export default { | ||
723 | this.form.sn = ""; | 739 | this.form.sn = ""; |
724 | this.form.frequency = ""; | 740 | this.form.frequency = ""; |
725 | this.form.pairingCode = ""; | 741 | this.form.pairingCode = ""; |
726 | - this.form.classIds = ""; | 742 | + this.form.classIds = []; |
727 | this.form.roomName = ""; | 743 | this.form.roomName = ""; |
728 | this.form.schoolId = this.school.id; | 744 | this.form.schoolId = this.school.id; |
729 | delete this.form.deviceId; | 745 | delete this.form.deviceId; |
@@ -733,16 +749,17 @@ export default { | @@ -733,16 +749,17 @@ export default { | ||
733 | async showSchool() { | 749 | async showSchool() { |
734 | const { data, status, info } = await this.$request.schoolList(); | 750 | const { data, status, info } = await this.$request.schoolList(); |
735 | if (status === 0) { | 751 | if (status === 0) { |
752 | + let gradeListAll = data.list?.map((item) => { | ||
753 | + return { | ||
754 | + value: item.id, | ||
755 | + label: item.schoolName, | ||
756 | + }; | ||
757 | + }); | ||
736 | this.schoolAll = [ | 758 | this.schoolAll = [ |
737 | { | 759 | { |
738 | value: 0, | 760 | value: 0, |
739 | label: "全部", | 761 | label: "全部", |
740 | - children: data.list?.map((item) => { | ||
741 | - return { | ||
742 | - value: item.id, | ||
743 | - label: item.schoolName, | ||
744 | - }; | ||
745 | - }), | 762 | + children: [...gradeListAll], |
746 | }, | 763 | }, |
747 | ]; | 764 | ]; |
748 | this.gradeList = [...this.schoolAll, ...this.gradeList]; | 765 | this.gradeList = [...this.schoolAll, ...this.gradeList]; |
@@ -811,18 +828,9 @@ export default { | @@ -811,18 +828,9 @@ export default { | ||
811 | this.loadingAnswerEqu = true; | 828 | this.loadingAnswerEqu = true; |
812 | let query = { ...this.form }; | 829 | let query = { ...this.form }; |
813 | 830 | ||
814 | - // query.classIds = query.classIds.map((item) => { | ||
815 | - // return item[1]; | ||
816 | - // }); | ||
817 | - if ( | ||
818 | - typeof query.classIds == "string" || | ||
819 | - typeof query.classIds == "number" | ||
820 | - ) { | ||
821 | - query.classIds = [query.classIds]; | ||
822 | - } else { | ||
823 | - query.classIds = [query.classIds[1]]; | ||
824 | - } | ||
825 | - | 831 | + query.classIds = query.classIds.map((item) => { |
832 | + return item[1]; | ||
833 | + }); | ||
826 | let deviceApi = this.isAdd | 834 | let deviceApi = this.isAdd |
827 | ? this.$request.addStation | 835 | ? this.$request.addStation |
828 | : this.$request.updateDevice; | 836 | : this.$request.updateDevice; |