Files
FE_CPONE/test/vuex/cpone-md-nonlab-conclusion/components/oneMdNonlabConclusionTest.vue
2026-04-27 10:13:31 +07:00

533 lines
20 KiB
Vue

<template>
<v-layout>
<!-- Alert dialog -->
<v-dialog v-model="dialogdeletealert" max-width="30%">
<v-card>
<v-card-title class="headline grey lighten-2 pt-2 pb-2" primary-title>
Peringatan !
</v-card-title>
<v-card-text class="pt-2 pb-2">
<v-layout row>
<v-flex xs12 d-flex>
<v-layout row>
<v-flex pb-1 xs12>
<v-layout row>
<v-flex pt-2 pr-2 xs12>
{{ msgalert }}
</v-flex>
</v-layout>
</v-flex>
</v-layout>
</v-flex>
</v-layout>
</v-card-text>
<v-divider></v-divider>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn color="primary" flat @click="dialogdeletealert = false">
Tutup
</v-btn>
<v-btn color="primary" flat @click="deleteRow()">
Yakin lah
</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
<!-- End alert dialog -->
<!-- ERROR DIALOG -->
<v-dialog v-model="dialog_error" max-width="500px">
<v-card>
<v-card-title>
<span>ERROR !</span>
<v-spacer></v-spacer>
</v-card-title>
<v-divider></v-divider>
<div class="ma-3 red--text">{{ msgError }}</div>
<v-divider></v-divider>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn color="primary" flat @click="dialog_error = false">Close</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
<!-- END ERROR DIALOG -->
<!-- Snackbar -->
<v-snackbar v-model="snackbar" :timeout="5000" :multi-line="false" :vertical="false" :top="true" :color="clr"
:value="snackbar">
{{ msgsnackbar }}
<v-btn flat @click="snackbar = false"> Tutup </v-btn>
</v-snackbar>
<!-- End Snackbar -->
<v-dialog v-model="dialog_form" persistent max-width="600px">
<v-card>
<v-card-title>
<span class="headline">FORM NONLAB CONCLUSION</span></v-card-title>
<v-divider></v-divider>
<v-progress-linear v-if="loading_save" :indeterminate="true"></v-progress-linear>
<v-card-text class="pt-0 pb-0">
<v-layout wrap>
<v-flex xs12>
<v-text-field v-model="xcode" label="Kode*"
:error="code_error_message !== ''"
:error-messages="code_error_message" @blur="codeValidation" required></v-text-field>
</v-flex>
<v-flex xs12>
<v-text-field v-model="xname" label="Nama*"
:error="nama_error_message !== ''"
:error-messages="nama_error_message" @blur="namaValidation" required></v-text-field>
</v-flex>
</v-layout>
</v-card-text>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn color="primary" flat @click="dialog_form = false" :disabled="loading_save">Tutup</v-btn>
<v-btn v-if="xact === 'new'" color="blue darken-1" flat :disabled="loading_save" @click="saveAdd()">Simpan</v-btn>
<v-btn v-if="xact === 'edit'" color="blue darken-1" flat :disabled="loading_save" @click="saveEdit()">Simpan Perubahan</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
<v-flex xs12>
<v-card>
<v-toolbar color="blue lighten-3" dark height="50px">
<v-toolbar-title>NONLAB CONCLUSION MAPPING TEST</v-toolbar-title>
<v-spacer></v-spacer>
<!-- <div>
<v-btn icon @click="openAddForm()"><v-icon>library_add</v-icon></v-btn>
</div> -->
</v-toolbar>
<v-layout row style="background:white">
<v-layout row justify-left>
<v-flex xs8>
<v-text-field class="ma-1 ml-2 mr-2" label="Cari" placeholder="Kode atau Nama"
v-model="xsearch" outline hide-details></v-text-field>
</v-flex>
<v-flex xs4>
<v-select item-text="M_StatusName" return-object :items="f_statuss" style="font-size:14px"
class="mini-select ma-1 text-md-right" v-model="selected_statuss" outline hide-details
label="Status"></v-select>
</v-flex>
</v-layout>
</v-layout>
<v-divider></v-divider>
<div>
<v-layout row class="scroll-container" style="max-height:600px;overflow: auto;">
<v-flex xs12 pl-2 pr-2 pt-2 pb-2>
<v-data-table :headers="headers" :items="xnonlabtest" :isLoading="isLoading" hide-actions class="elevation-1">
<template slot="items" slot-scope="props">
<td class="text-xs-center pa-2">
{{ props.item.Nat_TestCode }}
</td>
<td class="text-xs-left pa-2">
{{ props.item.Nat_TestName }}
</td>
<td class="text-xs-center pa-2">
<div>
<v-btn @click="changeBtnFlag(props.item)" v-if="props.item.status === 'N'" small color="error">
Belum dipilih</v-btn>
<v-btn @click="changeBtnFlag(props.item)" v-if="props.item.status === 'Y'" small color="success">
Sudah terpilih</v-btn>
</div>
</td>
</template>
</v-data-table>
</v-flex>
</v-layout>
<v-divider></v-divider>
<v-pagination style="margin-top:10px;margin-bottom:10px" v-model="curr_page" :length="xtotal_page"></v-pagination>
</div>
</v-card>
</v-flex>
</v-layout>
</template>
<style scoped>
.searchbox .v-input.v-text-field .v-input__slot {
min-height: 60px;
}
.searchbox .v-btn {
min-height: 60px;
}
table.v-table tbody td,
table.v-table tbody th {
height: 40px;
}
table.v-table thead tr {
height: 40px;
}
.textinput {
-webkit-transition: width 0.4s ease-in-out;
transition: width 0.4s ease-in-out;
background-color: white;
background-position: 10px 10px;
background-repeat: no-repeat;
padding-left: 40px;
width: 100%;
padding: 8px 10px;
margin-bottom: 5px;
box-sizing: border-box;
border: 1px solid #607d8b;
}
.textinput:focus {
width: 100%;
}
.textinput:focus::-webkit-input-placeholder {
color: transparent;
}
.textinput:focus::-moz-placeholder {
color: transparent;
}
.textinput:-moz-placeholder {
color: transparent;
}
.boxoutline {
color: red;
border: 1px solid red;
justify-content: center;
height: 45px;
line-height: 45px;
padding-left: 10px;
background: #ffffff;
font-size: 14px;
font-weight: 500;
border-radius: 1px
}
.boxoutline:hover {
background: rgba(0, 0, 0, 0.07) !important;
font-size: 15px;
font-weight: 700;
}
.boxsolid {
color: #ffffff;
border: 1px solid #ffffff;
justify-content: center;
height: 45px;
line-height: 45px;
padding-left: 10px;
background: #f44336;
font-size: 14px;
font-weight: 500;
border-radius: 1px
}
.boxsolid:hover {
background: #f44336de;
font-size: 15px;
font-weight: 700;
}
.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;
}
/* if both the vertical and the horizontal bars appear, then perhaps the right bottom corner also needs to be styled */
</style>
<script>
module.exports = {
data() {
return {
xcode: "",
xname: "",
code_error_message: "",
nama_error_message: "",
clr: "success",
dialogdeletealert: false,
msgalert: "",
headers: [{
text: "KODE",
align: "center",
sortable: false,
value: "name",
width: "20%",
class: "blue lighten-3 white--text"
},
{
text: "NAMA",
align: "left",
sortable: false,
value: "name",
width: "50%",
class: "blue lighten-3 white--text"
},
{
text: "AKSI",
align: "center",
sortable: false,
value: "name",
width: "30%",
class: "blue lighten-3 white--text"
},
],
};
},
mounted() {
},
computed: {
f_statuss() {
return this.$store.state.nonlabtest.statuss
},
selected_statuss: {
get() {
return this.$store.state.nonlabtest.selected_statuss
},
set(val) {
this.$store.commit("nonlabtest/update_selected_statuss", val)
// this.$store.dispatch("nonlabtest/lookuptest")
}
},
xnonlabtest() {
return this.$store.state.nonlabtest.nonlabtests
},
isLoading() {
return this.$store.state.nonlabtest.lookup_search
},
xsearch: {
get() {
return this.$store.state.nonlabtest.x_search
},
set(val) {
this.$store.commit("nonlabtest/update_x_search", val)
}
},
curr_page: {
get() {
return this.$store.state.nonlabtest.current_page
},
set(val) {
this.$store.commit("nonlabtest/update_current_page", val)
this.$store.commit("nonlabtest/update_last_id", -1)
this.$store.dispatch("nonlabtest/lookuptest")
}
},
xtotal_page: {
get() {
return this.$store.state.nonlabtest.total_nonlabtest
},
set(val) {
this.$store.commit("nonlabtest/update_total_nonlabtest", val)
}
},
selected_nonlabconclusiontestid() {
return this.$store.state.nonlabtest.selected_nonlabconclusiontestid
},
dialog_form: {
get() {
return this.$store.state.detail.dialog_form
},
set(val) {
this.$store.commit("detail/update_dialog_form", val)
},
},
xact: {
get() {
return this.$store.state.detail.act
},
set(val) {
this.$store.commit("detail/update_act", val)
}
},
loading_save: {
get() {
return this.$store.state.nonlabtest.loading_save
},
set(val) {
this.$store.commit("nonlabtest/update_loading_save", val)
},
},
snackbar: {
get() {
return this.$store.state.nonlabtest.alert_success
},
set(val) {
this.$store.commit("nonlabtest/update_alert_success", val)
}
},
msgsnackbar() {
return this.$store.state.nonlabtest.msg_success
},
dialog_error: {
get() {
return this.$store.state.nonlabtest.alert_error
},
set(val) {
this.$store.commit("nonlabtest/update_alert_error", val)
},
},
msgError() {
return this.$store.state.nonlabtest.error_message
}
},
methods: {
// selectMe(selected) {
// this.$store.commit("detail/update_selected_nonlabdetail", selected)
// this.$store.commit("detail/update_last_id", selected.NonlabTemplateDetailID)
// },
thr_search: _.debounce(function () {
this.$store.dispatch("nonlabtest/lookuptest")
}, 1000),
thr_search_nonlabtest: _.debounce(function () {
this.$store.dispatch("nonlabtest/lookuptest")
}, 1000),
thr_search_statuss: _.debounce(function () {
this.$store.dispatch("nonlabtest/lookuptest")
}, 1000),
codeValidation() {
if (!this.xcode) {
this.code_error_message = "Anda belum mengisi"
}
if (this.xcode) {
this.code_error_message = ""
}
},
namaValidation() {
if (!this.xname) {
this.nama_error_message = "Anda belum mengisi"
}
if (this.xname) {
this.nama_error_message = ""
}
},
resetAllInput() {
this.xname = ""
this.xcode = ""
this.code_error_message = ""
this.nama_error_message = ""
},
openAddForm() {
this.dialog_form = true
this.$store.commit("nonlab/update_act", "new")
this.$store.commit("nonlab/update_last_id", -1)
this.xname = ""
this.xcode = ""
this.resetAllInput()
},
saveAdd() {
this.codeValidation()
this.namaValidation()
if (this.code_error_message === "" && this.nama_error_message === "") {
let prm = {
code: this.xcode,
name: this.xname,
nonlabid: this.selected_nonlabtemplate_id
}
this.$store.dispatch("detail/adddetail", prm)
}
},
confirmDelete(data) {
this.selectMe(data)
this.xid = data.NonlabTemplateDetailID
this.xname = data.NonlabTemplateDetailName
this.msgalert = "Yakin, mau hapus non lab template detail " + data.NonlabTemplateDetailName + " ?"
this.dialogdeletealert = true
},
deleteRow() {
this.$store.commit("detail/update_last_id", -1)
let prm = {
id: this.xid,
name: this.xname
}
this.$store.dispatch("detail/deletedetail", prm)
this.dialogdeletealert = false
},
changeBtnFlag(value) {
var prm = {
status: value.status == "N" ? "Y" : "N",
conclusionid: this.selected_nonlabconclusiontestid,
test_id: value.Nat_TestID,
name: value.Nat_TestName
}
// console.log(prm)
this.$store.dispatch("nonlabtest/saveedittestmap", prm)
},
resetAllError() {
this.code_error_message = ""
this.nama_error_message = ""
},
openEdit(data) {
// console.log(data)
this.selectMe(data)
this.dialog_form = true
this.$store.commit("detail/update_act", "edit")
this.xid = data.NonlabTemplateDetailID
this.xcode = data.NonlabTemplateDetailCode
this.xname = data.NonlabTemplateDetailName
this.resetAllError()
this.$store.commit("detail/update_last_id", data.NonlabTemplateDetailID)
},
saveEdit() {
this.codeValidation()
this.namaValidation()
if (this.nama_error_message === "" && this.code_error_message === "") {
let prm = {
id: this.xid,
name: this.xname,
code: this.xcode
}
this.$store.dispatch("detail/editdetail", prm)
}
},
},
watch: {
xsearch(val, old) {
this.xsearch = val
this.thr_search()
},
selected_nonlabconclusiontestid(val, old) {
this.thr_search_nonlabtest()
},
selected_statuss(val, old) {
this.thr_search_statuss()
}
}
}
</script>