add modules folder based on s_menu

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

View File

@@ -0,0 +1,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>

View File

@@ -0,0 +1,925 @@
<template>
<v-layout row justify-center>
<v-dialog v-model="dialogUnit" persistent max-width="25%">
<v-card>
<v-card-title class="title grey lighten-2" primary-title>
Ganti Satuan {{ 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>
<v-dialog v-model="dialogRequest" persistent max-width="75%">
<v-card>
<v-card-title class="headline grey lighten-2" primary-title>
FORM REQUEST PENGELUARAN BARANG
</v-card-title>
<v-card-text class="pt-0 pb-0">
<v-form ref="formRequest" v-model="validationForm" lazy-validtion>
<v-layout row>
<v-flex pa-2 xs3>
<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 xs3>
<v-text-field
v-model="xRegional.S_RegionalName"
label="Regional"
readonly
:disabled="act == 'preview'">
</v-text-field>
<!-- <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">
</v-autocomplete> -->
</v-flex>
<v-flex pa-2 xs3>
<v-text-field
v-model="xBranch.M_BranchName"
label="Cabang"
readonly
:disabled="act == 'preview'"
></v-text-field>
<!-- <v-autocomplete
v-model="xBranch"
label="Cabang"
menu-icon="mdi-chevron-down"
:items="branchOptions"
item-text="M_BranchName"
item-value="M_BranchCode"
:disabled="act == 'preview'"
required
></v-autocomplete> -->
</v-flex>
<v-flex pa-2 xs6>
<v-text-field
v-model="selectedWarehouse.WarehouseName"
label="Gudang"
:disabled="act == 'preview'"
readonly
></v-text-field>
<!-- <v-autocomplete
v-model="selectedWarehouse"
label="Gudang"
menu-icon="mdi-chevron-down"
:items="warehouseOptions"
item-text="WarehouseName"
item-value="WarehouseID"
:disabled="act == 'preview'"
required
></v-autocomplete> -->
</v-flex>
</v-layout>
<v-layout>
<v-flex pa-2 pt-2 xs12>
<v-text-field
v-model="xDescription"
label="Keterangan"
:disabled="act == 'preview'"
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>
<div v-if="dialogItem == true">
<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.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>
</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 small color="primary" @click="openDialogUnit(props.item)">{{ props.item.unitName }}</v-btn>
</td>
<td
class="text-xs-center pa-2"
v-bind:class="{ 'amber lighten-4': isSelected(props.item) }"
@click="selectMe(props.item)"
>
{{ props.item.stockWarehouse }}
</td>
<td
class="text-xs-center pa-2"
v-bind:class="{ 'amber lighten-4': isSelected(props.item) }"
@click="selectMe(props.item)"
>
{{ props.item.stockDivisi }}
</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-model="props.item.qty" @change="updateQuantity(props.item)"></v-text-field>
<p v-show="emptycheckvalue.includes(props.item.itemId)" style="color: red;" class="ma-0 pa-0">Jumlah harus diisi</p>
</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>
</td>
</template>
</v-data-table>
</v-flex>
</v-layout>
</v-card>
</v-form>
</v-card-text>
<v-card-actions>
<v-btn
v-if="act === 'edit'"
color="info"
:disabled="loadingSave"
dark
@click="sendRequest()"
>Send Request</v-btn
>
<v-spacer></v-spacer>
<v-btn color="error" flat @click="closeDialogRequest()">
Tutup
</v-btn>
<v-btn
v-if="act === 'new'"
color="primary"
:disabled="loadingSave"
dark
@click="saveItemOutRequest()"
>Simpan</v-btn
>
<v-btn
v-if="act === 'edit' || act === 'preview'"
color="primary"
:disabled="loadingSave"
dark
@click="updateItemOutRequest()"
>Simpan Perubahan</v-btn
>
</v-card-actions>
</v-card>
</v-dialog>
</v-layout>
</template>
<script>
module.exports = {
name: "AddPurchaseRequestDialog",
data() {
return {
itemUnitChange:{},
branchRules: [(v) => !!v || "Cabang harus diisi"],
descRules: [(v) => !!v || "Keterangan harus diisi"],
warehoueRules: [ v => !!v || 'Gudang harus diisi'],
validationForm: false,
headers: [
{
text: "ITEM PERSEDIAAN",
align: "center",
sortable: false,
value: "itemName",
width: "15%",
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: "30%",
class: "blue lighten-3 white--text",
},
{
text: "SATUAN",
align: "center",
sortable: false,
value: "unitName",
width: "25%",
class: "blue lighten-3 white--text",
},
{
text: "STOK GUDANG",
align: "center",
sortable: false,
value: "unitName",
width: "10%",
class: "blue lighten-3 white--text",
},
{
text: "STOK DIVISI",
align: "center",
sortable: false,
value: "unitName",
width: "10%",
class: "blue lighten-3 white--text",
},
{
text: "JUMLAH",
align: "center",
sortable: false,
value: "qty",
width: "15%",
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;
},
warehouseOptions() {
return this.$store.state.requester.warehouseOptions;
},
xRegional: {
get() {
return this.$store.state.requester.xRegional;
},
set(val) {
this.$store.commit("requester/updateXRegional", val);
},
},
selectedWarehouse: {
get() {
return this.$store.state.requester.selectedWarehouse;
},
set(val) {
this.$store.commit("requester/updateSelectedWarehouse", 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 : "",
warehouseID: this.$store.state.requester.selectedWarehouse.WarehouseID
});
},
},
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");
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 : "",
warehouseID: this.$store.state.requester.selectedWarehouse.WarehouseID
});
}
},
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);
}
},
dialogItem: {
get() {
return this.$store.state.requester.dialogItem;
},
set(val) {
this.$store.commit("requester/updateDialogItem", val);
}
},
emptycheckvalue: {
get() {
return this.$store.state.requester.emptycheckvalue;
},
set(val) {
this.$store.commit("requester/updateEmptycheckvalue", val);
}
},
},
methods: {
sendRequest(){
this.$store.commit("requester/updateLoadingSave", true);
this.$store.dispatch("requester/updateRequest", {
act: "sendrequest",
RIOID: this.$store.state.requester.selectedMainTable.rioId,
RIONumber : this.$store.state.requester.selectedMainTable.rioNumber,
RIODateUse: this.xDateUse,
RIORegional: this.xRegional.S_RegionalID,
RIOBranch: this.xBranch.M_BranchCode,
RIOWarehouse: this.selectedWarehouse.WarehouseID,
RIODescription: this.xDescription,
RIODivision: this.$store.state.requester.selectedMainTable.rioDivisionId,
items: this.selectedItems
});
},
updateItemOutRequest(){
let emptycheckvalue = [];
let tempSelectedItems = this.selectedItems;
tempSelectedItems.forEach(e => {
let currentInputQty = parseInt(e.qty) || 0;
// Kalau input user kosong atau 0
if (currentInputQty <= 0) {
emptycheckvalue.push(e.itemId);
return;
}
});
if (emptycheckvalue.length === 0) {
this.emptycheckvalue = emptycheckvalue;
this.$store.commit("requester/updateLoadingSave", true);
this.$store.dispatch("requester/updateRequest", {
act: this.act,
RIOID: this.$store.state.requester.selectedMainTable.rioId,
RIONumber : this.$store.state.requester.selectedMainTable.rioNumber,
RIODateUse: this.xDateUse,
RIORegional: this.xRegional.S_RegionalID,
RIOBranch: this.xBranch.M_BranchCode,
RIOWarehouse: this.selectedWarehouse.WarehouseID,
RIODescription: this.xDescription,
RIODivision: this.selectedDivision.DivisionID,
items: this.selectedItems
});
} else {
this.emptycheckvalue = emptycheckvalue;
}
},
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;
},
saveItemOutRequest() {
let emptycheckvalue = [];
let tempSelectedItems = this.selectedItems;
tempSelectedItems.forEach(e => {
let currentInputQty = parseInt(e.qty) || 0;
// Kalau input user kosong atau 0
if (currentInputQty <= 0) {
emptycheckvalue.push(e.itemId);
return;
}
});
if (emptycheckvalue.length === 0) {
this.emptycheckvalue = emptycheckvalue;
this.$store.commit("requester/updateLoadingSave", true);
this.$store.dispatch("requester/saveRequest", {
RIODateUse: this.xDateUse,
RIORegional: this.xRegional.S_RegionalID,
RIOBranch: this.xBranch.M_BranchCode,
RIOWarehouse: this.selectedWarehouse.WarehouseID,
RIODescription: this.xDescription,
RIODivision: this.selectedDivision.DivisionID,
items: this.selectedItems
});
} else {
this.emptycheckvalue = emptycheckvalue;
}
},
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 : "",
warehouseID: this.$store.state.requester.selectedWarehouse.WarehouseID
});
},
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;
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].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.$store.commit(
"requester/updateXDateUse",
moment(new Date()).format("YYYY-MM-DD")
);
this.$store.commit("requester/updateEmptycheckvalue", []);
this.$store.commit("requester/updateXBranch", "");
this.$store.commit("requester/updateXRegional", "");
this.$store.commit("requester/updateXDescription", "");
this.$refs.formRequest.resetValidation();
this.$store.commit("requester/updateDialogRequest", false);
},
},
};
</script>

