ModifyMarkerTaskCount.vue 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <template>
  2. <el-dialog
  3. :visible.sync="modalIsShow"
  4. title="设置评卷数"
  5. top="10vh"
  6. width="448px"
  7. :close-on-click-modal="false"
  8. :close-on-press-escape="false"
  9. append-to-body
  10. @opened="visibleChange"
  11. >
  12. <el-form ref="modalFormComp" :model="modalForm" :rules="rules">
  13. <el-form-item prop="topCount" label="任务数:">
  14. <el-input-number
  15. style="width: 125px"
  16. v-model="modalForm.topCount"
  17. :min="1"
  18. :max="9999999"
  19. :step="1"
  20. step-strictly
  21. :controls="false"
  22. ></el-input-number>
  23. </el-form-item>
  24. </el-form>
  25. <div slot="footer">
  26. <el-button type="primary" :loading="isSubmit" @click="submit"
  27. >确认</el-button
  28. >
  29. <el-button @click="cancel">取消</el-button>
  30. </div>
  31. </el-dialog>
  32. </template>
  33. <script>
  34. import { markMarkerSetTaskCount } from "../../api";
  35. const initModalForm = {
  36. topCount: null,
  37. };
  38. export default {
  39. name: "modify-marker-task-count",
  40. props: {
  41. ids: {
  42. type: Array,
  43. default() {
  44. return [];
  45. },
  46. },
  47. },
  48. data() {
  49. return {
  50. modalIsShow: false,
  51. isSubmit: false,
  52. modalForm: {},
  53. rules: {
  54. topCount: [
  55. {
  56. required: true,
  57. message: "请输入任务数量",
  58. trigger: "change",
  59. },
  60. ],
  61. },
  62. };
  63. },
  64. methods: {
  65. visibleChange() {
  66. this.modalForm = { ...initModalForm };
  67. this.$nextTick(() => {
  68. this.$refs.modalFormComp.clearValidate();
  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 datas = { ...this.modalForm, markUserGroupIds: this.ids };
  83. const res = await markMarkerSetTaskCount(datas).catch(() => {});
  84. this.isSubmit = false;
  85. if (!res) return;
  86. this.$message.success("设置成功!");
  87. this.cancel();
  88. this.$emit("modified");
  89. },
  90. },
  91. };
  92. </script>