123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- <template>
- <BasicModal
- @ok="handleSubmit"
- :destroyOnClose="true"
- :maskClosable="false"
- v-bind="$attrs"
- @register="registerModal"
- :title="getTitle"
- :width="1002"
- showFooter
- >
- <BasicForm @register="registerForm" />
- </BasicModal>
- </template>
- <script setup lang="ts">
- import { ref, computed, unref } from 'vue';
- import { BasicModal, useModalInner } from '/@/components/Modal';
- import { BasicForm, useForm } from '/@/components/Form/index';
- import { formSchema } from '../data.config';
- import { postClasstimeClassTimeStatistics } from '/@/services/apis/ClassTimeStatisticsController';
- import { formatToDate } from '/@/utils/dateUtil';
- const isUpdate = ref(true);
- const emit = defineEmits(['success', 'register']);
- const [registerForm, { validate, resetFields }] = useForm({
- labelWidth: 100,
- schemas: formSchema,
- showActionButtonGroup: false,
- });
- const [registerModal, { closeModal, setModalProps }] = useModalInner(async (data) => {
- resetFields();
- setModalProps({ confirmLoading: false });
- isUpdate.value = !!data?.isUpdate;
- });
- const getTitle = computed(() =>
- !unref(isUpdate) ? '请选择需要统计课时时间段' : '请选择需要统计课时时间段',
- );
- const handleSubmit = async () => {
- try {
- const values = await validate();
- setModalProps({ confirmLoading: true });
- const postParams: Recordable = {
- year: formatToDate(values['yearMonth'], 'YYYY'),
- month: formatToDate(values['yearMonth'], 'MM'),
- startDate: values['date'][0],
- endDate: values['date'][1],
- };
- await postClasstimeClassTimeStatistics(postParams as API.AddClassTimeStatisticsDto);
- closeModal();
- emit('success');
- } finally {
- setModalProps({ confirmLoading: false });
- }
- };
- </script>
- <style scoped lang="less"></style>
|