add button report po asset

This commit is contained in:
Hanan Askarim
2026-07-21 09:21:31 +07:00
parent 5d0351d2a5
commit ba320134f8
5 changed files with 1315 additions and 1 deletions

View File

@@ -0,0 +1,244 @@
<template>
<v-dialog v-model="dialog_add_itemaset" persistent width="60vw">
<v-card>
<v-card-title class="headline grey lighten-2" primary title>
TAMBAH REQUEST ASET
</v-card-title>
<v-card-text>
<v-layout row wrap>
<v-flex xs12>
<v-text-field
v-model="keyword" hide-details outline
label="cari" placeholder="nomor request aset"
></v-text-field>
</v-flex>
<v-flex xs12 mt-2>
<v-data-table
:headers="headers" :items="list_requestaset.records"
v-model="temp_selectedrequest" item-key="PurchaseRequestDetailID"
class="elevation-1" hide-actions :loading="loading"
>
<template v-slot:headers="props">
<tr>
<th class="blue lighten-3 white--text" style="width: 10%;">
<v-checkbox
:input-value="props.all" primary
:indeterminate="props.indeterminate"
@click.native="toggleAll" hide-details
></v-checkbox>
</th>
<th v-for="header in props.headers" :key="header.text"
:class="header.class" :style="{ width: header.width }"
>{{ header.text }}</th>
</tr>
</template>
<template v-slot:items="props">
<tr>
<td>
<v-checkbox
v-model="props.selected"
primary hide-details
></v-checkbox>
</td>
<td class="text-xs-center pa-2">
{{ props.item.PurchaseRequestNumber }}
</td>
<td class="text-xs-center pa-2">
{{ props.item.M_ItemCode }}
</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.RequestQty }}
</td>
</tr>
</template>
</v-data-table>
</v-flex>
</v-layout>
</v-card-text>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn class="white--text" color="error" @click="batalrequest()">Batal</v-btn>
<v-btn class="white--text" color="primary" @click="simpanrequest()">Simpan</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
</template>
<script>
module.exports = {
data() {
return {
keyword: "",
loading: false,
temp_selectedrequest: [],
headers: [
{
text: "NO PURCHASE REQ", align: "center", sortable: false,
value: "noreq", width: "20%", class: "pa-1 blue lighten-3 white--text",
},
{
text: "KODE ITEM", align: "center", sortable: false,
value: "kode", width: "20%", class: "pa-1 blue lighten-3 white--text",
},
{
text: "ITEM", align: "center", sortable: false,
value: "serve", width: "20%", class: "pa-1 blue lighten-3 white--text",
},
{
text: "SATUAN", align: "center", sortable: false,
value: "unit", width: "20%", class: "pa-1 blue lighten-3 white--text",
},
{
text: "REQ QTY", align: "center", sortable: false,
value: "qty", width: "10%", class: "pa-1 blue lighten-3 white--text",
},
]
}
},
computed: {
dialog_add_itemaset: {
get() {
return this.$store.state.common.dialog_add_itemaset
},
set(val) {
this.$store.commit('common/update_dialog_add_itemaset', val)
}
},
list_requestaset: {
get() {
return this.$store.state.common.list_requestaset
},
set(val) {
this.$store.commit('common/update_list_requestaset', val)
}
},
form_orderaset: {
get() {
return this.$store.state.common.form_orderaset
},
set(val) {
this.$store.commit('common/update_form_orderaset', val)
}
},
item_orderaset: {
get() {
return this.$store.state.common.item_orderaset
},
set(val) {
this.$store.commit('common/update_item_orderaset', val)
}
},
summary_orderaset: {
get() {
return this.$store.state.common.summary_orderaset
},
set(val) {
this.$store.commit('common/update_summary_orderaset', val)
}
}
},
methods: {
searchrequest(search) {
this.loading = true
setTimeout(() => {
this.$store.dispatch('common/lookupOrderRequest', search)
this.loading = false
}, 500);
},
toggleAll() {
if (this.temp_selectedrequest.length > 0) {
this.temp_selectedrequest = []
} else {
this.temp_selectedrequest = this.list_requestaset.records.slice()
}
},
parseCurrency(value) {
let cleanvalue = 0;
if (!isNaN(value)) {
cleanvalue = value;
} else {
cleanvalue = String(value).replace(/\./g, '');
cleanvalue = cleanvalue.replace(',', '.');
}
return parseFloat(cleanvalue) || 0;
},
batalrequest() {
this.temp_selectedrequest = []
this.dialog_add_itemaset = false
},
simpanrequest() {
let request = JSON.parse(JSON.stringify(this.temp_selectedrequest))
let form = JSON.parse(JSON.stringify(this.form_orderaset))
const prnumber = [...new Set(request.map(item => item.PurchaseRequestNumber))].join(', ')
form.reference = prnumber
const newitem = Object.values(request.reduce((acc, current) => {
const itemcode = current.M_ItemCode
if (!acc[itemcode]) {
acc[itemcode] = {
M_ItemID: current.M_ItemID,
M_ItemCode: itemcode,
M_ItemDesc: current.M_ItemDesc,
ItemUnitID: current.ItemUnitID,
ItemUnitName: current.ItemUnitName,
SupplierPrice: Number(current.SupplierPrice),
M_BranchName: current.M_BranchName,
RequestQty: 0.00,
DiskonAmount: 0.00,
DiskonType: 'R',
EndPrice: 0.00,
TempTotal: 0.00,
detail: []
}
}
acc[itemcode].RequestQty += Number(current.RequestQty)
acc[itemcode].detail.push(current)
acc[itemcode].EndPrice = acc[itemcode].SupplierPrice - acc[itemcode].DiskonAmount
acc[itemcode].TempTotal = acc[itemcode].RequestQty * acc[itemcode].EndPrice
return acc
}, {}))
let subtotal = newitem.reduce((sum, item) => sum + Number(item.TempTotal), 0)
let disc = this.parseCurrency(form.valuediskon)
if (form.typediskon == 'percent') {
disc = subtotal * Number(form.valuediskon) / 100
}
let tax = this.parseCurrency(form.valuepajak)
if (form.typepajak == 'percent') {
tax = (subtotal - disc) * Number(form.valuepajak) / 100
}
let total = (subtotal - disc) + tax
let summary = {
subtotal: subtotal,
diskon: disc,
pajak: tax,
total: total
}
this.item_orderaset = newitem
this.form_orderaset = form
this.summary_orderaset = summary
this.temp_selectedrequest = []
this.dialog_add_itemaset = false
}
},
watch: {
keyword(newval, oldval) {
if (!newval) return
if (newval === oldval) return
if (newval.length < 1) return
this.searchrequest(newval)
},
}
}
</script>

