From 17b3e73d21d9e6b91752feee25e898f2fbbbd085 Mon Sep 17 00:00:00 2001 From: joan Date: Wed, 19 Oct 2022 12:22:05 +0200 Subject: [PATCH] Claim summary --- src/pages/Claim/Card/ClaimBasicData.vue | 118 +++++++++------ src/pages/Claim/Card/ClaimCard.vue | 4 +- src/pages/Claim/Card/ClaimSummary.vue | 186 ++++++++++++++++++++++++ src/pages/Claim/ClaimList.vue | 17 ++- src/router/modules/claim.js | 15 +- 5 files changed, 290 insertions(+), 50 deletions(-) create mode 100644 src/pages/Claim/Card/ClaimSummary.vue diff --git a/src/pages/Claim/Card/ClaimBasicData.vue b/src/pages/Claim/Card/ClaimBasicData.vue index 66cd7c8e1..c73a4817f 100644 --- a/src/pages/Claim/Card/ClaimBasicData.vue +++ b/src/pages/Claim/Card/ClaimBasicData.vue @@ -19,6 +19,7 @@ const session = useSession(); const token = session.getToken(); const claim = ref(null); +const claimCopy = ref(null); function fetch() { const id = route.params.id; const filter = { @@ -32,39 +33,76 @@ function fetch() { ], }; const options = { params: { filter } }; - axios.get(`Claims/${id}`, options).then((response) => { - // const { data } = response; - - // data.created = new Date(data.created); - - claim.value = response.data; + axios.get(`Claims/${id}`, options).then(({ data }) => { + claim.value = data; + claimCopy.value = Object.assign({}, data); }); } const workers = ref([]); +const workersCopy = ref([]); function fetchWorkers() { - axios.get(`Workers`).then((response) => (workers.value = response.data)); -} - -function filterFn(val, update) { - console.log(val, update); - - // if (val === '') { - // update(() => { - // workers.value = workersCopy.value; - // }); - // return; - // } - - // update(() => { - // const needle = val.toLowerCase(); - // workers.value = workers.value.filter((v) => v.firstName.toLowerCase().indexOf(needle) > -1); - // }); + const filter = { + where: { + role: 'employee', + }, + }; + const options = { params: { filter } }; + axios.get(`Workers/activeWithRole`, options).then(({ data }) => { + workers.value = data; + workersCopy.value = data; + }); } const claimStates = ref([]); +const claimStatesCopy = ref([]); function fetchClaimStates() { - axios.get(`ClaimStates`).then((response) => (claimStates.value = response.data)); + axios.get(`ClaimStates`).then(({ data }) => { + claimStates.value = data; + claimStatesCopy.value = 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 save() { @@ -74,15 +112,15 @@ function save() { axios.patch(`Claims/${id}`, formData); } -const vRule = { - mounted: (element, binding) => console.log(binding.value), -}; +function onReset() { + claim.value = claimCopy.value; +} diff --git a/src/router/modules/claim.js b/src/router/modules/claim.js index c7e39fc68..98102d5f0 100644 --- a/src/router/modules/claim.js +++ b/src/router/modules/claim.js @@ -4,7 +4,6 @@ export default { name: 'Claim', path: '/claim', meta: { - roles: ['developer'], title: 'claims', icon: 'vn:claims' }, @@ -38,15 +37,25 @@ export default { ] }, { + name: 'ClaimCard', path: ':id', component: () => import('src/pages/Claim/Card/ClaimCard.vue'), - redirect: { name: 'ClaimBasicData' }, + redirect: { name: 'ClaimSummary' }, children: [ + { + name: 'ClaimSummary', + path: 'summary', + meta: { + title: 'summary' + }, + component: () => import('src/pages/Claim/Card/ClaimSummary.vue'), + }, { name: 'ClaimBasicData', path: 'basic-data', meta: { - title: 'basicData' + title: 'basicData', + roles: ['salesPerson'] }, component: () => import('src/pages/Claim/Card/ClaimBasicData.vue'), }