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 | 462 | clearable |
463 | 463 | v-model="form.classIds" |
464 | 464 | :options="gradeList" |
465 | - :props="{ expandTrigger: 'hover' }" | |
465 | + :props="{ | |
466 | + multiple: true, | |
467 | + checkStrictly: false, | |
468 | + }" | |
469 | + collapse-tags | |
466 | 470 | :show-all-levels="false" |
467 | 471 | ></el-cascader> |
468 | 472 | </el-col> |
... | ... | @@ -559,7 +563,7 @@ export default { |
559 | 563 | sn: "", |
560 | 564 | frequency: "", |
561 | 565 | pairingCode: "", |
562 | - classIds: "", | |
566 | + classIds: [], | |
563 | 567 | roomName: "", |
564 | 568 | }, |
565 | 569 | formRules: { |
... | ... | @@ -568,7 +572,7 @@ export default { |
568 | 572 | pairingCode: [ |
569 | 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 | 577 | tableData: [], |
574 | 578 | total: 0, |
... | ... | @@ -649,17 +653,29 @@ export default { |
649 | 653 | showClose: true, |
650 | 654 | message: `成功(${res.data.success}) 失败(${res.data.error})`, |
651 | 655 | type: "success", |
652 | - duration:5000 | |
656 | + duration: 5000, | |
653 | 657 | }); |
654 | 658 | this.diaUp = false; |
655 | 659 | this.page = 1; |
656 | 660 | this._QueryData(); |
657 | 661 | }, |
658 | - edit(obj) { | |
662 | + edit(obj) {//修改设备 | |
659 | 663 | this.isAdd = false; |
660 | 664 | for (let key in this.form) { |
661 | 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 | 679 | } else { |
664 | 680 | this.form[key] = obj[key]; |
665 | 681 | } |
... | ... | @@ -723,7 +739,7 @@ export default { |
723 | 739 | this.form.sn = ""; |
724 | 740 | this.form.frequency = ""; |
725 | 741 | this.form.pairingCode = ""; |
726 | - this.form.classIds = ""; | |
742 | + this.form.classIds = []; | |
727 | 743 | this.form.roomName = ""; |
728 | 744 | this.form.schoolId = this.school.id; |
729 | 745 | delete this.form.deviceId; |
... | ... | @@ -733,16 +749,17 @@ export default { |
733 | 749 | async showSchool() { |
734 | 750 | const { data, status, info } = await this.$request.schoolList(); |
735 | 751 | if (status === 0) { |
752 | + let gradeListAll = data.list?.map((item) => { | |
753 | + return { | |
754 | + value: item.id, | |
755 | + label: item.schoolName, | |
756 | + }; | |
757 | + }); | |
736 | 758 | this.schoolAll = [ |
737 | 759 | { |
738 | 760 | value: 0, |
739 | 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 | 765 | this.gradeList = [...this.schoolAll, ...this.gradeList]; |
... | ... | @@ -811,18 +828,9 @@ export default { |
811 | 828 | this.loadingAnswerEqu = true; |
812 | 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 | 834 | let deviceApi = this.isAdd |
827 | 835 | ? this.$request.addStation |
828 | 836 | : this.$request.updateDevice; | ... | ... |