View File

@@ -0,0 +1,259 @@
<template>
<v-dialog v-model="dialog_create_contract" persistent width="80vw">
<v-card style="max-height: 80vh; display: flex; flex-direction: column;">
<v-card-title class="headline grey lighten-2">BUAT KONTRAK BARU</v-card-title>
<v-card-text style="flex: 1 1 auto; overflow: visible;">
<!-- field forms -->
<v-layout row wrap>
<v-flex xs4 pa-1>
<v-text-field
v-model="form_kontrak.nama_kontrak" hide-details outline
label="Nama Kontrak" placeholder="masukan nama kontrak"
></v-text-field>
</v-flex>
<v-flex xs4 pa-1>
<v-menu
v-model="menuKontrakDate" offset-y lazy min-width="290px"
transition="scale-transition" max-width="290px" full-width
:nudge-right="40" :close-on-content-click="false"
>
<template v-slot:activator="{ on }">
<v-text-field
v-model="formattedDateKontrak" label="Tanggal Kontrak"
hide-details readonly outline v-on="on"
></v-text-field>
</template>
<v-date-picker v-model="form_kontrak.tanggal_kontrak"
no-title @input="menuKontrakDate = false"
></v-date-picker>
</v-menu>
</v-flex>
<v-flex xs4 pa-1>
<v-autocomplete
v-model="form_kontrak.supplierID_kontrak" hide-details
:items="supplier_list" label="Supplier" outline
item-text="SupplierName" item-value="SupplierID"
></v-autocomplete>
</v-flex>
</v-layout>
<v-layout row wrap>
<v-flex xs3 pa-1>
<v-menu
v-model="menuKontrakStartdate" offset-y lazy min-width="290px"
transition="scale-transition" max-width="290px" full-width
:nudge-right="40" :close-on-content-click="false"
>
<template v-slot:activator="{ on }">
<v-text-field
v-model="formattedStartdateKontrak" outline v-on="on"
label="Tanggal Awal Kontrak" hide-details readonly
></v-text-field>
</template>
<v-date-picker v-model="form_kontrak.tanggalAwal_kontrak"
no-title @input="menuKontrakStartdate = false"
></v-date-picker>
</v-menu>
</v-flex>
<v-flex xs3 pa-1>
<v-menu
v-model="menuKontrakEnddate" offset-y lazy min-width="290px"
transition="scale-transition" max-width="290px" full-width
:nudge-right="40" :close-on-content-click="false"
>
<template v-slot:activator="{ on }">
<v-text-field
v-model="formattedEnddateKontrak" outline v-on="on"
label="Tanggal Akhir Kontrak" hide-details readonly
></v-text-field>
</template>
<v-date-picker v-model="form_kontrak.tanggalAkhir_kontrak"
no-title @input="menuKontrakEnddate = false"
></v-date-picker>
</v-menu>
</v-flex>
<v-flex xs2 pa-1>
<v-text-field
v-model="form_kontrak.durasi_cicilan" hide-details outline
label="Durasi Kontrak (Bulan)" placeholder="1" readonly
></v-text-field>
</v-flex>
<v-flex xs2 pa-1>
<v-text-field
v-model="form_kontrak.jumlah_cicilan" hide-details
label="Jumlah Cicilan" placeholder="1" outline
></v-text-field>
</v-flex>
<v-flex xs2 pa-1>
<v-text-field
v-model="form_kontrak.tanggalBayar_cicilan" hide-details
label="Tanggal Bayar Cicilan" placeholder="1" outline
></v-text-field>
</v-flex>
</v-layout>
<v-layout row wrap>
<v-flex xs4 pa-1>
<v-text-field
v-model="form_kontrak.besarNilai_cicilan" hide-details
label="Besar Bayar Cicilan" placeholder="0" prefix="Rp." outline
></v-text-field>
</v-flex>
<v-flex xs1 pa-1>
<v-autocomplete
:items="['nominal', 'persen']" label="Tipe Nilai"
v-model="form_kontrak.type_downpayment" hide-details
@input="changeTypeAmount('DP')" outline
></v-autocomplete>
</v-flex>
<v-flex xs3 pa-1>
<v-text-field
v-model="form_kontrak.besarNilai_downpayment" hide-details
label="Jumlah Uang Muka" placeholder="0" suffix="%" outline
></v-text-field>
</v-flex>
<v-flex xs1 pa-1>
<v-autocomplete
:items="['nominal', 'persen']" label="Tipe Nilai"
v-model="form_kontrak.type_pajak" hide-details
@input="changeTypeAmount('tax')" outline
></v-autocomplete>
</v-flex>
<v-flex xs3 pa-1>
<v-text-field
v-model="form_kontrak.besarNilai_pajak" hide-details
label="Jumlah Pajak" placeholder="0" suffix="%" outline
></v-text-field>
</v-flex>
</v-layout>
<!-- table item -->
<v-layout row wrap class="mt-2">
<v-flex xs3 pa-1>
<v-btn block color="info">TAMBAH ITEM</v-btn>
</v-flex>
<v-flex xs12 pa-1>
<div style="max-height: 35vh; overflow-y: auto;">
<v-data-table
:headers="headers" :items="[]"
item-key="M_ItemID" class="elevation-1" hide-actions
>
<template v-slot:items="props">
<tr>
<td class="text-xs-center pa-1"></td>
<td class="text-xs-center pa-1"></td>
<td class="text-xs-center pa-1"></td>
<td class="text-xs-center pa-1"></td>
<td class="text-xs-center pa-1"></td>
<td class="text-xs-center pa-1"></td>
</tr>
</template>
</v-data-table>
</div>
</v-flex>
</v-layout>
</v-card-text>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn @click="" color="error" class="white--text">Batal</v-btn>
<v-btn @click="" color="primary" class="white--text">Simpan</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
</template>
<script>
module.exports = {
data() {
return {
menuKontrakDate: false,
menuKontrakStartdate: false,
menuKontrakEnddate: false,
headers: [
{
text: "NO", align: "center", sortable: false, value: "no",
width: "5%", class: "pa-1 blue lighten-3 white--text",
},
{
text: "ITEM", align: "center", sortable: false, value: "item",
width: "25%", class: "pa-1 blue lighten-3 white--text",
},
{
text: "JUMLAH", align: "center", sortable: false, value: "qty",
width: "15%", class: "pa-1 blue lighten-3 white--text",
},
{
text: "HARGA", align: "center", sortable: false, value: "price",
width: "25%", class: "pa-1 blue lighten-3 white--text",
},
{
text: "TOTAL", align: "center", sortable: false, value: "total",
width: "20%", class: "pa-1 blue lighten-3 white--text",
},
{
text: "AKSI", align: "center", sortable: false, value: "act",
width: "10%", class: "pa-1 blue lighten-3 white--text",
}
]
};
},
computed: {
dialog_create_contract: {
get() {
return this.$store.state.kontrakAsset.dialog_create_contract
},
set(val) {
this.$store.commit("kontrakAsset/update_dialog_create_contract", val);
}
},
supplier_list() {
return [];
},
form_kontrak: {
get() {
return this.$store.state.kontrakAsset.form_kontrak
},
set(val) {
this.$store.commit("kontrakAsset/update_form_kontrak", val);
}
},
formattedDateKontrak() {
return this.formatDate(this.form_kontrak.tanggal_kontrak);
},
formattedStartdateKontrak() {
return this.formatDate(this.form_kontrak.tanggalAwal_kontrak);
},
formattedEnddateKontrak() {
return this.formatDate(this.form_kontrak.tanggalAkhir_kontrak);
}
},
methods: {
formatDate(date) {
if (!date) return null;
const [year, month, day] = date.split('-');
return `${day}-${month}-${year}`;
},
countMonths(startdate, enddate) {
const start = new Date(stardate);
const end = new Date(enddate);
let months = (end.getFullYear() - start.getFullYear()) * 12 + (end.getMonth() - start.getMonth());
if (end.getDate() > start.getDate()) {
months += 1;
}
return Math.max(months, 1);
},
changeTypeAmount(name) {
let form = this.form_kontrak;
if (name == 'DP') {
form_kontrak.jumlah_downpayment = 0;
}
if (name == 'tax') {
form_kontrak.jumlah_pajak = 0;
}
}
}
}
</script>

