SendBackMark.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. <template>
  2. <base-dialog
  3. v-model="visible"
  4. :title="needRejectReason === true ? '打回原因' : '提示'"
  5. :footer="false"
  6. destroy-on-close
  7. :width="needRejectReason === true ? 550 : 330"
  8. >
  9. <template v-if="needRejectReason === true">
  10. <base-form ref="formRef" :model="model" :items="items" :rules="rules" label-width="72px">
  11. <el-form-item>
  12. <confirm-button @confirm="onSendBack" @cancel="onCancel"></confirm-button>
  13. </el-form-item>
  14. </base-form>
  15. </template>
  16. <!-- <base-form ref="formRef" :model="model" :items="items" :rules="rules" :label-width="useVW(72)"> -->
  17. <template v-else-if="needRejectReason === false">
  18. <h3 style="margin-top: 10px; margin-bottom: 40px">确定打回吗?</h3>
  19. <el-form-item>
  20. <confirm-button @confirm="onSendBack" @cancel="onCancel"></confirm-button>
  21. </el-form-item>
  22. </template>
  23. <!-- </base-form> -->
  24. </base-dialog>
  25. </template>
  26. <script setup lang="ts" name="SendBackMark">
  27. /** 打回弹窗 */
  28. import { reactive, withDefaults, watch, ref } from 'vue'
  29. import { ElFormItem, ElMessage } from 'element-plus'
  30. import BaseDialog from '@/components/element/BaseDialog.vue'
  31. import BaseForm from '../element/BaseForm.vue'
  32. import ConfirmButton from '../common/ConfirmButton.vue'
  33. import useVModel from '@/hooks/useVModel'
  34. import useForm from '@/hooks/useForm'
  35. import useFetch from '@/hooks/useFetch'
  36. import useVW from '@/hooks/useVW'
  37. import useMainStore from '@/store/main'
  38. import type { EpFormItem, EpFormRules } from 'global-type'
  39. const mainStore = useMainStore()
  40. const needRejectReason = ref<any>(null)
  41. const emits = defineEmits<{
  42. (e: 'rejected'): void
  43. }>()
  44. const props = withDefaults(
  45. defineProps<{
  46. modelValue: boolean
  47. id: number | undefined
  48. // 问题卷 | 系统抽查 | 自查卷
  49. type?: 'problem' | 'system-check' | 'self-check' | 'custom-check'
  50. }>(),
  51. { type: 'problem' }
  52. )
  53. const visible = useVModel(props)
  54. const { formRef, elFormRef } = useForm()
  55. const model = reactive({
  56. reason: '',
  57. description: '',
  58. })
  59. const { fetch: getExamInfo } = useFetch('getExamInfo')
  60. watch(visible, () => {
  61. if (!visible.value) {
  62. elFormRef?.value?.resetFields()
  63. } else {
  64. getExamInfo({ id: mainStore.myUserInfo?.examId as number }).then((result: any) => {
  65. needRejectReason.value = result.rejectReason
  66. })
  67. }
  68. })
  69. const rules: EpFormRules = {
  70. reason: [{ required: true, message: '请选择打回原因' }],
  71. description: [{ type: 'string', max: 50, message: '说明文字限制50字以内' }],
  72. }
  73. const reason = ['给分太高', '给分太低', '注意,评分偏紧', '注意,评分偏松', '评分不稳定,请认真评卷', '其他'].map((v) => ({
  74. label: v,
  75. value: v,
  76. }))
  77. const items: any[] = [
  78. { label: '打回原因', labelWidth: '80px', prop: 'reason', slotType: 'select', slot: { options: reason } },
  79. {
  80. label: '说明',
  81. labelWidth: '80px',
  82. prop: 'description',
  83. slotType: 'input',
  84. slot: { type: 'textarea', maxlength: 50, resize: 'none', rows: 6, showWordLimit: true },
  85. },
  86. ]
  87. const { fetch: rejectMarkHistory } = useFetch('rejectMarkHistory')
  88. const { fetch: rejectSystemSpotPaper } = useFetch('rejectSystemSpotPaper')
  89. const { fetch: rejectSelfCheckData } = useFetch('rejectSelfCheckData')
  90. const { fetch: rejectCustomCheckData } = useFetch('rejectCustomQueryTask')
  91. const ApiMap = {
  92. problem: rejectMarkHistory,
  93. 'system-check': rejectSystemSpotPaper,
  94. 'self-check': rejectSelfCheckData,
  95. 'custom-check': rejectCustomCheckData,
  96. }
  97. const onSendBack = async () => {
  98. try {
  99. if (!props.id) {
  100. ElMessage.warning('请选先选择一条评卷数据')
  101. return
  102. }
  103. // const valid = await elFormRef?.value?.validate()
  104. // if (valid) {
  105. // await ApiMap[props.type]({ description: model.description, reason: model.reason, id: props.id })
  106. if (props.type === 'custom-check') {
  107. await rejectCustomCheckData({ description: model.description, reason: model.reason, taskId: props.id })
  108. } else {
  109. await ApiMap[props.type]({ description: model.description, reason: model.reason, id: props.id })
  110. }
  111. // }
  112. visible.value = false
  113. // ElMessage.success('操作成功')
  114. emits('rejected')
  115. } catch (error) {
  116. console.error(error)
  117. }
  118. }
  119. const onCancel = () => {
  120. visible.value = false
  121. }
  122. </script>
  123. <style scoped lang="scss"></style>