update-courseware.vue 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <template>
  2. <div class="update-courseware">
  3. <el-form
  4. ref="visibleForm"
  5. :model="visibleForm"
  6. class="visibleForm"
  7. label-width="100px"
  8. >
  9. <el-form-item label="课件名称">{{ detail.name }}</el-form-item>
  10. <el-form-item
  11. label="声部"
  12. :rules="[{ required: true, message: '请选择声部', trigger: 'change' }]"
  13. prop="subjectId"
  14. >
  15. <el-select
  16. clearable
  17. v-model="visibleForm.subjectId"
  18. placeholder="请选择声部"
  19. style="width: 100% !important"
  20. >
  21. <el-option
  22. v-for="item in selects.subjects"
  23. :value="item.id"
  24. :label="item.name"
  25. :key="item.id"
  26. ></el-option>
  27. </el-select>
  28. </el-form-item>
  29. </el-form>
  30. <span slot="footer" class="dialog-footer">
  31. <el-button @click="$emit('close')">取 消</el-button>
  32. <el-button @click="onSubmit" type="primary">确 定</el-button>
  33. </span>
  34. </div>
  35. </template>
  36. <script>
  37. import { updateSubject } from "./api";
  38. export default {
  39. name: "update-courseware",
  40. props: ["detail"],
  41. data() {
  42. return {
  43. visibleForm: {
  44. subjectId: null
  45. }
  46. };
  47. },
  48. async mounted() {
  49. this.$store.dispatch("setSubjects");
  50. this.visibleForm.subjectId = this.detail.subjectId || null;
  51. },
  52. methods: {
  53. async onSubmit() {
  54. //
  55. this.$refs["visibleForm"].validate(async flag => {
  56. if (!flag) {
  57. return;
  58. }
  59. try {
  60. await updateSubject({
  61. id: this.detail.id,
  62. subjectId: this.visibleForm.subjectId
  63. });
  64. this.$message.success("修改成功");
  65. this.$emit("close");
  66. this.$emit("getList");
  67. } catch {
  68. //
  69. }
  70. });
  71. }
  72. }
  73. };
  74. </script>
  75. <style lang="scss" scoped>
  76. .dialog-footer {
  77. display: block;
  78. text-align: right;
  79. }
  80. </style>