Files
FE_CPONE/test/vuex/one-result-email/components/oneSampleStorageForm.vue
2026-04-27 10:13:31 +07:00

1179 lines
52 KiB
Vue

<template>
<div>
<v-dialog v-model="dialogconfirmationdelete" persistent max-width="290">
<v-card>
<v-card-title
dark
class="headline error pt-2 pb-2"
primary-title
style="color:white"
>
<h4 dark>Konfirmasi</h4>
</v-card-title>
<v-card-text>
{{msgconfirmationdelete}}
</v-card-text>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn small color="error darken-1 text-sm-left" flat @click="doDeleteTrx()">Lakukan</v-btn>
<v-btn small color="primary darken-1 text-sm-right" flat @click="dialogconfirmationdelete = false">Batal</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
<v-dialog v-model="dialogsearchsample" persistent max-width="850">
<v-card>
<v-card-title color="warning" class="headline">Pencarian Sample</v-card-title>
<v-card-text>
<v-layout row>
<v-flex xs4 pa-1>
<v-text-field outline v-model="search_dialog" label="No Lab / Nama Pasien"></v-text-field>
</v-flex>
<v-flex xs2 pa-1>
<v-btn @click="searchSample()" color="primary">Cari ...</v-btn>
</v-flex>
</v-layout>
<v-layout row>
<v-flex xs12 pa-1>
<v-data-table
:headers="headers_search"
:items="xsamples"
:loading="isLoading"
hide-actions class="elevation-1">
<template slot="items" slot-scope="props">
<td class="text-xs-left pa-2" v-bind:class="{'amber lighten-4':isSelected(props.item)}" @click="selectMe(props.item)">{{ props.item.patientname }}</td>
<td class="text-xs-center pa-2" v-bind:class="{'amber lighten-4':isSelected(props.item)}" @click="selectMe(props.item)">{{ props.item.barcode }}</td>
<td class="pa-2" v-bind:class="{'amber lighten-4':isSelected(props.item)}" @click="selectMe(props.item)">{{ props.item.almari.name }}</td>
<td class="text-xs-center pa-2" v-bind:class="{'amber lighten-4':isSelected(props.item)}" @click="selectMe(props.item)">{{ props.item.rack.code }}</td>
<td class="text-xs-center pa-2" v-bind:class="{'amber lighten-4':isSelected(props.item)}" @click="selectMe(props.item)">{{ props.item.row }} x {{ props.item.col }}</td>
<td class="text-xs-center pa-2" v-bind:class="{'amber lighten-4':isSelected(props.item)}" @click="selectMe(props.item)">
<div>
<v-btn @click="addToLists(props.item)" v-if="checkInLists(props.item) === false" small color="error"><v-icon left>close</v-icon> Belum dipilih</v-btn>
<v-btn v-if="checkInLists(props.item) === true" flat small color="success"><v-icon left>check</v-icon> Sudah terpilih</v-btn>
</div>
</td>
</template>
</v-data-table>
</v-flex>
</v-layout>
</v-card-text>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn color="green darken-1" flat @click="closeDialogSearch()">OK</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
<v-dialog v-model="dialogsearchnonsample" persistent max-width="850">
<v-card>
<v-card-title primary-title dark color="warning" class="headline warning white--text">Daftar Non Sample</v-card-title>
<v-card-text>
<v-layout row>
<v-flex xs4 pa-1>
<v-text-field hide-details small outline v-model="search_nonsample_dialog" label="Nama Item"></v-text-field>
</v-flex>
<v-flex xs2 pa-1>
<v-btn small @click="searchNonSample()" color="primary">Cari ...</v-btn>
</v-flex>
<v-flex xs4 pa-1>
<v-text-field hide-details small outline v-model="item_new" label="Nama Item Baru"></v-text-field>
</v-flex>
<v-flex xs2 pa-1>
<v-btn small @click="addNewItemNonSample()" color="info">Tambahkan</v-btn>
</v-flex>
</v-layout>
<v-layout class="mt-2" align-center v-if="successadditem" row>
<v-flex xs12 pa-1>
<div class="success">
<h5 class="white--text text-xs-center">Item Baru sudah berhasil ditambahkan dong</h5>
</div>
</v-flex>
</v-layout>
<v-layout row>
<v-flex xs12 pa-1>
<v-data-table
:headers="headers_nonsamplesearch"
:items="xnonsamples"
:loading="isLoading"
hide-actions class="elevation-1">
<template slot="items" slot-scope="props">
<td class="text-xs-left pa-2" >{{ props.item.name }}</td>
<td class="text-xs-center pa-2" >
<div>
<v-btn @click="addToNonSampleLists(props.item)" v-if="checkInNonSampleLists(props.item) === false" small color="error"><v-icon left>close</v-icon> Belum dipilih</v-btn>
<v-btn v-if="checkInNonSampleLists(props.item) === true" flat small color="success"><v-icon left>check</v-icon> Sudah terpilih</v-btn>
</div>
</td>
</template>
</v-data-table>
</v-flex>
</v-layout>
</v-card-text>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn color="green darken-1" flat @click="closeDialogSearchNonSample()">OK</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
<v-layout class="mb-2" column >
<v-card>
<v-layout row>
<v-flex xs12>
<v-subheader red--text text--lighten-1> FORM TRANSAKSI SAMPLE STORAGE
<span v-if="xact === 'edit'"> &nbsp;[ <span style="color:#2196F3;font-weight: 900;">{{xnumbering}}</span> ]</span>
<v-flex text-md-right>
<v-btn v-if="xact === 'new'" @click="saveNewTransaction()" small color="info">Simpan</v-btn>
<v-btn v-if="xact !== 'new'" @click="cancelTransaction()" small color="error">Pembatalan</v-btn>
</v-flex>
</v-subheader>
<v-divider></v-divider>
<v-layout row wrap>
<v-flex xs12 pa-2>
<v-layout row>
<v-flex xs3 pa-1>
<v-text-field v-model="xdate" readonly="readonly" label="Tanggal Transaksi*"></v-text-field>
<p v-if="checkError('requiredate')" class="error pl-2 pr-2" style="color:#fff">Tanggal transaksi harus diisi dong</p>
</v-flex>
<v-flex xs2 pa-1>
<v-text-field v-model="xtime" readonly="readonly" label="Waktu Transaksi*"></v-text-field>
<p v-if="checkError('requiretime')" class="error pl-2 pr-2" style="color:#fff">Waktu transaksi harus diisi dong</p>
</v-flex>
<v-flex xs6 pa-1>
<v-autocomplete
label="Staf(OB)*"
v-model="xselected_staff"
:items="xstaffs"
:search-input.sync="search_staff"
auto-select-first
no-filter
item-text="M_StaffName"
return-object
:loading="is_loading"
no-data-text="Pilih Staff*"
>
<template
slot="item"
slot-scope="{ item }"
>
<v-list-tile-content>
<v-list-tile-title v-text="item.M_StaffName"></v-list-tile-title>
</v-list-tile-content>
</template>
</v-autocomplete>
<p v-if="checkError('requirestaff')" class="error pl-2 pr-2" style="color:#fff">Staff harus dipilih salah satu dong</p>
</v-flex>
<!--<v-flex xs3 pa-1>
<v-text-field v-model="xtransportername" label="Porter*"></v-text-field>
<p v-if="checkError('requiretransporter')" class="error pl-2 pr-2" style="color:#fff">Porter harus diisi dong</p>
</v-flex>-->
</v-layout>
<v-layout row>
<v-flex xs12 pa-1>
<v-textarea
filled
outline
label="Catatan"
v-model="xnote"
rows="3"
></v-textarea>
</v-flex>
</v-layout>
</v-flex>
</v-layout>
</v-flex>
</v-flex>
</v-card>
</v-layout>
<v-layout class="mb-2" column >
<v-card>
<v-layout row>
<v-flex xs12>
<v-subheader red--text text--lighten-1> NON SAMPLE
<v-flex text-md-right>
<v-btn @click="openDialogSearchNonSample()" v-if="xact === 'new'" small color="warning">Cari non sample</v-btn>
</v-flex>
</v-subheader>
<v-divider></v-divider>
<v-layout row wrap>
<v-flex xs12 pa-2>
<v-layout row>
<v-flex xs12 pa-1>
<v-data-table
:headers="headernonsamples"
:items="detailnonsamples"
:loading="isLoading"
hide-actions class="elevation-1">
<template slot="items" slot-scope="props">
<td class="text-xs-center pa-2" >
<v-icon v-if="xact === 'new'" color="error" @click="deleteDetailNonSample(props.item)">delete</v-icon>
<v-icon v-if="xact === 'edit'" color="success" >check</v-icon>
</td>
<td class="text-xs-left pa-2" >{{ props.item.name }}</td>
<td class="text-xs-left pa-2" >
<v-text-field
style="margin-top:0;padidng-top:0"
single-line
hide-details
@change="changeWeight(props.item)"
v-model="props.item.weight"
></v-text-field>
</td>
</template>
</v-data-table>
</v-flex>
</v-layout>
</v-flex>
</v-layout>
<v-divider></v-divider>
<v-layout row wrap>
<v-flex xs12 pa-2>
<v-layout align-center row>
<v-flex xs10 class="text-xs-right pr-2" pa-1>
<h3 class="font-weight-black">TOTAL BERAT</h3>
</v-flex>
<v-flex x1 class="text-xs-right pb-2" pa-1>
<v-text-field
style="text-align:center;font-size:18px;font-weight:bold;margin-top:0; width:70px"
single-line
hide-details
readonly
outline
v-model="sumTotalWeight()"
></v-text-field>
</v-flex>
<v-flex xs1 pa-1>
<h3 class="font-weight-black">KG</h3>
</v-flex>
</v-layout>
</v-flex>
</v-layout>
</v-flex>
</v-flex>
</v-card>
</v-layout>
<v-layout class="mb-2" column >
<v-card>
<v-layout row>
<v-flex xs12>
<v-subheader red--text text--lighten-1> SAMPLE
<v-flex text-md-right>
<v-btn @click="openDialogSearch()" v-if="xact === 'new'" small color="warning">Cari sample</v-btn>
</v-flex>
</v-subheader>
<v-divider></v-divider>
<v-layout row wrap>
<v-flex xs12 pa-2>
<v-layout row>
<v-flex xs12 pa-1>
<v-data-table
:headers="headers"
:items="details"
:loading="isLoading"
hide-actions class="elevation-1">
<template slot="items" slot-scope="props">
<td class="text-xs-center pa-2" v-bind:class="{'amber lighten-4':isSelected(props.item)}" @click="selectMe(props.item)">
<v-icon v-if="xact === 'new'" color="error" @click="deleteDetail(props.item)">delete</v-icon>
<v-icon v-if="xact === 'edit'" color="success" >check</v-icon>
</td>
<td class="text-xs-left pa-2" v-bind:class="{'amber lighten-4':isSelected(props.item)}" @click="selectMe(props.item)">{{ props.item.patientname }}</td>
<td class="text-xs-center pa-2" v-bind:class="{'amber lighten-4':isSelected(props.item)}" @click="selectMe(props.item)">{{ props.item.barcode }}</td>
<td class="pa-2" v-bind:class="{'amber lighten-4':isSelected(props.item)}" @click="selectMe(props.item)">{{ props.item.almari.name }}</td>
<td class="text-xs-center pa-2" v-bind:class="{'amber lighten-4':isSelected(props.item)}" @click="selectMe(props.item)">{{ props.item.rack.code }}</td>
<td class="text-xs-center pa-2" v-bind:class="{'amber lighten-4':isSelected(props.item)}" @click="selectMe(props.item)">{{ props.item.row }} x {{ props.item.col }}</td>
</template>
</v-data-table>
</v-flex>
</v-layout>
</v-flex>
</v-layout>
<v-divider></v-divider>
<v-layout row wrap>
<v-flex xs12 pa-2>
<v-layout align-center row>
<v-flex xs10 class="text-xs-right pr-2" pa-1>
<h3 class="font-weight-black">TOTAL BERAT</h3>
</v-flex>
<v-flex x1 class="text-xs-right pb-2" pa-1>
<v-text-field
style="text-align:center;font-size:18px;font-weight:bold;margin-top:0; width:70px"
single-line
hide-details
outline
v-model="sampleweight"
></v-text-field>
</v-flex>
<v-flex xs1 pa-1>
<h3 class="font-weight-black">KG</h3>
</v-flex>
</v-layout>
</v-flex>
</v-layout>
</v-flex>
</v-flex>
</v-card>
</v-layout>
<v-layout v-if="xact === 'new'" class="mb-2" column >
<v-card>
<v-layout row>
<v-flex xs12>
<v-subheader red--text text--lighten-1> POSISI PENEMPATAN SAMPLE &nbsp;<v-icon style="font-weight:800">dialpad</v-icon>&nbsp;&nbsp;
<span style="font-weight:900; color:#2196f3" v-if="xopenalmari && !xopenrack">{{xselected_almari.name}}</span>
<span style="font-weight:900; color:#2196f3" v-if="!xopenalmari && xopenrack">{{xselected_almari.name}}</span> <v-icon v-if="!xopenalmari && xopenrack" style="font-weight:800">keyboard_arrow_right</v-icon> <span v-if="!xopenalmari && xopenrack" style="font-weight:700; color:#ff5722">{{xselected_rack.code}}</span>
</v-subheader>
<v-divider></v-divider>
<v-layout row>
<v-flex xs12 align-center pa-2>
<v-layout align-center justify-center v-if="!xopenalmari && !xopenrack" row wrap>
<v-btn v-for="almari in xalmaries" color="info" dark large>{{almari.code}}</v-btn>
</v-layout>
<v-layout align-center justify-center v-if="xopenalmari && !xopenrack" row wrap>
<v-btn v-for="rack in xracks" color="info" dark>{{rack.code}}</v-btn>
</v-layout>
<v-layout align-center justify-center v-for="(rackcontent, index) in xrackcontents" v-if="!xopenalmari && xopenrack" row wrap>
<v-btn v-for="position in rackcontent" fab dark :color="checkStatus(position)">
<v-icon v-if="position.status === 'N' && position.selected === 'N'">inbox</v-icon>
<v-icon v-if="position.status === 'Y' && position.selected === 'T'">archive</v-icon>
<v-icon v-if="position.status === 'Y' && position.selected === 'N'">report_problem</v-icon>
</v-btn>
</v-layout>
</v-flex>
</v-layout>
</v-flex>
</v-flex>
</v-card>
</v-layout>
</div>
</template>
<style scoped>
table, td, th {
border: 1px solid #ddd;
text-align: left;
}
table {
border-collapse: collapse;
width: 100%;
}
th, td {
padding-top: 5px;
padding-bottom: 5px;
padding-left: 8px;
padding-right: 5px;
}
.mini-input .v-input{
margin-top: 0px;
}
.mini-input .v-input, .mini-input .v-input--selection-controls,.mini-input .v-input__slot{
margin-top: 0px;
margin-bottom:0px;
margin-left:3px;
}
.mini-input .v-messages{
min-height:0px;
}
input.fhm-input{
border: 1px solid black;
border-radius: 2px;
-webkit-box-shadow:
inset 0 0 2px rgba(0,0,0,0.1),
0 0 4px rgba(0,0,0,0.1);
-moz-box-shadow:
inset 0 0 2px rgba(0,0,0,0.1),
0 0 4px rgba(0,0,0,0.1);
box-shadow:
inset 0 0 2px rgba(0,0,0,0.1),
0 0 4px rgba(0,0,0,0.1);
padding: 2px 4px;
background: rgba(255,255,255,0.5);
margin: 0 0 1px 0;
width:30px;
text-align:center;
}
.v-messages{
min-height:0;
margin:0px;
}
</style>
<script>
module.exports = {
data: () => ({
is_loading:false,
xbarcode:'',
search_dialog:'',
search_nonsample_dialog:'',
search_staff:'',
xalmariname:'',
xrackcode:'',
xrow:0,
xcol:0,
rackrows:[],
rackcols:[],
vendor_name:'',
vendor_address:'',
item_new:'',
headers: [
{
text: "",
align: "left",
sortable: false,
width: "8%",
class: "pa-2 blue lighten-3 white--text"
},
{
text: "PASIEN",
align: "left",
sortable: false,
width: "20%",
class: "pa-2 blue lighten-3 white--text"
},
{
text: "BARCODE",
align: "center",
sortable: false,
width: "15%",
class: "pa-2 blue lighten-3 white--text"
},
{
text: "ALMARI",
align: "left",
sortable: false,
width: "25%",
class: "pa-2 blue lighten-3 white--text"
},
{
text: "RAK",
align: "center",
sortable: false,
width: "15%",
class: "pa-2 blue lighten-3 white--text"
},
{
text: "POSISI",
align: "center",
sortable: false,
width: "10%",
class: "pa-2 blue lighten-3 white--text"
}
],
headers_search: [
{
text: "PASIEN",
align: "left",
sortable: false,
width: "20%",
class: "pa-2 blue lighten-3 white--text"
},
{
text: "BARCODE",
align: "center",
sortable: false,
width: "15%",
class: "pa-2 blue lighten-3 white--text"
},
{
text: "ALMARI",
align: "left",
sortable: false,
width: "25%",
class: "pa-2 blue lighten-3 white--text"
},
{
text: "RAK",
align: "center",
sortable: false,
width: "15%",
class: "pa-2 blue lighten-3 white--text"
},
{
text: "POSISI",
align: "center",
sortable: false,
width: "10%",
class: "pa-2 blue lighten-3 white--text"
},
{
text: "AKSI",
align: "center",
sortable: false,
width: "10%",
class: "pa-2 blue lighten-3 white--text"
}
],
headers_nonsamplesearch: [
{
text: "NON SAMPLE",
align: "left",
sortable: false,
width: "90%",
class: "pa-2 blue lighten-3 white--text"
},
{
text: "AKSI",
align: "center",
sortable: false,
width: "10%",
class: "pa-2 blue lighten-3 white--text"
}
],
headernonsamples: [
{
text: "",
align: "left",
sortable: false,
width: "10%",
class: "pa-2 blue lighten-3 white--text"
},
{
text: "NON SAMPLE",
align: "left",
sortable: false,
width: "80%",
class: "pa-2 blue lighten-3 white--text"
},
{
text: "BERAT (SATUAN KG)",
align: "center",
sortable: false,
width: "15%",
class: "pa-2 blue lighten-3 white--text"
},
]
}),
computed: {
xact(){
return this.$store.state.samplestorage.act
},
xnumbering(){
return this.$store.state.form.transaction_number
},
xdate:{
get() {
return this.$store.state.form.transaction_date
},
set(val) {
this.$store.commit("form/update_transaction_date",val)
this.$store.commit("samplestorage/update_no_save",1)
}
},
xtime:{
get() {
return this.$store.state.form.transaction_time
},
set(val) {
this.$store.commit("form/update_transaction_time",val)
this.$store.commit("samplestorage/update_no_save",1)
}
},
xnote:{
get() {
return this.$store.state.form.transaction_note
},
set(val) {
this.$store.commit("form/update_transaction_note",val)
this.$store.commit("samplestorage/update_no_save",1)
}
},
isLoading() {
return this.$store.state.samplestorage.search_status == 1
},
xalmaries(){
return this.$store.state.form.almaries
},
xracks(){
return this.$store.state.form.racks
},
xstaffs(){
return this.$store.state.form.staffs
},
xselected_almari:{
get() {
return this.$store.state.form.selected_almari
},
set(val) {
this.$store.commit("form/update_selected_almari",val)
this.$store.dispatch("form/getracks",{
id:this.$store.state.form.selected_almari.id
})
}
},
xselected_rack:{
get() {
return this.$store.state.form.selected_rack
},
set(val) {
this.$store.commit("form/update_selected_rack",val)
}
},
xselected_staff:{
get() {
return this.$store.state.form.selected_staff
},
set(val) {
this.$store.commit("form/update_selected_staff",val)
}
},
details(){
return this.$store.state.form.details
},
detailnonsamples(){
return this.$store.state.form.detailnonsamples
},
xsamples(){
return this.$store.state.form.samples
},
xnonsamples(){
return this.$store.state.form.nonsamples
},
xopenalmari(){
return this.$store.state.form.open_almari
},
xopenrack(){
return this.$store.state.form.open_rack
},
xrackcontents(){
return this.$store.state.form.rack_contents
},
successadditem(){
return this.$store.state.form.success_add_item
},
dialogsearchsample:{
get() {
return this.$store.state.form.dialog_search_sample
},
set(val) {
this.$store.commit("form/update_dialog_search_sample",val)
}
},
dialogsearchnonsample:{
get() {
return this.$store.state.form.dialog_search_nonsample
},
set(val) {
this.$store.commit("form/update_dialog_search_nonsample",val)
}
},
xtransportername:{
get() {
return this.$store.state.form.porter
},
set(val) {
this.$store.commit("form/update_porter",val)
}
},
dialogconfirmationdelete:{
get() {
return this.$store.state.samplestorage.dialog_confirmation_delete
},
set(val) {
this.$store.commit("samplestorage/update_dialog_confirmation_delete",val)
}
},
msgconfirmationdelete(){
return this.$store.state.samplestorage.msg_confirmation_delete
},
sampleweight:{
get() {
return this.$store.state.form.sample_weight
},
set(val) {
this.$store.commit("form/update_sample_weight",val)
}
}
},
methods : {
checkError(value){
var errors = this.$store.state.form.errors
if(errors.includes(value)){
return true
}
else{
return false
}
},
isSelected(p) {
return p.barcode == this.$store.state.form.selected_detail.barcode
},
selectMe(detail) {
this.$store.commit("form/update_selected_detail",detail)
this.$store.commit("form/update_open_almari",false)
this.$store.commit("form/update_open_rack",true)
this.$store.commit("form/update_selected_almari",detail.almari)
this.xalmariname = detail.almari.name
this.$store.commit("form/update_selected_rack",detail.rack)
this.xrackcode = detail.rack.code
this.$store.dispatch("form/getrackcontent",{
almariid:detail.almari.id,
rackid:detail.rack.id,
col:detail.col,
row:detail.row
})
},
addDetail(){
/*var arr = this.$store.state.form.details
let idx = _.findIndex(arr, { barcode : this.xbarcode})
if(idx === -1 ){
var detail = {
xid:0,
barcode:this.xbarcode,
almari:{},
rack:{},
rackid:0,
row:0,
col:0
}
arr.push(detail)
this.$store.commit("form/update_details",arr)
let idx = _.findIndex(arr, function(o) { return o.barcode == detail.barcode })
this.$store.commit("form/update_selected_detail",arr[idx])
this.xbarcode = ''
}*/
var barcode = this.xbarcode
this.xbarcode = ''
this.$store.dispatch("form/checkbarcode",{
barcode : barcode,
details : this.$store.state.form.details
})
},
deleteDetail(detail){
var selectedbarcode = this.$store.state.form.selected_detail.barcode
var arr = this.$store.state.form.details
let idx = _.findIndex(arr, function(o) { return o.barcode == detail.barcode })
//arr.splice(idx, 1)
var result = _.reject(arr, { barcode: detail.barcode })
this.$store.commit("form/update_details",result)
if(!_.isEmpty(this.xselected_rack)){
var rackcontents = this.$store.state.form.rack_contents
for (var i = 0; i < rackcontents.length; i++) {
var childs = rackcontents[i]
for (var x = 0; x < childs.length; x++) {
var arrinlist = this.$store.state.form.details
if(childs[x].row !== 0 & childs[x].col !== 0){
let idx = _.findIndex(arrinlist, { rackid: this.xselected_rack.id, row:childs[x].row, col: childs[x].col})
if(idx !== -1){
childs[x].selected = 'T'
}
else{
childs[x].selected = 'N'
}
}
}
}
this.$store.commit("form/update_rack_contents",rackcontents)
}
if(selectedbarcode === detail.barcode){
//console.log('empty detail')
this.$store.commit("form/update_selected_detail",{})
if(!_.isEmpty(this.$store.state.form.details)){
var xnewdetail = this.$store.state.form.details[0]
this.selectMe(xnewdetail)
//this.$store.commit("form/update_selected_detail",xnewdetail)
}
this.$store.commit("form/update_selected_almari",{})
this.$store.commit("form/update_selected_rack",{})
this.$store.commit("form/update_rack_contents",[])
}
},
deleteDetailNonSample(detail){
var arr = this.$store.state.form.detailnonsamples
let idx = _.findIndex(arr, function(o) { return o.id == detail.id })
var result = _.reject(arr, { id: detail.id })
this.$store.commit("form/update_detailnonsamples",result)
},
saveNewTransaction(){
this.$store.commit("form/update_errors",[])
var errors = this.$store.state.form.errors
if(this.xdate === ''){
errors.push("requiredate")
}
if(this.xtime === ''){
errors.push("requiretime")
}
if(_.isEmpty(this.xselected_staff)){
errors.push("requirestaff")
}
if(errors.length === 0){
var prm = {
date: this.$store.state.form.transaction_date,
time: this.$store.state.form.transaction_time,
staffid:this.xselected_staff.M_StaffID,
note: this.$store.state.form.transaction_note,
details : this.$store.state.form.details,
sampleweight : this.sampleweight,
detailnonsamples:this.$store.state.form.detailnonsamples
}
this.$store.dispatch("form/save",prm)
}else{
this.$store.commit("form/update_errors",errors)
}
},
openAlmari(almari){
/*var xseldel = this.$store.state.form.selected_detail
var zxdetails = this.$store.state.form.details
let zzidxsel = _.findIndex(zxdetails, function(o) { return o.barcode == xseldel.barcode })
if(!_.isEmpty(this.$store.state.form.selected_detail) && zzidxsel !== -1){*/
this.$store.commit("form/update_open_almari",true)
this.$store.commit("form/update_selected_almari",almari)
this.xalmariname = almari.name
this.$store.dispatch("form/getracks",{
id:this.$store.state.form.selected_almari.id
})
this.$store.commit("form/update_selected_rack",{})
/*var arr = this.$store.state.form.details
var nowbarcode = this.$store.state.form.selected_detail.barcode
let idx = _.findIndex(arr, function(o) { return o.barcode == nowbarcode })
//console.log(idx)
arr[idx].almari = this.$store.state.form.selected_almari
arr[idx].rack = {}
arr[idx].rackid = 0
arr[idx].row = 0
arr[idx].col = 0
this.$store.commit("form/update_details",arr)*/
/*}
else{
var msg = "Belum memilih salah satu barcode dong "
this.$store.commit("samplestorage/update_msg_info",msg)
this.$store.commit("samplestorage/update_open_dialog_info",true)
}*/
},
openRack(rack){
/*var xseldel = this.$store.state.form.selected_detail
var zxdetails = this.$store.state.form.details
let zzidxsel = _.findIndex(zxdetails, function(o) { return o.barcode == xseldel.barcode })
if(!_.isEmpty(this.$store.state.form.selected_detail) && zzidxsel !== -1){*/
this.$store.commit("form/update_open_almari",false)
this.$store.commit("form/update_open_rack",true)
this.$store.commit("form/update_selected_rack",rack)
this.xrackcode = rack.code
/*var arr = this.$store.state.form.details
var nowbarcode = this.$store.state.form.selected_detail.barcode
let idx = _.findIndex(arr, function(o) { return o.barcode == nowbarcode })
arr[idx].almari = this.$store.state.form.selected_almari
arr[idx].rack = this.$store.state.form.selected_rack
arr[idx].rackid = this.$store.state.form.selected_rack.id
arr[idx].row = 0
arr[idx].col = 0
this.$store.commit("form/update_details",arr)*/
if(!_.isEmpty(this.xselected_rack)){
var rackcontents = rack.rackcontens
for (var i = 0; i < rackcontents.length; i++) {
var childs = rackcontents[i]
for (var x = 0; x < childs.length; x++) {
var arrinlist = this.$store.state.form.details
if(childs[x].row !== 0 & childs[x].col !== 0){
let idx = _.findIndex(arrinlist, { rackid: this.xselected_rack.id, row:childs[x].row, col: childs[x].col})
if(idx !== -1){
childs[x].selected = 'T'
}
else{
childs[x].selected = 'N'
}
}
}
}
this.$store.commit("form/update_rack_contents",rackcontents)
}
/*}
else{
var msg = "Belum memilih salah satu barcode dong "
this.$store.commit("samplestorage/update_msg_info",msg)
this.$store.commit("samplestorage/update_open_dialog_info",true)
}*/
},
setPosition(position,idx){
var xseldel = this.$store.state.form.selected_detail
var zxdetails = this.$store.state.form.details
let zzidxsel = _.findIndex(zxdetails, function(o) { return o.barcode == xseldel.barcode })
if(!_.isEmpty(this.$store.state.form.selected_detail) && zzidxsel !== -1){
var arr = this.$store.state.form.details
var existindex = _.findIndex(arr, { rackid : this.xselected_rack.id, row:position.row, col : position.col })
if(existindex === -1){
var nowbarcode = this.$store.state.form.selected_detail.barcode
let ixdx = _.findIndex(arr, function(o) { return o.barcode == nowbarcode })
arr[ixdx].almari = this.$store.state.form.selected_almari
arr[ixdx].rack = this.$store.state.form.selected_rack
arr[ixdx].rackid = this.$store.state.form.selected_rack.id
arr[ixdx].row = position.row
arr[ixdx].col = position.col
this.$store.commit("form/update_details",arr)
if(!_.isEmpty(this.xselected_rack)){
var rackcontents = this.$store.state.form.rack_contents
for (var i = 0; i < rackcontents.length; i++) {
var childs = rackcontents[i]
for (var x = 0; x < childs.length; x++) {
var arrinlist = this.$store.state.form.details
if(childs[x].row !== 0 & childs[x].col !== 0){
let idx = _.findIndex(arrinlist, { rackid: this.xselected_rack.id, row:childs[x].row, col: childs[x].col})
if(idx !== -1){
childs[x].selected = 'T'
}
else{
childs[x].selected = 'N'
}
}
}
}
this.$store.commit("form/update_rack_contents",rackcontents)
}
}
else{
var msg = "Cuman bisa diisi satu dong "
this.$store.commit("samplestorage/update_msg_info",msg)
this.$store.commit("samplestorage/update_open_dialog_info",true)
}
}
else{
var msg = "Belum memilih salah satu barcode dong "
this.$store.commit("samplestorage/update_msg_info",msg)
this.$store.commit("samplestorage/update_open_dialog_info",true)
}
},
backToAlmari(){
/*var xseldel = this.$store.state.form.selected_detail
var zxdetails = this.$store.state.form.details
let zzidxsel = _.findIndex(zxdetails, function(o) { return o.barcode == xseldel.barcode })
if(!_.isEmpty(this.$store.state.form.selected_detail) && zzidxsel !== -1){*/
this.$store.commit("form/update_open_almari",false)
this.$store.commit("form/update_open_rack",false)
this.$store.commit("form/update_selected_rack",{})
this.$store.commit("form/update_selected_almari",{})
/*}
else{
var msg = "Belum memilih salah satu barcode dong "
this.$store.commit("samplestorage/update_msg_info",msg)
this.$store.commit("samplestorage/update_open_dialog_info",true)
}*/
},
backToRack(){
/*var xseldel = this.$store.state.form.selected_detail
var zxdetails = this.$store.state.form.details
let zzidxsel = _.findIndex(zxdetails, function(o) { return o.barcode == xseldel.barcode })
if(!_.isEmpty(this.$store.state.form.selected_detail) && zzidxsel !== -1){*/
this.$store.commit("form/update_open_almari",true)
this.$store.commit("form/update_open_rack",false)
this.$store.commit("form/update_selected_rack",{})
/*}
else{
var msg = "Belum memilih salah satu barcode dong "
this.$store.commit("samplestorage/update_msg_info",msg)
this.$store.commit("samplestorage/update_open_dialog_info",true)
}*/
},
checkInLists(value){
let arrtests = this.$store.state.form.details
var idx = _.findIndex(arrtests, item => item.barcode === value.barcode)
if(idx !== -1){
return true
}
else{
return false
}
},
checkInNonSampleLists(value){
let arrtests = this.$store.state.form.detailnonsamples
var idx = _.findIndex(arrtests, item => item.id === value.id)
if(idx !== -1){
return true
}
else{
return false
}
},
addToLists(value){
let arr = this.$store.state.form.details
var idx = _.findIndex(arr, item => item.barcode === value.barcode)
if(idx === -1){
var detail = {
xid:0,
barcode:value.barcode,
almari:value.almari,
rack:value.rack,
rackid:value.rack.id,
row:value.row,
col:value.col,
ordersampleid:value.ordersampleid,
patientname:value.patientname
}
arr.push(detail)
this.$store.commit("form/update_details",arr)
let idx = _.findIndex(arr, function(o) { return o.barcode == detail.barcode })
this.$store.commit("form/update_selected_detail",arr[idx])
this.$store.commit("samplestorage/update_no_save",true)
this.$store.dispatch("form/lookupsamples",{
search:this.search_dialog
})
}
else{
var msg = "Sudah ada di list dong "
this.$store.commit("samplestorage/update_msg_info",msg)
this.$store.commit("samplestorage/update_open_dialog_info",true)
}
},
addToNonSampleLists(value){
//console.log(value.name)
let arr = this.$store.state.form.detailnonsamples
var idx = _.findIndex(arr, item => item.id === value.id)
if(idx === -1){
var detail = {
xid:0,
id:value.id,
name:value.name,
weight:0
}
arr.push(detail)
this.$store.commit("form/update_detailnonsamples",arr)
//console.log(this.$store.state.form.detailnonsamples)
let idx = _.findIndex(arr, function(o) { return o.id == detail.id })
this.$store.commit("form/update_selected_detail_nonsample",arr[idx])
this.$store.commit("samplestorage/update_no_save",true)
this.$store.dispatch("form/lookupnonsamples",{
search:this.search_nonsample_dialog
})
}
else{
var msg = "Sudah ada di list dong "
this.$store.commit("samplestorage/update_msg_info",msg)
this.$store.commit("samplestorage/update_open_dialog_info",true)
}
},
openDialogSearch(){
this.$store.dispatch("form/lookupsamples",{
search:this.search_dialog
})
},
openDialogSearchNonSample(){
//this.dialogsearchnonsample = true
//console.log(this.$store.state.form.dialog_search_nonsample)
this.$store.dispatch("form/lookupnonsamples",{
search:this.search_nonsample_dialog
})
},
closeDialogSearch(){
this.$store.commit("form/update_dialog_search_sample",false)
},
closeDialogSearchNonSample(){
this.$store.commit("form/update_dialog_search_nonsample",false)
},
searchSample(){
this.$store.dispatch("form/lookupsamples",{
search:this.search_dialog
})
},
searchNonSample(){
this.$store.dispatch("form/lookupnonsamples",{
search:this.search_nonsample_dialog
})
},
checkStatus(value){
if(value.status === 'N' && value.selected === 'N'){
return 'info'
}else if(value.status === 'Y' && value.selected === 'T'){
return 'warning'
}
else{
return 'error'
}
},
changeWeight(value){
let arr = this.$store.state.form.detailnonsamples
var idx = _.findIndex(arr, item => item.id === value.id)
arr[idx].weight = value.weight
console.log(arr)
this.$store.commit("form/update_detailnonsamples",arr)
},
saveNewVendor(){
this.$store.commit("form/update_errors",[])
var errors = this.$store.state.form.errors
if(this.vendor_name === ''){
errors.push("requirevendorname")
}
if(errors.length === 0){
var prm = {vendor_name:this.vendor_name,vendor_address:this.vendor_address}
this.$store.dispatch("form/savenewvendor",prm)
}
},
addNewItemNonSample(){
var newitem = this.item_new
var prm = {name:newitem}
this.$store.dispatch("form/savenewitem",prm)
this.item_new = ''
},
thr_search_staff: _.debounce( function () {
this.$store.dispatch("form/searchstaff",this.search_staff)
},2000),
sumTotalWeight(){
console.log(this.$store.state.form.detailnonsamples)
if(this.$store.state.form.detailnonsamples){
var total = 0
var nonsamples = this.$store.state.form.detailnonsamples
for (var i = 0; i < this.$store.state.form.detailnonsamples.length; i++) {
console.log(nonsamples[i].weight)
total = total + parseFloat(nonsamples[i].weight)
}
console.log(total)
return total
}
else{
return 0
}
},
cancelTransaction(){
var trx = this.$store.state.samplestorage.selected_transaction
console.log(trx)
let msg = "Yakin, akan membatalkan data transaksi "+trx.trx_number+" ?"
this.$store.commit("samplestorage/update_msg_confirmation_delete",msg)
this.$store.commit("samplestorage/update_dialog_confirmation_delete",true)
},
doDeleteTrx(){
var trx = this.$store.state.samplestorage.selected_transaction
this.$store.dispatch("samplestorage/deletetrx",trx)
},
},
watch: {
search_staff(val,old) {
if (val == old ) return
if (! val) return
if (val.length < 1 ) return
if (this.$store.state.form.update_autocomplete_status == 1 ) return
this.thr_search_staff()
}
}
}
</script>