View File

@@ -0,0 +1,859 @@
<template>
<v-layout row justify-center>
<v-dialog v-model="dialogUnit" persistent max-width="25%">
<v-card>
<v-card-title class="title grey lighten-2" primary-title>
Ganti Satuan {{ 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>
<v-dialog v-model="dialogApprove" persistent max-width="75%">
<v-card>
<v-card-title class="headline grey lighten-2" primary-title>
Approved Request Pengeluaran Barang <span v-if="categoryApprove == 'K'"> [ {{ levelname }} ]</span> <span v-if="categoryApprove == 'M'"> [ {{ levelname }} / {{ approveDivision }} ]</span>
</v-card-title>
<v-card-text class="pt-0 pb-0">
<v-form ref="formRequest" v-model="validationForm" lazy-validtion>
<v-layout row>
<v-flex pa-2 xs3>
<v-menu
v-model="menuDateUse"
:close-on-content-click="false"
transition="scale-transition"
:nudge-right="40"
lazy
:disabled="actApprove == 'approve'"
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 xs3>
<v-text-field
v-model="xRegional.S_RegionalName"
label="Regional"
readonly
:disabled="actApprove == 'approve'">
</v-text-field>
</v-flex>
<v-flex pa-2 xs3>
<v-text-field
v-model="xBranch.M_BranchName"
label="Cabang"
readonly
:disabled="actApprove == 'approve'"
></v-text-field>
</v-flex>
<v-flex pa-2 xs6>
<v-text-field
v-model="selectedWarehouse.WarehouseName"
label="Gudang"
:disabled="actApprove == 'approve'"
readonly
></v-text-field>
</v-flex>
</v-layout>
<v-layout>
<v-flex pa-2 pt-2 xs12>
<v-text-field
v-model="xDescription"
label="Keterangan"
:disabled="actApprove == 'approve'"
required
></v-text-field>
</v-flex>
</v-layout>
<v-layout row>
<v-flex pa-2 pl-0 xs12>
<v-btn v-if="dialogItem == false && actApprove != 'approve'" color="primary" @click="dialogItem = true">Pilih Item</v-btn>
<v-btn v-if="dialogItem == true && actApprove != 'approve'" color="primary" @click="dialogItem = false">Tutup Pilih Item</v-btn>
</v-flex>
</v-layout>
<div v-if="dialogItem == true">
<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.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>
</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 small color="primary" @click="openDialogUnit(props.item)">{{ props.item.unitName }}</v-btn>
</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-model="props.item.qty" @change="updateQuantity(props.item)" :disabled="actApprove == 'approve'"></v-text-field>
</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="actApprove != 'approve'" style="min-width: 35px; height: 35px; margin: 0" small color="error" dark @click="deleteItem(props.item)"><v-icon small>close</v-icon></v-btn>
</td>
</template>
</v-data-table>
</v-flex>
</v-layout>
</v-card>
</v-form>
</v-card-text>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn color="error" flat @click="closeDialogRequest()">
Tutup
</v-btn>
<v-btn
color="red"
:disabled="loadingSaveRequest"
dark
outline
@click="rejectRequestx()"
>Reject</v-btn
>
<v-btn
color="primary"
:disabled="loadingSaveRequest"
dark
@click="approveRequestx()"
> {{categoryApprove == 'M' ? 'Verifikasi' : 'Approve'}} </v-btn
>
</v-card-actions>
</v-card>
</v-dialog>
</v-layout>
</template>
<script>
module.exports = {
name: "AddPurchaseRequestDialog",
data() {
return {
itemUnitChange:{},
branchRules: [(v) => !!v || "Cabang harus diisi"],
descRules: [(v) => !!v || "Keterangan harus diisi"],
warehoueRules: [ v => !!v || 'Gudang harus diisi'],
validationForm: false,
headers: [
{
text: "ITEM PERSEDIAAN",
align: "center",
sortable: false,
value: "itemName",
width: "15%",
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);
},
},
dialogApprove: {
get() {
return this.$store.state.requester.dialogApprove;
},
set(val) {
this.$store.commit("requester/update_dialogApprove", 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;
},
warehouseOptions() {
return this.$store.state.requester.warehouseOptions;
},
xRegional: {
get() {
return this.$store.state.requester.xRegional;
},
set(val) {
this.$store.commit("requester/updateXRegional", val);
},
},
selectedWarehouse: {
get() {
return this.$store.state.requester.selectedWarehouse;
},
set(val) {
this.$store.commit("requester/updateSelectedWarehouse", val);
},
},
xDescription: {
get() {
return this.$store.state.requester.xDescription;
},
set(val) {
this.$store.commit("requester/updateXDescription", val);
},
},
xPRID() {
return this.$store.state.requester.xPRID;
},
actApprove() {
return this.$store.state.requester.act_approve;
},
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 : "",
warehouseID: this.$store.state.requester.selectedWarehouse.WarehouseID
});
},
},
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");
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 : "",
warehouseID: this.$store.state.requester.selectedWarehouse.WarehouseID
});
}
},
loadingSave: {
get() {
return this.$store.state.requester.loadingSave;
},
set(val) {
this.$store.commit("requester/updateLoadingSave", val);
}
},
loadingSaveRequest: {
get() {
return this.$store.state.requester.loadingSaveRequest;
},
set(val) {
this.$store.commit("requester/updateLoadingSaveRequest", 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);
}
},
dialogItem: {
get() {
return this.$store.state.requester.dialogItem;
},
set(val) {
this.$store.commit("requester/updateDialogItem", val);
}
},
levelname: {
get() {
return this.$store.state.requester.levelname;
},
set(val) {
this.$store.commit("requester/updateLevelName", val);
},
},
categoryApprove: {
get() {
return this.$store.state.requester.categoryApprove;
},
set(val) {
this.$store.commit("requester/updateCategoryApprove", val);
},
},
approveDivision: {
get() {
return this.$store.state.requester.approveDivision;
},
set(val) {
this.$store.commit("requester/updateApproveDivision", val);
},
},
},
methods: {
approveRequestx() {
this.$store.commit("requester/updateLoadingSaveRequest", true);
let prm = {
categoryApprove: this.categoryApprove,
RIOID: this.$store.state.requester.selectedMainTable.rioId,
}
this.$store.dispatch("requester/approveRequest", prm)
},
rejectRequestx() {
this.$store.commit("requester/updateLoadingSaveRequest", true);
let prm = {
RIOID: this.$store.state.requester.selectedMainTable.rioId,
}
this.$store.dispatch("requester/rejectRequest", prm)
},
sendRequest(){
this.$store.commit("requester/updateLoadingSave", true);
this.$store.dispatch("requester/updateRequest", {
act: "sendrequest",
RIOID: this.$store.state.requester.selectedMainTable.rioId,
RIONumber : this.$store.state.requester.selectedMainTable.rioNumber,
RIODateUse: this.xDateUse,
RIORegional: this.xRegional.S_RegionalID,
RIOBranch: this.xBranch.M_BranchCode,
RIOWarehouse: this.selectedWarehouse.WarehouseID,
RIODescription: this.xDescription,
RIODivision: this.$store.state.requester.selectedMainTable.rioDivisionId,
items: this.selectedItems
});
},
updateItemOutRequest(){
this.$store.commit("requester/updateLoadingSave", true);
this.$store.dispatch("requester/updateRequest", {
act: "edit",
RIOID: this.$store.state.requester.selectedMainTable.rioId,
RIONumber : this.$store.state.requester.selectedMainTable.rioNumber,
RIODateUse: this.xDateUse,
RIORegional: this.xRegional.S_RegionalID,
RIOBranch: this.xBranch.M_BranchCode,
RIOWarehouse: this.selectedWarehouse.WarehouseID,
RIODescription: this.xDescription,
RIODivision: this.selectedDivision.DivisionID,
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;
},
saveItemOutRequest() {
this.$store.commit("requester/updateLoadingSave", true);
this.$store.dispatch("requester/saveRequest", {
RIODateUse: this.xDateUse,
RIORegional: this.xRegional.S_RegionalID,
RIOBranch: this.xBranch.M_BranchCode,
RIOWarehouse: this.selectedWarehouse.WarehouseID,
RIODescription: this.xDescription,
RIODivision: this.selectedDivision.DivisionID,
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 : "",
warehouseID: this.$store.state.requester.selectedWarehouse.WarehouseID
});
},
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;
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].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.$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.$refs.formRequest.resetValidation();
this.$store.commit("requester/update_dialogApprove", false);
},
},
};
</script>