View File

@@ -0,0 +1,601 @@
<template>
<v-dialog v-model="dialog_form_orderaset" persistent width="70vw">
<v-card>
<v-card-title class="headline grey lighten-2">FORM PO ASET</v-card-title>
<v-card-text>
<!-- first row -->
<v-layout row wrap>
<v-flex xs4>
<v-menu
v-model="menuPOdate" offset-y lazy min-width="290px"
transition="scale-transition" max-width="290px" full-width
:nudge-right="40" :close-on-content-click="false"
>
<template v-slot:activator="{on}">
<v-text-field
v-model="formatPOdate" label="Tanggal PO"
hide-details readonly v-on="on" outline
></v-text-field>
</template>
<v-date-picker
v-model="form_orderaset.podate" no-title
@input="menuPOdate = false"
></v-date-picker>
</v-menu>
</v-flex>
<v-flex xs4 pl-2>
<v-autocomplete
:items="list_supplier" hide-details outline
v-model="form_orderaset.supplierID" label="Vendor"
item-text="SupplierName" item-value="SupplierID"
@input="changeSupplierCabang()"
></v-autocomplete>
</v-flex>
<v-flex xs4 pl-2>
<v-text-field
v-model="form_orderaset.reference" hide-details outline
label="Referensi" placeholder="nomor request" readonly
></v-text-field>
</v-flex>
</v-layout>
<!-- 2nd row -->
<v-layout row wrap class="mt-2">
<v-flex xs4>
<v-autocomplete
:items="list_branch" hide-details outline
v-model="form_orderaset.branchcode" label="Cabang"
item-text="M_BranchName" item-value="M_BranchCode"
@input="changeSupplierCabang()"
></v-autocomplete>
</v-flex>
<v-flex xs2 pl-2>
<v-autocomplete
:items="['absolute', 'percent']" label="Pajak (PPN)"
v-model="form_orderaset.typepajak" hide-details
@input="changeTypeTaxDiskon('tax')" outline
></v-autocomplete>
</v-flex>
<v-flex xs2 pl-2>
<v-text-field
v-if="form_orderaset.typepajak == 'percent'" label="Pajak"
v-model="form_orderaset.valuepajak" hide-details outline
placeholder="besar pajak dalam persen" suffix="%"
@input="debounceCalcForm(form_orderaset)"
></v-text-field>
<v-text-field
v-else label="Pajak" outline prefix="Rp."
v-model="form_orderaset.valuepajak" hide-details
placeholder="besar pajak dalam rupiah"
@input="debounceCalcForm(form_orderaset)"
@focus="handleFocus(form_orderaset, 'formtax')"
@blur="handleBlur(form_orderaset, 'formtax')"
></v-text-field>
</v-flex>
<v-flex xs2 pl-2>
<v-autocomplete
:items="['absolute', 'percent']" hide-details
v-model="form_orderaset.typediskon" label="Diskon"
@input="changeTypeTaxDiskon('diskon')" outline
></v-autocomplete>
</v-flex>
<v-flex xs2 pl-2>
<v-text-field
v-if="form_orderaset.typediskon == 'percent'" label="Diskon"
v-model="form_orderaset.valuediskon" hide-details outline
placeholder="besar diskon dalam persen" suffix="%"
@input="debounceCalcForm(form_orderaset)"
></v-text-field>
<v-text-field
v-else label="Diskon" outline prefix="Rp."
v-model="form_orderaset.valuediskon" hide-details
placeholder="besar diskon dalam rupiah"
@input="debounceCalcForm(form_orderaset)"
@focus="handleFocus(form_orderaset, 'formdiskon')"
@blur="handleBlur(form_orderaset, 'formdiskon')"
></v-text-field>
</v-flex>
</v-layout>
<v-layout row wrap class="mt-2">
<v-flex xs3>
<v-btn
block color="info" @click="addItemRequest()"
:disabled="form_orderaset.branchcode == '' || form_orderaset.supplierID == ''"
>TAMBAH ITEM</v-btn>
</v-flex>
</v-layout>
<!-- table item -->
<v-layout row wrap class="mt-2">
<v-flex xs12 v-if="item_orderaset.length > 0">
<v-data-table
:headers="headers" :items="item_orderaset" :expand="expand"
item-key="M_ItemCode" class="elevation-1" hide-actions
>
<template v-slot:items="props">
<tr>
<td class="text-xs-center pa-2"
@click="props.expanded = !props.expanded"
>
<v-icon>{{ props.expanded
? "keyboard_arrow_down"
: "keyboard_arrow_right"
}}</v-icon>
</td>
<td class="text-xs-center pa-2">
{{ props.item.M_ItemDesc }}
</td>
<td class="text-xs-center pa-2">
{{ props.item.RequestQty }}
</td>
<td class="text-xs-center pa-2">
Rp. {{ formatCurrency(props.item.SupplierPrice) }}
</td>
<td class="text-xs-center pa-2">
<v-layout row>
<v-menu open-on-hover top offset-y attach>
<v-btn slot="activator" color="primary" dark small>
<span v-if="props.item.DiskonType == 'R'">Rp</span>
<span v-else>%</span>
</v-btn>
<v-list>
<v-list-tile
v-for="(name, index) in typedisc" :key="index"
@click="changeDiscountPerItem(name, props.item)"
>
<v-list-tile-title>{{ name }}</v-list-tile-title>
</v-list-tile>
</v-list>
</v-menu>
<v-text-field
v-if="props.item.DiskonType == 'R'" prefix="Rp."
v-model="props.item.DiskonAmount" hide-details
@input="debounceCalcItem(props.item)" solo
@focus="handleFocus(props.item, 'itemdiskon')"
@blur="handleBlur(props.item, 'itemdiskon')"
></v-text-field>
<v-text-field
v-if="props.item.DiskonType == 'P'" suffix="%" min="0"
v-model="props.item.DiskonAmount" hide-details solo
@input="debounceCalcItem(props.item)" type="number"
></v-text-field>
</v-layout>
</td>
<td class="text-xs-center pa-2">
Rp. {{ formatCurrency(props.item.EndPrice) }}
</td>
<td class="text-xs-center pa-2">
Rp. {{ formatCurrency(props.item.TempTotal) }}
</td>
<td class="text-xs-center pa-2">
<v-btn
color="red" dark @click="{}"
style="min-width: 40px; margin: 0;" small
>
<v-icon small>delete</v-icon>
</v-btn>
</td>
</tr>
</template>
<!-- expanded -->
<template v-slot:expand="props">
<v-card flat>
<v-card-text>
<v-data-table
:headers="headers_detail" class="elevation-0"
:items="props.item.detail" hide-actions
>
<template v-slot:items="detail">
<tr>
<td class="text-xs-center pa-2">
{{ detail.item.M_ItemDesc }}
</td>
<td class="text-xs-center pa-2">
{{ detail.item.PurchaseRequestNumber }}
</td>
<td class="text-xs-center pa-2">
{{ detail.item.M_BranchName }}
</td>
<td class="text-xs-center pa-2">
{{ detail.item.RequestQty }}
</td>
<td class="text-xs-center pa-2">
{{ detail.item.ItemUnitName }}
</td>
<td class="text-xs-center pa-2">
Rp. {{ formatCurrency(detail.item.SupplierPrice) }}
</td>
<td class="text-xs-center pa-2">
<v-btn
color="red" flat @click="{}"
style="min-width: 40px; margin: 0;" small
>
<v-icon>delete</v-icon>
</v-btn>
</td>
</tr>
</template>
</v-data-table>
</v-card-text>
</v-card>
</template>
<!-- footer -->
<template v-slot:footer>
<tr>
<td colspan="1" class="text-xs-left pa-2"></td>
<td colspan="4" class="text-xs-left pa-2">
<strong>JUMLAH</strong>
</td>
<td colspan="2" class="text-xs-right pa-2">
<strong>
Rp. {{ formatCurrency(summary_orderaset.subtotal) }}
</strong>
</td>
<td colspan="1" class="text-xs-right pa-2"></td>
</tr>
<tr>
<td colspan="1" class="text-xs-left pa-2"></td>
<td colspan="4" class="text-xs-left pa-2">
<strong>DISKON</strong>
</td>
<td colspan="2" class="text-xs-right pa-2">
<strong>
Rp. {{ formatCurrency(summary_orderaset.diskon) }}
</strong>
</td>
<td colspan="1" class="text-xs-right pa-2"></td>
</tr>
<tr>
<td colspan="1" class="text-xs-left pa-2"></td>
<td colspan="4" class="text-xs-left pa-2">
<strong>PAJAK</strong>
</td>
<td colspan="2" class="text-xs-right pa-2">
<strong>
Rp. {{ formatCurrency(summary_orderaset.pajak) }}
</strong>
</td>
<td colspan="1" class="text-xs-right pa-2"></td>
</tr>
<tr>
<td colspan="1" class="text-xs-left pa-2"></td>
<td colspan="4" class="text-xs-left pa-2">
<strong>TOTAL</strong>
</td>
<td colspan="2" class="text-xs-right pa-2">
<strong>
Rp. {{ formatCurrency(summary_orderaset.total) }}
</strong>
</td>
<td colspan="1" class="text-xs-right pa-2"></td>
</tr>
</template>
</v-data-table>
</v-flex>
</v-layout>
</v-card-text>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn @click="batalOrder()" color="error" class="white--text">Batal</v-btn>
<v-btn @click="simpanOrder()" color="primary" class="white--text">Simpan</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
</template>
<script>
module.exports = {
data() {
return {
menuPOdate: false,
expand: false,
headers: [
{
text: "", align: "center", sortable: false,
value: "item", width: "5%", class: "pa-1 blue lighten-3 white--text",
},
{
text: "ITEM", align: "center", sortable: false,
value: "item", width: "15%", class: "pa-1 blue lighten-3 white--text",
},
{
text: "JUMLAH", align: "center", sortable: false,
value: "qty", width: "10%", class: "pa-1 blue lighten-3 white--text",
},
{
text: "HARGA", align: "center", sortable: false,
value: "price", width: "15%", class: "pa-1 blue lighten-3 white--text",
},
{
text: "DISKON", align: "center", sortable: false,
value: "disc", width: "20%", class: "pa-1 blue lighten-3 white--text",
},
{
text: "HARGA SETELAH DISKON", align: "center", sortable: false,
value: "disc", width: "15%", class: "pa-1 blue lighten-3 white--text",
},
{
text: "TOTAL", align: "center", sortable: false,
value: "disc", width: "15%", class: "pa-1 blue lighten-3 white--text",
},
{
text: "AKSI", align: "center", sortable: false,
value: "disc", width: "5%", class: "pa-1 blue lighten-3 white--text",
}
],
headers_detail: [
{
text: "NAMA PRODUK", align: "center", sortable: false,
value: "prod", width: "20%", class: "pa-1 blue lighten-4 black--text",
},
{
text: "NO REQUEST", align: "center", sortable: false,
value: "noreq", width: "20%", class: "pa-1 blue lighten-4 black--text",
},
{
text: "REQUESTER", align: "center", sortable: false,
value: "req", width: "20%", class: "pa-1 blue lighten-4 black--text",
},
{
text: "JUMLAH", align: "center", sortable: false,
value: "qty", width: "10%", class: "pa-1 blue lighten-4 black--text",
},
{
text: "UNIT", align: "center", sortable: false,
value: "unit", width: "10%", class: "pa-1 blue lighten-4 black--text",
},
{
text: "HARGA", align: "center", sortable: false,
value: "price", width: "15%", class: "pa-1 blue lighten-4 black--text",
},
{
text: "AKSI", align: "center", sortable: false,
value: "act", width: "5%", class: "pa-1 blue lighten-4 black--text",
}
],
typedisc: ["absolute", "percent"]
}
},
computed: {
dialog_form_orderaset: {
get() {
return this.$store.state.common.dialog_form_orderaset;
},
set(val) {
this.$store.commit('common/update_dialog_form_orderaset', val);
}
},
form_orderaset: {
get() {
return this.$store.state.common.form_orderaset;
},
set(val) {
this.$store.commit('common/update_form_orderaset', val);
}
},
item_orderaset: {
get() {
return this.$store.state.common.item_orderaset;
},
set(val) {
this.$store.commit('common/update_item_orderaset', val);
}
},
summary_orderaset: {
get() {
return this.$store.state.common.summary_orderaset
},
set(val) {
this.$store.commit('common/update_summary_orderaset', val)
}
},
formatPOdate() {
return this.formatDate(this.form_orderaset.podate);
},
list_supplier() {
return this.$store.state.common.list_supplier;
},
list_branch() {
return this.$store.state.common.list_branch;
}
},
methods: {
formatDate(date) {
if (!date) return null;
const [year, month, day] = date.split('-');
return `${day}-${month}-${year}`;
},
formatCurrency(value) {
const num = parseFloat(value);
if (isNaN(num)) return 0;
return num.toFixed(2).replace('.', ',').replace(/\B(?=(\d{3})+(?!\d))/g, ".");
},
parseCurrency(value) {
let cleanvalue = 0;
if (!isNaN(value)) {
cleanvalue = value;
} else {
cleanvalue = String(value).replace(/\./g, '');
cleanvalue = cleanvalue.replace(',', '.');
}
return parseFloat(cleanvalue) || 0;
},
handleFocus(item, type) {
if (type == 'itemprice') {
const currentval = item.SupplierPrice
const parsedval = this.parseCurrency(currentval)
item.SupplierPrice = parsedval
}
if (type == 'itemdiskon') {
const currentdisc = item.DiskonAmount
const parseddisc = this.parseCurrency(currentdisc)
item.DiskonAmount = parseddisc
}
if (type == 'formdiskon') {
const currdisc = item.valuediskon
const formdisc = this.parseCurrency(currdisc)
item.valuediskon = formdisc
}
if (type == 'formtax') {
const currtax = item.valuepajak
const formtax = this.parseCurrency(currtax)
item.valuepajak = formtax
}
},
handleBlur(item, type) {
switch (type) {
case 'itemprice':
const currentval = item.SupplierPrice
const parsedval = this.parseCurrency(currentval)
item.SupplierPrice = this.formatCurrency(parsedval)
break;
case 'itemdiskon':
const currentdisc = item.DiskonAmount
const parseddisc = this.parseCurrency(currentdisc)
item.DiskonAmount = this.formatCurrency(parseddisc)
break;
case 'formdiskon':
const currdisc = item.valuediskon
const formdisc = this.parseCurrency(currdisc)
item.valuediskon = this.formatCurrency(formdisc)
break;
case 'formtax':
const currtax = item.valuepajak
const formtax = this.parseCurrency(currtax)
item.valuepajak = this.formatCurrency(formtax)
break;
default:
break;
}
},
changeSupplierCabang() {
this.item_orderaset = []
this.debounceCalcForm(this.form_orderaset)
},
changeTypeTaxDiskon(type) {
let form = this.form_orderaset
switch (type) {
case 'tax':
form.valuepajak = 0
break;
case 'diskon':
form.valuediskon = 0
break;
case 'kontrak':
break;
default:
break;
}
this.calculateFormSummary(form)
},
addItemRequest() {
this.$store.dispatch('common/lookupOrderRequest', 'SR')
this.$store.commit('common/update_dialog_add_itemaset', true)
},
changeDiscountPerItem(name, item) {
switch (name) {
case 'percent':
item.DiskonType = 'P'
item.DiskonAmount = 0.00
break;
case 'absolute':
item.DiskonType = 'R'
item.DiskonAmount = 0.00
break;
default:
break;
}
this.calculateItemSummary(item)
},
calculateItemSummary(item) {
let current = JSON.parse(JSON.stringify(this.item_orderaset))
let changed = current.find(ele => ele.M_ItemCode == item.M_ItemCode)
const newqty = item.detail.reduce((sum, ele) => sum + Number(ele.RequestQty), 0)
let itemprice = this.parseCurrency(changed.SupplierPrice)
let currentdiskon = 0
if (item.DiskonType == 'R') {
currentdiskon = this.parseCurrency(changed.DiskonAmount)
}
if (item.DiskonType == 'P' && Number(changed.DiskonAmount) > 0) {
let percent = Number(changed.DiskonAmount)
currentdiskon = itemprice * percent / 100
}
changed.RequestQty = newqty
changed.EndPrice = itemprice - currentdiskon
changed.TempTotal = changed.EndPrice * changed.RequestQty
this.item_orderaset = current
/* update footer summary */
let summary = JSON.parse(JSON.stringify(this.summary_orderaset))
const subtotal = current.reduce((sum, acc) => sum + Number(acc.TempTotal), 0)
summary.subtotal = subtotal
this.summary_orderaset = summary
this.calculateFormSummary(this.form_orderaset)
},
calculateFormSummary(form) {
let summary = JSON.parse(JSON.stringify(this.summary_orderaset))
/* calculate diskon value */
let valuediskon = this.parseCurrency(form.valuediskon)
if (form.typediskon == 'percent' && valuediskon > 0) {
let percent = valuediskon
let value = (summary.subtotal * percent) / 100
summary.diskon = value
} else {
let absolute = valuediskon
summary.diskon = absolute
}
/* calculate tax value */
let valuepajak = this.parseCurrency(form.valuepajak)
if (form.typepajak == 'percent' && valuepajak > 0) {
let percent = valuepajak
let value = (summary.subtotal - summary.diskon) * percent / 100
summary.pajak = value
} else {
let absolute = valuepajak
summary.pajak = absolute
}
summary.total = (summary.subtotal - summary.diskon) + summary.pajak
this.summary_orderaset = summary
},
batalOrder() {
},
simpanOrder() {
}
},
watch: {
},
created() {
this.debounceCalcForm = _.debounce((form) => {
this.calculateFormSummary(form)
}, 500)
this.debounceCalcItem = _.debounce((item) => {
this.calculateItemSummary(item)
}, 500)
},
destroyed() {
this.debounceCalcItem = null
this.debounceCalcForm = null
},
}
</script>

