add modules folder based on s_menu

This commit is contained in:
2026-06-30 10:16:11 +07:00
parent 315b657ee3
commit a1aab09ac9
625 changed files with 192283 additions and 794 deletions

View File

@@ -0,0 +1,166 @@
const URL = "/one-api/mockup/itemout/";
export async function getDivisionByUser(payload) {
try {
var resp = await axios.post(URL + 'itemusagev3/getDivisionByUser', payload);
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 search(payload) {
try {
var resp = await axios.post(URL + 'itemusagev3/search', payload);
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(payload) {
try {
var resp = await axios.post(URL + 'itemusagev3/getUnit', payload);
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 saveItemUsage(payload) {
try {
var resp = await axios.post(URL + 'itemusagev3/saveItemUsage', payload);
if (resp.status != 200) {
return {
status: "ERR",
message: resp.statusText
};
}
let data = resp.data;
return data;
} catch (e) {
return {
status: "ERR",
message: e.message
};
}
}
// item used
export async function getItemUsed(payload) {
try {
var resp = await axios.post(URL + 'itemusagev3/getItemUsed', payload);
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 updateItemUsed(payload) {
try {
var resp = await axios.post(URL + 'itemusagev3/updateItemUsed', payload);
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 deleteItemUsed(payload) {
try {
var resp = await axios.post(URL + 'itemusagev3/deleteItemUsed', payload);
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 confirmItemUsed(payload) {
try {
var resp = await axios.post(URL + 'itemusagev3/confirmItemUsed', payload);
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 getUnitByItemId(payload) {
try {
var resp = await axios.post(URL + 'itemusagev3/getUnitByItemId', payload);
if (resp.status != 200) {
return {
status: "ERR",
message: resp.statusText
};
}
let data = resp.data;
return data;
} catch (e) {
return {
status: "ERR",
message: e.message
};
}
}

View File

@@ -0,0 +1,310 @@
<template>
<v-layout row justify-center>
<v-dialog v-model="dialogUnit" persistent max-width="25%">
<v-card>
<v-card-title class="title grey lighten-2" primary-title>
Ganti Satuan {{ selectedItemUsage.M_ItemDesc ? selectedItemUsage.M_ItemDesc : "" }}
</v-card-title>
<v-card-text>
<v-layout row>
<v-flex xs12>
<v-select
:loading="loadingUnit"
v-model="selectedUnit"
return-object
:items="unitOptions"
label="Pilih Satuan"
item-text="ItemUnitName"
></v-select>
</v-flex>
</v-layout>
</v-card-text>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn color="error" flat @click="dialogUnit = false">
Tutup
</v-btn>
<v-btn color="primary" flat @click="saveUnit()">Ganti</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
<v-dialog v-model="dialogform" persistent max-width="75%">
<v-card>
<v-card-title class="headline grey lighten-2" primary-title>
Detail Pemakaian
</v-card-title>
<v-card-text class="pt-2 pb-0">
<v-layout row wrap>
<v-flex xs12 pa-2>
<p class="mb-0"><strong>Item:</strong> {{ selectedItemUsage.M_ItemDesc }}</p>
<p class="mb-0"><strong>Unit:</strong> {{ selectedItemUsage.ItemUnitName }}</p>
<p class="mb-0"><strong>Jumlah Stock:</strong> {{ selectedItemUsage.TotalStockQtyReq }}</p>
</v-flex>
</v-layout>
<v-card flat class=" 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
:headers="headersItems"
:items="itemRequestList"
hide-actions
class="elevation-1"
>
<template slot="items" slot-scope="props">
<td
class="text-xs-left pa-2"
>
{{ props.item.StockBatchNo }}
</td>
<td
class="text-xs-left pa-2"
>
{{ props.item.ItemUnitName }}
</td>
<td
class="text-xs-center pa-2"
>
{{ props.item.QtyReq }}
</td>
<td
class="text-xs-center pa-2"
>
<v-text-field
v-model="props.item.amountUsed"
label="Jumlah"
single-line
hide-details
outline
type="number" min="0" step="1">
</v-text-field>
<p v-show="emptycheck.includes(props.item.StockID)" style="color: red;" class="ma-0 pa-0">Jumlah melebihi stock request</p>
</td>
<td
class="text-xs-center pa-2"
>
<v-btn depressed small color="primary" @click="openDialogUnit(props.item)">{{ props.item.ItemUnitName }}</v-btn>
</td>
</template>
</v-data-table>
</v-flex>
</v-layout>
</v-card>
</v-card-text>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn color="error" flat @click="closeDialogForm()">
Tutup
</v-btn>
<v-btn
color="green"
dark
@click="btnSaveUsed()"
>Simpan</v-btn
>
</v-card-actions>
</v-card>
</v-dialog>
</v-layout>
</template>
<script>
module.exports = {
name: "AddPurchaseRequestDialog",
data() {
return {
itemUnitChange:{},
headersItems: [
{
text: "NUMBER BATCH",
align: "center",
sortable: false,
value: "action",
width: "20%",
class: "pa-2 pl-2 blue lighten-3 white--text",
},
{
text: "UNIT",
align: "center",
sortable: false,
value: "action",
width: "25%",
class: "pa-2 pl-2 blue lighten-3 white--text",
},
{
text: "STOCK",
align: "center",
sortable: false,
value: "action",
width: "15%",
class: "pa-2 pl-2 blue lighten-3 white--text",
},
{
text: "JUMLAH DIGUNAKAN",
align: "center",
sortable: false,
value: "action",
width: "15%",
class: "pa-2 pl-2 blue lighten-3 white--text",
},
{
text: "UNIT DIGUNAKAN",
align: "center",
sortable: false,
value: "action",
width: "25%",
class: "pa-2 pl-2 blue lighten-3 white--text",
}
]
};
},
mounted() {
},
computed: {
loadingUnit() {
return this.$store.state.usage.loadingUnit;
},
dialogUnit: {
get() {
return this.$store.state.usage.dialogUnit;
},
set(val) {
this.$store.commit("usage/updateDialogUnit", val);
},
},
selectedUnit: {
get() {
return this.$store.state.usage.selectedUnit;
},
set(val) {
this.$store.commit("usage/updateSelectedUnit", val);
},
},
unitOptions: {
get() {
return this.$store.state.usage.unitOptions;
},
set(val) {
this.$store.commit("usage/updateUnitOptions", val);
},
},
dialogform: {
get() {
return this.$store.state.usage.dialogform;
},
set(val) {
this.$store.commit("usage/updateDialogform", val);
},
},
itemRequestList: {
get() {
return this.$store.state.usage.itemRequestList;
},
set(val) {
this.$store.commit("usage/updateItemRequestList", val);
},
},
emptycheck: {
get() {
return this.$store.state.usage.emptycheck;
},
set(val) {
this.$store.commit("usage/updateEmptycheck", val);
},
},
selectedItemUsage: {
get() {
return this.$store.state.usage.selectedItemUsage;
},
set(val) {
this.$store.commit("usage/updateSelectedItemUsage", val);
}
},
itemUsageList: {
get() {
return this.$store.state.usage.itemUsageList;
},
set(val) {
this.$store.commit("usage/updateItemUsageList", val);
}
},
},
methods: {
saveUnit() {
let items = this.itemRequestList;
let index = items.findIndex(itemloop => itemloop.ItemUsageDetailID == this.itemUnitChange.ItemUsageDetailID);
let selectedUnit = this.selectedUnit;
items[index].StockItemUnitID = selectedUnit.StockItemUnitID;
items[index].ItemUnitCode = selectedUnit.ItemUnitCode;
items[index].ItemUnitName = selectedUnit.ItemUnitName;
this.$store.commit("usage/updateItemRequestList", items);
this.$store.commit("usage/updateDialogUnit", false);
},
openDialogUnit(item) {
this.itemUnitChange = item
this.$store.dispatch("usage/getUnitByItemId", {
itemId: item.StockItemID,
selectedUnit: {StockItemUnitID: item.StockItemUnitID, ItemUnitCode: item.ItemUnitCode, ItemUnitName: item.ItemUnitName}
});
},
closeDialogForm() {
this.$store.commit("usage/updateDialogform", false);
this.$store.commit("usage/updateItemRequestList", []);
this.$store.dispatch("usage/search", {
currentPage: this.$store.state.usage.currentPage,
divisionID: this.$store.state.usage.selectedDivision == undefined ? 0 : this.$store.state.usage.selectedDivision.DivisionID,
search: this.$store.state.usage.xsearch
});
this.$store.commit("usage/update_last_id", this.$store.state.usage.selectedItemUsage.ItemUsageID);
this.emptycheck = [];
},
btnSaveUsed() {
let emptycheck = [];
this.itemRequestList.forEach(element => {
if(element.amountUsed > element.QtyReq){
emptycheck.push(element.StockID);
}
});
if(emptycheck.length > 0){
this.emptycheck = emptycheck;
return;
}
let itemRequestList = this.itemRequestList
let tempItemRequestList = []
let totalAmountUsed = 0
itemRequestList.forEach(element => {
totalAmountUsed += Number(element.amountUsed);
if ( element.amountUsed != "" && element.amountUsed != 0 && element.amountUsed != '0') {
tempItemRequestList.push(element);
}
});
if (totalAmountUsed == 0) {
alert("Jumlah digunakan harus diisi salah satu");
return;
}
let param = {
ItemUsageID: this.selectedItemUsage.ItemUsageID,
ItemRequest: tempItemRequestList,
currentPage: this.$store.state.used.currentPage,
search: this.$store.state.used.search,
statusConfirm: this.$store.state.used.statusConfirm,
currentPageUsage: this.$store.state.usage.currentPage,
divisionID: this.$store.state.usage.selectedDivision == undefined ? 0 : this.$store.state.usage.selectedDivision.DivisionID,
searchUsage: this.$store.state.usage.xsearch
};
this.$store.dispatch("usage/saveItemUsage", param)
}
},
watch: {
}
};
</script>

View File

@@ -0,0 +1,168 @@
<template>
<v-layout row justify-center>
<v-dialog v-model="showDialog" persistent max-width="600px">
<v-card>
<v-card-title class="headline grey lighten-2" primary-title>
Detail Pemakaian
</v-card-title>
<v-card-text class="pt-2 pb-0">
<v-layout>
<v-flex xs12 pa-2>
<p class="mb-0"><strong>Item:</strong> {{ selectedItem.M_ItemDesc }}</p>
<p class="mb-0"><strong>Unit Asal:</strong> {{ selectedItem.ItemUnitName }}</p>
<p class="mb-0"><strong>Qty:</strong> {{ selectedItem.ItemUsageQty }}</p>
</v-flex>
</v-layout>
<v-layout row>
<v-flex xs12 pa-2>
<v-text-field
v-model="usedQty"
label="Jumlah Digunakan"
hide-details
outline
type="number">
</v-text-field>
<p v-if="checkErrorForm('requireUsageQty')" class="error pl-2 pr-2" style="color:#fff">Jumlah digunakan masih kosong</p>
</v-flex>
</v-layout>
<v-layout row>
<v-flex xs12 pa-2>
<v-autocomplete
v-model="selectedItemUnit"
:items="unitList"
item-text="ToUnitName"
item-value="ToUnitID"
:loading="loadingAutocomplete"
return-object
label="Unit Digunakan"
outline
hide-details
></v-autocomplete>
<p v-if="checkErrorForm('requireUnit')" class="error pl-2 pr-2" style="color:#fff">Unit harus dipilih</p>
</v-flex>
</v-layout>
</v-card-text>
<v-divider></v-divider>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn text @click="closeDialog">Batal</v-btn>
<v-btn color="primary" @click="saveItem">Simpan</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
</v-layout>
</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 {
};
},
mounted() {
},
computed: {
showDialog: {
get() {
return this.$store.state.usage.dialogUsage;
},
set(val) {
this.$store.commit("usage/updateDialogUsage", val);
}
},
selectedItem() {
return this.$store.state.usage.selectedItemUsage;
},
unitList() {
return this.$store.state.usage.unitList;
},
selectedItemUnit: {
get() {
return this.$store.state.usage.selectedItemUnit;
},
set(val) {
this.$store.commit("usage/updateSelectedItemUnit", val);
}
},
loadingAutocomplete() {
return this.$store.state.usage.loadingAutocomplete === 1;
},
usedQty: {
get() {
return this.$store.state.usage.usedQty;
},
set(val) {
this.$store.commit("usage/updateUsedQty", val);
}
}
},
methods: {
closeDialog() {
this.showDialog = false;
this.$store.commit("usage/updateSelectedItemUnit", {});
this.usedQty = 0;
this.$store.commit("usage/updateErrors", []);
},
checkErrorForm(val) {
let errors = this.$store.state.usage.errors;
if (errors.includes(val)) {
return true;
} else {
return false;
}
},
saveItem() {
this.$store.commit("usage/updateErrors", []);
var errors = this.$store.state.usage.errors;
if (_.isEmpty(this.usedQty) || this.usedQty <= 0) {
errors.push("requireUsageQty");
}
if (_.isEmpty(this.selectedItemUnit) || !this.selectedItemUnit.ToUnitID) {
errors.push("requireUnit");
}
if (errors.length === 0) {
let prm = {
itemUsageID: this.selectedItem.ItemUsageID,
itemID: this.selectedItem.M_ItemID,
usedQty: this.usedQty,
fromUnitID: this.selectedItemUnit.FromUnitID,
toUnitID: this.selectedItemUnit.ToUnitID,
usedPrice: this.selectedItem.ItemUsagePrice,
currentPage: this.$store.state.used.currentPage,
search: this.$store.state.used.search,
statusConfirm: this.$store.state.used.statusConfirm
};
this.$store.dispatch("usage/saveItemUsage", prm)
}
}
},
};
</script>

View File

@@ -0,0 +1,331 @@
<template>
<div style="width: 100%">
<v-snackbar
v-model="snackbar.state"
:color="snackbar.type"
:timeout="3000"
multi-line
top
>
{{ snackbar.message }}
<v-btn flat @click="snackbar.state = false">
Close
</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-toolbar color="primary" dark>
<v-toolbar-title class="white--text"
>PEMAKAIAN ITEM PER DIVISI</v-toolbar-title
>
<v-spacer></v-spacer>
</v-toolbar>
<v-card class="pa-2">
<v-layout row>
<v-flex pl-2 xs4>
<v-autocomplete
v-model="selectedDivision"
menu-icon="mdi-chevron-down"
:items="divisionOptions"
item-text="DivisionName"
item-value="DivisionID"
:loading="loadingAutocomplete"
return-object
label="Divisi"
outline
hide-details
></v-autocomplete>
</v-flex>
<v-flex xs4 pl-2>
<v-text-field
label="Cari..."
placeholder="ITEM"
outline
hide-details
v-model="xsearch"
></v-text-field>
</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
:headers="headers"
:items="itemUsageList"
:loading="loading"
hide-actions
class="elevation-1"
>
<template slot="items" slot-scope="props">
<td
class="text-xs-center pa-2"
v-bind:class="{ 'amber lighten-4': isSelected(props.item) }"
@click="selectMe(props.item)"
>
{{ props.item.DivisionName }}
</td>
<td
class="text-xs-left pa-2"
v-bind:class="{ 'amber lighten-4': isSelected(props.item) }"
@click="selectMe(props.item)"
>
<span class="font-weight-bold" style="color:#000000">{{ props.item.M_ItemCode }}</span> {{ props.item.M_ItemDesc }}
</td>
<td
class="text-xs-center pa-2"
v-bind:class="{ 'amber lighten-4': isSelected(props.item) }"
>
<v-btn
color="info"
@click="openDialogDetail(props.item)"
>
Detail
</v-btn>
</td>
</template>
</v-data-table>
</v-flex>
</v-layout>
<v-divider></v-divider>
<v-pagination
style="margin-top: 10px; margin-bottom: 10px"
v-model="currentPage"
:length="totalPage"
></v-pagination>
</v-card>
<dialog-detail-usage-item></dialog-detail-usage-item>
</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: {
"one-dialog-alert": httpVueLoader("../../common/oneDialogAlert.vue"),
"one-dialog-error": httpVueLoader("../../common/oneDialogError.vue"),
"dialog-detail-usage-item": httpVueLoader("./dialogDetailUsageItem.vue"),
},
data() {
return {
headers: [
{
text: "DIVISI",
align: "center",
sortable: false,
value: "no",
width: "30%",
class: "blue lighten-3 white--text",
},
{
text: "ITEM",
align: "center",
sortable: false,
value: "requestDate",
width: "60%",
class: "blue lighten-3 white--text",
},
{
text: "AKSI",
align: "center",
sortable: false,
value: "keterangan",
width: "10%",
class: "blue lighten-3 white--text",
}
],
};
},
mounted() {
this.$store.dispatch("usage/getDivisionByUser")
.then(() => {
this.$store.dispatch("usage/search", {
currentPage: this.$store.state.usage.currentPage,
divisionID: this.$store.state.usage.selectedDivision == undefined ? 0 : this.$store.state.usage.selectedDivision.DivisionID,
search: this.$store.state.usage.xsearch
});
})
.catch(error => {
console.error("Error fetching:", error);
});
},
computed: {
itemUsageList() {
return this.$store.state.usage.itemUsageList;
},
loading() {
return this.$store.state.usage.loadingStatus === 1;
},
snackbar: {
get() {
return this.$store.state.usage.snackbar;
},
set(val) {
this.$store.commit("usage/updateSnackbar", val);
},
},
dialog_error: {
get() {
return this.$store.state.usage.alertError;
},
set(val) {
this.$store.commit("usage/updateAlertError", val);
},
},
msgError() {
return this.$store.state.usage.errMessage;
},
selectedDivision: {
get() {
return this.$store.state.usage.selectedDivision;
},
set(val) {
this.$store.commit("usage/updateSelectedDivision", val);
this.$store.commit("usage/update_last_id", -1);
this.$store.dispatch("usage/search", {
currentPage: this.$store.state.usage.currentPage,
divisionID: val == undefined ? 0 : val.DivisionID,
search: this.$store.state.usage.xsearch,
});
}
},
divisionOptions: {
get() {
return this.$store.state.usage.divisionOptions;
},
set(val) {
this.$store.commit("usage/updateDivisionOptions", val);
this.$store.commit("usage/update_last_id", -1);
}
},
currentPage: {
get() {
return this.$store.state.usage.currentPage;
},
set(val) {
this.$store.commit("usage/updateCurrentPage", val);
this.$store.commit("usage/update_last_id", -1);
this.$store.dispatch("usage/search", {
currentPage: val,
divisionID: this.$store.state.usage.selectedDivision == undefined ? 0 : this.$store.state.usage.selectedDivision.DivisionID,
search: this.$store.state.usage.xsearch,
last_id: -1
});
}
},
totalPage: {
get() {
return this.$store.state.usage.totalPage;
},
set(val) {
this.$store.commit("usage/updateTotalPage", val);
}
},
loadingAutocomplete() {
return this.$store.state.usage.loadingAutocomplete === 1;
},
selectedItemUsage: {
get() {
return this.$store.state.usage.selectedItemUsage;
},
set(val) {
this.$store.commit("usage/updateSelectedItemUsage", val);
}
},
xsearch: {
get() {
return this.$store.state.usage.xsearch;
},
set(val) {
this.$store.commit("usage/updateXsearch", val);
this.$store.commit("usage/update_last_id", -1);
this.$store.dispatch("usage/search", {
currentPage: this.$store.state.usage.currentPage,
divisionID: this.$store.state.usage.selectedDivision == undefined ? 0 : this.$store.state.usage.selectedDivision.DivisionID,
search: val,
last_id: -1
});
}
}
},
methods: {
isSelected(item) {
return this.$store.state.usage.selectedItemUsage.ItemUsageID === item.ItemUsageID;
},
selectMe(item) {
this.$store.commit("usage/updateSelectedItemUsage", item);
},
convertMoney(money){
return one_money(money)
},
openDialogDetail(item){
this.$store.commit("usage/updateDialogform", true);
this.$store.commit("usage/updateItemRequestList", item.ItemRequest);
this.$store.commit("usage/updateSelectedItemUsage", item);
let prm = {
itemUnitID: item.ItemUnitID
}
this.$store.dispatch("usage/getUnit", prm);
},
thr_search: _.debounce(function () {
this.$store.dispatch("used/getItemUsed", {
itemUsageID: this.$store.state.usage.selectedItemUsage.ItemUsageID,
currentPage: this.$store.state.used.currentPage,
search: this.$store.state.used.search,
statusConfirm: this.$store.state.used.statusConfirm,
startdate: this.$store.state.used.fStartDate,
enddate: this.$store.state.used.fEndDate
});
}, 700),
},
watch: {
selectedItemUsage(val, old) {
this.thr_search()
}
}
};
</script>

View File

@@ -0,0 +1,690 @@
<template>
<div style="width: 100%">
<v-snackbar
v-model="snackbar.state"
:color="snackbar.type"
:timeout="3000"
multi-line
top
>
{{ snackbar.message }}
<v-btn flat @click="snackbar.state = false">
Close
</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-toolbar color="primary" dark>
<v-toolbar-title class="white--text"
>DAFTAR ITEM DIGUNAKAN</v-toolbar-title
>
<v-spacer></v-spacer>
</v-toolbar>
<v-card class="pa-2">
<div class="d-flex justify-start align-center" style="gap: 0.5rem">
<v-menu
v-model="menuStartDate"
:close-on-content-click="false"
transition="scale-transition"
:nudge-right="40"
lazy
offset-y
max-width="290px"
min-width="290px"
>
<template v-slot:activator="{ on }">
<v-text-field
v-model="startDateFormatted"
label="Tanggal Awal"
readonly
style="max-width: 250px"
outline
hide-details
class="mb-0"
v-on="on"
@blur="dStartDate = deFormatedDate(startDateFormatted)"
></v-text-field>
</template>
<v-date-picker
no-title
v-model="fStartDate"
@input="menuStartDate = false"
></v-date-picker>
</v-menu>
<v-menu
v-model="menuEndDate"
:close-on-content-click="false"
transition="scale-transition"
:nudge-right="40"
lazy
offset-y
max-width="290px"
min-width="290px"
>
<template v-slot:activator="{ on }">
<v-text-field
v-model="endDateFormatted"
label="Tanggal Akhir"
readonly
style="max-width: 250px"
outline
hide-details
class="mb-0"
v-on="on"
@blur="dEndDate = deFormatedDate(endDateFormatted)"
></v-text-field>
</template>
<v-date-picker
no-title
v-model="fEndDate"
@input="menuEndDate = false"
></v-date-picker>
</v-menu>
<v-select
v-model="statusConfirm"
:items="statusConfirmOptions"
label=""
item-text="text"
item-value="value"
outline
hide-details
></v-select>
</div>
</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
:headers="headers"
:items="itemUsedList"
:loading="loading"
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)"
>
<p class="mb-0">{{ formatDate(props.item.ItemUsedDate)}}</p>
<p class="mb-0 font-weight-bold">{{ props.item.ItemUsedNumber }}</p>
</td>
<td
class="text-xs-left pa-2"
v-bind:class="{ 'amber lighten-4': isSelected(props.item) }"
@click="selectMe(props.item)"
>
<span class="font-weight-bold" style="color:#000000">{{ props.item.M_ItemCode }}</span> {{ 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)"
>
<p class="mb-0"><strong>Qty : </strong> {{ props.item.ItemUsedQty }}</p>
<p class="mb-0"><strong>Unit : </strong> {{ props.item.ItemUnitName }}</p>
</td>
<td
class="text-xs-center pa-2"
v-bind:class="{ 'amber lighten-4': isSelected(props.item) }"
@click="selectMe(props.item)"
>
{{ props.item.M_UserUsername }}
</td>
<td
class="text-xs-left pa-2"
v-bind:class="{ 'amber lighten-4': isSelected(props.item) }"
@click="selectMe(props.item)"
>
<span v-if="props.item.ItemUsedIsConfirm === 'N'">
<v-btn
style="min-width: 25px; height: 25px; margin: 0;"
color="blue"
small title="Konfirmasi"
@click="openConfirm(props.item)"
>
<v-icon small color="white">check_circle</v-icon>
</v-btn>
<!-- <v-btn
style="min-width: 25px; height: 25px; margin: 0;"
color="black"
small title="Edit"
@click="openDialogEdit(props.item)"
>
<v-icon small color="white">edit</v-icon>
</v-btn>
<v-btn
style="min-width: 25px; height: 25px; margin: 0;"
color="red"
small title="Hapus"
@click="openDialogDelete(props.item)"
>
<v-icon small color="white">delete</v-icon>
</v-btn> -->
</span>
<span v-else-if="props.item.ItemUsedIsConfirm === 'Y'">
<span class="text-xs-center">Sudah Dikonfirmasi</span>
</span>
</td>
</template>
</v-data-table>
</v-flex>
</v-layout>
<v-divider></v-divider>
<v-pagination
style="margin-top: 10px; margin-bottom: 10px"
v-model="currentPage"
:length="totalPage"
></v-pagination>
</v-card>
<template>
<v-layout row justify-center>
<v-dialog v-model="dialogUsed" persistent max-width="600px">
<v-card>
<v-card-title class="headline grey lighten-2" primary-title>
Edit Pemakaian
</v-card-title>
<v-card-text class="pt-2 pb-0">
<v-layout>
<v-flex xs12 pa-2>
<p class="mb-0"><strong>Item:</strong> {{ selectedItemUsed.M_ItemDesc }}</p>
<p class="mb-0"><strong>Unit:</strong> {{ selectedItemUsed.ItemUnitName }}</p>
<p class="mb-0"><strong>Qty:</strong> {{ selectedItemUsed.ItemUsedQty }}</p>
</v-flex>
</v-layout>
<v-layout row>
<v-flex xs12 pa-2>
<v-text-field
v-model="selectedusedqty"
label="Jumlah Digunakan"
hide-details
outline
type="number">
</v-text-field>
<p v-if="checkErrorForm('requireUsageQty')" class="error pl-2 pr-2" style="color:#fff">Jumlah digunakan masih kosong</p>
</v-flex>
</v-layout>
</v-card-text>
<v-divider></v-divider>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn text @click="closeDialog">Batal</v-btn>
<v-btn color="primary" @click="saveItem">Simpan</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
</v-layout>
</template>
<template>
<v-dialog v-model="dialogConfirmation" persistent width="500">
<v-card>
<v-card-title class="headline grey lighten-2" primary-title>
KONFIRMASI
</v-card-title>
<v-card-text>
Apakah anda yakin untuk konfirmasi ?
<div class="mt-2">
<p class="mb-0"><strong>Item:</strong> {{ selectedItemUsed.M_ItemDesc }}</p>
<p class="mb-0"><strong>Batch No:</strong> {{ selectedItemUsed.ItemUsedBatchNo }}</p>
<p class="mb-0"><strong>Unit:</strong> {{ selectedItemUsed.ItemUnitName }}</p>
<p class="mb-0"><strong>Qty:</strong> {{ selectedItemUsed.ItemUsedQty }}</p>
</div>
</v-card-text>
<v-divider></v-divider>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn
color="red"
flat
@click="dialogConfirmation = false"
>
Tidak
</v-btn>
<v-btn
color="green"
flat
@click="requestConfirm()"
>
Ya
</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
</template>
<template>
<v-dialog v-model="dialogDelete" persistent width="500">
<v-card>
<v-card-title class="headline grey lighten-2" primary-title>
PERHATIAN
</v-card-title>
<v-card-text>
Apakah anda yakin untuk menghapus
<span style="font-weight: bold;">{{
selectedItemUsed.M_ItemDesc
}}</span>
??
</v-card-text>
<v-divider></v-divider>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn
color="red"
flat
@click="dialogDelete = false"
>
Tidak
</v-btn>
<v-btn
color="green"
flat
@click="deleteUsed()"
>
Ya
</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: {
"one-dialog-alert": httpVueLoader("../../common/oneDialogAlert.vue"),
"one-dialog-error": httpVueLoader("../../common/oneDialogError.vue"),
},
data() {
return {
headers: [
{
text: "TANGGAL/NO",
align: "center",
sortable: false,
value: "no",
width: "15%",
class: "blue lighten-3 white--text",
},
{
text: "ITEM",
align: "center",
sortable: false,
value: "no",
width: "40%",
class: "blue lighten-3 white--text",
},
{
text: "QTY/UNIT",
align: "center",
sortable: false,
value: "requestDate",
width: "20%",
class: "blue lighten-3 white--text",
},
{
text: "USER",
align: "center",
sortable: false,
value: "status",
width: "15%",
class: "blue lighten-3 white--text",
},
{
text: "AKSI",
align: "left",
sortable: false,
value: "status",
width: "10%",
class: "blue lighten-3 white--text",
}
],
};
},
mounted() {
},
computed: {
itemUsedList() {
return this.$store.state.used.itemUsedList;
},
loading() {
return this.$store.state.used.loadingStatus === 1;
},
dialog_error: {
get() {
return this.$store.state.used.alertError;
},
set(val) {
this.$store.commit("used/updateAlertError", val);
},
},
msgError() {
return this.$store.state.used.errMessage;
},
currentPage: {
get() {
return this.$store.state.used.currentPage;
},
set(val) {
this.$store.commit("used/updateCurrentPage", val);
this.$store.dispatch("used/getItemUsed", {
itemUsageID: this.$store.state.usage.selectedItemUsage.ItemUsageID,
currentPage: val,
search: this.$store.state.used.search,
statusConfirm: this.$store.state.used.statusConfirm,
startdate: this.$store.state.used.fStartDate,
enddate: this.$store.state.used.fEndDate
});
},
},
totalPage: {
get() {
return this.$store.state.used.totalPageUsed;
},
set(val) {
this.$store.commit("used/updateTotalPageUsed", val);
},
},
selectedusedqty: {
get() {
return this.$store.state.used.selectedUsedQty;
},
set(val) {
this.$store.commit("used/updateSelectedUsedQty", val);
},
},
selectedItemUsed: {
get() {
return this.$store.state.used.selectedItemUsed;
},
set(val) {
this.$store.commit("used/updateSelectedItemUsed", val);
},
},
dialogUsed: {
get() {
return this.$store.state.used.dialogUsed;
},
set(val) {
this.$store.commit("used/updateDialogUsed", val);
},
},
snackbar: {
get() {
return this.$store.state.used.snackbar;
},
set(val) {
this.$store.commit("used/updateSnackbar", val);
},
},
dialogDelete: {
get() {
return this.$store.state.used.dialogDelete;
},
set(val) {
this.$store.commit("used/updateDialogDelete", val);
},
},
dialogConfirmation: {
get() {
return this.$store.state.used.dialogConfirmation;
},
set(val) {
this.$store.commit("used/updateDialogConfirmation", val);
},
},
xsearch: {
get() {
return this.$store.state.used.search;
},
set(val) {
this.$store.commit("used/updateSearch", val);
this.$store.dispatch("used/getItemUsed", {
itemUsageID: this.$store.state.usage.selectedItemUsage.ItemUsageID,
currentPage: this.$store.state.used.currentPage,
search: val,
statusConfirm: this.$store.state.used.statusConfirm,
startdate: this.$store.state.used.fStartDate,
enddate: this.$store.state.used.fEndDate
});
},
},
statusConfirmOptions() {
return this.$store.state.used.statusConfirmOptions;
},
statusConfirm: {
get() {
return this.$store.state.used.statusConfirm;
},
set(val) {
this.$store.commit("used/updateStatusConfirm", val);
this.$store.dispatch("used/getItemUsed", {
itemUsageID: this.$store.state.usage.selectedItemUsage.ItemUsageID,
currentPage: this.$store.state.used.currentPage,
search: this.$store.state.used.search,
statusConfirm: val,
startdate: this.$store.state.used.fStartDate,
enddate: this.$store.state.used.fEndDate
});
},
},
menuStartDate: {
get() {
return this.$store.state.used.menuStartDate;
},
set(val) {
this.$store.commit("used/updateMenuStartDate", val);
},
},
menuEndDate: {
get() {
return this.$store.state.used.menuEndDate;
},
set(val) {
this.$store.commit("used/updateMenuEndDate", val);
},
},
startDateFormatted() {
return this.formatDate(this.fStartDate);
},
endDateFormatted() {
return this.formatDate(this.fEndDate);
},
fStartDate: {
get() {
return this.$store.state.used.fStartDate;
},
set(val) {
this.$store.commit("used/updateFStartDate", val);
this.$store.dispatch("used/getItemUsed", {
itemUsageID: this.$store.state.usage.selectedItemUsage.ItemUsageID,
currentPage: this.$store.state.used.currentPage,
search: this.$store.state.used.search,
statusConfirm: this.$store.state.used.statusConfirm,
startdate: val,
enddate: this.$store.state.used.fEndDate
});
},
},
fEndDate: {
get() {
return this.$store.state.used.fEndDate;
},
set(val) {
this.$store.commit("used/updateFEndDate", val);
this.$store.dispatch("used/getItemUsed", {
itemUsageID: this.$store.state.usage.selectedItemUsage.ItemUsageID,
currentPage: this.$store.state.used.currentPage,
search: this.$store.state.used.search,
statusConfirm: this.$store.state.used.statusConfirm,
startdate: this.$store.state.used.fStartDate,
enddate: val
});
},
},
dStartDate: {
get() {
return this.$store.state.used.dStartDate;
},
set(val) {
this.$store.commit("used/updateDStartDate", val);
},
},
dEndDate: {
get() {
return this.$store.state.used.dEndDate;
},
set(val) {
this.$store.commit("used/updateDEndDate", val);
},
},
},
methods: {
formatDate(date) {
if (!date) return null
const [year, month, day] = date.split('-')
return `${day}-${month}-${year}`
},
deFormatedDate(date) {
if (!date) return null;
const [day, month, year] = date.split("-");
return `${year}-${month.padStart(2, "0")}-${day.padStart(2, "0")}`;
},
isSelected(item) {
return this.$store.state.used.selectedItemUsed.ItemUsedID === item.ItemUsedID;
},
selectMe(item) {
this.$store.commit("used/updateSelectedItemUsed", item);
},
convertMoney(money){
return one_money(money)
},
openDialogEdit(item) {
this.$store.commit("used/updateSelectedItemUsed", item);
this.selectedusedqty = item.ItemUsedQty;
this.dialogUsed = true;
},
closeDialog() {
this.dialogUsed = false;
this.selectedusedqty = 0;
this.$store.commit("used/updateSelectedItemUsed", {});
this.$store.commit("used/updateErrors", []);
},
checkErrorForm(val) {
let errors = this.$store.state.used.errors;
if (errors.includes(val)) {
return true;
} else {
return false;
}
},
saveItem() {
this.$store.commit("used/updateErrors", []);
var errors = this.$store.state.used.errors;
if (this.selectedusedqty <= 0) {
errors.push("requireUsageQty");
this.$store.commit("used/updateErrors", errors);
return;
}
let prm = {
ItemUsedQty: this.selectedusedqty,
itemUsedID: this.selectedItemUsed.ItemUsedID,
itemUsageID: this.$store.state.usage.selectedItemUsage.ItemUsageID,
currentPage: this.$store.state.used.currentPage,
search: this.$store.state.used.search,
statusConfirm: this.$store.state.used.statusConfirm,
startdate: this.$store.state.used.fStartDate,
enddate: this.$store.state.used.fEndDate
};
this.$store.dispatch("used/updateItemUsed", prm);
},
openDialogDelete(item) {
this.$store.commit("used/updateSelectedItemUsed", item);
this.dialogDelete = true;
},
deleteUsed() {
let prm = {
itemUsedID: this.selectedItemUsed.ItemUsedID,
itemUsageID: this.$store.state.usage.selectedItemUsage.ItemUsageID,
currentPage: this.$store.state.used.currentPage,
search: this.$store.state.used.search,
statusConfirm: this.$store.state.used.statusConfirm,
startdate: this.$store.state.used.fStartDate,
enddate: this.$store.state.used.fEndDate
};
this.$store.dispatch("used/deleteItemUsed", prm);
},
openConfirm(item) {
this.$store.commit("used/updateSelectedItemUsed", item);
this.dialogConfirmation = true;
},
requestConfirm() {
let prm = {
itemUsedID: this.selectedItemUsed.ItemUsedID,
itemUsageID: this.$store.state.usage.selectedItemUsage.ItemUsageID,
currentPage: this.$store.state.used.currentPage,
search: this.$store.state.used.search,
statusConfirm: this.$store.state.used.statusConfirm,
startdate: this.$store.state.used.fStartDate,
enddate: this.$store.state.used.fEndDate
};
this.$store.dispatch("used/confirmItemUsed", prm);
}
},
};
</script>

View File

@@ -0,0 +1,119 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" href="../../../libs/vendor/css/google-fonts.css">
<link rel="stylesheet" href="../../../libs/vendor/css/icomoon-fonts.css">
<link rel="stylesheet" href="../../../libs/vendor/css/vuetify.min.css">
<title>One</title>
</head>
<body>
<v-dialog
v-model="alertError"
width="350">
<v-card>
<v-card-title
class="headline error lighten-2"
primary-title>
Error
</v-card-title>
<v-card-text>
{{errMessage}}
</v-card-text>
<v-divider></v-divider>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn
color="primary"
flat
@click="alertError = false">
Tutup
</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
<div v-cloak id="app">
<v-app id="smartApp">
<one-navbar></one-navbar>
<v-container style="background: #F5E8DF!important" fluid fill-height class="pl-1 pr-1 pt-2 pb-2 mt-4">
<v-layout row wrap>
<v-flex xs6 class="left" fill-height pa-1>
<item-usage-listing></item-usage-listing>
</v-flex>
<v-flex xs6 class="right" fill-height pa-1>
<item-used-listing></item-used-listing>
</v-flex>
</v-layout>
</v-container>
<one-footer></one-footer>
</v-app>
</div>
<!-- Vendor -->
<script src="../../../libs/vendor/moment.min.js"></script>
<script src="../../../libs/vendor/numeral.min.js"></script>
<script src="../../../libs/vendor/moment-locale-id.js"></script>
<script src="../../../libs/vendor/lodash.js"></script>
<script src="../../../libs/vendor/axios.min.js"></script>
<script src="../../../libs/vendor/vue.js"></script>
<script src="../../../libs/vendor/vuex.js"></script>
<script src="../../../libs/vendor/vuetify.js"></script>
<script src="../../../libs/vendor/httpVueLoader.js"></script>
<script src="../../../libs/one_global.js"></script>
<!-- App Script -->
<script type="module">
import {
store
} from './store.js';
window.store = store;
new Vue({
store,
el: "#app",
methods: {},
components: {
'one-navbar': httpVueLoader('../../../apps/components/oneNavbarComponent.vue'),
'one-footer': httpVueLoader('../../../apps/components/oneFooter.vue'),
'item-usage-listing': httpVueLoader('./components/itemUsageList.vue'),
'item-used-listing': httpVueLoader('./components/itemUsedList.vue')
},
computed: {
alertError: {
get() {
return this.$store.state.usage.alertError;
},
set(val) {
this.$store.commit("usage/updateAlertError", val);
}
},
errMessage: {
get() {
return this.$store.state.usage.errMessage;
},
set(val) {
this.$store.commit("usage/updateErrMessage", val);
}
}
}
})
</script>
<style>
[v-cloak] {
display: none
}
</style>
</body>
</html>

View File

@@ -0,0 +1,290 @@
// 1 => LOADING
// 2 => DONE
// 3 => ERROR
import * as api from "../api/api.js";
export default {
namespaced: true,
state: {
errMessage: "",
alertError: false,
snackbar: {
state: false,
type: 'success',
message: '',
},
loadingAutocomplete: false,
divisionOptions: [],
selectedDivision: {},
user: one_user(),
currentPage: 1,
loadingStatus: 1, // 1 => LOADING, 2 => DONE, 3 => ERROR
itemUsageList: [],
selectedItemUsage: {},
totalPage: 0,
dialogUsage: false,
unitList: [],
selectedItemUnit: {},
usedQty: 0,
errors: [],
last_id: -1,
xsearch: "",
dialogform: false,
itemRequestList: [],
emptycheck: [],
dialogUnit: false,
selectedUnit: {},
unitOptions: [],
loadingUnit: false,
},
mutations: {
updateErrMessage(state, val) {
state.errMessage = val;
},
updateAlertError(state, val) {
state.alertError = val;
},
updateSnackbar(state, val) {
state.snackbar = val;
},
updateLoadingAutocomplete(state, val) {
state.loadingAutocomplete = val;
},
updateDivisionOptions(state, val) {
state.divisionOptions = val;
},
updateSelectedDivision(state, val) {
state.selectedDivision = val;
},
updateUser(state, val) {
state.user = val;
},
updateCurrentPage(state, val) {
state.currentPage = val;
},
updateLoadingStatus(state, val) {
state.loadingStatus = val;
},
updateItemUsageList(state, val) {
state.itemUsageList = val;
},
updateSelectedItemUsage(state, val) {
state.selectedItemUsage = val;
},
updateTotalPage(state, val) {
state.totalPage = val;
},
updateDialogUsage(state, val) {
state.dialogUsage = val;
},
updateUnitList(state, val) {
state.unitList = val;
},
updateSelectedItemUnit(state, val) {
state.selectedItemUnit = val;
},
updateUsedQty(state, val) {
state.usedQty = val;
},
updateErrors(state, val) {
state.errors = val;
},
update_last_id(state, val) {
state.last_id = val
},
updateXsearch(state, val) {
state.xsearch = val
},
updateDialogform(state, val) {
state.dialogform = val
},
updateItemRequestList(state, val) {
state.itemRequestList = val
},
updateEmptycheck(state, val) {
state.emptycheck = val
},
updateLoadingUnit(state, val) {
state.loadingUnit = val;
},
updateDialogUnit(state, val) {
state.dialogUnit = val;
},
updateSelectedUnit(state, val) {
state.selectedUnit = val;
},
updateUnitOptions(state, val) {
state.unitOptions = val;
}
},
actions: {
async getDivisionByUser(context) {
context.commit("updateLoadingAutocomplete", true)
try {
let payload = {}
payload.token = one_token()
payload.userId = context.state.user.M_UserID
let response = await api.getDivisionByUser(payload);
if (response.status != "OK") {
context.commit("updateLoadingAutocomplete", false)
context.commit("updateErrMessage", response.message);
context.commit("updateAlertError", true);
} else {
context.commit("updateLoadingAutocomplete", false)
let data = {
records: response.data.records,
selected: response.data.selected
};
context.commit("updateDivisionOptions", data.records);
context.commit("updateSelectedDivision", data.selected[0]);
}
} catch (e) {
context.commit("updateLoadingAutocomplete", false)
context.commit("updateErrMessage", e.message);
context.commit("updateAlertError", true);
}
},
async search(context, payload) {
context.commit("updateLoadingStatus", 1);
try {
// var payload = {
// token: one_token(),
// currentPage: context.state.currentPage,
// divisionID: context.state.selectedDivision == undefined ? 0 : context.state.selectedDivision.DivisionID,
// search: context.state.xsearch,
// };
payload.token = one_token();
let response = await api.search(payload);
if (response.status != "OK") {
context.commit("updateLoadingStatus", 3);
context.commit("updateErrMessage", response.message);
context.commit("updateAlertError", true);
} else {
context.commit("updateLoadingStatus", 2);
context.commit("updateErrMessage", "");
let data = {
records: response.data.records,
total_page: response.data.total_page,
};
context.commit("updateItemUsageList", data.records);
context.commit("updateTotalPage", data.total_page);
if (context.state.last_id == -1) {
if (response.data && response.data.records.length > 0) {
context.commit("updateSelectedItemUsage", response.data.records[0])
}
} else {
let idx = _.findIndex(response.data.records, function (o) {
return o.ItemUsageID == context.state.selectedItemUsage.ItemUsageID
});
if (idx >= 0) {
context.commit("updateSelectedItemUsage", response.data.records[idx]);
}
}
}
} catch (e) {
context.commit("updateLoadingStatus", 3);
context.commit("updateErrMessage", e.message);
context.commit("updateAlertError", true);
}
},
async getUnit(context, payload) {
context.commit("updateLoadingAutocomplete", 1);
try {
payload.token = one_token()
let response = await api.getUnit(payload);
if (response.status != "OK") {
context.commit("updateLoadingAutocomplete", 3);
context.commit("updateErrMessage", response.message);
context.commit("updateAlertError", true);
} else {
context.commit("updateLoadingAutocomplete", 2);
context.commit("updateErrMessage", "");
let data = {
records: response.data.records
};
context.commit("updateUnitList", data.records);
}
} catch (e) {
context.commit("updateLoadingAutocomplete", 3);
context.commit("updateErrMessage", e.message);
context.commit("updateAlertError", true);
}
},
async saveItemUsage(context, payload) {
context.commit("updateLoadingStatus", 1);
try {
payload.token = one_token();
let response = await api.saveItemUsage(payload);
if (response.status != "OK") {
context.commit("updateLoadingStatus", 3);
context.commit("updateErrMessage", response.message);
context.commit("updateAlertError", true);
} else {
context.commit("updateLoadingStatus", 2);
context.commit("updateErrMessage", "");
let data = {
records: response.data.records,
};
context.commit("updateDialogform", false);
context.commit("updateItemRequestList", []);
context.commit("update_last_id", payload.ItemUsageID)
context.commit("updateSnackbar", {
state: true,
type: 'success',
message: 'Item usage saved successfully.'
});
context.dispatch("search", {
currentPage: payload.currentPageUsage,
divisionID: payload.divisionID,
search: payload.searchUsage
});
context.dispatch("used/getItemUsed", {
itemUsageID: payload.ItemUsageID,
currentPage: payload.currentPage,
search: payload.search,
statusConfirm: payload.statusConfirm,
}, { root: true });
}
} catch (e) {
context.commit("updateLoadingStatus", 3);
context.commit("updateErrMessage", e.message);
context.commit("updateAlertError", true);
}
},
async getUnitByItemId(context, payload) {
context.commit("updateLoadingUnit", true)
context.commit("updateDialogUnit", true);
try {
payload.token = one_token();
let response = await api.getUnitByItemId(payload);
if (response.status != "OK") {
context.commit("updateLoadingUnit", false)
context.commit("updateDialogUnit", false);
context.commit("updateErrMessage", response.message);
context.commit("updateAlertError", true);
} else {
context.commit("updateLoadingUnit", false)
context.commit("updateErrMessage", "");
context.commit("updateUnitOptions", response.data.records);
context.commit("updateSelectedUnit", payload.selectedUnit);
}
} catch (e) {
context.commit("updateLoadingUnit", false)
context.commit("updateDialogUnit", false);
context.commit("updateErrMessage", e.message);
context.commit("updateAlertError", true);
}
}
}
};

View File

@@ -0,0 +1,280 @@
// 1 => LOADING
// 2 => DONE
// 3 => ERROR
import * as api from "../api/api.js";
export default {
namespaced: true,
state: {
errMessage: "",
alertError: false,
snackbar: {
state: false,
type: 'success',
message: '',
},
user: one_user(),
currentPage: 1,
loadingStatus: 1, // 1 => LOADING, 2 => DONE, 3 => ERROR
itemUsedList: [],
selectedItemUsed: {},
totalPageUsed: 0,
selectedUsedQty: 0,
dialogUsed: false,
errors: [],
dialogDelete: false,
dialogConfirmation: false,
search: "",
statusConfirmOptions: [
{ value: "X", text: "Semua" },
{ value: "N", text: "Belum Dikonfirmasi" },
{ value: "Y", text: "Sudah Dikonfirmasi" },
],
statusConfirm: "X",
menuStartDate: false,
menuEndDate: false,
fStartDate: moment(new Date()).format("YYYY-MM-DD"),
fEndDate: moment(new Date()).format("YYYY-MM-DD"),
dStartDate: new Date().toISOString().substring(0, 10),
dEndDate: new Date().toISOString().substring(0, 10)
},
mutations: {
updateErrMessage(state, val) {
state.errMessage = val;
},
updateAlertError(state, val) {
state.alertError = val;
},
updateSnackbar(state, val) {
state.snackbar = val;
},
updateLoadingAutocomplete(state, val) {
state.loadingAutocomplete = val;
},
updateDivisionOptions(state, val) {
state.divisionOptions = val;
},
updateSelectedDivision(state, val) {
state.selectedDivision = val;
},
updateUser(state, val) {
state.user = val;
},
updateCurrentPage(state, val) {
state.currentPage = val;
},
updateLoadingStatus(state, val) {
state.loadingStatus = val;
},
updateItemUsedList(state, val) {
state.itemUsedList = val;
},
updateSelectedItemUsed(state, val) {
state.selectedItemUsed = val;
},
updateTotalPageUsed(state, val) {
state.totalPageUsed = val;
},
updateSelectedUsedQty(state, val) {
state.selectedUsedQty = val;
},
updateDialogUsed(state, val) {
state.dialogUsed = val;
},
updateErrors(state, val) {
state.errors = val;
},
updateDialogDelete(state, val) {
state.dialogDelete = val;
},
updateDialogConfirmation(state, val) {
state.dialogConfirmation = val;
},
updateSearch(state, val) {
state.search = val;
state.currentPage = 1; // Reset to first page on new search
},
updateStatusConfirm(state, val) {
state.statusConfirm = val;
},
updateStatusConfirmOptions(state, val) {
state.statusConfirmOptions = val;
},
updateMenuStartDate(state, val) {
state.menuStartDate = val;
},
updateMenuEndDate(state, val) {
state.menuEndDate = val;
},
updateFStartDate(state, val) {
state.fStartDate = val;
},
updateFEndDate(state, val) {
state.fEndDate = val;
},
updateDStartDate(state, val) {
state.dStartDate = val;
},
updateDEndDate(state, val) {
state.dEndDate = val;
}
},
actions: {
async getItemUsed(context, payload) {
context.commit("updateLoadingStatus", 1);
try {
payload.token = one_token();
// var payload = {
// itemUsageID: context.state.usage.selectedItemUsage.ItemUsageID,
// currentPage: context.state.currentPage,
// search: context.state.search,
// statusConfirm: context.state.statusConfirm,
// token: one_token()
// };
let response = await api.getItemUsed(payload);
if (response.status != "OK") {
context.commit("updateLoadingStatus", 3);
context.commit("updateErrMessage", response.message);
context.commit("updateAlertError", true);
} else {
context.commit("updateLoadingStatus", 2);
context.commit("updateErrMessage", "");
let data = {
records: response.data.records,
total_page: response.data.total_page,
};
context.commit("updateItemUsedList", data.records);
context.commit("updateTotalPageUsed", data.total_page);
}
} catch (e) {
context.commit("updateLoadingStatus", 3);
context.commit("updateErrMessage", e.message);
context.commit("updateAlertError", true);
}
},
async updateItemUsed(context, payload) {
context.commit("updateLoadingStatus", 1);
try {
payload.token = one_token();
let response = await api.updateItemUsed(payload);
if (response.status != "OK") {
context.commit("updateLoadingStatus", 3);
context.commit("updateErrMessage", response.message);
context.commit("updateAlertError", true);
} else {
context.commit("updateLoadingStatus", 2);
context.commit("updateErrMessage", "");
context.commit("updateDialogUsed", false);
context.commit("updateSelectedItemUsed", {});
context.commit("updateSelectedUsedQty", 0);
context.commit("usage/update_last_id", payload.itemUsageID, { root: true });
context.commit("updateSnackbar", {
state: true,
type: 'success',
message: 'Item used berhasil diupdate.'
});
context.dispatch("usage/search",{}, { root: true });
context.dispatch("getItemUsed", {
itemUsageID: payload.itemUsageID,
currentPage: payload.currentPage,
search: payload.search,
statusConfirm: payload.statusConfirm,
startdate: payload.startdate,
enddate: payload.enddate
});
}
} catch (e) {
context.commit("updateLoadingStatus", 3);
context.commit("updateErrMessage", e.message);
context.commit("updateAlertError", true);
}
},
async deleteItemUsed(context, payload) {
context.commit("updateLoadingStatus", 1);
try {
payload.token = one_token();
let response = await api.deleteItemUsed(payload);
if (response.status != "OK") {
context.commit("updateLoadingStatus", 3);
context.commit("updateErrMessage", response.message);
context.commit("updateAlertError", true);
} else {
context.commit("updateLoadingStatus", 2);
context.commit("updateErrMessage", "");
context.commit("updateDialogDelete", false);
context.commit("updateSelectedItemUsed", {});
context.commit("usage/update_last_id", payload.itemUsageID, { root: true });
context.commit("updateSnackbar", {
state: true,
type: 'success',
message: 'Item used berhasil dihapus.'
});
context.dispatch("usage/search",{}, { root: true });
context.dispatch("getItemUsed", {
itemUsageID: payload.itemUsageID,
currentPage: payload.currentPage,
search: payload.search,
statusConfirm: payload.statusConfirm,
startdate: payload.startdate,
enddate: payload.enddate
});
}
} catch (e) {
context.commit("updateLoadingStatus", 3);
context.commit("updateErrMessage", e.message);
context.commit("updateAlertError", true);
}
},
async confirmItemUsed(context, payload) {
context.commit("updateLoadingStatus", 1);
try {
payload.token = one_token();
let response = await api.confirmItemUsed(payload);
if (response.status != "OK") {
context.commit("updateLoadingStatus", 3);
context.commit("updateErrMessage", response.message);
context.commit("updateAlertError", true);
} else {
context.commit("updateLoadingStatus", 2);
context.commit("updateErrMessage", "");
context.commit("updateSelectedItemUsed", {});
context.commit("updateDialogConfirmation", false);
context.commit("usage/update_last_id", payload.itemUsageID, { root: true });
context.commit("updateSnackbar", {
state: true,
type: 'success',
message: 'Item used berhasil dikonfirmasi.'
});
context.dispatch("getItemUsed", {
itemUsageID: payload.itemUsageID,
currentPage: payload.currentPage,
search: payload.search,
statusConfirm: payload.statusConfirm,
startdate: payload.startdate,
enddate: payload.enddate
});
}
} catch (e) {
context.commit("updateLoadingStatus", 3);
context.commit("updateErrMessage", e.message);
context.commit("updateAlertError", true);
}
}
}
};

View File

@@ -0,0 +1,13 @@
import usage from "./modules/usage.js";
import used from "./modules/used.js";
import system from "../../../apps/modules/system/system.js";
export const store = new Vuex.Store({
modules: {
usage: usage,
used: used,
system: system,
},
state: {},
mutations: {},
actions: {},
});