forked from verdnatura/salix-front
70 lines
1.8 KiB
Vue
70 lines
1.8 KiB
Vue
<script setup>
|
|
import ShelvingForm from 'pages/Shelving/Card/ShelvingForm.vue';
|
|
import { useI18n } from 'vue-i18n';
|
|
import { useValidator } from 'composables/useValidator';
|
|
import { ref } from 'vue';
|
|
import axios from 'axios';
|
|
import {useRouter} from "vue-router";
|
|
|
|
const { t } = useI18n();
|
|
const { validate } = useValidator();
|
|
|
|
const isLoading = ref(false);
|
|
const formData = ref({});
|
|
const router = useRouter();
|
|
|
|
async function save() {
|
|
isLoading.value = true;
|
|
try {
|
|
await axios.patch('Shelvings', formData.value);
|
|
} catch (e) { /* empty */ }
|
|
isLoading.value = false;
|
|
}
|
|
|
|
function filter(value, update, filterOptions) {
|
|
update(
|
|
() => {
|
|
const { options, filterFn } = filterOptions;
|
|
|
|
options.value = filterFn(options, value);
|
|
},
|
|
(ref) => {
|
|
ref.setOptionIndex(-1);
|
|
ref.moveOptionSelection(1, true);
|
|
}
|
|
);
|
|
}
|
|
</script>
|
|
<template>
|
|
<div class="column items-center">
|
|
<QForm v-if="formData" @submit.prevent class="q-pa-md" id="formModel">
|
|
<QCard>
|
|
<ShelvingForm :data="formData" :validate="validate" :filter="filter" />
|
|
</QCard>
|
|
<QBtn
|
|
:label="t('globals.create')"
|
|
type="submit"
|
|
color="primary"
|
|
class="q-mt-md"
|
|
@click="save()"
|
|
/>
|
|
<QBtn :label="t('globals.cancel')" class="q-mt-md q-ml-md" flat @click.stop="router.push({ name: 'ShelvingList' })" />
|
|
</QForm>
|
|
</div>
|
|
<QInnerLoading
|
|
:showing="isLoading"
|
|
:label="t('globals.pleaseWait')"
|
|
color="primary"
|
|
/>
|
|
</template>
|
|
<style lang="scss" scoped>
|
|
#formModel {
|
|
max-width: 800px;
|
|
width: 100%;
|
|
}
|
|
|
|
.q-card {
|
|
padding: 32px;
|
|
}
|
|
</style>
|