SendBackMark.vue 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <template>
  2. <base-dialog v-model="visible" title="打回说明" :footer="false">
  3. <base-form ref="formRef" :model="model" :items="items" :rules="rules" :label-width="useVW(72)">
  4. <el-form-item>
  5. <confirm-button @confirm="onSendBack" @cancel="onCancel"></confirm-button>
  6. </el-form-item>
  7. </base-form>
  8. </base-dialog>
  9. </template>
  10. <script setup lang="ts" name="SendBackMark">
  11. /** 打回弹窗 */
  12. import { reactive, withDefaults } from 'vue'
  13. import { ElFormItem } from 'element-plus'
  14. import BaseDialog from '@/components/element/BaseDialog.vue'
  15. import BaseForm from '../element/BaseForm.vue'
  16. import ConfirmButton from '../common/ConfirmButton.vue'
  17. import useVModel from '@/hooks/useVModel'
  18. import useForm from '@/hooks/useForm'
  19. import useFetch from '@/hooks/useFetch'
  20. import useVW from '@/hooks/useVW'
  21. import type { EpFormItem } from 'global-type'
  22. const emits = defineEmits<{
  23. (e: 'rejected'): void
  24. }>()
  25. const props = withDefaults(
  26. defineProps<{
  27. modelValue: boolean
  28. id: number | undefined
  29. // 问题卷 | 系统抽查 | 自查卷
  30. type?: 'problem' | 'system-check' | 'self-check'
  31. }>(),
  32. { type: 'problem' }
  33. )
  34. const visible = useVModel(props)
  35. const { formRef, elFormRef } = useForm()
  36. const model = reactive({
  37. reason: '',
  38. description: '',
  39. })
  40. const rules = {
  41. reason: [{ required: true, message: '请选择打回原因' }],
  42. }
  43. const reason = ['给分太高', '给分太低', '注意,评分偏紧', '注意,评分偏松', '评分不稳定,请认真评卷'].map((v) => ({
  44. label: v,
  45. value: v,
  46. }))
  47. const items: EpFormItem[] = [
  48. { label: '打回原因', prop: 'reason', slotType: 'select', slot: { options: reason } },
  49. { label: '说明', prop: 'description', slotType: 'input', slot: { type: 'textarea' } },
  50. ]
  51. const { fetch: rejectMarkHistory } = useFetch('rejectMarkHistory')
  52. const { fetch: rejectSystemSpotPaper } = useFetch('rejectSystemSpotPaper')
  53. const { fetch: rejectSelfCheckData } = useFetch('rejectSelfCheckData')
  54. const ApiMap = {
  55. problem: rejectMarkHistory,
  56. 'system-check': rejectSystemSpotPaper,
  57. 'self-check': rejectSelfCheckData,
  58. }
  59. const onSendBack = async () => {
  60. try {
  61. if (!props.id) {
  62. return
  63. }
  64. const valid = await elFormRef?.value?.validate()
  65. if (valid) {
  66. await ApiMap[props.type]({ description: model.description, reason: model.reason, id: props.id })
  67. }
  68. visible.value = false
  69. emits('rejected')
  70. } catch (error) {
  71. console.error(error)
  72. }
  73. }
  74. const onCancel = () => {
  75. visible.value = false
  76. }
  77. </script>
  78. <style scoped lang="scss"></style>