<template>
|
<app-page-form v-bind="pageFormProps" v-loading="appStore.getLoading('getEntity')">
|
<base-info v-bind="baseInfoProps"/>
|
<editor-form v-bind="editorFormProps"/>
|
</app-page-form>
|
</template>
|
|
<script setup>
|
|
import BaseInfo from './BaseInfo';
|
import EditorForm from './EditorForm';
|
import {closeTab} from '@/utils/iframe.js';
|
import {useAppStore, useEntityStore} from "@/store/modules";
|
import {convertFilter} from "@/utils/filter.js";
|
import * as baseApi from "@/api/index.js";
|
|
const entityStore = useEntityStore();
|
const appStore = useAppStore();
|
|
const router = useRouter();
|
|
const baseInfoRef = ref();
|
|
const baseInfoProps = {
|
ref: baseInfoRef,
|
}
|
|
const params = router.currentRoute.value.query;
|
|
const onReset = async () => {
|
if (params.id) {
|
const {data} = await entityStore.getEntity({
|
dataName: "affiche",
|
filter: convertFilter({
|
andEqParams: {
|
id: params.id
|
}
|
})
|
});
|
|
const content = await baseApi.file.getFileText(data.affiche.file_id);
|
baseInfoRef.value.onSetData(data.affiche);
|
editorFormRef.value.onSetData({content});
|
return;
|
}
|
baseInfoRef.value.onSetData({});
|
editorFormRef.value.onSetData({});
|
|
}
|
|
onMounted(async () => {
|
await onReset();
|
});
|
|
const editorFormRef = ref();
|
|
const editorFormProps = {
|
ref: editorFormRef,
|
}
|
|
|
const pageFormProps = {
|
subClose() {
|
closeTab();
|
},
|
async subSubmit() {
|
const baseInfo = await baseInfoRef.value.onGetData();
|
const content = await editorFormRef.value.onGetData();
|
await entityStore.dataEntity({
|
dataName: 'affiche',
|
data: {
|
affiche: {
|
...baseInfo,
|
content
|
}
|
}
|
});
|
closeTab();
|
},
|
async subReset() {
|
await onReset();
|
},
|
}
|
|
</script>
|