View File

@@ -0,0 +1,912 @@
<template>
<div style="width: 100%">
<v-snackbar
v-model="snackbar.state"
:color="snackbar.type"
:timeout="3000"
multi-line
top
>
{{ snackbar.message }}
<v-btn flat @click="snackbar.state = false">
Close
</v-btn>
</v-snackbar>
<!-- ERROR DIALOG -->
<v-dialog v-model="dialog_error" max-width="500px">
<v-card>
<v-card-title>
<span>ERROR !</span>
<v-spacer></v-spacer>
</v-card-title>
<v-divider></v-divider>
<div class="ma-3 red--text">{{ msgError }}</div>
<v-divider></v-divider>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn color="primary" flat @click="dialog_error = false"
>Tutup</v-btn
>
</v-card-actions>
</v-card>
</v-dialog>
<!-- END ERROR DIALOG -->
<v-toolbar color="primary" dark>
<v-toolbar-title class="white--text"
>REQUEST PENGELUARAN BARANG</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 pl-2 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"
>
<template v-slot:activator="{ on }">
<v-text-field
:value="startDateFormatted"
label="Tanggal Awal"
readonly
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 pl-2 xs2>
<v-menu
v-model="menuEndDate"
:close-on-content-click="false"
transition="scale-transition"
:nudge-right="40"
lazy
offset-y
max-width="290px"
min-width="290px"
>
<template v-slot:activator="{ on }">
<v-text-field
:value="endDateFormatted"
label="Tanggal Akhir"
readonly
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 pl-2 xs2>
<v-autocomplete
v-model="fStatus"
menu-icon="mdi-chevron-down"
:items="statusOptions"
item-text="title"
item-value="value"
label="Status"
outline
hide-details
></v-autocomplete>
</v-flex>
<v-flex pl-2 xs2>
<v-text-field
v-model="fSearch"
label="Cari..."
placeholder="NO. RIO"
outline
hide-details
></v-text-field>
</v-flex>
<v-flex pl-2>
<v-btn
dark
color="primary"
style="min-width: 50px; height: 50px; margin: 0"
@click="mainTableSearch()"
>
<v-icon>search</v-icon>
</v-btn>
</v-flex>
<v-spacer></v-spacer>
<v-btn v-if="flag == 'G'" @click="goBack()" color="orange darken-2" title="Kembali ke listing pending approval" dark>
<v-icon dark left>arrow_back</v-icon>Back
</v-btn>
</v-layout>
</v-card>
<v-card class="pa-2 mt-2">
<v-layout row style="max-height: 600px; overflow: auto">
<v-flex xs12 pl-2 pr-2 pt-2 pb-2>
<v-data-table
:headers="headers"
:items="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.rioNumber }}
<!-- <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.rioDate)
}}
</span>
</div>
</td>
<td
class="text-xs-left pa-2"
v-bind:class="{ 'amber lighten-4': isSelected(props.item) }"
@click="selectMe(props.item)"
>
{{ props.item.rioNote }}
</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.rioStatus === 'Draft'
? 'black'
: 'white'
"
:color="
getChipStatusColor(
props.item.rioStatus
)
"
>
{{ props.item.rioStatus }}
</v-chip>
</td>
<template
v-if="props.item.rioStatus == 'Draft'"
>
<td
class="text-xs-center pa-2"
v-bind:class="{
'amber lighten-4': isSelected(props.item),
}"
>
<v-btn
style="min-width: 25px; height: 25px; margin: 0;"
@click="editRequest(props.item)"
color="black"
small title="Edit"
>
<v-icon color="white" small
>edit</v-icon
>
</v-btn>
<v-btn
style="min-width: 25px; height: 25px; margin: 0;"
@click="deleteRequest(props.item)"
color="red"
small title="Hapus"
>
<v-icon color="white" small>delete</v-icon>
</v-btn>
</td>
</template>
<template v-else-if="props.item.rioStatus == 'Send Request'">
<td
class="text-xs-center pa-2 pr-5"
v-bind:class="{
'amber lighten-4': isSelected(props.item),
}"
>
<v-btn
:disabled="mainTableLoading || props.item.RequestItemOutVerifiedUserID != '0'"
@click="approveRequest(props.item, 'M')" round depressed color="primary" small :outline="props.item.rioStatus != 'Process'"
class="d-block mx-auto mb-2"
>
Verifikasi
<v-icon small right dark>done_all</v-icon>
</v-btn>
<v-btn
:disabled="mainTableLoading || props.item.RequestItemOutVerifiedUserID == '0'"
v-if="props.item.rioStatus === 'Send Request'"
@click="approveRequest(props.item, 'K')" round depressed color="primary" small :outline="props.item.rioStatus != 'Process'"
class="d-block mx-auto mb-2"
>
Approve
<v-icon small right dark>done_all</v-icon>
</v-btn>
<v-btn
style="min-width: 25px; height: 25px; margin: 0;"
@click="previewRequest(props.item)"
color="success"
small title="Preview dan Edit Qty"
class="d-block mx-auto mb-2"
>
<v-icon color="white" small>receipt</v-icon>
</v-btn>
</td>
</template>
<template v-else>
<td
class="text-xs-center pa-2"
v-bind:class="{
'amber lighten-4': isSelected(props.item),
}"
></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>
<add-request-dialog></add-request-dialog>
<add-request-detail-dialog></add-request-detail-dialog>
<approve-dialog></approve-dialog>
<v-dialog v-model="dialogAlertDeleteRequest" max-width="30%">
<v-card>
<v-card-title class="headline grey lighten-2 pt-2 pb-2" primary-title>
Peringatan !
</v-card-title>
<v-card-text class="pt-2 pb-2">
<v-layout row>
<v-flex xs12 d-flex>
<v-layout row>
<v-flex pb-1 xs12>
<v-layout row>
<v-flex pt-2 pr-2 xs12>
{{ msgAlertDeleteRequest }}
</v-flex>
</v-layout>
</v-flex>
</v-layout>
</v-flex>
</v-layout>
</v-card-text>
<v-divider></v-divider>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn color="primary" flat @click="dialogAlertDeleteRequest = false">
Tutup
</v-btn>
<v-btn color="red" flat @click="closeAndDeleteRequest()">
Yakin lah
</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
</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-request-dialog": httpVueLoader(
"./addRequestDialog.vue"
),
"add-request-detail-dialog": httpVueLoader("./addRequestDetailDialog.vue"),
"approve-dialog": httpVueLoader("./approveDialog.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 RIO",
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: "left",
sortable: false,
value: "keterangan",
width: "40%",
class: "blue lighten-3 white--text",
},
{
text: "STATUS",
align: "left",
sortable: false,
value: "status",
width: "20%",
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/getlevel");
this.$store.dispatch("requester/getDivisionUser");
this.$store.dispatch("requester/search");
},
computed: {
flag() {
return this.$store.state.requester.flag;
},
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);
},
},
dialog_error: {
get() {
return this.$store.state.requester.alertError;
},
set(val) {
this.$store.commit("requester/updateAlertError", val);
},
},
approveLevelID: {
get() {
return this.$store.state.requester.approveLevelID;
},
set(val) {
this.$store.commit("requester/updateApproveLevelID", val);
},
},
approveDivisionUserID: {
get() {
return this.$store.state.requester.approveDivisionUserID;
},
set(val) {
this.$store.commit("requester/updateApproveDivisionUserID", val);
},
},
msgError() {
return this.$store.state.requester.errMessage;
}
},
methods: {
goBack() {
window.history.back();
// location.href = "/one-ui/test/vuex/one-accone-approve-all/"
},
isApproved(data, type) {
if (!data) {
return false
}
if (data.rioStatus == 'Process') {
return false
}
if (type == 'M' && data.RequestItemOutApprovedManagerUserID == '0') {
return true
} else if (type == 'D' && data.RequestItemOutApprovedDivisionUserID == '0') {
return true
} else {
return false
}
},
approveRequest(val, app){
this.$store.commit("requester/updateCategoryApprove", app);
this.$store.commit("requester/updateSelectedMainTable", val);
let selectedRio = val
this.$store.commit("requester/updateRegionalOptions", [{S_RegionalID : selectedRio.S_RegionalID, S_RegionalName : selectedRio.S_RegionalName}]);
this.$store.commit("requester/updateXRegional", {S_RegionalID : selectedRio.S_RegionalID, S_RegionalName : selectedRio.S_RegionalName});
this.$store.commit("requester/updateBranchOptions", [{M_BranchCode : selectedRio.M_BranchCode, M_BranchName : selectedRio.M_BranchName}]);
this.$store.commit("requester/updateXBranch", {M_BranchCode : selectedRio.M_BranchCode, M_BranchName : selectedRio.M_BranchName});
this.$store.commit(
"requester/updateXDateUse",
selectedRio.rioDate
);
this.$store.dispatch("requester/getWarehouse");
this.$store.commit("requester/updateSelectedWarehouse",selectedRio.rioWarehouseId);
this.$store.commit("requester/updateXDescription", selectedRio.rioNote);
this.$store.dispatch("requester/getDivisionByUser", {
act: 'edit',
DivisionID: val.rioDivisionId
});
this.$store.commit("requester/update_dialogApprove", true);
this.$store.dispatch("requester/getDetailRequest", {
requestId: selectedRio.rioId
});
this.$store.commit("requester/update_act_approve", "approve");
},
previewRequest(val){
this.$store.commit("requester/updateSelectedMainTable", val);
let selectedRio = val
console.log(selectedRio)
this.$store.commit("requester/updateRegionalOptions", [{S_RegionalID : selectedRio.S_RegionalID, S_RegionalName : selectedRio.S_RegionalName}]);
this.$store.commit("requester/updateXRegional", {S_RegionalID : selectedRio.S_RegionalID, S_RegionalName : selectedRio.S_RegionalName});
this.$store.commit("requester/updateBranchOptions", [{M_BranchCode : selectedRio.M_BranchCode, M_BranchName : selectedRio.M_BranchName}]);
this.$store.commit("requester/updateXBranch", {M_BranchCode : selectedRio.M_BranchCode, M_BranchName : selectedRio.M_BranchName});
this.$store.commit(
"requester/updateXDateUse",
selectedRio.rioDate
);
this.$store.dispatch("requester/getWarehouse");
this.$store.commit("requester/updateSelectedWarehouse",selectedRio.rioWarehouseId);
this.$store.commit("requester/updateXDescription", selectedRio.rioNote);
this.$store.dispatch("requester/getDivisionByUser", {
act: 'edit',
DivisionID: val.rioDivisionId
});
this.$store.commit("requester/updateDialogRequest", true);
this.$store.dispatch("requester/getDetailRequest", {
requestId: selectedRio.rioId,
division: selectedRio.rioDivisionId,
warehouseID: selectedRio.rioWarehouseId
});
this.$store.commit("requester/updateAct", "preview");
},
convertMoney(money){
return one_money(money)
},
isSelected(p) {
return (
p.rioId ==
this.$store.state.requester.selectedMainTable
.rioId
);
},
selectMe(spr) {
this.$store.commit("requester/updateSelectedMainTable", 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")}`;
},
getChipStatusColor(status) {
switch (status) {
case "Send Request":
return "warning";
case "Process":
return "success";
case "Partial":
return "green";
case "Rejected":
return "error";
case "Completed":
return "info";
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", {});
this.$store.commit("requester/updateSelectedWarehouse", "");
},
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/updateBranchOptions", [{M_BranchCode : user.M_BranchCode, M_BranchName : 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/getWarehouse");
this.$store.dispatch("requester/getDivisionByUser", {
act: 'new',
DivisionID: ''
}).then(() => {
const divisionId = this.$store.state.requester.selectedDivision.DivisionID;
this.$store.dispatch("requester/getItems", {
search: "",
division: divisionId,
itemGroup: "",
itemSubGroup: "",
warehouseID: this.$store.state.requester.selectedWarehouse.WarehouseID
});
this.$store.dispatch("requester/getItemGroupSubGroup");
});
this.$store.commit("requester/updateDialogItem", false);
this.$store.commit("requester/updateSelectedItems", []);
},
editRequest(val) {
console.log(val)
this.$store.commit("requester/updateSelectedMainTable", val);
this.$store.commit("requester/updateAct", "edit");
let selectedRio = val
this.$store.commit("requester/updateRegionalOptions", [{S_RegionalID : selectedRio.S_RegionalID, S_RegionalName : selectedRio.S_RegionalName}]);
this.$store.commit("requester/updateXRegional", {S_RegionalID : selectedRio.S_RegionalID, S_RegionalName : selectedRio.S_RegionalName});
this.$store.commit("requester/updateBranchOptions", [{M_BranchCode : selectedRio.M_BranchCode, M_BranchName : selectedRio.M_BranchName}]);
this.$store.commit("requester/updateXBranch", {M_BranchCode : selectedRio.M_BranchCode, M_BranchName : selectedRio.M_BranchName});
this.$store.commit(
"requester/updateXDateUse",
selectedRio.rioDate
);
this.$store.dispatch("requester/getWarehouse");
this.$store.commit("requester/updateSelectedWarehouse",selectedRio.rioWarehouseId);
this.$store.commit("requester/updateXDescription", selectedRio.rioNote);
this.$store.dispatch("requester/getDivisionByUser", {
act: 'edit',
DivisionID: val.rioDivisionId
}).then(() => {
const divisionId = this.$store.state.requester.selectedDivision.DivisionID;
this.$store.dispatch("requester/getItems", {
search: "",
division: divisionId,
itemGroup: "",
itemSubGroup: "",
warehouseID: this.$store.state.requester.selectedWarehouse.WarehouseID
});
this.$store.dispatch("requester/getItemGroupSubGroup");
});
this.$store.commit("requester/updateDialogRequest", true);
this.$store.commit("requester/updateDialogItem", false);
this.$store.dispatch("requester/getDetailRequest", {
requestId: selectedRio.rioId,
division: selectedRio.rioDivisionId,
warehouseID: selectedRio.rioWarehouseId
});
},
deleteRequest(data) {
this.xPRID = data.rioId;
this.xNumber = data.rioNumber;
this.msgAlertDeleteRequest = `Yakin, mau hapus Request [${data.rioNumber}] ?`;
this.dialogAlertDeleteRequest = true;
},
closeAndDeleteRequest() {
this.$store.dispatch("requester/deleteRequest", {
RIOID: this.xPRID,
RIONumber: this.xNumber,
});
this.dialogAlertDeleteRequest = false;
},
orderRequest(id, status) {
if (status === "Draft") {
this.$store.dispatch("requester/orderRequest", {
PRID: id,
});
}
},
},
};
</script>