Initial import
This commit is contained in:
178
one-ui/test_x_old/vuex/one-md-price-ref/api/priceref.js
Normal file
178
one-ui/test_x_old/vuex/one-md-price-ref/api/priceref.js
Normal file
@@ -0,0 +1,178 @@
|
||||
const URL = "/one-api/mockup/masterdata/";
|
||||
|
||||
export async function search_company(token) {
|
||||
try {
|
||||
var resp = await axios.post(URL + 'priceref/search_company', {
|
||||
token:token
|
||||
});
|
||||
if (resp.status != 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: resp.statusText
|
||||
};
|
||||
}
|
||||
let data = resp.data;
|
||||
return data;
|
||||
} catch (e) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export async function search_mou(token, company, query) {
|
||||
try {
|
||||
var resp = await axios.post(URL + 'priceref/search_mou', {
|
||||
token:token,
|
||||
company_id: company,
|
||||
search: query
|
||||
});
|
||||
if (resp.status != 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: resp.statusText
|
||||
};
|
||||
}
|
||||
let data = resp.data;
|
||||
return data;
|
||||
} catch (e) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export async function search_price(token, mou, query) {
|
||||
try {
|
||||
var resp = await axios.post(URL + 'priceref/search_price', {
|
||||
token:token,
|
||||
mou_id: mou,
|
||||
search: query
|
||||
});
|
||||
if (resp.status != 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: resp.statusText
|
||||
};
|
||||
}
|
||||
let data = resp.data;
|
||||
return data;
|
||||
} catch (e) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export async function del_price(token, id) {
|
||||
try {
|
||||
var resp = await axios.post(URL + 'priceref/del_price', {
|
||||
token:token,
|
||||
id: id
|
||||
});
|
||||
if (resp.status != 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: resp.statusText
|
||||
};
|
||||
}
|
||||
let data = resp.data;
|
||||
return data;
|
||||
} catch (e) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export async function search_px(token, query) {
|
||||
try {
|
||||
var resp = await axios.post(URL + 'price/search_px', {
|
||||
token:token,
|
||||
search: query
|
||||
});
|
||||
if (resp.status != 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: resp.statusText
|
||||
};
|
||||
}
|
||||
let data = resp.data;
|
||||
return data;
|
||||
} catch (e) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export async function save_px(token, datax) {
|
||||
try {
|
||||
var resp = await axios.post(URL + 'priceref/save_px', {
|
||||
token:token,
|
||||
data: datax
|
||||
});
|
||||
if (resp.status != 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: resp.statusText
|
||||
};
|
||||
}
|
||||
let data = resp.data;
|
||||
return data;
|
||||
} catch (e) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// export async function search_addon(token, query) {
|
||||
// try {
|
||||
// var resp = await axios.post(URL + 'price/search_addon', {
|
||||
// token:token,
|
||||
// search: query
|
||||
// });
|
||||
// if (resp.status != 200) {
|
||||
// return {
|
||||
// status: "ERR",
|
||||
// message: resp.statusText
|
||||
// };
|
||||
// }
|
||||
// let data = resp.data;
|
||||
// return data;
|
||||
// } catch (e) {
|
||||
// return {
|
||||
// status: "ERR",
|
||||
// message: e.message
|
||||
// };
|
||||
// }
|
||||
// }
|
||||
|
||||
// export async function save_addon(token, name) {
|
||||
// try {
|
||||
// var resp = await axios.post(URL + 'price/save_addon', {
|
||||
// token:token,
|
||||
// name: name
|
||||
// });
|
||||
// if (resp.status != 200) {
|
||||
// return {
|
||||
// status: "ERR",
|
||||
// message: resp.statusText
|
||||
// };
|
||||
// }
|
||||
// let data = resp.data;
|
||||
// return data;
|
||||
// } catch (e) {
|
||||
// return {
|
||||
// status: "ERR",
|
||||
// message: e.message
|
||||
// };
|
||||
// }
|
||||
// }
|
||||
@@ -0,0 +1,77 @@
|
||||
<template>
|
||||
<v-menu
|
||||
v-model="menu2"
|
||||
:close-on-content-click="false"
|
||||
:nudge-right="40"
|
||||
lazy
|
||||
transition="scale-transition"
|
||||
offset-y
|
||||
full-width
|
||||
max-width="290px"
|
||||
min-width="290px"
|
||||
>
|
||||
<v-text-field
|
||||
slot="activator"
|
||||
v-model="computedDateFormatted"
|
||||
:label=init_label
|
||||
hint="MM/DD/YYYY format"
|
||||
persistent-hint
|
||||
readonly
|
||||
browser-autocomplete="off"
|
||||
></v-text-field>
|
||||
<v-date-picker v-model="init_date" no-title @input="menu2 = false" :max="init_max_date"></v-date-picker>
|
||||
</v-menu>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
module.exports = {
|
||||
props : ['label', 'date', 'data', 'max_date'],
|
||||
|
||||
data () {
|
||||
return {
|
||||
init_date: this.date && this.date != "0000-00-00" ? this.date : null, //new Date().toISOString().substr(0, 10),
|
||||
init_max_date: this.max_date ? this.max_date : '2999-09-09',
|
||||
dateFormatted: this.formatDate(new Date().toISOString().substr(0, 10)),
|
||||
menu1: false,
|
||||
menu2: false,
|
||||
|
||||
init_label: this.label ? this.label : 'Date',
|
||||
init_data: this.data ? this.data : ''
|
||||
}
|
||||
},
|
||||
|
||||
computed: {
|
||||
computedDateFormatted () {
|
||||
return this.formatDate(this.init_date)
|
||||
}
|
||||
},
|
||||
|
||||
watch: {
|
||||
init_date (n, o) {
|
||||
this.dateFormatted = this.formatDate(this.init_date)
|
||||
|
||||
this.$emit('change', {"old_date":o, "new_date":n, "data":this.init_data});
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
formatDate (date) {
|
||||
if (!date) { return null }
|
||||
|
||||
const [year, month, day] = date.split('-')
|
||||
return `${day}-${month}-${year}`
|
||||
},
|
||||
parseDate (date) {
|
||||
if (!date) return null
|
||||
|
||||
const [month, day, year] = date.split('/')
|
||||
return `${year}-${month.padStart(2, '0')}-${day.padStart(2, '0')}`
|
||||
},
|
||||
|
||||
emitChange (n, o) {
|
||||
console.log("old:"+o)
|
||||
console.log("new:"+n)
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,188 @@
|
||||
<template>
|
||||
<v-layout class="fill-height" column>
|
||||
|
||||
<v-card class="mb-2 pa-2 searchbox">
|
||||
<v-layout >
|
||||
<v-text-field class="xs6 ma-1"
|
||||
label=""
|
||||
placeholder="Pencarian"
|
||||
single-line
|
||||
outline
|
||||
v-model="query_mou"
|
||||
hide-details
|
||||
></v-text-field>
|
||||
|
||||
<v-select class="xs6 ma-1" :items="companies"
|
||||
item-text="M_CompanyName"
|
||||
item-value="M_CompanyID"
|
||||
return-object
|
||||
v-model="selected_company"
|
||||
label="Company" outline hide-details></v-select>
|
||||
<v-btn class="xs3 ma-1" color="success" @click="search_mou" >Search</v-btn>
|
||||
<!-- <v-btn class="xs3 ma-1" color="info" @click="set" >Baru</v-btn> -->
|
||||
</v-layout>
|
||||
</v-card>
|
||||
<v-card >
|
||||
<v-layout row>
|
||||
<v-flex xs12 pl-2 pr-2 pt-2 pb-2>
|
||||
<v-data-table
|
||||
:headers="headers"
|
||||
:items="mous"
|
||||
:loading="isLoading"
|
||||
:pagination.sync="pagination"
|
||||
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)">{{ props.item.M_MouName }}</td>
|
||||
<td class="text-xs-center pa-2" v-bind:class="{'amber lighten-4':isSelected(props.item)}" @click="selectMe(props.item)">{{ props.item.M_MouStartDate }}</td>
|
||||
<td class="text-xs-center pa-2" v-bind:class="{'amber lighten-4':isSelected(props.item)}" @click="selectMe(props.item)">{{ props.item.M_MouEndDate }}</td>
|
||||
<!-- <td class="text-xs-left pa-2" v-bind:class="{'amber lighten-4':isSelected(props.item)}" @click="selectMe(props.item)">{{ props.item.status}}</td> -->
|
||||
</template>
|
||||
<template>
|
||||
<div class="text-xs-center">
|
||||
<v-pagination
|
||||
|
||||
:length="15"
|
||||
:total-visible="7"
|
||||
></v-pagination>
|
||||
</div>
|
||||
</template>
|
||||
</v-data-table>
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
</v-card>
|
||||
|
||||
</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;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
<script>
|
||||
module.exports = {
|
||||
components : {
|
||||
|
||||
},
|
||||
|
||||
mounted() {
|
||||
this.$store.dispatch("priceref/search_company")
|
||||
},
|
||||
|
||||
methods : {
|
||||
isSelected(p) {
|
||||
return false
|
||||
},
|
||||
|
||||
search_mou() {
|
||||
this.$store.dispatch("priceref/search_mou")
|
||||
},
|
||||
|
||||
selectMe(doc) {
|
||||
this.$store.commit('priceref/update_selected_mou', doc)
|
||||
this.$store.dispatch('priceref/search_price')
|
||||
}
|
||||
},
|
||||
|
||||
computed: {
|
||||
companies : {
|
||||
get () {
|
||||
return this.$store.state.priceref.companies
|
||||
},
|
||||
set (v) {
|
||||
this.$store.commit('priceref/update_companies', v)
|
||||
}
|
||||
},
|
||||
|
||||
mous : {
|
||||
get () {
|
||||
return this.$store.state.priceref.mous
|
||||
},
|
||||
set (v) {
|
||||
this.$store.commit('priceref/update_mous', v)
|
||||
}
|
||||
},
|
||||
|
||||
selected_company : {
|
||||
get () {
|
||||
return this.$store.state.priceref.selected_company
|
||||
},
|
||||
set (v) {
|
||||
this.$store.commit('priceref/update_selected_company', v)
|
||||
}
|
||||
},
|
||||
|
||||
selected_mou : {
|
||||
get () {
|
||||
return this.$store.state.priceref.selected_mou
|
||||
},
|
||||
set (v) {
|
||||
this.$store.commit('priceref/update_selected_mou', v)
|
||||
}
|
||||
},
|
||||
|
||||
query_mou : {
|
||||
get () {
|
||||
return this.$store.state.priceref.query_mou
|
||||
},
|
||||
set (v) {
|
||||
this.$store.commit('priceref/update_query_mou', v)
|
||||
}
|
||||
},
|
||||
|
||||
isLoading () {
|
||||
return false
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
headers: [
|
||||
{
|
||||
text: "NAMA",
|
||||
align: "left",
|
||||
sortable: false,
|
||||
value: "mr",
|
||||
width: "25%",
|
||||
class: "pa-2 blue lighten-3 white--text"
|
||||
},
|
||||
{
|
||||
text: "START DATE",
|
||||
align: "center",
|
||||
sortable: false,
|
||||
value: "lab",
|
||||
width: "10%",
|
||||
class: "pa-2 blue lighten-3 white--text"
|
||||
},
|
||||
{
|
||||
text: "END DATE",
|
||||
align: "center",
|
||||
sortable: false,
|
||||
value: "name",
|
||||
width: "10%",
|
||||
class: "pa-2 blue lighten-3 white--text"
|
||||
}
|
||||
],
|
||||
|
||||
pagination:{
|
||||
descending: false,
|
||||
page: 1,
|
||||
rowsPerPage: 5,
|
||||
sortBy: 'M_MouName',
|
||||
totalItems: this.$store.state.priceref.total_mous
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,261 @@
|
||||
<template>
|
||||
<v-layout row justify-center>
|
||||
<v-dialog v-model="dialog" persistent max-width="600px">
|
||||
|
||||
<v-card>
|
||||
<v-card-title>
|
||||
<span class="headline" v-show="!state_edit">Tambah Data Harga Rujukan</span>
|
||||
<span class="headline" v-show="state_edit">Ubah Data Harga Rujukan</span>
|
||||
</v-card-title>
|
||||
<v-card-text class="pt-0">
|
||||
<v-container grid-list-md pa-0>
|
||||
<v-layout row wrap>
|
||||
<v-flex xs12 pr-3>
|
||||
<v-autocomplete
|
||||
v-show="!state_edit"
|
||||
label="Nama Test"
|
||||
v-model="selected_px"
|
||||
:items="pxs"
|
||||
:search-input.sync="query_px"
|
||||
|
||||
auto-select-first
|
||||
no-filter
|
||||
return-object
|
||||
clearable
|
||||
item-text="T_TestName"
|
||||
:loading="is_loading"
|
||||
no-data-text="Pilih Test"
|
||||
|
||||
ref="ref_px"
|
||||
>
|
||||
<template
|
||||
slot="item"
|
||||
slot-scope="{ item }"
|
||||
>
|
||||
<v-list-tile-content>
|
||||
<v-list-tile-title v-text="item.T_TestName"></v-list-tile-title>
|
||||
<v-list-tile-sub-title v-text="item.T_TestCode"></v-list-tile-sub-title>
|
||||
</v-list-tile-content>
|
||||
</template>
|
||||
|
||||
</v-autocomplete>
|
||||
|
||||
<v-text-field v-show="state_edit" label="Nama Test" readonly v-model="selected_px.T_TestName"></v-text-field>
|
||||
</v-flex>
|
||||
<!-- <v-flex xs6> </v-flex> -->
|
||||
<v-flex xs12 sm12 md12>
|
||||
<v-text-field v-model="new_price_amount" solo label="" hide-details required reverse suffix="Harga"></v-text-field>
|
||||
</v-flex>
|
||||
|
||||
<v-flex xs6 pr-3>
|
||||
<one-date-picker
|
||||
label="Start Date"
|
||||
:date="init_start_date"
|
||||
@change="startDateChange"
|
||||
v-if="refresh_date"
|
||||
></one-date-picker>
|
||||
</v-flex>
|
||||
|
||||
<v-flex xs6 pl-3>
|
||||
<one-date-picker
|
||||
label="End Date"
|
||||
:date="init_end_date"
|
||||
@change="endDateChange"
|
||||
v-if="refresh_date"
|
||||
></one-date-picker>
|
||||
</v-flex>
|
||||
|
||||
<v-flex xs12 sm12 md12 pt-2 pb-2><v-divider></v-divider></v-flex>
|
||||
|
||||
</v-layout>
|
||||
</v-container>
|
||||
<small>*indicates required field</small>
|
||||
</v-card-text>
|
||||
<v-card-actions>
|
||||
<v-spacer></v-spacer>
|
||||
<v-btn color="blue darken-1" flat @click="dialog = false">Tutup</v-btn>
|
||||
<v-btn color="blue darken-1" :dark="btn_save_enabled" @click="save_price" :disabled="!btn_save_enabled">Simpan</v-btn>
|
||||
</v-card-actions>
|
||||
</v-card>
|
||||
</v-dialog>
|
||||
</v-layout>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
|
||||
.v-input__append-outer {
|
||||
margin: 0;
|
||||
}
|
||||
</style>
|
||||
<style>
|
||||
.btn-outer, .btn-outer-2 {
|
||||
margin-top: -6px;
|
||||
/* border-radius: 5% !important; */
|
||||
}
|
||||
.btn-outer-2 {
|
||||
margin-top: -10px;
|
||||
margin-right: -5px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script>
|
||||
module.exports = {
|
||||
components : {
|
||||
'one-date-picker': httpVueLoader('./oneDatePicker.vue')
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
|
||||
// new_price_amount: this.$store.state.price.new_price.amount,
|
||||
// new_price_disc: this.$store.state.price.new_price.disc,
|
||||
// new_price_discrp: this.$store.state.price.new_price.discrp
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
computed : {
|
||||
state_edit () {
|
||||
return this.$store.state.priceref.edit_price
|
||||
},
|
||||
|
||||
dialog : {
|
||||
get () {
|
||||
return this.$store.state.priceref.dialog_px_new
|
||||
},
|
||||
set (v) {
|
||||
this.$store.commit('priceref/update_dialog_px_new', v)
|
||||
}
|
||||
},
|
||||
|
||||
pxs () {
|
||||
return this.$store.state.priceref.pxs
|
||||
},
|
||||
|
||||
selected_px : {
|
||||
get () {
|
||||
return this.$store.state.priceref.selected_px
|
||||
},
|
||||
set (v) {
|
||||
this.$store.commit('priceref/update_selected_px', v)
|
||||
}
|
||||
},
|
||||
|
||||
query_px : {
|
||||
get () {
|
||||
return this.$store.state.priceref.query_px
|
||||
},
|
||||
set (v) {
|
||||
this.$store.commit('priceref/update_query_px', v)
|
||||
}
|
||||
},
|
||||
|
||||
new_price : {
|
||||
get () {
|
||||
return this.$store.state.priceref.new_price
|
||||
},
|
||||
set (v) {
|
||||
|
||||
this.$store.commit('priceref/update_new_price', v)
|
||||
}
|
||||
},
|
||||
|
||||
new_price_amount : {
|
||||
get () {
|
||||
return this.$store.state.priceref.new_price.amount
|
||||
},
|
||||
set (v) {
|
||||
let x = this.$store.state.priceref.new_price
|
||||
x.amount = v
|
||||
this.$store.commit('priceref/update_new_price', x)
|
||||
}
|
||||
},
|
||||
|
||||
is_loading () {
|
||||
return false
|
||||
},
|
||||
|
||||
btn_save_enabled () {
|
||||
if (!this.$store.state.priceref.selected_px.T_TestID)
|
||||
return false
|
||||
|
||||
return true
|
||||
},
|
||||
|
||||
init_start_date () {
|
||||
if (this.$store.state.priceref.edit_price)
|
||||
return this.$store.state.priceref.selected_price.T_PriceRefStartDate
|
||||
else
|
||||
return ''
|
||||
},
|
||||
|
||||
init_end_date () {
|
||||
if (this.$store.state.priceref.edit_price)
|
||||
return this.$store.state.priceref.selected_price.T_PriceRefEndDate
|
||||
else
|
||||
return null
|
||||
},
|
||||
|
||||
refresh_date : {
|
||||
get () {
|
||||
return this.$store.state.priceref.refresh_date
|
||||
},
|
||||
set (v) {
|
||||
this.$store.commit('priceref/update_refresh_date', v)
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
methods : {
|
||||
thr_search: _.debounce( function () {
|
||||
this.$store.dispatch("priceref/search_px")
|
||||
}, 700),
|
||||
|
||||
save_price () {
|
||||
let x = this.state_edit
|
||||
if (x == true)
|
||||
this.$store.dispatch('priceref/save_px', this.$store.state.priceref.selected_price.T_PriceRefID)
|
||||
else
|
||||
this.$store.dispatch('priceref/save_px')
|
||||
},
|
||||
|
||||
startDateChange (prm) {
|
||||
let x = this.$store.state.priceref.new_price
|
||||
x.start_date = prm.new_date
|
||||
this.$store.commit('priceref/update_new_price', x)
|
||||
},
|
||||
|
||||
endDateChange (prm) {
|
||||
let x = this.$store.state.priceref.new_price
|
||||
x.end_date = prm.new_date
|
||||
this.$store.commit('priceref/update_new_price', x)
|
||||
}
|
||||
},
|
||||
|
||||
watch : {
|
||||
query_px(val, old) {
|
||||
|
||||
if (val == null || typeof val == 'undefined') val = ""
|
||||
console.log("1-val:"+val)
|
||||
if (val == old ) return
|
||||
console.log("2-val:"+val)
|
||||
// if (! val) return
|
||||
console.log("3-val:"+val)
|
||||
// if (val.length < 1 ) return
|
||||
console.log("4-val:"+val)
|
||||
if (this.$store.state.priceref.search_status == 1 ) return
|
||||
console.log("5-val:"+val)
|
||||
this.$store.commit("priceref/update_query_px", val)
|
||||
this.thr_search()
|
||||
|
||||
},
|
||||
|
||||
others (v, o) {
|
||||
console.log(v)
|
||||
}
|
||||
},
|
||||
|
||||
mounted () {
|
||||
this.$store.dispatch('priceref/search_addon')
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,249 @@
|
||||
<template>
|
||||
<v-layout class="fill-height" column>
|
||||
|
||||
<v-card class="mb-2 pa-2 searchbox">
|
||||
<v-layout >
|
||||
<!-- <v-text-field class="xs6 ma-1"
|
||||
label=""
|
||||
placeholder="Pencarian"
|
||||
single-line
|
||||
outline
|
||||
v-model="query_mou"
|
||||
hide-details
|
||||
></v-text-field>
|
||||
|
||||
<v-select class="xs6 ma-1" :items="companies"
|
||||
item-text="M_CompanyName"
|
||||
item-value="M_CompanyID"
|
||||
return-object
|
||||
v-model="selected_company"
|
||||
label="Company" outline hide-details></v-select> -->
|
||||
<v-text-field class="xs6 ma-1"
|
||||
label=""
|
||||
placeholder="Pencarian"
|
||||
single-line
|
||||
outline
|
||||
v-model="query_price"
|
||||
hide-details
|
||||
></v-text-field>
|
||||
<v-btn class="xs3 ma-1" color="success" @click="search_price" dark>Cari</v-btn>
|
||||
<v-btn class="xs3 ma-1" color="primary" @click="add" :disabled="!btn_add_enabled" :dark="btn_add_enabled" >Tambah</v-btn>
|
||||
|
||||
|
||||
<!-- <v-btn class="xs3 ma-1" color="info" @click="set" >Baru</v-btn> -->
|
||||
</v-layout>
|
||||
</v-card>
|
||||
<v-card >
|
||||
<v-layout row>
|
||||
<v-flex xs12 pl-2 pr-2 pt-2 pb-2>
|
||||
<v-data-table
|
||||
:headers="headers"
|
||||
:items="prices"
|
||||
:loading="isLoading"
|
||||
:pagination.sync="pagination"
|
||||
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)">{{ props.item.T_TestName }}</td>
|
||||
<td class="text-xs-center pa-2" v-bind:class="{'amber lighten-4':isSelected(props.item)}" @click="selectMe(props.item)">{{ one_money(props.item.T_PriceRefAmount) }}</td>
|
||||
<td class="text-xs-left pa-2" v-bind:class="{'amber lighten-4':isSelected(props.item)}" @click="selectMe(props.item)">
|
||||
<v-btn icon @click="edit_price(props.item)" color="blue" dark class="ma-0"><v-icon>create</v-icon></v-btn>
|
||||
<v-btn icon @click="del_price(props.item)" color="red" dark class="ma-0"><v-icon>clear</v-icon></v-btn>
|
||||
</td>
|
||||
</template>
|
||||
<template>
|
||||
<div class="text-xs-center">
|
||||
<v-pagination
|
||||
|
||||
:length="15"
|
||||
:total-visible="7"
|
||||
></v-pagination>
|
||||
</div>
|
||||
</template>
|
||||
</v-data-table>
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
</v-card>
|
||||
<one-md-price-ref-new-dialog></one-md-price-ref-new-dialog>
|
||||
<one-dialog-confirm :data="selected_price" v-if="refresh_confirm" @confirm="confirm_delete"></one-dialog-confirm>
|
||||
</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;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
<script>
|
||||
module.exports = {
|
||||
components : {
|
||||
'one-md-price-ref-new-dialog': httpVueLoader('./oneMdPriceRefNewDialog.vue'),
|
||||
'one-dialog-confirm': httpVueLoader('../../common/oneDialogConfirm.vue')
|
||||
},
|
||||
|
||||
mounted() {
|
||||
// this.$store.dispatch("priceref/search_company")
|
||||
},
|
||||
|
||||
methods : {
|
||||
one_money (p) {
|
||||
return window.one_money(p)
|
||||
},
|
||||
|
||||
isSelected(p) {
|
||||
return false
|
||||
},
|
||||
|
||||
search_price() {
|
||||
this.$store.dispatch("priceref/search_price")
|
||||
},
|
||||
|
||||
selectMe(doc) {
|
||||
this.$store.commit('priceref/update_selected_price', doc)
|
||||
},
|
||||
|
||||
add() {
|
||||
this.$store.commit('priceref/update_refresh_date', false)
|
||||
|
||||
this.$store.commit('priceref/update_new_price', { amount: 0 })
|
||||
this.$store.commit('priceref/update_selected_px', {})
|
||||
|
||||
this.$store.commit('priceref/update_edit_price', false)
|
||||
this.$store.commit('priceref/update_dialog_px_new', true)
|
||||
|
||||
var x = this
|
||||
setTimeout(function() {
|
||||
x.$store.commit('priceref/update_refresh_date', true)
|
||||
delete x
|
||||
}, 100)
|
||||
},
|
||||
|
||||
edit_price(data) {
|
||||
|
||||
this.$store.commit('priceref/update_refresh_date', false)
|
||||
// this.$store.commit('priceref/update_others', {records:data.others, total:data.others.length})
|
||||
this.$store.commit('priceref/update_new_price', {
|
||||
amount: data.T_PriceRefAmount,
|
||||
start_date: data.T_PriceRefStartDate,
|
||||
end_date: data.T_PriceRefEndDate
|
||||
})
|
||||
this.$store.commit('priceref/update_selected_price', data)
|
||||
this.$store.commit('priceref/update_selected_px', data.px)
|
||||
this.$store.commit('priceref/update_edit_price', true)
|
||||
this.$store.commit('priceref/update_dialog_px_new', true)
|
||||
|
||||
var x = this
|
||||
setTimeout(function() {
|
||||
x.$store.commit('priceref/update_refresh_date', true)
|
||||
delete x
|
||||
}, 100)
|
||||
|
||||
},
|
||||
|
||||
del_price(data) {
|
||||
this.refresh_confirm = false
|
||||
this.$store.commit('update_dialog_confirm', true)
|
||||
var x = this
|
||||
setTimeout(function() {
|
||||
x.refresh_confirm = true
|
||||
}, 100)
|
||||
|
||||
},
|
||||
|
||||
confirm_delete(data) {
|
||||
this.$store.dispatch('priceref/del_price', data.data.T_PriceRefID)
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
prices : {
|
||||
get () {
|
||||
return this.$store.state.priceref.prices
|
||||
},
|
||||
set (v) {
|
||||
this.$store.commit('priceref/update_prices', v)
|
||||
}
|
||||
},
|
||||
|
||||
selected_price : {
|
||||
get () {
|
||||
return this.$store.state.priceref.selected_price
|
||||
},
|
||||
set (v) {
|
||||
this.$store.commit('priceref/update_selected_price', v)
|
||||
}
|
||||
},
|
||||
|
||||
query_price : {
|
||||
get () {
|
||||
return this.$store.state.priceref.query_price
|
||||
},
|
||||
set (v) {
|
||||
this.$store.commit('priceref/update_query_price', v)
|
||||
}
|
||||
},
|
||||
|
||||
isLoading () {
|
||||
return false
|
||||
},
|
||||
|
||||
btn_add_enabled () {
|
||||
if (this.$store.state.priceref.selected_mou.M_MouID)
|
||||
return true
|
||||
|
||||
return false
|
||||
}
|
||||
},
|
||||
|
||||
data() {
|
||||
return {
|
||||
headers: [
|
||||
{
|
||||
text: "NAMA",
|
||||
align: "left",
|
||||
sortable: false,
|
||||
value: "mr",
|
||||
width: "25%",
|
||||
class: "pa-2 blue lighten-3 white--text"
|
||||
},
|
||||
{
|
||||
text: "HARGA",
|
||||
align: "center",
|
||||
sortable: false,
|
||||
value: "lab",
|
||||
width: "10%",
|
||||
class: "pa-2 blue lighten-3 white--text"
|
||||
},
|
||||
{
|
||||
text: "ACTION",
|
||||
align: "center",
|
||||
sortable: false,
|
||||
value: "name",
|
||||
width: "15%",
|
||||
class: "pa-2 blue lighten-3 white--text"
|
||||
}
|
||||
],
|
||||
|
||||
pagination:{
|
||||
descending: false,
|
||||
page: 1,
|
||||
rowsPerPage: 5,
|
||||
sortBy: 'T_TestName',
|
||||
totalItems: this.$store.state.priceref.total_price
|
||||
},
|
||||
|
||||
refresh_confirm : false
|
||||
};
|
||||
}
|
||||
}
|
||||
</script>
|
||||
93
one-ui/test_x_old/vuex/one-md-price-ref/index.php
Normal file
93
one-ui/test_x_old/vuex/one-md-price-ref/index.php
Normal file
@@ -0,0 +1,93 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<title>One</title>
|
||||
<link rel="stylesheet" href="../../../libs/vendor/css/google-fonts.css">
|
||||
<link rel="stylesheet" href="../../../libs/vendor/css/vuetify.min.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div v-cloak id="app">
|
||||
<v-app id="smartApp" >
|
||||
<one-navbar></one-navbar>
|
||||
<v-content style="background:#F5E8DF!important" >
|
||||
<v-container fluid fill-height class="pl-1 pr-1 pt-2 pb-2">
|
||||
<v-layout row wrap >
|
||||
<v-flex xs6 class="left" fill-height pa-1>
|
||||
<one-md-price-ref-mou-list></one-md-price-ref-mou-list>
|
||||
</v-flex>
|
||||
<v-flex xs6 class="right" fill-height pa-1>
|
||||
<one-md-price-ref-px-list></one-md-price-ref-px-list>
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
</v-container>
|
||||
</v-content>
|
||||
<one-footer> </one-footer>
|
||||
</v-app>
|
||||
</div>
|
||||
|
||||
<!-- Vendor -->
|
||||
<script src="../../../libs/vendor/moment.min.js"></script>
|
||||
<script src="../../../libs/vendor/numeral.min.js"></script>
|
||||
<script src="../../../libs/vendor/moment-locale-id.js"></script>
|
||||
<script src="../../../libs/vendor/lodash.js"></script>
|
||||
<script src="../../../libs/vendor/axios.min.js"></script>
|
||||
<script src="../../../libs/vendor/vue.js"></script>
|
||||
<script src="../../../libs/vendor/vuex.js"></script>
|
||||
<script src="../../../libs/vendor/vuetify.js"></script>
|
||||
<script src="../../../libs/vendor/httpVueLoader.js"></script>
|
||||
<script src="../../../libs/one_global.js"></script>
|
||||
<!-- App Script -->
|
||||
<?php
|
||||
$ts = "?ts=" . Date("ymdhis");
|
||||
?>
|
||||
<script type="module">
|
||||
window.calculate_age = function (inp_dob) {
|
||||
var now = moment(new Date())
|
||||
var dob = moment(new Date(inp_dob))
|
||||
var year = now.diff(dob,'years')
|
||||
dob.add(year,'years')
|
||||
var month = now.diff(dob,'months')
|
||||
dob.add(month,'months')
|
||||
var day = now.diff(dob,'days')
|
||||
if (isNaN(year)) return ''
|
||||
return `${year} tahun ${month} bulan ${day} hari`
|
||||
}
|
||||
|
||||
|
||||
import { store } from './store.js<?php echo $ts ?>';
|
||||
//for testing
|
||||
window.store = store;
|
||||
new Vue({
|
||||
store,
|
||||
el: '#app',
|
||||
methods: {
|
||||
tab_selected : function(tab) {
|
||||
return this.$store.state.tab_selected == tab
|
||||
}
|
||||
},
|
||||
components: {
|
||||
'one-navbar': httpVueLoader('../../../apps/components/oneNavbarComponent.vue'),
|
||||
'one-footer': httpVueLoader('../../../apps/components/oneFooter.vue'),
|
||||
'one-md-price-ref-mou-list': httpVueLoader('./components/oneMdPriceRefMouList.vue'),
|
||||
'one-md-price-ref-px-list': httpVueLoader('./components/oneMdPriceRefPxList.vue')
|
||||
|
||||
}
|
||||
})
|
||||
</script>
|
||||
<style>
|
||||
[v-cloak] {
|
||||
display: none
|
||||
}
|
||||
.left {
|
||||
}
|
||||
.right {
|
||||
}
|
||||
</style>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
350
one-ui/test_x_old/vuex/one-md-price-ref/modules/priceref.js
Normal file
350
one-ui/test_x_old/vuex/one-md-price-ref/modules/priceref.js
Normal file
@@ -0,0 +1,350 @@
|
||||
// 1 => LOADING
|
||||
// 2 => DONE
|
||||
// 3 => ERROR
|
||||
import * as api from "../api/priceref.js"
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {
|
||||
|
||||
search_status: 0,
|
||||
search_error_message: '',
|
||||
|
||||
companies: [],
|
||||
selected_company: {},
|
||||
total_company: 0,
|
||||
|
||||
query_mou: '',
|
||||
mous: [],
|
||||
selected_mou: {},
|
||||
total_mou: 0,
|
||||
|
||||
query_price: '',
|
||||
prices: [],
|
||||
selected_price: {},
|
||||
total_price: 0,
|
||||
new_price: {amount:0, start_date:null, end_date:null},
|
||||
edit_price: false,
|
||||
|
||||
query_px: '',
|
||||
pxs: [],
|
||||
selected_px: {},
|
||||
total_px: 0,
|
||||
|
||||
query_addon: '',
|
||||
addons: [],
|
||||
selected_addon: {},
|
||||
total_addon: 0,
|
||||
new_addon_name: '',
|
||||
|
||||
// others: [{id:1, name:'Jasa Dokter', price:10000}, {id:2, name:'Lain - lain', price:5000}],
|
||||
others: [],
|
||||
selected_other: {},
|
||||
total_other: 0,
|
||||
|
||||
dialog_px_new: false,
|
||||
dialog_addon_new: false,
|
||||
|
||||
refresh_date: false
|
||||
},
|
||||
mutations: {
|
||||
|
||||
update_search_error_message(state, patient) {
|
||||
state.search_error_message = patient
|
||||
},
|
||||
|
||||
// MOU
|
||||
update_query_mou(state, q) {
|
||||
state.query_mou = q
|
||||
},
|
||||
|
||||
update_mous(state, d) {
|
||||
state.mous = d.records
|
||||
state.total_mou = d.total
|
||||
},
|
||||
|
||||
update_selected_mou(state, d) {
|
||||
state.selected_mou = d
|
||||
},
|
||||
|
||||
// COMPANY
|
||||
update_companies(state, d) {
|
||||
state.companies = d.records
|
||||
state.total_company = d.total
|
||||
},
|
||||
|
||||
update_selected_company(state, d) {
|
||||
state.selected_company = d
|
||||
},
|
||||
|
||||
// PRICE
|
||||
update_query_price(state, q) {
|
||||
state.query_price = q
|
||||
},
|
||||
|
||||
update_prices(state, d) {
|
||||
state.prices = d.records
|
||||
state.total_price = d.total
|
||||
},
|
||||
|
||||
update_selected_price(state, d) {
|
||||
state.selected_price = d
|
||||
},
|
||||
|
||||
update_new_price(state, d) {
|
||||
state.new_price = d
|
||||
},
|
||||
|
||||
update_edit_price(state, d) {
|
||||
state.edit_price = d
|
||||
},
|
||||
|
||||
// PX
|
||||
update_query_px(state, q) {
|
||||
state.query_px = q
|
||||
},
|
||||
|
||||
update_pxs(state, d) {
|
||||
state.pxs = d.records
|
||||
state.total_px = d.total
|
||||
},
|
||||
|
||||
update_selected_px(state, d) {
|
||||
state.selected_px = d
|
||||
},
|
||||
|
||||
// ADDON
|
||||
update_addons(state, d) {
|
||||
state.addons = d.records
|
||||
state.total_addon = d.total
|
||||
},
|
||||
|
||||
update_selected_addon(state, d) {
|
||||
state.selected_addon = d
|
||||
},
|
||||
|
||||
// OTHER
|
||||
update_others(state, d) {
|
||||
state.others = d.records
|
||||
state.total_other = d.total
|
||||
},
|
||||
|
||||
update_selected_other(state, d) {
|
||||
state.selected_other = d
|
||||
},
|
||||
|
||||
add_other(state) {
|
||||
let x = state.selected_addon
|
||||
let y = state.others
|
||||
y.push({id:x.T_AddonID, name:x.T_AddonName, price:0})
|
||||
|
||||
state.others = y
|
||||
},
|
||||
|
||||
remove_other(state, item) {
|
||||
// console.log('np')
|
||||
// console.log(state.new_price)
|
||||
|
||||
let x = state.others
|
||||
for (let i in x)
|
||||
if (x[i].id == item.id)
|
||||
{
|
||||
x.splice(i, 1)
|
||||
// x[i].disabled = true
|
||||
let y = state.new_price
|
||||
// console.log('y1')
|
||||
// console.log(y)
|
||||
|
||||
|
||||
y.other = Math.round(y.other) - Math.round(item.price)
|
||||
y.total = Math.round(y.sub_total) + Math.round(y.other)
|
||||
|
||||
|
||||
state.new_price = y
|
||||
}
|
||||
|
||||
state.others = x
|
||||
},
|
||||
|
||||
update_other_price(state, d) {
|
||||
let x = state.others
|
||||
x[d.idx].price = d.price
|
||||
|
||||
state.others = x
|
||||
let y = state.new_price
|
||||
y.other = 0
|
||||
for (let i in state.others)
|
||||
y.other = Math.round(y.other) + Math.round(state.others[i].price)
|
||||
|
||||
y.total = Math.round(y.sub_total) + Math.round(y.other)
|
||||
state.new_price = y
|
||||
|
||||
},
|
||||
|
||||
update_search_status(state, val) {
|
||||
state.search_status = val
|
||||
},
|
||||
|
||||
update_errors(state, val) {
|
||||
state.errors = val
|
||||
},
|
||||
|
||||
update_dialog_px_new(state, val) {
|
||||
state.dialog_px_new = val
|
||||
},
|
||||
|
||||
update_dialog_addon_new(state, val) {
|
||||
state.dialog_addon_new = val
|
||||
},
|
||||
|
||||
update_new_addon_name(state, val) {
|
||||
state.new_addon_name = val
|
||||
},
|
||||
|
||||
update_refresh_date(state, val) {
|
||||
state.refresh_date = val
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
async search_company(context) {
|
||||
|
||||
try {
|
||||
let resp = await api.search_company(one_token())
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_search_status", 3)
|
||||
context.commit("update_search_error_message", resp.message)
|
||||
} else {
|
||||
context.commit("update_search_status", 2)
|
||||
context.commit("update_search_error_message", "")
|
||||
let data = {
|
||||
records: resp.data.records,
|
||||
total: resp.data.total
|
||||
}
|
||||
|
||||
context.commit("update_companies", data)
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_search_status", 3)
|
||||
context.commit("update_search_error_message", e.message)
|
||||
}
|
||||
},
|
||||
|
||||
async search_mou(context) {
|
||||
|
||||
try {
|
||||
let resp = await api.search_mou(one_token(), context.state.selected_company.M_CompanyID, context.state.query_mou)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_search_status", 3)
|
||||
context.commit("update_search_error_message", resp.message)
|
||||
} else {
|
||||
context.commit("update_search_status", 2)
|
||||
context.commit("update_search_error_message", "")
|
||||
let data = {
|
||||
records: resp.data.records,
|
||||
total: resp.data.total
|
||||
}
|
||||
|
||||
context.commit("update_mous", data)
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_search_status", 3)
|
||||
context.commit("update_search_error_message", e.message)
|
||||
}
|
||||
},
|
||||
|
||||
async search_price(context) {
|
||||
|
||||
try {
|
||||
let resp = await api.search_price(one_token(), context.state.selected_mou.M_MouID, context.state.query_price)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_search_status", 3)
|
||||
context.commit("update_search_error_message", resp.message)
|
||||
} else {
|
||||
context.commit("update_search_status", 2)
|
||||
context.commit("update_search_error_message", "")
|
||||
let data = {
|
||||
records: resp.data.records,
|
||||
total: resp.data.total
|
||||
}
|
||||
|
||||
context.commit("update_prices", data)
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_search_status", 3)
|
||||
context.commit("update_search_error_message", e.message)
|
||||
}
|
||||
},
|
||||
|
||||
async del_price(context, id) {
|
||||
|
||||
try {
|
||||
let resp = await api.del_price(one_token(), id)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_search_status", 3)
|
||||
context.commit("update_search_error_message", resp.message)
|
||||
} else {
|
||||
context.commit("update_search_status", 2)
|
||||
context.commit("update_search_error_message", "")
|
||||
context.dispatch('search_price')
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_search_status", 3)
|
||||
context.commit("update_search_error_message", e.message)
|
||||
}
|
||||
},
|
||||
|
||||
async search_px(context) {
|
||||
|
||||
try {
|
||||
let resp = await api.search_px(one_token(), context.state.query_px)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_search_status", 3)
|
||||
context.commit("update_search_error_message", resp.message)
|
||||
} else {
|
||||
context.commit("update_search_status", 2)
|
||||
context.commit("update_search_error_message", "")
|
||||
let data = {
|
||||
records: resp.data.records,
|
||||
total: resp.data.total
|
||||
}
|
||||
|
||||
context.commit("update_pxs", data)
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_search_status", 3)
|
||||
context.commit("update_search_error_message", e.message)
|
||||
}
|
||||
},
|
||||
|
||||
async save_px(context, price_id) {
|
||||
|
||||
try {
|
||||
let c = context.state.new_price
|
||||
let data = {
|
||||
test_id: context.state.selected_px.T_TestID,
|
||||
mou_id: context.state.selected_mou.M_MouID,
|
||||
price: c.amount,
|
||||
start_date: c.start_date,
|
||||
end_date: c.end_date
|
||||
}
|
||||
if (price_id) data.id = price_id
|
||||
|
||||
let resp = await api.save_px(one_token(), JSON.stringify(data))
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_search_status", 3)
|
||||
context.commit("update_search_error_message", resp.message)
|
||||
} else {
|
||||
context.commit("update_search_status", 2)
|
||||
context.commit("update_search_error_message", "")
|
||||
|
||||
|
||||
context.dispatch("search_price")
|
||||
context.commit("update_dialog_px_new", false)
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_search_status", 3)
|
||||
context.commit("update_search_error_message", e.message)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
31
one-ui/test_x_old/vuex/one-md-price-ref/store.js
Normal file
31
one-ui/test_x_old/vuex/one-md-price-ref/store.js
Normal file
@@ -0,0 +1,31 @@
|
||||
// State
|
||||
// data ...
|
||||
// Mutations
|
||||
//
|
||||
//
|
||||
// Actions
|
||||
import priceref from "./modules/priceref.js";
|
||||
import system from "../../../apps/modules/system/system.js";
|
||||
export const store = new Vuex.Store({
|
||||
modules: {
|
||||
priceref: priceref,
|
||||
system: system
|
||||
},
|
||||
state: {
|
||||
dialog_confirm: false
|
||||
},
|
||||
mutations: {
|
||||
change_tab(state, ntab) {
|
||||
state.tab_selected = ntab
|
||||
},
|
||||
|
||||
update_dialog_confirm(state, v) {
|
||||
state.dialog_confirm = v
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
change_tab(context, ntab) {
|
||||
context.commit('change_tab', ntab)
|
||||
}
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user