2024-12-12 16:07:42 +08:00
|
|
|
<script setup lang="ts">
|
|
|
|
import { onMounted } from 'vue';
|
|
|
|
import { useRoute } from 'vue-router';
|
|
|
|
|
|
|
|
import { Card } from 'ant-design-vue';
|
|
|
|
import dayjs from 'dayjs';
|
|
|
|
|
|
|
|
import { useVbenForm } from '#/adapter/form';
|
|
|
|
|
|
|
|
import { leaveInfo } from './api';
|
|
|
|
import { modalSchema } from './data';
|
|
|
|
|
|
|
|
const route = useRoute();
|
|
|
|
const disabled = route.query?.readonly === 'true';
|
|
|
|
const id = route.query?.id as string;
|
|
|
|
|
|
|
|
const [BasicForm, formApi] = useVbenForm({
|
|
|
|
commonConfig: {
|
|
|
|
// 默认占满两列
|
|
|
|
formItemClass: 'col-span-2',
|
|
|
|
// 默认label宽度 px
|
|
|
|
labelWidth: 80,
|
|
|
|
// 通用配置项 会影响到所有表单项
|
|
|
|
componentProps: {
|
|
|
|
class: 'w-full',
|
|
|
|
disabled,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
schema: modalSchema(),
|
|
|
|
showDefaultActions: false,
|
|
|
|
wrapperClass: 'grid-cols-2',
|
|
|
|
fieldMappingTime: [
|
|
|
|
[
|
|
|
|
'dateRange',
|
|
|
|
['startDate', 'endDate'],
|
|
|
|
['YYYY-MM-DD 00:00:00', 'YYYY-MM-DD 23:59:59'],
|
|
|
|
],
|
|
|
|
],
|
|
|
|
});
|
|
|
|
|
|
|
|
onMounted(async () => {
|
|
|
|
// 只读 获取信息赋值
|
|
|
|
if (id && disabled) {
|
|
|
|
const resp = await leaveInfo(id);
|
|
|
|
await formApi.setValues(resp);
|
|
|
|
const dateRange = [dayjs(resp.startDate), dayjs(resp.endDate)];
|
|
|
|
await formApi.setFieldValue('dateRange', dateRange);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<Card>
|
2024-12-16 13:53:58 +08:00
|
|
|
<div id="leave-form">
|
|
|
|
<BasicForm />
|
|
|
|
</div>
|
2024-12-12 16:07:42 +08:00
|
|
|
</Card>
|
|
|
|
</template>
|
2024-12-16 13:53:58 +08:00
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
|
/**
|
|
|
|
去除 '菜单加载中' 主要是iframe内嵌使用
|
|
|
|
*/
|
|
|
|
html:has(#leave-form) {
|
|
|
|
.ant-message-notice-content:has(.ant-message-loading) {
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|