2024-04-18 18:27:22 +07:00
|
|
|
<script setup lang="ts">
|
2024-04-19 11:09:36 +07:00
|
|
|
import { ref, watch } from 'vue';
|
2024-04-19 09:06:38 +07:00
|
|
|
|
2024-04-18 18:27:22 +07:00
|
|
|
defineProps<{
|
|
|
|
|
title: string;
|
2024-04-19 09:06:38 +07:00
|
|
|
isEdit?: boolean;
|
2024-04-19 10:49:14 +07:00
|
|
|
bgOn?: boolean;
|
2024-04-18 18:27:22 +07:00
|
|
|
editData?: (...args: unknown[]) => void;
|
|
|
|
|
deleteData?: (...args: unknown[]) => void;
|
|
|
|
|
submit?: (...args: unknown[]) => void;
|
|
|
|
|
close?: (...args: unknown[]) => void;
|
2024-04-19 09:06:38 +07:00
|
|
|
undo?: (...args: unknown[]) => void;
|
2024-04-18 18:27:22 +07:00
|
|
|
}>();
|
|
|
|
|
|
2024-04-19 11:09:36 +07:00
|
|
|
// const drawerWidth = ref(window.screen.width * 0.8);
|
2024-04-18 18:27:22 +07:00
|
|
|
const drawerOpen = defineModel<boolean>('drawerOpen', {
|
|
|
|
|
default: false,
|
|
|
|
|
});
|
2024-04-19 09:06:38 +07:00
|
|
|
|
|
|
|
|
const myForm = ref();
|
|
|
|
|
|
|
|
|
|
function reset() {
|
|
|
|
|
if (myForm.value) {
|
|
|
|
|
myForm.value.resetValidation();
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-04-19 11:09:36 +07:00
|
|
|
|
|
|
|
|
// watch(
|
|
|
|
|
// () => window.screen.width,
|
|
|
|
|
// (v) => {
|
|
|
|
|
// console.log(v);
|
|
|
|
|
|
|
|
|
|
// drawerWidth.value = v;
|
|
|
|
|
// },
|
|
|
|
|
// );
|
2024-04-18 18:27:22 +07:00
|
|
|
</script>
|
|
|
|
|
<template>
|
|
|
|
|
<q-drawer
|
2024-04-19 09:06:38 +07:00
|
|
|
@before-hide="reset"
|
2024-04-18 18:27:22 +07:00
|
|
|
@hide="close"
|
2024-04-19 11:09:36 +07:00
|
|
|
:width="$q.screen.gt.md ? 1200 : $q.screen.gt.xs ? 700 : 900"
|
|
|
|
|
:breakpoint="1366"
|
2024-04-18 18:27:22 +07:00
|
|
|
v-model="drawerOpen"
|
|
|
|
|
behavior="mobile"
|
|
|
|
|
side="right"
|
|
|
|
|
show-if-above
|
|
|
|
|
>
|
2024-04-19 09:06:38 +07:00
|
|
|
<q-form
|
|
|
|
|
ref="myForm"
|
|
|
|
|
class="full-height"
|
|
|
|
|
greedy
|
|
|
|
|
@submit.prevent
|
|
|
|
|
@validation-success="submit"
|
2024-04-18 18:27:22 +07:00
|
|
|
>
|
2024-04-19 09:06:38 +07:00
|
|
|
<AppBox
|
|
|
|
|
class="column justify-between full-height"
|
|
|
|
|
style="padding: 0; border-radius: var(--radius-2)"
|
|
|
|
|
>
|
|
|
|
|
<div class="form-header col q-px-lg row items-center">
|
|
|
|
|
<div v-if="isEdit" class="row">
|
|
|
|
|
<q-btn
|
|
|
|
|
round
|
|
|
|
|
flat
|
|
|
|
|
id="closeDialog"
|
|
|
|
|
icon="mdi-undo"
|
|
|
|
|
padding="xs"
|
|
|
|
|
class="q-mr-md"
|
|
|
|
|
:class="{ dark: $q.dark.isActive }"
|
|
|
|
|
style="color: var(--brand-1)"
|
|
|
|
|
@click="undo"
|
|
|
|
|
/>
|
|
|
|
|
<div style="width: 31.98px"></div>
|
|
|
|
|
</div>
|
|
|
|
|
<div v-else>
|
|
|
|
|
<q-btn
|
|
|
|
|
round
|
|
|
|
|
flat
|
|
|
|
|
id="editDialog"
|
|
|
|
|
icon="mdi-pencil-outline"
|
|
|
|
|
padding="xs"
|
|
|
|
|
class="q-mr-md"
|
|
|
|
|
:class="{ dark: $q.dark.isActive }"
|
|
|
|
|
style="color: var(--brand-1)"
|
|
|
|
|
@click="editData"
|
|
|
|
|
/>
|
|
|
|
|
<q-btn
|
|
|
|
|
round
|
|
|
|
|
flat
|
|
|
|
|
id="deleteDialog"
|
|
|
|
|
icon="mdi-trash-can-outline"
|
|
|
|
|
padding="xs"
|
|
|
|
|
:class="{ dark: $q.dark.isActive }"
|
|
|
|
|
style="color: hsl(var(--negative-bg))"
|
|
|
|
|
@click="deleteData"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="col text-subtitle1 text-weight-bold text-center">
|
|
|
|
|
{{ title }}
|
|
|
|
|
</div>
|
2024-04-18 18:27:22 +07:00
|
|
|
|
2024-04-19 09:06:38 +07:00
|
|
|
<div style="width: 31.98px"></div>
|
|
|
|
|
<q-btn
|
|
|
|
|
round
|
|
|
|
|
flat
|
|
|
|
|
id="closeDialog"
|
|
|
|
|
icon="mdi-close"
|
|
|
|
|
padding="xs"
|
|
|
|
|
class="close-btn"
|
|
|
|
|
:class="{ dark: $q.dark.isActive }"
|
|
|
|
|
type="reset"
|
|
|
|
|
@click="close"
|
|
|
|
|
resetValidation
|
|
|
|
|
/>
|
2024-04-18 18:27:22 +07:00
|
|
|
</div>
|
|
|
|
|
|
2024-04-19 09:06:38 +07:00
|
|
|
<div
|
|
|
|
|
class="col-10 form-body"
|
|
|
|
|
style="position: relative"
|
2024-04-18 18:27:22 +07:00
|
|
|
:class="{ dark: $q.dark.isActive }"
|
2024-04-19 10:49:14 +07:00
|
|
|
:style="` ${bgOn ? `background-image: url(/personnel-info-bg-${$q.dark.isActive ? 'dark' : 'light'}.png)` : ''}`"
|
2024-04-19 09:06:38 +07:00
|
|
|
>
|
|
|
|
|
<slot name="info"></slot>
|
|
|
|
|
</div>
|
2024-04-18 18:27:22 +07:00
|
|
|
|
2024-04-19 09:06:38 +07:00
|
|
|
<div
|
|
|
|
|
class="form-footer col q-pr-lg row items-center justify-end q-gutter-x-lg"
|
|
|
|
|
>
|
|
|
|
|
<q-btn
|
|
|
|
|
dense
|
|
|
|
|
outline
|
|
|
|
|
unelevated
|
|
|
|
|
id="cancelBtn"
|
|
|
|
|
class="q-px-md app-text-negative"
|
|
|
|
|
:label="$t('cancel')"
|
|
|
|
|
type="reset"
|
|
|
|
|
@click="close"
|
|
|
|
|
/>
|
|
|
|
|
<q-btn
|
|
|
|
|
v-if="isEdit"
|
|
|
|
|
dense
|
|
|
|
|
unelevated
|
|
|
|
|
id="submitBtn"
|
|
|
|
|
type="submit"
|
|
|
|
|
color="primary"
|
|
|
|
|
class="q-px-md"
|
|
|
|
|
:label="$t('save')"
|
|
|
|
|
/>
|
|
|
|
|
<q-btn
|
|
|
|
|
v-else
|
|
|
|
|
dense
|
|
|
|
|
unelevated
|
|
|
|
|
id="okBtn"
|
|
|
|
|
color="primary"
|
|
|
|
|
class="q-px-md"
|
|
|
|
|
label="ตกลง"
|
|
|
|
|
@click="close"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</AppBox>
|
|
|
|
|
</q-form>
|
2024-04-18 18:27:22 +07:00
|
|
|
</q-drawer>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<style scoped lang="scss">
|
|
|
|
|
.close-btn {
|
|
|
|
|
color: hsl(var(--negative-bg));
|
|
|
|
|
background-color: hsla(var(--negative-bg) / 0.1);
|
|
|
|
|
|
|
|
|
|
&.dark {
|
|
|
|
|
background-color: transparent;
|
|
|
|
|
border: 1px solid hsl(var(--negative-bg));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.form-header {
|
|
|
|
|
border-bottom: 1px solid var(--border-color);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.form-body {
|
|
|
|
|
--_body-bg: var(--sand-0);
|
|
|
|
|
background-color: var(--_body-bg);
|
|
|
|
|
background-repeat: no-repeat;
|
|
|
|
|
background-size: cover;
|
|
|
|
|
&.dark {
|
|
|
|
|
--_body-bg: var(--gray-10);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.form-footer {
|
|
|
|
|
border-top: 1px solid var(--border-color);
|
|
|
|
|
}
|
|
|
|
|
</style>
|