forked from verdnatura/salix-front
fix: refs #7323 generate code & minor changes
This commit is contained in:
parent
172c238ac3
commit
635ac2716d
|
@ -93,7 +93,6 @@ const filter = {
|
|||
/>
|
||||
</template>
|
||||
</VnLv>
|
||||
<VnLv :label="t('worker.list.email')" :value="worker.user.email" copy />
|
||||
<VnLv :label="t('worker.summary.boss')" link>
|
||||
<template #value>
|
||||
<VnUserLink
|
||||
|
@ -139,29 +138,25 @@ const filter = {
|
|||
/>
|
||||
<VnLv :label="t('worker.summary.fi')" :value="worker.fi" />
|
||||
<VnLv :label="t('worker.summary.birth')" :value="toDate(worker.birth)" />
|
||||
<VnRow class="q-mt-sm" wrap>
|
||||
<VnLv
|
||||
:label="t('worker.summary.isFreelance')"
|
||||
:value="worker.isFreelance"
|
||||
/>
|
||||
<VnLv
|
||||
:label="t('worker.summary.isSsDiscounted')"
|
||||
:value="worker.isSsDiscounted"
|
||||
/>
|
||||
<VnLv
|
||||
:label="t('worker.summary.hasMachineryAuthorized')"
|
||||
:value="worker.hasMachineryAuthorized"
|
||||
/>
|
||||
<VnLv
|
||||
:label="t('worker.summary.isDisable')"
|
||||
:value="worker.isDisable"
|
||||
/>
|
||||
</VnRow>
|
||||
<VnLv
|
||||
:label="t('worker.summary.isFreelance')"
|
||||
:value="worker.isFreelance"
|
||||
/>
|
||||
<VnLv
|
||||
:label="t('worker.summary.isSsDiscounted')"
|
||||
:value="worker.isSsDiscounted"
|
||||
/>
|
||||
<VnLv
|
||||
:label="t('worker.summary.hasMachineryAuthorized')"
|
||||
:value="worker.hasMachineryAuthorized"
|
||||
/>
|
||||
<VnLv :label="t('worker.summary.isDisable')" :value="worker.isDisable" />
|
||||
</QCard>
|
||||
<QCard class="vn-one">
|
||||
<VnTitle :text="t('worker.summary.userData')" />
|
||||
<VnLv :label="t('worker.summary.userId')" :value="worker.user.id" />
|
||||
<VnLv :label="t('worker.card.name')" :value="worker.user.nickname" />
|
||||
<VnLv :label="t('worker.list.email')" :value="worker.user.email" copy />
|
||||
<VnLv :label="t('worker.summary.role')">
|
||||
<template #value>
|
||||
<span class="link">
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
import { onBeforeMount, ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import axios from 'axios';
|
||||
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';
|
||||
|
@ -14,15 +13,26 @@ import FetchData from 'components/FetchData.vue';
|
|||
import FormModel from 'components/FormModel.vue';
|
||||
import CreateBankEntityForm from 'src/components/CreateBankEntityForm.vue';
|
||||
import VnRadio from 'src/components/common/VnRadio.vue';
|
||||
import { useState } from 'src/composables/useState';
|
||||
|
||||
const { t } = useI18n();
|
||||
const user = useState().getUser();
|
||||
|
||||
const companiesOptions = ref([]);
|
||||
const workersOptions = ref([]);
|
||||
const payMethodsOptions = ref([]);
|
||||
const bankEntitiesOptions = ref([]);
|
||||
const formData = ref({ isFreelance: false });
|
||||
const defaultPayMethod = ref(0);
|
||||
const formData = ref({ companyFk: user.value.companyFk, isFreelance: false });
|
||||
const defaultPayMethod = ref();
|
||||
|
||||
onBeforeMount(async () => {
|
||||
defaultPayMethod.value = (
|
||||
await axios.get('WorkerConfigs/findOne', {
|
||||
params: { field: ['payMethodFk'] },
|
||||
})
|
||||
).data.payMethodFk;
|
||||
formData.value.payMethodFk = defaultPayMethod.value;
|
||||
});
|
||||
|
||||
function handleLocation(data, location) {
|
||||
const { town, code, provinceFk, countryFk } = location ?? {};
|
||||
|
@ -32,16 +42,20 @@ function handleLocation(data, location) {
|
|||
data.countryFk = countryFk;
|
||||
}
|
||||
|
||||
onBeforeMount(async () => {
|
||||
const userInfo = await useUserConfig().fetch();
|
||||
formData.value.companyFk = userInfo.companyFk;
|
||||
function generateCodeUser(worker) {
|
||||
if (!worker.firstName || !worker.lastNames) return;
|
||||
|
||||
const { data } = await axios.get('WorkerConfigs/findOne', {
|
||||
params: { field: ['payMethodFk'] },
|
||||
});
|
||||
defaultPayMethod.value = data.payMethodFk;
|
||||
formData.value.payMethodFk = defaultPayMethod.value;
|
||||
});
|
||||
const totalName = worker.firstName.concat(' ' + worker.lastNames).toLowerCase();
|
||||
const totalNameArray = totalName.split(' ');
|
||||
let newCode = '';
|
||||
|
||||
for (let part of totalNameArray) newCode += part.charAt(0);
|
||||
|
||||
worker.code = newCode.toUpperCase().slice(0, 3);
|
||||
worker.name = totalNameArray[0] + newCode.slice(1);
|
||||
|
||||
if (!worker.companyFk) worker.companyFk = user.companyFk;
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<FetchData
|
||||
|
@ -93,11 +107,13 @@ onBeforeMount(async () => {
|
|||
v-model="data.firstName"
|
||||
:label="t('worker.create.name')"
|
||||
:rules="validate('Worker.firstName')"
|
||||
@update:model-value="generateCodeUser(data)"
|
||||
/>
|
||||
<VnInput
|
||||
v-model="data.lastNames"
|
||||
:label="t('worker.create.lastName')"
|
||||
:rules="validate('Worker.lastNames')"
|
||||
@update:model-value="generateCodeUser(data)"
|
||||
/>
|
||||
<VnInput
|
||||
v-model="data.code"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<script setup>
|
||||
import { computed, ref } from 'vue';
|
||||
import { onBeforeMount, computed, ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useSummaryDialog } from 'src/composables/useSummaryDialog';
|
||||
import VnSearchbar from 'src/components/ui/VnSearchbar.vue';
|
||||
|
@ -16,6 +16,8 @@ import CreateBankEntityForm from 'src/components/CreateBankEntityForm.vue';
|
|||
import FetchData from 'src/components/FetchData.vue';
|
||||
import RightMenu from 'src/components/common/RightMenu.vue';
|
||||
import WorkerFilter from './WorkerFilter.vue';
|
||||
import { useState } from 'src/composables/useState';
|
||||
import axios from 'axios';
|
||||
|
||||
const { t } = useI18n();
|
||||
const tableRef = ref();
|
||||
|
@ -26,6 +28,8 @@ const payMethodsOptions = ref([]);
|
|||
const bankEntitiesOptions = ref([]);
|
||||
const postcodesOptions = ref([]);
|
||||
|
||||
const user = useState().getUser();
|
||||
const defaultPayMethod = ref();
|
||||
const columns = computed(() => [
|
||||
{
|
||||
align: 'left',
|
||||
|
@ -82,6 +86,14 @@ const columns = computed(() => [
|
|||
},
|
||||
]);
|
||||
|
||||
onBeforeMount(async () => {
|
||||
defaultPayMethod.value = (
|
||||
await axios.get('WorkerConfigs/findOne', {
|
||||
params: { field: ['payMethodFk'] },
|
||||
})
|
||||
).data?.payMethodFk;
|
||||
});
|
||||
|
||||
function handleLocation(data, location) {
|
||||
const { town, code, provinceFk, countryFk } = location ?? {};
|
||||
data.postcode = code;
|
||||
|
@ -98,6 +110,21 @@ function uppercaseStreetModel(data) {
|
|||
},
|
||||
};
|
||||
}
|
||||
|
||||
function generateCodeUser(worker) {
|
||||
if (!worker.firstName || !worker.lastNames) return;
|
||||
|
||||
const totalName = worker.firstName.concat(' ' + worker.lastNames).toLowerCase();
|
||||
const totalNameArray = totalName.split(' ');
|
||||
let newCode = '';
|
||||
|
||||
for (let part of totalNameArray) newCode += part.charAt(0);
|
||||
|
||||
worker.code = newCode.toUpperCase().slice(0, 3);
|
||||
worker.name = totalNameArray[0] + newCode.slice(1);
|
||||
|
||||
if (!worker.companyFk) worker.companyFk = user.companyFk;
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<VnSearchbar
|
||||
|
@ -131,6 +158,7 @@ function uppercaseStreetModel(data) {
|
|||
</template>
|
||||
</RightMenu>
|
||||
<VnTable
|
||||
v-if="defaultPayMethod"
|
||||
ref="tableRef"
|
||||
data-key="Worker"
|
||||
url="Workers/filter"
|
||||
|
@ -139,6 +167,8 @@ function uppercaseStreetModel(data) {
|
|||
title: t('Create worker'),
|
||||
onDataSaved: ({ id }) => tableRef.redirect(id),
|
||||
formInitialData: {
|
||||
payMethodFk: defaultPayMethod,
|
||||
companyFk: user.companyFk,
|
||||
isFreelance: false,
|
||||
},
|
||||
}"
|
||||
|
@ -149,7 +179,7 @@ function uppercaseStreetModel(data) {
|
|||
auto-load
|
||||
>
|
||||
<template #more-create-dialog="{ data }">
|
||||
<div class="q-pa-lg full-width" style="max-width: 1200px">
|
||||
<div class="q-pa-lg full-width">
|
||||
<VnRadio
|
||||
v-model="data.isFreelance"
|
||||
:val="false"
|
||||
|
@ -163,10 +193,16 @@ function uppercaseStreetModel(data) {
|
|||
@update:model-value="delete data.payMethodFk"
|
||||
/>
|
||||
<VnRow>
|
||||
<VnInput v-model="data.firstName" :label="t('worker.create.name')" />
|
||||
<VnInput
|
||||
next
|
||||
v-model="data.firstName"
|
||||
:label="t('worker.create.name')"
|
||||
@update:model-value="generateCodeUser(data)"
|
||||
/>
|
||||
<VnInput
|
||||
v-model="data.lastNames"
|
||||
:label="t('worker.create.lastName')"
|
||||
@update:model-value="generateCodeUser(data)"
|
||||
/>
|
||||
<VnInput v-model="data.code" :label="t('worker.create.code')" />
|
||||
</VnRow>
|
||||
|
|
Loading…
Reference in New Issue