add modules folder based on s_menu
This commit is contained in:
99
test/vuex/acc-one-md-item-category/api/rktype.js
Normal file
99
test/vuex/acc-one-md-item-category/api/rktype.js
Normal file
@@ -0,0 +1,99 @@
|
||||
const URL = "/one-api/mockup/masterdata/accounting/";
|
||||
|
||||
export async function getListing(prm) {
|
||||
try {
|
||||
var resp = await axios.post(URL + 'mdcategory/listcategory', prm);
|
||||
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 gettype(token, prm) {
|
||||
try {
|
||||
var resp = await axios.post(URL + 'mdcategory/gettype', {
|
||||
token: token,
|
||||
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 deleteCategory(prm) {
|
||||
try {
|
||||
var resp = await axios.post(URL + 'mdcategory/deleteCategory', prm);
|
||||
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 saveCategory(prm) {
|
||||
try {
|
||||
var resp = await axios.post(URL + 'mdcategory/addCategory', prm);
|
||||
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 updateCategory(prm) {
|
||||
try {
|
||||
var resp = await axios.post(URL + 'mdcategory/editCategory', prm);
|
||||
if (resp.status != 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: error.message
|
||||
};
|
||||
}
|
||||
let data = resp.data;
|
||||
return data;
|
||||
} catch (error) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: error.message
|
||||
};
|
||||
}
|
||||
}
|
||||
189
test/vuex/acc-one-md-item-category/components/detail.vue
Normal file
189
test/vuex/acc-one-md-item-category/components/detail.vue
Normal file
@@ -0,0 +1,189 @@
|
||||
<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 ITEM CATEGORY
|
||||
<v-flex text-md-right pa-1>
|
||||
<span @click="addType()" 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 xs6 pa-1>
|
||||
<v-text-field v-model="xcategory" hide-details label="Nama Kategori"></v-text-field>
|
||||
<p v-if="checkErrorForm('requirenamecategory')" class="error pl-2 pr-2" style="color:#fff">Nama kategori harus diisi</p>
|
||||
</v-flex>
|
||||
<v-flex xs6 pa-1>
|
||||
<v-autocomplete label="Type" :items="xtypelist" v-model="selected_type"
|
||||
:search-input.sync="search_item_type" hide-details
|
||||
auto-select-first no-filter item-text="Rk_TypeName" return-object
|
||||
:loading="isLoading" no-data-text="Pilih Type">
|
||||
<template slot="item" slot-scope="{ item }">
|
||||
<v-list-tile-content>
|
||||
<v-list-tile-title v-text="item.Rk_TypeName"></v-list-tile-title>
|
||||
<v-list-tile-sub-title v-text="item.Rk_TypeCode"></v-list-tile-sub-title>
|
||||
</v-list-tile-content>
|
||||
</template>
|
||||
</v-autocomplete>
|
||||
<p v-if="checkErrorForm('requiretype')" class="error pl-2 pr-2" style="color:#fff">Type harus dipilih</p>
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
<v-layout row>
|
||||
<v-flex pa-1 text-md-right>
|
||||
<v-btn small color="error" @click="deleteCategory()">Hapus</v-btn>
|
||||
<v-btn small v-if="xact === 'new'" color="primary" @click="saveCategory()">Simpan</v-btn>
|
||||
<v-btn small v-if="xact === 'edit'" color="primary" @click="saveEditCategory()">Simpan Perubahan</v-btn>
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
</v-card>
|
||||
</v-layout>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
module.exports = {
|
||||
data: () => ({
|
||||
search_item_type: "",
|
||||
}),
|
||||
mounted() {
|
||||
this.$store.dispatch("rktype/gettype", this.search_item_type);
|
||||
},
|
||||
computed: {
|
||||
selected_type: {
|
||||
get() {
|
||||
return this.$store.state.rktype.selected_type;
|
||||
},
|
||||
set(data) {
|
||||
this.$store.commit('rktype/update_selected_type', data)
|
||||
}
|
||||
},
|
||||
snackbar: {
|
||||
get() {
|
||||
return this.$store.state.rktype.snackbar;
|
||||
},
|
||||
set(bool) {
|
||||
this.$store.commit("rktype/open_snackbar", bool)
|
||||
}
|
||||
},
|
||||
msgsnackbar() {
|
||||
return this.$store.state.rktype.message_snack;
|
||||
},
|
||||
xact: {
|
||||
get() {
|
||||
return this.$store.state.rktype.act;
|
||||
},
|
||||
set(data) {
|
||||
this.$store.commit('rktype/update_act', data)
|
||||
}
|
||||
},
|
||||
xtypelist() {
|
||||
return this.$store.state.rktype.typelist;
|
||||
},
|
||||
isLoading() {
|
||||
return this.$store.state.rktype.status_get == 1;
|
||||
},
|
||||
selected_category: {
|
||||
get() {
|
||||
return this.$store.state.rktype.selected_category;
|
||||
},
|
||||
set(data) {
|
||||
this.$store.commit('rktype/update_selected_category', data)
|
||||
}
|
||||
},
|
||||
xcategory: {
|
||||
get() {
|
||||
return this.$store.state.rktype.xcategory;
|
||||
},
|
||||
set(data) {
|
||||
this.$store.commit('rktype/update_xcategory', data)
|
||||
}
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
checkErrorForm(value) {
|
||||
var errors = this.$store.state.rktype.errors
|
||||
if (errors.includes(value)) {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
},
|
||||
deleteCategory() {
|
||||
let prm = {
|
||||
categoryid: this.selected_category.itemCategoryID,
|
||||
}
|
||||
this.$store.dispatch("rktype/delete", prm)
|
||||
},
|
||||
saveCategory() {
|
||||
this.$store.commit("rktype/update_errors", [])
|
||||
var errors = this.$store.state.rktype.errors
|
||||
if(_.isEmpty(this.xcategory)) {
|
||||
errors.push("requirenamecategory")
|
||||
}
|
||||
if(_.isEmpty(this.selected_type)) {
|
||||
errors.push("requiretype")
|
||||
}
|
||||
|
||||
if (errors.length === 0) {
|
||||
this.$store.commit("rktype/update_errors", [])
|
||||
let prm = {
|
||||
categoryname: this.xcategory,
|
||||
typeid: this.selected_type.Rk_TypeID
|
||||
}
|
||||
this.$store.dispatch("rktype/save", prm)
|
||||
}
|
||||
},
|
||||
saveEditCategory() {
|
||||
this.$store.commit("rktype/update_errors", [])
|
||||
var errors = this.$store.state.rktype.errors
|
||||
if(_.isEmpty(this.xcategory)) {
|
||||
errors.push("requirenamecategory")
|
||||
}
|
||||
if(_.isEmpty(this.selected_type)) {
|
||||
errors.push("requiretype")
|
||||
}
|
||||
|
||||
if (errors.length === 0) {
|
||||
this.$store.commit("rktype/update_errors", [])
|
||||
let prm = {
|
||||
categoryid: this.selected_category.itemCategoryID,
|
||||
categoryname: this.xcategory,
|
||||
typeid: this.selected_type.Rk_TypeID
|
||||
}
|
||||
this.$store.dispatch("rktype/update", prm)
|
||||
}
|
||||
},
|
||||
addType() {
|
||||
this.$store.commit("rktype/update_selected_type", {})
|
||||
this.$store.commit("rktype/update_xcategory", "")
|
||||
this.$store.commit("rktype/update_act", "new")
|
||||
},
|
||||
openSnackBar(bool) {
|
||||
this.$store.commit("rktype/update_message_snack", "");
|
||||
this.$store.commit("rktype/open_snackbar", bool);
|
||||
},
|
||||
thr_search_type: _.debounce(function () {
|
||||
this.$store.dispatch("rktype/gettype", this.search_item_type)
|
||||
}, 1000),
|
||||
},
|
||||
watch: {
|
||||
search_item_type(val, old) {
|
||||
if (val == old) return;
|
||||
if (!val) return;
|
||||
if (val.length < 1) return;
|
||||
if (this.$store.state.rktype.update_status_get == 1) return;
|
||||
this.thr_search_type();
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
164
test/vuex/acc-one-md-item-category/components/listing.vue
Normal file
164
test/vuex/acc-one-md-item-category/components/listing.vue
Normal file
@@ -0,0 +1,164 @@
|
||||
<template>
|
||||
<v-layout class="fill-height" column>
|
||||
<v-card>
|
||||
<v-layout row>
|
||||
<v-flex xs-12>
|
||||
<v-card-title>
|
||||
<span class="title">Daftar Item Category</span>
|
||||
<v-spacer></v-spacer>
|
||||
<v-text-field append-icon="search" label="Search" single-line hide-details v-model="xsearch"></v-text-field>
|
||||
</v-card-title>
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
<v-layout row>
|
||||
<v-flex xs-12 pl-2 pr-2 pt-2 pb-2>
|
||||
<v-data-table :headers="headers" :items="xcategorylist" :loading="isLoading" :pagination.sync="pagination" class="elevation-1">
|
||||
<template slot="items" slot-scope="props">
|
||||
<tr :class="{'amber lighten-4':isSelected(props.item)}" @click="selectType(props.item)">
|
||||
<td class="text-xs-center pa-2">{{ props.item.rownumber }}</td>
|
||||
<td class="text-xs-center pa-2">{{ props.item.itemCategoryName }}</td>
|
||||
<td class="text-xs-center pa-2">{{ props.item.Rk_TypeCode }}</td>
|
||||
<td class="text-xs-center pa-2">{{ props.item.Rk_TypeName }}</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("rktype/getList");
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
page: 1,
|
||||
pagination: {
|
||||
descending: false,
|
||||
page: 1,
|
||||
rowsPerPage: 5,
|
||||
sortBy: 'rownumber',
|
||||
totalItems: this.$store.state.rktype.categorylist,
|
||||
},
|
||||
headers: [
|
||||
{
|
||||
text: "NO",
|
||||
align: "center",
|
||||
sortable: false,
|
||||
value: "no",
|
||||
width: "10%",
|
||||
class: "pa-2 blue lighten-3 white--text"
|
||||
},
|
||||
{
|
||||
text: "KATEGORI ITEM",
|
||||
align: "center",
|
||||
sortable: false,
|
||||
value: "no",
|
||||
width: "30%",
|
||||
class: "pa-2 blue lighten-3 white--text"
|
||||
},
|
||||
{
|
||||
text: "KODE TYPE",
|
||||
align: "center",
|
||||
sortable: false,
|
||||
value: "no",
|
||||
width: "30%",
|
||||
class: "pa-2 blue lighten-3 white--text"
|
||||
},
|
||||
{
|
||||
text: "NAMA TYPE",
|
||||
align: "center",
|
||||
sortable: false,
|
||||
value: "no",
|
||||
width: "30%",
|
||||
class: "pa-2 blue lighten-3 white--text"
|
||||
},
|
||||
]
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
xtypelist() {
|
||||
return this.$store.state.rktype.typelist;
|
||||
},
|
||||
selected_type: {
|
||||
get() {
|
||||
return this.$store.state.rktype.selected_type;
|
||||
},
|
||||
set(data) {
|
||||
this.$store.commit('rktype/update_selected_type', data)
|
||||
}
|
||||
},
|
||||
xcategorylist() {
|
||||
return this.$store.state.rktype.categorylist;
|
||||
},
|
||||
selected_category: {
|
||||
get() {
|
||||
return this.$store.state.rktype.selected_category;
|
||||
},
|
||||
set(data) {
|
||||
this.$store.commit('rktype/update_selected_category', data)
|
||||
}
|
||||
},
|
||||
isLoading() {
|
||||
return this.$store.state.rktype.status_get == 1;
|
||||
},
|
||||
xsearch: {
|
||||
get() {
|
||||
return this.$store.state.rktype.search;
|
||||
},
|
||||
set(data) {
|
||||
this.$store.commit('rktype/update_search', data)
|
||||
}
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
isSelected(row) {
|
||||
return row.itemCategoryID == this.$store.state.rktype.selected_category.itemCategoryID
|
||||
},
|
||||
selectType(selected) {
|
||||
this.$store.commit('rktype/update_selected_category', selected);
|
||||
this.$store.commit('rktype/update_xcategory', selected.itemCategoryName);
|
||||
this.$store.commit('rktype/update_typelist', [{
|
||||
Rk_TypeID: selected.Rk_TypeID,
|
||||
Rk_TypeCode: selected.Rk_TypeCode,
|
||||
Rk_TypeName: selected.Rk_TypeName
|
||||
}]);
|
||||
this.$store.commit('rktype/update_selected_type', {
|
||||
Rk_TypeID: selected.Rk_TypeID,
|
||||
Rk_TypeCode: selected.Rk_TypeCode,
|
||||
Rk_TypeName: selected.Rk_TypeName
|
||||
});
|
||||
this.$store.commit("rktype/update_errors", [])
|
||||
this.$store.commit("rktype/update_act", "edit")
|
||||
},
|
||||
thr_search: _.debounce(function () {
|
||||
this.$store.dispatch("rktype/getList")
|
||||
}, 500),
|
||||
},
|
||||
watch: {
|
||||
xsearch(val, old) {
|
||||
this.xsearch = val
|
||||
this.thr_search()
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
73
test/vuex/acc-one-md-item-category/index.php
Normal file
73
test/vuex/acc-one-md-item-category/index.php
Normal file
@@ -0,0 +1,73 @@
|
||||
<!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-type-list></one-md-type-list>
|
||||
</v-flex>
|
||||
<v-flex xs6 class="right" fill-height pa-1>
|
||||
<one-md-type-detail></one-md-type-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-type-list': httpVueLoader('./components/listing.vue'),
|
||||
'one-md-type-detail': httpVueLoader('./components/detail.vue'),
|
||||
}
|
||||
})
|
||||
</script>
|
||||
<style>
|
||||
[v-cloak] {
|
||||
display: none;
|
||||
}
|
||||
</style>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
202
test/vuex/acc-one-md-item-category/modules/rktype.js
Normal file
202
test/vuex/acc-one-md-item-category/modules/rktype.js
Normal file
@@ -0,0 +1,202 @@
|
||||
// 1 => LOADING
|
||||
// 2 => DONE
|
||||
// 3 => ERROR
|
||||
import * as api from "../api/rktype.js"
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {
|
||||
typelist: [],
|
||||
total_listtype: 0,
|
||||
status_get: 0,
|
||||
selected_type: {},
|
||||
snackbar: false,
|
||||
message_snack: "",
|
||||
errors: [],
|
||||
save_status: 0,
|
||||
act: "new",
|
||||
search: "",
|
||||
categorylist: [],
|
||||
total_categorylist: 0,
|
||||
selected_category: {},
|
||||
xcategory: ""
|
||||
},
|
||||
mutations: {
|
||||
update_selected_type(state, data) {
|
||||
state.selected_type = data
|
||||
},
|
||||
update_total_listtype(state, data) {
|
||||
state.total_listtype = data
|
||||
},
|
||||
update_typelist(state, data) {
|
||||
state.typelist = 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
|
||||
},
|
||||
update_errors(state, val) {
|
||||
state.errors = val
|
||||
},
|
||||
update_save_status(state, val) {
|
||||
state.save_status = val
|
||||
},
|
||||
update_act(state, val) {
|
||||
state.act = val
|
||||
},
|
||||
update_search(state, val) {
|
||||
state.search = val
|
||||
},
|
||||
update_categorylist(state, val) {
|
||||
state.categorylist = val
|
||||
},
|
||||
update_total_categorylist(state, val) {
|
||||
state.total_categorylist = val
|
||||
},
|
||||
update_selected_category(state, val) {
|
||||
state.selected_category = val
|
||||
},
|
||||
update_xcategory(state, val) {
|
||||
state.xcategory = val
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
async getList(context) {
|
||||
context.commit("update_status_get", 1);
|
||||
try {
|
||||
var prm = {token: one_token(), search: context.state.search};
|
||||
let resp = await api.getListing(prm);
|
||||
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
|
||||
}
|
||||
context.commit("update_categorylist", data.records);
|
||||
context.commit("update_total_categorylist", data.total);
|
||||
}
|
||||
} catch (error) {
|
||||
context.commit("update_status_get", 3);
|
||||
context.commit("update_message_snack", error.message);
|
||||
context.commit("open_snackbar", true);
|
||||
}
|
||||
},
|
||||
|
||||
async gettype(context, prm) {
|
||||
context.commit("update_status_get", 1);
|
||||
try {
|
||||
let resp = await api.gettype(one_token(), prm)
|
||||
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);
|
||||
context.commit("update_message_snack", resp.message);
|
||||
let data = {
|
||||
records: resp.data.records
|
||||
}
|
||||
|
||||
context.commit("update_typelist", data.records)
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_status_get", 3);
|
||||
context.commit("update_message_snack", error.message);
|
||||
context.commit("open_snackbar", true);
|
||||
}
|
||||
},
|
||||
|
||||
async delete(context, prm) {
|
||||
context.commit("update_save_status", 1);
|
||||
try {
|
||||
prm.token = one_token();
|
||||
let resp = await api.deleteCategory(prm);
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_save_status", 3);
|
||||
context.commit("open_snackbar", true);
|
||||
context.commit("update_message_snack", resp.message);
|
||||
} else {
|
||||
context.commit("update_save_status", 3);
|
||||
context.commit("update_message_snack", resp.message);
|
||||
|
||||
context.commit("open_snackbar", true);
|
||||
var msg = "Berhasil menghapus data kategori";
|
||||
context.commit("update_message_snack", msg);
|
||||
context.commit("update_selected_type", {});
|
||||
context.commit("update_xcategory", "");
|
||||
context.dispatch("getList");
|
||||
}
|
||||
} catch (error) {
|
||||
context.commit("update_save_status", 3);
|
||||
context.commit("update_message_snack", error.message);
|
||||
context.commit("open_snackbar", true);
|
||||
}
|
||||
},
|
||||
|
||||
async save(context, prm) {
|
||||
context.commit("update_save_status", 1);
|
||||
try {
|
||||
prm.token = one_token();
|
||||
let resp = await api.saveCategory(prm);
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_save_status", 3);
|
||||
context.commit("open_snackbar", true);
|
||||
context.commit("update_message_snack", resp.message);
|
||||
} else {
|
||||
context.commit("update_save_status", 2);
|
||||
context.commit("update_message_snack", resp.message);
|
||||
|
||||
|
||||
context.commit("open_snackbar", true);
|
||||
var msg = "Berhasil menyimpan data kategori";
|
||||
context.commit("update_message_snack", msg);
|
||||
context.commit("update_selected_type", {});
|
||||
context.commit("update_xcategory", "");
|
||||
context.commit("update_errors", []);
|
||||
context.dispatch("getList");
|
||||
}
|
||||
} catch (error) {
|
||||
context.commit("update_save_status", 3);
|
||||
context.commit("update_message_snack", error.message);
|
||||
context.commit("open_snackbar", true);
|
||||
}
|
||||
},
|
||||
|
||||
async update(context, prm) {
|
||||
context.commit("update_save_status", 1);
|
||||
try {
|
||||
prm.token = one_token()
|
||||
let resp = await api.updateCategory(prm);
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_save_status", 3);
|
||||
context.commit("open_snackbar", true);
|
||||
context.commit("update_message_snack", resp.message);
|
||||
} else {
|
||||
context.commit("update_save_status", 2);
|
||||
context.commit("update_message_snack", resp.message);
|
||||
|
||||
context.commit("open_snackbar", true);
|
||||
var msg = "Berhasil menyimpan data kategori";
|
||||
context.commit("update_message_snack", msg);
|
||||
context.commit("update_selected_type", {});
|
||||
context.commit("update_xcategory", "");
|
||||
context.commit("update_errors", []);
|
||||
context.dispatch("getList");
|
||||
}
|
||||
} catch (error) {
|
||||
context.commit("update_save_status", 3);
|
||||
context.commit("update_message_snack", error.message);
|
||||
context.commit("open_snackbar", true);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
17
test/vuex/acc-one-md-item-category/store.js
Normal file
17
test/vuex/acc-one-md-item-category/store.js
Normal file
@@ -0,0 +1,17 @@
|
||||
import rktype from "./modules/rktype.js";
|
||||
import system from "../../../apps/modules/system/system.js";
|
||||
export const store = new Vuex.Store({
|
||||
modules: {
|
||||
rktype: rktype,
|
||||
system: system
|
||||
},
|
||||
state: {
|
||||
|
||||
},
|
||||
mutations: {
|
||||
|
||||
},
|
||||
actions: {
|
||||
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user