Files
FE_CPONE/test/vuex/one-home-service-supplies-receive/components/oneWalkLetterSoForm.vue
2026-04-27 10:13:31 +07:00

977 lines
44 KiB
Vue

<template>
<v-layout class="mb-2" column >
<v-dialog v-model="dialogsupplies" persistent max-width="850">
<v-card>
<v-card-title class="headline">Supplies</v-card-title>
<v-card-text>
<v-layout row>
<v-flex xs12 pa-1>
<v-data-table
:headers="headers_dialog_supplies"
:items="xsupplies"
:loading="isLoading"
hide-actions class="elevation-1">
<template slot="items" slot-scope="props">
<td class="text-xs-left pa-2">{{ props.item.supplies_name }}</td>
<td class="text-xs-center pa-2">
<div>
<v-btn v-if="checkInLists(props.item) === false" @click="addToLists(props.item)" 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="dialogsupplies = false">OK</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
<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()">Hapus</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="xdialogaction" persistent max-width="350">
<v-card>
<v-card-title color="warning" class="headline">Konfirmasi</v-card-title>
<v-card-text v-html="xmsgaction">
</v-card-text>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn color="primary darken-1" flat @click="closeDialogAction()">Ya</v-btn>
<v-btn color="error darken-1" flat @click="xdialogaction = false">Tutup</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
<v-layout row>
<v-flex xs12>
<v-card>
<v-subheader red--text text--lighten-1> FORM SUPPLIES
<span v-if="xact !== 'new'"> &nbsp;[ <span style="color:#2196F3;font-weight: 900;">{{xnumbering}}</span> ]</span>
<v-btn v-if="xact !== 'new' && currStatus === 'NEW'" dark @click="confirm()" small color="teal">Konfirmasi</v-btn>
<v-flex text-md-right>
<v-btn v-if="xact !== 'new' && currStatus === 'NEW'" @click="deleteTrx()" small color="error">Hapus</v-btn>
<v-btn v-if="( xact !== 'new' && currStatus === 'NEW') || xact === 'new'" @click="saveTrx()" small color="primary">Simpan</v-btn>
</v-flex>
</v-subheader>
<v-divider></v-divider>
<v-layout class="pb-2" row wrap>
<v-flex xs12 pa-2>
<v-layout row>
<v-flex xs2 pa-1>
<v-menu class="pr-2"
v-model="menutrxdate"
:close-on-content-click="false"
:nudge-right="40"
lazy
transition="scale-transition"
offset-y
full-width
max-width="290px"
min-width="290px"
>
<template v-slot:activator="{ on }">
<v-text-field
class="mt-1"
v-model="filterComputedDateFormattedTrx"
label="Tanggal Transaksi*"
:disabled="xact === 'edit'"
readonly
v-on="on"
@blur="date = deFormatedDate(filterComputedDateFormattedTrx)"
></v-text-field>
</template>
<v-date-picker :min="xmin" v-model="xtrxdate" no-title @input="menutrxdate = false"></v-date-picker>
</v-menu>
</v-flex>
<v-flex pa-1 xs4>
<v-select
item-text="trx_numbering"
return-object
:items="xss"
v-model="xselectedss"
:disabled="xact === 'edit'"
label="Nomor SJ Supplies*"
></v-select>
<p v-if="checkError('requiress')" class="error pl-2 pr-2" style="color:#fff">Nomor SJ dipilih dulu dong</p>
</v-flex>
<v-flex pa-1 xs4>
<v-text-field
v-model="xselectedstaff.name"
label="Petugas"
:disabled="xact !== 'eyaaa'"
></v-text-field>
</v-flex>
</v-layout>
<v-layout row>
<v-flex xs12 pa-1>
<v-textarea
filled
outline
:disabled="xact === 'edit' && currStatus === 'RCV'"
label="Catatan"
v-model="xnote"
rows="3"
></v-textarea>
</v-flex>
</v-layout>
</v-flex>
</v-layout>
</v-card>
<v-layout class="pt-2 mb-1" column row>
<v-card>
<v-layout row>
<v-flex xs12>
<v-subheader red--text text--lighten-1> ORDER</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="headerdp"
:items="dp"
:loading="isLoading"
hide-actions class="elevation-1">
<template slot="items" slot-scope="props">
<td class="text-xs-left pa-2">{{ props.item.trx_numbering }} [ <kbd>{{ props.item.trx_time }}</kbd> ]</td>
<td class="text-xs-left pa-2">{{ props.item.patient_name }}</td>
<td class="text-xs-center pa-2" >
<v-menu
bottom
origin="center center"
transition="scale-transition"
>
<template v-slot:activator="{ on }">
<v-btn
color="warning"
dark
v-on="on"
>
<v-icon left>account_balance_wallet</v-icon>{{selectedPaymentType(props.item)}}
</v-btn>
</template>
<v-list>
<v-list-tile
v-for="(paymenttype, i) in xpaymenttypes"
:key="i"
@click="selectPaymentType(props.item,paymenttype)"
>
<v-list-tile-title>{{ paymenttype.name }}</v-list-tile-title>
</v-list-tile>
</v-list>
</v-menu>
</td>
<td class="text-xs-center pa-2" >
<v-text-field
v-model="props.item.dp"
@change="changeDpAmount(props.item)"
label="Isikan jumlah DP"
single-line
class="text-xs-right"
hide-details
></v-text-field>
</td>
</template>
</v-data-table>
</v-flex>
</v-layout>
</v-flex>
</v-layout>
</v-flex>
</v-flex>
</v-card>
</v-layout>
<v-layout class="pt-2 mb-1" column row>
<v-card>
<v-layout row>
<v-flex xs12>
<v-subheader red--text text--lighten-1> SAMPLE</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="headersamples"
:items="samples"
:loading="isLoading"
hide-actions class="elevation-1">
<template slot="items" slot-scope="props">
<td class="text-xs-center pa-2">
<div>
<v-btn style="min-width:30px;padding-left: 8px;padding-right: 8px;" @click="changeStatusSample(props.item)" v-if="props.item.flag_receive === 'N'" small color="error"><v-icon>close</v-icon></v-btn>
<v-btn style="min-width:30px;padding-left: 8px;padding-right: 8px;" @click="changeStatusSample(props.item)" v-if="props.item.flag_receive === 'Y'" flat small color="success"><v-icon>check</v-icon></v-btn>
</div>
</td>
<td class="text-xs-left pa-2">{{ props.item.trx_numbering }} [ <kbd>{{ props.item.trx_time }}</kbd> ]</td>
<td class="text-xs-left pa-2">{{ props.item.patient_name }}</td>
<td class="text-xs-center pa-2" >
{{props.item.sampletype_name}}
</td>
<td class="text-xs-center pa-2" >
{{props.item.barcode}}
</td>
<td class="text-xs-center pa-2" >
<v-text-field
v-model="props.item.qty"
@change="changeQtySample(props.item)"
single-line
class="text-xs-right"
hide-details
></v-text-field>
</td>
</template>
</v-data-table>
</v-flex>
</v-layout>
</v-flex>
</v-layout>
</v-flex>
</v-flex>
</v-card>
</v-layout>
<v-layout class="pt-2 mb-1" column row>
<v-card>
<v-layout row>
<v-flex xs12>
<v-subheader red--text text--lighten-1> PENGGUNAAN SUPPLIES</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="headeruses"
:items="uses"
:loading="isLoading"
hide-actions class="elevation-1">
<template slot="items" slot-scope="props">
<td class="text-xs-left pa-2">{{ props.item.trx_numbering }} [ <kbd>{{ props.item.trx_time }}</kbd> ]</td>
<td class="text-xs-left pa-2">{{ props.item.patient_name }}</td>
<td class="text-xs-center pa-2" >
{{props.item.supplies_name}}
</td>
<td class="text-xs-center pa-2" >
{{props.item.qty}}
</td>
</template>
</v-data-table>
</v-flex>
</v-layout>
</v-flex>
</v-layout>
</v-flex>
</v-flex>
</v-card>
</v-layout>
<v-layout class="pt-2 mb-1" column row>
<v-card>
<v-layout row>
<v-flex xs12>
<v-subheader red--text text--lighten-1> SUPPLIES
</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="headersupplies"
:items="supplies"
:loading="isLoading"
hide-actions class="elevation-1">
<template slot="items" slot-scope="props">
<td class="text-xs-left pa-2">{{ props.item.supplies_name }}</td>
<td class="text-xs-center pa-2">
<v-text-field
style="margin-top:0;padidng-top:0"
single-line
hide-details
@change="changeQtySupplies(props.item)"
v-model="props.item.qty"
></v-text-field>
</td>
</template>
</v-data-table>
</v-flex>
</v-layout>
</v-flex>
</v-layout>
</v-flex>
</v-flex>
</v-card>
</v-layout>
</v-flex>
</v-flex>
</v-layout>
</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;
}
</style>
<script>
module.exports = {
data: () => ({
menutrxdate:false,
date: new Date().toISOString().substr(0, 10),
isLoading:false,
headerdp: [
{
text: "NOMOR",
align: "left",
sortable: false,
width: "15%",
class: "pa-2 blue lighten-3 white--text"
},
{
text: "PASIEN",
align: "left",
sortable: false,
width: "15%",
class: "pa-2 blue lighten-3 white--text"
},
{
text: "TIPE BAYAR",
align: "center",
sortable: false,
width: "15%",
class: "pa-2 blue lighten-3 white--text"
},
{
text: "DP",
align: "center",
sortable: false,
width: "15%",
class: "pa-2 blue lighten-3 white--text"
}
],
headersamples: [
{
text: "STATUS",
align: "center",
sortable: false,
width: "8%",
class: "pa-2 blue lighten-3 white--text"
},
{
text: "NOMOR",
align: "left",
sortable: false,
width: "15%",
class: "pa-2 blue lighten-3 white--text"
},
{
text: "PASIEN",
align: "left",
sortable: false,
width: "15%",
class: "pa-2 blue lighten-3 white--text"
},
{
text: "SAMPLE",
align: "center",
sortable: false,
width: "12%",
class: "pa-2 blue lighten-3 white--text"
},
{
text: "BARCODE",
align: "center",
sortable: false,
width: "10%",
class: "pa-2 blue lighten-3 white--text"
},
{
text: "JUMLAH",
align: "center",
sortable: false,
width: "10%",
class: "pa-2 blue lighten-3 white--text"
},
],
headeruses: [
{
text: "NOMOR",
align: "left",
sortable: false,
width: "15%",
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: "SUPPLIES",
align: "center",
sortable: false,
width: "15%",
class: "pa-2 blue lighten-3 white--text"
},
{
text: "JUMLAH",
align: "center",
sortable: false,
width: "10%",
class: "pa-2 blue lighten-3 white--text"
}
],
headersupplies: [
{
text: "SUPPLIES",
align: "left",
sortable: false,
width: "75%",
class: "pa-2 blue lighten-3 white--text"
},
{
text: "SISA",
align: "center",
sortable: false,
width: "10%",
class: "pa-2 blue lighten-3 white--text"
}
],
headerbuffer: [
{
text: "SUPPLIES",
align: "left",
sortable: false,
width: "45%",
class: "pa-2 blue lighten-3 white--text"
},
{
text: "QTY",
align: "center",
sortable: false,
width: "10%",
class: "pa-2 blue lighten-3 white--text"
},
{
text: "SISA",
align: "center",
sortable: false,
width: "10%",
class: "pa-2 blue lighten-3 white--text"
}
],
headers_dialog_supplies: [
{
text: "SUPPLIES",
align: "left",
sortable: false,
width: "85%",
class: "pa-2 blue lighten-3 white--text"
},
{
text: "STATUS",
align: "center",
sortable: false,
width: "15%",
class: "pa-2 blue lighten-3 white--text"
}
],
}),
computed: {
xact: {
get() {
return this.$store.state.sample.act
},
set(val) {
this.$store.commit("sample/update_act",val)
}
},
xnumbering(){
if(this.$store.state.sample.selected_transaction)
return this.$store.state.sample.selected_transaction.trx_numbering
else
return '-'
},
currStatus(){
if(this.$store.state.sample.selected_transaction)
return this.$store.state.sample.selected_transaction.status
else
return 'NONE'
},
xselectedtransaction(){
return this.$store.state.sample.selected_transaction
},
xtrxdate : {
get() {
return this.$store.state.sample.trx_date
},
set(val) {
this.$store.commit("sample/update_trx_date",val)
this.$store.dispatch("sample/getssbydate",{
xdate:val
})
}
},
xmin(){
return this.$store.state.sample.mindate
},
dialogconfirmationdelete:{
get() {
return this.$store.state.sample.dialog_confirmation_delete
},
set(val) {
this.$store.commit("sample/update_dialog_confirmation_delete",val)
}
},
msgconfirmationdelete(){
return this.$store.state.sample.msg_confirmation_delete
},
filterComputedDateFormattedTrx () {
return this.sampleatDate(this.xtrxdate)
},
xpaymenttypes: {
get() {
return this.$store.state.sample.paymenttypes
},
set(val) {
this.$store.commit("sample/update_paymenttypes",val)
}
},
xss: {
get() {
return this.$store.state.sample.ss
},
set(val) {
this.$store.commit("sample/update_ss",val)
}
},
xselectedss: {
get() {
return this.$store.state.sample.selected_ss
},
set(val) {
this.$store.commit("sample/update_selected_ss",val)
this.$store.commit("sample/update_selected_staff",{id:val.staff_id,name:val.staff_name})
this.$store.dispatch("sample/getdatabyss",{
ss:val
})
}
},
xselectedstaff: {
get() {
return this.$store.state.sample.selected_staff
},
set(val) {
this.$store.commit("sample/update_selected_staff",val)
console.log(val)
console.log({
xdate:this.$store.state.sample.trx_date,
staffid:val.id
})
this.$store.dispatch("sample/getorderbydatestaff",{
xdate:this.$store.state.sample.trx_date,
staffid:val.id
})
}
},
xstaffs(){
return this.$store.state.sample.staffs
},
xnote: {
get() {
return this.$store.state.sample.trx_note
},
set(val) {
this.$store.commit("sample/update_trx_note",val)
}
},
dp(){
return this.$store.state.sample.dp
},
samples(){
return this.$store.state.sample.samples
},
uses(){
return this.$store.state.sample.uses
},
supplies(){
console.log(this.$store.state.sample.supplies)
return this.$store.state.sample.supplies
},
buffers(){
return this.$store.state.sample.buffers
},
xsupplies(){
return this.$store.state.sample.list_supplies
},
xdialogaction:{
get() {
return this.$store.state.sample.dialog_action
},
set(val) {
this.$store.commit("sample/update_dialog_action",val)
}
},
xmsgaction:{
get() {
return this.$store.state.sample.msg_action
},
set(val) {
this.$store.commit("sample/update_msg_action",val)
}
},
dialogsupplies:{
get() {
return this.$store.state.sample.dialog_supplies
},
set(val) {
this.$store.commit("sample/update_dialog_supplies",val)
}
},
dialogsuppliesact:{
get() {
return this.$store.state.sample.dialog_supplies_act
},
set(val) {
this.$store.commit("sample/update_dialog_supplies_act",val)
}
},
xdateedit(){
return this.$store.state.sample.trx_date_edit
},
xstaffedit(){
return this.$store.state.sample.trx_staff_edit
},
},
methods : {
checkError(value){
var errors = this.$store.state.sample.errors
if(errors.includes(value)){
return true
}
else{
return false
}
},
sampleatDate (date) {
if (!date) return null
const [year, month, day] = date.split('-')
return `${day}-${month}-${year}`
},
deFormatedDate (date) {
if (!date) return null
const [ day,month, year] = date.split('-')
return `${year}-${month.padStart(2, '0')}-${day.padStart(2, '0')}`
},
saveTrx(){
this.$store.commit("sample/update_errors",[])
var errors = this.$store.state.sample.errors
var dp = this.$store.state.sample.dp
var samples = this.$store.state.sample.samples
var uses = this.$store.state.sample.uses
var supplies = this.$store.state.sample.supplies
var prm = {}
if(this.xact === 'new')
prm.trx_id = 0
else
prm.trx_id = this.$store.state.sample.selected_transaction.trx_id
prm.dp = dp
prm.samples = samples
prm.uses = uses
prm.supplies = supplies
prm.ss = this.$store.state.sample.selected_ss
prm.trx_date = this.xtrxdate
prm.trx_note = this.xnote
prm.staff = this.xselectedstaff
prm.startdate = this.$store.state.sample.start_date
prm.enddate = this.$store.state.sample.end_date
prm.search = this.$store.state.sample.name_lab
prm.stationid = this.$store.state.sample.selected_station.id
prm.lastid = -1
this.$store.dispatch("sample/save",prm)
},
changeFlagImage(value){
console.log('changeFlagImage')
if(this.xact === 'new' || (this.xact !== 'new' && this.currStatus === 'CREATED')){
let arr = this.$store.state.sample.details
var idx = _.findIndex(arr, item => item.orderid === value.orderid && item.sampleid === value.sampleid)
arr[idx].flag_image = value.flag_image === 'N' ? 'Y':'N'
this.$store.commit("sample/update_details",arr)
}
},
changeStatusDetail(value){
let arr = this.$store.state.sample.details
var idx = _.findIndex(arr, item => item.trx_id === value.trx_id)
arr[idx].status = value.status === 'N' ? 'Y':'N'
this.$store.commit("sample/update_details",arr)
},
changeStatusSupplies(value){
let arr = this.$store.state.sample.supplies
var idx = _.findIndex(arr, item => item.supplies_id === value.supplies_id)
arr[idx].status = value.status === 'N' ? 'Y':'N'
this.$store.commit("sample/update_supplies",arr)
},
changeStatusBuffers(value){
let arr = this.$store.state.sample.buffers
var idx = _.findIndex(arr, item => item.supplies_id === value.supplies_id)
arr[idx].status = value.status === 'N' ? 'Y':'N'
this.$store.commit("sample/update_buffers",arr)
},
changeQtySupplies(value){
let arr = this.$store.state.sample.supplies
var idx = _.findIndex(arr, item => item.supplies_id === value.supplies_id)
arr[idx].qty = value.qty
this.$store.commit("sample/update_supplies",arr)
},
changeQtyBuffers(value){
let arr = this.$store.state.sample.buffers
var idx = _.findIndex(arr, item => item.supplies_id === value.supplies_id)
arr[idx].qty = value.qty
this.$store.commit("sample/update_buffers",arr)
},
changeFlagImageReceive(value){
console.log('changeFlagImageReceive')
if(this.xact !== 'new' && this.currStatus !== 'DONE'){
let arr = this.$store.state.sample.details
var idx = _.findIndex(arr, item => item.orderid === value.orderid && item.sampleid === value.sampleid)
arr[idx].flag_image_receive = value.flag_image_receive === 'N' ? 'Y':'N'
this.$store.commit("sample/update_details",arr)
}
},
changeFlagResultReceive(value){
console.log('changeFlagResultReceive')
if(this.xact !== 'new' && this.currStatus !== 'DONE'){
let arr = this.$store.state.sample.details
var idx = _.findIndex(arr, item => item.orderid === value.orderid && item.sampleid === value.sampleid)
arr[idx].flag_result_receive = value.flag_result_receive === 'N' ? 'Y':'N'
this.$store.commit("sample/update_details",arr)
}
},
deleteTrx(){
var trx = this.$store.state.sample.selected_transaction
console.log(trx)
let msg = "Yakin, akan menghapus data transaksi "+trx.trx_numbering+" ?"
this.$store.commit("sample/update_msg_confirmation_delete",msg)
this.$store.commit("sample/update_dialog_confirmation_delete",true)
},
doDeleteTrx(){
var trx = this.$store.state.sample.selected_transaction
this.$store.dispatch("sample/deletetrx",trx)
},
releaseToCourier(){
var trx = this.$store.state.sample.selected_transaction
var msg = "Anda yakin akan menyerahkan dokumen transaksi "+trx.trx_numbering+" ke kurir ? "
this.$store.commit("sample/update_msg_action",msg)
this.$store.commit("sample/update_act",'RELEASEC')
this.$store.commit("sample/update_dialog_action",true)
},
receiveDoctor(){
var trx = this.$store.state.sample.selected_transaction
var msg = "Dokumen transaksi "+trx.trx_numbering+" telah diterima dokter ? "
this.$store.commit("sample/update_msg_action",msg)
this.$store.commit("sample/update_act",'RCVDOC')
this.$store.commit("sample/update_dialog_action",true)
},
receiveFromCourier(){
var trx = this.$store.state.sample.selected_transaction
var msg = "Dokumen transaksi "+trx.trx_numbering+" diterima dari kurir ? "
this.$store.commit("sample/update_msg_action",msg)
this.$store.commit("sample/update_act",'DONE')
this.$store.commit("sample/update_dialog_action",true)
},
forceClose(){
var trx = this.$store.state.sample.selected_transaction
var msg = "Dokumen transaksi "+trx.trx_numbering+" ditutup ? "
this.$store.commit("sample/update_msg_action",msg)
this.$store.commit("sample/update_act",'FORCEDONE')
this.$store.commit("sample/update_dialog_action",true)
},
getAge(trx_date,dob){
var patientdob = dob
var patientage = ''
var now = moment(new Date(trx_date))
var dob = moment(new Date(patientdob))
var year = now.diff(dob,'years')
dob.add(year,'years')
var month = now.diff(dob,'months')
dob.add(month,'months')
var day = now.diff(dob,'days')
if (isNaN(year)) patientage= ''
else patientage = `${year} tahun ${month} bulan ${day} hari`
return patientage
},
closeDialogAction(){
var act = this.$store.state.sample.act
var trx = this.$store.state.sample.selected_transaction
let arrtrx = this.$store.state.sample.transactions
var idx = _.findIndex(arrtrx, item => item.trx_id === trx.trx_id)
var dp = this.$store.state.sample.dp
for (var i = 0; i < dp.length; i++) {
dp[i]['patient_age'] = this.getAge(dp[i]['trx_date'],dp[i]['patient_dob'])
}
var prm = {}
prm.act = act
prm.trx = trx
prm.startdate = this.$store.state.sample.start_date
prm.enddate = this.$store.state.sample.end_date
prm.search = this.$store.state.sample.name_lab
prm.stationid = this.$store.state.sample.selected_station.id
prm.lastid = idx
prm.dp = dp
prm.trx_note = this.xnote
this.$store.dispatch("sample/doaction",prm)
},
objectPayment(value){
return {id:value.id,name:value.name}
},
changePaymentType(row,value){
let arr = this.$store.state.sample.dp
var idx = _.findIndex(arr, item => item.trx_id === row.trx_id)
arr[idx].paymenttype_id = value.paymenttype_id
this.$store.commit("sample/update_dp",arr)
},
changeDpAmount(value){
let arr = this.$store.state.sample.dp
var idx = _.findIndex(arr, item => item.trx_id === value.trx_id)
var nowval = value.dp
arr[idx].dp = nowval
this.$store.commit("sample/update_dp",arr)
},
selectedPaymentType(value){
return value.paymenttype_name
},
selectPaymentType(trx,paymenttype){
var ar = this.$store.state.sample.dp
let idx = _.findIndex(ar, function(o) { return o.trx_id == trx.trx_id })
ar[idx].paymenttype_id = paymenttype.id
ar[idx].paymenttype_name = paymenttype.name
this.$store.commit("sample/update_dp",ar)
},
changeStatusSample(value){
let arr = this.$store.state.sample.samples
var idx = _.findIndex(arr, item => item.trx_id === value.trx_id)
arr[idx].flag_receive = value.flag_receive === 'N' ? 'Y':'N'
this.$store.commit("sample/update_samples",arr)
},
changeQtySample(value){
let arr = this.$store.state.sample.samples
var idx = _.findIndex(arr, item => item.trx_id === value.trx_id)
arr[idx].qty = value.qty
this.$store.commit("sample/update_samples",arr)
},
confirm(){
var trx = this.$store.state.sample.selected_transaction
var msg = "Anda yakin akan melakukan konfirmasi ? order yang terpilih otomatis akan dikirimkan ke lab "
this.$store.commit("sample/update_msg_action",msg)
this.$store.commit("sample/update_act",'CONFIRM')
this.$store.commit("sample/update_dialog_action",true)
},
}
}
</script>