modifyTask.vue 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <template>
  2. <a-modal
  3. v-model:visible="visible"
  4. title-align="start"
  5. :width="800"
  6. :footer="false"
  7. top="10vh"
  8. :align-center="false"
  9. @before-open="modalBeforeOpen"
  10. >
  11. <template #title> {{ title }} </template>
  12. <a-tabs
  13. v-if="isEdit"
  14. v-model:activeKey="compType"
  15. type="card-gutter"
  16. hide-content
  17. >
  18. <a-tab-pane key="rule" title="基础规则"> </a-tab-pane>
  19. <a-tab-pane key="time" title="预约时段"> </a-tab-pane>
  20. <a-tab-pane key="notice" title="考试说明"> </a-tab-pane>
  21. </a-tabs>
  22. <component
  23. :is="formComp"
  24. v-if="visible"
  25. :row-data="rowData"
  26. @cancel="close"
  27. @modified="modifiedHandle"
  28. ></component>
  29. </a-modal>
  30. </template>
  31. <script setup lang="ts">
  32. import { computed, ref } from 'vue';
  33. import useModal from '@/hooks/modal';
  34. import { TaskItem } from '@/api/types/order';
  35. import ruleForm from './ruleForm.vue';
  36. import timeForm from './timeForm.vue';
  37. import noticeForm from './noticeForm.vue';
  38. defineOptions({
  39. name: 'ModifyTask',
  40. });
  41. /* modal */
  42. const { visible, open, close } = useModal();
  43. defineExpose({ open, close });
  44. const props = defineProps<{
  45. rowData: TaskItem;
  46. }>();
  47. const emit = defineEmits(['modified']);
  48. const isEdit = computed(() => !!props.rowData.id);
  49. const title = computed(() => `${isEdit.value ? '编辑' : '新增'}任务`);
  50. const comps = {
  51. rule: ruleForm,
  52. time: timeForm,
  53. noitce: noticeForm,
  54. };
  55. const compType = ref('rule');
  56. const formComp = computed(() => comps[compType.value]);
  57. function modifiedHandle() {
  58. emit('modified');
  59. if (isEdit.value) return;
  60. close();
  61. }
  62. function modalBeforeOpen() {
  63. compType.value = 'rule';
  64. }
  65. </script>