add modules folder based on s_menu
This commit is contained in:
77
test/vuex/acc-one-md-periode/api/api-periode.js
Normal file
77
test/vuex/acc-one-md-periode/api/api-periode.js
Normal file
@@ -0,0 +1,77 @@
|
||||
const URL = "/one-api/mockup/masterdata/accounting/";
|
||||
|
||||
export async function getListing(params) {
|
||||
try {
|
||||
var resp = await axios.post(URL + 'mdperiode/listperiode', params);
|
||||
if (resp.status != 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: resp.message
|
||||
};
|
||||
}
|
||||
let data = resp.data;
|
||||
return data;
|
||||
} catch (error) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: error.message
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export async function p_delete(params) {
|
||||
try {
|
||||
var resp = await axios.post(URL + 'mdperiode/deleteperiode', params);
|
||||
if (resp.status != 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: error.message
|
||||
};
|
||||
}
|
||||
let data = resp.data;
|
||||
return data;
|
||||
} catch (error) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: error.message
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export async function p_add(params) {
|
||||
try {
|
||||
var resp = await axios.post(URL + 'mdperiode/addperiode', params);
|
||||
if (resp.status != 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: error.message
|
||||
};
|
||||
}
|
||||
let data = resp.data;
|
||||
return data;
|
||||
} catch (error) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: error.message
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export async function p_edit(params) {
|
||||
try {
|
||||
var resp = await axios.post(URL + 'mdperiode/editperiode', params);
|
||||
if (resp.status != 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: error.message
|
||||
};
|
||||
}
|
||||
let data = resp.data;
|
||||
return data;
|
||||
} catch (error) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: error.message
|
||||
};
|
||||
}
|
||||
}
|
||||
77
test/vuex/acc-one-md-periode/api/coa.js
Normal file
77
test/vuex/acc-one-md-periode/api/coa.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 + 'mdcoa/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 + 'mdcoa/addnewcoa', 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 + 'mdcoa/editcoa', 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 xdelete(token,coid) {
|
||||
try {
|
||||
var resp = await axios.post(URL + 'mdcoa/deletecoa', { coid: coid, 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
|
||||
};
|
||||
}
|
||||
}
|
||||
187
test/vuex/acc-one-md-periode/components/detail.vue
Normal file
187
test/vuex/acc-one-md-periode/components/detail.vue
Normal file
@@ -0,0 +1,187 @@
|
||||
<template>
|
||||
<v-layout class="mb-2" column>
|
||||
<v-snackbar v-model="snackbar" :timeout="5000" :multi-line="false" :vertical="false" :top="true">
|
||||
{{ msgsnackbar }}
|
||||
<v-btn flat @click="openSnackBar(false)">Tutup</v-btn>
|
||||
</v-snackbar>
|
||||
<v-card>
|
||||
<v-layout row>
|
||||
<v-flex xs12>
|
||||
<v-subheader>DETAIL PERIODE
|
||||
<v-flex text-md-right pa-1>
|
||||
<span @click="periodeTambah()" class="ml-1 primary icon-add icon-medium-fill-base white--text xs1"></span>
|
||||
</v-flex>
|
||||
</v-subheader>
|
||||
<v-divider></v-divider>
|
||||
<v-layout row wrap>
|
||||
<v-flex xs12 pa-2>
|
||||
<v-layout row>
|
||||
<v-flex xs4 pa-1>
|
||||
<v-text-field v-model="selected.periodeName" label="Nama Periode"></v-text-field>
|
||||
</v-flex>
|
||||
<v-flex xs4 pa-1>
|
||||
<!-- <v-text-field v-model="selected.periodeMonth" label="Bulan Periode" type="number"></v-text-field> -->
|
||||
<v-select item-text="name" item-value="periodeMonth" :items="bulan" v-model="selected.periodeMonth" label="Bulan Periode"></v-select>
|
||||
</v-flex>
|
||||
<v-flex xs4 pa-1>
|
||||
<v-text-field v-model="selected.periodeYear" label="Tahun Periode" type="number"></v-text-field>
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
<v-layout row>
|
||||
<v-flex xs6 pa-1>
|
||||
<v-menu
|
||||
ref="menustartdate" v-model="menustartdate"
|
||||
:close-on-content-click="false" :nudge-right="0" lazy transition="scale-transition"
|
||||
offset-y full-width max-width="290px" min-width="290px">
|
||||
<template v-slot:activator="{ on }">
|
||||
<v-text-field v-model="startComputedDateFormatted" label="Start Date" readonly v-on="on" @blur="date = deFormatedDate(startComputedDateFormatted)"></v-text-field>
|
||||
</template>
|
||||
<v-date-picker v-model="selected.periodeStartDate" no-title @input="menustartdate = false"></v-date-picker>
|
||||
</v-menu>
|
||||
</v-flex>
|
||||
<v-flex xs6 pa-1>
|
||||
<v-menu
|
||||
ref="menuenddate" v-model="menuenddate"
|
||||
:close-on-content-click="false" :nudge-right="0" lazy transition="scale-transition"
|
||||
offset-y full-width max-width="290px" min-width="290px">
|
||||
<template v-slot:activator="{ on }">
|
||||
<v-text-field v-model="endComputedDateFormatted" label="End Date" readonly v-on="on" @blur="date = deFormatedDate(endComputedDateFormatted)"></v-text-field>
|
||||
</template>
|
||||
<v-date-picker v-model="selected.periodeEndDate" no-title @input="menuenddate = false"></v-date-picker>
|
||||
</v-menu>
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
<v-layout row>
|
||||
<v-flex pa-1 text-md-right>
|
||||
<v-btn small color="error" @click="periodeDelete()">Hapus</v-btn>
|
||||
<v-btn small color="primary" @click="periodeSimpan()">Simpan</v-btn>
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
</v-card>
|
||||
</v-layout>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
module.exports = {
|
||||
data: () => ({
|
||||
menustartdate: false,
|
||||
menuenddate: false,
|
||||
date: new Date().toISOString().substr(0, 10),
|
||||
bulan: [
|
||||
{
|
||||
periodeMonth: "1",
|
||||
name: "Januari"
|
||||
},
|
||||
{
|
||||
periodeMonth: "2",
|
||||
name: "Februari"
|
||||
},
|
||||
{
|
||||
periodeMonth: "3",
|
||||
name: "Maret"
|
||||
},
|
||||
{
|
||||
periodeMonth: "4",
|
||||
name: "April"
|
||||
},
|
||||
{
|
||||
periodeMonth: "5",
|
||||
name: "Mei"
|
||||
},
|
||||
{
|
||||
periodeMonth: "6",
|
||||
name: "Juni"
|
||||
},
|
||||
{
|
||||
periodeMonth: "7",
|
||||
name: "Juli"
|
||||
},
|
||||
{
|
||||
periodeMonth: "8",
|
||||
name: "Agustus"
|
||||
},
|
||||
{
|
||||
periodeMonth: "9",
|
||||
name: "September"
|
||||
},
|
||||
{
|
||||
periodeMonth: "10",
|
||||
name: "Oktober"
|
||||
},
|
||||
{
|
||||
periodeMonth: "11",
|
||||
name: "November"
|
||||
},
|
||||
{
|
||||
periodeMonth: "12",
|
||||
name: "Desember"
|
||||
},
|
||||
]
|
||||
}),
|
||||
computed: {
|
||||
selected: {
|
||||
get() {
|
||||
return this.$store.state.periode.selected;
|
||||
},
|
||||
set(data) {
|
||||
this.$store.commit('periode/update_selected', data)
|
||||
}
|
||||
},
|
||||
snackbar: {
|
||||
get() {
|
||||
return this.$store.state.periode.snackbar;
|
||||
},
|
||||
set(bool) {
|
||||
this.$store.commit("periode/open_snackbar", bool)
|
||||
}
|
||||
},
|
||||
msgsnackbar() {
|
||||
return this.$store.state.periode.message_snack;
|
||||
},
|
||||
startComputedDateFormatted() {
|
||||
return this.formatDate(this.selected.periodeStartDate)
|
||||
},
|
||||
endComputedDateFormatted() {
|
||||
return this.formatDate(this.selected.periodeEndDate)
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
formatDate(date) {
|
||||
if (!date) return null
|
||||
|
||||
const [year, month, day] = date.split('-')
|
||||
return `${day}-${month}-${year}`
|
||||
},
|
||||
deFormatedDate(date) {
|
||||
if (!date) return null
|
||||
|
||||
const [day, month, year] = date.split('-')
|
||||
return `${year}-${month.padStart(2, '0')}-${day.padStart(2, '0')}`
|
||||
},
|
||||
periodeDelete() {
|
||||
this.$store.dispatch("periode/deletePeriode")
|
||||
},
|
||||
periodeSimpan() {
|
||||
this.$store.dispatch("periode/checkNewOrEdit")
|
||||
},
|
||||
periodeTambah() {
|
||||
this.$store.commit("periode/update_selected", {})
|
||||
},
|
||||
openSnackBar(bool) {
|
||||
this.$store.commit("periode/update_message_snack", "");
|
||||
this.$store.commit("periode/open_snackbar", bool);
|
||||
},
|
||||
setMonthText(id) {
|
||||
const targetMonth = this.bulan.find((month) => month.id === id);
|
||||
|
||||
if (targetMonth) {
|
||||
this.selected.periodeMonth = targetMonth;
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
</script>
|
||||
125
test/vuex/acc-one-md-periode/components/listing.vue
Normal file
125
test/vuex/acc-one-md-periode/components/listing.vue
Normal file
@@ -0,0 +1,125 @@
|
||||
<template>
|
||||
<v-layout class="fill-height" column>
|
||||
<v-card>
|
||||
<v-layout row>
|
||||
<v-flex xs-12 pl-2 pr-2 pt-2 pb-2>
|
||||
<v-data-table :headers="headers" :items="l_periode" :loading="isLoading" :pagination.sync="pagination" class="elevation-1">
|
||||
<template slot="items" slot-scope="props">
|
||||
<tr :class="{'amber lighten-4':isSelected(props.item)}" @click="selectPeriode(props.item)">
|
||||
<td class="text-xs-center pa-2">{{ props.item.periodeID }}</td>
|
||||
<td class="text-xs-center pa-2">{{ props.item.periodeName }}</td>
|
||||
<td class="text-xs-center pa-2">{{ props.item.periodeStartDate }}</td>
|
||||
<td class="text-xs-center pa-2">{{ props.item.periodeEndDate }}</td>
|
||||
<td v-if="props.item.periodeIsClosed === 'Y'" class="text-xs-center pa-2">YA</td>
|
||||
<td v-else class="text-xs-center pa-2">TIDAK</td>
|
||||
</tr>
|
||||
</template>
|
||||
<template>
|
||||
<div class="text-xs-center">
|
||||
<v-pagination v-model="page" :length="15" :total-visible="7"></v-pagination>
|
||||
</div>
|
||||
</template>
|
||||
</v-data-table>
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
</v-card>
|
||||
</v-layout>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
table.v-table tbody td,
|
||||
table.v-table tbody th {
|
||||
height: 40px;
|
||||
}
|
||||
|
||||
table.v-table thead tr {
|
||||
height: 40px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script>
|
||||
module.exports = {
|
||||
mounted() {
|
||||
this.$store.dispatch("periode/getList");
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
page: 1,
|
||||
pagination: {
|
||||
descending: false,
|
||||
page: 1,
|
||||
rowsPerPage: 5,
|
||||
sortBy: 'periodeID',
|
||||
totalItems: this.$store.state.periode.total_list,
|
||||
},
|
||||
headers: [
|
||||
{
|
||||
text: "NO",
|
||||
align: "center",
|
||||
sortable: false,
|
||||
value: "no",
|
||||
width: "20%",
|
||||
class: "pa-2 blue lighten-3 white--text"
|
||||
},
|
||||
{
|
||||
text: "PERIODE",
|
||||
align: "center",
|
||||
sortable: false,
|
||||
value: "no",
|
||||
width: "20%",
|
||||
class: "pa-2 blue lighten-3 white--text"
|
||||
},
|
||||
{
|
||||
text: "START DATE",
|
||||
align: "center",
|
||||
sortable: false,
|
||||
value: "no",
|
||||
width: "20%",
|
||||
class: "pa-2 blue lighten-3 white--text"
|
||||
},
|
||||
{
|
||||
text: "END DATE",
|
||||
align: "center",
|
||||
sortable: false,
|
||||
value: "no",
|
||||
width: "20%",
|
||||
class: "pa-2 blue lighten-3 white--text"
|
||||
},
|
||||
{
|
||||
text: "CLOSED",
|
||||
align: "center",
|
||||
sortable: false,
|
||||
value: "no",
|
||||
width: "20%",
|
||||
class: "pa-2 blue lighten-3 white--text"
|
||||
},
|
||||
]
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
l_periode() {
|
||||
return this.$store.state.periode.periode;
|
||||
},
|
||||
selected: {
|
||||
get() {
|
||||
return this.$store.state.periode.selected;
|
||||
},
|
||||
set(data) {
|
||||
this.$store.commit('periode/update_selected', data)
|
||||
}
|
||||
},
|
||||
isLoading() {
|
||||
return this.$store.state.periode.status_get == 1;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
isSelected(row) {
|
||||
return row.periodeID == this.$store.state.periode.selected.periodeID
|
||||
},
|
||||
selectPeriode(per) {
|
||||
const selRow = {...per};
|
||||
this.selected = selRow;
|
||||
}
|
||||
},
|
||||
}
|
||||
</script>
|
||||
68
test/vuex/acc-one-md-periode/index.php
Normal file
68
test/vuex/acc-one-md-periode/index.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<!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">
|
||||
<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">
|
||||
<title>One</title>
|
||||
</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-periode-list></one-md-periode-list>
|
||||
</v-flex>
|
||||
<v-flex xs6 class="right" fill-height pa-1>
|
||||
<one-md-periode-detail></one-md-periode-detail>
|
||||
</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 -->
|
||||
|
||||
<script type="module">
|
||||
import { store } from './store.js';
|
||||
window.store = store;
|
||||
new Vue({
|
||||
store,
|
||||
el: '#app',
|
||||
methods: {
|
||||
|
||||
},
|
||||
components: {
|
||||
'one-navbar': httpVueLoader('../../../apps/components/oneNavbarComponent.vue'),
|
||||
'one-footer': httpVueLoader('../../../apps/components/oneFooter.vue'),
|
||||
'one-md-periode-list': httpVueLoader('./components/listing.vue'),
|
||||
'one-md-periode-detail': httpVueLoader('./components/detail.vue'),
|
||||
}
|
||||
})
|
||||
</script>
|
||||
<style>
|
||||
[v-cloak] {
|
||||
display: none;
|
||||
}
|
||||
</style>
|
||||
</body>
|
||||
</html>
|
||||
213
test/vuex/acc-one-md-periode/modules/coa.js
Normal file
213
test/vuex/acc-one-md-periode/modules/coa.js
Normal file
@@ -0,0 +1,213 @@
|
||||
// 1 => LOADING
|
||||
// 2 => DONE
|
||||
// 3 => ERROR
|
||||
import * as api from "../api/coa.js"
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {
|
||||
search_status: 0,
|
||||
current_page: 1,
|
||||
x_search: "",
|
||||
search_error_message: "",
|
||||
last_id: -1,
|
||||
coas: [],
|
||||
total_coas: 0,
|
||||
selected_coa: {},
|
||||
dialog_form_coa: false,
|
||||
act: 'new',
|
||||
save_status: 0,
|
||||
save_error_message: '',
|
||||
errors: [],
|
||||
alert_success: false,
|
||||
msg_success: "",
|
||||
alert_error: false,
|
||||
dialog_error: false,
|
||||
},
|
||||
mutations: {
|
||||
update_search_status(state, val) {
|
||||
state.search_status = val
|
||||
},
|
||||
update_current_page(state, val) {
|
||||
state.current_page = val
|
||||
},
|
||||
update_x_search(state, val) {
|
||||
state.x_search = val
|
||||
state.current_page = 1
|
||||
},
|
||||
update_search_error_message(state, val) {
|
||||
state.search_error_message = val
|
||||
},
|
||||
update_last_id(state, val) {
|
||||
state.last_id = val
|
||||
},
|
||||
update_coas(state, val) {
|
||||
state.coas = val
|
||||
},
|
||||
update_total_coas(state, val) {
|
||||
state.total_coas = val
|
||||
},
|
||||
update_selected_coa(state, val) {
|
||||
state.selected_coa = val
|
||||
},
|
||||
update_dialog_form_coa(state, val) {
|
||||
state.dialog_form_coa = 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_errors(state, val) {
|
||||
state.errors = val
|
||||
},
|
||||
update_alert_success(state, val) {
|
||||
state.alert_success = val
|
||||
},
|
||||
update_msg_success(state, val) {
|
||||
state.msg_success = val
|
||||
},
|
||||
update_alert_error(state, val) {
|
||||
state.alert_error = val
|
||||
},
|
||||
update_dialog_error(state, val) {
|
||||
state.dialog_error = 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.x_search,
|
||||
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
|
||||
}
|
||||
|
||||
context.commit("update_coas", data.records)
|
||||
context.commit("update_total_coas", 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_status", 3)
|
||||
context.commit("update_save_error_message", resp.message)
|
||||
context.commit("update_alert_error", true)
|
||||
} else {
|
||||
context.commit("update_save_status", 2)
|
||||
context.commit("update_save_error_message", resp.message)
|
||||
var 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_coa", false)
|
||||
var msg =" Account " + prm.description + " sudah tersimpan dong ..."
|
||||
context.commit("update_msg_success", msg)
|
||||
context.dispatch("search")
|
||||
} else {
|
||||
context.commit("update_errors", resp.data.errors)
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_save_status", 3)
|
||||
context.commit("update_save_error_message", e.message)
|
||||
context.commit("update_alert_error", true)
|
||||
console.log(e)
|
||||
}
|
||||
},
|
||||
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_status", 3)
|
||||
context.commit("update_save_error_message", resp.message)
|
||||
context.commit("update_alert_error", true)
|
||||
} else {
|
||||
context.commit("update_save_status", 2)
|
||||
context.commit("update_save_error_message", resp.message)
|
||||
let data = {
|
||||
records: resp.data.records,
|
||||
total: resp.data.total
|
||||
}
|
||||
|
||||
if (data.total !== -1) {
|
||||
context.commit("update_alert_success", true)
|
||||
context.commit("update_dialog_form_coa", false)
|
||||
var msg = " Account " + prm.description + " sudah terupdate dong ..."
|
||||
context.commit("update_msg_success", msg)
|
||||
context.dispatch("search")
|
||||
}else {
|
||||
context.commit("update_errors", resp.data.errors)
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_save_status", 3)
|
||||
context.commit("update_save_error_message", e.message)
|
||||
context.commit("update_alert_error", true)
|
||||
console.log(e)
|
||||
}
|
||||
},
|
||||
|
||||
async delete(context, prm) {
|
||||
context.commit("update_save_status", 1)
|
||||
try {
|
||||
let resp = await api.xdelete(one_token(), prm.coid)
|
||||
console.log(prm.coid)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_save_status", 3)
|
||||
context.commit("update_save_error_message", resp.message)
|
||||
context.commit("update_alert_error", true)
|
||||
} else {
|
||||
context.commit("update_save_status", 2)
|
||||
context.commit("update_save_error_message", resp.message)
|
||||
context.commit("update_alert_success", true)
|
||||
|
||||
var msg = " Account " + prm.description + " sudah dihapus dong"
|
||||
context.commit("update_msg_success", msg)
|
||||
context.commit("update_alert_success", true)
|
||||
context.commit("update_selected_coa", {})
|
||||
context.dispatch("search")
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_save_status", 3)
|
||||
context.commit("update_alert_error", true)
|
||||
console.log(e)
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
160
test/vuex/acc-one-md-periode/modules/periode.js
Normal file
160
test/vuex/acc-one-md-periode/modules/periode.js
Normal file
@@ -0,0 +1,160 @@
|
||||
// 1 => LOADING
|
||||
// 2 => DONE
|
||||
// 3 => ERROR
|
||||
import * as api from "../api/api-periode.js"
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {
|
||||
periode: [],
|
||||
total_list: 0,
|
||||
status_get: 0,
|
||||
selected: {},
|
||||
snackbar: false,
|
||||
message_snack: ""
|
||||
},
|
||||
mutations: {
|
||||
update_selected(state, data) {
|
||||
state.selected = data
|
||||
},
|
||||
update_total_list(state, data) {
|
||||
state.total_list = data
|
||||
},
|
||||
update_list(state, data) {
|
||||
state.periode = data
|
||||
},
|
||||
update_status_get(state, data) {
|
||||
state.status_get = data
|
||||
},
|
||||
open_snackbar(state, bool) {
|
||||
state.snackbar = bool
|
||||
},
|
||||
update_message_snack(state, data) {
|
||||
state.message_snack = data
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
async getList(context) {
|
||||
context.commit("update_status_get", 1);
|
||||
try {
|
||||
var params = {token: one_token()};
|
||||
let resp = await api.getListing(params);
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_status_get", 3);
|
||||
context.commit("update_message_snack", resp.message);
|
||||
context.commit("open_snackbar", true);
|
||||
} else {
|
||||
context.commit("update_status_get", 2);
|
||||
let data = {
|
||||
records: resp.data.records,
|
||||
total: resp.data.total
|
||||
}
|
||||
// console.log(data.total);
|
||||
// console.log(data.records);
|
||||
context.commit("update_list", data.records);
|
||||
context.commit("update_total_list", data.total);
|
||||
}
|
||||
} catch (error) {
|
||||
context.commit("update_status_get", 3);
|
||||
context.commit("update_message_snack", error.message);
|
||||
context.commit("open_snackbar", true);
|
||||
}
|
||||
},
|
||||
|
||||
async deletePeriode(context) {
|
||||
try {
|
||||
var params = {
|
||||
token: one_token(),
|
||||
id: context.state.selected.periodeID
|
||||
}
|
||||
console.log(params);
|
||||
let resp = await api.p_delete(params);
|
||||
if (resp.status != "OK") {
|
||||
// console.log(resp.message);
|
||||
context.commit("open_snackbar", true);
|
||||
context.commit("update_message_snack", resp.message);
|
||||
} else {
|
||||
context.commit("open_snackbar", true);
|
||||
var msg = "Berhasil menghapus data periode";
|
||||
context.commit("update_message_snack", msg);
|
||||
context.commit("update_selected", {});
|
||||
context.dispatch("getList");
|
||||
}
|
||||
} catch (error) {
|
||||
context.commit("update_message_snack", error.message);
|
||||
context.commit("open_snackbar", true);
|
||||
}
|
||||
},
|
||||
|
||||
async addPeriode(context) {
|
||||
try {
|
||||
var params = {
|
||||
token: one_token(),
|
||||
...context.state.selected
|
||||
};
|
||||
console.log(params);
|
||||
let resp = await api.p_add(params);
|
||||
if (resp.status != "OK") {
|
||||
context.commit("open_snackbar", true);
|
||||
context.commit("update_message_snack", resp.message);
|
||||
} else {
|
||||
context.commit("open_snackbar", true);
|
||||
var msg = "Berhasil menyimpan data periode";
|
||||
context.commit("update_message_snack", msg);
|
||||
context.commit("update_selected", {});
|
||||
context.dispatch("getList");
|
||||
}
|
||||
} catch (error) {
|
||||
context.commit("update_message_snack", error.message);
|
||||
context.commit("open_snackbar", true);
|
||||
}
|
||||
},
|
||||
|
||||
async editPeriode(context) {
|
||||
try {
|
||||
var params = {
|
||||
token: one_token(),
|
||||
...context.state.selected
|
||||
};
|
||||
console.log(params);
|
||||
let resp = await api.p_edit(params);
|
||||
if (resp.status != "OK") {
|
||||
context.commit("open_snackbar", true);
|
||||
context.commit("update_message_snack", resp.message);
|
||||
} else {
|
||||
context.commit("open_snackbar", true);
|
||||
var msg = "Berhasil menyimpan data periode";
|
||||
context.commit("update_message_snack", msg);
|
||||
context.commit("update_selected", {});
|
||||
context.dispatch("getList");
|
||||
}
|
||||
} catch (error) {
|
||||
context.commit("update_message_snack", error.message);
|
||||
context.commit("open_snackbar", true);
|
||||
}
|
||||
},
|
||||
|
||||
async checkNewOrEdit(context) {
|
||||
if (!checkIsEmpty(context.state.selected)) {
|
||||
var msg = "Form masih ada yang kosong";
|
||||
context.commit("update_message_snack", msg);
|
||||
context.commit("open_snackbar", true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!context.state.selected.periodeID) {
|
||||
context.dispatch("addPeriode");
|
||||
} else {
|
||||
context.dispatch("editPeriode");
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function checkIsEmpty(obj) {
|
||||
if (Object.keys(obj).length === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return obj.periodeYear && obj.periodeMonth && obj.periodeName && obj.periodeStartDate && obj.periodeEndDate;
|
||||
}
|
||||
17
test/vuex/acc-one-md-periode/store.js
Normal file
17
test/vuex/acc-one-md-periode/store.js
Normal file
@@ -0,0 +1,17 @@
|
||||
import periode from "./modules/periode.js";
|
||||
import system from "../../../apps/modules/system/system.js";
|
||||
export const store = new Vuex.Store({
|
||||
modules: {
|
||||
periode: periode,
|
||||
system: system
|
||||
},
|
||||
state: {
|
||||
|
||||
},
|
||||
mutations: {
|
||||
|
||||
},
|
||||
actions: {
|
||||
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user