View File

@@ -56,7 +56,7 @@
Rp. {{ formatCurrency(props.item.PurchaseOrderGrandTotal) }}
</td>
<td class="text-xs-center pa-2">{{ props.item.PurchaseOrderStatus }}</td>
<td class="text-xs-center pa-2">
<td class="text-xs-center pa-2" style="white-space: nowrap;">
<div v-show="props.item.PurchaseOrderStatus == 'Draft'">
<v-tooltip bottom>
<template v-slot:activator="{ on }">
@@ -114,6 +114,15 @@
</template>
<span>Detail PO</span>
</v-tooltip>
<v-tooltip bottom>
<template v-slot:activator="{ on }">
<v-btn color="primary" dark v-on="on" @click="printout(props.item)"
small style="min-width: 40px; margin: 0;">
<v-icon small>print</v-icon>
</v-btn>
</template>
<span>Cetak PDF</span>
</v-tooltip>
</div>
</td>
</tr>
@@ -133,6 +142,14 @@
<dialog-add-attchment></dialog-add-attchment>
<dialog-delete-order></dialog-delete-order>
<dialog-create-order></dialog-create-order>
<one-dialog-print
:title="printtitle"
:width="printwidth"
:height="600"
:status="openprint"
:urlprint="urlprint"
@close-dialog-print="openprint = false"
></one-dialog-print>
</div>
</template>
@@ -145,6 +162,10 @@ module.exports = {
},
data() {
return {
urlprint: "",
printtitle: "",
printwidth: "60%",
openprint: false,
menuStartdateFilter: false,
menuEnddateFilter: false,
headers: [
@@ -187,6 +208,7 @@ module.exports = {
'dialog-add-attchment': httpVueLoader('./dialog-add-attachment.vue'),
'dialog-delete-order': httpVueLoader('./dialog-delete-order.vue'),
'dialog-create-order': httpVueLoader('./dialog-create-order.vue'),
'one-dialog-print': httpVueLoader('../../common/oneDialogPrintX.vue'),
},
computed: {
snackbar: {
@@ -289,6 +311,15 @@ module.exports = {
viewDetailPO(item) {
this.$store.commit("common/update_viewonlymode", true);
this.$store.dispatch("kontrakAsset/getDetailDataPO", item.PurchaseOrderID);
},
printout(val) {
this.printwidth = "60%";
this.printtitle = "";
let user = one_user();
let username = user && user.M_StaffName ? user.M_StaffName : "";
let tm = Date.now();
this.urlprint = BASE_URL + "/one-api/report/rpt_purchase_order_asset/pdf?id=" + val.PurchaseOrderID + "&username=" + username + "&tm=" + tm;
this.openprint = true;
}
},
watch: {