|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
<template>
<BasicModal
v-bind="$attrs"
@register="register"
title="提交审核"
width="500px"
:bodyStyle="{ height: '240px' }"
@ok="handleOk"
>
请选择日期:
<a-date-picker v-model:value="date" />
</BasicModal>
</template>
<script lang="ts" setup>
import { BasicModal, useModalInner } from '@/components/Modal';
import { ref } from 'vue';
import { checkCommit } from '@/api/project/invoice';
|
|
18
|
import { useMessage } from '/@/hooks/web/useMessage';
|
|
19
20
21
|
const id = ref();
const date = ref();
|
|
22
|
const emit = defineEmits(['success']);
|
|
23
24
|
const { createMessage } = useMessage();
const { error } = createMessage;
|
|
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
const [register, { closeModal }] = useModalInner(async (data) => {
id.value = data.data.id;
});
function formatDate(input: string): string {
// 创建一个 Date 对象
const date = new Date(input);
// 获取年月日
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, '0'); // 月份从 0 开始,所以要加 1
const day = String(date.getDate()).padStart(2, '0');
// 返回格式化后的日期字符串
return `${year}-${month}-${day}`;
}
|
|
40
|
const isDisabled = ref(false);
|
|
41
|
async function handleOk() {
|
|
42
43
44
45
|
if (isDisabled.value) {
error('请勿连续点击生成按钮,需要等待三秒再点击生成');
return;
}
|
|
46
|
const formattedDate = formatDate(date.value);
|
|
47
48
49
50
|
isDisabled.value = true;
setTimeout(() => {
isDisabled.value = false;
}, 3000);
|
|
51
|
checkCommit({ id: id.value, actualPayedDate: formattedDate });
|
|
52
|
emit('success');
|
|
53
54
55
|
closeModal();
}
</script>
|