4043-form_data #25

Merged
joan merged 5 commits from 4043-form_data into dev 2022-11-02 11:33:08 +00:00
12 changed files with 340 additions and 379 deletions
Showing only changes of commit bd908e5e93 - Show all commits

View File

@ -61,7 +61,7 @@ function responseError(error) {
router.push({ path: '/login' }); router.push({ path: '/login' });
} }
return Promise.resolve(error); return Promise.reject(error);
} }
axios.interceptors.response.use((response) => { axios.interceptors.response.use((response) => {

View File

@ -15,13 +15,10 @@ const $props = defineProps({
type: Object, type: Object,
default: null, default: null,
}, },
limit: {
type: String,
default: '20',
},
}); });
const emit = defineEmits(['fetch-data']); defineExpose({ fetch });
const emit = defineEmits(['onFetch']);
onMounted(async () => { onMounted(async () => {
if ($props.autoLoad) { if ($props.autoLoad) {
@ -34,7 +31,7 @@ async function fetch() {
params: { filter: $props.filter }, params: { filter: $props.filter },
}); });
return emit('fetch-data', data); emit('onFetch', data);
} }
const render = () => { const render = () => {

View File

@ -5,11 +5,13 @@ import { useQuasar } from 'quasar';
import axios from 'axios'; import axios from 'axios';
import { useState } from 'src/composables/useState'; import { useState } from 'src/composables/useState';
import { useValidator } from 'src/composables/useValidator';
import SkeletonForm from 'src/components/SkeletonForm.vue'; import SkeletonForm from 'src/components/SkeletonForm.vue';
const quasar = useQuasar(); const quasar = useQuasar();
const { t } = useI18n(); const { t } = useI18n();
const state = useState(); const state = useState();
const { validate } = useValidator();
const $props = defineProps({ const $props = defineProps({
url: { url: {
@ -26,7 +28,7 @@ const $props = defineProps({
}, },
}); });
const emit = defineEmits(['fetch-data']); const emit = defineEmits(['onFetch']);
defineExpose({ defineExpose({
save, save,
@ -53,7 +55,7 @@ async function fetch() {
watch(formData.value, () => (hasChanges.value = true)); watch(formData.value, () => (hasChanges.value = true));
return emit('fetch-data', state.get($props.model)); emit('onFetch', state.get($props.model));
} }
async function save() { async function save() {
@ -64,10 +66,10 @@ async function save() {
}); });
} }
isLoading.value = true; isLoading.value = true;
await new Promise((resolve) => {
setTimeout(resolve, 5000);
});
await axios.patch($props.url, formData.value); await axios.patch($props.url, formData.value);
originalData.value = formData.value;
hasChanges.value = false;
isLoading.value = false; isLoading.value = false;
} }
@ -75,11 +77,29 @@ function reset() {
state.set($props.model, originalData.value); state.set($props.model, originalData.value);
hasChanges.value = false; hasChanges.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> </script>
<template> <template>
<q-banner v-if="hasChanges" inline-actions class="text-white bg-red"> You have changes pending to save </q-banner> <q-banner v-if="hasChanges" class="text-white bg-warning">
<q-icon name="warning" size="md" class="q-mr-md" />
<span>{{ t('globals.changesToSave') }}</span>
</q-banner>
<q-form v-if="formData" @submit="save" @reset="reset" class="q-pa-md"> <q-form v-if="formData" @submit="save" @reset="reset" class="q-pa-md">
<slot name="form" :data="formData"></slot> <slot name="form" :data="formData" :validate="validate" :filter="filter"></slot>
<div class="q-mt-lg">
<slot name="actions"> <slot name="actions">
<q-btn :label="t('globals.save')" type="submit" color="primary" /> <q-btn :label="t('globals.save')" type="submit" color="primary" />
<q-btn <q-btn
@ -91,6 +111,7 @@ function reset() {
:disable="!hasChanges" :disable="!hasChanges"
/> />
</slot> </slot>
</div>
</q-form> </q-form>
<skeleton-form v-if="!formData" /> <skeleton-form v-if="!formData" />
<q-inner-loading :showing="isLoading" :label="t('globals.pleaseWait')" color="primary" /> <q-inner-loading :showing="isLoading" :label="t('globals.pleaseWait')" color="primary" />

View File

@ -1,6 +1,6 @@
<script setup> <script setup>
import axios from 'axios'; import axios from 'axios';
import { onMounted, ref } from 'vue'; import { onMounted, ref, watch } from 'vue';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
const { t } = useI18n(); const { t } = useI18n();
@ -10,6 +10,10 @@ const $props = defineProps({
type: String, type: String,
default: '', default: '',
}, },
data: {
type: Array,
default: null,
},
filter: { filter: {
type: Object, type: Object,
default: null, default: null,
@ -35,6 +39,17 @@ const $props = defineProps({
defineEmits(['onNavigate']); defineEmits(['onNavigate']);
defineExpose({ fetch }); defineExpose({ fetch });
onMounted(() => {
if ($props.autoLoad) fetch();
});
watch(
() => $props.data,
() => {
rows.value = $props.data;
}
);
const isLoading = ref(false); const isLoading = ref(false);
const hasMoreData = ref(false); const hasMoreData = ref(false);
const pagination = ref({ const pagination = ref({
@ -42,17 +57,13 @@ const pagination = ref({
rowsPerPage: $props.rowsPerPage, rowsPerPage: $props.rowsPerPage,
page: 1, page: 1,
}); });
const rows = ref(null); const rows = ref(null);
onMounted(() => {
if ($props.autoLoad) fetch();
else rows.value = [];
});
async function fetch() { async function fetch() {
const { page, rowsPerPage, sortBy, descending } = pagination.value; const { page, rowsPerPage, sortBy, descending } = pagination.value;
if (!$props.url) return;
isLoading.value = true; isLoading.value = true;
const filter = { const filter = {
@ -89,7 +100,7 @@ async function fetch() {
async function onLoad(...params) { async function onLoad(...params) {
const done = params[1]; const done = params[1];
if (!rows.value || rows.value.length === 0) return done(false); if (!rows.value || rows.value.length === 0 || !$props.url) return done(false);
pagination.value.page = pagination.value.page + 1; pagination.value.page = pagination.value.page + 1;

View File

@ -21,6 +21,7 @@ export default {
yes: 'Yes', yes: 'Yes',
no: 'No', no: 'No',
noChanges: 'No changes to save', noChanges: 'No changes to save',
changesToSave: 'You have changes pending to save',
confirmRemove: 'You are about to delete this row. Are you sure?', confirmRemove: 'You are about to delete this row. Are you sure?',
rowAdded: 'Row added', rowAdded: 'Row added',
rowRemoved: 'Row removed', rowRemoved: 'Row removed',

View File

@ -21,6 +21,7 @@ export default {
yes: 'Si', yes: 'Si',
no: 'No', no: 'No',
noChanges: 'Sin cambios que guardar', noChanges: 'Sin cambios que guardar',
changesToSave: 'Tienes cambios pendientes de guardar',
confirmRemove: 'Vas a eliminar este registro. ¿Continuar?', confirmRemove: 'Vas a eliminar este registro. ¿Continuar?',
rowAdded: 'Fila añadida', rowAdded: 'Fila añadida',
rowRemoved: 'Fila eliminada', rowRemoved: 'Fila eliminada',

View File

@ -1,33 +1,43 @@
<script setup> <script setup>
import { ref, onMounted, watch } from 'vue'; import { ref } from 'vue';
import { useRoute } from 'vue-router'; import { useRoute } from 'vue-router';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import { useQuasar } from 'quasar';
import axios from 'axios';
import { useSession } from 'src/composables/useSession';
import { useValidator } from 'src/composables/useValidator';
import SkeletonForm from 'src/components/SkeletonForm.vue';
onMounted(() => { import { useSession } from 'src/composables/useSession';
fetch(); import FetchData from 'src/components/FetchData.vue';
fetchWorkers(); import FormModel from 'src/components/FormModel.vue';
fetchClaimStates();
});
const route = useRoute(); const route = useRoute();
const quasar = useQuasar();
const { t } = useI18n(); const { t } = useI18n();
const { validate } = useValidator();
const session = useSession(); const session = useSession();
const token = session.getToken(); const token = session.getToken();
const claim = ref(null); // const claim = ref(null);
const claimCopy = ref(null); // const claimCopy = ref(null);
const hasChanges = ref(false); // const hasChanges = ref(false);
function fetch() { // function fetch() {
const id = route.params.id; // const id = route.params.id;
const filter = { // const filter = {
// include: [
// {
// relation: 'client',
// scope: {
// fields: ['name'],
// },
// },
// ],
// };
// const options = { params: { filter } };
// axios.get(`Claims/${id}`, options).then(({ data }) => {
// claim.value = data;
// claimCopy.value = Object.assign({}, data);
// watch(claim.value, () => (hasChanges.value = true));
// });
// }
const claimFilter = {
include: [ include: [
{ {
relation: 'client', relation: 'client',
@ -37,116 +47,120 @@ function fetch() {
}, },
], ],
}; };
const options = { params: { filter } };
axios.get(`Claims/${id}`, options).then(({ data }) => {
claim.value = data;
claimCopy.value = Object.assign({}, data);
watch(claim.value, () => (hasChanges.value = true));
});
}
const workers = ref([]); const workers = ref([]);
const workersCopy = ref([]); const workersCopy = ref([]);
function fetchWorkers() {
const filter = {
where: {
role: 'salesPerson',
},
};
const options = { params: { filter } };
axios.get(`Workers/activeWithRole`, options).then(({ data }) => {
workers.value = data;
workersCopy.value = data;
});
}
const claimStates = ref([]); const claimStates = ref([]);
const claimStatesCopy = ref([]); const claimStatesCopy = ref([]);
function fetchClaimStates() {
axios.get(`ClaimStates`).then(({ data }) => { // function filter(value, update, options, originalOptions, filter) {
// update(
// () => {
// if (value === '') {
// options.value = originalOptions.value;
// return;
// }
// options.value = options.value.filter(filter);
// },
// (ref) => {
// ref.setOptionIndex(-1);
// ref.moveOptionSelection(1, true);
// }
// );
// }
// function filterWorkers(value, update) {
// const search = value.toLowerCase();
// filter(value, update, workers, workersCopy, (row) => {
// const id = row.id;
// const name = row.name.toLowerCase();
// const idMatch = id == search;
// const nameMatch = name.indexOf(search) > -1;
// return idMatch || nameMatch;
// });
// }
// function filterStates(value, update) {
// const search = value.toLowerCase();
// filter(value, update, claimStates, claimStatesCopy, (row) => {
// const description = row.description.toLowerCase();
// return description.indexOf(search) > -1;
// });
// }
function setWorkers(data) {
workers.value = data;
workersCopy.value = data;
}
function setClaimStates(data) {
claimStates.value = data; claimStates.value = data;
claimStatesCopy.value = data; claimStatesCopy.value = data;
});
} }
function filter(value, update, options, originalOptions, filter) { const workerFilter = {
update( options: workers,
() => { filterFn: (options, value) => {
if (value === '') {
options.value = originalOptions.value;
return;
}
options.value = options.value.filter(filter);
},
(ref) => {
ref.setOptionIndex(-1);
ref.moveOptionSelection(1, true);
}
);
}
function filterWorkers(value, update) {
const search = value.toLowerCase(); const search = value.toLowerCase();
filter(value, update, workers, workersCopy, (row) => { if (value === '') return workersCopy.value;
return options.value.filter((row) => {
const id = row.id; const id = row.id;
const name = row.name.toLowerCase(); const name = row.name.toLowerCase();
const idMatch = id == search; const idMatches = id == search;
const nameMatch = name.indexOf(search) > -1; const nameMatches = name.indexOf(search) > -1;
return idMatch || nameMatch; return idMatches || nameMatches;
}); });
} },
};
function filterStates(value, update) { const statesFilter = {
options: claimStates,
filterFn: (options, value) => {
const search = value.toLowerCase(); const search = value.toLowerCase();
filter(value, update, claimStates, claimStatesCopy, (row) => { if (value === '') return claimStatesCopy.value;
return options.value.filter((row) => {
const description = row.description.toLowerCase(); const description = row.description.toLowerCase();
return description.indexOf(search) > -1; return description.indexOf(search) > -1;
}); });
} },
};
function save() {
const id = route.params.id;
const formData = claim.value;
if (!hasChanges.value) {
return quasar.notify({
type: 'negative',
message: t('globals.noChanges'),
});
}
axios.patch(`Claims/${id}`, formData).then((hasChanges.value = false));
}
function onReset() {
claim.value = claimCopy.value;
hasChanges.value = false;
}
</script> </script>
<template> <template>
<fetch-data
url="Workers/activeWithInheritedRole"
:filter="{ where: { role: 'salesPerson' } }"
@on-fetch="setWorkers"
auto-load
/>
<fetch-data url="ClaimStates" @on-fetch="setClaimStates" auto-load />
<q-page class="q-pa-md"> <q-page class="q-pa-md">
<div class="container"> <div class="container">
<q-card class="q-pa-md"> <q-card>
<skeleton-form v-if="!claim" /> <form-model :url="`Claims/${route.params.id}`" :filter="claimFilter" model="claim">
<q-form v-if="claim" @submit="save" @reset="onReset" greedy> <template #form="{ data, validate, filter }">
<div class="row q-gutter-md q-mb-md"> <div class="row q-gutter-md q-mb-md">
<div class="col"> <div class="col">
<q-input v-model="claim.client.name" :label="t('claim.basicData.customer')" disable /> <q-input v-model="data.client.name" :label="t('claim.basicData.customer')" disable />
</div> </div>
<div class="col"> <div class="col">
<q-input v-model="claim.created" mask="####-##-##" fill-mask="_" autofocus> <q-input v-model="data.created" mask="####-##-##" fill-mask="_" autofocus>
<template #append> <template #append>
<q-icon name="event" class="cursor-pointer"> <q-icon name="event" class="cursor-pointer">
<q-popup-proxy cover transition-show="scale" transition-hide="scale"> <q-popup-proxy cover transition-show="scale" transition-hide="scale">
<q-date v-model="claim.created" mask="YYYY-MM-DD"> <q-date v-model="data.created" mask="YYYY-MM-DD">
<div class="row items-center justify-end"> <div class="row items-center justify-end">
<q-btn v-close-popup label="Close" color="primary" flat /> <q-btn v-close-popup label="Close" color="primary" flat />
</div> </div>
@ -160,7 +174,7 @@ function onReset() {
<div class="row q-gutter-md q-mb-md"> <div class="row q-gutter-md q-mb-md">
<div class="col"> <div class="col">
<q-select <q-select
v-model="claim.workerFk" v-model="data.workerFk"
:options="workers" :options="workers"
option-value="id" option-value="id"
option-label="name" option-label="name"
@ -168,15 +182,15 @@ function onReset() {
:label="t('claim.basicData.assignedTo')" :label="t('claim.basicData.assignedTo')"
map-options map-options
use-input use-input
@filter="filterWorkers" @filter="(value, update) => filter(value, update, workerFilter)"
:rules="validate('claim.claimStateFk')" :rules="validate('claim.claimStateFk')"
:input-debounce="0" :input-debounce="0"
> >
<template #before> <template #before>
<q-avatar color="orange"> <q-avatar color="orange">
<q-img <q-img
v-if="claim.workerFk" v-if="data.workerFk"
:src="`/api/Images/user/160x160/${claim.workerFk}/download?access_token=${token}`" :src="`/api/Images/user/160x160/${data.workerFk}/download?access_token=${token}`"
spinner-color="white" spinner-color="white"
/> />
</q-avatar> </q-avatar>
@ -185,7 +199,7 @@ function onReset() {
</div> </div>
<div class="col"> <div class="col">
<q-select <q-select
v-model="claim.claimStateFk" v-model="data.claimStateFk"
:options="claimStates" :options="claimStates"
option-value="id" option-value="id"
option-label="description" option-label="description"
@ -193,7 +207,7 @@ function onReset() {
:label="t('claim.basicData.state')" :label="t('claim.basicData.state')"
map-options map-options
use-input use-input
@filter="filterStates" @filter="(value, update) => filter(value, update, statesFilter)"
:rules="validate('claim.claimStateFk')" :rules="validate('claim.claimStateFk')"
:input-debounce="0" :input-debounce="0"
> >
@ -203,14 +217,14 @@ function onReset() {
<div class="row q-gutter-md q-mb-md"> <div class="row q-gutter-md q-mb-md">
<div class="col"> <div class="col">
<q-input <q-input
v-model="claim.packages" v-model="data.packages"
:label="t('claim.basicData.packages')" :label="t('claim.basicData.packages')"
:rules="validate('claim.packages')" :rules="validate('claim.packages')"
/> />
</div> </div>
<div class="col"> <div class="col">
<q-input <q-input
v-model="claim.rma" v-model="data.rma"
:label="t('claim.basicData.returnOfMaterial')" :label="t('claim.basicData.returnOfMaterial')"
:rules="validate('claim.rma')" :rules="validate('claim.rma')"
/> />
@ -218,14 +232,11 @@ function onReset() {
</div> </div>
<div class="row q-gutter-md q-mb-md"> <div class="row q-gutter-md q-mb-md">
<div class="col"> <div class="col">
<q-checkbox v-model="claim.hasToPickUp" :label="t('claim.basicData.picked')" /> <q-checkbox v-model="data.hasToPickUp" :label="t('claim.basicData.picked')" />
</div> </div>
</div> </div>
<div> </template>
<q-btn :label="t('globals.save')" type="submit" color="primary" /> </form-model>
<q-btn :label="t('globals.reset')" type="reset" class="q-ml-sm" color="primary" flat />
</div>
</q-form>
</q-card> </q-card>
</div> </div>
</q-page> </q-page>

View File

@ -163,7 +163,7 @@ function stateColor(code) {
</q-scroll-area> </q-scroll-area>
</q-drawer> </q-drawer>
<q-page-container> <q-page-container>
<router-view v-if="claim.id" :claim="claim"></router-view> <router-view></router-view>
</q-page-container> </q-page-container>
</template> </template>

View File

@ -1,24 +1,27 @@
<script setup> <script setup>
import { onMounted, ref } from 'vue'; import { ref } from 'vue';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import { useQuasar } from 'quasar'; import { useQuasar } from 'quasar';
import { useRoute } from 'vue-router';
import axios from 'axios'; import axios from 'axios';
import SmartCard from 'src/components/SmartCard.vue'; import SmartCard from 'src/components/SmartCard.vue';
import FetchData from 'src/components/FetchData.vue';
import { toDate } from 'src/filters'; import { toDate } from 'src/filters';
onMounted(() => fetch());
const $props = defineProps({
claim: {
type: Object,
required: true,
},
});
const quasar = useQuasar(); const quasar = useQuasar();
const route = useRoute();
const { t } = useI18n(); const { t } = useI18n();
// const card = ref();
const claim = ref([]);
const fetcher = ref();
// const rma = computed(() => claim.value.rma);
const filter = { const filter = {
include: {
relation: 'rmas',
scope: {
include: { include: {
relation: 'worker', relation: 'worker',
scope: { scope: {
@ -27,27 +30,23 @@ const filter = {
}, },
}, },
}, },
where: { },
code: $props.claim.rma,
}, },
}; };
function fetch() { async function addRow() {
//console.log($props.claim);
}
function addRow() {
const formData = { const formData = {
code: $props.claim.rma, code: claim.value.rma,
}; };
axios.post(`ClaimRmas`, formData).then(() => { await axios.post(`ClaimRmas`, formData);
await fetcher.value.fetch();
quasar.notify({ quasar.notify({
type: 'positive', type: 'positive',
message: t('globals.rowAdded'), message: t('globals.rowAdded'),
icon: 'check', icon: 'check',
}); });
});
} }
const confirmShown = ref(false); const confirmShown = ref(false);
@ -57,9 +56,11 @@ function confirmRemove(id) {
rmaId.value = id; rmaId.value = id;
} }
function remove() { async function remove() {
const id = rmaId.value; const id = rmaId.value;
axios.delete(`ClaimRmas/${id}`).then(() => {
await axios.delete(`ClaimRmas/${id}`);
await fetcher.value.fetch();
confirmShown.value = false; confirmShown.value = false;
quasar.notify({ quasar.notify({
@ -67,7 +68,6 @@ function remove() {
message: t('globals.rowRemoved'), message: t('globals.rowRemoved'),
icon: 'check', icon: 'check',
}); });
});
} }
function hide() { function hide() {
@ -75,6 +75,13 @@ function hide() {
} }
</script> </script>
<template> <template>
<fetch-data
ref="fetcher"
:url="`Claims/${route.params.id}`"
:filter="filter"
@on-fetch="($data) => (claim = $data)"
auto-load
/>
<q-page class="q-pa-md sticky"> <q-page class="q-pa-md sticky">
<q-page-sticky expand position="top"> <q-page-sticky expand position="top">
<q-toolbar class="bg-grey-9"> <q-toolbar class="bg-grey-9">
@ -85,7 +92,7 @@ function hide() {
</q-toolbar> </q-toolbar>
</q-page-sticky> </q-page-sticky>
<smart-card ref="card" url="/ClaimRmas" :filter="filter" sort-by="id DESC" auto-load> <smart-card :data="claim.rmas">
<template #header="{ row }"> <template #header="{ row }">
<q-item-label caption>{{ t('claim.rma.user') }}</q-item-label> <q-item-label caption>{{ t('claim.rma.user') }}</q-item-label>
<q-item-label>{{ row.worker.user.name }}</q-item-label> <q-item-label>{{ row.worker.user.name }}</q-item-label>

View File

@ -1,52 +0,0 @@
<script setup>
import { reactive, watch } from 'vue'
const customer = reactive({
name: '',
});
watch(() => customer.name, () => {
console.log('customer.name changed');
});
</script>
<template>
<q-page class="q-pa-md">
<q-card class="q-pa-md">
<q-form @submit="onSubmit" @reset="onReset" class="q-gutter-md">
<q-input
filled
v-model="customer.name"
label="Your name *"
hint="Name and surname"
lazy-rules
:rules="[val => val && val.length > 0 || 'Please type something']"
/>
<q-input
filled
type="number"
v-model="age"
label="Your age *"
lazy-rules
:rules="[
val => val !== null && val !== '' || 'Please type your age',
val => val > 0 && val < 100 || 'Please type a real age'
]"
/>
<div>
<q-btn label="Submit" type="submit" color="primary" />
<q-btn label="Reset" type="reset" color="primary" flat class="q-ml-sm" />
</div>
</q-form>
</q-card>
</q-page>
</template>
<style lang="scss" scoped>
.card {
width: 100%;
max-width: 60em;
}
</style>

View File

@ -1,86 +1,60 @@
<script setup> <script setup>
import { onMounted, ref } from 'vue'; import { ref } from 'vue';
import { useRoute } from 'vue-router'; import { useRoute } from 'vue-router';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
// import { useQuasar } from 'quasar';
// import axios from 'axios';
import { useSession } from 'src/composables/useSession'; import { useSession } from 'src/composables/useSession';
import { useValidator } from 'src/composables/useValidator';
import { useState } from 'src/composables/useState';
import FetchData from 'src/components/FetchData.vue'; import FetchData from 'src/components/FetchData.vue';
import FormModel from 'src/components/FormModel.vue'; import FormModel from 'src/components/FormModel.vue';
onMounted(() => {
// fetch();
// fetchWorkers();
// fetchBusinessTypes();
// fetchContactChannels();
});
const route = useRoute(); const route = useRoute();
// const quasar = useQuasar();
const { t } = useI18n(); const { t } = useI18n();
const { validate } = useValidator();
const state = useState();
const session = useSession(); const session = useSession();
const token = session.getToken(); const token = session.getToken();
const data2 = state.get('customer');
console.log(data2);
const workers = ref([]); const workers = ref([]);
const contactChannels = ref([]); const workersCopy = ref([]);
const businessTypes = ref([]); const businessTypes = ref([]);
const contactChannels = ref([]);
// const customer = ref(null); function setWorkers(data) {
// const customerCopy = ref(null); workers.value = data;
// const hasChanges = ref(false); workersCopy.value = data;
}
// function filter(value, update, options, originalOptions, filter) { const filterOptions = {
// update( options: workers,
// () => { filterFn: (options, value) => {
// if (value === '') { const search = value.toLowerCase();
// options.value = originalOptions.value;
// return; if (value === '') return workersCopy.value;
// }
// options.value = options.value.filter(filter); return options.value.filter((row) => {
// }, const id = row.id;
// (ref) => { const name = row.name.toLowerCase();
// ref.setOptionIndex(-1);
// ref.moveOptionSelection(1, true);
// }
// );
// }
// function filterWorkers(value, update) { const idMatches = id == search;
// const search = value.toLowerCase(); const nameMatches = name.indexOf(search) > -1;
// filter(value, update, workers, workersCopy, (row) => { return idMatches || nameMatches;
// const id = row.id; });
// const name = row.name.toLowerCase(); },
};
// const idMatch = id == search;
// const nameMatch = name.indexOf(search) > -1;
// return idMatch || nameMatch;
// });
// }
</script> </script>
<template> <template>
<fetch-data <fetch-data
url="Workers/activeWithRole" url="Workers/activeWithInheritedRole"
:filter="{ where: { role: 'salesPerson' } }" :filter="{ where: { role: 'salesPerson' } }"
@fetch-data="($data) => (workers = $data)" @on-fetch="setWorkers"
auto-load auto-load
/> />
<fetch-data url="ContactChannels" @fetch-data="($data) => (contactChannels = $data)" auto-load /> <fetch-data url="ContactChannels" @on-fetch="($data) => (contactChannels = $data)" auto-load />
<fetch-data url="BusinessTypes" @fetch-data="($data) => (businessTypes = $data)" auto-load /> <fetch-data url="BusinessTypes" @on-fetch="($data) => (businessTypes = $data)" auto-load />
<q-page class="q-pa-md"> <q-page class="q-pa-md">
<div class="container"> <div class="container">
<q-card> <q-card>
<form-model :url="`Clients/${route.params.id}`" model="customer"> <form-model :url="`Clients/${route.params.id}`" model="customer">
<template #form="{ data }"> <template #form="{ data, validate, filter }">
<div class="row q-gutter-md q-mb-md"> <div class="row q-gutter-md q-mb-md">
<div class="col"> <div class="col">
<q-input <q-input
@ -152,7 +126,7 @@ const businessTypes = ref([]);
:label="t('customer.basicData.salesPerson')" :label="t('customer.basicData.salesPerson')"
map-options map-options
use-input use-input
@filter="filterWorkers" @filter="(value, update) => filter(value, update, filterOptions)"
:rules="validate('client.salesPersonFk')" :rules="validate('client.salesPersonFk')"
:input-debounce="0" :input-debounce="0"
> >

View File

@ -34,15 +34,6 @@ export default {
roles: ['claimManager'] roles: ['claimManager']
}, },
component: () => import('src/pages/Claim/ClaimRmaList.vue'), component: () => import('src/pages/Claim/ClaimRmaList.vue'),
},
{
name: 'ClaimCreate',
path: 'create',
meta: {
title: 'createClaim',
icon: 'vn:addperson',
},
component: () => import('src/pages/Claim/ClaimCreate.vue'),
} }
] ]
}, },
@ -76,8 +67,7 @@ export default {
title: 'rma', title: 'rma',
roles: ['claimManager'] roles: ['claimManager']
}, },
component: () => import('src/pages/Claim/Card/ClaimRma.vue'), component: () => import('src/pages/Claim/Card/ClaimRma.vue')
props: { claim: true }
} }
] ]
}, },