Commit bb4c8454eb478e4af572f1594ef17555390bedee

Authored by 阿宝
1 parent 42056450

添加,修改教师

src/utils/index.js
... ... @@ -678,3 +678,34 @@ export function formatClass(data) {
678 678 console.log(sectionNameArr);
679 679 return sectionNameArr;
680 680 }
  681 +export function formatGradeClass(data) {
  682 + let gradeName = [];
  683 + let gradeNameArr = [];
  684 + data.map((item) => {
  685 + if (!gradeName.includes(item.gradeName)) {
  686 + gradeName.push(item.gradeName);
  687 + gradeNameArr.push({
  688 + value: item.grade,
  689 + label: item.gradeName,
  690 + children: [
  691 + {
  692 + value: item.classCode,
  693 + label: item.className,
  694 + },
  695 + ],
  696 + });
  697 + } else {
  698 + let gradeIndex = 0;
  699 + gradeNameArr.map((items, index) => {
  700 + if (items.value == item.grade) {
  701 + gradeIndex = index;
  702 + }
  703 + });
  704 + gradeNameArr[gradeIndex].children.push({
  705 + value: item.classCode,
  706 + label: item.className,
  707 + });
  708 + }
  709 + });
  710 + return gradeNameArr;
  711 +}
... ...
src/views/index/mainIndex.vue
... ... @@ -5,21 +5,33 @@
5 5 <img class="icon" src="../../assets/nav/setUpAccount.png" alt="" />
6 6 <div class="text">
7 7 <p class="p1">账号管理</p>
8   - <p class="p2">管理{{schoolInfo.teacherCourseCount}}个任课教师,{{schoolInfo.classManagerCount}}个班主任,{{schoolInfo.teacherGradeCount}}个备课组长账号信息。</p>
  8 + <p class="p2">
  9 + 管理{{ schoolInfo.teacherCourseCount }}个任课教师,{{
  10 + schoolInfo.classManagerCount
  11 + }}个班主任,{{ schoolInfo.teacherGradeCount }}个备课组长账号信息。
  12 + </p>
9 13 </div>
10 14 </li>
11 15 <li class="nav-item item1" @click="links('/setUpSchool')">
12 16 <img class="icon" src="../../assets/nav/setUpSchool.png" alt="" />
13 17 <div class="text">
14 18 <p class="p1">学校管理</p>
15   - <p class="p2">管理{{schoolInfo.gradeCount}}个年级,{{schoolInfo.classCount}}个班级,{{schoolInfo.studentCount}}名学生信息。</p>
  19 + <p class="p2">
  20 + 管理{{ schoolInfo.gradeCount }}个年级,{{
  21 + schoolInfo.classCount
  22 + }}个班级,{{ schoolInfo.studentCount }}名学生信息。
  23 + </p>
16 24 </div>
17 25 </li>
18 26 <li class="nav-item item2" @click="links('/device')">
19 27 <img class="icon" src="../../assets/nav/device.png" alt="" />
20 28 <div class="text">
21 29 <p class="p1">设备状态</p>
22   - <p class="p2">管理{{schoolInfo.stationCount}}个基站,{{schoolInfo.keyboardCount}}套答题器设备。</p>
  30 + <p class="p2">
  31 + 管理{{ schoolInfo.stationCount }}个基站,{{
  32 + schoolInfo.keyboardCount
  33 + }}套答题器设备。
  34 + </p>
23 35 </div>
24 36 </li>
25 37 <li class="item3">
... ... @@ -44,8 +56,13 @@
44 56 </ul>
45 57 <ul class="nav-list" v-if="type == 'ROLE_JITUAN'">
46 58 <template v-for="item in navList">
47   - <li v-if="!item.path.includes('dataSync')" :key="item.path" class="nav-item item4" @click="links(item.path)">
48   - <img class="icon" :src="getImgs(item.path)" alt="" />
  59 + <li
  60 + v-if="!item.path.includes('dataSync')"
  61 + :key="item.path"
  62 + class="nav-item item4"
  63 + @click="links(item.path)"
  64 + >
  65 + <img class="icon" :src="getImgs(item.path)" alt="" />
