<template>
    <v-layout v-if="xact !== 'new'" column>
        <v-dialog v-model="dialogconfirmationdeletepat" persistent max-width="190">
            <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>
                    {{msgconfirmationdeletepat}}
                </v-card-text>
                <v-card-actions>
                    <v-spacer></v-spacer>
                    <v-btn small color="error darken-1 text-sm-left" flat @click="doDeletePat()">Hapus</v-btn>
                    <v-btn small color="primary darken-1 text-sm-right" flat @click="dialogconfirmationdeletepat = false">Batal</v-btn>
                </v-card-actions>
            </v-card>
        </v-dialog>
        <v-dialog v-model="dialogconfirmationsend" persistent max-width="90">
            <v-card>
                <v-card-title dark class="headline success pt-2 pb-2" primary-title style="color:white">
                    <h4 dark>Konfirmasi</h4>
                </v-card-title>
                <v-card-text>
                    {{msgconfirmationsend}}
                </v-card-text>
                <v-card-actions>
                    <v-spacer></v-spacer>
                    <v-btn small color="success darken-1 text-sm-left" flat @click="doOrderPatient()">Kirim</v-btn>
                    <v-btn small color="primary darken-1 text-sm-right" flat @click="dialogconfirmationsend = false">Batal</v-btn>
                </v-card-actions>
            </v-card>
        </v-dialog>

        <v-card>
            <v-layout row>
                <v-flex xs12>
                    <v-subheader red--text text--lighten-1> Daftar Home Service No. {{this.$store.state.receivereference.selected_receivereference.HS_DeliveryOrderNumber}}
                        [ {{this.$store.state.receivereference.selected_receivereference.M_StaffName}} ]
                        <v-flex text-md-right>
                            
                        </v-flex>
                    </v-subheader>

                    <v-divider></v-divider>
                    
                    <v-layout row class="scroll-container" style="max-height:700px;overflow: auto;">
                        <v-flex xs12 pl-2 pr-2 pt-2 pb-2>

                            <v-data-table :headers="headers" :items="xpatients" :loading="isLoading" hide-actions class="elevation-1">

                                <template v-slot:items="props">
                                    <tr>
                                        <td class="text-xs-left pa-2">{{ props.item.T_TransactionNumbering}}</td>
                                        <td class="text-xs-left pa-2">
                                            <table>
                                                <tr style="background:#64b2cd">
                                                    <th style="width:35%;font-weight:bold;font-size:12px;color:#fff" class="text-md-center pt-2 pb-2">PASIEN</th>
                                                    <th style="width:35%;font-weight:bold;font-size:12px;color:#fff" class="text-md-center pt-2 pb-2">PEMERIKSAAN</th>
                                                    <th style="width:75%;font-weight:bold;font-size:12px;color:#fff" class="text-md-center pt-2 pb-2">SAMPEL</th>
                                                </tr>
                                                <tr style="font-size:12px" v-for="(p, xid) in props.item.details" v-bind:key="xid">


                                                    <td class="text-md-left pl-3">
                                                        <p class="mb-1">{{ p.M_PatientName}} | {{ p.T_OrderNumber}}</p>
                                                        <p style="color:#800000" class="mb-0 font-weight-bold caption">{{ p.T_OrderHeaderLabNumber}}</p>
                                                    </td>
                                                    <td class="text-md-left pl-3">
                                                        <p class="mb-1">{{ p.tes}}</p>
                                                    </td>
                                                    <td class="text-md-right mono font-weight-black pr-2">
                                                        <v-layout row wrap>
                                                            <v-flex xs12 v-for="(s, i) in p.sample" v-bind:key="i">
                                                                <v-btn @click="changeBtnSample(props.item,xid,i)" v-if="s.IsChecked === 'N'" small color="error">
                                                                    <v-icon left>close</v-icon>{{s.T_OrderSampleT_SampleTypeName}}</v-btn>
                                                                <v-btn @click="changeBtnSample(props.item,xid,i)" v-if="s.IsChecked === 'Y'" small color="success">
                                                                    <v-icon left>check</v-icon>{{s.T_OrderSampleT_SampleTypeName}}</v-btn>
                                                                <v-btn v-if="s.IsChecked === 'R'" small color="grey">
                                                                    <v-icon left>check</v-icon>{{s.T_OrderSampleT_SampleTypeName}}</v-btn>
                                                            </v-flex>
                                                        </v-layout>
                                                    </td>
                                                </tr>
                                            </table>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td class="text-xs-left pa-2">
                                            <v-btn v-if="props.item.islunas !== 'Kurang Bayar'" small color="success">{{props.item.islunas}}</v-btn>
                                            <v-btn v-if="props.item.islunas === 'Kurang Bayar'" small color="error">{{props.item.islunas}}</v-btn>
                                            <v-btn v-if="props.item.t_transactionHSIsFree === 'Y'" small color="success">Bebas Biaya</v-btn>
                                            <v-btn small color="success">NON CASH : {{convertMoney(props.item.totalnoncash)}}</v-btn>
                                            <v-btn @click="changeBtnPaid(props.item)" v-if="props.item.HS_DeliveryOrderDetailIsPaid === 'N'" small color="error">
                                                <v-icon left>close</v-icon>CASH : {{convertMoney(props.item.total)}}</v-btn>
                                            <v-btn @click="changeBtnPaid(props.item)" v-if="props.item.HS_DeliveryOrderDetailIsPaid === 'Y'" small color="success">
                                                <v-icon left>check</v-icon>CASH :{{convertMoney(props.item.total)}}</v-btn>
                                        </td>
                                        <td class="text-xs-left pa-2">
                                            <v-text-field v-model="props.item.note" label="Catatan"></v-text-field>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td class="text-xs-left pa-2">
                                            <v-btn v-if="(props.item.T_TransactionIsConfirmReceived === 'N' || (props.item.T_TransactionIsConfirmReceived === 'X' && props.item.T_TransactionIsDeliveryOrder === 'N')) && props.item.sampel !== '0' && props.item.HS_DeliveryOrderDetailIsActive ==='Y' && props.item.isreadyconfirm === 'Y'" @click="confirmTransaction(props.item)" style="min-width:160px;" class="mt-1 mb-2" small :color="'green'">Konfirmasi</v-btn>
                                     
                                            <v-btn v-if="(props.item.T_TransactionIsConfirmReceived === 'N' || props.item.T_TransactionIsConfirmReceived === 'X') && props.item.islunas === 'Kurang Bayar' && props.item.sampel === '0' && props.item.HS_DeliveryOrderDetailIsActive ==='Y'" @click="cancelTransaction(props.item)" style="min-width:160px;" class="mt-1 mb-2" small :color="'red'">Batal</v-btn>
                                            <v-btn v-if="props.item.T_TransactionIsConfirmReceived === 'Y'" @click="generateTransaction(props.item)" style="min-width:160px;" class="mt-1 mb-2" small :color="'blue'">Generate</v-btn>
                                                   <v-btn v-if="props.item.T_TransactionIsConfirmReceived === 'Y' && props.item.isgenerate === 'Y'" @click="openTransaction(props.item)" style="min-width:160px;" class="mt-1 mb-2" small :color="'orange'">Buka Transaksi</v-btn>
                                            <v-btn v-if="props.item.T_TransactionIsConfirmReceived === 'X' && props.item.T_TransactionIsDeliveryOrder === 'N' " @click="openTransaction(props.item)" style="min-width:160px;" class="mt-1 mb-2" small :color="'red'">Batal Buka Transaksi</v-btn>
                                        </td>
                                    </tr>
                                </template>
                            </v-data-table>

                        </v-flex>
                    </v-layout>
        </v-card>
        </v-layout>
