|
|
@@ -0,0 +1,91 @@
|
|
|
+<template>
|
|
|
+ <q-dialog ref="dialogRef" @hide="onDialogHide">
|
|
|
+ <q-card class="q-dialog-plugin overflow-hidden" style="width: 1000px; max-width: 90vw">
|
|
|
+ <DefaultDialogHeader :title="title" @close="onDialogCancel" />
|
|
|
+ <q-form ref="formRef" @submit="onOKClick">
|
|
|
+ <q-card-section class="row q-col-gutter-sm">
|
|
|
+ <q-input
|
|
|
+ v-model="form.description"
|
|
|
+ fill-mask
|
|
|
+ unmasked-value
|
|
|
+ :label="$t('common.terms.description')"
|
|
|
+ :rules="[inputRules.required]"
|
|
|
+ :error="!!serverErrors?.description"
|
|
|
+ :error-message="serverErrors?.description"
|
|
|
+ class="col-12"
|
|
|
+ />
|
|
|
+
|
|
|
+ <div class="col-12">
|
|
|
+ <q-checkbox
|
|
|
+ v-model="form.is_active"
|
|
|
+ :label="$t('common.status.active')"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+
|
|
|
+ </q-card-section>
|
|
|
+ <q-card-actions align="center">
|
|
|
+ <q-btn color="primary" label="Cancel" @click="onDialogCancel" />
|
|
|
+ <q-space />
|
|
|
+ <q-btn color="primary" label="OK" :type="'submit'" :loading="loading" :disable="!hasUpdatedFields" />
|
|
|
+ </q-card-actions>
|
|
|
+ </q-form>
|
|
|
+ </q-card>
|
|
|
+ </q-dialog>
|
|
|
+</template>
|
|
|
+<script setup>
|
|
|
+import { useTemplateRef } from "vue";
|
|
|
+import { useInputRules } from "src/composables/useInputRules";
|
|
|
+import { useDialogPluginComponent } from "quasar";
|
|
|
+import { useI18n } from "vue-i18n";
|
|
|
+import { createServiceType, updateServiceType } from "src/api/serviceType";
|
|
|
+import { useFormUpdateTracker } from "src/composables/useFormUpdateTracker";
|
|
|
+import { useSubmitHandler } from "src/composables/useSubmitHandler";
|
|
|
+import DefaultDialogHeader from "src/components/defaults/DefaultDialogHeader.vue";
|
|
|
+
|
|
|
+defineEmits([
|
|
|
+ ...useDialogPluginComponent.emits,
|
|
|
+]);
|
|
|
+
|
|
|
+const { serviceType, title } = defineProps({
|
|
|
+ serviceType: {
|
|
|
+ type: Object,
|
|
|
+ default: null,
|
|
|
+ },
|
|
|
+ title: {
|
|
|
+ type: Function,
|
|
|
+ default: () => useI18n().t("common.terms.title"),
|
|
|
+ },
|
|
|
+});
|
|
|
+
|
|
|
+const { inputRules } = useInputRules();
|
|
|
+
|
|
|
+const { dialogRef, onDialogHide, onDialogOK, onDialogCancel } =
|
|
|
+ useDialogPluginComponent();
|
|
|
+
|
|
|
+const formRef = useTemplateRef("formRef");
|
|
|
+const { form, getUpdatedFields, hasUpdatedFields } = useFormUpdateTracker({
|
|
|
+ description: serviceType ? serviceType?.description : "",
|
|
|
+ is_active: serviceType ? serviceType?.is_active : false,
|
|
|
+});
|
|
|
+
|
|
|
+// const birthDate = ref(null);
|
|
|
+
|
|
|
+const {
|
|
|
+ loading,
|
|
|
+ serverErrors,
|
|
|
+ execute: submitForm,
|
|
|
+} = useSubmitHandler({
|
|
|
+ onSuccess: () => onDialogOK(true),
|
|
|
+ formRef: formRef,
|
|
|
+});
|
|
|
+
|
|
|
+
|
|
|
+const onOKClick = async () => {
|
|
|
+ if (serviceType) {
|
|
|
+ await submitForm(() => updateServiceType(getUpdatedFields.value, serviceType.id));
|
|
|
+ } else {
|
|
|
+ await submitForm(() => createServiceType({ ...form }));
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+</script>
|