mirror of
https://github.com/beak-insights/felicity-lims.git
synced 2025-02-22 16:03:00 +08:00
added sample module"
This commit is contained in:
parent
1c3c2ad966
commit
e7ce786af7
3 changed files with 192 additions and 8 deletions
|
@ -5,7 +5,7 @@
|
|||
<meta charset="UTF-8">
|
||||
<link rel="icon" href="/favicon.ico" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Vite App</title>
|
||||
<title>Felicity LIMS</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
|
135
frontend/vite/src/modules/samples.ts
Normal file
135
frontend/vite/src/modules/samples.ts
Normal file
|
@ -0,0 +1,135 @@
|
|||
import Swal from 'sweetalert2';
|
||||
import { ref, toRefs, computed, PropType, watch, reactive } from 'vue';
|
||||
import { useRoute } from 'vue-router';
|
||||
import { useStore } from 'vuex';
|
||||
import { useMutation } from '@urql/vue';
|
||||
|
||||
import { isNullOrWs } from '../utils';
|
||||
import { ActionTypes, ISampleRequest, IAnalysisResult } from '../store/modules/samples';
|
||||
import { GET_ANALYSIS_RESULTS_BY_SAMPLE_UID } from '../graphql/analyses.queries';
|
||||
import {
|
||||
REINSTATE_SAMPLES,
|
||||
RECEIVE_SAMPLES,
|
||||
CANCEL_SAMPLES,
|
||||
} from '../graphql/analyses.mutations';
|
||||
import { IAnalysisProfile, IAnalysisService } from '../store/modules/analyses';
|
||||
import store from '../store';
|
||||
|
||||
export default function useSampleModules(){
|
||||
|
||||
const state = reactive({
|
||||
samples: computed(() => store.getters.getSamples )
|
||||
})
|
||||
|
||||
// CANCEL_SAMPLES
|
||||
const { executeMutation: cancelSamples } = useMutation(CANCEL_SAMPLES);
|
||||
|
||||
// function cancelSelectedSamples(analyses): void {
|
||||
// cancelSamples({ analyses }).then(_ => {});
|
||||
// }
|
||||
|
||||
const cancelSamples_ = async () => {
|
||||
try {
|
||||
Swal.fire({
|
||||
title: 'Are you sure?',
|
||||
text: "You want to cancel these samples",
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: '#3085d6',
|
||||
cancelButtonColor: '#d33',
|
||||
confirmButtonText: 'Yes, cancel now!',
|
||||
cancelButtonText: 'No, do not cancel!',
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
// cancelSelectedSamples(getSampleUids())
|
||||
let samples = getSampleUids()
|
||||
cancelSamples({ samples }).then(_ => {});
|
||||
|
||||
Swal.fire(
|
||||
'Its Happening!',
|
||||
'Your samples have been cancelled.',
|
||||
'success'
|
||||
).then(_ => location.reload())
|
||||
|
||||
}
|
||||
})
|
||||
} catch (error) {
|
||||
logger.log(error)
|
||||
}
|
||||
}
|
||||
|
||||
// REINSTATE_SAMPLES
|
||||
const { executeMutation: reinstateSamples } = useMutation(REINSTATE_SAMPLES);
|
||||
|
||||
function reInstateSelectedSamples(samples): void {
|
||||
reinstateSamples({ samples }).then(_ => {});
|
||||
}
|
||||
|
||||
const reInstateSamples_ = async () => {
|
||||
try {
|
||||
Swal.fire({
|
||||
title: 'Are you sure?',
|
||||
text: "You want to reinstate samples",
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: '#3085d6',
|
||||
cancelButtonColor: '#d33',
|
||||
confirmButtonText: 'Yes, reinstate now!',
|
||||
cancelButtonText: 'No, do not reinstate!',
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
reInstateSelectedSamples(getSampleUids());
|
||||
|
||||
Swal.fire(
|
||||
'Its Happening!',
|
||||
'Your samples have been reinstated.',
|
||||
'success'
|
||||
).then(_ => location.reload())
|
||||
|
||||
}
|
||||
})
|
||||
} catch (error) {
|
||||
logger.log(error)
|
||||
}
|
||||
}
|
||||
|
||||
// RECEIVE_SAMPLES
|
||||
const { executeMutation: receiveSamples } = useMutation(RECEIVE_SAMPLES);
|
||||
|
||||
function receiveSelectedSamples(samples): void {
|
||||
receiveSamples({ samples }).then(_ => {});
|
||||
}
|
||||
|
||||
const receiveSamples_ = async () => {
|
||||
try {
|
||||
Swal.fire({
|
||||
title: 'Are you sure?',
|
||||
text: "You want to receive samples",
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: '#3085d6',
|
||||
cancelButtonColor: '#d33',
|
||||
confirmButtonText: 'Yes, receice now!',
|
||||
cancelButtonText: 'No, do not receive!',
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
receiveSelectedSamples(getSampleUids());
|
||||
|
||||
Swal.fire(
|
||||
'Its Happening!',
|
||||
'Your analystes have been received.',
|
||||
'success'
|
||||
).then(_ => location.reload())
|
||||
|
||||
}
|
||||
})
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return {
|
||||
...toRefs(state),
|
||||
}
|
||||
}
|
|
@ -34,7 +34,39 @@
|
|||
</button>
|
||||
</div>
|
||||
<span>{{ profileAnalysesText(sample?.profiles, sample?.analyses) }}</span>
|
||||
<button type="button" class="bg-blue-400 text-white p-1 rounded leading-none">{{ sample?.status }}</button>
|
||||
<!-- <button type="button" class="bg-blue-400 text-white p-1 rounded leading-none">{{ sample?.status }}</button> -->
|
||||
<div >
|
||||
<div
|
||||
@click="dropdownOpen = !dropdownOpen"
|
||||
class="hidden md:block md:flex md:items-center ml-2 mt-2" >
|
||||
<button type="button" class="bg-blue-400 text-white p-1 rounded leading-none">{{ sample?.status }}</button>
|
||||
<div class="ml-2"><font-awesome-icon icon="chevron-down" class="text-gray-400" /></div>
|
||||
</div>
|
||||
<div
|
||||
v-show="dropdownOpen"
|
||||
@click="dropdownOpen = false"
|
||||
class="fixed inset-0 h-full w-full z-10" ></div>
|
||||
<div
|
||||
v-show="dropdownOpen"
|
||||
class="absolute mt-4 py-0 bg-gray-300 rounded-md shadow-xl z-20" >
|
||||
<div
|
||||
v-show="canVerify"
|
||||
class="no-underline text-gray-900 py-0 opacity-60 px-4 border-b border-transparent hover:opacity-100 md:hover:border-grey-dark hover:bg-blue-400 hover:text-white"
|
||||
>Verify</div>
|
||||
<div
|
||||
v-show="canReject"
|
||||
class="no-underline text-gray-900 py-0 opacity-60 px-4 border-b border-transparent hover:opacity-100 md:hover:border-grey-dark hover:bg-red-400 hover:text-white"
|
||||
>Reject</div>
|
||||
<div
|
||||
v-show="canCancel"
|
||||
class="no-underline text-gray-900 py-0 opacity-60 px-4 border-b border-transparent hover:opacity-100 md:hover:border-grey-dark hover:bg-red-400 hover:text-white"
|
||||
>Cancel</div>
|
||||
<div
|
||||
v-show="canInvalidate"
|
||||
class="no-underline text-gray-900 py-0 opacity-60 px-4 border-b border-transparent hover:opacity-100 md:hover:border-grey-dark hover:bg-gray-400 hover:text-white"
|
||||
>Invalidate</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<hr />
|
||||
<div class="grid grid-cols-2 mt-2">
|
||||
|
@ -74,14 +106,15 @@
|
|||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent, reactive, computed } from 'vue';
|
||||
import { defineComponent, reactive, computed, ref } from 'vue';
|
||||
import { useRoute } from 'vue-router';
|
||||
import { useStore } from 'vuex';
|
||||
import { ActionTypes } from '../../../store/modules/samples';
|
||||
import { ActionTypes, ISampleRequest } from '../../../store/modules/samples';
|
||||
|
||||
export default defineComponent({
|
||||
name: "sample-single",
|
||||
setup() {
|
||||
const dropdownOpen = ref(false);
|
||||
const route = useRoute();
|
||||
const store = useStore();
|
||||
|
||||
|
@ -95,15 +128,31 @@ export default defineComponent({
|
|||
}
|
||||
|
||||
function FormManager(create): void {
|
||||
|
||||
}
|
||||
|
||||
console.log(sample)
|
||||
// Sample Actions
|
||||
|
||||
|
||||
return {
|
||||
dropdownOpen,
|
||||
sample,
|
||||
profileAnalysesText,
|
||||
FormManager
|
||||
FormManager,
|
||||
canCancel: computed(() => {
|
||||
if(["received", "due"].includes(sample.value.status?.toLowerCase())) return true;
|
||||
return false
|
||||
}),
|
||||
canVerify: computed(() => { // all anlytes must be verified first
|
||||
if(sample.value.status?.toLowerCase() === "to_be_verified") return true;
|
||||
return false
|
||||
}),
|
||||
canInvalidate: computed(() => { // only for published a.k.a printed
|
||||
if(sample.value.status?.toLowerCase() === "published") return true;
|
||||
return false
|
||||
}),
|
||||
canReject: computed(() => {
|
||||
if(["received", "due"].includes(sample.value.status?.toLowerCase())) return true;
|
||||
return false
|
||||
}),
|
||||
};
|
||||
},
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue