add modules folder based on s_menu
This commit is contained in:
309
test/vuex/acc-one-purchase-request-direct/api/api-requester.js
Normal file
309
test/vuex/acc-one-purchase-request-direct/api/api-requester.js
Normal file
@@ -0,0 +1,309 @@
|
||||
const URL = "/one-api/mockup/purchase/requester/";
|
||||
|
||||
export async function search(payload) {
|
||||
try {
|
||||
var response = await axios.post(URL + "PurchaseRequestDirect/search", payload);
|
||||
if (response.status !== 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: response.statusText,
|
||||
};
|
||||
}
|
||||
|
||||
let data = response.data;
|
||||
return data;
|
||||
} catch (e) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export async function searchDetail(payload) {
|
||||
try {
|
||||
var response = await axios.post(
|
||||
URL + "PurchaseRequestDirect/searchDetail",
|
||||
payload
|
||||
);
|
||||
if (response.status !== 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: response.statusText,
|
||||
};
|
||||
}
|
||||
|
||||
let data = response.data;
|
||||
return data;
|
||||
} catch (e) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export async function getRegional(payload) {
|
||||
try {
|
||||
var response = await axios.post(URL + "PurchaseRequestDirect/getRegional", payload);
|
||||
if (response.status !== 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: response.statusText,
|
||||
};
|
||||
}
|
||||
|
||||
let data = response.data;
|
||||
return data;
|
||||
} catch (e) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export async function getBranch(payload) {
|
||||
try {
|
||||
var response = await axios.post(URL + "PurchaseRequestDirect/getBranch", payload);
|
||||
if (response.status !== 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: response.statusText,
|
||||
};
|
||||
}
|
||||
|
||||
let data = response.data;
|
||||
return data;
|
||||
} catch (e) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export async function saveRequest(payload) {
|
||||
try {
|
||||
var response = await axios.post(
|
||||
URL + "PurchaseRequestDirect/saveRequest",
|
||||
payload
|
||||
);
|
||||
if (response.status !== 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: response.statusText,
|
||||
};
|
||||
}
|
||||
|
||||
let data = response.data;
|
||||
return data;
|
||||
} catch (e) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export async function updateRequest(payload) {
|
||||
try {
|
||||
var response = await axios.post(
|
||||
URL + "PurchaseRequestDirect/updateRequest",
|
||||
payload
|
||||
);
|
||||
if (response.status !== 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: response.statusText,
|
||||
};
|
||||
}
|
||||
|
||||
let data = response.data;
|
||||
return data;
|
||||
} catch (e) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export async function deleteRequest(payload) {
|
||||
try {
|
||||
var response = await axios.post(
|
||||
URL + "PurchaseRequestDirect/deleteRequest",
|
||||
payload
|
||||
);
|
||||
if (response.status !== 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: response.statusText,
|
||||
};
|
||||
}
|
||||
|
||||
let data = response.data;
|
||||
return data;
|
||||
} catch (e) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export async function saveDetail(payload) {
|
||||
try {
|
||||
var response = await axios.post(
|
||||
URL + "PurchaseRequestDirect/saveDetail",
|
||||
payload
|
||||
);
|
||||
if (response.status !== 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: response.statusText,
|
||||
};
|
||||
}
|
||||
|
||||
let data = response.data;
|
||||
return data;
|
||||
} catch (e) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message,
|
||||
};
|
||||
}
|
||||
}
|
||||
export async function updateDetail(payload) {
|
||||
try {
|
||||
var response = await axios.post(
|
||||
URL + "PurchaseRequestDirect/updateDetail",
|
||||
payload
|
||||
);
|
||||
if (response.status !== 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: response.statusText,
|
||||
};
|
||||
}
|
||||
|
||||
let data = response.data;
|
||||
return data;
|
||||
} catch (e) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message,
|
||||
};
|
||||
}
|
||||
}
|
||||
export async function deleteDetail(payload) {
|
||||
try {
|
||||
var response = await axios.post(
|
||||
URL + "PurchaseRequestDirect/deleteDetail",
|
||||
payload
|
||||
);
|
||||
if (response.status !== 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: response.statusText,
|
||||
};
|
||||
}
|
||||
|
||||
let data = response.data;
|
||||
return data;
|
||||
} catch (e) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export async function orderRequest(payload) {
|
||||
try {
|
||||
var response = await axios.post(
|
||||
URL + "PurchaseRequestDirect/orderRequest",
|
||||
payload
|
||||
);
|
||||
if (response.status !== 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: response.statusText,
|
||||
};
|
||||
}
|
||||
|
||||
let data = response.data;
|
||||
return data;
|
||||
} catch (e) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export async function getUnit(token, prm) {
|
||||
try {
|
||||
var resp = await axios.post(URL + 'PurchaseRequestDirect/getUnit', {
|
||||
token: token,
|
||||
search: prm
|
||||
});
|
||||
if (resp.status != 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: resp.statusText
|
||||
};
|
||||
}
|
||||
let data = resp.data;
|
||||
return data;
|
||||
} catch (e) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export async function saveFiles(payload) {
|
||||
try {
|
||||
var response = await axios.post(
|
||||
URL + "PurchaseRequestDirect/saveFiles",
|
||||
payload
|
||||
);
|
||||
if (response.status !== 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: response.statusText,
|
||||
};
|
||||
}
|
||||
|
||||
let data = response.data;
|
||||
return data;
|
||||
} catch (e) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export async function getCategoryPD(params) {
|
||||
try {
|
||||
var response = await axios.post(URL + 'PurchaseRequestDirect/PurchaseDirectCategory', params)
|
||||
if (response.status !== 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: response.statusText
|
||||
}
|
||||
}
|
||||
|
||||
let data = response.data;
|
||||
return data
|
||||
} catch (error) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: error.message,
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,227 @@
|
||||
<template>
|
||||
<v-layout row justify-center>
|
||||
<v-dialog v-model="dialogRequest" persistent max-width="750px">
|
||||
<v-card>
|
||||
<v-card-title class="headline grey lighten-2" primary-title>
|
||||
FORM PURCHASE REQUEST
|
||||
</v-card-title>
|
||||
<v-card-text class="pt-0 pb-0">
|
||||
<v-form ref="formRequest" v-model="validationForm" lazy-validtion>
|
||||
<v-layout wrap>
|
||||
<v-flex xs12>
|
||||
<v-menu
|
||||
v-model="menuDateUse"
|
||||
:close-on-content-click="false"
|
||||
transition="scale-transition"
|
||||
:nudge-right="40"
|
||||
lazy
|
||||
offset-y
|
||||
full-width
|
||||
max-width="290px"
|
||||
min-width="290px"
|
||||
>
|
||||
<template v-slot:activator="{ on }">
|
||||
<v-text-field
|
||||
:value="dateUseFormatted"
|
||||
label="Tanggal Pelaksanaan"
|
||||
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 xs12>
|
||||
<v-autocomplete
|
||||
v-model="xRegional"
|
||||
label="Regional"
|
||||
menu-icon="mdi-chevron-down"
|
||||
:items="regionalOptions"
|
||||
item-text="S_RegionalName"
|
||||
item-value="S_RegionalID">
|
||||
</v-autocomplete>
|
||||
</v-flex>
|
||||
<v-flex xs12>
|
||||
<v-autocomplete
|
||||
v-model="xBranch"
|
||||
label="Cabang"
|
||||
menu-icon="mdi-chevron-down"
|
||||
:items="branchOptions"
|
||||
item-text="M_BranchName"
|
||||
item-value="M_BranchCode"
|
||||
:rules="branchRules"
|
||||
required
|
||||
></v-autocomplete>
|
||||
</v-flex>
|
||||
<v-flex xs12>
|
||||
<v-text-field
|
||||
v-model="xDescription"
|
||||
label="Keterangan"
|
||||
:rules="descRules"
|
||||
required
|
||||
></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="closeDialogRequest()">
|
||||
Tutup
|
||||
</v-btn>
|
||||
<v-btn
|
||||
v-if="act === 'new'"
|
||||
color="primary"
|
||||
dark
|
||||
@click="saveRequest()"
|
||||
>Simpan</v-btn
|
||||
>
|
||||
<v-btn
|
||||
v-if="act === 'edit'"
|
||||
color="primary"
|
||||
dark
|
||||
@click="updateRequest()"
|
||||
>Simpan Perubahan</v-btn
|
||||
>
|
||||
</v-card-actions>
|
||||
</v-card>
|
||||
</v-dialog>
|
||||
</v-layout>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
module.exports = {
|
||||
name: "AddPurchaseRequestDialog",
|
||||
data() {
|
||||
return {
|
||||
branchRules: [(v) => !!v || "Cabang harus diisi"],
|
||||
descRules: [(v) => !!v || "Keterangan harus diisi"],
|
||||
validationForm: false,
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
dialogRequest: {
|
||||
get() {
|
||||
return this.$store.state.requester.dialogRequest;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("requester/updateDialogRequest", val);
|
||||
},
|
||||
},
|
||||
menuDateUse: {
|
||||
get() {
|
||||
return this.$store.state.requester.menuDateUse;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("requester/updateMenuDateUse", val);
|
||||
},
|
||||
},
|
||||
dateUseFormatted() {
|
||||
return this.formatDate(this.xDateUse);
|
||||
},
|
||||
dDateUse: {
|
||||
get() {
|
||||
return this.$store.state.requester.dDateUse;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("requester/updateDDateUse", val);
|
||||
},
|
||||
},
|
||||
xDateUse: {
|
||||
get() {
|
||||
return this.$store.state.requester.xDateUse;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("requester/updateXDateUse", val);
|
||||
},
|
||||
},
|
||||
xBranch: {
|
||||
get() {
|
||||
return this.$store.state.requester.xBranch;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("requester/updateXBranch", val);
|
||||
},
|
||||
},
|
||||
branchOptions() {
|
||||
return this.$store.state.requester.branchOptions;
|
||||
},
|
||||
regionalOptions() {
|
||||
return this.$store.state.requester.regionalOptions;
|
||||
},
|
||||
xRegional: {
|
||||
get() {
|
||||
return this.$store.state.requester.xRegional;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("requester/updateXRegional", val);
|
||||
},
|
||||
},
|
||||
xDescription: {
|
||||
get() {
|
||||
return this.$store.state.requester.xDescription;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("requester/updateXDescription", val);
|
||||
},
|
||||
},
|
||||
xPRID() {
|
||||
return this.$store.state.requester.xPRID;
|
||||
},
|
||||
act() {
|
||||
return this.$store.state.requester.act;
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
formatDate(date) {
|
||||
if (!date) return null;
|
||||
|
||||
const [year, month, day] = date.split("-");
|
||||
return `${day}-${month}-${year}`;
|
||||
},
|
||||
deFormatedDate(date) {
|
||||
if (!date) return null;
|
||||
|
||||
const [day, month, year] = date.split("-");
|
||||
return `${year}-${month.padStart(2, "0")}-${day.padStart(2, "0")}`;
|
||||
},
|
||||
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/updateDialogRequest", false);
|
||||
},
|
||||
saveRequest() {
|
||||
if (this.$refs.formRequest.validate()) {
|
||||
this.$store.dispatch("requester/saveRequest", {
|
||||
PRDateUse: this.xDateUse,
|
||||
PRRegional: this.xRegional.S_RegionalID,
|
||||
PRBranch: this.xBranch.M_BranchCode,
|
||||
PRDescription: this.xDescription,
|
||||
});
|
||||
}
|
||||
},
|
||||
updateRequest() {
|
||||
if (this.$refs.formRequest.validate()) {
|
||||
this.$store.dispatch("requester/updateRequest", {
|
||||
PRID: this.xPRID,
|
||||
PRDateUse: this.xDateUse,
|
||||
PRRegional: this.xRegional.S_RegionalID,
|
||||
PRBranch: this.xBranch.M_BranchCode,
|
||||
PRDescription: this.xDescription,
|
||||
});
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
@@ -0,0 +1,350 @@
|
||||
<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
|
||||
</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-autocomplete
|
||||
label="Category" v-model="selected_category" no-filter
|
||||
:items="category_direct" item-key="PurchaseDirectCategoryCode"
|
||||
item-text="PurchaseDirectCategoryName" return-object
|
||||
></v-autocomplete>
|
||||
</v-flex>
|
||||
<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 :rules="inutRules"
|
||||
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
|
||||
prefix="Rp"
|
||||
v-model="formattedxEstimationPrice"
|
||||
required
|
||||
label="Harga">
|
||||
</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
|
||||
prefix="Rp"
|
||||
v-model="formatted_total_price"
|
||||
label="Total Harga">
|
||||
</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"],
|
||||
inutRules: [
|
||||
(v) => !!v || "Unit harus diisi",
|
||||
(v) => !!v.ItemUnitID && v.ItemUnitID !== "0" || "Unit tidak valid"
|
||||
],
|
||||
validationDetail: false,
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
this.$store.dispatch("requester/getUnit", this.search_item_unit)
|
||||
},
|
||||
computed: {
|
||||
formattedxEstimationPrice: {
|
||||
get() {
|
||||
return this.oneMoney(this.xEstimationPrice);
|
||||
},
|
||||
set(value) {
|
||||
// Hilangkan titik dan koma, ubah jadi number
|
||||
let raw = value.replace(/\./g, '').replace(',', '.');
|
||||
this.xEstimationPrice = parseFloat(raw) || 0;
|
||||
}
|
||||
},
|
||||
formatted_total_price: {
|
||||
get() {
|
||||
return this.oneMoney(this.total_price);
|
||||
},
|
||||
set(value) {
|
||||
// Hilangkan titik dan koma, ubah jadi number
|
||||
let raw = value.replace(/\./g, '').replace(',', '.');
|
||||
this.total_price = parseFloat(raw) || 0;
|
||||
}
|
||||
},
|
||||
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);
|
||||
},
|
||||
},
|
||||
category_direct() {
|
||||
return this.$store.state.requester.category_direct;
|
||||
},
|
||||
selected_category: {
|
||||
get() {
|
||||
return this.$store.state.requester.selected_category;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("requester/update_selected_category", val)
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
roundToThreeSignificantDigits(num) {
|
||||
if (num === 0) return 0;
|
||||
|
||||
// Hitung jumlah digit
|
||||
const absNum = Math.abs(num);
|
||||
const magnitude = Math.floor(Math.log10(absNum)) + 1;
|
||||
|
||||
// Jika kurang dari 3 digit, tidak perlu dibulatkan
|
||||
if (magnitude <= 3) return num;
|
||||
|
||||
// Hitung faktor pembulatan
|
||||
const factor = Math.pow(10, magnitude - 3);
|
||||
|
||||
// Bulatkan
|
||||
return Math.round(num / factor) * factor;
|
||||
},
|
||||
oneMoney(value){
|
||||
//return one_money(value);
|
||||
let splitValue = value.toString().split(".");
|
||||
if(splitValue.length > 1) {
|
||||
let val = splitValue[0]
|
||||
return val.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ".") + "," + this.roundToThreeSignificantDigits(splitValue[1]);
|
||||
} else {
|
||||
return value.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ".");
|
||||
}
|
||||
},
|
||||
convertMoney(money){
|
||||
return one_money(money)
|
||||
},
|
||||
formatAngka(nilai) {
|
||||
// Jika tidak ada nilai
|
||||
if (!nilai) return '';
|
||||
|
||||
try {
|
||||
// Ubah ke string
|
||||
let strNilai = String(nilai);
|
||||
|
||||
// Jika berisi titik desimal
|
||||
if (strNilai.includes('.')) {
|
||||
// Split bagian utama dan desimal
|
||||
let bagian = strNilai.split('.');
|
||||
let utama = bagian[0];
|
||||
let desimal = bagian[1];
|
||||
|
||||
// Format bagian utama
|
||||
utama = utama.replace(/\B(?=(\d{3})+(?!\d))/g, '.');
|
||||
|
||||
// Kembalikan gabungan
|
||||
return utama + ',' + desimal;
|
||||
} else {
|
||||
// Tidak ada desimal, hanya format bagian utama
|
||||
return strNilai.replace(/\B(?=(\d{3})+(?!\d))/g, '.');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error formatting:", error);
|
||||
return nilai;
|
||||
}
|
||||
},
|
||||
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,
|
||||
PRDCategoryID: this.selected_category.PurchaseDirectCategoryID
|
||||
});
|
||||
}
|
||||
},
|
||||
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,
|
||||
PRDCategoryID: this.selected_category.PurchaseDirectCategoryID
|
||||
});
|
||||
}
|
||||
},
|
||||
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) {
|
||||
if (val) {
|
||||
// Dialog dibuka
|
||||
this.$nextTick(() => {
|
||||
this.$refs.formDetail?.resetValidation();
|
||||
});
|
||||
}
|
||||
},
|
||||
xAmountRequest(val, old) {
|
||||
if (val <= 0) {
|
||||
this.$store.commit("requester/updateXAmountRequest", 0);
|
||||
}
|
||||
this.calculateTotalPrice();
|
||||
},
|
||||
xEstimationPrice(val, old) {
|
||||
if (val < 0) {
|
||||
this.$store.commit("requester/updateXEstimationPrice", 0);
|
||||
}
|
||||
this.calculateTotalPrice();
|
||||
},
|
||||
search_item_unit(val, old) {
|
||||
if (val == old) return;
|
||||
if (!val) return;
|
||||
if (val.length < 1) return;
|
||||
if (this.$store.state.requester.loadingAutocomplete == 1) return;
|
||||
this.thr_search_item_unit();
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
@@ -0,0 +1,376 @@
|
||||
<template>
|
||||
<v-dialog v-model="dialogDetail" persistent max-width="500px">
|
||||
<v-card>
|
||||
<v-card-title class="headline grey lighten-2" primary-title>
|
||||
FORM REQUEST DETAIL
|
||||
</v-card-title>
|
||||
|
||||
<v-card-text>
|
||||
<v-form ref="form_detail" v-model="form_detail_valid" lazy-validation>
|
||||
<v-layout column>
|
||||
<v-flex>
|
||||
<v-autocomplete
|
||||
v-model="selected_category" return-object label="Kategori"
|
||||
:items="category_direct" item-text="PurchaseDirectCategoryName"
|
||||
item-key="PurchaseDirectCategoryCode" :rules="autocomp_rules"
|
||||
@input="resetCalc()"
|
||||
></v-autocomplete>
|
||||
</v-flex>
|
||||
<v-flex>
|
||||
<v-text-field
|
||||
v-model="xDescriptionDetail" required
|
||||
:rules="freetext_rules" label="Deskripsi"
|
||||
:disabled="isCategorySelected()"
|
||||
></v-text-field>
|
||||
</v-flex>
|
||||
<v-flex>
|
||||
<v-text-field
|
||||
v-model="formatted_amount" required
|
||||
:min="1" :rules="freetext_rules" label="Jumlah"
|
||||
:disabled="isCategorySelected()" @blur="viewBlurAmount"
|
||||
:readonly="this.selected_category.PurchaseDirectCategoryName == 'BBM'"
|
||||
></v-text-field>
|
||||
</v-flex>
|
||||
<v-flex>
|
||||
<v-autocomplete
|
||||
label="Unit Item" v-model="selected_item_unit"
|
||||
:items="item_units" item-text="ItemUnitName"
|
||||
:rules="autocomp_rules" return-object
|
||||
:disabled="isCategorySelected()"
|
||||
></v-autocomplete>
|
||||
</v-flex>
|
||||
<v-flex>
|
||||
<v-text-field
|
||||
prefix="Rp." required label="Harga"
|
||||
v-model="formatted_estimate_price"
|
||||
:disabled="isCategorySelected()"
|
||||
@blur="viewBlurMoney" @focus="viewFokusNumber"
|
||||
></v-text-field>
|
||||
</v-flex>
|
||||
<v-flex>
|
||||
<v-text-field
|
||||
prefix="Rp." v-model="formatted_total_price"
|
||||
:disabled="isCategorySelected()" label="Total Harga"
|
||||
:readonly="this.selected_category.PurchaseDirectCategoryName != 'BBM'"
|
||||
@blur="viewBlurMoney" @focus="viewFokusNumber"
|
||||
></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="closeForm()">Tutup</v-btn>
|
||||
<v-btn v-if="this.act === 'new'" color="primary" dark @click="simpanForm()">Simpan</v-btn>
|
||||
<v-btn v-else color="primary" dark @click="updateForm()">Simpan</v-btn>
|
||||
</v-card-actions>
|
||||
</v-card>
|
||||
</v-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
module.exports = {
|
||||
data() {
|
||||
return {
|
||||
form_detail_valid: true,
|
||||
amount_input: 0,
|
||||
price_input: 0,
|
||||
total_input: 0,
|
||||
freetext_rules: [v => !!v || "Tidak boleh kosong"],
|
||||
autocomp_rules: [v => (v && Object.keys(v).length > 0) || 'Tidak boleh kosong'],
|
||||
amount_rules: [v => (v && v >= 0) || "Jumlah tidak sesuai"]
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
dialogDetail: {
|
||||
get() {
|
||||
return this.$store.state.requester.dialogDetail
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("requester/updateDialogDetail", val)
|
||||
}
|
||||
},
|
||||
selected_category: {
|
||||
get() {
|
||||
return this.$store.state.requester.selected_category;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("requester/update_selected_category", val)
|
||||
}
|
||||
},
|
||||
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", Number(val));
|
||||
},
|
||||
},
|
||||
formatted_amount: {
|
||||
get() {
|
||||
return this.amount_input;
|
||||
},
|
||||
set(value) {
|
||||
let raw = value.replace(/\./g, '').replace(',', '.');
|
||||
this.xAmountRequest = parseFloat(raw) || 0;
|
||||
}
|
||||
},
|
||||
selected_item_unit: {
|
||||
get() {
|
||||
return this.$store.state.requester.selected_item_unit;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("requester/updateSelectedItemUnit", val);
|
||||
},
|
||||
},
|
||||
xEstimationPrice: {
|
||||
get() {
|
||||
return this.$store.state.requester.xEstimationPrice;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("requester/updateXEstimationPrice", val);
|
||||
},
|
||||
},
|
||||
formatted_estimate_price: {
|
||||
get() {
|
||||
return this.price_input;
|
||||
},
|
||||
set(value) {
|
||||
let raw = value.replace(/\./g, '').replace(',', '.');
|
||||
this.xEstimationPrice = parseFloat(raw) || 0;
|
||||
}
|
||||
},
|
||||
total_price: {
|
||||
get() {
|
||||
return this.$store.state.requester.total_price;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("requester/updateTotalPrice", val)
|
||||
}
|
||||
},
|
||||
formatted_total_price: {
|
||||
get() {
|
||||
return this.total_input;
|
||||
},
|
||||
set(value) {
|
||||
// Hilangkan titik dan koma, ubah jadi number
|
||||
let raw = value.replace(/\./g, '').replace(',', '.');
|
||||
this.total_price = parseFloat(raw) || 0;
|
||||
}
|
||||
},
|
||||
category_direct() {
|
||||
return this.$store.state.requester.category_direct;
|
||||
},
|
||||
item_units() {
|
||||
return this.$store.state.requester.item_units;
|
||||
},
|
||||
selectedMainTable() {
|
||||
return this.$store.state.requester.selectedMainTable;
|
||||
},
|
||||
selectedDetailTable() {
|
||||
return this.$store.state.requester.selectedDetailTable;
|
||||
},
|
||||
act() {
|
||||
return this.$store.state.requester.act;
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
roundToThreeSignificantDigits(digit) {
|
||||
// if (num === 0) return 0;
|
||||
|
||||
// const absNum = Math.abs(num);
|
||||
// const magnitude = Math.floor(Math.log10(absNum)) + 1;
|
||||
// if (magnitude <= 3) return num;
|
||||
// const factor = Math.pow(10, magnitude - 3);
|
||||
// return Math.round(num / factor) * factor;
|
||||
|
||||
const num = parseInt(digit, 10)
|
||||
if (isNaN(num) || num <= 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
const scale = 10 ** digit.length;
|
||||
const decimal = num / scale
|
||||
return Math.round(decimal * 100);
|
||||
},
|
||||
oneMoney(value) {
|
||||
let splitValue = value.toString().split(".");
|
||||
|
||||
if(splitValue.length > 1) {
|
||||
let val = splitValue[0]
|
||||
return val.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ".") + "," + this.roundToThreeSignificantDigits(splitValue[1]);
|
||||
} else {
|
||||
return value.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ".");
|
||||
}
|
||||
},
|
||||
viewBlurMoney() {
|
||||
let category = this.selected_category
|
||||
if (category.PurchaseDirectCategoryName == 'BBM') {
|
||||
let total = this.total_price
|
||||
if (total % 1 === 0) {
|
||||
total = this.oneMoney(total) + ",00"
|
||||
this.total_input = total
|
||||
} else {
|
||||
this.total_input = this.oneMoney(this.total_price)
|
||||
}
|
||||
|
||||
let price = this.xEstimationPrice
|
||||
if (price % 1 === 0) {
|
||||
price = this.oneMoney(price) + ",00"
|
||||
this.price_input = price
|
||||
} else {
|
||||
this.price_input = this.oneMoney(this.xEstimationPrice)
|
||||
}
|
||||
|
||||
} else {
|
||||
this.price_input = this.oneMoney(this.xEstimationPrice)
|
||||
this.total_input = this.oneMoney(this.total_price)
|
||||
}
|
||||
},
|
||||
viewFokusNumber() {
|
||||
let price = this.xEstimationPrice ?? 0;
|
||||
let total = this.total_price ?? 0;
|
||||
|
||||
this.price_input = price.toString().replace('.', ',');
|
||||
this.total_input = total.toString().replace('.', ',');
|
||||
},
|
||||
viewBlurAmount() {
|
||||
let category = this.selected_category
|
||||
if (category.PurchaseDirectCategoryName == 'BBM') {
|
||||
let amount = this.xAmountRequest
|
||||
if (amount % 1 === 0) {
|
||||
this.amount_input = amount
|
||||
} else {
|
||||
this.amount_input = this.oneMoney(amount)
|
||||
}
|
||||
} else {
|
||||
this.amount_input = this.xAmountRequest
|
||||
}
|
||||
},
|
||||
calculateTotalPrice() {
|
||||
let category = this.selected_category
|
||||
let jumlah = this.xAmountRequest
|
||||
let total = this.total_price
|
||||
let price = this.xEstimationPrice
|
||||
|
||||
if (category.PurchaseDirectCategoryName === 'BBM') {
|
||||
if (total > 0 && price > 0) {
|
||||
let a = total / price
|
||||
this.xAmountRequest = a
|
||||
this.amount_input = this.oneMoney(a)
|
||||
return
|
||||
}
|
||||
this.xAmountRequest = 0
|
||||
this.amount_input = this.oneMoney(0)
|
||||
|
||||
} else {
|
||||
if (jumlah > 0 && price > 0) {
|
||||
let a = jumlah * price
|
||||
this.total_price = a
|
||||
return
|
||||
}
|
||||
this.total_price = 0
|
||||
}
|
||||
},
|
||||
isCategorySelected() {
|
||||
let category = this.selected_category
|
||||
if (Object.keys(category).length > 0) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
},
|
||||
resetCalc() {
|
||||
this.xDescriptionDetail = ''
|
||||
this.xAmountRequest = 0
|
||||
this.amount_input = 0
|
||||
this.selected_item_unit = {}
|
||||
|
||||
this.xEstimationPrice = 0
|
||||
this.price_input = 0
|
||||
this.total_price = 0
|
||||
this.total_input = 0
|
||||
|
||||
this.$refs.form_detail.resetValidation()
|
||||
},
|
||||
resetForm() {
|
||||
this.selected_category = {}
|
||||
this.selected_item_unit = {}
|
||||
this.xDescriptionDetail = ''
|
||||
this.xAmountRequest = 0
|
||||
this.xEstimationPrice = 0
|
||||
this.total_price = 0
|
||||
|
||||
this.amount_input = 0
|
||||
this.price_input = 0
|
||||
this.total_input = 0
|
||||
|
||||
this.$refs.form_detail.resetValidation()
|
||||
},
|
||||
closeForm() {
|
||||
this.resetForm()
|
||||
this.dialogDetail = false
|
||||
},
|
||||
simpanForm() {
|
||||
if (this.$refs.form_detail.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,
|
||||
PRDCategoryID: this.selected_category.PurchaseDirectCategoryID,
|
||||
PRDTotalPrice: this.total_price
|
||||
});
|
||||
}
|
||||
},
|
||||
updateForm() {
|
||||
if (this.$refs.form_detail.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,
|
||||
PRDCategoryID: this.selected_category.PurchaseDirectCategoryID,
|
||||
PRDTotalPrice: this.total_price
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
dialogDetail(val) {
|
||||
if (val) {
|
||||
this.$nextTick(() => {
|
||||
this.$refs.form_detail?.resetValidation()
|
||||
if (this.act == 'new') {
|
||||
this.resetForm()
|
||||
} else {
|
||||
this.price_input = this.oneMoney(this.xEstimationPrice)
|
||||
this.total_input = this.oneMoney(this.total_price)
|
||||
this.amount_input = this.oneMoney(this.xAmountRequest)
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
xAmountRequest(val, old) {
|
||||
this.calculateTotalPrice()
|
||||
},
|
||||
xEstimationPrice(val, old) {
|
||||
this.calculateTotalPrice()
|
||||
},
|
||||
total_price(val, old) {
|
||||
this.calculateTotalPrice()
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,155 @@
|
||||
<template>
|
||||
<v-layout row justify-center>
|
||||
<v-dialog v-model="dialogForm" persistent max-width="60vw">
|
||||
<v-card>
|
||||
<v-card-title class="headline grey lighten-2" primary-title>
|
||||
FORM BUKTI PEMBAYARAN
|
||||
</v-card-title>
|
||||
<v-card-text class="pt-2 pb-0">
|
||||
<v-layout v-if="actAttach == 'upload'" mr-2 ml-2 style="border:1px solid black" align-center row pa-2 mb-2>
|
||||
<v-flex xs9>
|
||||
<input type="file" id="files" ref="files" accept="image/*" multiple v-on:change="handleFileUploads()"/>
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
<p v-show="cekFile" class="error pl-2 pr-2" style="color:#fff">Belum diisi</p>
|
||||
<v-layout v-if="show_progrees_upload" row align-center mr-2 ml-2>
|
||||
<v-flex xs12>
|
||||
|
||||
<v-progress-linear :indeterminate="true"></v-progress-linear>
|
||||
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
<v-layout v-if="imagePreviews.length > 0 && !show_progrees_upload" align-center row wrap>
|
||||
<v-flex
|
||||
v-for="(img, index) in imagePreviews"
|
||||
:key="index"
|
||||
xs6
|
||||
class="pa-2"
|
||||
>
|
||||
<v-img :src="img">
|
||||
<div class="fill-height bottom-gradient"></div>
|
||||
</v-img>
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
</v-card-text>
|
||||
<v-divider></v-divider>
|
||||
<v-card-actions>
|
||||
<v-spacer></v-spacer>
|
||||
<v-btn color="error" flat @click="closeDiallog()"> Tutup </v-btn>
|
||||
<v-btn color="primary" v-if="actAttach == 'upload'" dark @click="saveForm()">Simpan</v-btn>
|
||||
</v-card-actions>
|
||||
</v-card>
|
||||
</v-dialog>
|
||||
</v-layout>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
module.exports = {
|
||||
name: "formDialogAttachtment",
|
||||
data() {
|
||||
return {
|
||||
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
|
||||
},
|
||||
computed: {
|
||||
dialogForm: {
|
||||
get() {
|
||||
return this.$store.state.requester.dialog_form;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("requester/update_dialog_form", val);
|
||||
},
|
||||
},
|
||||
show_progrees_upload: {
|
||||
get() {
|
||||
return this.$store.state.requester.show_progrees_upload
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("requester/update_show_progrees_upload", val)
|
||||
}
|
||||
},
|
||||
imageFiles: {
|
||||
get() {
|
||||
return this.$store.state.requester.imageFiles
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("requester/update_imageFiles", val)
|
||||
}
|
||||
},
|
||||
imagePreviews: {
|
||||
get() {
|
||||
return this.$store.state.requester.imagePreviews
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("requester/update_imagePreviews", val)
|
||||
}
|
||||
},
|
||||
cekFile: {
|
||||
get() {
|
||||
return this.$store.state.requester.cekFile;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("requester/update_cekFile", val);
|
||||
},
|
||||
},
|
||||
actAttach: {
|
||||
get() {
|
||||
return this.$store.state.requester.actAttach;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("requester/update_actAttach", val);
|
||||
},
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
closeDiallog() {
|
||||
this.$store.commit("requester/update_dialog_form", false);
|
||||
},
|
||||
handleFileUploads(){
|
||||
// this.files = this.$refs.files.files
|
||||
|
||||
const files = this.$refs.files.files;
|
||||
this.imagePreviews = [];
|
||||
this.imageFiles = [];
|
||||
for (let i = 0; i < files.length; i++) {
|
||||
const file = files[i];
|
||||
const url = URL.createObjectURL(file);
|
||||
this.imagePreviews.push(url);
|
||||
this.imageFiles.push(file);
|
||||
}
|
||||
// console.log('imagePreviews', this.imagePreviews)
|
||||
// console.log('imageFiles', this.imageFiles)
|
||||
},
|
||||
saveForm() {
|
||||
var formData = new FormData()
|
||||
console.log("formData",this.imageFiles.length)
|
||||
|
||||
for( var i = 0; i < this.imageFiles.length; i++ ){
|
||||
let file = this.imageFiles[i]
|
||||
|
||||
formData.append('files[' + i + ']', file)
|
||||
// console.log("formData",formData)
|
||||
}
|
||||
|
||||
var user = one_user()
|
||||
formData.append('PRDID', this.$store.state.requester.selectedDetailTable.PurchaseRequestDirectDetailID)
|
||||
formData.append('PRID', this.$store.state.requester.selectedMainTable.PurchaseRequestDirectID)
|
||||
formData.append('directNumber', this.$store.state.requester.selectedMainTable.PurchaseRequestDirectNumber)
|
||||
formData.append('userId', user.M_UserID)
|
||||
|
||||
// console.log('prpd', this.$store.state.requester.selectedDetailTable.PurchaseRequestDirectDetailID)
|
||||
// console.log('prm', formData)
|
||||
this.$store.dispatch('requester/saveFiles', formData)
|
||||
//this.submitFiles();
|
||||
|
||||
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
|
||||
},
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,80 @@
|
||||
<template>
|
||||
|
||||
<v-dialog
|
||||
v-model="dialog"
|
||||
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>
|
||||
{{xmsg}}
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
</v-card-text>
|
||||
<v-divider></v-divider>
|
||||
<v-card-actions>
|
||||
<v-btn
|
||||
color="error"
|
||||
flat
|
||||
@click="forgetAlert()"
|
||||
>
|
||||
Abaikan
|
||||
</v-btn>
|
||||
<v-spacer></v-spacer>
|
||||
<v-btn
|
||||
color="primary"
|
||||
flat
|
||||
@click="closeAlert()"
|
||||
>
|
||||
OK
|
||||
</v-btn>
|
||||
</v-card-actions>
|
||||
</v-card>
|
||||
</v-dialog>
|
||||
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
</style>
|
||||
|
||||
<script>
|
||||
module.exports = {
|
||||
props : ['status', 'msg'],
|
||||
computed : {
|
||||
xmsg() {
|
||||
return this.msg
|
||||
},
|
||||
dialog: {
|
||||
get() {
|
||||
return this.status
|
||||
},
|
||||
set(val) {
|
||||
this.$emit('close-dialog-alert')
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
closeAlert() {
|
||||
this.$emit('close-dialog-alert')
|
||||
},
|
||||
forgetAlert() {
|
||||
this.$emit('forget-dialog-alert')
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
File diff suppressed because it is too large
Load Diff
67
test/vuex/acc-one-purchase-request-direct/index.php
Normal file
67
test/vuex/acc-one-purchase-request-direct/index.php
Normal file
@@ -0,0 +1,67 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<link rel="stylesheet" href="../../../libs/vendor/css/google-fonts.css">
|
||||
<link rel="stylesheet" href="../../../libs/vendor/css/icomoon-fonts.css">
|
||||
<link rel="stylesheet" href="../../../libs/vendor/css/vuetify.min.css">
|
||||
<title>One</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div v-cloak id="app">
|
||||
<v-app id="smartApp">
|
||||
<one-navbar></one-navbar>
|
||||
<v-content style="background: #F5E8DF!important">
|
||||
<v-container fluid fill-height class="pl-1 pr-1 pt-2 pb-2">
|
||||
<v-layout row wrap>
|
||||
<v-flex xs12 class="left" fill-height pa-1>
|
||||
<request-listing></request-listing>
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
</v-container>
|
||||
</v-content>
|
||||
<one-footer></one-footer>
|
||||
</v-app>
|
||||
</div>
|
||||
|
||||
<!-- Vendor -->
|
||||
<script src="../../../libs/vendor/moment.min.js"></script>
|
||||
<script src="../../../libs/vendor/numeral.min.js"></script>
|
||||
<script src="../../../libs/vendor/moment-locale-id.js"></script>
|
||||
<script src="../../../libs/vendor/lodash.js"></script>
|
||||
<script src="../../../libs/vendor/axios.min.js"></script>
|
||||
<script src="../../../libs/vendor/vue.js"></script>
|
||||
<script src="../../../libs/vendor/vuex.js"></script>
|
||||
<script src="../../../libs/vendor/vuetify.js"></script>
|
||||
<script src="../../../libs/vendor/httpVueLoader.js"></script>
|
||||
<script src="../../../libs/one_global.js"></script>
|
||||
|
||||
<!-- App Script -->
|
||||
<script type="module">
|
||||
import {
|
||||
store
|
||||
} from './store.js';
|
||||
window.store = store;
|
||||
new Vue({
|
||||
store,
|
||||
el: "#app",
|
||||
methods: {},
|
||||
components: {
|
||||
'one-navbar': httpVueLoader('../../../apps/components/oneNavbarComponent.vue'),
|
||||
'one-footer': httpVueLoader('../../../apps/components/oneFooter.vue'),
|
||||
'request-listing': httpVueLoader('./components/requestListing.vue')
|
||||
}
|
||||
})
|
||||
</script>
|
||||
<style>
|
||||
[v-cloak] {
|
||||
display: none
|
||||
}
|
||||
</style>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
655
test/vuex/acc-one-purchase-request-direct/modules/requester.js
Normal file
655
test/vuex/acc-one-purchase-request-direct/modules/requester.js
Normal file
@@ -0,0 +1,655 @@
|
||||
// 1 => LOADING
|
||||
// 2 => DONE
|
||||
// 3 => ERROR
|
||||
|
||||
import * as api from "../api/api-requester.js";
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {
|
||||
mainTable: [],
|
||||
detailTable: [],
|
||||
countMainTable: 0,
|
||||
countDetailTable: 0,
|
||||
mainTableLoadingStatus: 0,
|
||||
detailTableLoadingStatus: 0,
|
||||
mainTableErrorMessage: "",
|
||||
detailTableErrorMessage: "",
|
||||
mainTableCurrentPage: 1,
|
||||
mainTableLastId: -1,
|
||||
|
||||
selectedMainTable: {},
|
||||
selectedDetailTable: {},
|
||||
|
||||
statusOptions: [
|
||||
{ value: 0, title: "All" },
|
||||
{ value: 1, title: "Draft" },
|
||||
{ value: 2, title: "Pending" },
|
||||
{ value: 3, title: "Approved" },
|
||||
{ value: 4, title: "Rejected" },
|
||||
{ value: 5, title: "Paid" },
|
||||
{ value: 6, title: "Completed" },
|
||||
],
|
||||
branchOptions: [],
|
||||
regionalOptions: [],
|
||||
|
||||
menuStartDate: false,
|
||||
menuEndDate: false,
|
||||
menuDateUse: false,
|
||||
|
||||
dStartDate: new Date().toISOString().substring(0, 10),
|
||||
dEndDate: new Date().toISOString().substring(0, 10),
|
||||
fStartDate: moment(new Date()).format("YYYY-MM-DD"),
|
||||
fEndDate: moment(new Date()).format("YYYY-MM-DD"),
|
||||
fStatus: 0,
|
||||
fSearch: "",
|
||||
|
||||
dDateUse: new Date().toISOString().substring(0, 10),
|
||||
xDateUse: moment(new Date()).format("YYYY-MM-DD"),
|
||||
xRegional: "",
|
||||
xBranch: "",
|
||||
xDescription: "",
|
||||
xPRID: 0,
|
||||
xNumber: "",
|
||||
xPRDID: 0,
|
||||
xDescriptionDetail: "",
|
||||
xAmountRequest: 0,
|
||||
xEstimationPrice: 0,
|
||||
|
||||
dialogRequest: false,
|
||||
dialogDetail: false,
|
||||
act: "new",
|
||||
errMessage: "",
|
||||
successMessage: "",
|
||||
alertError: false,
|
||||
alertSuccess: false,
|
||||
errors: [],
|
||||
total_price: 0,
|
||||
item_units: [],
|
||||
selected_item_unit: {},
|
||||
search_item_unit: "",
|
||||
loadingAutocomplete: false,
|
||||
dialog_form: false,
|
||||
show_progrees_upload: false,
|
||||
imageFiles: [],
|
||||
imagePreviews: [],
|
||||
cekFile: false,
|
||||
actAttach: "",
|
||||
|
||||
category_direct: [],
|
||||
selected_category: {}
|
||||
},
|
||||
mutations: {
|
||||
updateMainTable(state, val) {
|
||||
state.mainTable = val;
|
||||
},
|
||||
updateDetailTable(state, val) {
|
||||
state.detailTable = val;
|
||||
},
|
||||
updateCountMainTable(state, val) {
|
||||
state.countMainTable = val;
|
||||
},
|
||||
updateCountDetailTable(state, val) {
|
||||
state.countDetailTable = val;
|
||||
},
|
||||
updateMainTableLoadingStatus(state, val) {
|
||||
state.mainTableLoadingStatus = val;
|
||||
},
|
||||
updateDetailTableLoadingStatus(state, val) {
|
||||
state.detailTableLoadingStatus = val;
|
||||
},
|
||||
updateMainTableErrorMessage(state, val) {
|
||||
state.mainTableErrorMessage = val;
|
||||
},
|
||||
updateDetailTableErrorMessage(state, val) {
|
||||
state.detailTableErrorMessage = val;
|
||||
},
|
||||
updateMainTableCurrentPage(state, val) {
|
||||
state.mainTableCurrentPage = val;
|
||||
},
|
||||
updateMainTableLastId(state, val) {
|
||||
state.mainTableLastId = val;
|
||||
},
|
||||
|
||||
updateSelectedMainTable(state, val) {
|
||||
state.selectedMainTable = val;
|
||||
},
|
||||
updateSelectedDetailTable(state, val) {
|
||||
state.selectedDetailTable = val;
|
||||
},
|
||||
|
||||
updateBranchOptions(state, val) {
|
||||
state.branchOptions = val;
|
||||
},
|
||||
|
||||
updateRegionalOptions(state, val) {
|
||||
state.regionalOptions = val;
|
||||
},
|
||||
|
||||
updateMenuStartDate(state, val) {
|
||||
state.menuStartDate = val;
|
||||
},
|
||||
updateMenuEndDate(state, val) {
|
||||
state.menuEndDate = val;
|
||||
},
|
||||
updateMenuDateUse(state, val) {
|
||||
state.menuDateUse = val;
|
||||
},
|
||||
|
||||
updateDStartDate(state, val) {
|
||||
state.dStartDate = val;
|
||||
},
|
||||
updateDEndDate(state, val) {
|
||||
state.dEndDate = val;
|
||||
},
|
||||
updateFStartDate(state, val) {
|
||||
state.fStartDate = val;
|
||||
},
|
||||
updateFEndDate(state, val) {
|
||||
state.fEndDate = val;
|
||||
},
|
||||
updateFStatus(state, val) {
|
||||
state.fStatus = val;
|
||||
},
|
||||
updateFSearch(state, val) {
|
||||
state.fSearch = val;
|
||||
},
|
||||
|
||||
updateDDateUse(state, val) {
|
||||
state.dDateUse = val;
|
||||
},
|
||||
updateXDateUse(state, val) {
|
||||
state.xDateUse = val;
|
||||
},
|
||||
updateXRegional(state, val) {
|
||||
state.xRegional = val;
|
||||
},
|
||||
updateXBranch(state, val) {
|
||||
state.xBranch = val;
|
||||
},
|
||||
updateXDescription(state, val) {
|
||||
state.xDescription = val;
|
||||
},
|
||||
updateXPRID(state, val) {
|
||||
state.xPRID = val;
|
||||
},
|
||||
updateXNumber(state, val) {
|
||||
state.xNumber = val;
|
||||
},
|
||||
updateXPRDID(state, val) {
|
||||
state.xPRDID = val;
|
||||
},
|
||||
updateXDescriptionDetail(state, val) {
|
||||
state.xDescriptionDetail = val;
|
||||
},
|
||||
updateXAmountRequest(state, val) {
|
||||
state.xAmountRequest = val;
|
||||
},
|
||||
updateXEstimationPrice(state, val) {
|
||||
state.xEstimationPrice = val;
|
||||
},
|
||||
|
||||
updateDialogRequest(state, val) {
|
||||
state.dialogRequest = val;
|
||||
},
|
||||
updateDialogDetail(state, val) {
|
||||
state.dialogDetail = val;
|
||||
},
|
||||
updateAct(state, val) {
|
||||
state.act = val;
|
||||
},
|
||||
updateErrMessage(state, val) {
|
||||
state.errMessage = val;
|
||||
},
|
||||
updateSuccessMessage(state, val) {
|
||||
state.successMessage = val;
|
||||
},
|
||||
updateAlertError(state, val) {
|
||||
state.alertError = val;
|
||||
},
|
||||
updateAlertSuccess(state, val) {
|
||||
state.alertSuccess = val;
|
||||
},
|
||||
updateErrors(state, val) {
|
||||
state.errors = val;
|
||||
},
|
||||
updateTotalPrice(state, val) {
|
||||
state.total_price = val;
|
||||
},
|
||||
updateItemUnits(state, val) {
|
||||
state.item_units = val;
|
||||
},
|
||||
updateSelectedItemUnit(state, val) {
|
||||
state.selected_item_unit = val;
|
||||
},
|
||||
updateSearchItemUnit(state, val) {
|
||||
state.search_item_unit = val;
|
||||
},
|
||||
updateLoadingAutocomplete(state, val) {
|
||||
state.loadingAutocomplete = val;
|
||||
},
|
||||
update_dialog_form(state, val) {
|
||||
state.dialog_form = val;
|
||||
},
|
||||
update_show_progrees_upload(state, val) {
|
||||
state.show_progrees_upload = val
|
||||
},
|
||||
update_imageFiles(state, val) {
|
||||
state.imageFiles = val
|
||||
},
|
||||
update_imagePreviews(state, val) {
|
||||
state.imagePreviews = val
|
||||
},
|
||||
update_cekFile(state, val) {
|
||||
state.cekFile = val
|
||||
},
|
||||
update_actAttach(state, val) {
|
||||
state.actAttach = val
|
||||
},
|
||||
update_category_direct(state, val) {
|
||||
state.category_direct = val
|
||||
},
|
||||
update_selected_category(state, val) {
|
||||
state.selected_category = val
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
async getCategoryPD(context) {
|
||||
context.commit("updateDetailTableLoadingStatus", 1);
|
||||
try {
|
||||
var params = {
|
||||
token: one_token(),
|
||||
name: ''
|
||||
}
|
||||
|
||||
let resp = await api.getCategoryPD(params)
|
||||
if (resp.status != 'OK') {
|
||||
context.commit("updateDetailTableLoadingStatus", 3);
|
||||
context.commit("updateDetailTableErrorMessage", resp.message);
|
||||
} else {
|
||||
context.commit("updateDetailTableLoadingStatus", 2);
|
||||
context.commit("update_category_direct", resp.data)
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
context.commit("updateDetailTableLoadingStatus", 3);
|
||||
context.commit("updateDetailTableErrorMessage", error.message);
|
||||
}
|
||||
},
|
||||
async search(context) {
|
||||
context.commit("updateMainTableLoadingStatus", 1);
|
||||
|
||||
try {
|
||||
var url_string = window.location.href
|
||||
var url = new URL(url_string);
|
||||
var xdate = url.searchParams.get("date");
|
||||
var xsearch = url.searchParams.get("search");
|
||||
|
||||
if (xsearch) {
|
||||
context.commit("updateFSearch", xsearch);
|
||||
}
|
||||
if (xdate) {
|
||||
context.commit("updateFStartDate", xdate);
|
||||
context.commit("updateFEndDate", xdate);
|
||||
}
|
||||
|
||||
var payload = {
|
||||
token: one_token(),
|
||||
currentPage: context.state.mainTableCurrentPage,
|
||||
startDate: context.state.fStartDate,
|
||||
endDate: context.state.fEndDate,
|
||||
status: context.state.fStatus,
|
||||
search: context.state.fSearch,
|
||||
lastId: -1,
|
||||
};
|
||||
|
||||
let response = await api.search(payload);
|
||||
if (response.status != "OK") {
|
||||
context.commit("updateMainTableLoadingStatus", 3);
|
||||
context.commit("updateMainTableErrorMessage", response.message);
|
||||
} else {
|
||||
context.commit("updateMainTableLoadingStatus", 2);
|
||||
context.commit("updateMainTableErrorMessage", "");
|
||||
let data = {
|
||||
records: response.data.records,
|
||||
total: response.data.total,
|
||||
};
|
||||
|
||||
context.commit("updateMainTable", data.records);
|
||||
context.commit("updateCountMainTable", data.total);
|
||||
context.dispatch("system/getlistnotif", null, { root: true })
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("updateMainTableLoadingStatus", 3);
|
||||
context.commit("updateMainTableErrorMessage", e.message);
|
||||
}
|
||||
},
|
||||
async searchDetail(context) {
|
||||
context.commit("updateDetailTableLoadingStatus", 1);
|
||||
|
||||
try {
|
||||
var payload = {
|
||||
token: one_token(),
|
||||
PRID: context.state.selectedMainTable.PurchaseRequestDirectID,
|
||||
};
|
||||
|
||||
let response = await api.searchDetail(payload);
|
||||
if (response.status != "OK") {
|
||||
context.commit("updateDetailTableLoadingStatus", 3);
|
||||
context.commit("updateDetailTableErrorMessage", response.message);
|
||||
} else {
|
||||
context.commit("updateDetailTableLoadingStatus", 2);
|
||||
context.commit("updateDetailTableErrorMessage", "");
|
||||
let data = {
|
||||
records: response.data.records,
|
||||
total: response.data.total,
|
||||
};
|
||||
|
||||
context.commit("updateDetailTable", data.records);
|
||||
context.commit("updateCountDetailTable", data.total);
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("updateDetailTableLoadingStatus", 3);
|
||||
context.commit("updateDetailTableErrorMessage", e.message);
|
||||
}
|
||||
},
|
||||
async regional(context) {
|
||||
let response = await api.getRegional({ token: one_token() });
|
||||
if (response.status === "OK") {
|
||||
let data = {
|
||||
records: response.data.records,
|
||||
};
|
||||
|
||||
context.commit("updateRegionalOptions", data.records);
|
||||
}
|
||||
},
|
||||
async branch(context) {
|
||||
let response = await api.getBranch({ token: one_token() });
|
||||
if (response.status === "OK") {
|
||||
let data = {
|
||||
records: response.data.records,
|
||||
};
|
||||
|
||||
context.commit("updateBranchOptions", data.records);
|
||||
}
|
||||
},
|
||||
async saveRequest(context, payload) {
|
||||
try {
|
||||
payload.token = one_token();
|
||||
|
||||
let response = await api.saveRequest(payload);
|
||||
if (response.status !== "OK") {
|
||||
context.commit("updateErrMessage", response.message);
|
||||
} else {
|
||||
context.commit("updateErrMessage", "");
|
||||
let data = {
|
||||
records: response.data.records,
|
||||
total: response.data.total,
|
||||
};
|
||||
|
||||
if (data.total !== -1) {
|
||||
context.commit("updateErrors", []);
|
||||
context.commit("updateAlertSuccess", true);
|
||||
context.commit("updateDialogRequest", false);
|
||||
var msg = `Purchase Request baru dengan kode ${data.records[0].PurchaseRequestDirectNumber} sudah tersimpan`;
|
||||
context.commit("updateSuccessMessage", msg);
|
||||
context.dispatch("search");
|
||||
context.commit("updateSelectedMainTable", data.records[0]);
|
||||
context.dispatch("searchDetail");
|
||||
} else {
|
||||
context.commit("updateErrors", response.data.errors);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("updateErrMessage", e.message);
|
||||
context.commit("updateAlertError", true);
|
||||
}
|
||||
},
|
||||
async updateRequest(context, payload) {
|
||||
try {
|
||||
payload.token = one_token();
|
||||
|
||||
let response = await api.updateRequest(payload);
|
||||
if (response.status !== "OK") {
|
||||
context.commit("updateErrMessage", response.message);
|
||||
context.commit("updateAlertError", true);
|
||||
} else {
|
||||
context.commit("updateErrMessage", "");
|
||||
let data = {
|
||||
records: response.data.records,
|
||||
total: response.data.total,
|
||||
};
|
||||
|
||||
if (data.total !== -1) {
|
||||
context.commit("updateErrors", []);
|
||||
context.commit("updateAlertSuccess", true);
|
||||
context.commit("updateDialogRequest", false);
|
||||
var msg = `Perubahan Purchase Request dengan kode ${data.records[0].PurchaseRequestDirectNumber} sudah tersimpan`;
|
||||
context.commit("updateSuccessMessage", msg);
|
||||
context.dispatch("search");
|
||||
context.commit("updateSelectedMainTable", data.records[0]);
|
||||
context.dispatch("searchDetail");
|
||||
} else {
|
||||
context.commit("updateErrors", response.data.errors);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("updateErrMessage", e.message);
|
||||
context.commit("updateAlertError", true);
|
||||
}
|
||||
},
|
||||
async deleteRequest(context, payload) {
|
||||
try {
|
||||
payload.token = one_token();
|
||||
|
||||
let response = await api.deleteRequest(payload);
|
||||
if (response.status !== "OK") {
|
||||
context.commit("updateErrMessage", response.message);
|
||||
context.commit("updateAlertError", true);
|
||||
} else {
|
||||
context.commit("updateErrMessage", "");
|
||||
let data = {
|
||||
records: response.data.records,
|
||||
total: response.data.total,
|
||||
};
|
||||
|
||||
if (data.total !== -1) {
|
||||
context.commit("updateErrors", []);
|
||||
context.commit("updateAlertSuccess", true);
|
||||
context.commit("updateDialogRequest", false);
|
||||
var msg = `Purchase Request dengan kode ${payload.PRNumber} sudah dihapus`;
|
||||
context.commit("updateSuccessMessage", msg);
|
||||
context.dispatch("search");
|
||||
} else {
|
||||
context.commit("updateErrors", response.data.errors);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("updateErrMessage", e.message);
|
||||
context.commit("updateAlertError", true);
|
||||
}
|
||||
},
|
||||
async saveDetail(context, payload) {
|
||||
try {
|
||||
payload.token = one_token();
|
||||
|
||||
let response = await api.saveDetail(payload);
|
||||
if (response.status !== "OK") {
|
||||
context.commit("updateErrMessage", response.message);
|
||||
} else {
|
||||
context.commit("updateErrMessage", "");
|
||||
let data = {
|
||||
records: response.data.records,
|
||||
total: response.data.total,
|
||||
};
|
||||
|
||||
if (data.total !== -1) {
|
||||
context.commit("updateErrors", []);
|
||||
context.commit("updateAlertSuccess", true);
|
||||
context.commit("updateDialogDetail", false);
|
||||
var msg = `Request baru ${payload.PRDDescription} sudah tersimpan`;
|
||||
context.commit("updateSuccessMessage", msg);
|
||||
context.dispatch("search");
|
||||
context.dispatch("searchDetail");
|
||||
} else {
|
||||
context.commit("updateErrors", response.data.errors);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("updateErrMessage", e.message);
|
||||
context.commit("updateAlertError", true);
|
||||
}
|
||||
},
|
||||
async updateDetail(context, payload) {
|
||||
try {
|
||||
payload.token = one_token();
|
||||
|
||||
let response = await api.updateDetail(payload);
|
||||
if (response.status !== "OK") {
|
||||
context.commit("updateErrMessage", response.message);
|
||||
context.commit("updateAlertError", true);
|
||||
} else {
|
||||
context.commit("updateErrMessage", "");
|
||||
let data = {
|
||||
records: response.data.records,
|
||||
total: response.data.total,
|
||||
};
|
||||
|
||||
if (data.total !== -1) {
|
||||
context.commit("updateErrors", []);
|
||||
context.commit("updateAlertSuccess", true);
|
||||
context.commit("updateDialogDetail", false);
|
||||
var msg = "Perubahan Request sudah tersimpan";
|
||||
context.commit("updateSuccessMessage", msg);
|
||||
context.dispatch("search");
|
||||
context.dispatch("searchDetail");
|
||||
} else {
|
||||
context.commit("updateErrors", response.data.errors);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("updateErrMessage", e.message);
|
||||
context.commit("updateAlertError", true);
|
||||
}
|
||||
},
|
||||
async deleteDetail(context, payload) {
|
||||
try {
|
||||
payload.token = one_token();
|
||||
|
||||
let response = await api.deleteDetail(payload);
|
||||
if (response.status !== "OK") {
|
||||
context.commit("updateErrMessage", response.message);
|
||||
context.commit("updateAlertError", true);
|
||||
} else {
|
||||
context.commit("updateErrMessage", "");
|
||||
let data = {
|
||||
records: response.data.records,
|
||||
total: response.data.total,
|
||||
};
|
||||
|
||||
if (data.total !== -1) {
|
||||
context.commit("updateErrors", []);
|
||||
context.commit("updateAlertSuccess", true);
|
||||
context.commit("updateDialogDetail", false);
|
||||
var msg = `Request [${payload.PRDDescriptionDetail}] sudah dihapus`;
|
||||
context.commit("updateSuccessMessage", msg);
|
||||
context.dispatch("search");
|
||||
context.dispatch("searchDetail");
|
||||
} else {
|
||||
context.commit("updateErrors", response.data.errors);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("updateErrMessage", e.message);
|
||||
context.commit("updateAlertError", true);
|
||||
}
|
||||
},
|
||||
async orderRequest(context, payload) {
|
||||
try {
|
||||
payload.token = one_token();
|
||||
|
||||
let response = await api.orderRequest(payload);
|
||||
if (response.status !== "OK") {
|
||||
context.commit("updateErrMessage", response.message);
|
||||
context.commit("updateAlertError", true);
|
||||
} else {
|
||||
context.commit("updateErrMessage", "");
|
||||
let data = {
|
||||
records: response.data.records,
|
||||
total: response.data.total,
|
||||
};
|
||||
|
||||
if (data.total !== -1) {
|
||||
context.commit("updateErrors", []);
|
||||
context.commit("updateAlertSuccess", true);
|
||||
context.commit("updateDialogDetail", false);
|
||||
context.dispatch("search");
|
||||
context.commit("updateSelectedMainTable", data.records[0]);
|
||||
context.dispatch("searchDetail");
|
||||
} else {
|
||||
context.commit("updateErrors", response.data.errors);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("updateErrMessage", e.message);
|
||||
context.commit("updateAlertError", true);
|
||||
}
|
||||
},
|
||||
|
||||
async getUnit(context, prm) {
|
||||
context.commit("updateLoadingAutocomplete", true)
|
||||
try {
|
||||
let resp = await api.getUnit(one_token(), prm)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("updateLoadingAutocomplete", false)
|
||||
context.commit("updateErrMessage", response.message);
|
||||
context.commit("updateAlertError", true);
|
||||
} else {
|
||||
context.commit("updateLoadingAutocomplete", false)
|
||||
context.commit("updateErrMessage", "");
|
||||
let data = {
|
||||
records: resp.data.records
|
||||
}
|
||||
|
||||
context.commit("updateItemUnits", data.records)
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("updateLoadingAutocomplete", true)
|
||||
context.commit("updateErrMessage", e.message);
|
||||
context.commit("updateAlertError", true);
|
||||
}
|
||||
},
|
||||
|
||||
async saveFiles(context, payload) {
|
||||
try {
|
||||
// payload.token = one_token();
|
||||
|
||||
let response = await api.saveFiles(payload);
|
||||
if (response.status !== "OK") {
|
||||
context.commit("updateErrMessage", response.message);
|
||||
context.commit("updateAlertError", true);
|
||||
context.commit("update_cekFile", true);
|
||||
} else {
|
||||
context.commit("updateErrMessage", "");
|
||||
// let data = {
|
||||
// records: response.data.records,
|
||||
// total: response.data.total,
|
||||
// };
|
||||
|
||||
context.commit("update_dialog_form", false);
|
||||
context.commit("update_imageFiles", []);
|
||||
context.commit("update_imagePreviews", []);
|
||||
context.commit("updateErrors", []);
|
||||
context.commit("updateAlertSuccess", true);
|
||||
var msg = "Upload file berhasil";
|
||||
context.commit("updateSuccessMessage", msg);
|
||||
context.dispatch("search");
|
||||
context.dispatch("searchDetail");
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("updateErrMessage", e.message);
|
||||
context.commit("updateAlertError", true);
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
11
test/vuex/acc-one-purchase-request-direct/store.js
Normal file
11
test/vuex/acc-one-purchase-request-direct/store.js
Normal file
@@ -0,0 +1,11 @@
|
||||
import requester from "./modules/requester.js";
|
||||
import system from "../../../apps/modules/system/system.js";
|
||||
export const store = new Vuex.Store({
|
||||
modules: {
|
||||
requester: requester,
|
||||
system: system,
|
||||
},
|
||||
state: {},
|
||||
mutations: {},
|
||||
actions: {},
|
||||
});
|
||||
Reference in New Issue
Block a user