</template>
<style scoped>
    .scroll-container {
        scroll-padding: 50px 0 0 50px;
    }

    ::-webkit-scrollbar {
        width: 7px;
    }

    /* this targets the default scrollbar (compulsory) */

    ::-webkit-scrollbar-track {
        background-color: #73baf3;
    }

    /* the new scrollbar will have a flat appearance with the set background color */

    ::-webkit-scrollbar-thumb {
        background-color: #2196f3;
    }

    /* this will style the thumb, ignoring the track */

    ::-webkit-scrollbar-button {
        background-color: #0079da;
    }

    /* optionally, you can style the top and the bottom buttons (left and right for horizontal bars) */

    ::-webkit-scrollbar-corner {
        background-color: black;
    }

    .text-tagihan {
        text-align: left;
        font-size: 30px;
        font-family: open sans, tahoma, sans-serif;
    }

    .text-total {
        text-align: left;
        font-size: 15px;
        font-family: open sans, tahoma, sans-serif;
    }
</style>

<script>
    module.exports = {
        data: () => ({

            oldlabel: '',
            search_test: '',
            menufilterdatestart: false,
            menufilterdateend: false,
            headers: [{
                    text: "",
                    align: "left",
                    sortable: false,
                    value: "mr",
                    width: "15%",
                    class: "pa-1 teal lighten-3 white--text"
                },
                {
                    text: "",
                    align: "left",
                    sortable: false,
                    value: "mr",
                    width: "80%",
                    class: "pa-1 teal lighten-3 white--text"
                }
            ]
        }),
        computed: {
            sumtotal: {
                get() {
                    return this.$store.state.receivereference.sumtotal
                },
                set(val) {
                    this.$store.commit("receivereference/update_sumtotal", val)
                }
            },
            ctotal: {
                get() {
                    return this.$store.state.receivereference.ctotal
                },
                set(val) {
                    this.$store.commit("receivereference/update_ctotal", val)
                }
            },
            bar_chx_all: {
                get() {
                    return this.$store.state.receivereference.bar_chx_all
                },
                set(val) {
                    this.$store.commit("receivereference/update_bar_chx_all", val)
                }
            },
            indeterminatex: {
                get() {
                    return this.$store.state.receivereference.indeterminatex
                },
                set(val) {
                    this.$store.commit("receivereference/update_indeterminatex", val)
                }
            },
            dialogconfirmationdeletepat: {
                get() {
                    return this.$store.state.receivereference.dialog_confirmation_delete_pat
                },
                set(val) {
                    this.$store.commit("receivereference/update_dialog_confirmation_delete_pat", val)
                }
            },
            msgconfirmationdeletepat() {
                return this.$store.state.receivereference.msg_confirmation_delete_pat
            },
            dialogconfirmationsend: {
                get() {
                    return this.$store.state.receivereference.dialog_confirmation_send
                },
                set(val) {
                    this.$store.commit("receivereference/update_dialog_confirmation_send", val)
                }
            },
            msgconfirmationsend() {
                return this.$store.state.receivereference.msg_confirmation_send
            },
            xact() {
                return this.$store.state.receivereference.act
            },
            xactpat() {
                return this.$store.state.receivereference.act_pat
            },
            xactsend() {
                return this.$store.state.receivereference.act_send
            },

            dialogformpatient: {
                get() {
                    return this.$store.state.receivereference.dialog_form_patient
                },
                set(val) {
                    this.$store.commit("receivereference/update_dialog_form_patient", val)
                }
            },
            isLoading() {
                return this.$store.state.receivereference.search_status == 1
            },
            xpatients(p) {
                return this.$store.state.receivereference.patients
            },
            filterComputedDateFormattedStart() {
                return this.formatDate(this.init_sdate)
            },
            filterComputedDateFormattedEnd() {
                return this.formatDate(this.init_edate)
            },
            xsearch: {
                get() {
                    return this.$store.state.receivereference.xsearch
                },
                set(val) {
                    this.$store.commit("receivereference/update_xsearch", val)
                }
            },
            init_sdate: {
                get() {
                    return this.$store.state.receivereference.init_sdate
                },
                set(val) {
                    this.$store.commit("receivereference/update_init_sdate", val)
                }
            },
            init_edate: {
                get() {
                    return this.$store.state.receivereference.init_edate
                },
                set(val) {
                    this.$store.commit("receivereference/update_init_edate", val)
                }
            },
            xnoref: {
                get() {
                    return this.$store.state.receivereference.noref
                },
                set(val) {
                    this.$store.commit("receivereference/update_noref", val)
                }
            },
            namapasien: {
                get() {
                    return this.$store.state.receivereference.namapasien
                },
                set(val) {
                    this.$store.commit("receivereference/update_nama_pasien", val)
                }
            },
            xdob: {
                get() {
                    return this.$store.state.receivereference.dob
                },
                set(val) {
                    this.$store.commit("receivereference/update_dob", val)
                }
            },
            xsexes() {
                return this.$store.state.receivereference.sexes
            },
            xsex: {
                get() {
                    return this.$store.state.receivereference.selected_sex
                },
                set(val) {
                    this.$store.commit("receivereference/update_selected_sex", val)
                }
            },
            xorderautotests() {
                return this.$store.state.receivereference.orderautotests
            },
            xorderautotest: {
                get() {
                    return this.$store.state.receivereference.orderautotest
                },
                set(val) {
                    this.$store.commit("receivereference/update_orderautotest", val)
                }
            },
            xordertests() {
                return this.$store.state.receivereference.ordertests
            },
            sub_total() {
                let tests = this.xordertests
                sub_total = 0
                tests.forEach(function (vpx, idx) {
                    let total = parseInt(vpx.total)
                    sub_total = sub_total + total
                })
                return sub_total
            },
            dp() {
                let mindp = this.$store.state.receivereference.selected_receivereference.M_UserMinDP
                let dp = mindp / 100 * this.sub_total
                return dp
            },
            isbill() {
                let isbill = this.$store.state.receivereference.selected_receivereference.M_UserIsBill
                return isbill
            },
            isagingonhold() {
                let isagingonhold = this.$store.state.receivereference.selected_receivereference.M_UserIsAgingOnHold
                return isagingonhold
            },
            agingonhold() {
                let agingonhold = this.$store.state.receivereference.selected_receivereference.M_UserIsAgingOnHoldNote
                return agingonhold
            },
            is_having_detail() {
                if (this.$store.state.receivereference.selected_receivereference.haveDetail == 'Y') return true
                return false
            },
            in_saving: {
                get() {
                    return this.$store.state.receivereference.in_saving
                },
                set(val) {
                    this.$store.commit("receivereference/update_in_saving", val)
                }
            }
        },
        methods: {
            async save_patient() {
                let pat = this.$store.state.receivereference.selected_patient
                let billID = this.$store.state.receivereference.selected_receivereference.HS_DeliveryOrderID
                let prm = {
                    token: window.one_token(),
                    billID: billID,
                    patients: pat
                }
                await this.$store.dispatch("receivereference/save_patient", prm)
            },
            changeBtnPaid(value) {
                let sel = this.xpatients
                let idx = _.findIndex(sel, function (p) {
                    return p.T_TransactionID == value.T_TransactionID
                });
                if (sel[idx].HS_DeliveryOrderDetailIsPaid === 'Y') {
                sel[idx].HS_DeliveryOrderDetailIsPaid = 'N'
                } else {
                sel[idx].HS_DeliveryOrderDetailIsPaid = 'Y'
                }
                console.log(sel)
            },
            changeBtnSample(value,id,i) {
                let sel = this.xpatients
                let idx = _.findIndex(sel, function (p) {
                    return p.T_TransactionID == value.T_TransactionID
                });
                if (sel[idx].details[id].sample[i].IsChecked === 'Y') {
                sel[idx].details[id].sample[i].IsChecked = 'N'
                } else {
                sel[idx].details[id].sample[i].IsChecked = 'Y'
                }
                console.log(sel)
            },
            confirmTransaction(value) {
                let sel = this.xpatients
                let idx = _.findIndex(sel, function (p) {
                    return p.T_TransactionID == value.T_TransactionID
                });
                var prm = {}
                prm.id = sel[idx].HS_DeliveryOrderDetailID
                prm.idheader = sel[idx].HS_DeliveryOrderDetailHS_DeliveryOrderID
                prm.transactionid = sel[idx].T_TransactionID
                prm.total = sel[idx].total
                prm.note = sel[idx].note
                prm.details = sel[idx].details
                this.$store.dispatch("receivereference/confirmtransaction", prm)
            },
            cancelTransaction(value) {
                let sel = this.xpatients
                let idx = _.findIndex(sel, function (p) {
                    return p.T_TransactionID == value.T_TransactionID
                });
                var prm = {}
                prm.id = sel[idx].HS_DeliveryOrderDetailID
                prm.idheader = sel[idx].HS_DeliveryOrderDetailHS_DeliveryOrderID
                prm.transactionid = sel[idx].T_TransactionID
                prm.total = sel[idx].total
                prm.note = sel[idx].note
                prm.details = sel[idx].details
                this.$store.dispatch("receivereference/canceltransaction", prm)
            },
            openTransaction(value) {
                let sel = this.xpatients
                let idx = _.findIndex(sel, function (p) {
                    return p.T_TransactionID == value.T_TransactionID
                });
                var prm = {}
                prm.id = sel[idx].HS_DeliveryOrderDetailID
                prm.idheader = sel[idx].HS_DeliveryOrderDetailHS_DeliveryOrderID
                prm.transactionid = sel[idx].T_TransactionID
                prm.total = sel[idx].total
                prm.note = sel[idx].note
                prm.details = sel[idx].details
                this.$store.dispatch("receivereference/opentransaction", prm)
            },
            generateTransaction(value) {
                let sel = this.xpatients
                let idx = _.findIndex(sel, function (p) {
                    return p.T_TransactionID == value.T_TransactionID
                });
                var prm = {}
                prm.id = sel[idx].HS_DeliveryOrderDetailID
                prm.idheader = sel[idx].HS_DeliveryOrderDetailHS_DeliveryOrderID
                prm.transactionid = sel[idx].T_TransactionID
                prm.total = sel[idx].total
                prm.note = sel[idx].note
                prm.details = sel[idx].details
                this.$store.dispatch("receivereference/generatetransaction", prm)
            },
            formatDate(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')}`
            },
            convertMoney(money) {
                return one_money(money)
            },
            thr_search: _.debounce(function () {
                this.$store.dispatch("receivereference/getpatient", {
                    id: this.$store.state.receivereference.selected_receivereference.HS_DeliveryOrderID,
                    userid: pat.M_UserID,
                    startdate: this.$store.state.receivereference.selected_receivereference.HS_DeliveryOrderDateHS,
                    search: this.xsearch
                })
            }, 200),
            searchBillStart() {
                this.$store.dispatch("receivereference/getpatient", {
                    id: this.$store.state.receivereference.selected_receivereference.HS_DeliveryOrderID,
                    userid: pat.M_UserID,
                    startdate: this.$store.state.receivereference.selected_receivereference.HS_DeliveryOrderDateHS,
                    search: this.xsearch
                })
            },
            searchBillEnd() {
                this.$store.dispatch("receivereference/getpatient", {
                    id: this.$store.state.receivereference.selected_receivereference.HS_DeliveryOrderID,
                    userid: pat.M_UserID,
                    startdate: this.$store.state.receivereference.selected_receivereference.HS_DeliveryOrderDateHS,
                    search: this.xsearch
                })
            },
            async saveNewPatient() {
                if (this.in_saving) return;
                this.in_saving = true;
                this.$store.dispatch("receivereference/getpatientbeforesave", {
                    id: this.$store.state.receivereference.selected_receivereference.HS_DeliveryOrderID,
                    userid: this.$store.state.receivereference.selected_receivereference.HS_DeliveryOrderM_UserID,
                    startdate: this.$store.state.receivereference.selected_receivereference.HS_DeliveryOrderDateHS,
                    search: '',
                    staff: this.$store.state.receivereference.selected_receivereference.M_StaffName
                })

            },
            changeCbxAllold(value) {
                var arr = this.xpatients
                this.indeterminatex = false
                arr.forEach((el) => {
                    el.chex = value
                })
                var selected = _.filter(arr, function (o) {
                    return o.chex;
                })
                this.$store.commit("receivereference/update_selected_patient", selected)

            },
            checkTopold(pat) {
                let patients = this.$store.state.receivereference.patients
                let idx = _.findIndex(patients, function (p) {
                    return p.T_TransactionID == pat.T_TransactionID
                });
                patients[idx].checx = !patients[idx].chex
                var selected = _.filter(patients, function (o) {
                    return o.chex;
                })

                console.log(selected)
                this.$store.commit("receivereference/update_selected_patient", selected)
            },
            changeCbxAll(value) {

                var chx_all = value === false ? true : false
                this.$store.commit("receivereference/update_bar_chx_all", chx_all)

                if (this.in_saving) return;
                this.in_saving = true;
                let patients = this.$store.state.receivereference.patients
                let pat = _.filter(patients, function (it) {
                    return it.isbill == 'N'
                })
                var prm = {}
                prm.billID = this.$store.state.receivereference.selected_receivereference.HS_DeliveryOrderID
                prm.userid = pat.M_UserID
                prm.status = value === false ? 'Y' : 'N'
                prm.patients = pat
                prm.startdate = pat.hsdate
                prm.enddate = this.init_edate
                prm.search = this.xsearch
                this.$store.dispatch("receivereference/saveall_tempbill", prm)


            },
            checkTop(pat) {
                var newval = pat.checx === 'N' ? 'Y' : 'N'
                var prm = pat
                prm.checx = newval
                prm.billid = this.$store.state.receivereference.selected_receivereference.HS_DeliveryOrderID
                prm.userid = pat.M_UserID
                prm.headerid = pat.T_TransactionID
                prm.id = pat.Temp_DeliveryOrderID
                prm.total = pat.total
                prm.startdate = pat.hsdate
                prm.enddate = this.init_edate
                prm.search = this.xsearch

                this.$store.dispatch("receivereference/save_tempbill", prm)
            },
            createNewPatient() {
                this.$store.commit("receivereference/update_act_pat", 'new')
                this.xnoref = ''
                this.namapasien = ''
                this.$store.commit("receivereference/update_selected_sex", [])
                this.xdob = ''
                this.$store.commit("receivereference/update_ordertests", [])
                this.$store.commit("receivereference/update_dialog_form_patient", true)
            },
            checkError(value) {
                var errors = this.$store.state.receivereference.errors
                if (errors.includes(value)) {
                    return true
                } else {
                    return false
                }
            },
            thr_search_test: _.debounce(function () {
                this.$store.dispatch("receivereference/searchtest", {
                    tes: this.search_test,
                    mouid: this.$store.state.receivereference.selected_receivereference.T_ReceiveReferenceHeaderM_UserID
                })
            }, 2000),
            doDeletePat() {
                var prm = {}
                prm.T_ReceiveReferencePatientT_ReceiveReferenceHeaderID = this.$store.state.receivereference.selected_receivereference
                    .T_ReceiveReferenceHeaderID
                prm.T_ReceiveReferencePatientID = this.$store.state.receivereference.x_pat_id
                prm.T_ReceiveReferencePatientName = this.namapasien
                prm.M_StaffName = this.$store.state.receivereference.selected_receivereference.M_StaffName
                this.$store.dispatch("receivereference/deletepatient", prm)
            },
            sendOrderPatient(value) {
                let msg = "Yakin, akan mengirim permintaan nomor " + this.$store.state.receivereference.selected_receivereference
                    .T_ReceiveReferenceHeaderNumber + " ?"
                this.$store.commit("receivereference/update_msg_confirmation_send", msg)
                this.$store.commit("receivereference/update_dialog_confirmation_send", true)
            },
            doOrderPatient() {
                var prm = {}
                prm.T_ReceiveReferenceHeaderID = this.$store.state.receivereference.selected_receivereference
                    .T_ReceiveReferenceHeaderID
                prm.T_ReceiveReferenceHeaderNumber = this.$store.state.receivereference.selected_receivereference
                    .T_ReceiveReferenceHeaderNumber
                this.$store.dispatch("receivereference/sendorder", prm)
            },
            convertMoney(money) {
                return one_money(money)
            },
            addTest() {
                var oldArr = this.$store.state.receivereference.ordertests
                oldArr.push(this.$store.state.receivereference.orderautotest)
                this.searchtest = ''
                this.$store.commit("receivereference/update_orderautotests", [])
                this.$store.commit("receivereference/update_orderautotest", {})
            },
            deleteDataPx(idx) {
                var inx = parseInt(idx);
                var xrow = this.$store.state.receivereference.ordertests[inx]
                if (parseInt(xrow.xid) !== 0) {
                    var xdeltest = this.$store.state.receivereference.deleted_ordertests
                    xdeltest.push(xrow)
                    this.$store.commit("receivereference/update_deleted_ordertests", xdeltest)
                }
                var oldArr = this.$store.state.receivereference.ordertests
                oldArr.splice(inx, 1)
                this.$store.commit("receivereference/update_ordertests", oldArr)
            },
        },
        watch: {
            xsearch(val, old) {
                console.log(val)
                this.xsearch = val
                this.thr_search()
            },
            search_city(val, old) {
                if (val == old) return
                if (!val) return
                if (val.length < 1) return
                if (this.$store.state.receivereference.update_autocomplete_status == 1) return
                this.thr_search_city()
            },
            search_test(val, old) {
                if (val == old) return
                if (!val) return
                if (val.length < 1) return
                if (this.$store.state.receivereference.update_autocomplete_status == 1) return
                this.thr_search_test()
            }
        }
    }
</script>