add modules folder based on s_menu
This commit is contained in:
425
test/vuex/acc-one-purchase-request-persediaan/api/api.js
Normal file
425
test/vuex/acc-one-purchase-request-persediaan/api/api.js
Normal file
@@ -0,0 +1,425 @@
|
||||
const URL = "/one-api/mockup/purchase/requester/";
|
||||
|
||||
export async function search(payload) {
|
||||
try {
|
||||
var response = await axios.post(URL + "PurchaseRequestPersediaan/search", payload);
|
||||
if (response.status !== 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: response.statusText,
|
||||
};
|
||||
}
|
||||
|
||||
let data = response.data;
|
||||
return data;
|
||||
} catch (e) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export async function searchDetail(payload) {
|
||||
try {
|
||||
var response = await axios.post(
|
||||
URL + "PurchaseRequestPersediaan/searchDetail",
|
||||
payload
|
||||
);
|
||||
if (response.status !== 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: response.statusText,
|
||||
};
|
||||
}
|
||||
|
||||
let data = response.data;
|
||||
return data;
|
||||
} catch (e) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export async function getRegional(payload) {
|
||||
try {
|
||||
var response = await axios.post(URL + "PurchaseRequestPersediaan/getRegionalBranchByUser", payload);
|
||||
if (response.status !== 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: response.statusText,
|
||||
};
|
||||
}
|
||||
|
||||
let data = response.data;
|
||||
return data;
|
||||
} catch (e) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export async function getBranch(payload) {
|
||||
try {
|
||||
var response = await axios.post(URL + "PurchaseRequestPersediaan/getBranch", payload);
|
||||
if (response.status !== 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: response.statusText,
|
||||
};
|
||||
}
|
||||
|
||||
let data = response.data;
|
||||
return data;
|
||||
} catch (e) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export async function saveRequest(payload) {
|
||||
try {
|
||||
var response = await axios.post(
|
||||
URL + "PurchaseRequestPersediaan/saveRequest",
|
||||
payload
|
||||
);
|
||||
if (response.status !== 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: response.statusText,
|
||||
};
|
||||
}
|
||||
|
||||
let data = response.data;
|
||||
return data;
|
||||
} catch (e) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export async function updateRequest(payload) {
|
||||
try {
|
||||
var response = await axios.post(
|
||||
URL + "PurchaseRequestPersediaan/updateRequest",
|
||||
payload
|
||||
);
|
||||
if (response.status !== 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: response.statusText,
|
||||
};
|
||||
}
|
||||
|
||||
let data = response.data;
|
||||
return data;
|
||||
} catch (e) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export async function deleteRequest(payload) {
|
||||
try {
|
||||
var response = await axios.post(
|
||||
URL + "PurchaseRequestPersediaan/deleteRequest",
|
||||
payload
|
||||
);
|
||||
if (response.status !== 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: response.statusText,
|
||||
};
|
||||
}
|
||||
|
||||
let data = response.data;
|
||||
return data;
|
||||
} catch (e) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export async function saveDetail(payload) {
|
||||
try {
|
||||
var response = await axios.post(
|
||||
URL + "PurchaseRequestPersediaan/saveDetail",
|
||||
payload
|
||||
);
|
||||
if (response.status !== 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: response.statusText,
|
||||
};
|
||||
}
|
||||
|
||||
let data = response.data;
|
||||
return data;
|
||||
} catch (e) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message,
|
||||
};
|
||||
}
|
||||
}
|
||||
export async function updateDetail(payload) {
|
||||
try {
|
||||
var response = await axios.post(
|
||||
URL + "PurchaseRequestPersediaan/updateDetail",
|
||||
payload
|
||||
);
|
||||
if (response.status !== 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: response.statusText,
|
||||
};
|
||||
}
|
||||
|
||||
let data = response.data;
|
||||
return data;
|
||||
} catch (e) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message,
|
||||
};
|
||||
}
|
||||
}
|
||||
export async function deleteDetail(payload) {
|
||||
try {
|
||||
var response = await axios.post(
|
||||
URL + "PurchaseRequestPersediaan/deleteDetail",
|
||||
payload
|
||||
);
|
||||
if (response.status !== 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: response.statusText,
|
||||
};
|
||||
}
|
||||
|
||||
let data = response.data;
|
||||
return data;
|
||||
} catch (e) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export async function orderRequest(payload) {
|
||||
try {
|
||||
var response = await axios.post(
|
||||
URL + "PurchaseRequestPersediaan/orderRequest",
|
||||
payload
|
||||
);
|
||||
if (response.status !== 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: response.statusText,
|
||||
};
|
||||
}
|
||||
|
||||
let data = response.data;
|
||||
return data;
|
||||
} catch (e) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export async function getUnit(token, prm) {
|
||||
try {
|
||||
var resp = await axios.post(URL + 'PurchaseRequestPersediaan/getUnit', {
|
||||
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 getDivisionByUser(token) {
|
||||
try {
|
||||
var resp = await axios.post(URL + 'PurchaseRequestPersediaan/getDivisionByUser', {
|
||||
token: token
|
||||
});
|
||||
if (resp.status != 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: resp.statusText
|
||||
};
|
||||
}
|
||||
let data = resp.data;
|
||||
return data;
|
||||
} catch (e) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export async function getItems(payload) {
|
||||
try {
|
||||
var resp = await axios.post(URL + 'PurchaseRequestPersediaan/getItems', 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 getItemGroupSubGroup(payload) {
|
||||
try {
|
||||
var resp = await axios.post(URL + 'PurchaseRequestPersediaan/getItemGroupSubGroup', 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 + 'PurchaseRequestPersediaan/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
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export async function savePurchaseRequest(payload) {
|
||||
try {
|
||||
var response = await axios.post(URL + 'PurchaseRequestPersediaan/savePurchaseRequest', payload);
|
||||
if (response.status != 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: response.statusText
|
||||
};
|
||||
}
|
||||
let data = response.data;
|
||||
return data;
|
||||
} catch (e) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export async function saveAndDoPurchaseRequest(payload){
|
||||
try {
|
||||
var response = await axios.post(URL + 'PurchaseRequestPersediaan/saveAndDoPurchaseRequest', payload);
|
||||
if (response.status != 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: response.statusText
|
||||
};
|
||||
}
|
||||
let data = response.data;
|
||||
return data;
|
||||
} catch (e) {
|
||||
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export async function getAPI(fn,payload) {
|
||||
try {
|
||||
let urx = URL + 'PurchaseRequestPersediaan/'+fn;
|
||||
console.log(urx);
|
||||
var response = await axios.post(urx, payload);
|
||||
if (response.status != 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: response.statusText
|
||||
};
|
||||
}
|
||||
let data = response.data;
|
||||
return data;
|
||||
} catch (e) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export async function getRiwayatItem(params) {
|
||||
try {
|
||||
var resp = await axios.post(URL + 'PurchaseRequestPersediaan/getRiwayatItem', params);
|
||||
if (resp.status != 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: resp.statusText
|
||||
};
|
||||
}
|
||||
let data = resp.data;
|
||||
return data;
|
||||
} catch (error) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: error.message
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,848 @@
|
||||
<template>
|
||||
<v-layout row justify-center>
|
||||
<!-- Dialog Ganti Unit -->
|
||||
<v-dialog v-model="dialogUnit" persistent max-width="25%">
|
||||
<v-card>
|
||||
<v-card-title class="title grey lighten-2" primary-title>
|
||||
Ganti Satuan {{ selectedItem.itemDesc ? selectedItem.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="unitName"></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>
|
||||
|
||||
<!-- Dialog Induk Form Request -->
|
||||
<v-dialog v-model="dialogRequest" persistent max-width="75%">
|
||||
<v-card>
|
||||
<v-card-title class="headline grey lighten-2" primary-title>
|
||||
FORM STOCK REQUEST
|
||||
</v-card-title>
|
||||
<v-card-text class="pt-0 pb-0">
|
||||
|
||||
<v-layout row>
|
||||
<v-flex pa-2 xs6>
|
||||
<v-menu v-model="menuDateUse" :close-on-content-click="false" transition="scale-transition"
|
||||
:nudge-right="40" lazy :disabled="act == 'preview'" offset-y full-width max-width="290px"
|
||||
min-width="290px">
|
||||
<template v-slot:activator="{ on }">
|
||||
<v-text-field :value="dateUseFormatted" label="Tanggal Permintaan" readonly v-on="on"
|
||||
@blur="dDateUse = deFormatedDate(dateUseFormatted)"></v-text-field>
|
||||
</template>
|
||||
<v-date-picker no-title v-model="xDateUse" @input="menuDateUse = false"></v-date-picker>
|
||||
</v-menu>
|
||||
</v-flex>
|
||||
<v-flex pa-2 xs6>
|
||||
<v-autocomplete v-model="xRegional" label="Regional*" menu-icon="mdi-chevron-down"
|
||||
:items="regionalOptions" item-text="S_RegionalName" :disabled="act == 'preview'"
|
||||
item-value="S_RegionalID" return-object readonly :error="errors.regional"
|
||||
:error-messages="errors.regional ? 'Regional harus diisi' : ''"></v-autocomplete>
|
||||
</v-flex>
|
||||
<v-flex pa-2 xs6>
|
||||
<v-autocomplete v-model="xBranch" :label="user.M_BranchID != '0' ? 'Cabang*' : 'Cabang'" menu-icon="mdi-chevron-down" :items="branchOptions"
|
||||
item-text="M_BranchName" item-value="M_BranchCode" placeholder="Pilih Cabang"
|
||||
:disabled="act == 'preview'" return-object :error="errors.branch"
|
||||
:error-messages="errors.branch ? 'Cabang harus diisi' : ''"></v-autocomplete>
|
||||
</v-flex>
|
||||
<v-flex pa-2 xs6>
|
||||
<v-text-field v-model="xDescription" label="Keterangan*" :disabled="act == 'preview'"
|
||||
:error="errors.description" :error-messages="errors.description ? 'Keterangan harus diisi' : ''"
|
||||
required></v-text-field>
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
<v-layout row>
|
||||
<v-flex pa-2 pl-0 xs12>
|
||||
<v-btn v-if="dialogItem == false && act != 'preview'" color="primary" @click="dialogItem = true">Pilih
|
||||
Item</v-btn>
|
||||
<v-btn v-if="dialogItem == true && act != 'preview'" color="primary" @click="dialogItem = false">Tutup
|
||||
Pilih
|
||||
Item</v-btn>
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
<v-layout v-if="errors.details" row>
|
||||
<v-flex xs12 pl-2 pr-2 pt-2 pb-2>
|
||||
<v-alert :value="true" type="error" dismissible v-html="msgErrDetails">
|
||||
|
||||
</v-alert>
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
|
||||
<div v-if="dialogItem == true && act != 'preview'">
|
||||
<v-divider></v-divider>
|
||||
<v-card elevation="10" class=" mt-2">
|
||||
<v-layout row>
|
||||
<v-flex class="mt-2" pa-2 pb-0 xs3>
|
||||
<v-text-field v-model="searchItem" label="Cari..." placeholder="Ketikkan item"
|
||||
style="max-width: 250px" hide-details></v-text-field>
|
||||
</v-flex>
|
||||
<v-flex class="mt-2" pa-2 pb-0 xs3>
|
||||
<v-autocomplete v-model="selectedDivision" :items="divisionOptions" label="Divisi" return-object
|
||||
menu-icon="mdi-chevron-down" item-text="DivisionName" hide-details
|
||||
item-value="DivisionID"></v-autocomplete>
|
||||
|
||||
</v-flex>
|
||||
<v-flex class="mt-2" pa-2 pb-0 xs3>
|
||||
<v-autocomplete v-model="selectedItemGroup" :items="itemGroupOptions" hide-details label="Grup"
|
||||
return-object menu-icon="mdi-chevron-down" item-text="Nat_GroupName"
|
||||
item-value="Nat_GroupID"></v-autocomplete>
|
||||
|
||||
</v-flex>
|
||||
<v-flex class="mt-2" pa-2 pb-0 xs3>
|
||||
<v-autocomplete v-model="selectedItemSubGroup" :items="itemSubGroupOptions" return-object hide-details
|
||||
label="Sub Grup" menu-icon="mdi-chevron-down" item-text="Nat_SubGroupName"
|
||||
item-value="Nat_SubGroupID"></v-autocomplete>
|
||||
|
||||
</v-flex>
|
||||
<v-flex class="mt-2" pa-2 pb-0 xs2>
|
||||
<v-btn dark color="success" style="min-width: 40px; height: 40px; margin: 0" @click="itemSearch()">
|
||||
<v-icon>search</v-icon>
|
||||
</v-btn>
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
|
||||
<v-layout row>
|
||||
<v-flex xs12 pl-2 pr-2 pt-2 pb-2>
|
||||
<v-data-table :headers="headers" :items="items" :loading="loadingItem" 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)">
|
||||
<div style="
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
">
|
||||
{{ props.item.itemCode }}
|
||||
<v-chip small style="border-radius: 5px; flex-grow: 0">
|
||||
{{ props.item.itemDesc }}
|
||||
</v-chip>
|
||||
</div>
|
||||
</td>
|
||||
<td class="text-xs-center pa-2" v-bind:class="{ 'amber lighten-4': isSelected(props.item) }"
|
||||
@click="selectMe(props.item)">
|
||||
{{ props.item.remaining_stock }}
|
||||
</td>
|
||||
<td class="text-xs-center pa-2" v-bind:class="{ 'amber lighten-4': isSelected(props.item) }"
|
||||
@click="selectMe(props.item)">
|
||||
{{ props.item.unitName }}
|
||||
</td>
|
||||
<td class="text-xs-center pa-2" v-bind:class="{ 'amber lighten-4': isSelected(props.item) }"
|
||||
@click="selectMe(props.item)">
|
||||
<!--<v-btn v-if="checkSelected(props.item) == true" flat style="min-width: 35px; height: 35px; margin: 0" small color="grey" depressed><v-icon small>check</v-icon></v-btn---->
|
||||
<v-btn v-if="checkSelected(props.item) == false"
|
||||
style="min-width: 35px; height: 35px; margin: 0" small color="success"
|
||||
@click="addItem(props.item)"><v-icon small>check</v-icon></v-btn>
|
||||
|
||||
<v-btn
|
||||
style="min-width: 35px; height: 35px; margin: 0"
|
||||
small color="info"
|
||||
@click="get_riwayat(props.item.itemId)"
|
||||
>
|
||||
<v-icon small>history</v-icon>
|
||||
</v-btn>
|
||||
</td>
|
||||
</template>
|
||||
</v-data-table>
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
<v-divider></v-divider>
|
||||
<v-layout row>
|
||||
<v-flex xs6>
|
||||
<v-pagination style="margin-top: 10px; margin-bottom: 10px" v-model="itemCurrentPage"
|
||||
:length="itemTotalPage" :total-visible="7"></v-pagination>
|
||||
</v-flex>
|
||||
<v-flex class="pt-2 text-xs-right" xs6>
|
||||
<v-btn color="primary" @click="dialogItem = false">Tutup Pilih Item</v-btn>
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
</v-card>
|
||||
<v-divider></v-divider>
|
||||
</div>
|
||||
<v-card elevation="0" 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="selectedItems" hide-actions
|
||||
:loading="loadingDetailRequest" 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)">
|
||||
<div style="
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
">
|
||||
{{ props.item.itemCode }}
|
||||
<v-chip small style="border-radius: 5px; flex-grow: 0">
|
||||
{{ props.item.itemDesc }}
|
||||
</v-chip>
|
||||
</div>
|
||||
</td>
|
||||
<td class="text-xs-center pa-2" v-bind:class="{ 'amber lighten-4': isSelected(props.item) }"
|
||||
@click="selectMe(props.item)">
|
||||
<v-btn depressed v-if="act != 'preview'" small color="primary"
|
||||
@click="openDialogUnit(props.item)">{{ props.item.unitName }}</v-btn>
|
||||
<span v-else>{{ props.item.unitName }}</span>
|
||||
</td>
|
||||
<td class="text-xs-center pa-2" v-bind:class="{ 'amber lighten-4': isSelected(props.item) }"
|
||||
@click="selectMe(props.item)">
|
||||
<v-text-field v-if="act != 'preview'" v-model="props.item.qty"
|
||||
type="number" min=0 step=1
|
||||
@keypress="blockDecimalInput($event)" @change="updateQuantity(props.item)">
|
||||
</v-text-field>
|
||||
<span v-else>{{ props.item.qty }}</span>
|
||||
</td>
|
||||
<td class="text-xs-center pa-2" v-bind:class="{ 'amber lighten-4': isSelected(props.item) }"
|
||||
@click="selectMe(props.item)">
|
||||
<v-btn v-if="act != 'preview'" style="min-width: 35px; height: 35px; margin: 0" small
|
||||
color="error" dark @click="deleteItem(props.item)"><v-icon small>close</v-icon></v-btn>
|
||||
|
||||
<v-btn
|
||||
style="min-width: 35px; height: 35px; margin: 0"
|
||||
small color="info"
|
||||
@click="get_riwayat(props.item.itemId)"
|
||||
>
|
||||
<v-icon small>history</v-icon>
|
||||
</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 v-if="act === 'new'" color="info" :disabled="loadingSave" dark @click="saveAndRequestPurchase()">Save & Request Purchase</v-btn>
|
||||
<v-btn v-if="act === 'edit'" color="info" :disabled="loadingSave" dark @click="requestPending()">Request Purchase</v-btn>
|
||||
<v-btn color="error" flat @click="closeDialogRequest()">
|
||||
Tutup
|
||||
</v-btn>
|
||||
<v-btn v-if="act === 'new'" color="primary" :disabled="loadingSave" dark
|
||||
@click="savePurchaseRequest()">Simpan</v-btn>
|
||||
<v-btn v-if="act === 'edit'" color="primary" :disabled="loadingSave" dark
|
||||
@click="updatePurchaseRequest()">Simpan
|
||||
Perubahan</v-btn>
|
||||
</v-card-actions>
|
||||
|
||||
</v-card>
|
||||
</v-dialog>
|
||||
|
||||
<one-dialog-alert
|
||||
:status="dialogConfirmRequest"
|
||||
:msg="'Yakin mau melakukan Purchase Request? Tidak bisa diedit setelah melakukan Request'"
|
||||
@forget-dialog-alert="dialogConfirmRequest = false"
|
||||
@close-dialog-alert="confirmAndRequestPurchase()"
|
||||
confirmLabel="Yakin"
|
||||
cancelLabel="Batal"
|
||||
></one-dialog-alert>
|
||||
</v-layout>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
module.exports = {
|
||||
name: "AddPurchaseRequestDialog",
|
||||
components: {
|
||||
"one-dialog-alert": httpVueLoader("../../common/oneDialogAlert.vue")
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
errors: { regional: false, branch: false, description: false, details: false },
|
||||
msgErrDetails: "<p>Data item belum ada. Silahkan masukkan data item terlebih dahulu.</p>",
|
||||
itemUnitChange: {},
|
||||
dialogItem: false,
|
||||
regionalRules: [(v) => !!v || "Regional harus diisi"],
|
||||
branchRules: [(v) => !!v || "Cabang harus diisi"],
|
||||
descRules: [(v) => !!v || "Keterangan harus diisi"],
|
||||
validationForm: true,
|
||||
dialogConfirmRequest: false,
|
||||
headers: [
|
||||
{
|
||||
text: "ITEM PERSEDIAAN",
|
||||
align: "center",
|
||||
sortable: false,
|
||||
value: "itemName",
|
||||
width: "15%",
|
||||
class: "success lighten-3 white--text",
|
||||
},
|
||||
{
|
||||
text: "SISA STOCK",
|
||||
align: "center",
|
||||
sortable: false,
|
||||
value: "qty",
|
||||
width: "10%",
|
||||
class: "success lighten-3 white--text",
|
||||
},
|
||||
{
|
||||
text: "SATUAN",
|
||||
align: "center",
|
||||
sortable: false,
|
||||
value: "unitName",
|
||||
width: "15%",
|
||||
class: "success lighten-3 white--text",
|
||||
},
|
||||
{
|
||||
text: "AKSI",
|
||||
align: "center",
|
||||
sortable: false,
|
||||
value: "action",
|
||||
width: "10%",
|
||||
class: "success lighten-3 white--text",
|
||||
},
|
||||
],
|
||||
headersItems: [
|
||||
{
|
||||
text: "ITEM PERSEDIAAN",
|
||||
align: "center",
|
||||
sortable: false,
|
||||
value: "itemName",
|
||||
width: "15%",
|
||||
class: "blue lighten-3 white--text",
|
||||
},
|
||||
{
|
||||
text: "SATUAN",
|
||||
align: "center",
|
||||
sortable: false,
|
||||
value: "unitName",
|
||||
width: "15%",
|
||||
class: "blue lighten-3 white--text",
|
||||
},
|
||||
{
|
||||
text: "JUMLAH",
|
||||
align: "center",
|
||||
sortable: false,
|
||||
value: "qty",
|
||||
width: "10%",
|
||||
class: "blue lighten-3 white--text",
|
||||
},
|
||||
{
|
||||
text: "AKSI",
|
||||
align: "center",
|
||||
sortable: false,
|
||||
value: "action",
|
||||
width: "10%",
|
||||
class: "blue lighten-3 white--text",
|
||||
},
|
||||
]
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
loadingDetailRequest() {
|
||||
return this.$store.state.requester.loadingDetailRequest;
|
||||
},
|
||||
loadingUnit() {
|
||||
return this.$store.state.requester.loadingUnit;
|
||||
},
|
||||
dialogUnit: {
|
||||
get() {
|
||||
return this.$store.state.requester.dialogUnit;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("requester/updateDialogUnit", val);
|
||||
},
|
||||
},
|
||||
selectedUnit: {
|
||||
get() {
|
||||
return this.$store.state.requester.selectedUnit;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("requester/updateSelectedUnit", val);
|
||||
},
|
||||
},
|
||||
unitOptions: {
|
||||
get() {
|
||||
return this.$store.state.requester.unitOptions;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("requester/updateUnitOptions", val);
|
||||
},
|
||||
},
|
||||
dialogRequest: {
|
||||
get() {
|
||||
return this.$store.state.requester.dialogRequest;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("requester/updateDialogRequest", val);
|
||||
},
|
||||
},
|
||||
menuDateUse: {
|
||||
get() {
|
||||
return this.$store.state.requester.menuDateUse;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("requester/updateMenuDateUse", val);
|
||||
},
|
||||
},
|
||||
dateUseFormatted() {
|
||||
return this.formatDate(this.xDateUse);
|
||||
},
|
||||
dDateUse: {
|
||||
get() {
|
||||
return this.$store.state.requester.dDateUse;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("requester/updateDDateUse", val);
|
||||
},
|
||||
},
|
||||
xDateUse: {
|
||||
get() {
|
||||
return this.$store.state.requester.xDateUse;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("requester/updateXDateUse", val);
|
||||
},
|
||||
},
|
||||
xBranch: {
|
||||
get() {
|
||||
return this.$store.state.requester.xBranch;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("requester/updateXBranch", val);
|
||||
},
|
||||
},
|
||||
branchOptions() {
|
||||
return this.$store.state.requester.branchOptions;
|
||||
},
|
||||
regionalOptions() {
|
||||
return this.$store.state.requester.regionalOptions;
|
||||
},
|
||||
xRegional: {
|
||||
get() {
|
||||
return this.$store.state.requester.xRegional;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("requester/updateXRegional", val);
|
||||
},
|
||||
},
|
||||
xDescription: {
|
||||
get() {
|
||||
return this.$store.state.requester.xDescription;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("requester/updateXDescription", val);
|
||||
},
|
||||
},
|
||||
xPRID() {
|
||||
return this.$store.state.requester.xPRID;
|
||||
},
|
||||
act() {
|
||||
return this.$store.state.requester.act;
|
||||
},
|
||||
itemCurrentPage: {
|
||||
get() {
|
||||
return this.$store.state.requester.itemCurrentPage;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("requester/updateItemCurrentPage", val);
|
||||
this.$store.dispatch("requester/getItems", {
|
||||
search: this.searchItem,
|
||||
division: this.selectedDivision.DivisionID ? this.selectedDivision.DivisionID : "",
|
||||
itemGroup: this.selectedItemGroup.Nat_GroupID ? this.selectedItemGroup.Nat_GroupID : "",
|
||||
itemSubGroup: this.selectedItemSubGroup.Nat_SubGroupID ? this.selectedItemSubGroup.Nat_SubGroupID : ""
|
||||
});
|
||||
},
|
||||
},
|
||||
itemTotalPage: {
|
||||
get() {
|
||||
return this.$store.state.requester.itemTotalPage;
|
||||
},
|
||||
},
|
||||
items: {
|
||||
get() {
|
||||
return this.$store.state.requester.items;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("requester/updateItems", val);
|
||||
}
|
||||
},
|
||||
selectedItem: {
|
||||
get() {
|
||||
return this.$store.state.requester.selectedItem;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("requester/updateSelectedItem", val);
|
||||
}
|
||||
},
|
||||
searchItem: {
|
||||
get() {
|
||||
return this.$store.state.requester.searchItem;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("requester/updateSearchItem", val);
|
||||
}
|
||||
},
|
||||
loadingItem: {
|
||||
get() {
|
||||
return this.$store.state.requester.loadingItem;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("requester/updateLoadingItem", val);
|
||||
}
|
||||
},
|
||||
itemGroupOptions: {
|
||||
get() {
|
||||
return this.$store.state.requester.itemGroupOptions;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("requester/updateItemGroupOptions", val);
|
||||
}
|
||||
},
|
||||
selectedItemGroup: {
|
||||
get() {
|
||||
return this.$store.state.requester.selectedItemGroup;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("requester/updateSelectedItemGroup", val);
|
||||
console.log(val)
|
||||
this.$store.commit("requester/updateItemSubGroupOptions", val.subGroups);
|
||||
this.$store.commit("requester/updateSelectedItemSubGroup", val.subGroups[0]);
|
||||
}
|
||||
},
|
||||
itemSubGroupOptions: {
|
||||
get() {
|
||||
return this.$store.state.requester.itemSubGroupOptions;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("requester/updateItemSubGroupOptions", val);
|
||||
}
|
||||
},
|
||||
selectedItemSubGroup: {
|
||||
get() {
|
||||
return this.$store.state.requester.selectedItemSubGroup;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("requester/updateSelectedItemSubGroup", val);
|
||||
|
||||
}
|
||||
},
|
||||
loadingItemSubGroup: {
|
||||
get() {
|
||||
return this.$store.state.requester.loadingItemSubGroup;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("requester/updateLoadingItemSubGroup", val);
|
||||
}
|
||||
},
|
||||
loadingItemGroup: {
|
||||
get() {
|
||||
return this.$store.state.requester.loadingItemGroup;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("requester/updateLoadingItemGroup", val);
|
||||
}
|
||||
},
|
||||
divisionOptions: {
|
||||
get() {
|
||||
return this.$store.state.requester.divisionOptions;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("requester/updateDivisionOptions", val);
|
||||
}
|
||||
},
|
||||
selectedDivision: {
|
||||
get() {
|
||||
return this.$store.state.requester.selectedDivision;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("requester/updateSelectedDivision", val);
|
||||
this.$store.dispatch("requester/getItemGroupSubGroup");
|
||||
}
|
||||
},
|
||||
loadingSave: {
|
||||
get() {
|
||||
return this.$store.state.requester.loadingSave;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("requester/updateLoadingSave", val);
|
||||
}
|
||||
},
|
||||
selectedItem: {
|
||||
get() {
|
||||
return this.$store.state.requester.selectedItem;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("requester/updateSelectedItem", val);
|
||||
}
|
||||
},
|
||||
selectedItems: {
|
||||
get() {
|
||||
return this.$store.state.requester.selectedItems;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("requester/updateSelectedItems", val);
|
||||
}
|
||||
},
|
||||
dialog_riwayat: {
|
||||
get() {
|
||||
return this.$store.state.requester.dialog_riwayat
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("requester/update_dialog_riwayat", val)
|
||||
}
|
||||
},
|
||||
user: {
|
||||
get() {
|
||||
return this.$store.state.requester.user
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("requester/updateUser", val)
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
blockDecimalInput(e) {
|
||||
const invalidChars = ['.', ',', '-', 'e'];
|
||||
if (invalidChars.includes(e.key)) {
|
||||
e.preventDefault();
|
||||
}
|
||||
},
|
||||
|
||||
requestPending() {
|
||||
let items = this.$store.state.requester.selectedItems;
|
||||
let valid = true
|
||||
items.forEach(item => {
|
||||
if (item.qty <= 0.9) {
|
||||
valid = false
|
||||
}
|
||||
});
|
||||
if (valid == true) {
|
||||
this.$store.commit("requester/updateLoadingSave", true);
|
||||
this.$store.dispatch("requester/updatePurchaseRequest", {
|
||||
act: "pending",
|
||||
PRID: this.$store.state.requester.selectedMainTable.prId,
|
||||
PRNumber: this.$store.state.requester.selectedMainTable.prNumber,
|
||||
PRDateUse: this.xDateUse,
|
||||
PRRegional: this.xRegional.S_RegionalID,
|
||||
PRBranch: typeof this.xBranch === "object" && this.xBranch !== null && "M_BranchCode" in this.xBranch ? this.xBranch.M_BranchCode : "",
|
||||
PRDescription: this.xDescription,
|
||||
items: this.$store.state.requester.selectedItems
|
||||
});
|
||||
this.errors.details = false;
|
||||
|
||||
} else {
|
||||
this.errors.details = true;
|
||||
if (this.msgErrDetails == "") {
|
||||
this.msgErrDetails = "<p>Qty " + item.itemDesc + " tidak boleh 0</p>";
|
||||
} else {
|
||||
this.msgErrDetails += "<p>Qty " + item.itemDesc + " tidak boleh 0</p>";
|
||||
}
|
||||
}
|
||||
},
|
||||
saveAndRequestPurchase() {
|
||||
if (this.validateForm()) {
|
||||
// Show confirmation dialog instead of proceeding directly
|
||||
this.dialogConfirmRequest = true;
|
||||
} else {
|
||||
this.errors.details = true;
|
||||
this.msgErrDetails = this.selectedItems.length == 0 ?
|
||||
"<p>Data item belum ada. Silahkan masukkan data item terlebih dahulu.</p>" :
|
||||
this.msgErrDetails;
|
||||
}
|
||||
},
|
||||
confirmAndRequestPurchase() {
|
||||
// Close the dialog
|
||||
this.dialogConfirmRequest = false;
|
||||
|
||||
// Now proceed with the actual save and request
|
||||
this.$store.commit("requester/updateLoadingSave", true);
|
||||
this.$store.dispatch("requester/saveAndDoPurchaseRequest", {
|
||||
PRDateUse: this.xDateUse,
|
||||
PRRegional: this.xRegional.S_RegionalID,
|
||||
PRBranch: typeof this.xBranch === "object" && this.xBranch !== null && "M_BranchCode" in this.xBranch ? this.xBranch.M_BranchCode : "",
|
||||
PRDescription: this.xDescription,
|
||||
items: this.selectedItems
|
||||
});
|
||||
},
|
||||
|
||||
updatePurchaseRequest() {
|
||||
if (this.validateForm()) {
|
||||
this.$store.commit("requester/updateLoadingSave", true);
|
||||
this.$store.dispatch("requester/updatePurchaseRequest", {
|
||||
act: "edit",
|
||||
PRID: this.$store.state.requester.selectedMainTable.prId,
|
||||
PRNumber: this.$store.state.requester.selectedMainTable.prNumber,
|
||||
PRDateUse: this.xDateUse,
|
||||
PRRegional: this.xRegional.S_RegionalID,
|
||||
PRBranch: typeof this.xBranch === "object" && this.xBranch !== null && "M_BranchCode" in this.xBranch ? this.xBranch.M_BranchCode : "",
|
||||
PRDescription: this.xDescription,
|
||||
items: this.selectedItems
|
||||
});
|
||||
}
|
||||
|
||||
},
|
||||
checkSelected(item) {
|
||||
let selectedItems = this.selectedItems;
|
||||
let rtn = false
|
||||
if (selectedItems.length == 0) {
|
||||
console.log(item.itemId, "selectedItems.length == 0");
|
||||
rtn = false;
|
||||
}
|
||||
selectedItems.forEach(itemloop => {
|
||||
if (itemloop.itemId == item.itemId) {
|
||||
console.log(item.itemId, "itemloop.itemId == item.itemId");
|
||||
rtn = true;
|
||||
}
|
||||
});
|
||||
console.log(item.itemId, "return false");
|
||||
return rtn;
|
||||
},
|
||||
savePurchaseRequest() {
|
||||
if (this.validateForm()) {
|
||||
this.$store.commit("requester/updateLoadingSave", true);
|
||||
this.$store.dispatch("requester/savePurchaseRequest", {
|
||||
PRDateUse: this.xDateUse,
|
||||
PRRegional: this.xRegional.S_RegionalID,
|
||||
PRBranch: typeof this.xBranch === "object" && this.xBranch !== null && "M_BranchCode" in this.xBranch ? this.xBranch.M_BranchCode : "",
|
||||
PRDescription: this.xDescription,
|
||||
items: this.selectedItems
|
||||
});
|
||||
}
|
||||
|
||||
},
|
||||
itemSearch() {
|
||||
this.$store.dispatch("requester/getItems", {
|
||||
search: this.searchItem,
|
||||
division: this.selectedDivision.DivisionID ? this.selectedDivision.DivisionID : "",
|
||||
itemGroup: this.selectedItemGroup.Nat_GroupID ? this.selectedItemGroup.Nat_GroupID : "",
|
||||
itemSubGroup: this.selectedItemSubGroup.Nat_SubGroupID ? this.selectedItemSubGroup.Nat_SubGroupID : ""
|
||||
});
|
||||
},
|
||||
addItem(item) {
|
||||
let selectedItems = this.selectedItems;
|
||||
let index = selectedItems.findIndex(itemloop => itemloop.itemId == item.itemId);
|
||||
if (index == -1) {
|
||||
selectedItems.push(item);
|
||||
}
|
||||
|
||||
this.$store.commit("requester/updateSelectedItems", selectedItems);
|
||||
console.log(this.selectedItems);
|
||||
},
|
||||
deleteItem(item) {
|
||||
let selectedItems = this.selectedItems;
|
||||
let index = selectedItems.findIndex(itemloop => itemloop.itemId == item.itemId);
|
||||
if (index != -1) {
|
||||
selectedItems.splice(index, 1);
|
||||
}
|
||||
this.$store.commit("requester/updateSelectedItems", selectedItems);
|
||||
},
|
||||
|
||||
updateQuantity(item) {
|
||||
let items = this.selectedItems;
|
||||
let index = items.findIndex(itemloop => itemloop.itemId == item.itemId);
|
||||
items[index].qty = item.qty;
|
||||
console.log(items[index].qty)
|
||||
this.$store.commit("requester/updateSelectedItems", items);
|
||||
},
|
||||
saveUnit() {
|
||||
let items = this.selectedItems;
|
||||
let index = items.findIndex(itemloop => itemloop.itemId == this.itemUnitChange.itemId);
|
||||
let selectedUnit = this.selectedUnit;
|
||||
|
||||
items[index].unitId = selectedUnit.unitId;
|
||||
items[index].unitCode = selectedUnit.unitCode;
|
||||
items[index].unitName = selectedUnit.unitName;
|
||||
this.$store.commit("requester/updateSelectedItems", items);
|
||||
this.$store.commit("requester/updateDialogUnit", false);
|
||||
},
|
||||
openDialogUnit(item) {
|
||||
this.itemUnitChange = item
|
||||
this.$store.dispatch("requester/getUnitByItemId", {
|
||||
itemId: item.itemId,
|
||||
selectedUnit: { unitId: item.unitId, unitCode: item.unitCode, unitName: item.unitName }
|
||||
});
|
||||
},
|
||||
isSelected(p) {
|
||||
return (
|
||||
p.itemId ==
|
||||
this.$store.state.requester.selectedItem
|
||||
.itemId
|
||||
);
|
||||
},
|
||||
selectMe(spr) {
|
||||
this.$store.commit("requester/updateSelectedItem", spr);
|
||||
},
|
||||
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")}`;
|
||||
},
|
||||
closeDialogRequest() {
|
||||
this.errors.details = false
|
||||
this.$store.commit(
|
||||
"requester/updateXDateUse",
|
||||
moment(new Date()).format("YYYY-MM-DD")
|
||||
);
|
||||
this.$store.commit("requester/updateXBranch", "");
|
||||
this.$store.commit("requester/updateXRegional", "");
|
||||
this.$store.commit("requester/updateXDescription", "");
|
||||
this.$store.commit("requester/updateDialogRequest", false);
|
||||
this.$store.commit("requester/updateSelectedItems", []);
|
||||
},
|
||||
validateForm() {
|
||||
this.errors.regional = _.isEmpty(this.xRegional) ? true : false;
|
||||
if (this.user.M_BranchID == '0') {
|
||||
this.errors.branch = false
|
||||
} else if (this.user.M_BranchID != '0') {
|
||||
this.errors.branch = _.isEmpty(this.xBranch) ? true : false;
|
||||
}
|
||||
this.errors.description = this.xDescription == "" ? true : false;
|
||||
this.errors.details = this.selectedItems.length == 0 ? true : false;
|
||||
this.msgErrDetails = this.selectedItems.length == 0 ? "<p>Data item belum ada. Silahkan masukkan data item terlebih dahulu.</p>" : "";
|
||||
|
||||
let details = this.selectedItems
|
||||
details.forEach(item => {
|
||||
if (parseInt(item.qty) == 0 || item.qty == "" || parseInt(item.qty) <= 0) {
|
||||
this.errors.details = true;
|
||||
if (this.msgErrDetails == "") {
|
||||
this.msgErrDetails = "<p>Qty " + item.itemDesc + " tidak boleh 0</p>";
|
||||
} else {
|
||||
this.msgErrDetails += "<p>Qty " + item.itemDesc + " tidak boleh 0</p>";
|
||||
}
|
||||
}
|
||||
});
|
||||
//console.log(this.errors.details);
|
||||
if (this.errors.regional == false && this.errors.branch == false && this.errors.description == false && this.errors.details == false) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
get_riwayat(id) {
|
||||
this.$store.dispatch("requester/getRiwayatItem", {itemid: id})
|
||||
this.dialog_riwayat = true
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
dialogItem(newVal) {
|
||||
if (newVal == true) {
|
||||
this.$store.commit("requester/updateItems", []);
|
||||
this.$store.dispatch("requester/getItems", {
|
||||
search: this.searchItem,
|
||||
division: this.selectedDivision.DivisionID ? this.selectedDivision.DivisionID : "",
|
||||
itemGroup: this.selectedItemGroup.Nat_GroupID ? this.selectedItemGroup.Nat_GroupID : "",
|
||||
itemSubGroup: this.selectedItemSubGroup.Nat_SubGroupID ? this.selectedItemSubGroup.Nat_SubGroupID : ""
|
||||
});
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
@@ -0,0 +1,280 @@
|
||||
<template>
|
||||
<v-layout row justify-center>
|
||||
<v-dialog v-model="dialogDetail" persistent max-width="500px">
|
||||
<v-card>
|
||||
<v-card-title class="headline grey lighten-2" primary-title>
|
||||
FORM REQUEST DETAIL <span class="text-h6 font-weight-bold" v-if="act === 'edit'"> {{selectedMainTable.prNumber}}</span>
|
||||
</v-card-title>
|
||||
<v-card-text class="pt-0 pb-0">
|
||||
<v-form ref="formDetail" v-model="validationDetail" lazy-validtion>
|
||||
<v-layout wrap>
|
||||
<v-flex xs12>
|
||||
<v-text-field
|
||||
v-model="xDescriptionDetail"
|
||||
label="Deskripsi"
|
||||
:rules="descriptionRules"
|
||||
required
|
||||
></v-text-field>
|
||||
</v-flex>
|
||||
<v-flex xs12>
|
||||
<v-text-field
|
||||
v-model="xAmountRequest"
|
||||
type="number"
|
||||
label="Jumlah"
|
||||
:min="1"
|
||||
:rules="amountRules"
|
||||
required
|
||||
></v-text-field>
|
||||
</v-flex>
|
||||
<v-flex xs12>
|
||||
<v-autocomplete label="Item Unit" v-model="selected_item_unit"
|
||||
:items="item_units" :search-input.sync="search_item_unit"
|
||||
auto-select-first no-filter item-text="ItemUnitName"
|
||||
return-object
|
||||
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>
|
||||
</v-flex>
|
||||
<v-flex xs12>
|
||||
<!-- <v-text-field
|
||||
v-model="xEstimationPrice"
|
||||
label="Harga"
|
||||
type="number"
|
||||
:min="1"
|
||||
prefix="Rp "
|
||||
:rules="priceRules"
|
||||
required
|
||||
:hint="convertMoney(xEstimationPrice)"
|
||||
></v-text-field> -->
|
||||
<v-text-field
|
||||
v-model="xEstimationPrice"
|
||||
label="Harga"><template v-slot:append-outer>
|
||||
<span class="text-h4 font-weight-bold">{{formatAngka(xEstimationPrice)}}</span>
|
||||
</template>
|
||||
</v-text-field>
|
||||
</v-flex>
|
||||
<v-flex xs12>
|
||||
<!-- <v-text-field
|
||||
v-model="total_price"
|
||||
label="Total Harga"
|
||||
type="number"
|
||||
prefix="Rp "
|
||||
readonly
|
||||
:hint="convertMoney(total_price)"
|
||||
></v-text-field> -->
|
||||
<v-text-field
|
||||
v-model="total_price"
|
||||
label="Total Harga"><template v-slot:append-outer>
|
||||
<span class="text-h4 font-weight-bold">{{formatAngka(total_price)}}</span>
|
||||
</template>
|
||||
</v-text-field>
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
</v-form>
|
||||
</v-card-text>
|
||||
<v-card-actions>
|
||||
<v-spacer></v-spacer>
|
||||
<v-btn color="error" flat @click="closeDialogDetail()"> Tutup </v-btn>
|
||||
<v-btn v-if="act === 'new'" color="primary" dark @click="saveDetail()"
|
||||
>Simpan</v-btn
|
||||
>
|
||||
<v-btn
|
||||
v-if="act === 'edit'"
|
||||
color="primary"
|
||||
dark
|
||||
@click="updateDetail()"
|
||||
>Simpan Perubahan</v-btn
|
||||
>
|
||||
</v-card-actions>
|
||||
</v-card>
|
||||
</v-dialog>
|
||||
</v-layout>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
module.exports = {
|
||||
name: "AddRequestDetailDialog",
|
||||
data() {
|
||||
return {
|
||||
descriptionRules: [(v) => !!v || "Deskripsi harus diisi"],
|
||||
amountRules: [(v) => (!!v && v > 0) || "Jumlah harus diisi"],
|
||||
priceRules: [(v) => (!!v && v > 0) || "Harga harus diisi"],
|
||||
validationDetail: false,
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
this.$store.dispatch("requester/getUnit", this.search_item_unit)
|
||||
},
|
||||
computed: {
|
||||
selectedMainTable() {
|
||||
return this.$store.state.requester.selectedMainTable;
|
||||
},
|
||||
selectedDetailTable() {
|
||||
return this.$store.state.requester.selectedDetailTable;
|
||||
},
|
||||
xDescriptionDetail: {
|
||||
get() {
|
||||
return this.$store.state.requester.xDescriptionDetail;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("requester/updateXDescriptionDetail", val);
|
||||
},
|
||||
},
|
||||
xAmountRequest: {
|
||||
get() {
|
||||
return this.$store.state.requester.xAmountRequest;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("requester/updateXAmountRequest", val);
|
||||
},
|
||||
},
|
||||
xEstimationPrice: {
|
||||
get() {
|
||||
return this.$store.state.requester.xEstimationPrice;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("requester/updateXEstimationPrice", val);
|
||||
},
|
||||
},
|
||||
dialogDetail: {
|
||||
get() {
|
||||
return this.$store.state.requester.dialogDetail;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("requester/updateDialogDetail", val);
|
||||
},
|
||||
},
|
||||
act() {
|
||||
return this.$store.state.requester.act;
|
||||
},
|
||||
total_price() {
|
||||
return this.$store.state.requester.total_price;
|
||||
},
|
||||
item_units() {
|
||||
return this.$store.state.requester.item_units;
|
||||
},
|
||||
selected_item_unit: {
|
||||
get() {
|
||||
return this.$store.state.requester.selected_item_unit;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("requester/updateSelectedItemUnit", val);
|
||||
},
|
||||
},
|
||||
search_item_unit: {
|
||||
get() {
|
||||
return this.$store.state.requester.search_item_unit;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("requester/updateSearchItemUnit", val);
|
||||
},
|
||||
},
|
||||
act() {
|
||||
return this.$store.state.requester.act;
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
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;
|
||||
}
|
||||
},
|
||||
closeDialogDetail() {
|
||||
this.$store.commit("requester/updateXDescriptionDetail", "");
|
||||
this.$store.commit("requester/updateXAmountRequest", 0);
|
||||
this.$store.commit("requester/updateXEstimationPrice", 0);
|
||||
this.$refs.formDetail.resetValidation();
|
||||
this.$store.commit("requester/updateDialogDetail", false);
|
||||
},
|
||||
saveDetail() {
|
||||
if (this.$refs.formDetail.validate()) {
|
||||
this.$store.dispatch("requester/saveDetail", {
|
||||
PRID: this.selectedMainTable.PurchaseRequestDirectID,
|
||||
PRDDescriptionDetail: this.xDescriptionDetail,
|
||||
PRDAmountRequest: this.xAmountRequest,
|
||||
PRDEstimationPrice: this.xEstimationPrice,
|
||||
PRDItemUnitID: this.selected_item_unit.ItemUnitID,
|
||||
});
|
||||
}
|
||||
},
|
||||
updateDetail() {
|
||||
if (this.$refs.formDetail.validate()) {
|
||||
this.$store.dispatch("requester/updateDetail", {
|
||||
PRID: this.selectedMainTable.PurchaseRequestDirectID,
|
||||
PRDID: this.selectedDetailTable.PurchaseRequestDirectDetailID,
|
||||
PRDDescriptionDetail: this.xDescriptionDetail,
|
||||
PRDAmountRequest: this.xAmountRequest,
|
||||
PRDEstimationPrice: this.xEstimationPrice,
|
||||
PRDItemUnitID: this.selected_item_unit.ItemUnitID,
|
||||
});
|
||||
}
|
||||
},
|
||||
calculateTotalPrice() {
|
||||
let total_price = this.xAmountRequest * this.xEstimationPrice;
|
||||
this.$store.commit("requester/updateTotalPrice", total_price);
|
||||
},
|
||||
thr_search_item_unit: _.debounce(function () {
|
||||
this.$store.dispatch("requester/getUnit", this.search_item_unit)
|
||||
}, 1000),
|
||||
},
|
||||
watch: {
|
||||
dialogDetail(val, old) {
|
||||
if (val) {
|
||||
// this.$refs.formDetail.reset();
|
||||
// this.$refs.formDetail.resetValidation();
|
||||
}
|
||||
},
|
||||
xAmountRequest(val, old) {
|
||||
if (val <= 0) {
|
||||
this.$store.commit("requester/updateXAmountRequest", 0);
|
||||
}
|
||||
this.calculateTotalPrice();
|
||||
},
|
||||
xEstimationPrice(val, old) {
|
||||
if (val < 0) {
|
||||
this.$store.commit("requester/updateXEstimationPrice", 0);
|
||||
}
|
||||
this.calculateTotalPrice();
|
||||
},
|
||||
search_item_unit(val, old) {
|
||||
if (val == old) return;
|
||||
if (!val) return;
|
||||
if (val.length < 1) return;
|
||||
if (this.$store.state.requester.loadingAutocomplete == 1) return;
|
||||
this.thr_search_item_unit();
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
@@ -0,0 +1,89 @@
|
||||
<template>
|
||||
<v-dialog v-model="dialog_riwayat" persistent max-width="40%">
|
||||
<v-card>
|
||||
<v-card-title class="headline grey lighten-2" primary-title>
|
||||
Riwayat Stock Request Item
|
||||
</v-card-title>
|
||||
|
||||
<v-card-text>
|
||||
<v-data-table
|
||||
:headers="headers" :items="riwayat_item.records"
|
||||
hide-actions class="elevation-1"
|
||||
>
|
||||
<template slot="items" slot-scope="props">
|
||||
<tr>
|
||||
<td class="text-xs-center pa-2">{{ props.item.PurchaseRequestDetailCreated }}</td>
|
||||
<td class="text-xs-center pa-2">{{ props.item.M_ItemDesc }}</td>
|
||||
<td class="text-xs-center pa-2">{{ props.item.ItemUnitName }}</td>
|
||||
<td class="text-xs-center pa-2">{{ props.item.PurchaseRequestDetailQty }}</td>
|
||||
<td class="text-xs-center pa-2">{{ props.item.PurchaseRequestStatus }}</td>
|
||||
</tr>
|
||||
</template>
|
||||
</v-data-table>
|
||||
</v-card-text>
|
||||
|
||||
<v-card-actions>
|
||||
<v-spacer></v-spacer>
|
||||
<v-btn color="error" flat @click="closeDialog()">
|
||||
Tutup
|
||||
</v-btn>
|
||||
</v-card-actions>
|
||||
</v-card>
|
||||
</v-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
module.exports = {
|
||||
mounted() {},
|
||||
data() {
|
||||
return {
|
||||
headers: [
|
||||
{
|
||||
text: "TANGGAL", align: "center", sortable: false,
|
||||
value: "no", width: "20%", class: "blue lighten-3 white--text",
|
||||
},
|
||||
{
|
||||
text: "ITEM", align: "center", sortable: false,
|
||||
value: "item", width: "30%", class: "blue lighten-3 white--text",
|
||||
},
|
||||
{
|
||||
text: "UNIT", align: "center", sortable: false,
|
||||
value: "unit", width: "20%", class: "blue lighten-3 white--text",
|
||||
},
|
||||
{
|
||||
text: "QTY", align: "center", sortable: false,
|
||||
value: "qty", width: "15%", class: "blue lighten-3 white--text",
|
||||
},
|
||||
{
|
||||
text: "STATUS", align: "center", sortable: false,
|
||||
value: "status", width: "15%", class: "blue lighten-3 white--text",
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
dialog_riwayat: {
|
||||
get() {
|
||||
return this.$store.state.requester.dialog_riwayat
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("requester/update_dialog_riwayat", val)
|
||||
}
|
||||
},
|
||||
riwayat_item: {
|
||||
get() {
|
||||
return this.$store.state.requester.riwayat_item
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("requester/update_riwayat_item", val)
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
closeDialog() {
|
||||
this.riwayat_item = {}
|
||||
this.dialog_riwayat = false
|
||||
}
|
||||
},
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,793 @@
|
||||
<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>
|
||||
|
||||
<v-layout row wrap>
|
||||
<v-flex xs12 class="left" fill-height pa-1>
|
||||
<!-- TOOLBAR PR ATAS -->
|
||||
<v-toolbar color="primary" dark>
|
||||
<v-toolbar-title class="white--text"
|
||||
>STOCK REQUEST</v-toolbar-title
|
||||
>
|
||||
<v-spacer></v-spacer>
|
||||
<v-btn icon @click="openDialogRequest()">
|
||||
<v-icon>add_box</v-icon>
|
||||
</v-btn>
|
||||
</v-toolbar>
|
||||
<v-card class="pa-2">
|
||||
<v-layout row>
|
||||
<v-flex pa-1 xs2>
|
||||
<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"
|
||||
hide-details
|
||||
>
|
||||
<template v-slot:activator="{ on }">
|
||||
<v-text-field
|
||||
:value="startDateFormatted"
|
||||
label="Tanggal Awal"
|
||||
readonly
|
||||
style="max-width: 250px"
|
||||
outline
|
||||
hide-details
|
||||
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-flex>
|
||||
<v-flex pa-1 xs2>
|
||||
<v-menu
|
||||
v-model="menuEndDate"
|
||||
hide-details
|
||||
: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
|
||||
:value="endDateFormatted"
|
||||
label="Tanggal Akhir"
|
||||
readonly
|
||||
style="max-width: 250px"
|
||||
outline
|
||||
hide-details
|
||||
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-flex>
|
||||
<v-flex pa-1 xs2>
|
||||
<v-autocomplete
|
||||
v-model="fStatus"
|
||||
menu-icon="mdi-chevron-down"
|
||||
:items="statusOptions"
|
||||
item-text="title"
|
||||
item-value="value"
|
||||
label="Status"
|
||||
style="max-width: 250px"
|
||||
outline
|
||||
hide-details
|
||||
></v-autocomplete>
|
||||
</v-flex>
|
||||
<v-flex pa-1 xs2>
|
||||
<v-text-field
|
||||
v-model="fSearch"
|
||||
label="Cari..."
|
||||
placeholder="NO. PR"
|
||||
style="max-width: 250px"
|
||||
outline
|
||||
hide-details
|
||||
></v-text-field>
|
||||
</v-flex>
|
||||
<v-flex pa-1 xs2>
|
||||
<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>
|
||||
|
||||
<!-- LIST TABLE PR -->
|
||||
<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="mainTable"
|
||||
:loading="mainTableLoading"
|
||||
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)"
|
||||
>
|
||||
<div
|
||||
style="
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
"
|
||||
>
|
||||
{{ props.item.prNumber }}
|
||||
<v-chip small style="border-radius: 5px; flex-grow: 0">
|
||||
{{ props.item.prRequestedBy }}
|
||||
</v-chip>
|
||||
</div>
|
||||
</td>
|
||||
<td
|
||||
class="text-xs-left pa-2"
|
||||
v-bind:class="{ 'amber lighten-4': isSelected(props.item) }"
|
||||
@click="selectMe(props.item)"
|
||||
>
|
||||
<div class="date-type-table">
|
||||
<span>
|
||||
|
||||
{{
|
||||
deFormatedDate(props.item.prDate)
|
||||
}}
|
||||
</span>
|
||||
|
||||
</div>
|
||||
</td>
|
||||
<td
|
||||
class="text-xs-left pa-2"
|
||||
v-bind:class="{ 'amber lighten-4': isSelected(props.item) }"
|
||||
@click="selectMe(props.item)"
|
||||
>
|
||||
<div
|
||||
style="
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
"
|
||||
>
|
||||
{{ props.item.prNote }}
|
||||
</div>
|
||||
</td>
|
||||
<td
|
||||
class="text-xs-left pa-2"
|
||||
v-bind:class="{ 'amber lighten-4': isSelected(props.item) }"
|
||||
@click="selectMe(props.item)"
|
||||
>
|
||||
<v-chip
|
||||
small
|
||||
:text-color="
|
||||
props.item.prStatus === 'Draft'
|
||||
? 'black'
|
||||
: 'white'
|
||||
"
|
||||
:color="
|
||||
getChipStatusColor(
|
||||
props.item.prStatus
|
||||
)
|
||||
"
|
||||
>
|
||||
{{ props.item.prStatus }}
|
||||
</v-chip>
|
||||
</td>
|
||||
|
||||
<template
|
||||
v-if="props.item.prStatus == 'Draft'"
|
||||
>
|
||||
<td
|
||||
class="text-xs-center pa-2 pr-5"
|
||||
v-bind:class="{
|
||||
'amber lighten-4': isSelected(props.item),
|
||||
}"
|
||||
>
|
||||
<v-icon small @click="editRequest(props.item)"
|
||||
>edit</v-icon
|
||||
>
|
||||
<v-icon small @click="deleteRequest(props.item)"
|
||||
>delete</v-icon
|
||||
>
|
||||
</td>
|
||||
</template>
|
||||
<template v-else>
|
||||
<td
|
||||
class="text-xs-center pa-2 pr-5"
|
||||
v-bind:class="{
|
||||
'amber lighten-4': isSelected(props.item),
|
||||
}"
|
||||
>
|
||||
<v-icon small @click="previewRequest(props.item)"
|
||||
>receipt</v-icon
|
||||
>
|
||||
</td>
|
||||
</template>
|
||||
</template>
|
||||
</v-data-table>
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
<v-divider></v-divider>
|
||||
<v-pagination
|
||||
style="margin-top: 10px; margin-bottom: 10px"
|
||||
v-model="mainTableCurrentPage"
|
||||
:length="mainTableTotalPage"
|
||||
></v-pagination>
|
||||
</v-card>
|
||||
</v-flex>
|
||||
|
||||
</v-layout>
|
||||
|
||||
<add-purchase-request-dialog></add-purchase-request-dialog>
|
||||
<add-request-detail-dialog></add-request-detail-dialog>
|
||||
<riwayat-dialog></riwayat-dialog>
|
||||
|
||||
<one-dialog-alert
|
||||
:status="dialogAlertDeleteRequest"
|
||||
:msg="msgAlertDeleteRequest"
|
||||
@forget-dialog-alert="dialogAlertDeleteRequest = false"
|
||||
@close-dialog-alert="closeAndDeleteRequest()"
|
||||
></one-dialog-alert>
|
||||
|
||||
<one-dialog-alert
|
||||
:status="dialogAlertDeleteDetail"
|
||||
:msg="msgAlertDeleteRequest"
|
||||
@forget-dialog-alert="dialogAlertDeleteDetail = false"
|
||||
@close-dialog-alert="closeAndDeleteDetail()"
|
||||
></one-dialog-alert>
|
||||
</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: {
|
||||
"add-purchase-request-dialog": httpVueLoader("./addPurchaseRequestDialog.vue"),
|
||||
"add-request-detail-dialog": httpVueLoader("./addRequestDetailDialog.vue"),
|
||||
"riwayat-dialog": httpVueLoader("./dialogRiwayat.vue"),
|
||||
"one-dialog-alert": httpVueLoader("../../common/oneDialogAlert.vue"),
|
||||
"one-dialog-error": httpVueLoader("../../common/oneDialogError.vue"),
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
msgAlertDeleteRequest: "",
|
||||
dialogAlertDeleteRequest: false,
|
||||
dialogAlertDeleteDetail: false,
|
||||
headers: [
|
||||
{
|
||||
text: "NO PR",
|
||||
align: "center",
|
||||
sortable: false,
|
||||
value: "no",
|
||||
width: "15%",
|
||||
class: "blue lighten-3 white--text",
|
||||
},
|
||||
{
|
||||
text: "TANGGAL",
|
||||
align: "left",
|
||||
sortable: false,
|
||||
value: "requestDate",
|
||||
width: "15%",
|
||||
class: "blue lighten-3 white--text",
|
||||
},
|
||||
{
|
||||
text: "KETERANGAN",
|
||||
align: "center",
|
||||
sortable: false,
|
||||
value: "keterangan",
|
||||
width: "30%",
|
||||
class: "blue lighten-3 white--text",
|
||||
},
|
||||
{
|
||||
text: "STATUS",
|
||||
align: "center",
|
||||
sortable: false,
|
||||
value: "status",
|
||||
width: "10%",
|
||||
class: "blue lighten-3 white--text",
|
||||
},
|
||||
{
|
||||
text: "AKSI",
|
||||
align: "center",
|
||||
sortable: false,
|
||||
value: "action",
|
||||
width: "10%",
|
||||
class: "blue lighten-3 white--text",
|
||||
},
|
||||
],
|
||||
detailHeaders: [
|
||||
{
|
||||
text: "NO",
|
||||
align: "center",
|
||||
sortable: false,
|
||||
value: "no",
|
||||
width: "5%",
|
||||
class: "blue lighten-3 white--text",
|
||||
},
|
||||
{
|
||||
text: "KETERANGAN",
|
||||
align: "left",
|
||||
sortable: false,
|
||||
value: "requestDate",
|
||||
width: "25%",
|
||||
class: "blue lighten-3 white--text",
|
||||
},
|
||||
{
|
||||
text: "JUMLAH",
|
||||
align: "left",
|
||||
sortable: false,
|
||||
value: "requestDate",
|
||||
width: "5%",
|
||||
class: "blue lighten-3 white--text",
|
||||
},
|
||||
{
|
||||
text: "HARGA",
|
||||
align: "left",
|
||||
sortable: false,
|
||||
value: "requestDate",
|
||||
width: "15%",
|
||||
class: "blue lighten-3 white--text",
|
||||
},
|
||||
{
|
||||
text: "SATUAN",
|
||||
align: "left",
|
||||
sortable: false,
|
||||
value: "requestDate",
|
||||
width: "20%",
|
||||
class: "blue lighten-3 white--text",
|
||||
},
|
||||
{
|
||||
text: "TOTAL HARGA",
|
||||
align: "left",
|
||||
sortable: false,
|
||||
value: "useDate",
|
||||
width: "15%",
|
||||
class: "blue lighten-3 white--text",
|
||||
},
|
||||
{
|
||||
text: "STATUS",
|
||||
align: "left",
|
||||
sortable: false,
|
||||
value: "status",
|
||||
width: "10%",
|
||||
class: "blue lighten-3 white--text",
|
||||
},
|
||||
{
|
||||
text: "AKSI",
|
||||
align: "left",
|
||||
sortable: false,
|
||||
value: "action",
|
||||
width: "5%",
|
||||
class: "blue lighten-3 white--text",
|
||||
},
|
||||
],
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
this.$store.dispatch("requester/getRegionalBranchByUser");
|
||||
this.$store.dispatch("requester/search");
|
||||
},
|
||||
computed: {
|
||||
act() {
|
||||
return this.$store.state.requester.act;
|
||||
},
|
||||
mainTable() {
|
||||
return this.$store.state.requester.mainTable;
|
||||
},
|
||||
detailTable() {
|
||||
return this.$store.state.requester.detailTable;
|
||||
},
|
||||
mainTableLoading() {
|
||||
return this.$store.state.requester.mainTableLoadingStatus === 1;
|
||||
},
|
||||
detailTableLoading() {
|
||||
return this.$store.state.requester.detailTableLoadingStatus === 1;
|
||||
},
|
||||
mainTableTotalPage: {
|
||||
get() {
|
||||
return this.$store.state.requester.countMainTable;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("requester/updateCountMainTable", val);
|
||||
},
|
||||
},
|
||||
mainTableCurrentPage: {
|
||||
get() {
|
||||
return this.$store.state.requester.mainTableCurrentPage;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("requester/updateMainTableCurrentPage", val);
|
||||
this.$store.commit("requester/updateMainTableLastId", -1);
|
||||
this.$store.dispatch("requester/search");
|
||||
},
|
||||
},
|
||||
selectedMainTable: {
|
||||
get() {
|
||||
return this.$store.state.requester.selectedMainTable;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("updateSelectedMainTable", val);
|
||||
},
|
||||
},
|
||||
menuStartDate: {
|
||||
get() {
|
||||
return this.$store.state.requester.menuStartDate;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("requester/updateMenuStartDate", val);
|
||||
},
|
||||
},
|
||||
menuEndDate: {
|
||||
get() {
|
||||
return this.$store.state.requester.menuEndDate;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("requester/updateMenuEndDate", val);
|
||||
},
|
||||
},
|
||||
startDateFormatted() {
|
||||
return this.formatDate(this.fStartDate);
|
||||
},
|
||||
endDateFormatted() {
|
||||
return this.formatDate(this.fEndDate);
|
||||
},
|
||||
dStartDate: {
|
||||
get() {
|
||||
return this.$store.state.requester.dStartDate;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("requester/updateDStartDate", val);
|
||||
},
|
||||
},
|
||||
dEndDate: {
|
||||
get() {
|
||||
return this.$store.state.requester.dEndDate;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("requester/updateDEndDate", val);
|
||||
},
|
||||
},
|
||||
fStartDate: {
|
||||
get() {
|
||||
return this.$store.state.requester.fStartDate;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("requester/updateFStartDate", val);
|
||||
},
|
||||
},
|
||||
fEndDate: {
|
||||
get() {
|
||||
return this.$store.state.requester.fEndDate;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("requester/updateFEndDate", val);
|
||||
},
|
||||
},
|
||||
fStatus: {
|
||||
get() {
|
||||
return this.$store.state.requester.fStatus;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("requester/updateFStatus", val);
|
||||
},
|
||||
},
|
||||
statusOptions() {
|
||||
return this.$store.state.requester.statusOptions;
|
||||
},
|
||||
fSearch: {
|
||||
get() {
|
||||
return this.$store.state.requester.fSearch;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("requester/updateFSearch", val);
|
||||
},
|
||||
},
|
||||
xNumber: {
|
||||
get() {
|
||||
return this.$store.state.requester.xNumber;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("requester/updateXNumber", val);
|
||||
},
|
||||
},
|
||||
xPRID: {
|
||||
get() {
|
||||
return this.$store.state.requester.xPRID;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("requester/updateXPRID", val);
|
||||
},
|
||||
},
|
||||
xPRDID: {
|
||||
get() {
|
||||
return this.$store.state.requester.xPRDID;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("requester/updateXPRDID", val);
|
||||
},
|
||||
},
|
||||
snackbar: {
|
||||
get() {
|
||||
return this.$store.state.requester.snackbar;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("requester/update_snackbar", val);
|
||||
},
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
previewRequest(val){
|
||||
this.$store.commit("requester/updateSelectedMainTable", val);
|
||||
let selectedPr = val
|
||||
this.$store.commit("requester/updateRegionalOptions", [{S_RegionalID : selectedPr.S_RegionalID, S_RegionalName : selectedPr.S_RegionalName}]);
|
||||
this.$store.commit("requester/updateXRegional", {S_RegionalID : selectedPr.S_RegionalID, S_RegionalName : selectedPr.S_RegionalName});
|
||||
//this.$store.commit("requester/updateBranchOptions", [{M_BranchCode : selectedPr.M_BranchCode, M_BranchName : selectedPr.M_BranchName}]);
|
||||
this.$store.commit("requester/updateXBranch", {M_BranchCode : selectedPr.M_BranchCode, M_BranchName : selectedPr.M_BranchName});
|
||||
this.$store.commit(
|
||||
"requester/updateXDateUse",
|
||||
selectedPr.prDate
|
||||
);
|
||||
this.$store.commit("requester/updateXDescription", selectedPr.prNote);
|
||||
this.$store.dispatch("requester/getDivisionByUser");
|
||||
this.$store.commit("requester/updateDialogRequest", true);
|
||||
this.$store.dispatch("requester/getDetailRequest", {
|
||||
requestId: selectedPr.prId
|
||||
});
|
||||
this.$store.commit("requester/updateAct", "preview");
|
||||
},
|
||||
convertMoney(money){
|
||||
return one_money(money)
|
||||
},
|
||||
isSelected(p) {
|
||||
return (
|
||||
p.prId ==
|
||||
this.$store.state.requester.selectedMainTable
|
||||
.prId
|
||||
);
|
||||
},
|
||||
selectMe(spr) {
|
||||
this.$store.commit("requester/updateSelectedMainTable", spr);
|
||||
this.$store.dispatch("requester/searchDetail");
|
||||
},
|
||||
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")}`;
|
||||
},
|
||||
getChipStatusColor(status) {
|
||||
switch (status) {
|
||||
case "Pending":
|
||||
return "warning";
|
||||
case "Approved":
|
||||
return "success";
|
||||
case "Rejected":
|
||||
return "error";
|
||||
case "Completed":
|
||||
return "info";
|
||||
case "Paid":
|
||||
return "success";
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
},
|
||||
getChipStatusDetailColor(status) {
|
||||
switch (status) {
|
||||
case "Pending":
|
||||
return "warning";
|
||||
case "Ordered":
|
||||
return "success";
|
||||
case "Received":
|
||||
return "info";
|
||||
case "Cancelled":
|
||||
return "error";
|
||||
default:
|
||||
return "warning";
|
||||
}
|
||||
},
|
||||
mainTableSearch() {
|
||||
this.$store.dispatch("requester/search");
|
||||
this.$store.commit("requester/updateSelectedMainTable", {});
|
||||
this.$store.commit("requester/updateDetailTable", []);
|
||||
},
|
||||
resetItemTable() {
|
||||
this.$store.commit("requester/updateItems", []);
|
||||
this.$store.commit("requester/updateSelectedItem", {});
|
||||
this.$store.commit("requester/updateSearchItem", "");
|
||||
this.$store.commit("requester/updateLoadingItem", false);
|
||||
this.$store.commit("requester/updateItemGroupOptions", []);
|
||||
this.$store.commit("requester/updateSelectedItemGroup", {});
|
||||
this.$store.commit("requester/updateItemSubGroupOptions", []);
|
||||
this.$store.commit("requester/updateSelectedItemSubGroup", {});
|
||||
},
|
||||
openDialogRequest() {
|
||||
let user = one_user()
|
||||
this.$store.commit("requester/updateAct", "new");
|
||||
this.$store.commit("requester/updateRegionalOptions", [{S_RegionalID : user.S_RegionalID, S_RegionalName : user.S_RegionalName}]);
|
||||
this.$store.commit("requester/updateXRegional", {S_RegionalID : user.S_RegionalID, S_RegionalName : user.S_RegionalName});
|
||||
this.$store.commit("requester/updateXBranch", {});
|
||||
if(user.M_BranchName != ""){
|
||||
this.$store.commit("requester/updateXBranch", {M_BranchCode : user.M_BranchCode, M_BranchName : user.M_BranchName});
|
||||
}
|
||||
this.$store.commit(
|
||||
"requester/updateXDateUse",
|
||||
moment(new Date()).format("YYYY-MM-DD")
|
||||
);
|
||||
this.$store.commit("requester/updateXDescription", "");
|
||||
this.$store.commit("requester/updateDialogRequest", true);
|
||||
this.$store.commit("requester/updateSelectedMainTable", {});
|
||||
this.resetItemTable();
|
||||
this.$store.dispatch("requester/getDivisionByUser");
|
||||
this.$store.dispatch("requester/getItems", {
|
||||
search: "",
|
||||
division: "",
|
||||
itemGroup: "",
|
||||
itemSubGroup: ""
|
||||
});
|
||||
this.$store.commit("requester/updateAct", "new");
|
||||
this.$store.commit("requester/updateSelectedItems", []);
|
||||
},
|
||||
editRequest(val) {
|
||||
this.$store.commit("requester/updateSelectedMainTable", val);
|
||||
this.$store.commit("requester/updateAct", "edit");
|
||||
let selectedPr = val
|
||||
this.$store.commit("requester/updateRegionalOptions", [{S_RegionalID : selectedPr.S_RegionalID, S_RegionalName : selectedPr.S_RegionalName}]);
|
||||
this.$store.commit("requester/updateXRegional", {S_RegionalID : selectedPr.S_RegionalID, S_RegionalName : selectedPr.S_RegionalName});
|
||||
//this.$store.commit("requester/updateBranchOptions", [{M_BranchCode : selectedPr.M_BranchCode, M_BranchName : selectedPr.M_BranchName}]);
|
||||
this.$store.commit("requester/updateXBranch", {M_BranchCode : selectedPr.M_BranchCode, M_BranchName : selectedPr.M_BranchName});
|
||||
this.$store.commit(
|
||||
"requester/updateXDateUse",
|
||||
selectedPr.prDate
|
||||
);
|
||||
this.$store.commit("requester/updateXDescription", selectedPr.prNote);
|
||||
this.$store.dispatch("requester/getDivisionByUser");
|
||||
this.$store.commit("requester/updateDialogRequest", true);
|
||||
this.$store.dispatch("requester/getDetailRequest", {
|
||||
requestId: selectedPr.prId
|
||||
});
|
||||
},
|
||||
updateRequest(val) {
|
||||
//this.$store.dispatch("requester/branch");
|
||||
this.$store.commit(
|
||||
"requester/updateXDateUse",
|
||||
val.prDate
|
||||
);
|
||||
//this.$store.commit("requester/updateBranchOptions", [{M_BranchCode : val.M_BranchCode, M_BranchName : val.M_BranchName}]);
|
||||
this.$store.commit("requester/updateXBranch",{M_BranchCode : val.M_BranchCode, M_BranchName : val.M_BranchName});
|
||||
this.$store.commit("requester/updateRegionalOptions", [{S_RegionalID : val.S_RegionalID, S_RegionalName : val.S_RegionalName}]);
|
||||
this.$store.commit("requester/updateXRegional",{S_RegionalID : val.S_RegionalID, S_RegionalName : val.S_RegionalName});
|
||||
this.$store.commit(
|
||||
"requester/updateXDescription",
|
||||
val.PurchaseRequestDirectDescription
|
||||
);
|
||||
this.$store.commit("requester/updateXPRID", val.prId);
|
||||
this.$store.commit("requester/updateAct", "edit");
|
||||
this.$store.commit("requester/updateDialogRequest", true);
|
||||
},
|
||||
deleteRequest(data) {
|
||||
this.xPRID = data.prId;
|
||||
this.xNumber = data.prNumber;
|
||||
|
||||
this.msgAlertDeleteRequest = `Yakin, mau hapus Purchase Request [${data.prNumber}] ?`;
|
||||
this.dialogAlertDeleteRequest = true;
|
||||
},
|
||||
closeAndDeleteRequest() {
|
||||
this.$store.dispatch("requester/deleteRequest", {
|
||||
PRID: this.xPRID,
|
||||
PRNumber: this.xNumber,
|
||||
});
|
||||
this.dialogAlertDeleteRequest = false;
|
||||
},
|
||||
openDialogDetail() {
|
||||
this.$store.commit("requester/updateXDescriptionDetail", "");
|
||||
this.$store.commit("requester/updateXAmountRequest", 0);
|
||||
this.$store.commit("requester/updateXEstimationPrice",0);
|
||||
this.$store.commit("requester/updateAct", "new");
|
||||
this.$store.commit("requester/updateDialogDetail", true);
|
||||
this.$store.commit("requester/updateSelectedItemUnit", {});
|
||||
},
|
||||
updateDetail(val) {
|
||||
this.$store.commit("requester/updateXDescriptionDetail", val.PurchaseRequestDirectDescription);
|
||||
this.$store.commit(
|
||||
"requester/updateXAmountRequest",
|
||||
val.PurchaseRequestDirectDetailAmountRequest
|
||||
);
|
||||
this.$store.commit(
|
||||
"requester/updateXEstimationPrice",
|
||||
val.PurchaseRequestDirectDetailEstimationPrice
|
||||
);
|
||||
this.$store.commit("requester/updateItemUnits", [{
|
||||
ItemUnitID: val.PurchaseRequestDirectDetailItemUnitID,
|
||||
ItemUnitName: val.ItemUnitName
|
||||
}]);
|
||||
this.$store.commit("requester/updateSelectedItemUnit", {
|
||||
ItemUnitID: val.PurchaseRequestDirectDetailItemUnitID,
|
||||
ItemUnitName: val.ItemUnitName
|
||||
});
|
||||
this.$store.commit("requester/updateSelectedDetailTable", val);
|
||||
this.$store.commit("requester/updateAct", "edit");
|
||||
this.$store.commit("requester/updateDialogDetail", true);
|
||||
},
|
||||
deleteDetail(data) {
|
||||
this.xPRDID = data.PurchaseRequestDirectDetailID;
|
||||
|
||||
this.msgAlertDeleteRequest = `Yakin, mau hapus Request [${data.PurchaseRequestDirectDescription}] ?`;
|
||||
this.dialogAlertDeleteDetail = true;
|
||||
},
|
||||
closeAndDeleteDetail() {
|
||||
this.$store.dispatch("requester/deleteDetail", {
|
||||
PRDID: this.xPRDID,
|
||||
PRDDescriptionDetail: this.xDescriptionDetail,
|
||||
PRID: this.selectedMainTable.PurchaseRequestDirectID,
|
||||
});
|
||||
this.dialogAlertDeleteDetail = false;
|
||||
},
|
||||
orderRequest(id, status) {
|
||||
if (status === "Draft") {
|
||||
this.$store.dispatch("requester/orderRequest", {
|
||||
PRID: id,
|
||||
});
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
118
test/vuex/acc-one-purchase-request-persediaan/index.php
Normal file
118
test/vuex/acc-one-purchase-request-persediaan/index.php
Normal file
@@ -0,0 +1,118 @@
|
||||
<!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 xs12 class="left" fill-height pa-1>
|
||||
<request-listing></request-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'),
|
||||
'request-listing': httpVueLoader('./components/requestListing.vue')
|
||||
},
|
||||
computed: {
|
||||
|
||||
alertError: {
|
||||
get() {
|
||||
return this.$store.state.requester.alertError;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("requester/updateAlertError", val);
|
||||
}
|
||||
},
|
||||
errMessage: {
|
||||
get() {
|
||||
return this.$store.state.requester.errMessage;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("requester/updateErrMessage", val);
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
</script>
|
||||
<style>
|
||||
[v-cloak] {
|
||||
display: none
|
||||
}
|
||||
</style>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -0,0 +1,976 @@
|
||||
// 1 => LOADING
|
||||
// 2 => DONE
|
||||
// 3 => ERROR
|
||||
|
||||
import * as api from "../api/api.js";
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {
|
||||
mainTable: [],
|
||||
detailTable: [],
|
||||
countMainTable: 0,
|
||||
countDetailTable: 0,
|
||||
mainTableLoadingStatus: 0,
|
||||
detailTableLoadingStatus: 0,
|
||||
mainTableErrorMessage: "",
|
||||
detailTableErrorMessage: "",
|
||||
mainTableCurrentPage: 1,
|
||||
mainTableLastId: -1,
|
||||
|
||||
selectedMainTable: {},
|
||||
selectedDetailTable: {},
|
||||
|
||||
statusOptions: [
|
||||
{ value: '', title: "All" },
|
||||
{ value: 'draft', title: "Draft" },
|
||||
{ value: 'pending', title: "Pending" },
|
||||
{ value: 'approved', title: "Approved" },
|
||||
{ value: 'rejected', title: "Rejected" },
|
||||
{ value: 'paid', title: "Paid" },
|
||||
{ value: 'completed', title: "Completed" },
|
||||
],
|
||||
branchOptions: [],
|
||||
regionalOptions: [],
|
||||
|
||||
menuStartDate: false,
|
||||
menuEndDate: false,
|
||||
menuDateUse: false,
|
||||
|
||||
dStartDate: new Date().toISOString().substring(0, 10),
|
||||
dEndDate: new Date().toISOString().substring(0, 10),
|
||||
fStartDate: moment(new Date()).format("YYYY-MM-DD"),
|
||||
fEndDate: moment(new Date()).format("YYYY-MM-DD"),
|
||||
fStatus: '',
|
||||
fSearch: "",
|
||||
|
||||
dDateUse: new Date().toISOString().substring(0, 10),
|
||||
xDateUse: moment(new Date()).format("YYYY-MM-DD"),
|
||||
xRegional: "",
|
||||
xBranch: "",
|
||||
xDescription: "",
|
||||
xPRID: 0,
|
||||
xNumber: "",
|
||||
xPRDID: 0,
|
||||
xDescriptionDetail: "",
|
||||
xAmountRequest: 0,
|
||||
xEstimationPrice: 0,
|
||||
|
||||
dialogRequest: false,
|
||||
dialogDetail: false,
|
||||
act: "new",
|
||||
errMessage: "",
|
||||
succesMessage: "",
|
||||
alertError: false,
|
||||
alertSuccess: false,
|
||||
errors: [],
|
||||
total_price: 0,
|
||||
item_units: [],
|
||||
selected_item_unit: {},
|
||||
search_item_unit: "",
|
||||
loadingAutocomplete: false,
|
||||
divisionOptions: [],
|
||||
selectedDivision: {},
|
||||
itemCurrentPage: 1,
|
||||
itemTotalPage: 0,
|
||||
itemLastId: -1,
|
||||
items: [],
|
||||
selectedItems: [],
|
||||
selectedItem: {},
|
||||
searchItem: "",
|
||||
itemCurrentPage: 1,
|
||||
itemTotalPage: 0,
|
||||
loadingItem: false,
|
||||
itemGroupOptions: [],
|
||||
selectedItemGroup: {},
|
||||
loadingItemGroup: false,
|
||||
itemSubGroupOptions: [],
|
||||
selectedItemSubGroup: {},
|
||||
loadingItemSubGroup: false,
|
||||
dialogUnit: false,
|
||||
selectedUnit: {},
|
||||
unitOptions: [],
|
||||
loadingUnit: false,
|
||||
loadingSave: false,
|
||||
snackbar: {
|
||||
state: false,
|
||||
type: 'success',
|
||||
message: '',
|
||||
},
|
||||
loadingDetailRequest: false,
|
||||
|
||||
dialog_riwayat: false,
|
||||
riwayat_item: {},
|
||||
user: one_user(),
|
||||
},
|
||||
mutations: {
|
||||
updateLoadingDetailRequest(state, val) {
|
||||
state.loadingDetailRequest = val;
|
||||
},
|
||||
updateSnackbar(state, val) {
|
||||
state.snackbar = val;
|
||||
},
|
||||
updateSelectedItem(state, val) {
|
||||
state.selectedItem = val;
|
||||
},
|
||||
updateLoadingSave(state, val) {
|
||||
state.loadingSave = 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;
|
||||
},
|
||||
updateItemCurrentPage(state, val) {
|
||||
state.itemCurrentPage = val;
|
||||
},
|
||||
updateItemTotalPage(state, val) {
|
||||
state.itemTotalPage = val;
|
||||
},
|
||||
updateItemLastId(state, val) {
|
||||
state.itemLastId = val;
|
||||
},
|
||||
updateDivisionOptions(state, val) {
|
||||
state.divisionOptions = val;
|
||||
},
|
||||
updateSelectedDivision(state, val) {
|
||||
state.selectedDivision = val;
|
||||
},
|
||||
updateMainTable(state, val) {
|
||||
state.mainTable = val;
|
||||
},
|
||||
updateDetailTable(state, val) {
|
||||
state.detailTable = val;
|
||||
},
|
||||
updateCountMainTable(state, val) {
|
||||
state.countMainTable = val;
|
||||
},
|
||||
updateCountDetailTable(state, val) {
|
||||
state.countDetailTable = val;
|
||||
},
|
||||
updateMainTableLoadingStatus(state, val) {
|
||||
state.mainTableLoadingStatus = val;
|
||||
},
|
||||
updateDetailTableLoadingStatus(state, val) {
|
||||
state.detailTableLoadingStatus = val;
|
||||
},
|
||||
updateMainTableErrorMessage(state, val) {
|
||||
state.mainTableErrorMessage = val;
|
||||
},
|
||||
updateDetailTableErrorMessage(state, val) {
|
||||
state.detailTableErrorMessage = val;
|
||||
},
|
||||
updateMainTableCurrentPage(state, val) {
|
||||
state.mainTableCurrentPage = val;
|
||||
},
|
||||
updateMainTableLastId(state, val) {
|
||||
state.mainTableLastId = val;
|
||||
},
|
||||
|
||||
updateSelectedMainTable(state, val) {
|
||||
state.selectedMainTable = val;
|
||||
},
|
||||
updateSelectedDetailTable(state, val) {
|
||||
state.selectedDetailTable = val;
|
||||
},
|
||||
|
||||
updateBranchOptions(state, val) {
|
||||
state.branchOptions = val;
|
||||
},
|
||||
|
||||
updateRegionalOptions(state, val) {
|
||||
state.regionalOptions = val;
|
||||
},
|
||||
|
||||
updateMenuStartDate(state, val) {
|
||||
state.menuStartDate = val;
|
||||
},
|
||||
updateMenuEndDate(state, val) {
|
||||
state.menuEndDate = val;
|
||||
},
|
||||
updateMenuDateUse(state, val) {
|
||||
state.menuDateUse = val;
|
||||
},
|
||||
|
||||
updateDStartDate(state, val) {
|
||||
state.dStartDate = val;
|
||||
},
|
||||
updateDEndDate(state, val) {
|
||||
state.dEndDate = val;
|
||||
},
|
||||
updateFStartDate(state, val) {
|
||||
state.fStartDate = val;
|
||||
},
|
||||
updateFEndDate(state, val) {
|
||||
state.fEndDate = val;
|
||||
},
|
||||
updateFStatus(state, val) {
|
||||
state.fStatus = val;
|
||||
},
|
||||
updateFSearch(state, val) {
|
||||
state.fSearch = val;
|
||||
},
|
||||
|
||||
updateDDateUse(state, val) {
|
||||
state.dDateUse = val;
|
||||
},
|
||||
updateXDateUse(state, val) {
|
||||
state.xDateUse = val;
|
||||
},
|
||||
updateXRegional(state, val) {
|
||||
state.xRegional = val;
|
||||
},
|
||||
updateXBranch(state, val) {
|
||||
state.xBranch = val;
|
||||
},
|
||||
updateXDescription(state, val) {
|
||||
state.xDescription = val;
|
||||
},
|
||||
updateXPRID(state, val) {
|
||||
state.xPRID = val;
|
||||
},
|
||||
updateXNumber(state, val) {
|
||||
state.xNumber = val;
|
||||
},
|
||||
updateXPRDID(state, val) {
|
||||
state.xPRDID = val;
|
||||
},
|
||||
updateXDescriptionDetail(state, val) {
|
||||
state.xDescriptionDetail = val;
|
||||
},
|
||||
updateXAmountRequest(state, val) {
|
||||
state.xAmountRequest = val;
|
||||
},
|
||||
updateXEstimationPrice(state, val) {
|
||||
state.xEstimationPrice = val;
|
||||
},
|
||||
|
||||
updateDialogRequest(state, val) {
|
||||
state.dialogRequest = val;
|
||||
},
|
||||
updateDialogDetail(state, val) {
|
||||
state.dialogDetail = val;
|
||||
},
|
||||
updateAct(state, val) {
|
||||
state.act = val;
|
||||
},
|
||||
updateErrMessage(state, val) {
|
||||
state.errMessage = val;
|
||||
},
|
||||
updateSuccessMessage(state, val) {
|
||||
state.successMessage = val;
|
||||
},
|
||||
updateAlertError(state, val) {
|
||||
state.alertError = val;
|
||||
},
|
||||
updateAlertSuccess(state, val) {
|
||||
state.alertSuccess = val;
|
||||
},
|
||||
updateErrors(state, val) {
|
||||
state.errors = val;
|
||||
},
|
||||
updateTotalPrice(state, val) {
|
||||
state.total_price = val;
|
||||
},
|
||||
updateItemUnits(state, val) {
|
||||
state.item_units = val;
|
||||
},
|
||||
updateSelectedItemUnit(state, val) {
|
||||
state.selected_item_unit = val;
|
||||
},
|
||||
updateSearchItemUnit(state, val) {
|
||||
state.search_item_unit = val;
|
||||
},
|
||||
updateLoadingAutocomplete(state, val) {
|
||||
state.loadingAutocomplete = val;
|
||||
},
|
||||
updateItems(state, val) {
|
||||
state.items = val;
|
||||
},
|
||||
updateSelectedItems(state, val) {
|
||||
state.selectedItems = val;
|
||||
},
|
||||
updateSearchItem(state, val) {
|
||||
state.searchItem = val;
|
||||
},
|
||||
updateLoadingItem(state, val) {
|
||||
state.loadingItem = val;
|
||||
},
|
||||
updateItemGroupOptions(state, val) {
|
||||
state.itemGroupOptions = val;
|
||||
},
|
||||
updateSelectedItemGroup(state, val) {
|
||||
state.selectedItemGroup = val;
|
||||
},
|
||||
updateItemSubGroupOptions(state, val) {
|
||||
state.itemSubGroupOptions = val;
|
||||
},
|
||||
updateSelectedItemSubGroup(state, val) {
|
||||
state.selectedItemSubGroup = val;
|
||||
},
|
||||
updateLoadingItemGroup(state, val) {
|
||||
state.loadingItemGroup = val;
|
||||
},
|
||||
updateLoadingItemSubGroup(state, val) {
|
||||
state.loadingItemSubGroup = val;
|
||||
},
|
||||
update_dialog_riwayat(state, val) {
|
||||
state.dialog_riwayat = val;
|
||||
},
|
||||
update_riwayat_item(state, val) {
|
||||
state.riwayat_item = val
|
||||
},
|
||||
updateUser(state, val) {
|
||||
state.user = val
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
async search(context) {
|
||||
context.commit("updateMainTableLoadingStatus", 1);
|
||||
|
||||
try {
|
||||
var url_string = window.location.href
|
||||
var url = new URL(url_string);
|
||||
var xdate = url.searchParams.get("date");
|
||||
var xsearch = url.searchParams.get("search");
|
||||
|
||||
if (xsearch) {
|
||||
context.commit("updateFSearch", xsearch);
|
||||
}
|
||||
if (xdate) {
|
||||
context.commit("updateFStartDate", xdate);
|
||||
context.commit("updateFEndDate", xdate);
|
||||
}
|
||||
|
||||
var payload = {
|
||||
token: one_token(),
|
||||
currentPage: context.state.mainTableCurrentPage,
|
||||
startDate: context.state.fStartDate,
|
||||
endDate: context.state.fEndDate,
|
||||
status: context.state.fStatus,
|
||||
search: context.state.fSearch,
|
||||
lastId: -1,
|
||||
};
|
||||
|
||||
let response = await api.search(payload);
|
||||
if (response.status != "OK") {
|
||||
context.commit("updateMainTableLoadingStatus", 3);
|
||||
context.commit("updateMainTableErrorMessage", response.message);
|
||||
} else {
|
||||
context.commit("updateMainTableLoadingStatus", 2);
|
||||
context.commit("updateMainTableErrorMessage", "");
|
||||
let data = {
|
||||
records: response.data.records,
|
||||
total: response.data.total,
|
||||
};
|
||||
|
||||
context.commit("updateMainTable", data.records);
|
||||
context.commit("updateCountMainTable", data.total);
|
||||
context.dispatch("system/getlistnotif", null, { root: true })
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("updateMainTableLoadingStatus", 3);
|
||||
context.commit("updateMainTableErrorMessage", e.message);
|
||||
}
|
||||
},
|
||||
async searchDetail(context) {
|
||||
context.commit("updateDetailTableLoadingStatus", 1);
|
||||
|
||||
try {
|
||||
var payload = {
|
||||
token: one_token(),
|
||||
PRID: context.state.selectedMainTable.PurchaseRequestID,
|
||||
};
|
||||
|
||||
let response = await api.searchDetail(payload);
|
||||
if (response.status != "OK") {
|
||||
context.commit("updateDetailTableLoadingStatus", 3);
|
||||
context.commit("updateDetailTableErrorMessage", response.message);
|
||||
} else {
|
||||
context.commit("updateDetailTableLoadingStatus", 2);
|
||||
context.commit("updateDetailTableErrorMessage", "");
|
||||
let data = {
|
||||
records: response.data.records,
|
||||
total: response.data.total,
|
||||
};
|
||||
|
||||
context.commit("updateDetailTable", data.records);
|
||||
context.commit("updateCountDetailTable", data.total);
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("updateDetailTableLoadingStatus", 3);
|
||||
context.commit("updateDetailTableErrorMessage", e.message);
|
||||
}
|
||||
},
|
||||
async regional(context) {
|
||||
let response = await api.getRegional({ token: one_token() });
|
||||
if (response.status === "OK") {
|
||||
let data = {
|
||||
records: response.data.records,
|
||||
};
|
||||
|
||||
context.commit("updateRegionalOptions", data.records);
|
||||
}
|
||||
},
|
||||
async branch(context) {
|
||||
let response = await api.getBranch({ token: one_token() });
|
||||
if (response.status === "OK") {
|
||||
let data = {
|
||||
records: response.data.records,
|
||||
};
|
||||
|
||||
context.commit("updateBranchOptions", data.records);
|
||||
}
|
||||
},
|
||||
async saveRequest(context, payload) {
|
||||
try {
|
||||
payload.token = one_token();
|
||||
|
||||
let response = await api.saveRequest(payload);
|
||||
if (response.status !== "OK") {
|
||||
context.commit("updateErrMessage", response.message);
|
||||
} else {
|
||||
context.commit("updateErrMessage", "");
|
||||
let data = {
|
||||
records: response.data.records,
|
||||
total: response.data.total,
|
||||
};
|
||||
|
||||
if (data.total !== -1) {
|
||||
context.commit("updateErrors", []);
|
||||
context.commit("updateAlertSuccess", true);
|
||||
context.commit("updateDialogRequest", false);
|
||||
var msg = `Purchase Request baru dengan kode ${data.records[0].PurchaseRequestDirectNumber} sudah tersimpan`;
|
||||
context.commit("updateSuccessMessage", msg);
|
||||
context.dispatch("search");
|
||||
context.commit("updateSelectedMainTable", data.records[0]);
|
||||
context.dispatch("searchDetail");
|
||||
} else {
|
||||
context.commit("updateErrors", response.data.errors);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("updateErrMessage", e.message);
|
||||
context.commit("updateAlertError", true);
|
||||
}
|
||||
},
|
||||
async updateRequest(context, payload) {
|
||||
try {
|
||||
payload.token = one_token();
|
||||
|
||||
let response = await api.updateRequest(payload);
|
||||
if (response.status !== "OK") {
|
||||
context.commit("updateErrMessage", response.message);
|
||||
context.commit("updateAlertError", true);
|
||||
} else {
|
||||
context.commit("updateErrMessage", "");
|
||||
let data = {
|
||||
records: response.data.records,
|
||||
total: response.data.total,
|
||||
};
|
||||
|
||||
if (data.total !== -1) {
|
||||
context.commit("updateErrors", []);
|
||||
context.commit("updateAlertSuccess", true);
|
||||
context.commit("updateDialogRequest", false);
|
||||
var msg = `Perubahan Purchase Request dengan kode ${data.records[0].PurchaseRequestDirectNumber} sudah tersimpan`;
|
||||
context.commit("updateSuccessMessage", msg);
|
||||
context.dispatch("search");
|
||||
context.commit("updateSelectedMainTable", data.records[0]);
|
||||
context.dispatch("searchDetail");
|
||||
} else {
|
||||
context.commit("updateErrors", response.data.errors);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("updateErrMessage", e.message);
|
||||
context.commit("updateAlertError", true);
|
||||
}
|
||||
},
|
||||
async deleteRequest(context, payload) {
|
||||
try {
|
||||
payload.token = one_token();
|
||||
|
||||
let response = await api.getAPI('deletePurchaseRequest',payload);
|
||||
if (response.status !== "OK") {
|
||||
context.commit("updateErrMessage", response.message);
|
||||
context.commit("updateAlertError", true);
|
||||
} else {
|
||||
context.commit("updateErrMessage", "");
|
||||
let data = {
|
||||
records: response.data.records,
|
||||
total: response.data.total,
|
||||
};
|
||||
|
||||
if (data.total !== -1) {
|
||||
context.commit("updateErrors", []);
|
||||
context.commit("updateAlertSuccess", true);
|
||||
context.commit("updateDialogRequest", false);
|
||||
var msg = `Purchase Request dengan kode ${payload.PRNumber} sudah dihapus`;
|
||||
context.commit("updateSuccessMessage", msg);
|
||||
context.dispatch("search");
|
||||
} else {
|
||||
context.commit("updateErrors", response.data.errors);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("updateErrMessage", e.message);
|
||||
context.commit("updateAlertError", true);
|
||||
}
|
||||
},
|
||||
async saveDetail(context, payload) {
|
||||
try {
|
||||
payload.token = one_token();
|
||||
|
||||
let response = await api.saveDetail(payload);
|
||||
if (response.status !== "OK") {
|
||||
context.commit("updateErrMessage", response.message);
|
||||
} else {
|
||||
context.commit("updateErrMessage", "");
|
||||
let data = {
|
||||
records: response.data.records,
|
||||
total: response.data.total,
|
||||
};
|
||||
|
||||
if (data.total !== -1) {
|
||||
context.commit("updateErrors", []);
|
||||
context.commit("updateAlertSuccess", true);
|
||||
context.commit("updateDialogDetail", false);
|
||||
var msg = `Request baru ${payload.PRDDescription} sudah tersimpan`;
|
||||
context.commit("updateSuccessMessage", msg);
|
||||
context.dispatch("search");
|
||||
context.dispatch("searchDetail");
|
||||
} else {
|
||||
context.commit("updateErrors", response.data.errors);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("updateErrMessage", e.message);
|
||||
context.commit("updateAlertError", true);
|
||||
}
|
||||
},
|
||||
async updateDetail(context, payload) {
|
||||
try {
|
||||
payload.token = one_token();
|
||||
|
||||
let response = await api.updateDetail(payload);
|
||||
if (response.status !== "OK") {
|
||||
context.commit("updateErrMessage", response.message);
|
||||
context.commit("updateAlertError", true);
|
||||
} else {
|
||||
context.commit("updateErrMessage", "");
|
||||
let data = {
|
||||
records: response.data.records,
|
||||
total: response.data.total,
|
||||
};
|
||||
|
||||
if (data.total !== -1) {
|
||||
context.commit("updateErrors", []);
|
||||
context.commit("updateAlertSuccess", true);
|
||||
context.commit("updateDialogDetail", false);
|
||||
var msg = "Perubahan Request sudah tersimpan";
|
||||
context.commit("updateSuccessMessage", msg);
|
||||
context.dispatch("search");
|
||||
context.dispatch("searchDetail");
|
||||
} else {
|
||||
context.commit("updateErrors", response.data.errors);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("updateErrMessage", e.message);
|
||||
context.commit("updateAlertError", true);
|
||||
}
|
||||
},
|
||||
async deleteDetail(context, payload) {
|
||||
try {
|
||||
payload.token = one_token();
|
||||
|
||||
let response = await api.deleteDetail(payload);
|
||||
if (response.status !== "OK") {
|
||||
context.commit("updateErrMessage", response.message);
|
||||
context.commit("updateAlertError", true);
|
||||
} else {
|
||||
context.commit("updateErrMessage", "");
|
||||
let data = {
|
||||
records: response.data.records,
|
||||
total: response.data.total,
|
||||
};
|
||||
|
||||
if (data.total !== -1) {
|
||||
context.commit("updateErrors", []);
|
||||
context.commit("updateAlertSuccess", true);
|
||||
context.commit("updateDialogDetail", false);
|
||||
var msg = `Request [${payload.PRDDescriptionDetail}] sudah dihapus`;
|
||||
context.commit("updateSuccessMessage", msg);
|
||||
context.dispatch("search");
|
||||
context.dispatch("searchDetail");
|
||||
} else {
|
||||
context.commit("updateErrors", response.data.errors);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("updateErrMessage", e.message);
|
||||
context.commit("updateAlertError", true);
|
||||
}
|
||||
},
|
||||
async orderRequest(context, payload) {
|
||||
try {
|
||||
payload.token = one_token();
|
||||
|
||||
let response = await api.orderRequest(payload);
|
||||
if (response.status !== "OK") {
|
||||
context.commit("updateErrMessage", response.message);
|
||||
context.commit("updateAlertError", true);
|
||||
} else {
|
||||
context.commit("updateErrMessage", "");
|
||||
let data = {
|
||||
records: response.data.records,
|
||||
total: response.data.total,
|
||||
};
|
||||
|
||||
if (data.total !== -1) {
|
||||
context.commit("updateErrors", []);
|
||||
context.commit("updateAlertSuccess", true);
|
||||
context.commit("updateDialogDetail", false);
|
||||
context.dispatch("search");
|
||||
context.commit("updateSelectedMainTable", data.records[0]);
|
||||
context.dispatch("searchDetail");
|
||||
} else {
|
||||
context.commit("updateErrors", response.data.errors);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("updateErrMessage", e.message);
|
||||
context.commit("updateAlertError", true);
|
||||
}
|
||||
},
|
||||
|
||||
async getUnit(context, prm) {
|
||||
context.commit("updateLoadingAutocomplete", true)
|
||||
try {
|
||||
let resp = await api.getUnit(one_token(), prm)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("updateLoadingAutocomplete", false)
|
||||
context.commit("updateErrMessage", response.message);
|
||||
context.commit("updateAlertError", true);
|
||||
} else {
|
||||
context.commit("updateLoadingAutocomplete", false)
|
||||
context.commit("updateErrMessage", "");
|
||||
let data = {
|
||||
records: resp.data.records
|
||||
}
|
||||
|
||||
context.commit("updateItemUnits", data.records)
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("updateLoadingAutocomplete", true)
|
||||
context.commit("updateErrMessage", e.message);
|
||||
context.commit("updateAlertError", true);
|
||||
}
|
||||
},
|
||||
async getDivisionByUser(context) {
|
||||
context.commit("updateLoadingAutocomplete", true)
|
||||
try {
|
||||
let response = await api.getDivisionByUser({ token: one_token() });
|
||||
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);
|
||||
context.dispatch("getItemGroupSubGroup",data.selected);
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("updateLoadingAutocomplete", false)
|
||||
context.commit("updateErrMessage", e.message);
|
||||
context.commit("updateAlertError", true);
|
||||
}
|
||||
},
|
||||
async getItemGroupSubGroup(context, payload) {
|
||||
context.commit("updateLoadingItemGroup", true)
|
||||
context.commit("updateLoadingItemSubGroup", true)
|
||||
try {
|
||||
let response = await api.getItemGroupSubGroup({ token: one_token(), division: payload.M_DivisionID ? payload.M_DivisionID : "" });
|
||||
if (response.status != "OK") {
|
||||
context.commit("updateLoadingItemGroup", false)
|
||||
context.commit("updateLoadingItemSubGroup", false)
|
||||
context.commit("updateErrMessage", response.message);
|
||||
context.commit("updateAlertError", true);
|
||||
} else {
|
||||
context.commit("updateLoadingItemGroup", false)
|
||||
context.commit("updateLoadingItemSubGroup", false)
|
||||
context.commit("updateErrMessage", "");
|
||||
context.commit("updateItemGroupOptions", response.data.records);
|
||||
context.commit("updateSelectedItemGroup", response.data.records[0]);
|
||||
context.commit("updateItemSubGroupOptions", response.data.records[0].subGroups);
|
||||
context.commit("updateSelectedItemSubGroup", response.data.records[0].subGroups[0]);
|
||||
|
||||
/*let division = payload.M_DivisionID ? payload.M_DivisionID : "";
|
||||
let itemGroup = response.data.records[0].Nat_GroupID ? response.data.records[0].Nat_GroupID : "";
|
||||
let itemSubGroup = response.data.records[0].subGroups[0].Nat_SubGroupID ? response.data.records[0].subGroups[0].Nat_SubGroupID : "";
|
||||
|
||||
let payload = {
|
||||
search: "",
|
||||
division: division,
|
||||
itemGroup: itemGroup,
|
||||
itemSubGroup: itemSubGroup
|
||||
};
|
||||
context.dispatch("getItems", payload);*/
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("updateLoadingItemGroup", false)
|
||||
context.commit("updateLoadingItemSubGroup", false)
|
||||
context.commit("updateErrMessage", e.message);
|
||||
context.commit("updateAlertError", true);
|
||||
}
|
||||
},
|
||||
async getItems(context, payload) {
|
||||
context.commit("updateLoadingItem", true)
|
||||
try {
|
||||
payload.token = one_token();
|
||||
payload.currentPage = context.state.itemCurrentPage;
|
||||
let response = await api.getItems(payload);
|
||||
if (response.status != "OK") {
|
||||
context.commit("updateLoadingItem", false)
|
||||
context.commit("updateErrMessage", response.message);
|
||||
context.commit("updateAlertError", true);
|
||||
} else {
|
||||
context.commit("updateLoadingItem", false)
|
||||
context.commit("updateErrMessage", "");
|
||||
context.commit("updateItems", response.data.records);
|
||||
context.commit("updateItemTotalPage", response.data.total);
|
||||
if(!isEmpty(context.state.selectedMainTable)) {
|
||||
context.dispatch("getSelectedItem", context.state.selectedMainTable);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("updateLoadingItem", false)
|
||||
context.commit("updateErrMessage", e.message);
|
||||
context.commit("updateAlertError", true);
|
||||
}
|
||||
},
|
||||
async getSelectedItem(context, payload) {
|
||||
try {
|
||||
payload.token = one_token();
|
||||
let response = await api.getSelectedItem(payload);
|
||||
if (response.status != "OK") {
|
||||
context.commit("updateErrMessage", response.message);
|
||||
context.commit("updateAlertError", true);
|
||||
} else {
|
||||
context.commit("updateErrMessage", "");
|
||||
context.commit("updateSelectedItem", response.data.records);
|
||||
}
|
||||
} catch (e) {
|
||||
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);
|
||||
}
|
||||
},
|
||||
async getGroupByDivision(context, payload) {
|
||||
context.commit("updateLoadingItemGroup", true)
|
||||
try {
|
||||
let response = await api.getGroupByDivision(payload);
|
||||
if (response.status != "OK") {
|
||||
context.commit("updateLoadingItemGroup", false)
|
||||
context.commit("updateErrMessage", response.message);
|
||||
context.commit("updateAlertError", true);
|
||||
} else {
|
||||
context.commit("updateLoadingItemGroup", false)
|
||||
context.commit("updateErrMessage", "");
|
||||
context.commit("updateItemGroupOptions", response.data.records);
|
||||
context.commit("updateSelectedItemGroup", response.data.records[0]);
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("updateLoadingItemGroup", false)
|
||||
context.commit("updateErrMessage", e.message);
|
||||
context.commit("updateAlertError", true);
|
||||
}
|
||||
},
|
||||
async savePurchaseRequest(context, payload) {
|
||||
context.commit("updateLoadingSave", true);
|
||||
try {
|
||||
payload.token = one_token();
|
||||
let response = await api.savePurchaseRequest(payload);
|
||||
if (response.status != "OK") {
|
||||
context.commit("updateLoadingSave", false);
|
||||
context.commit("updateErrMessage", response.message);
|
||||
context.commit("updateAlertError", true);
|
||||
} else {
|
||||
context.commit("updateLoadingSave", false);
|
||||
context.commit("updateDialogRequest", false);
|
||||
context.commit("updateSnackbar", {
|
||||
state: true,
|
||||
type: 'success',
|
||||
message: 'Purchase Request berhasil disimpan',
|
||||
});
|
||||
console.log(context.state.snackbar);
|
||||
context.commit("updateSelectedItems", []);
|
||||
context.commit("updateSelectedItem", {});
|
||||
context.commit("updateItems", []);
|
||||
context.commit("updateItemTotalPage", 0);
|
||||
context.commit("updateItemCurrentPage", 1);
|
||||
context.commit("updateItemLastId", -1);
|
||||
context.dispatch("search");
|
||||
}
|
||||
|
||||
} catch (e) {
|
||||
context.commit("updateLoadingSave", false);
|
||||
context.commit("updateErrMessage", e.message);
|
||||
context.commit("updateAlertError", true);
|
||||
}
|
||||
},
|
||||
|
||||
async updatePurchaseRequest(context, payload) {
|
||||
context.commit("updateLoadingSave", true);
|
||||
try {
|
||||
payload.token = one_token();
|
||||
let response = await api.getAPI('updatePurchaseRequest',payload);
|
||||
if (response.status != "OK") {
|
||||
context.commit("updateLoadingSave", false);
|
||||
context.commit("updateErrMessage", response.message);
|
||||
context.commit("updateAlertError", true);
|
||||
} else {
|
||||
context.commit("updateLoadingSave", false);
|
||||
context.commit("updateDialogRequest", false);
|
||||
context.commit("updateSnackbar", {
|
||||
state: true,
|
||||
type: 'success',
|
||||
message: 'Purchase Request '+payload.PRNumber+' berhasil diupdate',
|
||||
});
|
||||
console.log(context.state.snackbar);
|
||||
context.commit("updateSelectedItems", []);
|
||||
context.commit("updateSelectedItem", {});
|
||||
context.commit("updateItems", []);
|
||||
context.commit("updateItemLastId", -1);
|
||||
context.dispatch("search");
|
||||
}
|
||||
|
||||
} catch (e) {
|
||||
context.commit("updateLoadingSave", false);
|
||||
context.commit("updateErrMessage", e.message);
|
||||
context.commit("updateAlertError", true);
|
||||
}
|
||||
},
|
||||
|
||||
async saveAndDoPurchaseRequest(context, payload) {
|
||||
context.commit("updateLoadingSave", true);
|
||||
try {
|
||||
payload.token = one_token();
|
||||
|
||||
let response = await api.saveAndDoPurchaseRequest(payload);
|
||||
if (response.status !== "OK") {
|
||||
context.commit("updateLoadingSave", false);
|
||||
context.commit("updateErrMessage", response.message);
|
||||
context.commit("updateAlertError", true);
|
||||
} else {
|
||||
context.commit("updateLoadingSave", false);
|
||||
context.commit("updateDialogRequest", false);
|
||||
context.commit("updateSnackbar", {
|
||||
state: true,
|
||||
type: 'success',
|
||||
message: 'Purchase Request berhasil disimpan dan diajukan',
|
||||
});
|
||||
console.log(context.state.snackbar);
|
||||
context.commit("updateSelectedItems", []);
|
||||
context.commit("updateSelectedItem", {});
|
||||
context.commit("updateItems", []);
|
||||
context.commit("updateItemTotalPage", 0);
|
||||
context.commit("updateItemCurrentPage", 1);
|
||||
context.commit("updateItemLastId", -1);
|
||||
context.dispatch("search");
|
||||
context.dispatch("system/getlistnotif", null, { root: true })
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("updateLoadingSave", false);
|
||||
context.commit("updateErrMessage", e.message);
|
||||
context.commit("updateAlertError", true);
|
||||
}
|
||||
},
|
||||
|
||||
async getDetailRequest(context, payload) {
|
||||
context.commit("updateLoadingDetailRequest", true)
|
||||
try {
|
||||
payload.token = one_token();
|
||||
let response = await api.getAPI('getDetailRequest',payload);
|
||||
if (response.status != "OK") {
|
||||
context.commit("updateLoadingDetailRequest", false)
|
||||
context.commit("updateErrMessage", response.message);
|
||||
context.commit("updateAlertError", true);
|
||||
} else {
|
||||
context.commit("updateSelectedItems", response.data.records);
|
||||
context.commit("updateLoadingDetailRequest", false)
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("updateLoadingDetailRequest", false)
|
||||
context.commit("updateErrMessage", e.message);
|
||||
context.commit("updateAlertError", true);
|
||||
}
|
||||
},
|
||||
|
||||
async getRegionalBranchByUser(context) {
|
||||
console.log("getRegionalBranchByUser");
|
||||
let response = await api.getAPI('getRegionalBranchByUser',{ token: one_token() });
|
||||
if (response.status != "OK") {
|
||||
context.commit("updateErrMessage", response.message);
|
||||
context.commit("updateAlertError", true);
|
||||
} else {
|
||||
context.commit("updateBranchOptions", response.data);
|
||||
}
|
||||
},
|
||||
|
||||
async getRiwayatItem(context, params) {
|
||||
try {
|
||||
params.token = one_token()
|
||||
params.page = 1
|
||||
|
||||
let resp = await api.getRiwayatItem(params)
|
||||
if (resp.status != 'OK') {
|
||||
context.commit("updateErrMessage", resp.message);
|
||||
context.commit("updateAlertError", true);
|
||||
} else {
|
||||
context.commit("update_riwayat_item", resp.data)
|
||||
}
|
||||
} catch (error) {
|
||||
context.commit("updateErrMessage", error.message);
|
||||
context.commit("updateAlertError", true);
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
11
test/vuex/acc-one-purchase-request-persediaan/store.js
Normal file
11
test/vuex/acc-one-purchase-request-persediaan/store.js
Normal file
@@ -0,0 +1,11 @@
|
||||
import requester from "./modules/requester.js";
|
||||
import system from "../../../apps/modules/system/system.js";
|
||||
export const store = new Vuex.Store({
|
||||
modules: {
|
||||
requester: requester,
|
||||
system: system,
|
||||
},
|
||||
state: {},
|
||||
mutations: {},
|
||||
actions: {},
|
||||
});
|
||||
Reference in New Issue
Block a user