ModifyCourseOutlineTargetPredict.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <template>
  2. <el-dialog
  3. :visible.sync="modalIsShow"
  4. title="课程目标预期值"
  5. top="10vh"
  6. width="500px"
  7. :close-on-click-modal="false"
  8. :close-on-press-escape="false"
  9. append-to-body
  10. @open="visibleChange"
  11. >
  12. <el-form ref="modalFormComp" :model="modalForm" :rules="rules">
  13. <el-form-item prop="expectValue" label="预期值:">
  14. <el-input-number
  15. v-model="modalForm.expectValue"
  16. :min="0.01"
  17. :max="1"
  18. :step="0.01"
  19. step-strictly
  20. :controls="false"
  21. ></el-input-number>
  22. </el-form-item>
  23. </el-form>
  24. <div slot="footer">
  25. <el-button type="primary" :disabled="isSubmit" @click="submit"
  26. >确认</el-button
  27. >
  28. <el-button @click="cancel">取消</el-button>
  29. </div>
  30. </el-dialog>
  31. </template>
  32. <script>
  33. import { updateCourseOutlineTargetPredict } from "../../api";
  34. const initModalForm = {
  35. obeCourseOutlineId: null,
  36. expectValue: "",
  37. };
  38. export default {
  39. name: "modify-training-plan-requirement-predict",
  40. props: {
  41. rowData: {
  42. type: Object,
  43. default() {
  44. return {};
  45. },
  46. },
  47. },
  48. data() {
  49. return {
  50. modalIsShow: false,
  51. isSubmit: false,
  52. modalForm: { ...initModalForm },
  53. rules: {
  54. expectValue: [
  55. {
  56. required: true,
  57. message: "请输入课程目标预期值",
  58. trigger: "change",
  59. },
  60. ],
  61. },
  62. };
  63. },
  64. methods: {
  65. visibleChange() {
  66. this.modalForm = {
  67. obeCourseOutlineId: this.rowData.id,
  68. expectValue: this.rowData.expectValue,
  69. };
  70. },
  71. cancel() {
  72. this.modalIsShow = false;
  73. },
  74. open() {
  75. this.modalIsShow = true;
  76. },
  77. async submit() {
  78. const valid = await this.$refs.modalFormComp.validate().catch(() => {});
  79. if (!valid) return;
  80. if (this.isSubmit) return;
  81. this.isSubmit = true;
  82. const data = await updateCourseOutlineTargetPredict(this.modalForm).catch(
  83. () => {}
  84. );
  85. this.isSubmit = false;
  86. if (!data) return;
  87. this.$message.success("修改成功!");
  88. this.$emit("modified");
  89. this.cancel();
  90. },
  91. },
  92. };
  93. </script>