Files
FE_CPONE/test/vuex/qc-control-v3/components/oneMdControlList.vue
2026-04-27 10:13:31 +07:00

877 lines
33 KiB
Vue

<template>
<v-layout>
<template>
<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="closeDeleteAlert()">
Yakin lah
</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
<v-dialog v-model="dialogcontrol" persistent max-width="600px">
<v-card>
<v-card-title>
<span class="headline">FORM CONTROL</span></v-card-title>
<v-card-text class="pt-0 pb-0">
<v-form ref="formcontrol" v-model="valid" lazy-validation>
<v-layout wrap>
<v-flex xs12>
<v-text-field v-model="xname" label="Nama*"></v-text-field>
<p v-if="checkError('requirename')" class="error pl-2 pr-2" style="color:#fff">Nama
harus diisi dong</p>
</v-flex>
<v-flex xs12>
<v-select item-text="Nat_QcLevelName" return-object :items="xlevels"
v-model="xlevel" label="Level Control*"></v-select>
<p v-if="checkError('requirelevel')" class="error pl-2 pr-2" style="color:#fff">
Level Control harus diisi dong</p>
</v-flex>
<v-flex xs12>
<v-text-field v-model="xlotnumber" label="Lot Number*"></v-text-field>
<p v-if="checkError('requirelotnumber')" class="error pl-2 pr-2" style="color:#fff">
Lot Number harus diisi dong</p>
</v-flex>
<v-flex xs12>
<v-menu class="xs3 pr-2" v-model="menufilterdateexp" :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="filterComputedDateFormattedExp"
label="Tanggal Kadaluarsa*" readonly v-on="on"
@blur="date = deFormatedDateExp(filterComputedDateFormattedExp)"></v-text-field>
</template>
<v-date-picker v-model="xexpdate" no-title
@input="menufilterdateexp = false"></v-date-picker>
</v-menu>
<p v-if="checkError('requireexp')" class="error pl-2 pr-2" style="color:#fff">
Tanggal Kadaluarsa harus diisi dong</p>
</v-flex>
<v-flex xs12>
<v-checkbox v-model="isused" label="Digunakan"></v-checkbox>
</v-flex>
<v-flex>
<p v-for="(xerror, idx) in xerrors" class="error pl-2 pr-2" style="color:#fff">
{{ xerror.msg }}</p>
</v-flex>
</v-layout>
</v-card-text>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn color="blue darken-1" flat @click="updateDialogFormControl()">Tutup</v-btn>
<v-btn v-if="xact === 'new'" color="blue darken-1" flat
@click="saveFormControl()">Simpan</v-btn>
<v-btn v-if="xact === 'edit'" color="blue darken-1" flat @click="updateFormControl()">Simpan
Perubahan</v-btn>
</v-card-actions>
</v-form>
</v-card>
</v-dialog>
</template>
<v-flex xs12>
<v-card>
<v-toolbar color="blue lighten-3" dark height="50px">
<v-toolbar-title>CONTROL</v-toolbar-title>
<v-spacer></v-spacer>
<v-btn @click="openFormControl(0)" icon>
<v-icon>library_add</v-icon>
</v-btn>
</v-toolbar>
<v-snackbar v-model="snackbar" :timeout="5000" :multi-line="false" :vertical="false" :top="true">
{{ msgsnackbar }}
<v-btn flat @click="updateAlert_success(false)">
Tutup
</v-btn>
</v-snackbar>
<v-layout row style="background:#bbdefb;padding-top:5px;" justify-left>
<v-list-tile>
<input type="text" v-model="xsearch" @click="selectMe(0)" class="textinput" label="Nama Station"
placeholder="Cari ..." />
</v-list-tile-content>
</v-list-tile>
</v-layout>
<v-divider></v-divider>
<div>
<v-layout row class="scroll-container" style="height:400px;overflow: auto;">
<v-flex xs12 pl-2 pr-2 pt-2 pb-2>
<v-data-table :headers="headers" :items="vcontrols" :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)">
<p v-if="props.item.Nat_QcControlIsUsed === 'N'" style="color:#d90101" class="mb-0 font-weight-bold caption">
{{ props.item.Nat_QcControlName }}</p>
<p v-if="props.item.Nat_QcControlIsUsed === 'Y'" style="color:#009632" class="mb-0 font-weight-bold caption">
{{ props.item.Nat_QcControlName }}</p></td>
<td class="text-xs-left pa-2"
v-bind:class="{ 'amber lighten-4': isSelected(props.item) }"
@click="selectMe(props.item)">{{ props.item.Nat_QcLevelName }}
<p style="color:#800000" class="mb-0 font-weight-bold caption">
{{ props.item.Nat_QcControlLotNumber }} | {{ props.item.expdate }}</p>
</td>
<td class="text-xs-left pa-2"
v-bind:class="{ 'amber lighten-4': isSelected(props.item) }"
@click="selectMe(props.item)">
<v-icon small class="ml-3" color="primary"
@click="editControl(props.item)">edit</v-icon>
<v-icon small class="ml-3" color="error"
@click="deleteControl(props.item)">clear</v-icon>
</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 {
msgalertconfirmation: "Perubahan yang telah dilakukan belum disimpan dong !",
dialogdeletealert: false,
msgalert: "",
valid: false,
xid: 0,
search_instrument: '',
items: [],
xname: '',
xcode: '',
xlotnumber: '',
xnameRules: [
v => !!v || 'Nama harus diisi'
],
instrumentRules: [
v => !!v || 'Instrument harus dipilih'
],
name: '',
isdefault: false,
isused: true,
scode: '',
search_doctor: '',
search_testheader: '',
search_template: '',
page: 1,
menufilterdateexp: false,
headers: [{
text: "NAMA",
align: "left",
sortable: false,
value: "mr",
width: "20%",
class: "pa-2 blue lighten-3 white--text"
},
{
text: "DETAIL",
align: "left",
sortable: false,
value: "mr",
width: "20%",
class: "pa-2 blue lighten-3 white--text"
},
{
text: "AKSI",
align: "left",
sortable: false,
value: "mr",
width: "20%",
class: "pa-2 blue lighten-3 white--text"
}
],
pagination: {
descending: true,
page: 1,
rowsPerPage: 100,
sortBy: 'id DESC',
totalItems: this.$store.state.control.total_filter_controls
}
};
},
mounted() {
this.$store.dispatch("control/selectlevel")
this.$store.dispatch("qc/selectaddressdoctor", {
id: 0
})
this.$store.dispatch("control/lookupbyname", {
control: this.xsearch,
instrument: this.$store.state.instrument.x_search,
qc: this.$store.state.qc.x_search,
current_page: 1,
lastid: -1
})
this.$store.dispatch("instrument/lookupbyname", {
control: this.xsearch,
instrument: this.$store.state.instrument.x_search,
qc: this.$store.state.qc.x_search,
current_page: 1,
lastid: -1
})
this.$store.dispatch("qc/lookupbyname", {
control: this.xsearch,
instrument: this.$store.state.instrument.x_search,
qc: this.$store.state.qc.x_search,
current_page: 1,
lastid: -1
})
},
computed: {
xact() {
return this.$store.state.control.act
},
xerrors() {
return this.$store.state.control.errors
},
xshowall() {
return this.$store.state.control.show_all
},
vcontrols() {
return this.$store.state.control.controls
},
xtotalcontrols() {
return this.$store.state.control.total_controls
},
xtotalfiltercontrols() {
return this.$store.state.control.total_filter_controls
},
xlevels() {
return this.$store.state.control.levels
},
xlevel: {
get() {
return this.$store.state.control.level
},
set(val) {
this.$store.commit("control/update_level", val)
}
},
filterComputedDateFormattedExp() {
return this.formatDateExp(this.xexpdate)
},
xexpdate: {
get() {
return this.$store.state.control.xexpdate
},
set(val) {
this.$store.commit("control/update_xexpdate", val)
console.log(val)
}
},
xsearch: {
get() {
return this.$store.state.control.x_search
},
set(val) {
this.$store.commit("control/update_x_search", val)
}
},
curr_page: {
get() {
return this.$store.state.control.current_page
},
set(val) {
this.$store.commit("control/update_current_page", val)
this.$store.dispatch("control/lookupbyname", {
control: this.xsearch,
qc: this.$store.state.qc.x_search,
current_page: val,
lastid: -1
})
}
},
xtotal_page: {
get() {
return this.$store.state.control.total_controls
},
set(val) {
this.$store.commit("control/update_total_controls", val)
}
},
dialogcontrol() {
return this.$store.state.control.dialog_form_control
},
snackbar: {
get() {
return this.$store.state.control.alert_success
},
set(val) {
this.$store.commit("control/update_alert_success", val)
}
},
msgsnackbar() {
return this.$store.state.control.msg_success
},
lookupstatus() {
return this.$store.state.control.lookup_control
},
xcontroltypes() {
return this.$store.state.control.controltypes
},
xcontroltype: {
get() {
return this.$store.state.control.controltype
},
set(val) {
this.$store.commit("control/update_controltype", val)
}
},
isLoading() {
return this.$store.state.control.search_status == 1
},
xnonlabs() {
return this.$store.state.control.nonlabs
},
xnonlab: {
get() {
return this.$store.state.control.selected_nonlab
},
set(val) {
this.$store.commit("control/update_selected_nonlab", val)
}
},
xcities() {
return this.$store.state.control.cities
},
qcaddress: {
get() {
return this.$store.state.control.qc_address
},
set(val) {
this.$store.commit("control/update_qc_address", val)
this.$store.dispatch("control/getdistrict", this.$store.state.control.qc_address)
}
},
xdoctors() {
return this.$store.state.control.doctors
},
doctor: {
get() {
return this.$store.state.control.doctor
},
set(val) {
this.$store.commit("control/update_doctor", val)
}
},
xinstruments() {
return this.$store.state.control.instruments
},
xinstrument: {
get() {
return this.$store.state.control.instrument
},
set(val) {
this.$store.commit("control/update_instrument", val)
}
},
xautotemplates() {
return this.$store.state.control.autotemplates
},
xautotemplate: {
get() {
return this.$store.state.control.autotemplate
},
set(val) {
this.$store.commit("control/update_autotemplate", val)
}
},
xdistricts() {
return this.$store.state.control.districts
},
districtaddress: {
get() {
return this.$store.state.control.district_address
},
set(val) {
this.$store.commit("control/update_district_address", val)
this.$store.dispatch("control/getkelurahan", this.$store.state.control.district_address)
}
},
xkelurahans() {
return this.$store.state.control.kelurahans
},
kelurahanaddress: {
get() {
return this.$store.state.control.kelurahan_address
},
set(val) {
this.$store.commit("control/update_kelurahan_address", val)
}
}
},
methods: {
updateShowAll(val) {
this.$store.commit("control/update_show_all", val)
this.$store.dispatch("control/lookupbyname", {
control: this.xsearch,
qc: this.$store.state.qc.x_search,
current_page: this.curr_page,
lastid: -1
})
},
searchControl() {
this.$store.dispatch("control/lookup", {
search: this.xsearch,
current_page: 1,
lastid: -1
})
},
deFormatedDateExp(date) {
if (!date) return null
const [day, month, year] = date.split('-')
return `${year}-${month.padStart(2, '0')}-${day.padStart(2, '0')}`
},
formatDateExp(date) {
console.log(date)
if (!date) return null
const [year, month, day] = date.split('-')
return `${day}-${month}-${year}`
},
isSelected(p) {
return p.id == this.$store.state.control.selected_control.id
},
subname(name) {
var xname = name
if (xname.length > 18) {
xname = xname.substring(0, 18) + '...'
}
return xname
},
checkError(value) {
var errors = this.$store.state.control.errors
if (errors.includes(value)) {
return true
} else {
return false
}
},
selectMe(sc) {
if (this.$store.state.qc.no_save == 1) {
this.$store.commit("qc/update_open_alert_confirmation", true)
} else if (this.$store.state.instrument.no_save == 1) {
this.$store.commit("instrument/update_open_alert_confirmation", true)
} else {
if (sc == '0') {
this.$store.commit("control/update_selected_control", {
name: "Belum Pilih Control"
})
this.$store.commit("instrument/update_selected_instrument", {
name: "Belum Pilih Instrument"
})
this.$store.commit("instrument/update_x_search", '')
this.$store.commit("qc/update_x_search", '')
this.$store.commit("qc/update_selected_qc", {
name: ""
})
this.$store.dispatch("control/lookupbyname", {
control: this.xsearch,
instrument: this.$store.state.instrument.x_search,
qc: this.$store.state.qc.x_search,
current_page: 1,
lastid: -1
})
this.$store.dispatch("qc/lookupbyname", {
control: this.xsearch,
qc: this.$store.state.qc.x_search,
instrument: this.$store.state.instrument.x_search,
current_page: 1,
lastid: -1
})
this.$store.dispatch("instrument/lookupbyname", {
control: this.xsearch,
qc: this.$store.state.qc.x_search,
instrument: this.$store.state.instrument.x_search,
current_page: 1,
lastid: -1
})
} else {
console.log('control')
console.log(sc.name)
this.$store.commit("instrument/update_x_search", '')
this.$store.commit("qc/update_x_search", '')
this.$store.commit("control/update_selected_control", sc)
this.$store.dispatch("instrument/lookupbyid", {
id: this.$store.state.control.selected_control.id,
instrument: this.$store.state.instrument.x_search,
current_page: 1,
lastid: -1
})
if (this.$store.state.control.selected_control.name !== 'Belum Pilih Control' && this.$store.state.instrument.selected_instrument.name === 'Belum Pilih Instrument') {
this.$store.dispatch("qc/lookupbyidname", {
control: this.$store.state.control.selected_control.id,
instrument: this.$store.state.instrument.x_search,
qc: this.$store.state.qc.x_search,
current_page: 1,
lastid: -1
})
} else if (this.$store.state.control.selected_control.name === 'Belum Pilih Control' && this.$store.state.instrument.selected_instrument.name === 'Belum Pilih Instrument') {
this.$store.dispatch("qc/lookupbyid", {
instrumentid: 0,
controlid: this.$store.state.control.selected_control.id,
px: this.$store.state.qc.x_search,
current_page: 1,
lastid: -1
})
}
this.$store.commit("instrument/update_autocontrols", [{
Nat_QcControlID: this.$store.state.control.selected_control.id,
Nat_QcControlName: this.$store.state.control.selected_control.name
}])
this.$store.commit("instrument/update_autocontrol", {
Nat_QcControlID: this.$store.state.control.selected_control.id,
Nat_QcControlName: this.$store.state.control.selected_control.name
})
this.$store.commit("instrument/update_selected_instrument", {
name: "Belum Pilih Instrument"
})
this.$store.commit("qc/update_selected_qc", {
name: ""
})
}
}
},
updateDialogFormControl() {
this.$store.commit("control/update_dialog_form_control", false)
},
openFormControl() {
this.xlotnumber = ""
this.xname = ""
this.isused = true
this.xexpdate = moment(new Date()).format('YYYY-MM-DD')
this.$store.commit("control/update_level", {})
this.$refs.formcontrol.reset()
this.$refs.formcontrol.resetValidation()
this.$store.commit("control/update_act", 'new')
this.$store.commit("control/update_dialog_form_control", true)
},
thr_search_instrument: _.debounce(function () {
this.$store.dispatch("control/searchinstrument", {
tes: this.search_instrument
})
}, 2000),
saveFormControl() {
this.$store.commit("control/update_errors", [])
var errors = this.$store.state.control.errors
if (_.isEmpty(this.xname)) {
errors.push("requirename")
}
if (_.isEmpty(this.xlotnumber)) {
errors.push("requirelotnumber")
}
if (_.isEmpty(this.xlevel)) {
errors.push("requirelevel")
}
if (this.xexpdate === '') {
errors.push("requireexp")
}
if (errors.length === 0) {
this.$store.dispatch("control/save", {
name: this.xname,
isused: this.isused === true ? "Y" : "N",
level: this.xlevel.Nat_QcLevelID,
lotnumber: this.xlotnumber,
exp: this.xexpdate,
scontrol: this.xsearch,
sinstrument: this.$store.state.instrument.x_search,
sqc: this.$store.state.qc.x_search
})
}
},
updateFormControl() {
this.$store.commit("control/update_errors", [])
var errors = this.$store.state.control.errors
if (_.isEmpty(this.xname)) {
errors.push("requirename")
}
if (_.isEmpty(this.xlotnumber)) {
errors.push("requirelotnumber")
}
if (_.isEmpty(this.xlevel)) {
errors.push("requirelevel")
}
if (this.xexpdate === '') {
errors.push("requireexp")
}
if (errors.length === 0) {
this.$store.dispatch("control/update", {
id: this.xid,
name: this.xname,
isused: this.isused === true ? "Y" : "N",
level: this.xlevel.Nat_QcLevelID,
lotnumber: this.xlotnumber,
exp: this.xexpdate,
scontrol: this.xsearch,
sinstrument: this.$store.state.instrument.x_search,
sqc: this.$store.state.qc.x_search
})
}
},
updateAlert_success(val) {
this.$store.commit("control/update_alert_success", val)
},
editControl(data) {
this.xid = data.id
this.xname = data.name
this.xlotnumber = data.Nat_QcControlLotNumber
this.xexpdate = data.Nat_QcControlExpired
this.isused = data.Nat_QcControlIsUsed === 'N' ? false : true
this.$store.commit("control/update_level", {
Nat_QcLevelID: data.Nat_QcLevelID,
Nat_QcLevelName: data.Nat_QcLevelName
})
this.$store.commit("control/update_act", 'edit')
this.$store.commit("control/update_dialog_form_control", true)
},
deleteControl(data) {
this.xid = data.id
var xdata = {
id: data.id,
name: data.name,
qcs: 'xxx'
}
this.$store.commit("control/update_selected_control", xdata)
this.msgalert = "Yakin, mau hapus control " + data.name + " ?"
this.dialogdeletealert = true
},
changeNewControlType(value) {
this.readonlytypecontrol = value === true ? true : false
this.readonlytypecontrolnew = value === true ? false : true
},
newControlType() {
readonlytypecontrol: true
readonlytypecontrolnew: false
},
closeDeleteAlert() {
this.$store.dispatch("control/delete", {
controlid: this.$store.state.control.selected_control.id,
xname: this.$store.state.control.selected_control.name,
scontrol: this.xsearch,
sinstrument: this.$store.state.instrument.x_search,
sqc: this.$store.state.qc.x_search
})
this.dialogdeletealert = false
},
thr_search: _.debounce(function () {
this.$store.commit("instrument/update_selected_instrument", {
name: "Belum Pilih Instrument"
})
this.$store.commit("control/update_selected_control", {
name: "Belum Pilih Control"
})
this.$store.commit("instrument/update_x_search", '')
this.$store.commit("qc/update_x_search", '')
this.$store.dispatch("control/lookupbyname", {
control: this.xsearch,
qc: this.$store.state.qc.x_search,
instrument: this.$store.state.instrument.x_search,
current_page: 1,
lastid: -1
})
this.$store.dispatch("qc/lookupbyname", {
control: this.xsearch,
qc: this.$store.state.qc.x_search,
instrument: this.$store.state.instrument.x_search,
current_page: 1,
lastid: -1
})
this.$store.dispatch("instrument/lookupbyname", {
control: this.xsearch,
qc: this.$store.state.qc.x_search,
instrument: this.$store.state.instrument.x_search,
current_page: 1,
lastid: -1
})
}, 1000)
},
watch: {
xsearch(val, old) {
console.log(val)
this.xsearch = val
this.thr_search()
},
search_instrument(val, old) {
if (val == old) return
if (!val) return
if (val.length < 1) return
if (this.$store.state.control.update_autocomplete_status == 1) return
this.thr_search_instrument()
}
}
}
</script>