InvigilateManagementDialog.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <template>
  2. <el-dialog
  3. ref="dialog"
  4. title="考场监考管理"
  5. width="450px"
  6. :visible.sync="visible"
  7. @close="closeDialog"
  8. >
  9. <el-form
  10. :model="form"
  11. ref="form"
  12. :rules="rules"
  13. label-position="right"
  14. label-width="120px"
  15. >
  16. <el-row>
  17. <el-form-item label="考场">
  18. <ExamRoomSelect
  19. v-model="form.roomCode"
  20. style="width: 100%;"
  21. ></ExamRoomSelect>
  22. </el-form-item>
  23. <el-form-item label="监考老师">
  24. <InvigilatorSelect
  25. v-model="form.userIds"
  26. style="width: 100%;"
  27. multiple
  28. />
  29. </el-form-item>
  30. </el-row>
  31. <el-row class="d-flex justify-content-center">
  32. <el-button type="primary" @click="submitForm" :loading="loading"
  33. >保 存</el-button
  34. >
  35. <el-button @click="closeDialog">取 消</el-button>
  36. </el-row>
  37. </el-form>
  38. </el-dialog>
  39. </template>
  40. <script>
  41. import { saveInvigilator } from "@/api/examwork-invigilate";
  42. export default {
  43. name: "InvigilateManagementDialog",
  44. props: {
  45. user: Object,
  46. },
  47. watch: {
  48. user: {
  49. immediate: true,
  50. handler(val) {
  51. this.form.roomCode = val.roomCode;
  52. const u = val.userId || "";
  53. this.form.userIds = u.split(",").filter((v) => v);
  54. },
  55. },
  56. },
  57. data() {
  58. return {
  59. visible: false,
  60. form: {
  61. roomCode: "",
  62. userIds: [],
  63. },
  64. rules: {},
  65. loading: false,
  66. };
  67. },
  68. methods: {
  69. openDialog() {
  70. this.visible = true;
  71. },
  72. closeDialog() {
  73. this.visible = false;
  74. },
  75. async submitForm() {
  76. let data = this.form;
  77. try {
  78. this.loading = true;
  79. await saveInvigilator(data);
  80. this.$emit("reload");
  81. this.$notify({ title: "保存成功", type: "success" });
  82. this.closeDialog();
  83. } finally {
  84. this.loading = false;
  85. }
  86. },
  87. },
  88. };
  89. </script>
  90. <style></style>