add modules folder based on s_menu
This commit is contained in:
80
test/vuex/acc-one-md-itemunit/api/unit.js
Normal file
80
test/vuex/acc-one-md-itemunit/api/unit.js
Normal file
@@ -0,0 +1,80 @@
|
||||
// const URL = "/one-api/v1/masterdata/";
|
||||
const URL = "/one-api/mockup/masterdata/accounting/";
|
||||
|
||||
export async function lookupbyname(prm) {
|
||||
try {
|
||||
var resp = await axios.post(URL + 'itemunit/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 add(prm) {
|
||||
try {
|
||||
var resp = await axios.post(URL + 'itemunit/add', 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,id) {
|
||||
try {
|
||||
var resp = await axios.post(URL + 'itemunit/delete',
|
||||
{ id: id, 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
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// edit
|
||||
export async function edit(prm) {
|
||||
try {
|
||||
var resp = await axios.post(URL + 'itemunit/edit', 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
|
||||
};
|
||||
}
|
||||
}
|
||||
539
test/vuex/acc-one-md-itemunit/components/oneMdItemUnit.vue
Normal file
539
test/vuex/acc-one-md-itemunit/components/oneMdItemUnit.vue
Normal file
@@ -0,0 +1,539 @@
|
||||
<template>
|
||||
<v-layout>
|
||||
|
||||
<!-- alert -->
|
||||
<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>
|
||||
{{ msgalert }}
|
||||
</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>
|
||||
<!-- alert -->
|
||||
|
||||
<!-- form -->
|
||||
<v-dialog v-model="dialogunit" persistent max-width="600px">
|
||||
<v-card>
|
||||
<v-card-title>
|
||||
<span class="title">Form Unit</span></v-card-title>
|
||||
<v-card-text class="pt-0 pb-0">
|
||||
<v-form ref="formunit" v-model="valid" lazy-validation>
|
||||
<v-layout wrap>
|
||||
<v-flex xs12>
|
||||
<v-text-field v-model="xname" label="Nama*" :rules="xnameRules" required></v-text-field>
|
||||
</v-flex>
|
||||
<v-flex>
|
||||
<p v-for="(xerror, idx) in xerrors" class="error pl-2 pr-2" style="color:#fff">
|
||||
{{ xerror.msg }}</p>
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
</v-card-text>
|
||||
<v-card-actions>
|
||||
<v-spacer></v-spacer>
|
||||
<v-btn color="error" flat @click="updateDialogFormUnit()">Tutup</v-btn>
|
||||
<v-btn v-if="xact === 'new'" color="primary" @click="saveFormUnit()">Simpan</v-btn>
|
||||
<v-btn v-if="xact === 'edit'" color="primary" @click="updateFormUnit()">Simpan
|
||||
Perubahan</v-btn>
|
||||
</v-card-actions>
|
||||
</v-form>
|
||||
</v-card>
|
||||
</v-dialog>
|
||||
<!-- form -->
|
||||
|
||||
<v-flex xs12>
|
||||
|
||||
<v-card>
|
||||
<!-- <v-toolbar color="blue darken-1" dark scroll-off-screen scroll-target="#scrolling-techniques">
|
||||
|
||||
<v-btn @click="openFormUnit(0)" icon>
|
||||
<v-icon>library_add</v-icon>
|
||||
</v-btn>
|
||||
<v-toolbar-title class="headline font-weight-bold">Master Unit</v-toolbar-title>
|
||||
<v-spacer></v-spacer> -->
|
||||
<!-- search -->
|
||||
<!-- <div>
|
||||
<v-text-field v-model="xsearch" append-icon="search" label="Search" single-line
|
||||
hide-details></v-text-field>
|
||||
</div> -->
|
||||
<!-- search -->
|
||||
<!-- </v-toolbar> -->
|
||||
|
||||
<!-- Toolbar -->
|
||||
<v-toolbar color="blue lighten-3" dark scroll-off-screen scroll-target="#scrolling-techniques">
|
||||
|
||||
<v-toolbar-title class="headline font-weight-bold">Master Data Unit</v-toolbar-title>
|
||||
<v-spacer></v-spacer>
|
||||
<v-btn class="text-xs-right" @click="openFormUnit(0)" icon><v-icon>library_add</v-icon></v-btn>
|
||||
</v-toolbar>
|
||||
<!-- End Toolbar -->
|
||||
|
||||
<div id="scrolling-techniques" class="scroll-y" :style="{ 'height': windowHeight }">
|
||||
|
||||
<!-- search -->
|
||||
<v-card elevation="0">
|
||||
<v-card-text>
|
||||
<v-layout row>
|
||||
<v-flex xs3>
|
||||
<v-text-field v-model="xsearch" label="Search"
|
||||
placeholder="Cari kode atau nama unit" outline hide-details></v-text-field>
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
</v-card-text>
|
||||
</v-card>
|
||||
<!-- search -->
|
||||
<v-divider></v-divider>
|
||||
|
||||
<v-data-table :headers="headers" :items="vitemunits" :loading="isLoading" hide-actions>
|
||||
<template v-slot:headers="props">
|
||||
<tr>
|
||||
<th v-for="header in props.headers" :key="header.text"
|
||||
@click="changeSort(header.value, pagination.descending, header)"
|
||||
:width="header.width"
|
||||
:align="header.align"
|
||||
:class="header.class">
|
||||
<!-- <v-icon v-if="pagination.descending === 'asc'" small>arrow_upward</v-icon>
|
||||
<v-icon v-if="pagination.descending === 'desc'" small>arrow_downward</v-icon> -->
|
||||
|
||||
<v-icon color="grey lighten-2" v-if="
|
||||
pagination.sortBy === header.value &&
|
||||
header.sort && pagination.descending === 'asc'" small>arrow_downward</v-icon>
|
||||
<v-icon color="grey lighten-2" v-if="
|
||||
pagination.sortBy === header.value &&
|
||||
header.sort && pagination.descending === 'desc'" small>arrow_upward</v-icon>
|
||||
|
||||
<v-icon color="grey lighten-2" v-if="pagination.sortBy !== header.value &&
|
||||
header.sort" small>arrow_upward</v-icon>
|
||||
|
||||
{{ header.text }}
|
||||
</th>
|
||||
</tr>
|
||||
</template>
|
||||
<v-progress-linear v-slot:progress color="blue" indeterminate></v-progress-linear>
|
||||
<template v-slot:items="props">
|
||||
<td class="text-xs-center pa-2" v-bind:class="{ 'amber lighten-4': isSelected(props.item) }"
|
||||
@click="selectMe(props.item)">{{ props.item.ItemUnitCode }}</td>
|
||||
<td class="text-xs-left pa-2" v-bind:class="{ 'amber lighten-4': isSelected(props.item) }"
|
||||
@click="selectMe(props.item)">{{ props.item.ItemUnitName }}</td>
|
||||
<td class="text-xs-center pa-2" v-bind:class="{ 'amber lighten-4': isSelected(props.item) }"
|
||||
@click="selectMe(props.item)">
|
||||
<v-tooltip bottom>
|
||||
<template v-slot:activator="{ on, attrs }">
|
||||
<v-icon v-bind="attrs" v-on="on" small class="ml-3" @click="editUnit(props.item)">edit</v-icon>
|
||||
</template>
|
||||
<span>Edit</span>
|
||||
</v-tooltip>
|
||||
<v-tooltip bottom>
|
||||
<template v-slot:activator="{ on, attrs }">
|
||||
<v-icon v-bind="attrs" v-on="on" small class="ml-3" @click="deleteUnit(props.item)">delete</v-icon>
|
||||
</template>
|
||||
<span>Delete</span>
|
||||
</v-tooltip>
|
||||
<!-- <v-toolbar flat dense>
|
||||
<v-btn @click="editUnit(props.item)" small color="primary" dark>ubah <v-icon small
|
||||
right dark>edit</v-icon></v-btn>
|
||||
<v-divider vertical></v-divider>
|
||||
<v-btn small @click="deleteUnit(props.item)" color="danger" dark>hapus <v-icon small
|
||||
right dark>clear</v-icon></v-btn>
|
||||
</v-toolbar> -->
|
||||
</td>
|
||||
</template>
|
||||
<template v-slot:no-results>
|
||||
<v-alert :value="true" color="error" icon="warning">
|
||||
Pencarian "{{ xsearch }}" tiada hasil.
|
||||
</v-alert>
|
||||
</template>
|
||||
</v-data-table>
|
||||
</div>
|
||||
<v-divider></v-divider>
|
||||
<v-flex xs12 class="text-xs-left pt-3 pb-3">
|
||||
<v-pagination v-model="curr_page" :length="xtotal_page"></v-pagination>
|
||||
</v-flex>
|
||||
</v-card>
|
||||
</v-flex>
|
||||
|
||||
</v-layout>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.searchbox .v-input.v-text-field .v-input__slot {
|
||||
min-height: 60px;
|
||||
}
|
||||
|
||||
.searchbox .v-btn {
|
||||
min-height: 60px;
|
||||
}
|
||||
|
||||
table.v-table tbody td,
|
||||
table.v-table tbody th {
|
||||
height: 40px;
|
||||
}
|
||||
|
||||
table.v-table thead tr {
|
||||
height: 40px;
|
||||
}
|
||||
|
||||
.textinput {
|
||||
-webkit-transition: width 0.4s ease-in-out;
|
||||
transition: width 0.4s ease-in-out;
|
||||
background-color: white;
|
||||
background-position: 10px 10px;
|
||||
background-repeat: no-repeat;
|
||||
padding-left: 40px;
|
||||
width: 100%;
|
||||
padding: 8px 10px;
|
||||
margin-bottom: 5px;
|
||||
box-sizing: border-box;
|
||||
border: 1px solid #607d8b;
|
||||
|
||||
}
|
||||
|
||||
.textinput:focus {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.textinput:focus::-webkit-input-placeholder {
|
||||
color: transparent;
|
||||
}
|
||||
|
||||
.textinput:focus::-moz-placeholder {
|
||||
color: transparent;
|
||||
}
|
||||
|
||||
.textinput:-moz-placeholder {
|
||||
color: transparent;
|
||||
}
|
||||
|
||||
.boxoutline {
|
||||
color: red;
|
||||
border: 1px solid red;
|
||||
justify-content: center;
|
||||
height: 45px;
|
||||
line-height: 45px;
|
||||
padding-left: 10px;
|
||||
background: #ffffff;
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
border-radius: 1px
|
||||
}
|
||||
|
||||
.boxoutline:hover {
|
||||
background: rgba(0, 0, 0, 0.07) !important;
|
||||
font-size: 15px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.boxsolid {
|
||||
color: #ffffff;
|
||||
border: 1px solid #ffffff;
|
||||
justify-content: center;
|
||||
height: 45px;
|
||||
line-height: 45px;
|
||||
padding-left: 10px;
|
||||
background: #f44336;
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
border-radius: 1px
|
||||
}
|
||||
|
||||
.boxsolid:hover {
|
||||
background: #f44336de;
|
||||
font-size: 15px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.scroll-container {
|
||||
scroll-padding: 50px 0 0 50px;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar {
|
||||
width: 7px;
|
||||
}
|
||||
|
||||
/* this targets the default scrollbar (compulsory) */
|
||||
|
||||
::-webkit-scrollbar-track {
|
||||
background-color: #73baf3;
|
||||
}
|
||||
|
||||
/* the new scrollbar will have a flat appearance with the set background color */
|
||||
|
||||
::-webkit-scrollbar-thumb {
|
||||
background-color: #2196f3;
|
||||
}
|
||||
|
||||
/* this will style the thumb, ignoring the track */
|
||||
|
||||
::-webkit-scrollbar-button {
|
||||
background-color: #0079da;
|
||||
}
|
||||
|
||||
/* optionally, you can style the top and the bottom buttons (left and right for horizontal bars) */
|
||||
|
||||
::-webkit-scrollbar-corner {
|
||||
background-color: black;
|
||||
}
|
||||
|
||||
/* if both the vertical and the horizontal bars appear, then perhaps the right bottom corner also needs to be styled */
|
||||
</style>
|
||||
|
||||
<script>
|
||||
module.exports = {
|
||||
data() {
|
||||
return {
|
||||
windowHeight: window.innerHeight - 300 + 'px',
|
||||
page: 1,
|
||||
dialogdeletealert: false,
|
||||
msgalert: "",
|
||||
xname: '',
|
||||
valid: false,
|
||||
xid: 0,
|
||||
isDefault: false,
|
||||
xnameRules: [
|
||||
v => !!v || 'Nama harus diisi'
|
||||
],
|
||||
headers: [{
|
||||
text: "KODE",
|
||||
align: "left",
|
||||
sortable: false,
|
||||
sort: true,
|
||||
value: "ItemUnitCode",
|
||||
width: "10%",
|
||||
class: "pa-2 blue lighten-3 white--text"
|
||||
},
|
||||
{
|
||||
text: "NAMA",
|
||||
align: "left",
|
||||
sortable: false,
|
||||
sort: true,
|
||||
value: "ItemUnitName",
|
||||
width: "80%",
|
||||
class: "pa-2 blue lighten-3 white--text"
|
||||
},
|
||||
{
|
||||
text: "AKSI",
|
||||
align: "center",
|
||||
sortable: false,
|
||||
value: "mr",
|
||||
width: "10%",
|
||||
class: "pa-2 blue lighten-3 white--text"
|
||||
}
|
||||
],
|
||||
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
// ambil data
|
||||
this.$store.commit("unit/update_last_id", -1)
|
||||
this.$store.dispatch("unit/lookupbyname")
|
||||
},
|
||||
computed: {
|
||||
// list data masuk ke objek vkelurahans
|
||||
vitemunits() {
|
||||
return this.$store.state.unit.units
|
||||
},
|
||||
|
||||
// paging
|
||||
pagination: {
|
||||
get() {
|
||||
return this.$store.state.unit.pagination
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("unit/update_pagination", val)
|
||||
}
|
||||
},
|
||||
// current page
|
||||
curr_page: {
|
||||
get() {
|
||||
return this.$store.state.unit.current_page
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("unit/update_current_page", val)
|
||||
this.$store.commit("unit/update_last_id", -1)
|
||||
this.$store.dispatch("unit/lookupbyname")
|
||||
}
|
||||
},
|
||||
|
||||
// wkt search
|
||||
xsearch: {
|
||||
get() {
|
||||
return this.$store.state.unit.x_search
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("unit/update_x_search", val)
|
||||
}
|
||||
},
|
||||
|
||||
xtotal_page: {
|
||||
get() {
|
||||
return this.$store.state.unit.total_units
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("unit/update_total_units", val)
|
||||
}
|
||||
},
|
||||
|
||||
xact() {
|
||||
return this.$store.state.unit.act
|
||||
},
|
||||
|
||||
// handle error
|
||||
xerrors() {
|
||||
return this.$store.state.unit.errors
|
||||
},
|
||||
|
||||
dialogunit() {
|
||||
return this.$store.state.unit.dialog_form_unit
|
||||
},
|
||||
|
||||
isLoading() {
|
||||
return this.$store.state.unit.search_status == 1
|
||||
},
|
||||
|
||||
// filter
|
||||
xtotalunits() {
|
||||
return this.$store.state.unit.total_units
|
||||
},
|
||||
xtotalfilterunits() {
|
||||
return this.$store.state.unit.total_filter_units
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
// click sort order by
|
||||
changeSort(value, sort, header) {
|
||||
if (header.sort) {
|
||||
var newVal = value
|
||||
var newSort = sort == 'asc' ? 'desc' : 'asc'
|
||||
if (newVal !== this.pagination.sortBy)
|
||||
newSort = 'asc'
|
||||
this.pagination = { descending: newSort, sortBy: newVal }
|
||||
// console.log(this.pagination)
|
||||
this.$store.commit("unit/update_last_id", -1)
|
||||
this.$store.dispatch("unit/lookupbyname")
|
||||
}
|
||||
},
|
||||
|
||||
// tutup dialog
|
||||
updateDialogFormUnit() {
|
||||
this.$store.commit("unit/update_dialog_form_unit", false)
|
||||
},
|
||||
|
||||
// open form
|
||||
openFormUnit() {
|
||||
console.log('open dialog');
|
||||
this.xname = ""
|
||||
this.isdefault = "N"
|
||||
this.$refs.formunit.reset()
|
||||
this.$refs.formunit.resetValidation()
|
||||
this.$store.commit("unit/update_act", 'new')
|
||||
this.$store.commit("unit/update_dialog_form_unit", true)
|
||||
},
|
||||
|
||||
// save form
|
||||
saveFormUnit() {
|
||||
if (this.$refs.formunit.validate()) {
|
||||
this.$store.dispatch("unit/add", {
|
||||
unit_name: this.xname
|
||||
})
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
// hapus
|
||||
deleteUnit(data) {
|
||||
this.xid = data.ItemUnitID
|
||||
console.log(data);
|
||||
var xdata = {
|
||||
id: data.ItemUnitID,
|
||||
name: data.ItemUnitName,
|
||||
}
|
||||
this.$store.commit("unit/update_selected_unit", xdata)
|
||||
this.msgalert = "Yakin, mau hapus item unit " + data.ItemUnitName + " ?"
|
||||
this.dialogdeletealert = true
|
||||
},
|
||||
|
||||
closeDeleteAlert() {
|
||||
this.$store.commit("unit/update_last_id", -1);
|
||||
this.$store.dispatch("unit/delete", {
|
||||
id: this.$store.state.unit.selected_unit.id,
|
||||
name: this.$store.state.unit.selected_unit.name,
|
||||
})
|
||||
this.dialogdeletealert = false
|
||||
},
|
||||
|
||||
// hover biru2
|
||||
isSelected(p) {
|
||||
return p.ItemUnitID == this.$store.state.unit.selected_unit.ItemUnitID
|
||||
},
|
||||
selectMe(selected) {
|
||||
this.$store.commit("unit/update_selected_unit", selected)
|
||||
this.$store.commit("unit/update_last_id", selected.ItemUnitID)
|
||||
},
|
||||
// edit
|
||||
editUnit(data) {
|
||||
this.selectMe(data)
|
||||
|
||||
this.xid = data.ItemUnitID
|
||||
// this.xcode = data.code
|
||||
this.xname = data.ItemUnitName
|
||||
// this.isdefault = data.T_SpecialistIsDefault === 'N' ? false : true
|
||||
this.$store.commit("unit/update_act", 'edit')
|
||||
this.$store.commit("unit/update_dialog_form_unit", true)
|
||||
},
|
||||
|
||||
// proses edit
|
||||
updateFormUnit() {
|
||||
if (this.$refs.formunit.validate()) {
|
||||
this.$store.dispatch("unit/edit", {
|
||||
id: this.xid,
|
||||
unit_name: this.xname
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
// alert
|
||||
updateAlert_success(val) {
|
||||
this.$store.commit("unit/update_alert_success", val)
|
||||
},
|
||||
|
||||
// search
|
||||
thr_search: _.debounce(function () {
|
||||
this.$store.commit("unit/update_last_id", -1)
|
||||
this.$store.dispatch("unit/lookupbyname")
|
||||
|
||||
}, 1000)
|
||||
},
|
||||
watch: {
|
||||
xsearch(val, old) {
|
||||
// console.log(val)
|
||||
this.xsearch = val
|
||||
this.thr_search()
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
70
test/vuex/acc-one-md-itemunit/index.php
Normal file
70
test/vuex/acc-one-md-itemunit/index.php
Normal file
@@ -0,0 +1,70 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<title>One</title>
|
||||
<link rel="stylesheet" href="../../../libs/vendor/css/google-fonts.css">
|
||||
<link rel="stylesheet" href="../../../libs/vendor/css/vuetify.min.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div v-cloak id="app">
|
||||
<v-app id="smartApp" >
|
||||
<one-navbar></one-navbar>
|
||||
<v-content class="blue lighten-5" >
|
||||
<v-container fluid fill-height class="pl-1 pr-1 pt-2 pb-2">
|
||||
<v-layout row wrap >
|
||||
<v-flex xs12 class="left" fill-height pa-1>
|
||||
<one-md-itemunit></one-md-itemunit>
|
||||
</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">
|
||||
import { store } from './store.js<?php echo $ts ?>';
|
||||
//for testing
|
||||
window.store = store;
|
||||
new Vue({
|
||||
store,
|
||||
el: '#app',
|
||||
components: {
|
||||
'one-navbar': httpVueLoader('../../../apps/components/oneNavbarComponent.vue'),
|
||||
'one-footer': httpVueLoader('../../../apps/components/oneFooter.vue'),
|
||||
'one-md-itemunit': httpVueLoader('./components/oneMdItemUnit.vue')
|
||||
}
|
||||
})
|
||||
</script>
|
||||
<style>
|
||||
[v-cloak] {
|
||||
display: none
|
||||
}
|
||||
.left {
|
||||
}
|
||||
.right {
|
||||
}
|
||||
</style>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
254
test/vuex/acc-one-md-itemunit/modules/unit.js
Normal file
254
test/vuex/acc-one-md-itemunit/modules/unit.js
Normal file
@@ -0,0 +1,254 @@
|
||||
// 1 => LOADING
|
||||
// 2 => DONE
|
||||
// 3 => ERROR
|
||||
import * as api from "../api/unit.js"
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {
|
||||
lookup_error_message:'',
|
||||
lookup_unit:0,
|
||||
units:[],
|
||||
total_units:0,
|
||||
total_filter_units:0,
|
||||
current_page:1,
|
||||
x_search: '',
|
||||
autocomplete_status: 0,
|
||||
pagination:{
|
||||
descending:'asc',
|
||||
sortBy:'ItemUnitCode'
|
||||
},
|
||||
search_status: false,
|
||||
|
||||
dialog_form_unit: false,
|
||||
alert_success: false,
|
||||
msg_success: "",
|
||||
show_all: 'N',
|
||||
errors: [],
|
||||
act: 'new',
|
||||
|
||||
selected_unit: {
|
||||
name: ""
|
||||
},
|
||||
save_status: 0,
|
||||
save_error_message: '',
|
||||
},
|
||||
mutations: {
|
||||
update_lookup_error_message(state, status) {
|
||||
state.lookup_error_message = status
|
||||
},
|
||||
update_lookup_unit(state, status) {
|
||||
state.lookup_unit = status
|
||||
},
|
||||
|
||||
update_units(state, data) {
|
||||
state.units = data.records
|
||||
state.total_units = data.total
|
||||
state.total_filter_units = data.total_filter
|
||||
},
|
||||
|
||||
update_current_page(state, val) {
|
||||
state.current_page = val
|
||||
},
|
||||
|
||||
update_autocomplete_status(state, val) {
|
||||
state.autocomplete_status = val
|
||||
},
|
||||
|
||||
update_last_id(state, val) {
|
||||
state.last_id = val
|
||||
},
|
||||
|
||||
update_pagination(state, val) {
|
||||
state.pagination = val
|
||||
},
|
||||
|
||||
update_dialog_form_unit(state, val) {
|
||||
console.log(state, val);
|
||||
state.dialog_form_unit = 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
|
||||
},
|
||||
|
||||
update_save_status(state, val) {
|
||||
state.save_status = val
|
||||
},
|
||||
update_save_error_message(state, val) {
|
||||
state.save_error_message = val
|
||||
},
|
||||
|
||||
update_act(state, val) {
|
||||
state.act = val
|
||||
},
|
||||
|
||||
update_search_status(state, val) {
|
||||
state.search_status = val
|
||||
},
|
||||
|
||||
update_selected_unit(state, val) {
|
||||
state.selected_unit = val
|
||||
},
|
||||
|
||||
update_x_search(state, val) {
|
||||
state.x_search = val
|
||||
state.current_page = 1;
|
||||
},
|
||||
},
|
||||
actions: {
|
||||
// load data dan search
|
||||
async lookupbyname(context, prm) {
|
||||
context.commit("update_lookup_unit", 1)
|
||||
context.commit("update_search_status", true)
|
||||
try {
|
||||
// prm.token = one_token()
|
||||
var prm = {
|
||||
// query:context.state.xsearch,
|
||||
current_page:context.state.current_page,
|
||||
// last_id:context.state.last_id,
|
||||
search:context.state.x_search,
|
||||
sortBy:context.state.pagination.sortBy,
|
||||
sortStatus:context.state.pagination.descending,
|
||||
token:one_token()
|
||||
}
|
||||
let resp = await api.lookupbyname(prm)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_search_status", false)
|
||||
context.commit("update_lookup_unit", 3)
|
||||
context.commit("update_lookup_error_message", resp.message)
|
||||
} else {
|
||||
context.commit("update_search_status", false)
|
||||
context.commit("update_lookup_unit", 2)
|
||||
context.commit("update_lookup_error_message", "")
|
||||
let data = {
|
||||
records: resp.data.records,
|
||||
total: resp.data.total,
|
||||
total_filter: resp.data.total_filter
|
||||
}
|
||||
context.commit("update_units", data)
|
||||
if(context.state.last_id != -1){
|
||||
var alldatas = resp.data.records
|
||||
// var selected = _.find(alldatas, function(o) { return o.id === context.state.last_id })
|
||||
var selected = _.find(alldatas, function (o) {
|
||||
return o.id === context.state.last_id;
|
||||
});
|
||||
context.commit("update_selected_unit", selected)
|
||||
}
|
||||
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_search_status", false)
|
||||
context.commit("update_lookup_unit", 3)
|
||||
context.commit("update_lookup_error_message", e.message)
|
||||
}
|
||||
},
|
||||
|
||||
// add data
|
||||
async add(context, prm) {
|
||||
context.commit("update_save_status", 1)
|
||||
try {
|
||||
prm.token = one_token()
|
||||
let resp = await api.add(prm)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_save_status", 3)
|
||||
context.commit("update_save_error_message", resp.message)
|
||||
} else {
|
||||
context.commit("update_save_status", 2)
|
||||
context.commit("update_save_error_message", resp.message)
|
||||
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_unit", false)
|
||||
var msg =" Item Unit " + prm.name + " sudah tersimpan dong ..."
|
||||
context.commit("update_msg_success", msg)
|
||||
context.dispatch("lookupbyname")
|
||||
} else {
|
||||
context.commit("update_errors", resp.data.errors)
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_save_status", 3)
|
||||
context.commit("update_save_error_message", e.message)
|
||||
console.log(e)
|
||||
}
|
||||
},
|
||||
|
||||
// hapus
|
||||
async delete(context, prm) {
|
||||
context.commit("update_save_status", 1)
|
||||
try {
|
||||
let resp = await api.xdelete(one_token(), prm.id)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_save_status", 3)
|
||||
context.commit("update_save_error_message", resp.message)
|
||||
} else {
|
||||
context.commit("update_save_status", 2)
|
||||
context.commit("update_save_error_message", resp.message)
|
||||
context.commit("update_alert_success", true)
|
||||
|
||||
var msg = " Item Unit " + prm.name + " sudah dihapus dong"
|
||||
context.commit("update_msg_success", msg)
|
||||
context.commit("update_alert_success", true)
|
||||
// context.commit("update_selected_unit", {})
|
||||
context.dispatch("lookupbyname")
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_save_status", 3)
|
||||
console.log(e)
|
||||
}
|
||||
},
|
||||
|
||||
// edit
|
||||
async edit(context, prm) {
|
||||
context.commit("update_save_status", 1)
|
||||
try {
|
||||
prm.token = one_token()
|
||||
let resp = await api.edit(prm)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_save_status", 3)
|
||||
context.commit("update_save_error_message", resp.message)
|
||||
} else {
|
||||
context.commit("update_save_status", 2)
|
||||
context.commit("update_save_error_message", resp.message)
|
||||
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_unit", false)
|
||||
var msg = " Item Unit " + prm.name + " sudah terupdate dong ..."
|
||||
context.commit("update_msg_success", msg)
|
||||
context.dispatch("lookupbyname")
|
||||
}else {
|
||||
context.commit("update_errors", resp.data.errors)
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_save_status", 3)
|
||||
context.commit("update_save_error_message", e.message)
|
||||
console.log(e)
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
23
test/vuex/acc-one-md-itemunit/store.js
Normal file
23
test/vuex/acc-one-md-itemunit/store.js
Normal file
@@ -0,0 +1,23 @@
|
||||
// State
|
||||
// data ...
|
||||
// Mutations
|
||||
//
|
||||
//
|
||||
// Actions
|
||||
import unit from "./modules/unit.js";
|
||||
import system from "../../../apps/modules/system/system.js";
|
||||
export const store = new Vuex.Store({
|
||||
modules: {
|
||||
unit:unit,
|
||||
system:system
|
||||
},
|
||||
state: {
|
||||
|
||||
},
|
||||
mutations: {
|
||||
|
||||
},
|
||||
actions: {
|
||||
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user