Correcciones menores
This commit is contained in:
parent
004836ece7
commit
a3c6d0e584
@ -20,9 +20,10 @@ const form = useForm({
|
|||||||
maternal: '',
|
maternal: '',
|
||||||
email: '',
|
email: '',
|
||||||
phone: '',
|
phone: '',
|
||||||
|
hire_date: '',
|
||||||
password: '',
|
password: '',
|
||||||
roles: [],
|
roles: [],
|
||||||
departmen_id: '',
|
department_id: '',
|
||||||
});
|
});
|
||||||
|
|
||||||
const roles = ref([]);
|
const roles = ref([]);
|
||||||
@ -33,7 +34,7 @@ function submit() {
|
|||||||
form.transform(data => ({
|
form.transform(data => ({
|
||||||
...data,
|
...data,
|
||||||
roles: data.roles.map(role => role.id),
|
roles: data.roles.map(role => role.id),
|
||||||
departmen_id: data.departmen_id?.id
|
department_id: data.department_id?.id
|
||||||
})).post(apiTo('store'), {
|
})).post(apiTo('store'), {
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
Notify.success(Lang('register.create.onSuccess'))
|
Notify.success(Lang('register.create.onSuccess'))
|
||||||
@ -55,7 +56,6 @@ onMounted(() => {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
onSuccess: (r) => {
|
onSuccess: (r) => {
|
||||||
console.log(r);
|
|
||||||
departments.value = r['department:all'] ?? [];
|
departments.value = r['department:all'] ?? [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -97,8 +97,8 @@ onMounted(() => {
|
|||||||
multiple
|
multiple
|
||||||
/>
|
/>
|
||||||
<Selectable
|
<Selectable
|
||||||
v-model="form.departmen_id"
|
v-model="form.department_id"
|
||||||
title="Departamentos"
|
title="Departamento"
|
||||||
:options="departments"
|
:options="departments"
|
||||||
/>
|
/>
|
||||||
</Form>
|
</Form>
|
||||||
|
|||||||
@ -1,11 +1,12 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { onMounted } from 'vue';
|
import { onMounted, ref } from 'vue';
|
||||||
import { RouterLink, useRoute, useRouter } from 'vue-router';
|
import { RouterLink, useRoute, useRouter } from 'vue-router';
|
||||||
import { api, useForm } from '@Services/Api';
|
import { api, useForm } from '@Services/Api';
|
||||||
import { viewTo, apiTo , transl } from './Module';
|
import { viewTo, apiTo , transl } from './Module';
|
||||||
|
|
||||||
import IconButton from '@Holos/Button/Icon.vue'
|
import IconButton from '@Holos/Button/Icon.vue'
|
||||||
import PageHeader from '@Holos/PageHeader.vue';
|
import PageHeader from '@Holos/PageHeader.vue';
|
||||||
|
import Selectable from '@Holos/Form/Selectable.vue';
|
||||||
import Form from './Form.vue'
|
import Form from './Form.vue'
|
||||||
|
|
||||||
/** Definiciones */
|
/** Definiciones */
|
||||||
@ -19,12 +20,19 @@ const form = useForm({
|
|||||||
paternal: '',
|
paternal: '',
|
||||||
maternal: '',
|
maternal: '',
|
||||||
email: '',
|
email: '',
|
||||||
|
hire_date: '',
|
||||||
phone: '',
|
phone: '',
|
||||||
|
department_id: '',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const departments = ref([]);
|
||||||
|
|
||||||
/** Métodos */
|
/** Métodos */
|
||||||
function submit() {
|
function submit() {
|
||||||
form.put(apiTo('update', { user: form.id }), {
|
form.transform(data => ({
|
||||||
|
...data,
|
||||||
|
department_id: data.department_id?.id
|
||||||
|
})).put(apiTo('update', { user: form.id }), {
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
Notify.success(Lang('register.edit.onSuccess'))
|
Notify.success(Lang('register.edit.onSuccess'))
|
||||||
router.push(viewTo({ name: 'index' }));
|
router.push(viewTo({ name: 'index' }));
|
||||||
@ -34,8 +42,24 @@ function submit() {
|
|||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
api.get(apiTo('show', { user: vroute.params.id }), {
|
api.get(apiTo('show', { user: vroute.params.id }), {
|
||||||
onSuccess: (r) => form.fill(r.user)
|
onSuccess: (r) => {
|
||||||
|
form.fill(r.user)
|
||||||
|
form.department_id = r.user.department
|
||||||
|
if (r.user.hire_date) {
|
||||||
|
form.hire_date = new Date(r.user.hire_date).toISOString().split('T')[0]
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
api.catalog({
|
||||||
|
'department:all': null,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
onSuccess: (r) => {
|
||||||
|
departments.value = r['department:all'] ?? [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@ -54,5 +78,11 @@ onMounted(() => {
|
|||||||
action="update"
|
action="update"
|
||||||
:form="form"
|
:form="form"
|
||||||
@submit="submit"
|
@submit="submit"
|
||||||
/>
|
>
|
||||||
|
<Selectable
|
||||||
|
v-model="form.department_id"
|
||||||
|
title="Departamento"
|
||||||
|
:options="departments"
|
||||||
|
/>
|
||||||
|
</Form>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@ -61,6 +61,13 @@ function submit() {
|
|||||||
:onError="form.errors.email"
|
:onError="form.errors.email"
|
||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
|
<Input
|
||||||
|
v-model="form.hire_date"
|
||||||
|
id="hire_date"
|
||||||
|
:onError="form.errors.hire_date"
|
||||||
|
type="date"
|
||||||
|
required
|
||||||
|
/>
|
||||||
<slot />
|
<slot />
|
||||||
<div class="col-span-1 md:col-span-2 lg:col-span-3 xl:col-span-4 flex flex-col items-center justify-end space-y-4 mt-4">
|
<div class="col-span-1 md:col-span-2 lg:col-span-3 xl:col-span-4 flex flex-col items-center justify-end space-y-4 mt-4">
|
||||||
<PrimaryButton
|
<PrimaryButton
|
||||||
|
|||||||
@ -72,7 +72,7 @@ onMounted(() => {
|
|||||||
<td>{{ model.full_name }}</td>
|
<td>{{ model.full_name }}</td>
|
||||||
<td>{{ model.department?.name }}</td>
|
<td>{{ model.department?.name }}</td>
|
||||||
<td>{{ model.headquarter }}</td>
|
<td>{{ model.headquarter }}</td>
|
||||||
<td>{{ getDate(model.hire_date) }}</td>
|
<td>{{ model.hire_date ? getDate(model.hire_date) : '-' }}</td>
|
||||||
<td class="py-6">
|
<td class="py-6">
|
||||||
<span
|
<span
|
||||||
class="inline-block px-3 py-1 rounded-full text-xs font-semibold bg-green-100 text-green-700 dark:bg-success-d dark:text-success-dt">
|
class="inline-block px-3 py-1 rounded-full text-xs font-semibold bg-green-100 text-green-700 dark:bg-success-d dark:text-success-dt">
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user