49 66 <div class="text" v-if="item.path == '/setUpConglomerate'">
50 67 <p class="p1">学校管理</p>
51 68 <p class="p2">管理3个区域,14个学校。</p>
... ... @@ -62,30 +79,40 @@
62 79 <p class="p1">使用分析</p>
63 80 <p class="p2">按软件功能、题型统计使用频率。</p>
64 81 </div>
65   - </li>
  82 + </li>
66 83 </template>
67 84 </ul>
68   - <ul class="nav-list" v-if="type == 'ROLE_JIAOSHI' || type == 'ROLE_BANZHUREN' ">
69   - <template v-for="(item) in navList">
70   - <li v-if="!item.path.includes('dataSync')" :key="item.path" class="nav-item item4" @click="links(item.path)">
71   - <img class="icon" :src="getImgs(item.path)" alt="" />
  85 + <ul
  86 + class="nav-list"
  87 + v-if="type == 'ROLE_JIAOSHI' || type == 'ROLE_BANZHUREN'"
  88 + >
  89 + <template v-for="item in navList">
  90 + <li
  91 + v-if="!item.path.includes('dataSync')"
  92 + :key="item.path"
  93 + class="nav-item item4"
  94 + @click="links(item.path)"
  95 + >
  96 + <img class="icon" :src="getImgs(item.path)" alt="" />
72 97 <div class="text" v-if="item.path == '/examinationPaper'">
73 98 <p class="p1">备题组卷</p>
74   - <p class="p2">管理{{schoolInfo.paperCount}}套答题卡。</p>
  99 + <p class="p2">管理{{ schoolInfo.paperCount }}套答题卡。</p>
75 100 </div>
76 101 <div class="text" v-else-if="item.path == '/portrait'">
77 102 <p class="p1">学生画像</p>
78   - <p class="p2">共分析{{schoolInfo.imagesCount}}名学生成绩。</p>
  103 + <p class="p2">共分析{{ schoolInfo.imagesCount }}名学生成绩。</p>
79 104 </div>
80 105 <div class="text" v-else-if="item.path == '/ask'">
81 106 <p class="p1">随堂问报表</p>
82   - <p class="p2">对{{schoolInfo.classPeriodCount}}套随堂问答题记录分析。</p>
  107 + <p class="p2">
  108 + 对{{ schoolInfo.classPeriodCount }}套随堂问答题记录分析。
  109 + </p>
83 110 </div>
84 111 <div class="text" v-else-if="item.path == '/test'">
85 112 <p class="p1">即时测报表</p>
86   - <p class="p2">对{{schoolInfo.examCount}}套即时测答题记录分析。</p>
  113 + <p class="p2">对{{ schoolInfo.examCount }}套即时测答题记录分析。</p>
87 114 </div>
88   - </li>
  115 + </li>
89 116 </template>
90 117 </ul>
91 118 </div>
... ... @@ -98,31 +125,49 @@ export default {
98 125 return {
99 126 type: "",
100 127 navList: [],
101   - schoolInfo:{}
  128 + schoolInfo: {},
102 129 };
103 130 },
104   - watch:{
105   - "$store.getters.info.showRoleName":function(val){
106   - window.location.reload()
107   - }
  131 + watch: {
  132 + "$store.getters.info.showRoleName": function (val) {
  133 + let type = "";
  134 + this.$store.getters.info.permissions.map((item) => {
  135 + if (item.roleName == val) {
  136 + type = item.role;
  137 + }
  138 + });
  139 + this.type = type ? type : this.$store.getters.info.permissions[0].role;
  140 + this.navList = this.$store.getters.addRouters.map((item) => {
  141 + return {
  142 + name: item.name,
  143 + path: item.children[0].path,
  144 + };
  145 + });
  146 + },
108 147 },
109 148 created() {
110   - this.type = this.$store.getters.info.permissions[0].role
111   - this.navList = this.$store.getters.addRouters.map(item=>{
112   - return {
113   - name:item.name,
114   - path:item.children[0].path,
  149 + let type = "";
  150 + this.$store.getters.info.permissions.map((item) => {
  151 + if (item.roleName == this.$store.getters.info.showRoleName) {
  152 + type = item.role;
115 153 }
116   - })
117   - if(this.type == "ROLE_XUEXIAO"){
118   - this.schoolIndex()
119   - }else if(this.type == "ROLE_JIAOSHI" || this.type == "ROLE_BANZHUREN"){
120   - this.teacherIndex()
  154 + });
  155 + this.type = type ? type : this.$store.getters.info.permissions[0].role;
  156 + this.navList = this.$store.getters.addRouters.map((item) => {
  157 + return {
  158 + name: item.name,
  159 + path: item.children[0].path,
  160 + };
  161 + });
  162 + if (this.type == "ROLE_XUEXIAO") {
  163 + this.schoolIndex();
  164 + } else if (this.type == "ROLE_JIAOSHI" || this.type == "ROLE_BANZHUREN") {
  165 + this.teacherIndex();
121 166 }
122 167 },
123 168 methods: {
124 169 getImgs(path) {
125   - return require(`@/assets/nav${path}.png`)
  170 + return require(`@/assets/nav${path}.png`);
126 171 },
127 172 links(path) {
128 173 this.$router.push({
... ...
src/views/login/index.vue
... ... @@ -90,12 +90,12 @@ export default {
90 90 disableClick: true,
91 91 passwordType: "password",
92 92 loginForm: {
93   - // username: "13610050254",
94   - // password: "Pw050254#",
  93 + username: "13610050254",
  94 + password: "Pw050254#",
95 95 // username: "18946034886",
96 96 // password: "Pw034886#",
97   - username: "18332123505",
98   - password: "Pw123505#",
  97 + // username: "18332123505",
  98 + // password: "Pw123505#",
99 99 },
100 100 loginRules: {
101 101 username: [
... ...
src/views/setUp/account.vue
... ... @@ -9,9 +9,9 @@
9 9 <div class="sel-box">
10 10 <el-select
11 11 class="sel"
12   - v-model="query.id"
  12 + v-model="query.roleId"
13 13 placeholder="选择账号角色"
14   - @change="(page = 1),_QueryData(1)"
  14 + @change="(page = 1), _QueryData(1)"
15 15 >
16 16 <el-option
17 17 v-for="item in roleList"
... ... @@ -25,34 +25,33 @@
25 25 class="sel"
26 26 v-model="query.available"
27 27 placeholder="选择账号状态"
28   - @change="(page = 1),_QueryData(1)"
  28 + @change="(page = 1), _QueryData(1)"
29 29 >
30   - <el-option label="可用" :value="0"></el-option>
31   - <el-option label="不可用" :value="1"></el-option>
  30 + <el-option label="正常" :value="0"></el-option>
  31 + <el-option label="禁用" :value="1"></el-option>
32 32 </el-select>
33 33 <el-input
34   - type="number"
35 34 placeholder="请输入老师账号"
36 35 v-model="query.loginName"
37 36 class="input-with-select"
38   - @keyup.enter.native="(page = 1),_QueryData(2)"
  37 + @keyup.enter.native="(page = 1), _QueryData(2)"
39 38 >
40 39 <el-button
41 40 slot="append"
42 41 icon="el-icon-search"
43   - @click="(page = 1),_QueryData(2)"
  42 + @click="(page = 1), _QueryData(2)"
44 43 ></el-button>
45 44 </el-input>
46 45 <el-input
47 46 placeholder="请输入老师姓名"
48 47 v-model="query.realName"
49 48 class="input-with-select"
50   - @keyup.enter.native="(page = 1),_QueryData(3)"
  49 + @keyup.enter.native="(page = 1), _QueryData(3)"
51 50 >
52 51 <el-button
53 52 slot="append"
54 53 icon="el-icon-search"
55   - @click="(page = 1),_QueryData(3)"
  54 + @click="(page = 1), _QueryData(3)"
56 55 ></el-button>
57 56 </el-input>
58 57 </div>
... ... @@ -117,7 +116,9 @@
117 116 ></el-button>
118 117 <el-dropdown-menu slot="dropdown">
119 118 <el-dropdown-item :command="0">重置密码</el-dropdown-item>
120   - <el-dropdown-item :command="1">禁用</el-dropdown-item>
  119 + <el-dropdown-item :command="1">{{
  120 + `${scoped.row.available == 0 ? "禁用" : "启用"}`
  121 + }}</el-dropdown-item>
121 122 <el-dropdown-item :command="2">删除</el-dropdown-item>
122 123 </el-dropdown-menu>
123 124 </el-dropdown>
... ... @@ -224,7 +225,18 @@ export default {
224 225 },
225 226 handleDropdownClick(value, item) {
226 227 //更多
227   - this.updateUser(item, value);
  228 + if (value == 2) {
  229 + this.$confirm("确定要删除这条账号信息吗?", "提示", {
  230 + customClass: "del-model",
  231 + cancelButttonText: "取消",
  232 + confirmButtonText: "确定",
  233 + type: "warning",
  234 + }).then(() => {
  235 + this.updateUser(item, value);
  236 + });
  237 + } else {
  238 + this.updateUser(item, value);
  239 + }
228 240 },
229 241 changePage(page) {
230 242 this.page = page;
... ... @@ -314,8 +326,17 @@ export default {
314 326 },
315 327 };
316 328 </script>
317   -
  329 +<style lang="scss">
  330 +.del-model {
  331 + .el-message-box__btns button:nth-child(1) {
  332 + color: #667ffd;
  333 + }
  334 +}
  335 +</style>
318 336 <style lang="scss" scoped>
  337 +.el-message-box .el-button--default {
  338 + color: red;
  339 +}
319 340 .set-count {
320 341 margin-right: 12px;
321 342 }
... ...
src/views/setUp/school.vue
... ... @@ -359,7 +359,6 @@ export default {
359 359 },
360 360 async _QuerySubject() {
361 361 const { data, status, info } = await this.$request.subjectList();
362   - console.log(status);
363 362 if (status === 0) {
364 363 this.subjectList = [...data.subjectNames] || [];
365 364 } else {
... ...
src/views/setUp/student.vue
... ... @@ -80,7 +80,12 @@
80 80 </div>
81 81 <ul class="s-ul" v-loading="loading">
82 82 <li class="s-li" v-for="(item,index) in studentList" :key="item.id">
83   - <i class="el-icon-delete" @click="removeStu(item,index)"></i>
  83 + <el-popconfirm
  84 + title="确定删除吗?"
  85 + @confirm="removeStu(item,index)"
  86 + >
  87 + <i class="el-icon-delete" slot="reference"></i>
  88 + </el-popconfirm>
84 89 <p class="name">{{ item.studentName }}</p>
85 90 <p class="p1">
86 91 答题器:{{
... ...
src/views/setUp/teacher.vue
... ... @@ -22,6 +22,7 @@
22 22 size="mini"
23 23 plain
24 24 circle
  25 + @click="addTeacherDia"
25 26 ></el-button>
26 27 </el-tooltip>
27 28 </template>
... ... @@ -93,7 +94,7 @@
93 94 </div>
94 95 <div class="teacher-detail">
95 96 <div class="icon-box">
96   - <i class="icon el-icon-edit-outline"></i>
  97 + <i class="icon el-icon-edit-outline" @click="editTeacher"></i>
97 98 <i class="icon el-icon-circle-plus-outline"></i>
98 99 </div>
99 100 <div class="detail-top">
... ... @@ -122,7 +123,9 @@
122 123 v-for="item in teacherDetail.managerList"
123 124 :key="item.classId"
124 125 >
125   - <i class="el-icon-delete"></i>
  126 + <el-popconfirm title="确定删除吗?" confirm="">
  127 + <i class="el-icon-delete" slot="reference"></i>
  128 + </el-popconfirm>
126 129 <div class="grade-item">
127 130 <p class="grade-name">{{ item.className }}</p>
128 131 <div class="grade-class">
... ... @@ -150,7 +153,9 @@
150 153 v-for="item in teacherDetail.teacherCourseList"
151 154 :key="item.classId"
152 155 >
153   - <i class="el-icon-delete"></i>
  156 + <el-popconfirm title="确定删除吗?" confirm="">
  157 + <i class="el-icon-delete" slot="reference"></i>
  158 + </el-popconfirm>
154 159 <div class="grade-item">
155 160 <p class="grade-name">
156 161 {{ item.className }}({{ item.subjectName }})
... ... @@ -180,7 +185,9 @@
180 185 :key="item.grade"
181 186 >
182 187 <li class="grade-li">
183   - <i class="el-icon-delete"></i>
  188 + <el-popconfirm title="确定删除吗?" confirm="">
  189 + <i class="el-icon-delete" slot="reference"></i>
  190 + </el-popconfirm>
184 191 <div class="grade-item">
185 192 <p class="grade-name">
186 193 {{ item.gradeName }}({{ item.subjectName }})
... ... @@ -192,7 +199,7 @@
192 199 </div>
193 200 </div>
194 201 </div>
195   - <el-dialog title="导入教师名单" :visible.sync="diaUp" width="400">
  202 + <el-dialog title="导入教师名单" :visible.sync="diaUp" width="600">
196 203 <up-load id="downTeacher" :url="url" fileName="教师名单">
197 204 <p class="down-txt" slot="down">
198 205 通过Excel名单导入教师名单,点击
... ... @@ -203,16 +210,17 @@
203 210 <el-button @click="diaUp = false">取 消</el-button>
204 211 </div>
205 212 </el-dialog>
206   - <el-dialog title="添加学生" :visible.sync="diaTeacher" width="400">
  213 + <el-dialog title="添加教师" :visible.sync="diaTeacher" width="400">
207 214 <el-form
208 215 class="form-box"
  216 + ref="formTeacher"
209 217 :model="formTeacher"
210 218 :rules="rulesTeacher"
211 219 label-width="160px"
212 220 >
213 221 <el-form-item label="手机号码:" prop="loginName">
214 222 <el-col :span="10">
215   - <el-input maxlength="30" v-model.trim="formTeacher.loginName" />
  223 + <el-input maxlength="11" v-model.trim="formTeacher.loginName" />
216 224 </el-col>
217 225 </el-form-item>
218 226 <el-form-item label="教师姓名:" prop="teacherName">
... ... @@ -220,14 +228,67 @@
220 228 <el-input maxlength="30" v-model.trim="formTeacher.teacherName" />
221 229 </el-col>
222 230 </el-form-item>
223   - <el-form-item label="性别:">
  231 + <el-form-item label="性别:" prop="sex">
224 232 <el-radio-group v-model="formTeacher.sex">
225 233 <el-radio :label="1">男</el-radio>
226 234 <el-radio :label="2">女</el-radio>
227 235 </el-radio-group>
228 236 </el-form-item>
229   - <el-form-item label="教师角色:">
230   -
  237 + <el-form-item label="教师角色:" prop="roleList">
  238 + <div
  239 + class="role-list"
  240 + v-for="(item, index) in formTeacher.roleList"
  241 + :key="item.id"
  242 + >
  243 + <el-select
  244 + class="sel-c"
  245 + v-model="item.roleId"
  246 + placeholder="选择角色"
  247 + @change="item.classId = []"
  248 + >
  249 + <el-option
  250 + v-for="item in teacherTypeList"
  251 + :key="item.value"
  252 + :label="item.label"
  253 + :value="item.value"
  254 + >
  255 + </el-option>
  256 + </el-select>
  257 + <el-cascader
  258 + v-if="item.roleId == 6"
  259 + class="sel-t"
  260 + collapse
  261 + clearable
  262 + placeholder="选择班级"
  263 + v-model="item.classId"
  264 + :options="gradeClassList"
  265 + :props="{ expandTrigger: 'hover' }"
  266 + ></el-cascader>
  267 + <el-cascader
  268 + v-if="item.roleId == 7"
  269 + class="sel-t"
  270 + collapse
  271 + clearable
  272 + placeholder="选择班级-科目"
  273 + v-model="item.classId"
  274 + :options="classList"
  275 + :props="{ expandTrigger: 'hover' }"
  276 + ></el-cascader>
  277 + <el-cascader
  278 + v-if="item.roleId == 8"
  279 + class="sel-t"
  280 + collapse
  281 + clearable
  282 + placeholder="选择年级-科目"
  283 + v-model="item.classId"
  284 + :options="gradeSubList"
  285 + :props="{ expandTrigger: 'hover' }"
  286 + ></el-cascader>
  287 + <i class="el-icon-close" @click="removeRoleList(index)"></i>
  288 + </div>
  289 + <p class="add-box">
  290 + <el-button icon="el-icon-plus" @click="addRoleList">添加</el-button>
  291 + </p>
231 292 </el-form-item>
232 293 </el-form>
233 294 <div class="dialog-footer" slot="footer">
... ... @@ -239,21 +300,40 @@
239 300 </template>
240 301  
241 302 <script>
242   -import { downloadFile } from "@/utils";
  303 +import { downloadFile, formatGradeClass, randomWord } from "@/utils";
243 304 export default {
244 305 data() {
245 306 return {
246 307 loading: false,
247 308 url: "",
248 309 diaUp: false,
249   - diaTeacher:false,
  310 + diaTeacher: false,
  311 + isAdd: false,
250 312 query: {
251 313 gradeName: "",
252 314 teacherName: "",
253 315 phone: "",
254 316 },
  317 + subjectList: [],
255 318 gradeList: [],
  319 + classList: [],
  320 + gradeClassList: [],
  321 + gradeSubList: [],
256 322 teacherList: [],
  323 + teacherTypeList: [
  324 + {
  325 + value: 6,
  326 + label: "班主任",
  327 + },
  328 + {
  329 + value: 7,
  330 + label: "任课老师",
  331 + },
  332 + {
  333 + value: 8,
  334 + label: "备课组长",
  335 + },
  336 + ],
257 337 teacherDetail: {
258 338 teacherName: "",
259 339 loginName: "",
... ... @@ -264,21 +344,60 @@ export default {
264 344 teacherGradeList: [],
265 345 },
266 346 showTId: "", //显示详情 教师ID
267   - formTeacher:{
268   - teacherName:"",
269   - loginName:"",
270   - sex:1,
271   - managerList:[]
  347 + roleList: [],
  348 + formTeacher: {
  349 + teacherName: "",
  350 + loginName: "",
  351 + sex: 1,
  352 + roleList: [],
  353 + },
  354 + rulesTeacher: {
  355 + teacherName: [
  356 + { required: true, message: "请输入联系电话", trigger: "blur" },
  357 + ],
  358 + loginName: [
  359 + { required: true, message: "请输入教师姓名", trigger: "blur" },
  360 + ],
  361 + sex: [{ required: true, message: "请选择性别", trigger: "blur" }],
  362 + roleList: [
  363 + { required: true, message: "请选择角色信息", trigger: "blur" },
  364 + ],
272 365 },
273   - rulesTeacher:{},
274 366 };
275 367 },
276 368 async created() {
277 369 await this._QueryDataGrade();
278 370 this._QueryData(1);
  371 + this._RoleList();
  372 + await this._QuerySubject();
  373 + await this._QueryClass();
279 374 },
280 375 methods: {
  376 + addRoleList() {
  377 + //添加教师角色
  378 + this.formTeacher.roleList.push({
  379 + id: randomWord(true, 16, 20),
  380 + roleId: "",
  381 + classId: [],
  382 + });
  383 + },
  384 + removeRoleList(index) {
  385 + //删除教师角色
  386 + this.formTeacher.roleList.splice(index, 1);
  387 + },
  388 + addTeacherDia() {
  389 + //添加教师弹窗
  390 + this.isAdd = true;
  391 + this.formTeacher = {
  392 + teacherName: "",
  393 + loginName: "",
  394 + sex: 1,
  395 + managerList: [],
  396 + };
  397 + this.diaTeacher = true;
  398 + },
281 399 setClass(obj) {
  400 + //教师角色数量
282 401 return (
283 402 obj.managerList?.length +
284 403 obj.teacherCourseList?.length +
... ... @@ -286,10 +405,161 @@ export default {
286 405 );
287 406 },
288 407 showTeacher(obj) {
  408 + //教师详细数据
289 409 this.showTId = obj.id;
290 410 this.teacherDetail = { ...obj };
291 411 },
292   - addTeacher(){},
  412 + editTeacher() {
  413 + this.isAdd = false;
  414 + for (let key in this.teacherDetail) {
  415 + if (key == "realName") {
  416 + this.formTeacher.teacherName = this.teacherDetail.realName;
  417 + } else {
  418 + this.formTeacher[key] = this.teacherDetail[key];
  419 + }
  420 + }
  421 + this.toTeacherForm();
  422 + this.diaTeacher = true;
  423 + },
  424 + addTeacher() {
  425 + //添加教师
  426 + this.$refs.formTeacher.validate(async (valid) => {
  427 + if (valid) {
  428 + let obj = this.setTeacharForm();
  429 + if (!obj) {
  430 + this.$message.error("教师角色数据有误请检查!");
  431 + return;
  432 + }
  433 + let res;
  434 + if (this.isAdd) {
  435 + res = await this.$request.addTeacher({
  436 + teacherName: this.formTeacher.teacherName,
  437 + loginName: this.formTeacher.loginName,
  438 + sex: this.formTeacher.sex,
  439 + ...obj,
  440 + });
  441 + } else {
  442 + res = await this.$request.updateTeacher({
  443 + teacherId: this.formTeacher.id,
  444 + teacherName: this.formTeacher.teacherName,
  445 + loginName: this.formTeacher.loginName,
  446 + sex: this.formTeacher.sex,
  447 + ...obj,
  448 + });
  449 + }
  450 + if (res.status === 0) {
  451 + this.$message.success(res.info);
  452 + this.diaTeacher = false;
  453 + this._QueryData(10);
  454 + } else {
  455 + this.$message.error(res.info);
  456 + }
  457 + } else {
  458 + console.log("输入有误请检查!");
  459 + return false;
  460 + }
  461 + });
  462 + },
  463 + setTeacharForm() {
  464 + //转换保存教师数据格式
  465 + let ERR_OK = true;
  466 + this.formTeacher.roleList.map((item) => {
  467 + if (item.classId.length == 0) {
  468 + ERR_OK = false;
  469 + }
  470 + });
  471 + if (ERR_OK) {
  472 + let [managerList, teacherCourseList, gradeGroupList] = [[], [], []];
  473 + this.formTeacher.roleList.map((item) => {
  474 + if (item.roleId == 6) {
  475 + managerList.push({
  476 + classId: item.classId[1],
  477 + className: this.classList.find(
  478 + (items) => items.value == item.classId[1]
  479 + ).label,
  480 + });
  481 + } else if (item.roleId == 7) {
  482 + teacherCourseList.push({
  483 + classId: item.classId[0],
  484 + className: this.classList.find(
  485 + (items) => items.value == item.classId[0]
  486 + ).label,
  487 + subjectName: item.classId[1],
  488 + });
  489 + } else {
  490 + gradeGroupList.push({
  491 + grade: item.classId[0],
  492 + gradeName: this.gradeList.find(
  493 + (items) => items.id == item.classId[0]
  494 + ).label,
  495 + subjectName: item.classId[1],
  496 + });
  497 + }
  498 + });
  499 + return {
  500 + managerList,
  501 + teacherCourseList,
  502 + gradeGroupList,
  503 + };
  504 + } else {
  505 + return false;
  506 + }
  507 + },
  508 + toTeacherForm() {
  509 + //教师角色数据转换为form格式数据
  510 + this.formTeacher.roleList = [];
  511 + this.formTeacher.managerList?.map((item) => {
  512 + console.log(
  513 + this.classList.find(
  514 + (items) =>
  515 + items.value == item.classId || items.label == item.className
  516 + )
  517 + );
  518 + this.formTeacher.roleList.push({
  519 + id: randomWord(true, 16, 20),
  520 + roleId: 6,
  521 + classId: [
  522 + this.classList.find(
  523 + (items) =>
  524 + items.value == item.classId || items.label == item.className
  525 + ).grade,
  526 + item.classId,
  527 + ],
  528 + });
  529 + });
  530 + this.formTeacher.teacherCourseList?.map((item) => {
  531 + this.formTeacher.roleList.push({
  532 + id: randomWord(true, 16, 20),
  533 + roleId: 7,
  534 + classId: [
  535 + this.classList.find(
  536 + (items) =>
  537 + items.value == item.classId || items.label == item.className
  538 + ).value,
  539 + item.subjectName,
  540 + ],
  541 + });
  542 + });
  543 + this.formTeacher.gradeGroupList?.map((item) => {
  544 + this.formTeacher.roleList.push({
  545 + id: randomWord(true, 16, 20),
  546 + roleId: 8,
  547 + classId: [
  548 + this.gradeList.find((items) => items.id == item.classId[0]).id,
  549 + item.subjectName,
  550 + ],
  551 + });
  552 + });
  553 + },
  554 + async _RoleList() {
  555 + //角色
  556 + const { data, status, info } = await this.$request.roleList();
  557 + if (status === 0) {
  558 + this.roleList = data.list || [];
  559 + } else {
  560 + this.$message.error(info);
  561 + }
  562 + },
293 563 async _QueryData(type) {
294 564 let query = {};
295 565 if (type == 1) {
... ... @@ -304,8 +574,11 @@ export default {
304 574 query.phone = this.query.phone;
305 575 this.query.teacherName = "";
306 576 this.query.gradeName = "";
  577 + } else if (type == 10) {
  578 + query = { ...this.query };
307 579 }
308 580 this.loading = true;
  581 + this.teacherList=[]
309 582 const { data, status, info } = await this.$request.teacherList({
310 583 ...query,
311 584 });
... ... @@ -313,13 +586,22 @@ export default {
313 586 console.log(status);
314 587 if (status === 0) {
315 588 this.teacherList = data.list || [];
316   - this.teacherDetail = { ...this.teacherList[0] };
317   - this.showTId = this.teacherList[0]?.id;
  589 + if (type == 10) {
  590 + let detailArr =
  591 + data.list.filter((item) => item.id == this.formTeacher.id) || [];
  592 + this.teacherDetail = (detailArr.length && detailArr[0]) || {
  593 + ...data.list[0],
  594 + };
  595 + } else {
  596 + this.teacherDetail = { ...this.teacherList[0] };
  597 + }
  598 + this.showTId = this.teacherDetail.id;
318 599 } else {
319 600 this.$message.error(info);
320 601 }
321 602 },
322 603 async _QueryDataGrade() {
  604 + //年级数据
323 605 const { data, status, info } = await this.$request.gradeList();
324 606 if (status === 0) {
325 607 this.gradeList =
... ... @@ -327,14 +609,60 @@ export default {
327 609 return {
328 610 value: item.gradeName,
329 611 label: item.gradeName,
  612 + id: item.grade,
330 613 };
331 614 }) || [];
332   - console.log(this.gradeList);
  615 +
333 616 this.query.gradeName = this.gradeList[0]?.value;
334 617 } else {
335 618 this.$message.error(info);
336 619 }
337 620 },
  621 + async _QuerySubject() {
  622 + //科目信息
  623 + const { data, status, info } = await this.$request.subjectList();
  624 + console.log(status);
  625 + if (status === 0) {
  626 + this.subjectList = [...data.subjectNames] || [];
  627 + this.gradeSubList = this.gradeList?.map((item) => {
  628 + return {
  629 + value: item.id,
  630 + label: item.label,
  631 + children: data.subjectNames.map((sub) => {
  632 + return {
  633 + value: sub,
  634 + label: sub,
  635 + };
  636 + }),
  637 + };
  638 + });
  639 + } else {
  640 + this.$message.error(info);
  641 + }
  642 + },
  643 + async _QueryClass() {
  644 + //班级数据
  645 + const { data, status, info } = await this.$request.schoolClassList();
  646 + if (status === 0) {
  647 + this.classList =
  648 + data.list.map((item) => {
  649 + return {
  650 + value: item.classCode,
  651 + label: item.className,
  652 + grade: item.grade,
  653 + children: this.subjectList.map((sub) => {
  654 + return {
  655 + value: sub,
  656 + label: sub,
  657 + };
  658 + }),
  659 + };
  660 + }) || [];
  661 + this.gradeClassList = formatGradeClass([...data.list]);
  662 + } else {
  663 + this.$message.error(info);
  664 + }
  665 + },
338 666 async downExcel() {
339 667 let data = await this.$request.downDevice({
340 668 id: this.id,
... ... @@ -476,4 +804,21 @@ export default {
476 804 }
477 805 }
478 806 }
  807 +.add-box {
  808 + margin-top: 10px;
  809 +}
  810 +.sel-c {
  811 + width: 120px;
  812 + margin-right: 12px;
  813 +}
  814 +.role-list {
  815 + margin-bottom: 10px;
  816 + .el-icon-close {
  817 + padding: 5px;
  818 + cursor: pointer;
  819 + margin-left: 16px;
  820 + background: #ccc;
  821 + border-radius: 50%;
  822 + }
  823 +}
479 824 </style>
480 825 \ No newline at end of file
... ...