refactor: bind form crud
Some checks failed
Spell Check / Spell Check with Typos (push) Failing after 9s
Some checks failed
Spell Check / Spell Check with Typos (push) Failing after 9s
This commit is contained in:
parent
aecfc4ec57
commit
1268f6e35f
5 changed files with 177 additions and 39 deletions
124
src/components/04_property-management/FormProperty.vue
Normal file
124
src/components/04_property-management/FormProperty.vue
Normal file
|
|
@ -0,0 +1,124 @@
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { computed } from 'vue';
|
||||||
|
import SelectBranch from '../shared/select/SelectBranch.vue';
|
||||||
|
import { getRole } from 'src/services/keycloak';
|
||||||
|
|
||||||
|
const name = defineModel<string>('name');
|
||||||
|
const nameEN = defineModel<string>('nameEn');
|
||||||
|
const type = defineModel<Record<string, any>>('type');
|
||||||
|
const registeredBranchId = defineModel<string>('registeredBranchId');
|
||||||
|
|
||||||
|
const isAdmin = computed(() => {
|
||||||
|
const roles = getRole() || [];
|
||||||
|
return roles.includes('system');
|
||||||
|
});
|
||||||
|
|
||||||
|
defineProps<{
|
||||||
|
readonly?: boolean;
|
||||||
|
onDrawer?: boolean;
|
||||||
|
inputOnly?: boolean;
|
||||||
|
}>();
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<section class="q-px-md q-py-sm">
|
||||||
|
<div
|
||||||
|
:class="{ 'surface-1 rounded bordered': readonly }"
|
||||||
|
style="border: 1px solid transparent"
|
||||||
|
>
|
||||||
|
<div class="q-col-gutter-sm">
|
||||||
|
<q-input
|
||||||
|
:for="`input-name-${onDrawer ? 'drawer' : 'dialog'}`"
|
||||||
|
:bg-color="readonly ? 'transparent' : ''"
|
||||||
|
:readonly
|
||||||
|
class="col-md-6 col-12"
|
||||||
|
hide-bottom-space
|
||||||
|
dense
|
||||||
|
outlined
|
||||||
|
:label="$t('property.dialog.name')"
|
||||||
|
:model-value="!readonly ? name : name || '-'"
|
||||||
|
@update:model-value="(v) => (name = v?.toString() || '')"
|
||||||
|
:rules="[(val: string) => !!val || $t('form.error.required')]"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<q-input
|
||||||
|
:for="`input-nameEn-${onDrawer ? 'drawer' : 'dialog'}`"
|
||||||
|
:bg-color="readonly ? 'transparent' : ''"
|
||||||
|
:readonly
|
||||||
|
class="col-md-6 col-12"
|
||||||
|
hide-bottom-space
|
||||||
|
dense
|
||||||
|
outlined
|
||||||
|
:label="$t('property.dialog.nameEn')"
|
||||||
|
:model-value="!readonly ? nameEN : nameEN || '-'"
|
||||||
|
@update:model-value="(v) => (nameEN = v?.toString() || '')"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<q-input
|
||||||
|
:for="`input-type-${onDrawer ? 'drawer' : 'dialog'}`"
|
||||||
|
:bg-color="readonly ? 'transparent' : ''"
|
||||||
|
:readonly
|
||||||
|
class="col-md-6 col-12"
|
||||||
|
hide-bottom-space
|
||||||
|
dense
|
||||||
|
outlined
|
||||||
|
:label="$t('property.dialog.type')"
|
||||||
|
:model-value="!readonly ? type : type || '-'"
|
||||||
|
@update:model-value="(v) => (type = v?.toString() || '')"
|
||||||
|
:rules="[(val: string) => !!val || $t('form.error.required')]"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<SelectBranch
|
||||||
|
v-if="isAdmin"
|
||||||
|
v-model:value="registeredBranchId"
|
||||||
|
:label="$t('quotation.branchVirtual')"
|
||||||
|
class="col-md-6 col-12"
|
||||||
|
:class="{
|
||||||
|
'field-one': inputOnly && $q.screen.gt.sm,
|
||||||
|
'q-mb-sm': inputOnly && $q.screen.lt.md,
|
||||||
|
}"
|
||||||
|
simple
|
||||||
|
required
|
||||||
|
:readonly
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
:deep(.responsible-search .q-field__control) {
|
||||||
|
height: 36px;
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(
|
||||||
|
.q-item__section.column.q-item__section--side.justify-center.q-item__section--avatar.q-focusable.relative-position.cursor-pointer
|
||||||
|
) {
|
||||||
|
justify-content: start !important;
|
||||||
|
padding-right: 8px !important;
|
||||||
|
padding-top: 16px;
|
||||||
|
min-width: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(i.q-icon.mdi.mdi-chevron-down-circle.q-expansion-item__toggle-icon) {
|
||||||
|
color: hsl(var(--text-mute));
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(
|
||||||
|
i.q-icon.mdi.mdi-chevron-down-circle.q-expansion-item__toggle-icon.q-expansion-item__toggle-icon--rotated
|
||||||
|
) {
|
||||||
|
color: var(--brand-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(
|
||||||
|
.q-item.q-item-type.row.no-wrap.q-item--dense.q-item--clickable.q-link.cursor-pointer.q-focusable.q-hoverable.expansion-rounded.surface-2
|
||||||
|
.q-focus-helper
|
||||||
|
) {
|
||||||
|
visibility: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(.q-dialog.fullscreen.no-pointer-events.q-dialog--modal) {
|
||||||
|
visibility: hidden;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
@ -120,7 +120,15 @@ onMounted(async () => {
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
{ label: 'workflow', route: '/workflow' },
|
{ label: 'workflow', route: '/workflow' },
|
||||||
{ label: 'property', route: '/property' },
|
{
|
||||||
|
label: 'property',
|
||||||
|
route: '/property',
|
||||||
|
hidden: !(
|
||||||
|
role.value.includes('admin') ||
|
||||||
|
role.value.includes('head_of_admin') ||
|
||||||
|
role.value.includes('system')
|
||||||
|
),
|
||||||
|
},
|
||||||
{ label: 'productService', route: '/product-service' },
|
{ label: 'productService', route: '/product-service' },
|
||||||
{ label: 'customer', route: '/customer-management' },
|
{ label: 'customer', route: '/customer-management' },
|
||||||
{ label: 'agencies', route: '/agencies-management' },
|
{ label: 'agencies', route: '/agencies-management' },
|
||||||
|
|
|
||||||
|
|
@ -126,6 +126,7 @@ function assignFormData(propertyData: Property) {
|
||||||
nameEN: propertyData.nameEN,
|
nameEN: propertyData.nameEN,
|
||||||
type: propertyData.type,
|
type: propertyData.type,
|
||||||
status: propertyData.status,
|
status: propertyData.status,
|
||||||
|
registeredBranchId: propertyData.registeredBranchId,
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
import DialogForm from 'src/components/DialogForm.vue';
|
import DialogForm from 'src/components/DialogForm.vue';
|
||||||
import SideMenu from 'src/components/SideMenu.vue';
|
import SideMenu from 'src/components/SideMenu.vue';
|
||||||
import DrawerInfo from 'src/components/DrawerInfo.vue';
|
import DrawerInfo from 'src/components/DrawerInfo.vue';
|
||||||
|
import FormProperty from 'src/components/04_property-management/FormProperty.vue';
|
||||||
import {
|
import {
|
||||||
UndoButton,
|
UndoButton,
|
||||||
SaveButton,
|
SaveButton,
|
||||||
|
|
@ -9,6 +10,7 @@ import {
|
||||||
DeleteButton,
|
DeleteButton,
|
||||||
} from 'src/components/button';
|
} from 'src/components/button';
|
||||||
import { Property } from 'src/stores/property/types';
|
import { Property } from 'src/stores/property/types';
|
||||||
|
import { DialogFormContainer, DialogHeader } from 'src/components/dialog';
|
||||||
|
|
||||||
const model = defineModel<boolean>({ required: true, default: false });
|
const model = defineModel<boolean>({ required: true, default: false });
|
||||||
const drawerModel = defineModel<boolean>('drawerModel', {
|
const drawerModel = defineModel<boolean>('drawerModel', {
|
||||||
|
|
@ -43,44 +45,40 @@ defineEmits<{
|
||||||
}>();
|
}>();
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<DialogForm
|
<DialogFormContainer
|
||||||
:title="$t('flow.title')"
|
width="60vw"
|
||||||
v-model:modal="model"
|
height="500px"
|
||||||
:submit="() => $emit('submit')"
|
v-model="model"
|
||||||
:close="() => $emit('close')"
|
@submit="() => $emit('submit')"
|
||||||
hide-footer
|
|
||||||
>
|
>
|
||||||
<div
|
<template #header>
|
||||||
class="col surface-1 rounded bordered scroll row relative-position"
|
<DialogHeader
|
||||||
:class="{
|
:title="$t(`general.add`, { text: $t('property.title') })"
|
||||||
'q-mx-lg q-my-md': $q.screen.gt.sm,
|
/>
|
||||||
'q-mx-md q-my-sm': !$q.screen.gt.sm,
|
</template>
|
||||||
}"
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
class="rounded row"
|
|
||||||
style="position: absolute; z-index: 999; right: 0; top: 0"
|
|
||||||
:class="{
|
|
||||||
'q-py-md q-px-lg': $q.screen.gt.sm,
|
|
||||||
'q-pa-sm': !$q.screen.gt.sm,
|
|
||||||
}"
|
|
||||||
>
|
|
||||||
<div class="surface-1 row rounded">
|
|
||||||
<SaveButton id="btn-info-basic-save" icon-only type="submit" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<section
|
<section class="q-pa-md col full-width">
|
||||||
class="col-12 col-md-10"
|
<div class="surface-1 rounded bordered q-pa-md full-height full-width">
|
||||||
:class="{
|
<FormProperty
|
||||||
'q-py-md q-pr-md ': $q.screen.gt.sm,
|
v-model:name="formProperty.name"
|
||||||
'q-pa-sm': !$q.screen.gt.sm,
|
v-model:name-en="formProperty.nameEN"
|
||||||
}"
|
v-model:type="formProperty.type"
|
||||||
style="height: 100%; max-height: 100%; overflow-y: auto"
|
v-model:registered-branch-id="formProperty.registeredBranchId"
|
||||||
id="flow-form-dialog"
|
/>
|
||||||
></section>
|
</div>
|
||||||
</div>
|
</section>
|
||||||
</DialogForm>
|
|
||||||
|
<template #footer>
|
||||||
|
<CancelButton class="q-ml-auto" outlined @click="$emit('close')" />
|
||||||
|
<SaveButton
|
||||||
|
:label="$t(`general.add`, { text: $t('property.title') })"
|
||||||
|
class="q-ml-sm"
|
||||||
|
icon="mdi-check"
|
||||||
|
solid
|
||||||
|
type="submit"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</DialogFormContainer>
|
||||||
|
|
||||||
<DrawerInfo
|
<DrawerInfo
|
||||||
bg-on
|
bg-on
|
||||||
|
|
@ -169,7 +167,13 @@ defineEmits<{
|
||||||
style="height: 100%; max-height: 100%; overflow-y: auto"
|
style="height: 100%; max-height: 100%; overflow-y: auto"
|
||||||
id="flow-form-drawer"
|
id="flow-form-drawer"
|
||||||
>
|
>
|
||||||
asdas
|
<FormProperty
|
||||||
|
:readonly="!isEdit"
|
||||||
|
v-model:name="formProperty.name"
|
||||||
|
v-model:name-en="formProperty.nameEN"
|
||||||
|
v-model:type="formProperty.type"
|
||||||
|
v-model:registered-branch-id="formProperty.registeredBranchId"
|
||||||
|
/>
|
||||||
</section>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,9 @@ import { Status } from '../types';
|
||||||
|
|
||||||
export type Property = {
|
export type Property = {
|
||||||
id?: string;
|
id?: string;
|
||||||
|
status?: Status;
|
||||||
|
registeredBranchId?: string;
|
||||||
name: string;
|
name: string;
|
||||||
nameEN: string;
|
nameEN: string;
|
||||||
type: Record<string, any>;
|
type: Record<string, any>;
|
||||||
status?: Status;
|
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue