ModifyTrainingPlanRequirement.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <template>
  2. <el-dialog
  3. :visible.sync="modalIsShow"
  4. :title="title"
  5. top="10vh"
  6. width="600px"
  7. :close-on-click-modal="false"
  8. :close-on-press-escape="false"
  9. append-to-body
  10. @open="visibleChange"
  11. >
  12. <el-form
  13. ref="modalFormComp"
  14. :model="modalForm"
  15. :key="modalForm.id"
  16. label-width="100px"
  17. >
  18. <template v-if="isNode">
  19. <el-form-item label="毕业要求:">
  20. {{ instance.parentName }}
  21. </el-form-item>
  22. <el-form-item label="指标点:">
  23. {{ instance.name }}
  24. </el-form-item>
  25. </template>
  26. <template v-else>
  27. <el-form-item label="毕业要求:">
  28. {{ instance.name }}
  29. </el-form-item>
  30. </template>
  31. <el-form-item label="内容:">
  32. <el-input
  33. v-model="modalForm.content"
  34. type="textarea"
  35. :autosize="{ minRows: 4, maxRows: 10 }"
  36. resize="none"
  37. placeholder="请输入内容"
  38. clearable
  39. maxlength="999"
  40. show-word-limit
  41. ></el-input>
  42. </el-form-item>
  43. </el-form>
  44. <div slot="footer">
  45. <el-button type="primary" :disabled="isSubmit" @click="submit"
  46. >确认</el-button
  47. >
  48. <el-button @click="cancel">取消</el-button>
  49. </div>
  50. </el-dialog>
  51. </template>
  52. <script>
  53. import { updateTrainingPlanRequirement } from "../../api";
  54. const initModalForm = {
  55. id: null,
  56. parentId: "",
  57. name: "",
  58. content: "",
  59. };
  60. export default {
  61. name: "modify-training-plan-requirement",
  62. props: {
  63. instance: {
  64. type: Object,
  65. default() {
  66. return {};
  67. },
  68. },
  69. },
  70. data() {
  71. return {
  72. modalIsShow: false,
  73. isSubmit: false,
  74. modalForm: { ...initModalForm },
  75. };
  76. },
  77. computed: {
  78. isNode() {
  79. return !!this.instance.parentId;
  80. },
  81. title() {
  82. const typeName = this.isNode ? "指标点" : "毕业要求";
  83. return `编辑${typeName}`;
  84. },
  85. },
  86. methods: {
  87. visibleChange() {
  88. this.modalForm = this.$objAssign(initModalForm, this.instance);
  89. },
  90. cancel() {
  91. this.modalIsShow = false;
  92. },
  93. open() {
  94. this.modalIsShow = true;
  95. },
  96. async submit() {
  97. const valid = await this.$refs.modalFormComp.validate().catch(() => {});
  98. if (!valid) return;
  99. if (this.isSubmit) return;
  100. this.isSubmit = true;
  101. const data = await updateTrainingPlanRequirement(this.modalForm).catch(
  102. () => {}
  103. );
  104. this.isSubmit = false;
  105. if (!data) return;
  106. this.$message.success("修改成功!");
  107. this.$emit("modified");
  108. this.cancel();
  109. },
  110. },
  111. };
  112. </script>