add modules folder based on s_menu
This commit is contained in:
77
test/vuex/acc-one-md-approve-level/api/approve.js
Normal file
77
test/vuex/acc-one-md-approve-level/api/approve.js
Normal file
@@ -0,0 +1,77 @@
|
||||
const URL = "/one-api/mockup/masterdata/accounting/";
|
||||
|
||||
export async function search(prm) {
|
||||
try {
|
||||
var resp = await axios.post(URL + 'approvelevel/search', prm);
|
||||
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(prm) {
|
||||
try {
|
||||
var resp = await axios.post(URL + 'approvelevel/save', prm);
|
||||
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 update(prm) {
|
||||
try {
|
||||
var resp = await axios.post(URL + 'approvelevel/update', prm);
|
||||
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 deleteDep(prm) {
|
||||
try {
|
||||
var resp = await axios.post(URL + 'approvelevel/delete', prm);
|
||||
if (resp.status != 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: resp.statusText
|
||||
};
|
||||
}
|
||||
let data = resp.data;
|
||||
return data;
|
||||
} catch (e) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message
|
||||
};
|
||||
}
|
||||
}
|
||||
20
test/vuex/acc-one-md-approve-level/api/approveuser.js
Normal file
20
test/vuex/acc-one-md-approve-level/api/approveuser.js
Normal file
@@ -0,0 +1,20 @@
|
||||
const URL = "/one-api/mockup/masterdata/accounting/";
|
||||
|
||||
export async function getUser(prm) {
|
||||
try {
|
||||
var resp = await axios.post(URL + 'approvelevel/getUser', prm);
|
||||
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,592 @@
|
||||
<template>
|
||||
<div style="width: 100%;">
|
||||
<!-- SNACKBAR -->
|
||||
<v-snackbar
|
||||
v-model="snackbar"
|
||||
:timeout="5000"
|
||||
:multi-line="false"
|
||||
:vertical="false"
|
||||
:top="true"
|
||||
>
|
||||
{{ msgSnackbar }}
|
||||
<v-btn flat @click="updateAlertSuccess(false)"> Tutup </v-btn>
|
||||
</v-snackbar>
|
||||
|
||||
<!-- 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"
|
||||
>Tutup</v-btn
|
||||
>
|
||||
</v-card-actions>
|
||||
</v-card>
|
||||
</v-dialog>
|
||||
<!-- END ERROR DIALOG -->
|
||||
<v-layout row wrap>
|
||||
<v-flex xs12 fill-height>
|
||||
<v-toolbar color="primary" dark>
|
||||
<v-toolbar-title class="white--text"
|
||||
>APPROVE LEVEL</v-toolbar-title
|
||||
>
|
||||
<v-spacer></v-spacer>
|
||||
<v-btn icon @click="openDialogApproveLevel()">
|
||||
<v-icon>add_box</v-icon>
|
||||
</v-btn>
|
||||
</v-toolbar>
|
||||
<v-card class="pa-2">
|
||||
<v-layout>
|
||||
<v-flex xs3 pl-2>
|
||||
<v-text-field
|
||||
label="Cari..."
|
||||
placeholder="Nama"
|
||||
outline
|
||||
v-model="xsearch"
|
||||
hide-details
|
||||
></v-text-field>
|
||||
</v-flex>
|
||||
<v-flex pl-2 pr-2>
|
||||
<v-btn
|
||||
dark
|
||||
color="primary"
|
||||
style="min-width: 50px; height: 50px; margin: 0"
|
||||
@click="mainTableSearch()"
|
||||
>
|
||||
<v-icon>search</v-icon>
|
||||
</v-btn>
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
</v-card>
|
||||
<v-card class="pa-2 mt-2">
|
||||
<v-layout row style="max-height: 600px; overflow: auto">
|
||||
<v-flex xs12 pl-2 pr-2 pt-2 pb-2>
|
||||
<v-data-table
|
||||
:items="approvelevels"
|
||||
:headers="headers"
|
||||
:loading="isLoading"
|
||||
hide-actions
|
||||
class="elevation-1"
|
||||
>
|
||||
<template slot="items" slot-scope="props">
|
||||
<td
|
||||
class="text-xs-center pa-2"
|
||||
v-bind:class="{ 'amber lighten-4': isSelected(props.item) }"
|
||||
@click="selectMe(props.item)"
|
||||
>{{ props.item.rownumber }}</td>
|
||||
<td
|
||||
class="text-xs-left pa-2"
|
||||
v-bind:class="{ 'amber lighten-4': isSelected(props.item) }"
|
||||
@click="selectMe(props.item)"
|
||||
>{{ props.item.M_ApproveLevelName }}</td>
|
||||
<td
|
||||
class="text-xs-left pa-2"
|
||||
v-bind:class="{ 'amber lighten-4': isSelected(props.item) }"
|
||||
@click="selectMe(props.item)"
|
||||
>
|
||||
Rp
|
||||
{{
|
||||
oneMoney(props.item.M_ApproveLevelStartTotal)
|
||||
}}
|
||||
</td>
|
||||
<td
|
||||
class="text-xs-left pa-2"
|
||||
v-bind:class="{ 'amber lighten-4': isSelected(props.item) }"
|
||||
@click="selectMe(props.item)"
|
||||
>
|
||||
Rp
|
||||
{{
|
||||
oneMoney(props.item.M_ApproveLevelEndTotal)
|
||||
}}
|
||||
</td>
|
||||
|
||||
<td class="text-xs-center pa-2"
|
||||
v-bind:class="{ 'amber lighten-4': isSelected(props.item) }"
|
||||
@click="selectMe(props.item)"
|
||||
>
|
||||
<v-icon small @click="openUpdateApproveLevel(props.item)"
|
||||
>edit</v-icon
|
||||
>
|
||||
<v-icon small @click="deleteSupplier(props.item)"
|
||||
>delete</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>
|
||||
</v-card>
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
|
||||
<!-- form -->
|
||||
<template>
|
||||
<v-layout row justify-center>
|
||||
<v-dialog v-model="dialogForm" persistent max-width="40vw">
|
||||
<v-card>
|
||||
<v-card-title class="headline grey lighten-2" primary-title>
|
||||
FORM APPROVE LEVEL
|
||||
</v-card-title>
|
||||
<v-card-text class="pt-2 pb-0">
|
||||
<v-layout wrap>
|
||||
<v-flex xs12 pa-2>
|
||||
<v-text-field
|
||||
label="Nama*"
|
||||
v-model="xname"
|
||||
hide-details
|
||||
></v-text-field>
|
||||
<p v-if="checkErrorForm('requireName')" class="error pl-2 pr-2" style="color:#fff">Nama harus diisi</p>
|
||||
</v-flex>
|
||||
<v-flex xs12 pa-2>
|
||||
<v-text-field
|
||||
prefix="Rp"
|
||||
v-model="formattedStartTotal"
|
||||
@focus="clearStartDate"
|
||||
@blur="resetStartDate"
|
||||
label="Start Total">
|
||||
</v-text-field>
|
||||
</v-flex>
|
||||
<v-flex xs12 pa-2>
|
||||
<v-text-field
|
||||
prefix="Rp"
|
||||
v-model="formattedEndTotal"
|
||||
@focus="clearEndDate"
|
||||
@blur="resetEndDate"
|
||||
label="Start Total">
|
||||
</v-text-field>
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
</v-card-text>
|
||||
<v-card-actions>
|
||||
<v-spacer></v-spacer>
|
||||
<v-btn color="error" flat @click="closeDialogForm()">
|
||||
Tutup
|
||||
</v-btn>
|
||||
<v-btn v-if="xact === 'new'" color="primary" @click="saveForm()">Simpan</v-btn>
|
||||
<v-btn v-if="xact === 'edit'" color="primary" @click="updateForm()">Simpan Perubahan</v-btn>
|
||||
</v-card-actions>
|
||||
</v-card>
|
||||
</v-dialog>
|
||||
</v-layout>
|
||||
</template>
|
||||
<!-- end form -->
|
||||
|
||||
<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>
|
||||
Yakin, mau hapus Item : <span class="font-weight-bold">{{ msgalertname }}</span> ?
|
||||
</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="error" flat @click="dialogdeletealert = false">
|
||||
Tutup
|
||||
</v-btn>
|
||||
<v-btn color="primary" @click="closeDeleteAlert()">
|
||||
Yakin lah
|
||||
</v-btn>
|
||||
</v-card-actions>
|
||||
</v-card>
|
||||
</v-dialog>
|
||||
</template>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.date-type-table {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.table.v-table tbody td,
|
||||
table.v-table tbody th {
|
||||
height: 40px;
|
||||
}
|
||||
|
||||
.table.v-table thead tr {
|
||||
height: 40px;
|
||||
}
|
||||
|
||||
.scroll-container {
|
||||
scroll-padding: 50px 0 0 50px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script>
|
||||
module.exports = {
|
||||
components: {
|
||||
"dialog-form-voucher": httpVueLoader("./dialogFormVoucher.vue"),
|
||||
"one-dialog-alert": httpVueLoader("../../common/oneDialogAlert.vue"),
|
||||
"one-dialog-error": httpVueLoader("../../common/oneDialogError.vue")
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
xname: "",
|
||||
xstartTotal: 0,
|
||||
xendTotal: 0,
|
||||
xid: 0,
|
||||
dialogdeletealert: false,
|
||||
msgalertname: "",
|
||||
codeDepartment: "",
|
||||
headers: [
|
||||
{
|
||||
text: "NO",
|
||||
align: "left",
|
||||
sortable: false,
|
||||
value: "no",
|
||||
width: "10%",
|
||||
class: "blue lighten-3 white--text",
|
||||
},
|
||||
{
|
||||
text: "NAMA",
|
||||
align: "left",
|
||||
sortable: false,
|
||||
value: "date",
|
||||
width: "30%",
|
||||
class: "blue lighten-3 white--text",
|
||||
},
|
||||
{
|
||||
text: "START TOTAL",
|
||||
align: "left",
|
||||
sortable: false,
|
||||
value: "total",
|
||||
width: "25%",
|
||||
class: "blue lighten-3 white--text",
|
||||
},
|
||||
{
|
||||
text: "END TOTAL",
|
||||
align: "left",
|
||||
sortable: false,
|
||||
value: "total",
|
||||
width: "25%",
|
||||
class: "blue lighten-3 white--text",
|
||||
},
|
||||
{
|
||||
text: "AKSI",
|
||||
align: "left",
|
||||
sortable: false,
|
||||
value: "status",
|
||||
width: "10%",
|
||||
class: "blue lighten-3 white--text",
|
||||
},
|
||||
],
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.$store.dispatch("approve/search")
|
||||
},
|
||||
computed: {
|
||||
formattedStartTotal: {
|
||||
get() {
|
||||
return this.oneMoney(this.xstartTotal);
|
||||
},
|
||||
set(value) {
|
||||
// Hilangkan titik dan koma, ubah jadi number
|
||||
let raw = value.replace(/\./g, '').replace(',', '.');
|
||||
this.xstartTotal = parseFloat(raw) || 0;
|
||||
}
|
||||
},
|
||||
formattedEndTotal: {
|
||||
get() {
|
||||
return this.oneMoney(this.xendTotal);
|
||||
},
|
||||
set(value) {
|
||||
// Hilangkan titik dan koma, ubah jadi number
|
||||
let raw = value.replace(/\./g, '').replace(',', '.');
|
||||
this.xendTotal = parseFloat(raw) || 0;
|
||||
}
|
||||
},
|
||||
approvelevels() {
|
||||
return this.$store.state.approve.approvelevels
|
||||
},
|
||||
isLoading() {
|
||||
return this.$store.state.approve.search_status == 1
|
||||
},
|
||||
xsearch: {
|
||||
get() {
|
||||
return this.$store.state.approve.xsearch
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("approve/update_xsearch", val)
|
||||
}
|
||||
},
|
||||
curr_page: {
|
||||
get() {
|
||||
return this.$store.state.approve.current_page
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("approve/update_current_page", val)
|
||||
this.$store.commit("approve/update_last_id", -1)
|
||||
this.$store.dispatch("approve/search")
|
||||
}
|
||||
},
|
||||
xtotal_page: {
|
||||
get() {
|
||||
return this.$store.state.approve.total_page
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("approve/update_total_page", val)
|
||||
}
|
||||
},
|
||||
dialogForm: {
|
||||
get() {
|
||||
return this.$store.state.approve.dialog_form
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("approve/update_dialog_form", val)
|
||||
}
|
||||
},
|
||||
xact: {
|
||||
get() {
|
||||
return this.$store.state.approve.act
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("approve/update_act", val)
|
||||
}
|
||||
},
|
||||
snackbar: {
|
||||
get() {
|
||||
return this.$store.state.approve.alert_success
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("approve/update_alert_success", val)
|
||||
}
|
||||
},
|
||||
msgSnackbar() {
|
||||
return this.$store.state.approve.msg_success;
|
||||
},
|
||||
dialog_error: {
|
||||
get() {
|
||||
return this.$store.state.approve.alert_error
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("approve/update_alert_error", val)
|
||||
},
|
||||
},
|
||||
msgError() {
|
||||
return this.$store.state.approve.save_error_message
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
roundToThreeSignificantDigits(num) {
|
||||
if (num === 0) return 0;
|
||||
|
||||
// Hitung jumlah digit
|
||||
const absNum = Math.abs(num);
|
||||
const magnitude = Math.floor(Math.log10(absNum)) + 1;
|
||||
|
||||
// Jika kurang dari 3 digit, tidak perlu dibulatkan
|
||||
if (magnitude <= 3) return num;
|
||||
|
||||
// Hitung faktor pembulatan
|
||||
const factor = Math.pow(10, magnitude - 3);
|
||||
|
||||
// Bulatkan
|
||||
return Math.round(num / factor) * factor;
|
||||
},
|
||||
oneMoney(value){
|
||||
//return one_money(value);
|
||||
let splitValue = value.toString().split(".");
|
||||
if(splitValue.length > 1) {
|
||||
let val = splitValue[0]
|
||||
return val.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ".") + "," + this.roundToThreeSignificantDigits(splitValue[1]);
|
||||
} else {
|
||||
return value.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ".");
|
||||
}
|
||||
},
|
||||
convertMoney(money){
|
||||
return one_money(money)
|
||||
},
|
||||
formatAngka(nilai) {
|
||||
// Jika tidak ada nilai
|
||||
if (!nilai) return '';
|
||||
|
||||
try {
|
||||
// Ubah ke string
|
||||
let strNilai = String(nilai);
|
||||
|
||||
// Jika berisi titik desimal
|
||||
if (strNilai.includes('.')) {
|
||||
// Split bagian utama dan desimal
|
||||
let bagian = strNilai.split('.');
|
||||
let utama = bagian[0];
|
||||
let desimal = bagian[1];
|
||||
|
||||
// Format bagian utama
|
||||
utama = utama.replace(/\B(?=(\d{3})+(?!\d))/g, '.');
|
||||
|
||||
// Kembalikan gabungan
|
||||
return utama + ',' + desimal;
|
||||
} else {
|
||||
// Tidak ada desimal, hanya format bagian utama
|
||||
return strNilai.replace(/\B(?=(\d{3})+(?!\d))/g, '.');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error formatting:", error);
|
||||
return nilai;
|
||||
}
|
||||
},
|
||||
isSelected(p) {
|
||||
return p.M_ApproveLevelID == this.$store.state.approve.selected_approvelevel.M_ApproveLevelID
|
||||
},
|
||||
selectMe(sc) {
|
||||
console.log(sc)
|
||||
this.$store.commit("approve/update_selected_approvelevel", sc)
|
||||
this.$store.dispatch("approveuser/getUser", {
|
||||
approveId: sc.M_ApproveLevelID,
|
||||
current_page: this.$store.state.approveuser.current_page,
|
||||
search: this.$store.state.approveuser.xsearch,
|
||||
})
|
||||
},
|
||||
thr_search: _.debounce(function () {
|
||||
this.$store.dispatch("approve/search")
|
||||
}, 1000),
|
||||
mainTableSearch() {
|
||||
this.$store.dispatch("approve/search")
|
||||
this.$store.commit("approve/update_selected_approvelevel", {})
|
||||
},
|
||||
openDialogApproveLevel() {
|
||||
this.$store.commit("approve/update_dialog_form", true)
|
||||
this.$store.commit("approve/update_act", "new")
|
||||
this.$store.commit("approve/update_errors", [])
|
||||
this.xname = ""
|
||||
this.xstartTotal = 0
|
||||
this.xendTotal = 0
|
||||
},
|
||||
closeDialogForm() {
|
||||
this.$store.commit("approve/update_dialog_form", false)
|
||||
},
|
||||
// check error form
|
||||
checkErrorForm(value) {
|
||||
var errors = this.$store.state.approve.errors
|
||||
if (errors.includes(value)) {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
},
|
||||
|
||||
clearStartDate() {
|
||||
if (this.xstartTotal === 0) {
|
||||
this.xstartTotal = ''
|
||||
}
|
||||
},
|
||||
resetStartDate() {
|
||||
if (this.xstartTotal === '' || this.xstartTotal === null) {
|
||||
this.xstartTotal = 0
|
||||
}
|
||||
},
|
||||
|
||||
clearEndDate() {
|
||||
if (this.xendTotal === 0) {
|
||||
this.xendTotal = ''
|
||||
}
|
||||
},
|
||||
resetEndDate() {
|
||||
if (this.xendTotal === '' || this.xendTotal === null) {
|
||||
this.xendTotal = 0
|
||||
}
|
||||
},
|
||||
|
||||
// save
|
||||
saveForm() {
|
||||
this.$store.commit("approve/update_errors", [])
|
||||
var errors = this.$store.state.approve.errors
|
||||
|
||||
if(_.isEmpty(this.xname)){
|
||||
errors.push("requireName")
|
||||
}
|
||||
|
||||
if (errors.length === 0) {
|
||||
this.$store.commit("approve/update_errors", [])
|
||||
|
||||
var prm = {
|
||||
name: this.xname,
|
||||
startTotal: this.xstartTotal,
|
||||
endTotal: this.xendTotal
|
||||
}
|
||||
this.$store.dispatch("approve/save", prm)
|
||||
}
|
||||
},
|
||||
|
||||
openUpdateApproveLevel(val) {
|
||||
this.$store.commit("approve/update_errors", [])
|
||||
this.$store.commit("approve/update_dialog_form", true)
|
||||
this.$store.commit("approve/update_act", "edit")
|
||||
this.xname = val.M_ApproveLevelName
|
||||
this.xstartTotal = val.M_ApproveLevelStartTotal
|
||||
this.xendTotal = val.M_ApproveLevelEndTotal
|
||||
this.xid = val.M_ApproveLevelID
|
||||
},
|
||||
|
||||
updateForm() {
|
||||
this.$store.commit("approve/update_errors", [])
|
||||
var errors = this.$store.state.approve.errors
|
||||
|
||||
if(_.isEmpty(this.xname)){
|
||||
errors.push("requireName")
|
||||
}
|
||||
|
||||
if (errors.length === 0) {
|
||||
this.$store.commit("approve/update_errors", [])
|
||||
|
||||
var prm = {
|
||||
name: this.xname,
|
||||
startTotal: this.xstartTotal,
|
||||
endTotal: this.xendTotal,
|
||||
approveId: this.xid
|
||||
}
|
||||
this.$store.dispatch("approve/update", prm)
|
||||
}
|
||||
},
|
||||
|
||||
deleteSupplier(val) {
|
||||
this.xid = val.M_ApproveLevelID
|
||||
this.msgalertname = val.M_ApproveLevelName
|
||||
this.dialogdeletealert = true
|
||||
},
|
||||
closeDeleteAlert() {
|
||||
this.dialogdeletealert = false
|
||||
this.$store.dispatch("approve/deleteDep", {
|
||||
approveId: this.xid
|
||||
})
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
// xsearch(val, old) {
|
||||
// this.xsearch = val
|
||||
// this.thr_search()
|
||||
// },
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,187 @@
|
||||
<template>
|
||||
<div style="width: 100%;">
|
||||
<v-layout row wrap>
|
||||
<v-flex xs12 fill-height>
|
||||
<v-toolbar color="primary" dark>
|
||||
<v-toolbar-title class="white--text"
|
||||
>USER</v-toolbar-title
|
||||
>
|
||||
<!-- <v-spacer></v-spacer>
|
||||
<v-btn icon @click="openDialogApproveLevel()">
|
||||
<v-icon>add_box</v-icon>
|
||||
</v-btn> -->
|
||||
</v-toolbar>
|
||||
<v-card class="pa-2">
|
||||
<v-layout>
|
||||
<v-flex xs3 pl-2>
|
||||
<v-text-field
|
||||
label="Cari..."
|
||||
placeholder="Nama"
|
||||
outline
|
||||
v-model="xsearch"
|
||||
hide-details
|
||||
></v-text-field>
|
||||
</v-flex>
|
||||
<v-flex pl-2 pr-2>
|
||||
<v-btn
|
||||
dark
|
||||
color="primary"
|
||||
style="min-width: 50px; height: 50px; margin: 0"
|
||||
@click="mainTableSearch()"
|
||||
>
|
||||
<v-icon>search</v-icon>
|
||||
</v-btn>
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
</v-card>
|
||||
<v-card class="pa-2 mt-2">
|
||||
<v-layout row style="max-height: 600px; overflow: auto">
|
||||
<v-flex xs12 pl-2 pr-2 pt-2 pb-2>
|
||||
<v-data-table
|
||||
:items="users"
|
||||
:headers="headers"
|
||||
:loading="isLoading"
|
||||
hide-actions
|
||||
class="elevation-1"
|
||||
>
|
||||
<template slot="items" slot-scope="props">
|
||||
<td
|
||||
class="text-xs-center pa-2"
|
||||
>{{ props.item.M_UserFullName }}</td>
|
||||
<td
|
||||
class="text-xs-center pa-2"
|
||||
>{{ props.item.M_StaffName }}</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>
|
||||
</v-card>
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.date-type-table {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.table.v-table tbody td,
|
||||
table.v-table tbody th {
|
||||
height: 40px;
|
||||
}
|
||||
|
||||
.table.v-table thead tr {
|
||||
height: 40px;
|
||||
}
|
||||
|
||||
.scroll-container {
|
||||
scroll-padding: 50px 0 0 50px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script>
|
||||
module.exports = {
|
||||
components: {
|
||||
"dialog-form-voucher": httpVueLoader("./dialogFormVoucher.vue"),
|
||||
"one-dialog-alert": httpVueLoader("../../common/oneDialogAlert.vue"),
|
||||
"one-dialog-error": httpVueLoader("../../common/oneDialogError.vue")
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
xname: "",
|
||||
xstartTotal: 0,
|
||||
xendTotal: 0,
|
||||
xid: 0,
|
||||
dialogdeletealert: false,
|
||||
msgalertname: "",
|
||||
codeDepartment: "",
|
||||
headers: [
|
||||
{
|
||||
text: "NAMA USER",
|
||||
align: "center",
|
||||
sortable: false,
|
||||
value: "date",
|
||||
width: "50%",
|
||||
class: "blue lighten-3 white--text",
|
||||
},
|
||||
{
|
||||
text: "NAMA STAFF",
|
||||
align: "center",
|
||||
sortable: false,
|
||||
value: "total",
|
||||
width: "50%",
|
||||
class: "blue lighten-3 white--text",
|
||||
}
|
||||
],
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
|
||||
},
|
||||
computed: {
|
||||
users() {
|
||||
return this.$store.state.approveuser.users
|
||||
},
|
||||
isLoading() {
|
||||
return this.$store.state.approveuser.search_status == 1
|
||||
},
|
||||
xsearch: {
|
||||
get() {
|
||||
return this.$store.state.approveuser.xsearch
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("approveuser/update_xsearch", val)
|
||||
}
|
||||
},
|
||||
curr_page: {
|
||||
get() {
|
||||
return this.$store.state.approveuser.current_page
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("approveuser/update_current_page", val)
|
||||
this.$store.commit("approveuser/update_last_id", -1)
|
||||
this.$store.dispatch("approveuser/getUser", {
|
||||
approveId: this.$store.state.approve.selected_approvelevel.M_ApproveLevelID,
|
||||
current_page: this.$store.state.approveuser.current_page,
|
||||
search: this.$store.state.approveuser.xsearch,
|
||||
})
|
||||
}
|
||||
},
|
||||
xtotal_page: {
|
||||
get() {
|
||||
return this.$store.state.approveuser.total_page
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("approveuser/update_total_page", val)
|
||||
}
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
thr_search: _.debounce(function () {
|
||||
this.$store.dispatch("approveuser/search")
|
||||
}, 1000),
|
||||
mainTableSearch() {
|
||||
this.$store.dispatch("approveuser/getUser", {
|
||||
approveId: this.$store.state.approve.selected_approvelevel.M_ApproveLevelID,
|
||||
current_page: this.$store.state.approveuser.current_page,
|
||||
search: this.$store.state.approveuser.xsearch,
|
||||
})
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
// xsearch(val, old) {
|
||||
// this.xsearch = val
|
||||
// this.thr_search()
|
||||
// },
|
||||
}
|
||||
}
|
||||
</script>
|
||||
91
test/vuex/acc-one-md-approve-level/index.php
Normal file
91
test/vuex/acc-one-md-approve-level/index.php
Normal file
@@ -0,0 +1,91 @@
|
||||
<!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/icomoon-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-approve-list></one-approve-list>
|
||||
</v-flex>
|
||||
<v-flex xs6 class="left" fill-height pa-1>
|
||||
<one-approve-user-list></one-approve-user-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-approve-list': httpVueLoader('./components/oneApproveLevel.vue'),
|
||||
'one-approve-user-list': httpVueLoader('./components/oneApproveLevelUser.vue')
|
||||
}
|
||||
})
|
||||
</script>
|
||||
<style>
|
||||
[v-cloak] {
|
||||
display: none
|
||||
}
|
||||
</style>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
205
test/vuex/acc-one-md-approve-level/modules/approve.js
Normal file
205
test/vuex/acc-one-md-approve-level/modules/approve.js
Normal file
@@ -0,0 +1,205 @@
|
||||
// 1 => LOADING
|
||||
// 2 => DONE
|
||||
// 3 => ERROR
|
||||
import * as api from "../api/approve.js"
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {
|
||||
search_status: 0,
|
||||
search_error_message: "",
|
||||
approvelevels: [],
|
||||
selected_approvelevel: {},
|
||||
total_page: 0,
|
||||
current_page: 1,
|
||||
xsearch: "",
|
||||
last_id: -1,
|
||||
dialog_form: false,
|
||||
act: "new",
|
||||
errors: "",
|
||||
save_status: 0,
|
||||
save_error_message: "",
|
||||
alert_error: false,
|
||||
alert_success: false,
|
||||
msg_success: ""
|
||||
},
|
||||
mutations: {
|
||||
update_search_status(state, val) {
|
||||
state.search_status = val
|
||||
},
|
||||
update_search_error_message(state, val) {
|
||||
state.search_error_message = val
|
||||
},
|
||||
update_approvelevels(state, val) {
|
||||
state.approvelevels = val
|
||||
},
|
||||
update_selected_approvelevel(state, val) {
|
||||
state.selected_approvelevel = val
|
||||
},
|
||||
update_total_page(state, val) {
|
||||
state.total_page = val
|
||||
},
|
||||
update_current_page(state, val) {
|
||||
state.current_page = val
|
||||
},
|
||||
update_xsearch(state, val) {
|
||||
state.xsearch = val
|
||||
state.current_page = 1
|
||||
},
|
||||
update_last_id(state, val) {
|
||||
state.last_id = val
|
||||
},
|
||||
update_dialog_form(state, val) {
|
||||
state.dialog_form = val
|
||||
},
|
||||
update_act(state, val) {
|
||||
state.act = val
|
||||
},
|
||||
update_save_status(state, val) {
|
||||
state.save_status = val
|
||||
},
|
||||
update_save_error_message(state, val) {
|
||||
state.save_error_message = val
|
||||
},
|
||||
update_alert_error(state, val) {
|
||||
state.alert_error = val
|
||||
},
|
||||
update_alert_success(state, val) {
|
||||
state.alert_success = val
|
||||
},
|
||||
update_msg_success(state, val) {
|
||||
state.msg_success = val
|
||||
},
|
||||
update_errors(state, val) {
|
||||
state.errors = val
|
||||
},
|
||||
},
|
||||
actions: {
|
||||
async search(context) {
|
||||
context.commit("update_search_status", 1)
|
||||
try {
|
||||
var prm = {
|
||||
token: one_token(),
|
||||
current_page: context.state.current_page,
|
||||
search: context.state.xsearch,
|
||||
last_id: -1
|
||||
}
|
||||
let resp = await api.search(prm)
|
||||
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_page
|
||||
}
|
||||
|
||||
context.commit("update_approvelevels", data.records)
|
||||
context.commit("update_total_page", data.total)
|
||||
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_search_status", 3)
|
||||
context.commit("update_search_error_message", e.message)
|
||||
}
|
||||
},
|
||||
async save(context, prm) {
|
||||
context.commit("update_save_status", 1)
|
||||
try {
|
||||
prm.token = one_token()
|
||||
let resp = await api.save(prm);
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_save_error_message", resp.message)
|
||||
context.commit("update_save_status", 3)
|
||||
context.commit("update_alert_error", true)
|
||||
} else {
|
||||
context.commit("update_save_error_message", resp.message)
|
||||
context.commit("update_save_status", 2)
|
||||
let data = {
|
||||
records: resp.data.records,
|
||||
total: resp.data.total
|
||||
};
|
||||
|
||||
if (data.total !== -1) {
|
||||
context.commit("update_errors", [])
|
||||
context.commit("update_alert_success", true)
|
||||
context.commit("update_dialog_form", false)
|
||||
var msg = `Approve level baru dengan nama ${data.records[0].M_ApproveLevelName} sudah tersimpan`;
|
||||
context.commit("update_msg_success", msg)
|
||||
context.dispatch("search")
|
||||
context.commit("update_selected_approvelevel", data.records[0]);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_save_error_message", e.message)
|
||||
context.commit("update_save_status", 3)
|
||||
context.commit("update_alert_error", true)
|
||||
}
|
||||
},
|
||||
async update(context, prm) {
|
||||
context.commit("update_save_status", 1)
|
||||
try {
|
||||
prm.token = one_token()
|
||||
let resp = await api.update(prm);
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_save_error_message", resp.message)
|
||||
context.commit("update_save_status", 3)
|
||||
context.commit("update_alert_error", true)
|
||||
} else {
|
||||
context.commit("update_save_error_message", resp.message)
|
||||
context.commit("update_save_status", 2)
|
||||
let data = {
|
||||
records: resp.data.records,
|
||||
total: resp.data.total
|
||||
};
|
||||
|
||||
if (data.total !== -1) {
|
||||
context.commit("update_errors", [])
|
||||
context.commit("update_alert_success", true)
|
||||
context.commit("update_dialog_form", false)
|
||||
var msg = `Approve level dengan nama ${data.records[0].M_ApproveLevelName} berhasil di update`;
|
||||
context.commit("update_msg_success", msg)
|
||||
context.dispatch("search")
|
||||
context.commit("update_selected_approvelevel", data.records[0]);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_save_error_message", e.message)
|
||||
context.commit("update_save_status", 3)
|
||||
context.commit("update_alert_error", true)
|
||||
}
|
||||
},
|
||||
async deleteDep(context, prm) {
|
||||
context.commit("update_save_status", 1)
|
||||
try {
|
||||
prm.token = one_token()
|
||||
let resp = await api.deleteDep(prm);
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_save_error_message", resp.message)
|
||||
context.commit("update_save_status", 3)
|
||||
context.commit("update_alert_error", true)
|
||||
} else {
|
||||
context.commit("update_save_error_message", resp.message)
|
||||
context.commit("update_save_status", 2)
|
||||
let data = {
|
||||
message: resp.data.message
|
||||
};
|
||||
|
||||
if (data.total !== -1) {
|
||||
context.commit("update_errors", [])
|
||||
context.commit("update_alert_success", true)
|
||||
context.commit("update_dialog_form", false)
|
||||
context.commit("update_msg_success", data.message)
|
||||
context.dispatch("search")
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_save_error_message", e.message)
|
||||
context.commit("update_save_status", 3)
|
||||
context.commit("update_alert_error", true)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
76
test/vuex/acc-one-md-approve-level/modules/approveuser.js
Normal file
76
test/vuex/acc-one-md-approve-level/modules/approveuser.js
Normal file
@@ -0,0 +1,76 @@
|
||||
// 1 => LOADING
|
||||
// 2 => DONE
|
||||
// 3 => ERROR
|
||||
import * as api from "../api/approveuser.js"
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {
|
||||
search_status: 0,
|
||||
search_error_message: "",
|
||||
users: [],
|
||||
total_page: 0,
|
||||
current_page: 1,
|
||||
xsearch: "",
|
||||
last_id: -1,
|
||||
dialog_form: false,
|
||||
act: "new",
|
||||
errors: "",
|
||||
save_status: 0,
|
||||
save_error_message: "",
|
||||
alert_error: false,
|
||||
alert_success: false,
|
||||
msg_success: ""
|
||||
},
|
||||
mutations: {
|
||||
update_search_status(state, val) {
|
||||
state.search_status = val
|
||||
},
|
||||
update_search_error_message(state, val) {
|
||||
state.search_error_message = val
|
||||
},
|
||||
update_users(state, val) {
|
||||
state.users = val
|
||||
},
|
||||
update_total_page(state, val) {
|
||||
state.total_page = val
|
||||
},
|
||||
update_current_page(state, val) {
|
||||
state.current_page = val
|
||||
},
|
||||
update_xsearch(state, val) {
|
||||
state.xsearch = val
|
||||
state.current_page = 1
|
||||
},
|
||||
update_last_id(state, val) {
|
||||
state.last_id = val
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
async getUser(context, prm) {
|
||||
context.commit("update_search_status", 1)
|
||||
try {
|
||||
prm.token = one_token()
|
||||
let resp = await api.getUser(prm)
|
||||
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_page
|
||||
}
|
||||
|
||||
context.commit("update_users", data.records)
|
||||
context.commit("update_total_page", data.total)
|
||||
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_search_status", 3)
|
||||
context.commit("update_search_error_message", e.message)
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
13
test/vuex/acc-one-md-approve-level/store.js
Normal file
13
test/vuex/acc-one-md-approve-level/store.js
Normal file
@@ -0,0 +1,13 @@
|
||||
import approve from "./modules/approve.js";
|
||||
import approveuser from "./modules/approveuser.js";
|
||||
import system from "../../../apps/modules/system/system.js";
|
||||
export const store = new Vuex.Store({
|
||||
modules: {
|
||||
approve: approve,
|
||||
approveuser: approveuser,
|
||||
system: system,
|
||||
},
|
||||
state: {},
|
||||
mutations: {},
|
||||
actions: {},
|
||||
});
|
||||
Reference in New Issue
Block a user