add modules folder based on s_menu
This commit is contained in:
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>
|
||||
Reference in New Issue
Block a user