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

147 lines
4.5 KiB
Vue

<template>
<v-layout column pb-2>
<v-card >
<v-layout row>
<v-flex pt-1 pb-1 pl-2 pr-1 xs12 sm6 md6>
<v-autocomplete
label="Perusahaan"
v-model="selected_company"
:items="companies"
:search-input.sync="search"
:readonly="isHavingTest"
auto-select-first
no-filter
return-object
:clearable="! isHavingTest"
item-text="M_CompanyName"
:loading="is_loading"
no-data-text="Pilih Company"
>
<template
slot="item"
slot-scope="{ item }"
>
<v-list-tile-content>
<v-list-tile-title v-text="item.M_CompanyName"></v-list-tile-title>
<v-list-tile-sub-title v-text="getMou(item)"></v-list-tile-sub-title>
</v-list-tile-content>
</template>
</v-autocomplete>
</v-flex>
<v-flex pt-1 pb-1 pl-1 pr-2 xs12 sm6 md6>
<v-select
v-model="selected_mou"
:items="company_mou"
:readonly="isHavingTest"
auto-select-first
item-text = "M_MouName"
return-object
label="Agreement"
>
<template
slot="item"
slot-scope="{ item }"
>
<v-list-tile-content>
<v-list-tile-title v-text="item.M_MouName"></v-list-tile-title>
<v-list-tile-sub-title v-text="getMouDate(item)"></v-list-tile-sub-title>
</v-list-tile-content>
</template>
</v-select>
</v-flex>
</v-layout>
</v-card>
</v-layout>
</template>
<style scoped>
</style>
<script>
module.exports = {
computed: {
search:{
get(){
return this.$store.state.company.search
},
set(val) {
if (val == null) return
this.$store.commit('company/update_search',val)
}
},
isHavingTest() {
return this.$store.state.px.selected_test.length > 0 ||
this.$store.state.px.selected_panel.length > 0
},
selected_mou: {
get() {
return this.$store.state.company.selected_mou
},
set(val) {
this.$store.commit("company/update_selected_mou",val)
}
},
selected_company: {
get() {
return this.$store.state.company.selected_company
},
set(val) {
this.$store.commit("company/update_selected_company",val)
}
},
company_mou() {
if (! this.$store.state.company.selected_company) return []
if (! this.$store.state.company.selected_company.mou) return []
return this.$store.state.company.selected_company.mou
},
companies() {
return this.$store.state.company.companies
},
is_loading() {
return this.$store.state.company.search_status == 1
}
},
methods: {
getMouDate(item) {
return item.M_MouStartDate + ' s/d ' + item.M_MouEndDate
},
getMou(item) {
if (!item) return ''
if (!item.mou) return ''
let s_mou = ''
item.mou.forEach( function(mou,idx) {
if (s_mou!='') s_mou += ', '
s_mou += mou.M_MouName
});
return s_mou
},
thr_search: _.debounce( function () {
this.$store.dispatch("company/search")
}, 700)
},
watch: {
search(val,old) {
if (this.$store.state.order.is_from_clinic)
return
if (val == null || typeof val == 'undefined') val = ""
if (val == old ) return
if (this.$store.state.company.search_status == 1 ) return
this.$store.commit("company/update_search",val)
this.thr_search()
}
},
data: function() {
return {
// search : ''
}
},
mounted () {
// this.$store.dispatch('company/search_default')
}
}
</script>