2025-07-07 16:31:20 +08:00
|
|
|
<script setup lang="ts">
|
2025-07-07 17:24:28 +08:00
|
|
|
import {onMounted, ref} from 'vue';
|
2025-07-07 16:31:20 +08:00
|
|
|
import { useVbenModal } from '@vben/common-ui';
|
|
|
|
import { cloneDeep } from '@vben/utils';
|
|
|
|
import { useVbenForm } from '#/adapter/form';
|
|
|
|
import { attachAdd, attachInfo, attachUpdate } from '#/api/property/roomBooking/conferenceAddServices';
|
|
|
|
import { defaultFormValueGetter, useBeforeCloseDiff } from '#/utils/popup';
|
|
|
|
import { modalSchema } from './data';
|
|
|
|
|
2025-07-07 17:24:28 +08:00
|
|
|
const emit = defineEmits<{ reload: [] }>();
|
2025-07-07 16:31:20 +08:00
|
|
|
const [BasicForm, formApi] = useVbenForm({
|
|
|
|
commonConfig: {
|
|
|
|
// 默认占满两列
|
|
|
|
formItemClass: 'col-span-1',
|
|
|
|
// 默认label宽度 px
|
|
|
|
labelWidth: 80,
|
|
|
|
// 通用配置项 会影响到所有表单项
|
|
|
|
componentProps: {
|
|
|
|
class: 'w-full',
|
|
|
|
}
|
|
|
|
},
|
|
|
|
schema: modalSchema(),
|
|
|
|
showDefaultActions: false,
|
|
|
|
wrapperClass: 'grid-cols-2',
|
|
|
|
});
|
|
|
|
|
|
|
|
const { onBeforeClose, markInitialized, resetInitialized } = useBeforeCloseDiff(
|
|
|
|
{
|
|
|
|
initializedGetter: defaultFormValueGetter(formApi),
|
|
|
|
currentGetter: defaultFormValueGetter(formApi),
|
|
|
|
},
|
|
|
|
);
|
|
|
|
|
|
|
|
const [BasicModal, modalApi] = useVbenModal({
|
|
|
|
class: 'w-[60%]',
|
|
|
|
fullscreenButton: false,
|
|
|
|
onBeforeClose,
|
|
|
|
onClosed: handleClosed,
|
|
|
|
onConfirm: handleConfirm,
|
|
|
|
});
|
|
|
|
|
|
|
|
async function handleConfirm() {
|
|
|
|
try {
|
|
|
|
modalApi.lock(true);
|
|
|
|
const { valid } = await formApi.validate();
|
|
|
|
if (!valid) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// getValues获取为一个readonly的对象 需要修改必须先深拷贝一次
|
|
|
|
const data = cloneDeep(await formApi.getValues());
|
2025-07-07 17:24:28 +08:00
|
|
|
await (attachAdd(data));
|
2025-07-07 16:31:20 +08:00
|
|
|
resetInitialized();
|
|
|
|
emit('reload');
|
|
|
|
modalApi.close();
|
|
|
|
} catch (error) {
|
|
|
|
console.error(error);
|
|
|
|
} finally {
|
|
|
|
modalApi.lock(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
async function handleClosed() {
|
|
|
|
await formApi.resetForm();
|
|
|
|
resetInitialized();
|
|
|
|
}
|
|
|
|
|
2025-07-07 17:24:28 +08:00
|
|
|
async function handleOpenChange() {
|
|
|
|
const { id } = modalApi.getData() as { id?: number };
|
|
|
|
if(id){
|
|
|
|
const response = await attachInfo(id);
|
|
|
|
conferenceReservationsDetail.value = response;
|
|
|
|
}
|
|
|
|
}
|
2025-07-07 16:31:20 +08:00
|
|
|
|
2025-07-07 17:24:28 +08:00
|
|
|
onMounted(()=>{
|
|
|
|
handleOpenChange()
|
2025-07-07 16:31:20 +08:00
|
|
|
})
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<BasicModal title="会议室预约">
|
|
|
|
<div class="detail-box">
|
|
|
|
<div><span>会议室名称: 会议室01</span><span>容纳人数: 50</span></div>
|
|
|
|
<div><span>会议室地址: 5楼505</span><span>配套设备: 话筒、音响、大屏。。</span></div>
|
|
|
|
<div><span>会议室负责人: 王林</span><span>联系电话: 15809875678</span></div>
|
|
|
|
<div><span>基础费用: 600元</span><span></span></div>
|
|
|
|
</div>
|
|
|
|
<BasicForm />
|
|
|
|
<div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</BasicModal>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
|
.detail-box{
|
|
|
|
width: 100%;
|
|
|
|
|
|
|
|
div{
|
|
|
|
display: grid;
|
|
|
|
margin: 20px;
|
|
|
|
grid-template-columns: repeat(2, 1fr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
|