ModifyFormalGradingTask.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. <template>
  2. <Modal
  3. class="modify-formal-grading-task"
  4. v-model="modalIsShow"
  5. title="创建正评任务"
  6. :mask-closable="false"
  7. @on-visible-change="visibleChange"
  8. >
  9. <Form
  10. ref="modalFormComp"
  11. class="modal-form"
  12. :model="modalForm"
  13. :rules="rules"
  14. :key="modalForm.id"
  15. :label-width="120"
  16. >
  17. <FormItem prop="questionId" label="考区">
  18. <Select
  19. size="large"
  20. v-model="modalForm.questionId"
  21. @on-change="areaChange"
  22. placeholder="请选择考区"
  23. >
  24. <Option
  25. v-for="(item, index) in areas"
  26. :key="index"
  27. :value="item.questionId"
  28. :label="item.areaName"
  29. ></Option>
  30. </Select>
  31. </FormItem>
  32. <FormItem label="已评数量">
  33. <Input
  34. size="large"
  35. v-model.trim="modalForm.successCount"
  36. readonly
  37. ></Input>
  38. </FormItem>
  39. <FormItem size="large" label="待评数量">
  40. <Input v-model.trim="modalForm.waitCount" readonly></Input>
  41. </FormItem>
  42. <FormItem size="large" label="整体进度">
  43. <Input v-model.trim="modalForm.progress" readonly></Input>
  44. </FormItem>
  45. <FormItem prop="taskCount" label="分配任务数量">
  46. <InputNumber
  47. size="large"
  48. :min="1"
  49. :max="modalForm.waitCount"
  50. :precision="0"
  51. v-model.trim="modalForm.taskCount"
  52. style="width: 120px"
  53. clearable
  54. ></InputNumber>
  55. </FormItem>
  56. </Form>
  57. <div slot="footer">
  58. <Button shape="circle" type="primary" :disabled="isSubmit" @click="submit"
  59. >发布</Button
  60. >
  61. <Button shape="circle" @click="cancel">取消</Button>
  62. </div>
  63. </Modal>
  64. </template>
  65. <script>
  66. import { checkMissionStatus, createGradingTask, areaStatProgress } from "@/api";
  67. import { numberValidator } from "@/plugins/formRules";
  68. const initModalForm = {
  69. questionId: null,
  70. totalCount: 0,
  71. successCount: 0,
  72. waitCount: 0,
  73. progress: 0,
  74. taskCount: 1
  75. };
  76. export default {
  77. name: "modify-formal-grading-task",
  78. props: {
  79. subjectId: {
  80. type: String,
  81. required: true
  82. }
  83. },
  84. data() {
  85. return {
  86. modalIsShow: false,
  87. isSubmit: false,
  88. modalForm: { ...initModalForm },
  89. areas: [],
  90. rules: {
  91. taskCount: numberValidator("请输入分配任务数量")
  92. }
  93. };
  94. },
  95. methods: {
  96. visibleChange(visible) {
  97. if (visible) {
  98. this.getArea();
  99. }
  100. },
  101. async getArea() {
  102. const data = await areaStatProgress(this.subjectId);
  103. this.areas = data;
  104. this.modalForm.questionId = data[data.length - 1].questionId;
  105. this.areaChange();
  106. },
  107. areaChange() {
  108. const curArea = this.areas.find(
  109. item => item.questionId === this.modalForm.questionId
  110. );
  111. this.modalForm = Object.assign({}, initModalForm, curArea);
  112. this.modalForm.progress += "%";
  113. },
  114. cancel() {
  115. this.modalIsShow = false;
  116. },
  117. open() {
  118. this.modalIsShow = true;
  119. },
  120. async submit() {
  121. const valid = await this.$refs.modalFormComp.validate();
  122. if (!valid) return;
  123. if (this.isSubmit) return;
  124. const ids = this.subjectId.split("-");
  125. await checkMissionStatus({ workId: ids[0], subject: ids[1] });
  126. this.isSubmit = true;
  127. let result = true;
  128. await createGradingTask({
  129. subjectId: this.subjectId,
  130. taskCount: this.modalForm.taskCount,
  131. questionId: this.modalForm.questionId
  132. }).catch(() => {
  133. result = false;
  134. });
  135. this.isSubmit = false;
  136. if (!result) return;
  137. this.$Modal.success({ content: "评卷任务创建成功" });
  138. this.$emit("modified");
  139. this.cancel();
  140. }
  141. }
  142. };
  143. </script>