feat: refs #6273 create worker form toggle
gitea/salix-front/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Jorge Penadés 2024-05-03 16:40:11 +02:00
parent e3a36c0ab1
commit 4b4c02c01a
2 changed files with 149 additions and 162 deletions

View File

@ -1,27 +1,20 @@
<script setup>
import { onMounted, ref } from 'vue';
import { useI18n } from 'vue-i18n';
import FetchData from 'components/FetchData.vue';
import FormModel from 'components/FormModel.vue';
import { useUserConfig } from 'src/composables/useUserConfig';
import VnRow from 'components/ui/VnRow.vue';
import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue';
import VnInputDate from 'components/common/VnInputDate.vue';
import VnSelect from 'src/components/common/VnSelect.vue';
import VnSelectDialog from 'src/components/common/VnSelectDialog.vue';
import CreateBankEntityForm from 'src/components/CreateBankEntityForm.vue';
import CustomerCreateNewPostcode from 'src/components/CreateNewPostcodeForm.vue';
import VnLocation from 'src/components/common/VnLocation.vue';
import VnInput from 'src/components/common/VnInput.vue';
import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue';
import { useUserConfig } from 'src/composables/useUserConfig';
import VnSelectDialog from 'src/components/common/VnSelectDialog.vue';
import FetchData from 'components/FetchData.vue';
import FormModel from 'components/FormModel.vue';
import CreateBankEntityForm from 'src/components/CreateBankEntityForm.vue';
const { t } = useI18n();
const workerConfigFilter = {
field: ['payMethodFk'],
};
const newWorkerForm = ref({
companyFk: null,
payMethodFk: null,
@ -47,6 +40,7 @@ const workersOptions = ref([]);
const payMethodsOptions = ref([]);
const bankEntitiesOptions = ref([]);
const postcodesOptions = ref([]);
const isFreelancer = ref(false);
const onFetchWorkerConfig = (workerConfig) => {
newWorkerForm.value.payMethodFk = workerConfig.payMethodFk;
@ -69,15 +63,13 @@ onMounted(async () => {
newWorkerForm.value = { companyFk: userInfo.companyFk };
});
</script>
<template>
<FetchData
url="WorkerConfigs/findOne"
@on-fetch="(data) => onFetchWorkerConfig(data)"
:filter="workerConfigFilter"
:filter="{ field: ['payMethodFk'] }"
auto-load
/>
<FetchData
url="Companies"
@on-fetch="(data) => (companiesOptions = data)"
@ -98,165 +90,159 @@ onMounted(async () => {
@on-fetch="(data) => (bankEntitiesOptions = data)"
auto-load
/>
<QPage>
<VnSubToolbar />
<VnSubToolbar>
<template #st-data>
<QBtnGroup>
<QBtn
:label="`${t('globals.worker')}`"
:title="`${t('globals.worker')}`"
color="primary"
icon="vn:worker"
@click="isFreelancer = false"
/>
<QBtn
:label="`${t('Freelancer')}`"
:title="`${t('Freelancer')}`"
flat
color="primary"
icon="person"
@click="isFreelancer = true"
/>
</QBtnGroup>
</template>
</VnSubToolbar>
<FormModel
url-create="Workers/new"
model="worker"
:form-initial-data="newWorkerForm"
>
<template #form="{ data, validate }">
<VnRow class="row q-gutter-md q-mb-md">
<div class="col">
<VnInput
v-model="data.firstName"
:label="t('worker.create.name')"
:rules="validate('Worker.firstName')"
/>
</div>
<div class="col">
<VnInput
v-model="data.lastNames"
:label="t('worker.create.lastName')"
:rules="validate('Worker.lastNames')"
/>
</div>
<div class="col">
<VnInputDate
v-model="data.birth"
:label="t('worker.create.birth')"
:rules="validate('Worker.birth')"
/>
</div>
<VnRow>
<VnInput
v-model="data.firstName"
:label="t('worker.create.name')"
:rules="validate('Worker.firstName')"
/>
<VnInput
v-model="data.lastNames"
:label="t('worker.create.lastName')"
:rules="validate('Worker.lastNames')"
/>
<VnInput
v-show="isFreelancer"
v-model="data.code"
:label="t('worker.create.code')"
:rules="validate('Worker.code')"
/>
<VnInputDate
v-show="!isFreelancer"
v-model="data.birth"
:label="t('worker.create.birth')"
:rules="validate('Worker.birth')"
/>
</VnRow>
<VnRow class="row q-gutter-md q-mb-md">
<div class="col">
<VnInput
v-model="data.fi"
:label="t('worker.create.fi')"
:rules="validate('Worker.fi')"
/>
</div>
<div class="col">
<VnInput
v-model="data.code"
:label="t('worker.create.code')"
:rules="validate('Worker.code')"
/>
</div>
<div class="col">
<VnInput
v-model="data.phone"
:label="t('worker.create.phone')"
:rules="validate('Worker.phone')"
/>
</div>
<VnRow v-show="!isFreelancer">
<VnInput
v-model="data.fi"
:label="t('worker.create.fi')"
:rules="validate('Worker.fi')"
/>
<VnInput
v-model="data.code"
:label="t('worker.create.code')"
:rules="validate('Worker.code')"
/>
<VnInput
v-model="data.phone"
:label="t('worker.create.phone')"
:rules="validate('Worker.phone')"
/>
</VnRow>
<VnRow class="row q-gutter-md q-mb-md">
<div class="col">
<VnLocation
:rules="validate('Worker.postcode')"
:roles-allowed-to-create="['deliveryAssistant']"
:options="postcodesOptions"
v-model="data.location"
@update:model-value="
(location) => handleLocation(data, location)
"
>
</VnLocation>
</div>
<VnRow v-show="!isFreelancer">
<VnLocation
:rules="validate('Worker.postcode')"
:roles-allowed-to-create="['deliveryAssistant']"
:options="postcodesOptions"
v-model="data.location"
@update:model-value="(location) => handleLocation(data, location)"
>
</VnLocation>
</VnRow>
<VnRow class="row q-gutter-md q-mb-md">
<div class="col">
<VnInput
:label="t('worker.create.street')"
v-model="data.street"
:rules="validate('Worker.street')"
/>
</div>
<VnRow>
<VnInput
v-show="!isFreelancer"
:label="t('worker.create.street')"
v-model="data.street"
:rules="validate('Worker.street')"
/>
</VnRow>
<VnRow class="row q-gutter-md q-mb-md">
<div class="col">
<VnInput
v-model="data.name"
:label="t('worker.create.webUser')"
:rules="validate('Worker.name')"
/>
</div>
<div class="col">
<VnInput
v-model="data.email"
:label="t('worker.create.personalEmail')"
:rules="validate('Worker.email')"
/>
</div>
<VnRow>
<VnInput
v-model="data.name"
:label="t('worker.create.webUser')"
:rules="validate('Worker.name')"
/>
<VnInput
v-model="data.email"
:label="t('worker.create.personalEmail')"
:rules="validate('Worker.email')"
/>
</VnRow>
<VnRow class="row q-gutter-md q-mb-md">
<div class="col">
<VnSelect
:label="t('worker.create.company')"
v-model="data.companyFk"
:options="companiesOptions"
option-value="id"
option-label="code"
hide-selected
:rules="validate('Worker.company')"
/>
</div>
<div class="col">
<VnSelect
:label="t('worker.create.boss')"
v-model="data.bossFk"
:options="workersOptions"
option-value="id"
option-label="name"
hide-selected
:rules="validate('Worker.boss')"
>
<template #option="scope">
<QItem v-bind="scope.itemProps">
<QItemSection>
<QItemLabel>{{ scope.opt.name }}</QItemLabel>
<QItemLabel caption
>{{ scope.opt.nickname }},
{{ scope.opt.code }}
</QItemLabel>
</QItemSection>
</QItem>
</template>
</VnSelect>
</div>
<VnRow>
<VnSelect
:label="t('worker.create.company')"
v-model="data.companyFk"
:options="companiesOptions"
option-value="id"
option-label="code"
hide-selected
:rules="validate('Worker.company')"
/>
<VnSelect
:label="t('worker.create.boss')"
v-model="data.bossFk"
:options="workersOptions"
option-value="id"
option-label="name"
hide-selected
:rules="validate('Worker.boss')"
>
<template #option="scope">
<QItem v-bind="scope.itemProps">
<QItemSection>
<QItemLabel>{{ scope.opt.name }}</QItemLabel>
<QItemLabel caption
>{{ scope.opt.nickname }},
{{ scope.opt.code }}
</QItemLabel>
</QItemSection>
</QItem>
</template>
</VnSelect>
</VnRow>
<VnRow class="row q-gutter-md q-mb-md">
<div class="col">
<VnSelect
:label="t('worker.create.payMethods')"
v-model="data.payMethodFk"
:options="payMethodsOptions"
option-value="id"
option-label="name"
map-options
hide-selected
:rules="validate('Worker.payMethodFk')"
/>
</div>
<div class="col">
<VnInput
v-model="data.iban"
:label="t('worker.create.iban')"
:rules="validate('Worker.iban')"
>
<template #append>
<QIcon name="info" class="cursor-info">
<QTooltip>{{
t('components.iban_tooltip')
}}</QTooltip>
</QIcon>
</template>
</VnInput>
</div>
<VnRow v-show="!isFreelancer">
<VnSelect
:label="t('worker.create.payMethods')"
v-model="data.payMethodFk"
:options="payMethodsOptions"
option-value="id"
option-label="name"
map-options
hide-selected
:rules="validate('Worker.payMethodFk')"
/>
<VnInput
v-model="data.iban"
:label="t('worker.create.iban')"
:rules="validate('Worker.iban')"
>
<template #append>
<QIcon name="info" class="cursor-info">
<QTooltip>{{ t('components.iban_tooltip') }}</QTooltip>
</QIcon>
</template>
</VnInput>
<VnSelectDialog
:label="t('worker.create.bankEntity')"
v-model="data.bankEntityFk"

View File

@ -1,2 +1,3 @@
Search worker: Buscar trabajador
You can search by worker id or name: Puedes buscar por id o nombre del trabajador
Freelancer: Autónomo