|
@@ -37,6 +37,25 @@
|
|
</el-option>
|
|
</el-option>
|
|
</el-select>
|
|
</el-select>
|
|
</el-form-item>
|
|
</el-form-item>
|
|
|
|
+ <el-form-item
|
|
|
|
+ prop="courseId"
|
|
|
|
+ label="科目:"
|
|
|
|
+ v-if="modalForm.roleCode === 'QUESTION_TEACHER'"
|
|
|
|
+ >
|
|
|
|
+ <el-select
|
|
|
|
+ style="width:142px;"
|
|
|
|
+ v-model="modalForm.courseId"
|
|
|
|
+ placeholder="请选择科目"
|
|
|
|
+ >
|
|
|
|
+ <el-option
|
|
|
|
+ v-for="item in courses"
|
|
|
|
+ :key="item.id"
|
|
|
|
+ :label="item.courseName"
|
|
|
|
+ :value="item.id"
|
|
|
|
+ >
|
|
|
|
+ </el-option>
|
|
|
|
+ </el-select>
|
|
|
|
+ </el-form-item>
|
|
<el-form-item>
|
|
<el-form-item>
|
|
<el-button
|
|
<el-button
|
|
style="width:88px;"
|
|
style="width:88px;"
|
|
@@ -52,7 +71,7 @@
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script>
|
|
<script>
|
|
-import { updateUser, userDetail, roleList } from "../api";
|
|
|
|
|
|
+import { updateUser, userDetail, roleList, courseList } from "../api";
|
|
|
|
|
|
export default {
|
|
export default {
|
|
name: "user-edit",
|
|
name: "user-edit",
|
|
@@ -62,7 +81,8 @@ export default {
|
|
userId: "",
|
|
userId: "",
|
|
name: "",
|
|
name: "",
|
|
loginName: "",
|
|
loginName: "",
|
|
- roleCode: ""
|
|
|
|
|
|
+ roleCode: "",
|
|
|
|
+ courseId: ""
|
|
},
|
|
},
|
|
rules: {
|
|
rules: {
|
|
name: [
|
|
name: [
|
|
@@ -85,9 +105,18 @@ export default {
|
|
message: "请选择角色",
|
|
message: "请选择角色",
|
|
trigger: "change"
|
|
trigger: "change"
|
|
}
|
|
}
|
|
|
|
+ ],
|
|
|
|
+ courseId: [
|
|
|
|
+ {
|
|
|
|
+ required: true,
|
|
|
|
+ message: "请选择科目",
|
|
|
|
+ trigger: "change"
|
|
|
|
+ }
|
|
]
|
|
]
|
|
},
|
|
},
|
|
|
|
+ user: {},
|
|
roles: [],
|
|
roles: [],
|
|
|
|
+ courses: [],
|
|
isSubmit: false
|
|
isSubmit: false
|
|
};
|
|
};
|
|
},
|
|
},
|
|
@@ -98,12 +127,17 @@ export default {
|
|
async init() {
|
|
async init() {
|
|
const data = await roleList();
|
|
const data = await roleList();
|
|
this.roles = data.records;
|
|
this.roles = data.records;
|
|
- const user = await userDetail(this.$route.params.userId);
|
|
|
|
- if (!user.account) {
|
|
|
|
|
|
+ this.user = await userDetail(this.$route.params.userId);
|
|
|
|
+ if (!this.user.account) {
|
|
this.$message.error("当前用户不存在!");
|
|
this.$message.error("当前用户不存在!");
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
- this.modalForm = Object.assign({}, this.modalForm, user.account);
|
|
|
|
|
|
+ this.modalForm = Object.assign({}, this.modalForm, this.user.account);
|
|
|
|
+ this.getCourseList();
|
|
|
|
+ },
|
|
|
|
+ async getCourseList() {
|
|
|
|
+ const data = await courseList();
|
|
|
|
+ this.courses = data.records;
|
|
},
|
|
},
|
|
async submit(name) {
|
|
async submit(name) {
|
|
const valid = await this.$refs[name].validate().catch(() => {});
|
|
const valid = await this.$refs[name].validate().catch(() => {});
|
|
@@ -111,11 +145,22 @@ export default {
|
|
|
|
|
|
if (this.isSubmit) return;
|
|
if (this.isSubmit) return;
|
|
this.isSubmit = true;
|
|
this.isSubmit = true;
|
|
- const data = await updateUser(this.modalForm).catch(() => {});
|
|
|
|
|
|
+
|
|
|
|
+ const datas = { ...this.modalForm };
|
|
|
|
+ if (datas.roleCode !== "QUESTION_TEACHER") delete datas.courseId;
|
|
|
|
+ const data = await updateUser(datas).catch(() => {});
|
|
this.isSubmit = false;
|
|
this.isSubmit = false;
|
|
if (!data) return;
|
|
if (!data) return;
|
|
|
|
|
|
- this.gaback();
|
|
|
|
|
|
+ this.$message.success("修改成功!");
|
|
|
|
+
|
|
|
|
+ // 自己把自己的角色改了之后要刷新页面,重新获取权限
|
|
|
|
+ if (
|
|
|
|
+ this.user.roleCode !== this.modalForm.roleCode &&
|
|
|
|
+ this.$ls.get("userId") === this.user.id
|
|
|
|
+ ) {
|
|
|
|
+ window.location.reload();
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
};
|
|
};
|