Files
FE_CPONE/test/vuex/one-mcu-fo-registration/components/oneMouPxPx.vue
2026-04-27 10:13:31 +07:00

123 lines
3.8 KiB
Vue

<template>
<v-card-text>
<v-layout column>
<v-layout row>
<v-flex xs6 class="pa-0 ma-0" >
<v-text-field
label="Pemeriksaan"
placeholder="ketikkan pemeriksaan ..."
@change="search"
class="ma-0"
outline
>
</v-text-field>
</v-flex>
<v-flex xs6 class="pa-3">
<v-label >
Test Found {{test_count}}, display {{ test_count < 20 ? test_count : 20 }}
</v-label>
</v-flex>
</v-layout>
<v-progress-linear class="ma-0 pa-0" indeterminate :active="is_loading" ></>
</v-layout>
<v-container grid-list-xs text-xs-center pa-0>
<v-layout row wrap>
<v-btn xs3 v-for="test in tests" :key="test.T_TestPriceID"
:disabled="is_selectPx"
@click="selectPx(test)"
depressed small color="error">
{{test.T_TestName}}
</v-btn>
</v-layout>
</v-container>
</v-card-text>
</template>
<script>
let in_selectPx = false
module.exports = {
methods: {
search(val) {
if ( val == this.prev_search ) return
console.log('Searching',val)
this.prev_search = val
this.$store.commit("px/update_search",val)
this.$store.dispatch("px/search")
},
selectPx(px) {
try {
if (in_selectPx) return
in_selectPx = true
let selected_test = this.$store.state.px.selected_test
let flag_found = false
selected_test.forEach( function(t,idx) {
if (t.T_TestID == px.T_TestID) {
selected_test[idx] = px
flag_found = true
}
})
if (!flag_found) {
selected_test.push(px)
let tests = this.$store.state.px.tests
let p_idx = -1
tests.forEach(function(t,idx) {
if (t.T_TestID == px.T_TestID) {
p_idx = idx
}
})
if (p_idx >= 0 ) {
_.pullAt(tests,[p_idx])
let dt = {
records: tests,
total: tests.length
}
this.$store.commit('px/update_tests',dt)
}
}
this.$store.commit('px/update_selected_test',selected_test)
if (px.T_TestRequirement != '' ) {
let reqs = this.$store.state.px.requirement
let rst = _.find(reqs, function(r) { return r.label == px.T_TestRequirement; })
if ( rst == undefined ) {
reqs.push({
px_id: px.T_TestID,
label: px.T_TestRequirement,
error_message: 'Hasil harus di isi',
is_error: true,
checked : false,
note: ''
})
}
this.$store.commit('px/update_requirement',reqs)
// Update Janji Hasil
this.$store.dispatch('px/appx_schedule')
}
in_selectPx = false
} catch(e) {
console.log(e)
in_selectPx = false
}
}
},
computed: {
test_count() {
return this.$store.state.px.total_test
},
tests() {
return this.$store.state.px.tests
},
is_selectPx() {
return in_selectPx
},
is_loading() {
return this.$store.state.px.search_status == 1
}
},
data: function(){
return {
prev_search : ''
}
}
}
</script>