add modules folder based on s_menu
This commit is contained in:
200
test/vuex/acc-one-md-supplier/api/supplier.js
Normal file
200
test/vuex/acc-one-md-supplier/api/supplier.js
Normal file
@@ -0,0 +1,200 @@
|
||||
const URL = "/one-api/mockup/masterdata/accounting/";
|
||||
|
||||
export async function search(prm) {
|
||||
try {
|
||||
var resp = await axios.post(URL + 'supplier/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 searchdetail(prm) {
|
||||
try {
|
||||
var resp = await axios.post(URL + 'supplier/searchdetail', 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 + "supplier/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 + "supplier/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 deletesupplier(prm) {
|
||||
try {
|
||||
var resp = await axios.post(URL + "supplier/deletesupplier", 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 searchItem(token, prm) {
|
||||
try {
|
||||
var resp = await axios.post(URL + 'supplier/searchItem', {
|
||||
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 getUnit(prm) {
|
||||
try {
|
||||
var resp = await axios.post(URL + 'supplier/getUnit', 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 saveprice(prm) {
|
||||
try {
|
||||
var resp = await axios.post(URL + "supplier/saveprice", 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 updateprice(prm) {
|
||||
try {
|
||||
var resp = await axios.post(URL + "supplier/updateprice", 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 deleteprice(prm) {
|
||||
try {
|
||||
var resp = await axios.post(URL + "supplier/deleteprice", 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,
|
||||
};
|
||||
}
|
||||
}
|
||||
759
test/vuex/acc-one-md-supplier/components/oneSupplierDetail.vue
Normal file
759
test/vuex/acc-one-md-supplier/components/oneSupplierDetail.vue
Normal file
@@ -0,0 +1,759 @@
|
||||
<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 -->
|
||||
|
||||
<!-- FORM KANAN -->
|
||||
<v-layout row wrap>
|
||||
<v-flex xs12 fill-height>
|
||||
<v-toolbar color="primary" dark>
|
||||
<v-toolbar-title class="white--text"
|
||||
>SUPPLIER ITEM PRICE</v-toolbar-title
|
||||
>
|
||||
<v-spacer></v-spacer>
|
||||
<v-btn :disabled=" Object.keys(this.$store.state.supplier.selected_supplier).length === 0" icon @click="openDialogDetail()">
|
||||
<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="Item"
|
||||
outline
|
||||
v-model="xsearch_detail"
|
||||
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="detailTableSearch()"
|
||||
>
|
||||
<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="supplier_prices"
|
||||
:headers="headers"
|
||||
:loading="isLoading"
|
||||
hide-actions
|
||||
class="elevation-1"
|
||||
>
|
||||
<template slot="items" slot-scope="props">
|
||||
<td
|
||||
class="text-xs-left pa-2"
|
||||
v-bind:class="{ 'amber lighten-4': isSelected(props.item) }"
|
||||
@click="selectMe(props.item)"
|
||||
>{{ props.item.M_ItemCode }}</td>
|
||||
<td
|
||||
class="text-xs-left pa-2"
|
||||
v-bind:class="{ 'amber lighten-4': isSelected(props.item) }"
|
||||
@click="selectMe(props.item)"
|
||||
>{{ props.item.M_ItemDesc }}</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-left pa-2"
|
||||
v-bind:class="{ 'amber lighten-4': isSelected(props.item) }"
|
||||
@click="selectMe(props.item)"
|
||||
>
|
||||
Rp {{
|
||||
oneMoney(props.item.SupplierPricePrice)
|
||||
}}
|
||||
</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="openUpdateDetail(props.item)"
|
||||
>edit</v-icon
|
||||
>
|
||||
<v-icon small @click="deleteDetail(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>
|
||||
|
||||
<!-- POP UP FORM ADD SUPPLIER ITEM -->
|
||||
<template>
|
||||
<v-layout row justify-center>
|
||||
<v-dialog v-model="dialogFormDetail" persistent max-width="40vw">
|
||||
<v-card>
|
||||
<v-card-title class="headline grey lighten-2" primary-title>
|
||||
FORM SUPPLIER ITEM PRICE
|
||||
</v-card-title>
|
||||
<v-card-text class="pt-2 pb-0">
|
||||
<v-layout wrap>
|
||||
<v-flex xs12 pa-2>
|
||||
<v-autocomplete label="Item*" :items="itemList" v-model="selectedItem"
|
||||
:search-input.sync="search_item"
|
||||
auto-select-first no-filter
|
||||
item-text="M_ItemDesc"
|
||||
return-object
|
||||
hide-details
|
||||
no-data-text="Pilih Item">
|
||||
<template slot="item" slot-scope="{ item }">
|
||||
<v-list-tile-content>
|
||||
<v-list-tile-title>
|
||||
{{ item.M_ItemDesc }} ({{ item.M_ItemCode }})
|
||||
</v-list-tile-title>
|
||||
<v-list-tile-sub-title v-text="item.M_ItemCode"></v-list-tile-sub-title>
|
||||
</v-list-tile-content>
|
||||
</template>
|
||||
</v-autocomplete>
|
||||
<p v-if="checkErrorFormDetail('requireItem')" class="error pl-2 pr-2" style="color:#fff">Item belum dipilih</p>
|
||||
</v-flex>
|
||||
<v-flex xs12 pa-2>
|
||||
<v-autocomplete label="Item Unit" v-model="selected_unit"
|
||||
:items="item_units" :search-input.sync="search_unit"
|
||||
auto-select-first no-filter item-text="ItemUnitName"
|
||||
return-object hide-details
|
||||
no-data-text="Pilih Item Unit"
|
||||
>
|
||||
<template slot="item" slot-scope="{ item }">
|
||||
<v-list-tile-content>
|
||||
<v-list-tile-title v-text="item.ItemUnitName"></v-list-tile-title>
|
||||
</v-list-tile-content>
|
||||
</template>
|
||||
</v-autocomplete>
|
||||
<p v-if="checkErrorFormDetail('requireUnit')" class="error pl-2 pr-2" style="color:#fff">Unit belum dipilih</p>
|
||||
</v-flex>
|
||||
<v-flex xs12 pa-2>
|
||||
<!-- <v-text-field
|
||||
label="Harga"
|
||||
type="number"
|
||||
prefix="Rp"
|
||||
v-model="xPrice"
|
||||
@focus="clearPrice"
|
||||
@blur="resetPrice"
|
||||
:hint="convertMoney(xPrice)"
|
||||
></v-text-field> -->
|
||||
<v-text-field
|
||||
prefix="Rp"
|
||||
v-model="formattedPrice"
|
||||
@focus="clearPrice"
|
||||
@blur="resetPrice"
|
||||
label="Harga Per Item">
|
||||
</v-text-field>
|
||||
<p v-if="checkErrorFormDetail('requirePrice')" class="error pl-2 pr-2" style="color:#fff">Harga belum diisi</p>
|
||||
</v-flex>
|
||||
<v-flex xs12 pa-2>
|
||||
<v-select v-model="selected_type" :items="types" item-text="name" label="Tipe"
|
||||
return-object></v-select>
|
||||
</v-flex>
|
||||
<v-flex xs12 pa-2>
|
||||
<v-card v-if="selected_type.value == 'R'" class="pa-2">
|
||||
<v-layout row>
|
||||
<v-flex pa-2 xs6>
|
||||
<v-text-field label="Qty Min" v-model="min_value" hide-details outline></v-text-field>
|
||||
<v-switch v-model="min_inclusive" label="Inclusive"></v-switch>
|
||||
</v-flex>
|
||||
<v-flex pa-2 xs6>
|
||||
<v-text-field label="Qty Max" v-model="max_value" hide-details outline></v-text-field>
|
||||
<v-switch v-model="max_inclusive" label="Inclusive"></v-switch>
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
</v-card>
|
||||
</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="xactdetail === 'new'" color="primary" @click="saveFormDetail()">Simpan</v-btn>
|
||||
<v-btn v-if="xactdetail === 'edit'" color="primary" @click="updateFormDetail()">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 price: <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: {
|
||||
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
xPrice: 0,
|
||||
search_item: "",
|
||||
search_unit: "",
|
||||
xid: 0,
|
||||
dialogdeletealert: false,
|
||||
msgalertname: "",
|
||||
types: [
|
||||
{id:"1", name:"Tak Terhingga", value:"T"},
|
||||
{id:"2", name:"Rentang", value:"R"}
|
||||
],
|
||||
headers: [
|
||||
{
|
||||
text: "KODE ITEM",
|
||||
align: "left",
|
||||
sortable: false,
|
||||
value: "no",
|
||||
width: "10%",
|
||||
class: "blue lighten-3 white--text",
|
||||
},
|
||||
{
|
||||
text: "ITEM",
|
||||
align: "left",
|
||||
sortable: false,
|
||||
value: "no",
|
||||
width: "35%",
|
||||
class: "blue lighten-3 white--text",
|
||||
},
|
||||
{
|
||||
text: "UNIT",
|
||||
align: "left",
|
||||
sortable: false,
|
||||
value: "request",
|
||||
width: "30%",
|
||||
class: "blue lighten-3 white--text",
|
||||
},
|
||||
{
|
||||
text: "HARGA",
|
||||
align: "left",
|
||||
sortable: false,
|
||||
value: "total",
|
||||
width: "15%",
|
||||
class: "blue lighten-3 white--text",
|
||||
},
|
||||
{
|
||||
text: "AKSI",
|
||||
align: "left",
|
||||
sortable: false,
|
||||
value: "act",
|
||||
width: "10%",
|
||||
class: "blue lighten-3 white--text",
|
||||
},
|
||||
],
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.$store.dispatch("supplier/searchItem", this.search_item)
|
||||
},
|
||||
computed: {
|
||||
formattedPrice: {
|
||||
get() {
|
||||
return this.oneMoney(this.xPrice);
|
||||
},
|
||||
set(value) {
|
||||
// Hilangkan titik dan koma, ubah jadi number
|
||||
let raw = value.replace(/\./g, '').replace(',', '.');
|
||||
this.xPrice = parseFloat(raw) || 0;
|
||||
}
|
||||
},
|
||||
supplier_prices() {
|
||||
return this.$store.state.supplier.supplier_prices
|
||||
},
|
||||
isLoading() {
|
||||
return this.$store.state.supplier.search_status_detail == 1
|
||||
},
|
||||
xsearch_detail: {
|
||||
get() {
|
||||
return this.$store.state.supplier.xsearch_detail
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("supplier/update_xsearch_detail", val)
|
||||
}
|
||||
},
|
||||
curr_page: {
|
||||
get() {
|
||||
return this.$store.state.supplier.current_page_detail
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("supplier/update_current_page_detail", val)
|
||||
this.$store.dispatch("supplier/searchdetail")
|
||||
}
|
||||
},
|
||||
xtotal_page: {
|
||||
get() {
|
||||
return this.$store.state.supplier.total_page_supplier_price
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("supplier/update_total_page_supplier_price", val)
|
||||
}
|
||||
},
|
||||
dialogFormDetail: {
|
||||
get() {
|
||||
return this.$store.state.supplier.dialog_form_detail
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("supplier/update_dialog_form_detail", val)
|
||||
}
|
||||
},
|
||||
xactdetail: {
|
||||
get() {
|
||||
return this.$store.state.supplier.act_detail
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("supplier/update_act_detail", val)
|
||||
}
|
||||
},
|
||||
itemList() {
|
||||
return this.$store.state.supplier.itemList.map(item => ({
|
||||
...item,
|
||||
itemCodeDesc: `${item.M_ItemDesc} (${item.M_ItemCode})`
|
||||
}));
|
||||
},
|
||||
selectedItem: {
|
||||
get() {
|
||||
return this.$store.state.supplier.selected_item;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("supplier/update_selected_item", val);
|
||||
this.$store.dispatch("supplier/getUnit", {search: this.search_unit, itemID: this.selectedItem.M_ItemID})
|
||||
},
|
||||
},
|
||||
item_units() {
|
||||
return this.$store.state.supplier.itemUnits;
|
||||
},
|
||||
selected_unit: {
|
||||
get() {
|
||||
return this.$store.state.supplier.selected_unit;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("supplier/update_selected_unit", val);
|
||||
},
|
||||
},
|
||||
snackbar: {
|
||||
get() {
|
||||
return this.$store.state.supplier.alert_success_detail
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("supplier/update_alert_success_detail", val)
|
||||
}
|
||||
},
|
||||
msgSnackbar() {
|
||||
return this.$store.state.supplier.msg_success;
|
||||
},
|
||||
dialog_error: {
|
||||
get() {
|
||||
return this.$store.state.supplier.alert_error_detail
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("supplier/update_alert_error_detail", val)
|
||||
},
|
||||
},
|
||||
msgError() {
|
||||
return this.$store.state.supplier.save_error_message
|
||||
},
|
||||
selected_type: {
|
||||
get() {
|
||||
return this.$store.state.supplier.selected_type
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("supplier/update_selected_type", val)
|
||||
if (this.xactdetail == 'new') {
|
||||
this.max_inclusive = false
|
||||
this.min_inclusive = false
|
||||
this.max_value = 0
|
||||
this.min_value = 0
|
||||
}
|
||||
},
|
||||
},
|
||||
max_inclusive: {
|
||||
get() {
|
||||
return this.$store.state.supplier.max_inclusive;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("supplier/update_max_inclusive", val);
|
||||
},
|
||||
},
|
||||
min_inclusive: {
|
||||
get() {
|
||||
return this.$store.state.supplier.min_inclusive;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("supplier/update_min_inclusive", val);
|
||||
},
|
||||
},
|
||||
max_value: {
|
||||
get() {
|
||||
return this.$store.state.supplier.max_value;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("supplier/update_max_value", val);
|
||||
},
|
||||
},
|
||||
min_value: {
|
||||
get() {
|
||||
return this.$store.state.supplier.min_value;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("supplier/update_min_value", val);
|
||||
},
|
||||
},
|
||||
},
|
||||
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.SupplierPriceID == this.$store.state.supplier.selected_supplier_price.SupplierPriceID
|
||||
},
|
||||
selectMe(sc) {
|
||||
this.$store.commit("supplier/update_selected_supplier_price", sc)
|
||||
},
|
||||
thr_search: _.debounce(function () {
|
||||
this.$store.dispatch("supplier/searchdetail")
|
||||
}, 1000),
|
||||
thr_search_item: _.debounce(function () {
|
||||
this.$store.dispatch("supplier/searchItem", this.search_item)
|
||||
}, 1000),
|
||||
thr_search_unit: _.debounce(function () {
|
||||
this.$store.dispatch("supplier/getUnit", this.search_unit)
|
||||
}, 1000),
|
||||
detailTableSearch() {
|
||||
this.$store.dispatch("supplier/searchdetail")
|
||||
this.$store.commit("supplier/update_selected_supplier_price", {})
|
||||
},
|
||||
openDialogDetail() {
|
||||
this.$store.commit("supplier/update_dialog_form_detail", true)
|
||||
this.$store.commit("supplier/update_act_detail", "new")
|
||||
this.$store.commit("supplier/update_errors", [])
|
||||
this.selectedItem = {}
|
||||
this.selected_unit = {}
|
||||
this.xPrice = 0,
|
||||
this.min_value = "";
|
||||
this.max_value = "";
|
||||
this.min_inclusive = false;
|
||||
this.max_inclusive = false;
|
||||
this.selected_type = {id:"1", name:"Tak Terhingga", value:"T"}
|
||||
this.$store.commit("supplier/update_itemList", [])
|
||||
this.$store.commit("supplier/update_itemUnits", [])
|
||||
},
|
||||
closeDialogForm() {
|
||||
this.$store.commit("supplier/update_dialog_form_detail", false)
|
||||
},
|
||||
clearPrice() {
|
||||
if (this.xPrice === 0) {
|
||||
this.xPrice = ''
|
||||
}
|
||||
},
|
||||
resetPrice() {
|
||||
if (this.xPrice === '' || this.xPrice === null) {
|
||||
this.xPrice = 0
|
||||
}
|
||||
},
|
||||
// check error form
|
||||
checkErrorFormDetail(value) {
|
||||
var errors = this.$store.state.supplier.errors
|
||||
if (errors.includes(value)) {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
},
|
||||
|
||||
saveFormDetail() {
|
||||
this.$store.commit("supplier/update_errors", [])
|
||||
var errors = this.$store.state.supplier.errors
|
||||
|
||||
if(_.isEmpty(this.selectedItem)){
|
||||
errors.push("requireItem")
|
||||
}
|
||||
if(_.isEmpty(this.selected_unit)){
|
||||
errors.push("requireUnit")
|
||||
}
|
||||
if(this.xPrice === '' || this.xPrice === null || this.xPrice === undefined || this.xPrice === 0){
|
||||
errors.push("requirePrice")
|
||||
}
|
||||
|
||||
if (errors.length === 0) {
|
||||
this.$store.commit("supplier/update_errors", [])
|
||||
|
||||
var prm = {
|
||||
supplier_id: this.$store.state.supplier.selected_supplier.SupplierID,
|
||||
item_id: this.selectedItem.M_ItemID,
|
||||
unit_id: this.selected_unit.ItemUnitID,
|
||||
price: this.xPrice,
|
||||
type: this.selected_type.value,
|
||||
min_value: this.min_value,
|
||||
max_value: this.max_value,
|
||||
min_inclusive: this.min_inclusive,
|
||||
max_inclusive: this.max_inclusive
|
||||
}
|
||||
|
||||
this.$store.dispatch("supplier/saveprice", prm)
|
||||
}
|
||||
},
|
||||
|
||||
openUpdateDetail(val) {
|
||||
this.$store.commit("supplier/update_dialog_form_detail", true)
|
||||
this.$store.commit("supplier/update_act_detail", "edit")
|
||||
this.$store.commit("supplier/update_errors", [])
|
||||
this.$store.commit(
|
||||
"supplier/update_itemList", [{
|
||||
M_ItemID: val.M_ItemID,
|
||||
M_ItemDesc: val.M_ItemDesc
|
||||
}]
|
||||
);
|
||||
this.$store.commit(
|
||||
"supplier/update_selected_item", {
|
||||
M_ItemID: val.M_ItemID,
|
||||
M_ItemDesc: val.M_ItemDesc
|
||||
}
|
||||
);
|
||||
this.$store.commit(
|
||||
"supplier/update_itemUnits", [{
|
||||
ItemUnitID: val.ItemUnitID,
|
||||
ItemUnitName: val.ItemUnitName
|
||||
}]
|
||||
);
|
||||
this.$store.commit(
|
||||
"supplier/update_selected_unit", {
|
||||
ItemUnitID: val.ItemUnitID,
|
||||
ItemUnitName: val.ItemUnitName
|
||||
}
|
||||
);
|
||||
this.min_value = val.SupplierPriceMinQty
|
||||
this.min_inclusive = val.SupplierPriceMinInclusive == 'Y' ? true : false
|
||||
this.max_value = val.SupplierPriceMaxQty
|
||||
this.max_inclusive = val.SupplierPriceMaxInclusive == 'Y' ? true : false
|
||||
if (val.SupplierPriceFlagQty == 'R') {
|
||||
this.selected_type = {id:"2", name:"Rentang", value:"R"}
|
||||
} else {
|
||||
this.selected_type = {id:"1", name:"Tak Terhingga", value:"T"}
|
||||
}
|
||||
this.xPrice = val.SupplierPricePrice
|
||||
this.xid = val.SupplierPriceID
|
||||
},
|
||||
|
||||
updateFormDetail() {
|
||||
this.$store.commit("supplier/update_errors", [])
|
||||
var errors = this.$store.state.supplier.errors
|
||||
|
||||
if(_.isEmpty(this.selectedItem)){
|
||||
errors.push("requireItem")
|
||||
}
|
||||
if(_.isEmpty(this.selected_unit)){
|
||||
errors.push("requireUnit")
|
||||
}
|
||||
if(this.xPrice === '' || this.xPrice === null || this.xPrice === undefined || this.xPrice === 0){
|
||||
errors.push("requirePrice")
|
||||
}
|
||||
|
||||
if (errors.length === 0) {
|
||||
this.$store.commit("supplier/update_errors", [])
|
||||
|
||||
var prm = {
|
||||
supplier_id: this.$store.state.supplier.selected_supplier.SupplierID,
|
||||
item_id: this.selectedItem.M_ItemID,
|
||||
unit_id: this.selected_unit.ItemUnitID,
|
||||
price: this.xPrice,
|
||||
supplier_price_id: this.xid,
|
||||
type: this.selected_type.value,
|
||||
min_value: this.min_value,
|
||||
max_value: this.max_value,
|
||||
min_inclusive: this.min_inclusive,
|
||||
max_inclusive: this.max_inclusive
|
||||
}
|
||||
|
||||
this.$store.dispatch("supplier/updateprice", prm)
|
||||
}
|
||||
},
|
||||
|
||||
deleteDetail(val) {
|
||||
this.xid = val.SupplierPriceID
|
||||
this.msgalertname = val.M_ItemCode + " " + val.M_ItemDesc
|
||||
this.dialogdeletealert = true
|
||||
},
|
||||
closeDeleteAlert() {
|
||||
this.dialogdeletealert = false
|
||||
this.$store.dispatch("supplier/deleteprice", {
|
||||
supplier_price_id: this.xid,
|
||||
})
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
xsearch_detail(val, old) {
|
||||
this.xsearch_detail = val
|
||||
this.thr_search()
|
||||
|
||||
},
|
||||
search_item(val, old) {
|
||||
if (val == old) return;
|
||||
if (!val) return;
|
||||
if (val.length < 1) return;
|
||||
if (this.$store.state.supplier.loading_autocomplete == 1) return;
|
||||
this.thr_search_item();
|
||||
},
|
||||
search_unit(val, old) {
|
||||
if (val == old) return;
|
||||
if (!val) return;
|
||||
if (val.length < 1) return;
|
||||
if (this.$store.state.supplier.loading_autocomplete == 1) return;
|
||||
this.thr_search_unit();
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
626
test/vuex/acc-one-md-supplier/components/oneSupplierList.vue
Normal file
626
test/vuex/acc-one-md-supplier/components/oneSupplierList.vue
Normal file
@@ -0,0 +1,626 @@
|
||||
<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">SUPPLIER</v-toolbar-title>
|
||||
<v-spacer></v-spacer>
|
||||
<v-btn icon @click="openDialogSupplier()">
|
||||
<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="Supplier" 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="suppliers" :headers="headers" :loading="isLoading" hide-actions
|
||||
class="elevation-1">
|
||||
<template slot="items" slot-scope="props">
|
||||
<td class="text-xs-left pa-2"
|
||||
v-bind:class="{ 'amber lighten-4': isSelected(props.item) }"
|
||||
@click="selectMe(props.item)">{{ props.item.SupplierCode }}</td>
|
||||
<td class="text-xs-left pa-2"
|
||||
v-bind:class="{ 'amber lighten-4': isSelected(props.item) }"
|
||||
@click="selectMe(props.item)">{{ props.item.SupplierName }}</td>
|
||||
<!-- <td
|
||||
class="text-xs-left pa-2"
|
||||
v-bind:class="{ 'amber lighten-4': isSelected(props.item) }"
|
||||
@click="selectMe(props.item)"
|
||||
>{{ props.item.SupplierPpnPct }}</td>
|
||||
<td
|
||||
class="text-xs-left pa-2"
|
||||
v-bind:class="{ 'amber lighten-4': isSelected(props.item) }"
|
||||
@click="selectMe(props.item)"
|
||||
>{{ props.item.SupplierPphPct }}</td> -->
|
||||
<td class="text-xs-left pa-2"
|
||||
v-bind:class="{ 'amber lighten-4': isSelected(props.item) }"
|
||||
@click="selectMe(props.item)">{{
|
||||
props.item.SupplierAddress ? props.item.SupplierAddress : "-" }}</td>
|
||||
<td class="text-xs-left pa-2"
|
||||
v-bind:class="{ 'amber lighten-4': isSelected(props.item) }"
|
||||
@click="selectMe(props.item)">{{
|
||||
props.item.SupplierPhone ? props.item.SupplierPhone : "-" }}</td>
|
||||
<td class="text-xs-left pa-2"
|
||||
v-bind:class="{ 'amber lighten-4': isSelected(props.item) }"
|
||||
@click="selectMe(props.item)">{{ props.item.SupplierPIC ? props.item.SupplierPIC
|
||||
:
|
||||
"-" }}</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="openUpdateSupplier(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 SUPPLIER
|
||||
</v-card-title>
|
||||
<v-card-text class="pt-2 pb-0">
|
||||
<v-layout wrap>
|
||||
<v-flex xs12 pa-2>
|
||||
<v-text-field label="Nama Supplier*" v-model="nameSupplier"
|
||||
hide-details></v-text-field>
|
||||
<p v-if="checkErrorForm('requireSupplierName')" class="error pl-2 pr-2"
|
||||
style="color:#fff">Nama harus diisi</p>
|
||||
</v-flex>
|
||||
<v-flex xs12 pa-2>
|
||||
<v-layout row>
|
||||
<v-flex>
|
||||
<v-textarea label="Alamat Supplier" v-model="supplierAddress" outline
|
||||
hide-details></v-textarea>
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
</v-flex>
|
||||
<v-flex xs12 pa-2>
|
||||
<v-layout row>
|
||||
<v-flex>
|
||||
<v-text-field
|
||||
label="Term Of Payment" type="number" suffix="hari"
|
||||
v-model="termofpay" outline hide-details
|
||||
></v-text-field>
|
||||
<p v-if="toperror" class="error pl-2 pr-2" style="color:#fff">
|
||||
Jumlah tidak boleh negatif
|
||||
</p>
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
</v-flex>
|
||||
<v-flex xs12 pa-2>
|
||||
<v-layout row>
|
||||
<v-flex>
|
||||
<v-text-field label="Supplier Phone" type="" v-model="supplierPhone" outline
|
||||
hide-details @keypress="onlyNumber($event)"
|
||||
@input="filterNumber('supplierPhone')"></v-text-field>
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
</v-flex>
|
||||
<v-flex xs12 pa-2>
|
||||
<v-layout row>
|
||||
<v-flex>
|
||||
<v-text-field label="PIC" v-model="supplierPIC" outline
|
||||
hide-details></v-text-field>
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
</v-flex>
|
||||
<v-flex xs12 pa-2>
|
||||
<v-layout row>
|
||||
<v-flex>
|
||||
<v-text-field label="PIC Email" v-model="supplierPICEmail" outline
|
||||
type="email" @input="validateEmail" hide-details></v-text-field>
|
||||
<p v-if="emailError && supplierPICEmail" class="error pl-2 pr-2" style="color:#fff">
|
||||
Format Email Tidak Sesuai
|
||||
</p>
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
</v-flex>
|
||||
<v-flex xs12 pa-2>
|
||||
<v-layout row>
|
||||
<v-flex>
|
||||
<v-text-field label="PIC Phone" v-model="supplierPICPhone" outline
|
||||
hide-details @keypress="onlyNumber($event)"
|
||||
@input="filterNumber('supplierPICPhone')"></v-text-field>
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
</v-flex>
|
||||
<v-flex xs12 pa-2>
|
||||
<v-layout row>
|
||||
<v-flex>
|
||||
<v-text-field label="PIC Hp" v-model="supplierPICHp" outline hide-details
|
||||
@keypress="onlyNumber($event)"
|
||||
@input="filterNumber('supplierPICHp')"></v-text-field>
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
</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 {
|
||||
termofpay: 0,
|
||||
toperror: false,
|
||||
nameSupplier: "",
|
||||
supplierAddress: "",
|
||||
supplierPhone: "",
|
||||
supplierPIC: "",
|
||||
supplierPICEmail: "",
|
||||
supplierPICPhone: "",
|
||||
supplierPICHp: "",
|
||||
emailError: false,
|
||||
IsPpn: false,
|
||||
IsPph: false,
|
||||
PpnPercent: 0,
|
||||
PphPercent: 0,
|
||||
xid: 0,
|
||||
dialogdeletealert: false,
|
||||
msgalertname: "",
|
||||
codeSupplier: "",
|
||||
headers: [
|
||||
{
|
||||
text: "KODE",
|
||||
align: "left",
|
||||
sortable: false,
|
||||
value: "no",
|
||||
width: "10%",
|
||||
class: "blue lighten-3 white--text",
|
||||
},
|
||||
{
|
||||
text: "NAMA",
|
||||
align: "left",
|
||||
sortable: false,
|
||||
value: "date",
|
||||
width: "20%",
|
||||
class: "blue lighten-3 white--text",
|
||||
},
|
||||
{
|
||||
text: "ALAMAT",
|
||||
align: "left",
|
||||
sortable: false,
|
||||
value: "total",
|
||||
width: "50%",
|
||||
class: "blue lighten-3 white--text",
|
||||
},
|
||||
{
|
||||
text: "PHONE",
|
||||
align: "left",
|
||||
sortable: false,
|
||||
value: "status",
|
||||
width: "10%",
|
||||
class: "blue lighten-3 white--text",
|
||||
},
|
||||
{
|
||||
text: "PIC",
|
||||
align: "left",
|
||||
sortable: false,
|
||||
value: "status",
|
||||
width: "10%",
|
||||
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("supplier/search")
|
||||
},
|
||||
computed: {
|
||||
suppliers() {
|
||||
return this.$store.state.supplier.suppliers
|
||||
},
|
||||
isLoading() {
|
||||
return this.$store.state.supplier.search_status == 1
|
||||
},
|
||||
xsearch: {
|
||||
get() {
|
||||
return this.$store.state.supplier.xsearch
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("supplier/update_xsearch", val)
|
||||
}
|
||||
},
|
||||
curr_page: {
|
||||
get() {
|
||||
return this.$store.state.supplier.current_page
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("supplier/update_current_page", val)
|
||||
this.$store.commit("supplier/update_last_id", -1)
|
||||
this.$store.dispatch("supplier/search")
|
||||
}
|
||||
},
|
||||
xtotal_page: {
|
||||
get() {
|
||||
return this.$store.state.supplier.total_page
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("supplier/update_total_page", val)
|
||||
}
|
||||
},
|
||||
dialogForm: {
|
||||
get() {
|
||||
return this.$store.state.supplier.dialog_form
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("supplier/update_dialog_form", val)
|
||||
}
|
||||
},
|
||||
xact: {
|
||||
get() {
|
||||
return this.$store.state.supplier.act
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("supplier/update_act", val)
|
||||
}
|
||||
},
|
||||
snackbar: {
|
||||
get() {
|
||||
return this.$store.state.supplier.alert_success
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("supplier/update_alert_success", val)
|
||||
}
|
||||
},
|
||||
msgSnackbar() {
|
||||
return this.$store.state.supplier.msg_success;
|
||||
},
|
||||
dialog_error: {
|
||||
get() {
|
||||
return this.$store.state.supplier.alert_error
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("supplier/update_alert_error", val)
|
||||
},
|
||||
},
|
||||
msgError() {
|
||||
return this.$store.state.supplier.save_error_message
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
validateEmail() {
|
||||
const email = this.supplierPICEmail;
|
||||
this.emailError = !!email && !/^[^@]+@[^@]+$/.test(email);
|
||||
},
|
||||
onlyNumber(e) {
|
||||
// hanya izinkan angka (0-9)
|
||||
const char = String.fromCharCode(e.keyCode);
|
||||
if (!/[0-9]/.test(char)) {
|
||||
e.preventDefault();
|
||||
}
|
||||
},
|
||||
filterNumber(field) {
|
||||
// filter agar hanya angka yang boleh diinput (untuk copy-paste)
|
||||
this[field] = this[field].replace(/\D/g, '');
|
||||
},
|
||||
isSelected(p) {
|
||||
return p.SupplierID == this.$store.state.supplier.selected_supplier.SupplierID
|
||||
},
|
||||
selectMe(sc) {
|
||||
this.$store.commit("supplier/update_selected_supplier", sc)
|
||||
this.$store.dispatch("supplier/searchdetail")
|
||||
},
|
||||
thr_search: _.debounce(function () {
|
||||
this.$store.dispatch("supplier/search")
|
||||
}, 1000),
|
||||
mainTableSearch() {
|
||||
this.$store.dispatch("supplier/search")
|
||||
this.$store.commit("supplier/update_selected_supplier", {})
|
||||
this.$store.commit("supplier/update_supplier_prices", [])
|
||||
this.$store.commit("supplier/update_total_page_supplier_price", 0)
|
||||
},
|
||||
openDialogSupplier() {
|
||||
this.$store.commit("supplier/update_dialog_form", true)
|
||||
this.$store.commit("supplier/update_act", "new")
|
||||
this.$store.commit("supplier/update_errors", [])
|
||||
this.nameSupplier = ""
|
||||
this.supplierAddress = ""
|
||||
this.supplierPhone = ""
|
||||
this.supplierPic = ""
|
||||
this.supplierPICEmail = ""
|
||||
this.supplierPICPhone = ""
|
||||
this.supplierPICHp = ""
|
||||
this.emailError = false
|
||||
this.IsPpn = false
|
||||
this.IsPph = false
|
||||
this.PpnPercent = 0
|
||||
this.PphPercent = 0
|
||||
},
|
||||
closeDialogForm() {
|
||||
this.$store.commit("supplier/update_dialog_form", false)
|
||||
},
|
||||
// check error form
|
||||
checkErrorForm(value) {
|
||||
var errors = this.$store.state.supplier.errors
|
||||
if (errors.includes(value)) {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
},
|
||||
|
||||
clearPpnPercent() {
|
||||
if (this.PpnPercent === 0) {
|
||||
this.PpnPercent = ''
|
||||
}
|
||||
},
|
||||
resetPpnPercent() {
|
||||
if (this.PpnPercent === '' || this.PpnPercent === null) {
|
||||
this.PpnPercent = 0
|
||||
}
|
||||
},
|
||||
|
||||
clearPphPercent() {
|
||||
if (this.PphPercent === 0) {
|
||||
this.PphPercent = ''
|
||||
}
|
||||
},
|
||||
resetPphPercent() {
|
||||
if (this.PphPercent === '' || this.PphPercent === null) {
|
||||
this.PphPercent = 0
|
||||
}
|
||||
},
|
||||
|
||||
// save
|
||||
saveForm() {
|
||||
this.$store.commit("supplier/update_errors", [])
|
||||
var errors = this.$store.state.supplier.errors
|
||||
|
||||
if (_.isEmpty(this.nameSupplier)) {
|
||||
errors.push("requireSupplierName")
|
||||
}
|
||||
|
||||
if (this.supplierPICEmail && !/^[^@]+@[^@]+$/.test(this.supplierPICEmail)) {
|
||||
this.emailError = true;
|
||||
return; // stop submit jika email tidak valid
|
||||
} else {
|
||||
this.emailError = false;
|
||||
}
|
||||
|
||||
if (Number(this.termofpay) < 0) {
|
||||
this.toperror = true
|
||||
return;
|
||||
} else {
|
||||
this.toperror = false
|
||||
}
|
||||
|
||||
if (errors.length === 0) {
|
||||
this.$store.commit("supplier/update_errors", [])
|
||||
|
||||
var prm = {
|
||||
nameSupplier: this.nameSupplier,
|
||||
SupplierAddress: this.supplierAddress,
|
||||
SupplierTOP: this.termofpay,
|
||||
SupplierPhone: this.supplierPhone,
|
||||
SupplierPIC: this.supplierPIC,
|
||||
SupplierPICEmail: this.supplierPICEmail,
|
||||
SupplierPICPhone: this.supplierPICPhone,
|
||||
SupplierPICHp: this.supplierPICHp,
|
||||
isPpn: this.IsPpn === true ? 'Y' : 'N',
|
||||
isPph: this.IsPph === true ? 'Y' : 'N',
|
||||
PpnPercent: this.PpnPercent,
|
||||
PphPercent: this.PphPercent
|
||||
}
|
||||
this.$store.dispatch("supplier/save", prm)
|
||||
}
|
||||
},
|
||||
|
||||
openUpdateSupplier(val) {
|
||||
this.$store.commit("supplier/update_errors", [])
|
||||
this.$store.commit("supplier/update_dialog_form", true)
|
||||
this.$store.commit("supplier/update_act", "edit")
|
||||
this.nameSupplier = val.SupplierName
|
||||
this.supplierAddress = val.SupplierAddress
|
||||
this.termofpay = val.SupplierTermOfPayment
|
||||
this.supplierPhone = val.SupplierPhone
|
||||
this.supplierPIC = val.SupplierPIC
|
||||
this.supplierPICEmail = val.SupplierPICEmail
|
||||
this.supplierPICPhone = val.SupplierPICPhone
|
||||
this.supplierPICHp = val.SupplierPICHp
|
||||
this.IsPpn = val.SupplierIsPpn === 'Y' ? true : false
|
||||
this.IsPph = val.SupplierIsPph === 'Y' ? true : false
|
||||
this.PpnPercent = val.SupplierPpnPct
|
||||
this.PphPercent = val.SupplierPphPct
|
||||
this.xid = val.SupplierID
|
||||
},
|
||||
|
||||
updateForm() {
|
||||
this.$store.commit("supplier/update_errors", [])
|
||||
var errors = this.$store.state.supplier.errors
|
||||
|
||||
if (_.isEmpty(this.nameSupplier)) {
|
||||
errors.push("requireSupplierName")
|
||||
}
|
||||
|
||||
if (this.supplierPICEmail && !/^[^@]+@[^@]+$/.test(this.supplierPICEmail)) {
|
||||
this.emailError = true;
|
||||
return; // stop submit jika email tidak valid
|
||||
} else {
|
||||
this.emailError = false;
|
||||
}
|
||||
|
||||
if (Number(this.termofpay) < 0) {
|
||||
this.toperror = true
|
||||
return;
|
||||
} else {
|
||||
this.toperror = false
|
||||
}
|
||||
|
||||
if (errors.length === 0) {
|
||||
this.$store.commit("supplier/update_errors", [])
|
||||
|
||||
var prm = {
|
||||
nameSupplier: this.nameSupplier,
|
||||
SupplierAddress: this.supplierAddress,
|
||||
SupplierTOP: this.termofpay,
|
||||
SupplierPhone: this.supplierPhone,
|
||||
SupplierPIC: this.supplierPIC,
|
||||
SupplierPICEmail: this.supplierPICEmail,
|
||||
SupplierPICPhone: this.supplierPICPhone,
|
||||
SupplierPICHp: this.supplierPICHp,
|
||||
isPpn: this.IsPpn === true ? 'Y' : 'N',
|
||||
isPph: this.IsPph === true ? 'Y' : 'N',
|
||||
PpnPercent: this.PpnPercent,
|
||||
PphPercent: this.PphPercent,
|
||||
supplier_id: this.xid
|
||||
}
|
||||
this.$store.dispatch("supplier/update", prm)
|
||||
}
|
||||
},
|
||||
|
||||
deleteSupplier(val) {
|
||||
this.xid = val.SupplierID
|
||||
this.msgalertname = val.SupplierCode + " " + val.SupplierName
|
||||
this.codeSupplier = val.SupplierCode
|
||||
this.dialogdeletealert = true
|
||||
},
|
||||
closeDeleteAlert() {
|
||||
this.dialogdeletealert = false
|
||||
this.$store.dispatch("supplier/deletesupplier", {
|
||||
supplier_id: this.xid,
|
||||
codeSupplier: this.codeSupplier
|
||||
})
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
xsearch(val, old) {
|
||||
this.xsearch = val
|
||||
this.thr_search()
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
91
test/vuex/acc-one-md-supplier/index.php
Normal file
91
test/vuex/acc-one-md-supplier/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-supplier-list></one-supplier-list>
|
||||
</v-flex>
|
||||
<v-flex xs6 class="right" fill-height pa-1>
|
||||
<one-supplier-detail></one-supplier-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 -->
|
||||
<?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-supplier-list': httpVueLoader('./components/oneSupplierList.vue'),
|
||||
'one-supplier-detail': httpVueLoader('./components/oneSupplierDetail.vue')
|
||||
}
|
||||
})
|
||||
</script>
|
||||
<style>
|
||||
[v-cloak] {
|
||||
display: none
|
||||
}
|
||||
</style>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
478
test/vuex/acc-one-md-supplier/modules/supplier.js
Normal file
478
test/vuex/acc-one-md-supplier/modules/supplier.js
Normal file
@@ -0,0 +1,478 @@
|
||||
// 1 => LOADING
|
||||
// 2 => DONE
|
||||
// 3 => ERROR
|
||||
import * as api from "../api/supplier.js"
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {
|
||||
search_status: 0,
|
||||
search_error_message: "",
|
||||
suppliers: [],
|
||||
selected_supplier: {},
|
||||
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: "",
|
||||
|
||||
// detail
|
||||
search_status_detail: 0,
|
||||
search_error_detail_message: "",
|
||||
supplier_prices: [],
|
||||
selected_supplier_price: {},
|
||||
total_page_supplier_price: 0,
|
||||
current_page_detail: 1,
|
||||
xsearch_detail: "",
|
||||
selected_supplier_id: 0,
|
||||
dialog_form_detail: false,
|
||||
act_detail: "new",
|
||||
loading_autocomplete: false,
|
||||
itemList: [],
|
||||
selected_item: {},
|
||||
itemUnits: [],
|
||||
selected_unit: {},
|
||||
alert_error_detail: false,
|
||||
alert_success_detail: false,
|
||||
selected_type: {id:"1", name:"Tak Terhingga", value:"T"},
|
||||
min_value:'',
|
||||
max_value:'',
|
||||
min_inclusive:false,
|
||||
max_inclusive:false,
|
||||
},
|
||||
mutations: {
|
||||
update_search_status(state, val) {
|
||||
state.search_status = val
|
||||
},
|
||||
update_search_error_message(state, val) {
|
||||
state.search_error_message = val
|
||||
},
|
||||
update_suppliers(state, val) {
|
||||
state.suppliers = val
|
||||
},
|
||||
update_selected_supplier(state, val) {
|
||||
state.selected_supplier = 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
|
||||
},
|
||||
|
||||
// detail
|
||||
update_search_status_detail(state, val) {
|
||||
state.search_status_detail = val
|
||||
},
|
||||
update_search_error_detail_message(state, val) {
|
||||
state.search_error_detail_message = val
|
||||
},
|
||||
update_supplier_prices(state, val) {
|
||||
state.supplier_prices = val
|
||||
},
|
||||
update_selected_supplier_price(state, val) {
|
||||
state.selected_supplier_price = val
|
||||
},
|
||||
update_total_page_supplier_price(state, val) {
|
||||
state.total_page_supplier_price = val
|
||||
},
|
||||
update_current_page_detail(state, val) {
|
||||
state.current_page_detail = val
|
||||
},
|
||||
update_xsearch_detail(state, val) {
|
||||
state.xsearch_detail = val
|
||||
state.current_page_detail = 1
|
||||
},
|
||||
update_selected_supplier_id(state, val) {
|
||||
state.selected_supplier_id = val
|
||||
},
|
||||
update_errors(state, val) {
|
||||
state.errors = val
|
||||
},
|
||||
update_dialog_form_detail(state, val) {
|
||||
state.dialog_form_detail = val
|
||||
},
|
||||
update_act_detail(state, val) {
|
||||
state.act_detail = val
|
||||
},
|
||||
update_loading_autocomplete(state, val) {
|
||||
state.loading_autocomplete = val
|
||||
},
|
||||
update_itemList(state, val) {
|
||||
state.itemList = val
|
||||
},
|
||||
update_selected_item(state, val) {
|
||||
state.selected_item = val
|
||||
},
|
||||
update_itemUnits(state, val) {
|
||||
state.itemUnits = val
|
||||
},
|
||||
update_selected_unit(state, val) {
|
||||
state.selected_unit = val
|
||||
},
|
||||
update_alert_error_detail(state, val) {
|
||||
state.alert_error_detail = val
|
||||
},
|
||||
update_alert_success_detail(state, val) {
|
||||
state.alert_success_detail = val
|
||||
},
|
||||
update_selected_type(state, val) {
|
||||
state.selected_type = val
|
||||
},
|
||||
update_min_inclusive(state, val) {
|
||||
state.min_inclusive = val
|
||||
},
|
||||
update_max_inclusive(state, val) {
|
||||
state.max_inclusive = val
|
||||
},
|
||||
update_min_value(state, val) {
|
||||
state.min_value = val
|
||||
},
|
||||
update_max_value(state, val) {
|
||||
state.max_value = 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_suppliers", 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 searchdetail(context) {
|
||||
context.commit("update_search_status_detail", 1)
|
||||
try {
|
||||
var prm = {
|
||||
token: one_token(),
|
||||
current_page: context.state.current_page_detail,
|
||||
search: context.state.xsearch_detail,
|
||||
supplier_id: context.state.selected_supplier.SupplierID
|
||||
}
|
||||
let resp = await api.searchdetail(prm)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_search_status_detail", 3)
|
||||
context.commit("update_search_error_detail_message", resp.message)
|
||||
} else {
|
||||
context.commit("update_search_status_detail", 2)
|
||||
context.commit("update_search_error_detail_message", "")
|
||||
let data = {
|
||||
records: resp.data.records,
|
||||
total: resp.data.total_page
|
||||
}
|
||||
|
||||
context.commit("update_supplier_prices", data.records)
|
||||
context.commit("update_total_page_supplier_price", data.total)
|
||||
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_search_status_detail", 3)
|
||||
context.commit("update_search_error_detail_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 = `Supplier baru dengan kode ${data.records[0].SupplierCode} sudah tersimpan`;
|
||||
context.commit("update_msg_success", msg)
|
||||
context.dispatch("search")
|
||||
context.commit("update_selected_supplier", data.records[0]);
|
||||
context.dispatch("searchdetail")
|
||||
}
|
||||
}
|
||||
} 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 = `Perubahan supplier dengan kode ${data.records[0].SupplierCode} sudah tersimpan`;
|
||||
context.commit("update_msg_success", msg)
|
||||
context.dispatch("search")
|
||||
context.commit("update_selected_supplier", data.records[0]);
|
||||
context.dispatch("searchdetail")
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_save_error_message", e.message)
|
||||
context.commit("update_save_status", 3)
|
||||
context.commit("update_alert_error", true)
|
||||
}
|
||||
},
|
||||
async deletesupplier(context, prm) {
|
||||
context.commit("update_save_status", 1)
|
||||
try {
|
||||
prm.token = one_token()
|
||||
let resp = await api.deletesupplier(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 = "Supplier dengan kode " + prm.codeSupplier + " sudah dihapus";
|
||||
context.commit("update_msg_success", msg)
|
||||
context.dispatch("search")
|
||||
context.dispatch("searchdetail")
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_save_error_message", e.message)
|
||||
context.commit("update_save_status", 3)
|
||||
context.commit("update_alert_error", true)
|
||||
}
|
||||
},
|
||||
|
||||
async searchItem(context, prm) {
|
||||
context.commit("update_loading_autocomplete", true)
|
||||
try {
|
||||
let resp = await api.searchItem(one_token(), prm)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_loading_autocomplete", false)
|
||||
context.commit("update_search_error_message", resp.message);
|
||||
} else {
|
||||
context.commit("update_loading_autocomplete", false)
|
||||
context.commit("update_search_error_message", "");
|
||||
let data = {
|
||||
records: resp.data.records
|
||||
}
|
||||
|
||||
context.commit("update_itemList", data.records)
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_loading_autocomplete", true)
|
||||
context.commit("update_search_error_message", e.message);
|
||||
}
|
||||
},
|
||||
|
||||
async getUnit(context, prm) {
|
||||
context.commit("update_loading_autocomplete", true)
|
||||
try {
|
||||
prm.token = one_token()
|
||||
let resp = await api.getUnit(prm)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_loading_autocomplete", false)
|
||||
context.commit("update_search_error_message", resp.message);
|
||||
} else {
|
||||
context.commit("update_loading_autocomplete", false)
|
||||
context.commit("update_search_error_message", "");
|
||||
let data = {
|
||||
records: resp.data.records
|
||||
}
|
||||
|
||||
context.commit("update_itemUnits", data.records)
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_loading_autocomplete", true)
|
||||
context.commit("update_search_error_message", e.message);
|
||||
}
|
||||
},
|
||||
|
||||
async saveprice(context, prm) {
|
||||
context.commit("update_save_status", 1)
|
||||
try {
|
||||
prm.token = one_token()
|
||||
let resp = await api.saveprice(prm);
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_save_error_message", resp.message)
|
||||
context.commit("update_save_status", 3)
|
||||
context.commit("update_alert_error_detail", 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_detail", true)
|
||||
context.commit("update_dialog_form_detail", false)
|
||||
var msg = "Harga baru berhasil ditambahkan";
|
||||
context.commit("update_msg_success", msg)
|
||||
context.commit("update_selected_supplier_price", data.records[0]);
|
||||
context.dispatch("searchdetail")
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_save_error_message", e.message)
|
||||
context.commit("update_save_status", 3)
|
||||
context.commit("update_alert_error_detail", true)
|
||||
}
|
||||
},
|
||||
|
||||
async updateprice(context, prm) {
|
||||
context.commit("update_save_status", 1)
|
||||
try {
|
||||
prm.token = one_token()
|
||||
let resp = await api.updateprice(prm);
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_save_error_message", resp.message)
|
||||
context.commit("update_save_status", 3)
|
||||
context.commit("update_alert_error_detail", 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_detail", true)
|
||||
context.commit("update_dialog_form_detail", false)
|
||||
var msg = "Harga baru berhasil di update";
|
||||
context.commit("update_msg_success", msg)
|
||||
context.commit("update_selected_supplier_price", data.records[0]);
|
||||
context.dispatch("searchdetail")
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_save_error_message", e.message)
|
||||
context.commit("update_save_status", 3)
|
||||
context.commit("update_alert_error_detail", true)
|
||||
}
|
||||
},
|
||||
|
||||
async deleteprice(context, prm) {
|
||||
context.commit("update_save_status", 1)
|
||||
try {
|
||||
prm.token = one_token()
|
||||
let resp = await api.deleteprice(prm);
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_save_error_message", resp.message)
|
||||
context.commit("update_save_status", 3)
|
||||
context.commit("update_alert_error_detail", 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_detail", true)
|
||||
var msg = "Harga baru berhasil di hapus";
|
||||
context.commit("update_msg_success", msg)
|
||||
context.dispatch("searchdetail")
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_save_error_message", e.message)
|
||||
context.commit("update_save_status", 3)
|
||||
context.commit("update_alert_error_detail", true)
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
11
test/vuex/acc-one-md-supplier/store.js
Normal file
11
test/vuex/acc-one-md-supplier/store.js
Normal file
@@ -0,0 +1,11 @@
|
||||
import supplier from "./modules/supplier.js";
|
||||
import system from "../../../apps/modules/system/system.js";
|
||||
export const store = new Vuex.Store({
|
||||
modules: {
|
||||
supplier: supplier,
|
||||
system: system,
|
||||
},
|
||||
state: {},
|
||||
mutations: {},
|
||||
actions: {},
|
||||
});
|
||||
Reference in New Issue
Block a user