refactor: enhance form submission handling and make responsible user selection required
This commit is contained in:
parent
666326af46
commit
84f5d3b969
2 changed files with 29 additions and 14 deletions
|
|
@ -42,7 +42,7 @@ watch(responsibleUserLocal, (lhs, rhs) => {
|
||||||
|
|
||||||
<div class="col-12 row">
|
<div class="col-12 row">
|
||||||
<SelectUser
|
<SelectUser
|
||||||
:required="false"
|
required
|
||||||
:key="responsibleUserLocal?.toString()"
|
:key="responsibleUserLocal?.toString()"
|
||||||
class="col-md-5 col-12"
|
class="col-md-5 col-12"
|
||||||
v-model:value="responsibleUserId"
|
v-model:value="responsibleUserId"
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import FormResponsibleUser from './FormResponsibleUser.vue';
|
||||||
import { UndoButton, SaveButton, EditButton } from 'src/components/button';
|
import { UndoButton, SaveButton, EditButton } from 'src/components/button';
|
||||||
import { AttributesForm, Step } from 'src/stores/request-list/types';
|
import { AttributesForm, Step } from 'src/stores/request-list/types';
|
||||||
import { useRequestList } from 'src/stores/request-list';
|
import { useRequestList } from 'src/stores/request-list';
|
||||||
|
import { QForm } from 'quasar';
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
readonly?: boolean;
|
readonly?: boolean;
|
||||||
|
|
@ -14,12 +15,18 @@ const props = defineProps<{
|
||||||
responsibleAreaDistrictId?: string;
|
responsibleAreaDistrictId?: string;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
(e: 'updateAttributes', value: AttributesForm): void;
|
||||||
|
}>();
|
||||||
|
|
||||||
const requestListStore = useRequestList();
|
const requestListStore = useRequestList();
|
||||||
|
|
||||||
const state = reactive({
|
const state = reactive({
|
||||||
isEdit: false,
|
isEdit: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const refForm = ref<InstanceType<typeof QForm>>();
|
||||||
|
|
||||||
const defaultForm = {
|
const defaultForm = {
|
||||||
customerDuty: false,
|
customerDuty: false,
|
||||||
customerDutyCost: 30,
|
customerDutyCost: 30,
|
||||||
|
|
@ -62,6 +69,7 @@ async function triggerSubmit() {
|
||||||
if (res) {
|
if (res) {
|
||||||
attributesForm.value = JSON.parse(JSON.stringify(formData.value));
|
attributesForm.value = JSON.parse(JSON.stringify(formData.value));
|
||||||
state.isEdit = false;
|
state.isEdit = false;
|
||||||
|
emit('updateAttributes', attributesForm.value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -100,7 +108,7 @@ function assignToForm() {
|
||||||
id="btn-info-basic-save"
|
id="btn-info-basic-save"
|
||||||
icon-only
|
icon-only
|
||||||
type="submit"
|
type="submit"
|
||||||
@click.stop="triggerSubmit"
|
@click.stop="refForm?.submit()"
|
||||||
/>
|
/>
|
||||||
<EditButton
|
<EditButton
|
||||||
v-if="!state.isEdit"
|
v-if="!state.isEdit"
|
||||||
|
|
@ -114,18 +122,25 @@ function assignToForm() {
|
||||||
|
|
||||||
<main class="row">
|
<main class="row">
|
||||||
<section class="col-12">
|
<section class="col-12">
|
||||||
<FormGroupHead>
|
<q-form
|
||||||
{{
|
ref="refForm"
|
||||||
$t('general.select', { msg: $t('requestList.employeeMessenger') })
|
greedy
|
||||||
}}
|
@submit.prevent
|
||||||
</FormGroupHead>
|
@validation-success="triggerSubmit"
|
||||||
<FormResponsibleUser
|
>
|
||||||
:readonly="!state.isEdit"
|
<FormGroupHead>
|
||||||
class="surface-1"
|
{{
|
||||||
v-model:responsible-user-local="formData.responsibleUserLocal"
|
$t('general.select', { msg: $t('requestList.employeeMessenger') })
|
||||||
v-model:responsible-user-id="formData.responsibleUserId"
|
}}
|
||||||
:district-id="responsibleAreaDistrictId"
|
</FormGroupHead>
|
||||||
/>
|
<FormResponsibleUser
|
||||||
|
:readonly="!state.isEdit"
|
||||||
|
class="surface-1"
|
||||||
|
v-model:responsible-user-local="formData.responsibleUserLocal"
|
||||||
|
v-model:responsible-user-id="formData.responsibleUserId"
|
||||||
|
:district-id="responsibleAreaDistrictId"
|
||||||
|
/>
|
||||||
|
</q-form>
|
||||||
</section>
|
</section>
|
||||||
</main>
|
</main>
|
||||||
</q-expansion-item>
|
</q-expansion-item>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue