ModifyCourseExamineEvaluation.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. <template>
  2. <el-dialog
  3. class="modify-semester"
  4. :visible.sync="modalIsShow"
  5. :title="title"
  6. top="10vh"
  7. width="700px"
  8. :close-on-click-modal="false"
  9. :close-on-press-escape="false"
  10. append-to-body
  11. @open="visibleChange"
  12. >
  13. <el-form
  14. ref="modalFormComp"
  15. :model="modalForm"
  16. :rules="rules"
  17. label-width="120px"
  18. label-position="top"
  19. >
  20. <el-form-item prop="evaluation" label="评价方式:">
  21. <el-input
  22. v-model.trim="modalForm.evaluation"
  23. placeholder="请输入评价方式"
  24. clearable
  25. :disabled="isEdit"
  26. ></el-input>
  27. </el-form-item>
  28. <el-form-item prop="evaluationDesc" label="评价方式描述:">
  29. <el-input
  30. v-model="modalForm.evaluationDesc"
  31. placeholder="请输入评价方式描述"
  32. type="textarea"
  33. :autosize="{ minRows: 4, maxRows: 10 }"
  34. :maxlength="999"
  35. resize="none"
  36. show-word-limit
  37. ></el-input>
  38. </el-form-item>
  39. </el-form>
  40. <div slot="footer">
  41. <el-button type="primary" :disabled="isSubmit" @click="submit"
  42. >确认</el-button
  43. >
  44. <el-button @click="cancel">取消</el-button>
  45. </div>
  46. </el-dialog>
  47. </template>
  48. <script>
  49. import { updateCourseExamineEvaluation } from "../../api";
  50. import { mapState } from "vuex";
  51. const initModalForm = {
  52. evaluationId: null,
  53. obeCourseOutlineId: "",
  54. evaluation: "",
  55. evaluationDesc: "",
  56. };
  57. export default {
  58. name: "modify-course-examine-evaluation",
  59. props: {
  60. instance: {
  61. type: Object,
  62. default() {
  63. return {};
  64. },
  65. },
  66. },
  67. computed: {
  68. ...mapState("target", ["cwStatus"]),
  69. isEdit() {
  70. return !!this.instance.evaluationId;
  71. },
  72. title() {
  73. return (this.isEdit ? "编辑" : "新增") + "评价方式";
  74. },
  75. },
  76. data() {
  77. return {
  78. modalIsShow: false,
  79. isSubmit: false,
  80. modalForm: { ...initModalForm },
  81. rules: {
  82. evaluation: [
  83. {
  84. required: true,
  85. message: "请输入评价方式",
  86. trigger: "change",
  87. },
  88. {
  89. message: "评价方式不能超过30个字",
  90. max: 30,
  91. trigger: "change",
  92. },
  93. ],
  94. evaluationDesc: [
  95. {
  96. required: true,
  97. max: 999,
  98. message: "评价方式描述不能超过999个字",
  99. trigger: "change",
  100. },
  101. ],
  102. },
  103. };
  104. },
  105. methods: {
  106. initData(val) {
  107. this.modalForm = this.$objAssign(initModalForm, val);
  108. },
  109. visibleChange() {
  110. this.initData(this.instance);
  111. },
  112. cancel() {
  113. this.modalIsShow = false;
  114. },
  115. open() {
  116. this.modalIsShow = true;
  117. },
  118. async submit() {
  119. const valid = await this.$refs.modalFormComp.validate().catch(() => {});
  120. if (!valid) return;
  121. if (this.cwStatus.everSettingStatus) {
  122. const confirm = await this.$confirm(
  123. `${this.title}会影响权重设置,确定要${this.title}吗?`,
  124. "提示",
  125. {
  126. type: "warning",
  127. }
  128. ).catch(() => {});
  129. if (confirm !== "confirm") return;
  130. }
  131. if (this.isSubmit) return;
  132. this.isSubmit = true;
  133. let datas = { ...this.modalForm, id: this.modalForm.evaluationId };
  134. const res = await updateCourseExamineEvaluation(datas).catch(() => {});
  135. this.isSubmit = false;
  136. if (!res) return;
  137. this.$message.success(this.title + "成功!");
  138. if (res.warning) {
  139. this.$notify({
  140. title: "警告",
  141. message: "评价方式有变化,请重新设置权重设置!",
  142. type: "warning",
  143. duration: 5000,
  144. });
  145. }
  146. this.$emit("modified");
  147. this.cancel();
  148. },
  149. },
  150. };
  151. </script>