HUGE REFACTOR / CLEANUP
if there is a issue it's probably something in here that was changed
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
<template>
|
||||
<div>
|
||||
<!-- {{ obj.items }} -->
|
||||
<gz-report-selector ref="reportSelector"></gz-report-selector>
|
||||
<div v-if="formState.ready">
|
||||
<gz-error :error-box-message="formState.errorBoxMessage"></gz-error>
|
||||
@@ -856,31 +855,20 @@
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/* Xeslint-disable */
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
const FORM_KEY = "inv-purchase-order-edit";
|
||||
const API_BASE_URL = "purchase-order/";
|
||||
const FORM_CUSTOM_TEMPLATE_KEY = "PurchaseOrder"; //<-- Should always be CoreBizObject AyaType name here where possible
|
||||
|
||||
const FORM_CUSTOM_TEMPLATE_KEY = "PurchaseOrder";
|
||||
export default {
|
||||
async created() {
|
||||
let vm = this;
|
||||
|
||||
const vm = this;
|
||||
try {
|
||||
await initForm(vm);
|
||||
|
||||
vm.rights = window.$gz.role.getRights(window.$gz.type.PurchaseOrder);
|
||||
vm.formState.readOnly = !vm.rights.change;
|
||||
window.$gz.eventBus.$on("menu-click", clickHandler);
|
||||
|
||||
//---------------------------------
|
||||
let setDirty = false;
|
||||
let setValid = true;
|
||||
//id 0 means create or duplicate to new
|
||||
if (vm.$route.params.recordid != 0) {
|
||||
//is there already an obj from a prior operation?
|
||||
@@ -888,7 +876,7 @@ export default {
|
||||
//yes, no need to fetch it
|
||||
this.obj = this.$route.params.obj;
|
||||
} else {
|
||||
await vm.getDataFromApi(vm.$route.params.recordid); //let getdata handle loading
|
||||
await vm.getDataFromApi(vm.$route.params.recordid);
|
||||
}
|
||||
} else {
|
||||
//Might be a duplicate and contain another record
|
||||
@@ -897,7 +885,6 @@ export default {
|
||||
this.obj.concurrency = undefined;
|
||||
this.obj.id = 0;
|
||||
this.obj.serial = 0;
|
||||
|
||||
vm.obj.status = 1; // OpenNotYetOrdered = 1,
|
||||
vm.obj.items.forEach(z => {
|
||||
z.id = 0;
|
||||
@@ -909,7 +896,6 @@ export default {
|
||||
z.workOrderItemPartRequestId = null;
|
||||
z.partRequestedById = null;
|
||||
});
|
||||
|
||||
setDirty = true;
|
||||
}
|
||||
}
|
||||
@@ -917,7 +903,7 @@ export default {
|
||||
vm: vm,
|
||||
loading: false,
|
||||
dirty: setDirty,
|
||||
valid: setValid
|
||||
valid: true
|
||||
});
|
||||
//----------------------------
|
||||
generateMenu(vm);
|
||||
@@ -956,31 +942,26 @@ export default {
|
||||
status: []
|
||||
},
|
||||
headers: [],
|
||||
obj:
|
||||
//IMPORTANT NOTE: Fields that are NON NULLABLE in the schema for the table but *are* hideable **MUST** have a default value set here or else there will be no way to save the record
|
||||
//I.E. Serial, usertype fields, ACTIVE
|
||||
//Also, if it's a non-nullable Enum backed field then it should have a valid selection i.e. not zero if there is no zero
|
||||
{
|
||||
id: 0,
|
||||
concurrency: 0,
|
||||
serial: 0,
|
||||
notes: null,
|
||||
wiki: null,
|
||||
customFields: null,
|
||||
tags: [],
|
||||
vendorMemo: null,
|
||||
dropShipToCustomerId: null,
|
||||
referenceNumber: null,
|
||||
vendorId: null,
|
||||
orderedDate: window.$gz.locale.nowUTC8601String(),
|
||||
expectedReceiveDate: null,
|
||||
status: 1,
|
||||
projectId: null,
|
||||
text1: null,
|
||||
text2: null,
|
||||
items: []
|
||||
},
|
||||
|
||||
obj: {
|
||||
id: 0,
|
||||
concurrency: 0,
|
||||
serial: 0,
|
||||
notes: null,
|
||||
wiki: null,
|
||||
customFields: null,
|
||||
tags: [],
|
||||
vendorMemo: null,
|
||||
dropShipToCustomerId: null,
|
||||
referenceNumber: null,
|
||||
vendorId: null,
|
||||
orderedDate: window.$gz.locale.nowUTC8601String(),
|
||||
expectedReceiveDate: null,
|
||||
status: 1,
|
||||
projectId: null,
|
||||
text1: null,
|
||||
text2: null,
|
||||
items: []
|
||||
},
|
||||
formState: {
|
||||
ready: false,
|
||||
dirty: false,
|
||||
@@ -1002,23 +983,17 @@ export default {
|
||||
hour12: window.$gz.locale.getHour12()
|
||||
};
|
||||
},
|
||||
//WATCHERS
|
||||
watch: {
|
||||
formState: {
|
||||
handler: function(val) {
|
||||
//,oldval is available here too if necessary
|
||||
if (this.formState.loading) {
|
||||
return;
|
||||
}
|
||||
|
||||
//enable / disable save button
|
||||
if (val.dirty && val.valid && !val.readOnly) {
|
||||
window.$gz.eventBus.$emit("menu-enable-item", FORM_KEY + ":save");
|
||||
} else {
|
||||
window.$gz.eventBus.$emit("menu-disable-item", FORM_KEY + ":save");
|
||||
}
|
||||
|
||||
//enable / disable duplicate / new button
|
||||
if (!val.dirty && val.valid && !val.readOnly) {
|
||||
window.$gz.eventBus.$emit(
|
||||
"menu-enable-item",
|
||||
@@ -1038,57 +1013,52 @@ export default {
|
||||
},
|
||||
computed: {
|
||||
headerList: function() {
|
||||
/*
|
||||
If the column is a text, left-align it
|
||||
If the column is a number or number + unit, (or date) right-align it (like excel)
|
||||
*/
|
||||
let headers = [];
|
||||
let vm = this;
|
||||
const headers = [];
|
||||
headers.push({
|
||||
text: vm.$ay.t("Part"),
|
||||
text: this.$ay.t("Part"),
|
||||
align: "left",
|
||||
value: "partViz"
|
||||
});
|
||||
|
||||
if (vm.form().showMe(vm, "Items.PartName")) {
|
||||
if (this.form().showMe(this, "Items.PartName")) {
|
||||
headers.push({
|
||||
text: vm.$ay.t("PartName"),
|
||||
text: this.$ay.t("PartName"),
|
||||
align: "left",
|
||||
value: "partNameViz"
|
||||
});
|
||||
}
|
||||
|
||||
if (vm.obj.hasSelectableWarehouses) {
|
||||
if (this.obj.hasSelectableWarehouses) {
|
||||
headers.push({
|
||||
text: vm.$ay.t("PartWarehouse"),
|
||||
text: this.$ay.t("PartWarehouse"),
|
||||
align: "left",
|
||||
value: "warehouseViz"
|
||||
});
|
||||
}
|
||||
|
||||
if (vm.form().showMe(vm, "Items.PartUnitOfMeasureViz")) {
|
||||
if (this.form().showMe(this, "Items.PartUnitOfMeasureViz")) {
|
||||
headers.push({
|
||||
text: vm.$ay.t("UnitOfMeasure"),
|
||||
text: this.$ay.t("UnitOfMeasure"),
|
||||
align: "left",
|
||||
value: "partUnitOfMeasureViz"
|
||||
});
|
||||
}
|
||||
|
||||
headers.push({
|
||||
text: vm.$ay.t("PurchaseOrderItemQuantityOrdered"),
|
||||
text: this.$ay.t("PurchaseOrderItemQuantityOrdered"),
|
||||
align: "right",
|
||||
value: "quantityOrdered"
|
||||
});
|
||||
|
||||
if (vm.obj.hasReceipt) {
|
||||
if (this.obj.hasReceipt) {
|
||||
headers.push({
|
||||
text: vm.$ay.t("PurchaseOrderItemQuantityReceived"),
|
||||
text: this.$ay.t("PurchaseOrderItemQuantityReceived"),
|
||||
align: "right",
|
||||
value: "quantityReceived"
|
||||
});
|
||||
if (vm.form().showMe(vm, "Items.ReceivedDate")) {
|
||||
if (this.form().showMe(this, "Items.ReceivedDate")) {
|
||||
headers.push({
|
||||
text: vm.$ay.t("PurchaseOrderReceiptReceivedDate"),
|
||||
text: this.$ay.t("PurchaseOrderReceiptReceivedDate"),
|
||||
align: "right",
|
||||
value: "receivedDate"
|
||||
});
|
||||
@@ -1096,115 +1066,120 @@ export default {
|
||||
}
|
||||
|
||||
headers.push({
|
||||
text: vm.$ay.t("PurchaseOrderItemPurchaseOrderCost"),
|
||||
text: this.$ay.t("PurchaseOrderItemPurchaseOrderCost"),
|
||||
align: "right",
|
||||
value: "purchaseOrderCost"
|
||||
});
|
||||
|
||||
if (vm.obj.hasReceipt) {
|
||||
if (this.obj.hasReceipt) {
|
||||
headers.push({
|
||||
text: vm.$ay.t("PurchaseOrderReceiptItemReceiptCost"),
|
||||
text: this.$ay.t("PurchaseOrderReceiptItemReceiptCost"),
|
||||
align: "right",
|
||||
value: "receivedCost"
|
||||
});
|
||||
}
|
||||
|
||||
if (vm.obj.hasTaxes && vm.form().showMe(vm, "Items.PurchaseTaxCodeId")) {
|
||||
if (
|
||||
this.obj.hasTaxes &&
|
||||
this.form().showMe(this, "Items.PurchaseTaxCodeId")
|
||||
) {
|
||||
headers.push({
|
||||
text: vm.$ay.t("TaxCode"),
|
||||
text: this.$ay.t("TaxCode"),
|
||||
align: "left",
|
||||
value: "purchaseTaxCodeViz"
|
||||
});
|
||||
}
|
||||
|
||||
headers.push({
|
||||
text: vm.$ay.t("PurchaseOrderItemNetTotal"),
|
||||
text: this.$ay.t("PurchaseOrderItemNetTotal"),
|
||||
align: "right",
|
||||
value: "netTotalViz"
|
||||
});
|
||||
|
||||
if (vm.obj.hasTaxes && vm.form().showMe(vm, "Items.PurchaseTaxCodeId")) {
|
||||
if (
|
||||
this.obj.hasTaxes &&
|
||||
this.form().showMe(this, "Items.PurchaseTaxCodeId")
|
||||
) {
|
||||
headers.push({
|
||||
text: vm.$ay.t("TaxCodeTaxA"),
|
||||
text: this.$ay.t("TaxCodeTaxA"),
|
||||
align: "right",
|
||||
value: "taxAViz"
|
||||
});
|
||||
|
||||
headers.push({
|
||||
text: vm.$ay.t("TaxCodeTaxB"),
|
||||
text: this.$ay.t("TaxCodeTaxB"),
|
||||
align: "right",
|
||||
value: "taxBViz"
|
||||
});
|
||||
}
|
||||
|
||||
headers.push({
|
||||
text: vm.$ay.t("PurchaseOrderItemLineTotal"),
|
||||
text: this.$ay.t("PurchaseOrderItemLineTotal"),
|
||||
align: "right",
|
||||
value: "lineTotalViz"
|
||||
});
|
||||
|
||||
if (
|
||||
vm.obj.hasVendorNumber &&
|
||||
vm.form().showMe(vm, "Items.VendorPartNumber")
|
||||
this.obj.hasVendorNumber &&
|
||||
this.form().showMe(this, "Items.VendorPartNumber")
|
||||
) {
|
||||
headers.push({
|
||||
text: vm.$ay.t("PurchaseOrderItemVendorPartNumber"),
|
||||
text: this.$ay.t("PurchaseOrderItemVendorPartNumber"),
|
||||
align: "left",
|
||||
value: "vendorPartNumber"
|
||||
});
|
||||
}
|
||||
|
||||
if (vm.obj.hasPartRequest) {
|
||||
if (vm.form().showMe(vm, "Items.PartRequestedById")) {
|
||||
if (this.obj.hasPartRequest) {
|
||||
if (this.form().showMe(this, "Items.PartRequestedById")) {
|
||||
headers.push({
|
||||
text: vm.$ay.t("PurchaseOrderItemPartRequestedByID"),
|
||||
text: this.$ay.t("PurchaseOrderItemPartRequestedByID"),
|
||||
align: "left",
|
||||
value: "partRequestedByViz"
|
||||
});
|
||||
}
|
||||
if (vm.form().showMe(vm, "Items.WorkOrderItemPartRequestId")) {
|
||||
if (this.form().showMe(this, "Items.WorkOrderItemPartRequestId")) {
|
||||
headers.push({
|
||||
text: vm.$ay.t("PurchaseOrderItemWorkOrderNumber"),
|
||||
text: this.$ay.t("PurchaseOrderItemWorkOrderNumber"),
|
||||
align: "left",
|
||||
value: "workOrderItemPartRequestViz"
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (!vm.formState.readOnly) {
|
||||
if (!this.formState.readOnly) {
|
||||
headers.push({ text: "", value: "actions" });
|
||||
}
|
||||
return headers;
|
||||
},
|
||||
itemList: function() {
|
||||
let vm = this;
|
||||
return vm.obj.items.map((x, i) => {
|
||||
return this.obj.items.map((x, i) => {
|
||||
return {
|
||||
index: i,
|
||||
id: x.id,
|
||||
quantityOrdered: window.$gz.locale.decimalLocalized(
|
||||
x.quantityOrdered,
|
||||
vm.languageName
|
||||
this.languageName
|
||||
),
|
||||
quantityReceived: window.$gz.locale.decimalLocalized(
|
||||
x.quantityReceived,
|
||||
vm.languageName
|
||||
this.languageName
|
||||
),
|
||||
purchaseOrderCost: window.$gz.locale.currencyLocalized(
|
||||
x.purchaseOrderCost,
|
||||
vm.languageName,
|
||||
vm.currencyName
|
||||
this.languageName,
|
||||
this.currencyName
|
||||
),
|
||||
receivedCost: window.$gz.locale.currencyLocalized(
|
||||
x.receivedCost,
|
||||
vm.languageName,
|
||||
vm.currencyName
|
||||
this.languageName,
|
||||
this.currencyName
|
||||
),
|
||||
receivedDate: window.$gz.locale.utcDateToShortDateAndTimeLocalized(
|
||||
x.receivedDate,
|
||||
vm.timeZoneName,
|
||||
vm.languageName,
|
||||
vm.hour12
|
||||
this.timeZoneName,
|
||||
this.languageName,
|
||||
this.hour12
|
||||
),
|
||||
vendorPartNumber: x.vendorPartNumber,
|
||||
partViz: x.partViz,
|
||||
@@ -1217,64 +1192,63 @@ export default {
|
||||
purchaseTaxCodeViz: x.purchaseTaxCodeViz,
|
||||
netTotalViz: window.$gz.locale.currencyLocalized(
|
||||
x.netTotalViz,
|
||||
vm.languageName,
|
||||
vm.currencyName
|
||||
this.languageName,
|
||||
this.currencyName
|
||||
),
|
||||
taxAViz: window.$gz.locale.currencyLocalized(
|
||||
x.taxAViz,
|
||||
vm.languageName,
|
||||
vm.currencyName
|
||||
this.languageName,
|
||||
this.currencyName
|
||||
),
|
||||
taxBViz: window.$gz.locale.currencyLocalized(
|
||||
x.taxBViz,
|
||||
vm.languageName,
|
||||
vm.currencyName
|
||||
this.languageName,
|
||||
this.currencyName
|
||||
),
|
||||
lineTotalViz: window.$gz.locale.currencyLocalized(
|
||||
x.lineTotalViz,
|
||||
vm.languageName,
|
||||
vm.currencyName
|
||||
this.languageName,
|
||||
this.currencyName
|
||||
)
|
||||
};
|
||||
});
|
||||
},
|
||||
restockHeaderList: function() {
|
||||
let headers = [];
|
||||
let vm = this;
|
||||
const headers = [];
|
||||
headers.push({
|
||||
text: vm.$ay.t("Part"),
|
||||
text: this.$ay.t("Part"),
|
||||
align: "left",
|
||||
value: "partNumber"
|
||||
});
|
||||
|
||||
if (vm.obj.hasSelectableWarehouses) {
|
||||
if (this.obj.hasSelectableWarehouses) {
|
||||
headers.push({
|
||||
text: vm.$ay.t("PartWarehouse"),
|
||||
text: this.$ay.t("PartWarehouse"),
|
||||
align: "left",
|
||||
value: "warehouseViz"
|
||||
});
|
||||
}
|
||||
|
||||
headers.push({
|
||||
text: vm.$ay.t("PartByWarehouseInventoryMinStockLevel"),
|
||||
text: this.$ay.t("PartByWarehouseInventoryMinStockLevel"),
|
||||
align: "right",
|
||||
value: "minimumQuantity"
|
||||
});
|
||||
|
||||
headers.push({
|
||||
text: vm.$ay.t("PartInventoryBalance"),
|
||||
text: this.$ay.t("PartInventoryBalance"),
|
||||
align: "right",
|
||||
value: "balance"
|
||||
});
|
||||
|
||||
headers.push({
|
||||
text: vm.$ay.t("PartByWarehouseInventoryQuantityOnOrder"),
|
||||
text: this.$ay.t("PartByWarehouseInventoryQuantityOnOrder"),
|
||||
align: "right",
|
||||
value: "onOrderQuantity"
|
||||
});
|
||||
|
||||
headers.push({
|
||||
text: vm.$ay.t("PartByWarehouseInventoryReorderQuantity"),
|
||||
text: this.$ay.t("PartByWarehouseInventoryReorderQuantity"),
|
||||
align: "right",
|
||||
value: "requiredQuantity"
|
||||
});
|
||||
@@ -1282,14 +1256,7 @@ export default {
|
||||
return headers;
|
||||
},
|
||||
restockItemList: function() {
|
||||
/**
|
||||
*
|
||||
* {"data":[{"partId":2,"partWarehouseId":1,"partNumber":"249986","warehouseViz":"Default","manufacturerId":2,
|
||||
* "displayManufacturer":"Ryan - Legros","wholesalerId":6,"displayWholesaler":"Emmerich and Sons","alternativeWholesalerId":9,
|
||||
* "displayAlternativeWholesaler":"O'Connell - MacGyver","minimumQuantity":6.0000,"balance":4.0000,"onOrderQuantity":0.0,"requiredQuantity":2.0000}]}
|
||||
*/
|
||||
let vm = this;
|
||||
return vm.restockItems.map((x, i) => {
|
||||
return this.restockItems.map((x, i) => {
|
||||
return {
|
||||
index: i,
|
||||
partId: x.partId,
|
||||
@@ -1299,66 +1266,65 @@ export default {
|
||||
|
||||
minimumQuantity: window.$gz.locale.decimalLocalized(
|
||||
x.minimumQuantity,
|
||||
vm.languageName
|
||||
this.languageName
|
||||
),
|
||||
balance: window.$gz.locale.decimalLocalized(
|
||||
x.balance,
|
||||
vm.languageName
|
||||
this.languageName
|
||||
),
|
||||
onOrderQuantity: window.$gz.locale.decimalLocalized(
|
||||
x.onOrderQuantity,
|
||||
vm.languageName
|
||||
this.languageName
|
||||
),
|
||||
requiredQuantity: window.$gz.locale.decimalLocalized(
|
||||
x.requiredQuantity,
|
||||
vm.languageName
|
||||
this.languageName
|
||||
)
|
||||
};
|
||||
});
|
||||
},
|
||||
requestHeaderList: function() {
|
||||
let headers = [];
|
||||
let vm = this;
|
||||
const headers = [];
|
||||
headers.push({
|
||||
text: vm.$ay.t("Part"),
|
||||
text: this.$ay.t("Part"),
|
||||
align: "left",
|
||||
value: "partNumber"
|
||||
});
|
||||
|
||||
if (vm.obj.hasSelectableWarehouses) {
|
||||
if (this.obj.hasSelectableWarehouses) {
|
||||
headers.push({
|
||||
text: vm.$ay.t("PartWarehouse"),
|
||||
text: this.$ay.t("PartWarehouse"),
|
||||
align: "left",
|
||||
value: "partWarehouseName"
|
||||
});
|
||||
}
|
||||
|
||||
headers.push({
|
||||
text: vm.$ay.t("WorkOrderItemPartRequestQuantity"),
|
||||
text: this.$ay.t("WorkOrderItemPartRequestQuantity"),
|
||||
align: "right",
|
||||
value: "quantity"
|
||||
});
|
||||
|
||||
headers.push({
|
||||
text: vm.$ay.t("WorkOrder"),
|
||||
text: this.$ay.t("WorkOrder"),
|
||||
align: "right",
|
||||
value: "serial"
|
||||
});
|
||||
|
||||
headers.push({
|
||||
text: vm.$ay.t("PurchaseOrderItemPartRequestedByID"),
|
||||
text: this.$ay.t("PurchaseOrderItemPartRequestedByID"),
|
||||
align: "left",
|
||||
value: "requestedByUserName"
|
||||
});
|
||||
|
||||
headers.push({
|
||||
text: vm.$ay.t("PartWholesalerID"),
|
||||
text: this.$ay.t("PartWholesalerID"),
|
||||
align: "left",
|
||||
value: "wholesalerName"
|
||||
});
|
||||
|
||||
headers.push({
|
||||
text: vm.$ay.t("PartAlternativeWholesalerID"),
|
||||
text: this.$ay.t("PartAlternativeWholesalerID"),
|
||||
align: "left",
|
||||
value: "altWholesalerName"
|
||||
});
|
||||
@@ -1366,26 +1332,7 @@ export default {
|
||||
return headers;
|
||||
},
|
||||
requestItemList: function() {
|
||||
/**
|
||||
{
|
||||
"0": {
|
||||
"requestId": 2,
|
||||
"partId": 7,
|
||||
"partWarehouseId": 1,
|
||||
"quantity": 498,
|
||||
"serial": 74,
|
||||
"partNumber": "CAB1064",
|
||||
"partName": "KYBD EXT-DIN5M DIN5F 6FT",
|
||||
"partWarehouseName": "Default",
|
||||
"wholesalerId": 19,
|
||||
"wholesalerName": "Merisale",
|
||||
"altWholesalerId": 13,
|
||||
"altWholesalerName": "Ingrim"
|
||||
}
|
||||
}
|
||||
*/
|
||||
let vm = this;
|
||||
return vm.requestItems.map((x, i) => {
|
||||
return this.requestItems.map((x, i) => {
|
||||
return {
|
||||
index: i,
|
||||
requestId: x.requestId,
|
||||
@@ -1400,7 +1347,7 @@ export default {
|
||||
altWholesalerName: x.altWholesalerName,
|
||||
quantity: window.$gz.locale.decimalLocalized(
|
||||
x.quantity,
|
||||
vm.languageName
|
||||
this.languageName
|
||||
)
|
||||
};
|
||||
});
|
||||
@@ -1453,13 +1400,11 @@ export default {
|
||||
},
|
||||
|
||||
async showRestockSelectDialog() {
|
||||
let vm = this;
|
||||
|
||||
let url = API_BASE_URL + "restock-by-vendor/" + vm.obj.vendorId;
|
||||
const vm = this;
|
||||
const url = API_BASE_URL + "restock-by-vendor/" + vm.obj.vendorId;
|
||||
window.$gz.form.deleteAllErrorBoxErrors(vm);
|
||||
try {
|
||||
let res = await window.$gz.api.get(url);
|
||||
|
||||
const res = await window.$gz.api.get(url);
|
||||
if (res.error) {
|
||||
vm.formState.serverError = res.error;
|
||||
window.$gz.form.setErrorBoxErrors(vm);
|
||||
@@ -1481,13 +1426,11 @@ export default {
|
||||
}
|
||||
},
|
||||
async showRequestSelectDialog() {
|
||||
let vm = this;
|
||||
|
||||
let url = API_BASE_URL + "requests-by-vendor/" + vm.obj.vendorId;
|
||||
const vm = this;
|
||||
const url = API_BASE_URL + "requests-by-vendor/" + vm.obj.vendorId;
|
||||
window.$gz.form.deleteAllErrorBoxErrors(vm);
|
||||
try {
|
||||
let res = await window.$gz.api.get(url);
|
||||
|
||||
const res = await window.$gz.api.get(url);
|
||||
if (res.error) {
|
||||
vm.formState.serverError = res.error;
|
||||
window.$gz.form.setErrorBoxErrors(vm);
|
||||
@@ -1552,7 +1495,7 @@ export default {
|
||||
this.editPoItemDialog = false;
|
||||
},
|
||||
receiveAll: function() {
|
||||
let vm = this;
|
||||
const vm = this;
|
||||
this.obj.items.forEach(item => receiveItem(item, vm));
|
||||
//set status to all received fwiw
|
||||
this.obj.status = 5;
|
||||
@@ -1596,15 +1539,15 @@ export default {
|
||||
return null;
|
||||
},
|
||||
async updatePartCost(item) {
|
||||
let vm = this;
|
||||
let dialogResult = await window.$gz.dialog.confirmGeneric(
|
||||
const vm = this;
|
||||
const dialogResult = await window.$gz.dialog.confirmGeneric(
|
||||
"ConfirmUpdatePartCost"
|
||||
);
|
||||
if (dialogResult == false) {
|
||||
return;
|
||||
}
|
||||
//send request
|
||||
let res = await window.$gz.api.put(
|
||||
const res = await window.$gz.api.put(
|
||||
`part/part-cost/${item.partId}`,
|
||||
item.receivedCost
|
||||
);
|
||||
@@ -1637,7 +1580,7 @@ export default {
|
||||
}
|
||||
},
|
||||
async getDataFromApi(recordId) {
|
||||
let vm = this;
|
||||
const vm = this;
|
||||
window.$gz.form.setFormState({
|
||||
vm: vm,
|
||||
loading: true
|
||||
@@ -1645,14 +1588,10 @@ export default {
|
||||
if (!recordId) {
|
||||
throw new Error(FORM_KEY + "::getDataFromApi -> Missing recordID!");
|
||||
}
|
||||
let url = API_BASE_URL + recordId;
|
||||
try {
|
||||
window.$gz.form.deleteAllErrorBoxErrors(vm);
|
||||
|
||||
let res = await window.$gz.api.get(url);
|
||||
|
||||
const res = await window.$gz.api.get(API_BASE_URL + recordId);
|
||||
if (res.error) {
|
||||
//Not found?
|
||||
if (res.error.code == "2010") {
|
||||
window.$gz.form.handleObjectNotFound(vm);
|
||||
}
|
||||
@@ -1660,10 +1599,7 @@ export default {
|
||||
window.$gz.form.setErrorBoxErrors(vm);
|
||||
} else {
|
||||
vm.obj = res.data;
|
||||
//modify the menu as necessary
|
||||
generateMenu(vm);
|
||||
|
||||
//Update the form status
|
||||
window.$gz.form.setFormState({
|
||||
vm: vm,
|
||||
dirty: false,
|
||||
@@ -1681,7 +1617,7 @@ export default {
|
||||
}
|
||||
},
|
||||
async submit() {
|
||||
let vm = this;
|
||||
const vm = this;
|
||||
if (vm.canSave == false) {
|
||||
return;
|
||||
}
|
||||
@@ -1691,17 +1627,13 @@ export default {
|
||||
vm: vm,
|
||||
loading: true
|
||||
});
|
||||
let url = API_BASE_URL; // + vm.$route.params.recordid;
|
||||
//clear any errors vm might be around from previous submit
|
||||
window.$gz.form.deleteAllErrorBoxErrors(vm);
|
||||
|
||||
let res = await window.$gz.api.upsert(url, vm.obj);
|
||||
|
||||
const res = await window.$gz.api.upsert(API_BASE_URL, vm.obj);
|
||||
if (res.error) {
|
||||
vm.formState.serverError = res.error;
|
||||
window.$gz.form.setErrorBoxErrors(vm);
|
||||
} else {
|
||||
//POST or PUT - whole new object returned which is a little different than other objects
|
||||
//POST or PUT which is a little different than other objects
|
||||
//so if it's new then need to navigate to it to update url with id
|
||||
if (vm.$route.params.recordid != 0) {
|
||||
//update of existing record
|
||||
@@ -1711,12 +1643,10 @@ export default {
|
||||
name: "inv-purchase-order",
|
||||
params: {
|
||||
recordid: res.data.id,
|
||||
obj: res.data // Pass data object to new form will prevent fetch
|
||||
obj: res.data
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//Update the form status
|
||||
window.$gz.form.setFormState({
|
||||
vm: vm,
|
||||
dirty: false,
|
||||
@@ -1733,42 +1663,34 @@ export default {
|
||||
}
|
||||
},
|
||||
async remove() {
|
||||
let vm = this;
|
||||
const vm = this;
|
||||
try {
|
||||
let dialogResult = await window.$gz.dialog.confirmDelete();
|
||||
const dialogResult = await window.$gz.dialog.confirmDelete();
|
||||
if (dialogResult != true) {
|
||||
return;
|
||||
}
|
||||
|
||||
//do the delete
|
||||
window.$gz.form.setFormState({
|
||||
vm: vm,
|
||||
loading: true
|
||||
});
|
||||
//No need to delete a new record, just abandon it...
|
||||
if (vm.$route.params.recordid == 0) {
|
||||
//this should not get offered for delete but to be safe and clear just in case:
|
||||
JUST_DELETED = true;
|
||||
// navigate backwards
|
||||
|
||||
vm.$router.go(-1);
|
||||
} else {
|
||||
let url = API_BASE_URL + vm.$route.params.recordid;
|
||||
|
||||
window.$gz.form.deleteAllErrorBoxErrors(vm);
|
||||
let res = await window.$gz.api.remove(url);
|
||||
const res = await window.$gz.api.remove(
|
||||
API_BASE_URL + vm.$route.params.recordid
|
||||
);
|
||||
if (res.error) {
|
||||
vm.formState.serverError = res.error;
|
||||
window.$gz.form.setErrorBoxErrors(vm);
|
||||
} else {
|
||||
//workaround to prevent warning about leaving dirty record
|
||||
//For some reason I couldn't just reset isdirty in formstate
|
||||
JUST_DELETED = true;
|
||||
// navigate backwards
|
||||
vm.$router.go(-1);
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
//Update the form status
|
||||
window.$gz.form.setFormState({
|
||||
vm: vm,
|
||||
loading: false
|
||||
@@ -1777,7 +1699,6 @@ export default {
|
||||
}
|
||||
},
|
||||
duplicate() {
|
||||
//Navigate to new record
|
||||
this.$router.push({
|
||||
name: "inv-purchase-order",
|
||||
params: {
|
||||
@@ -1808,7 +1729,7 @@ async function clickHandler(menuItem) {
|
||||
if (!menuItem) {
|
||||
return;
|
||||
}
|
||||
let m = window.$gz.menu.parseMenuItem(menuItem);
|
||||
const m = window.$gz.menu.parseMenuItem(menuItem);
|
||||
if (m.owner == FORM_KEY && !m.disabled) {
|
||||
switch (m.key) {
|
||||
case "save":
|
||||
@@ -1827,7 +1748,7 @@ async function clickHandler(menuItem) {
|
||||
m.vm.duplicate();
|
||||
break;
|
||||
case "report":
|
||||
let res = await m.vm.$refs.reportSelector.open(
|
||||
const res = await m.vm.$refs.reportSelector.open(
|
||||
{
|
||||
AType: window.$gz.type.PurchaseOrder,
|
||||
selectedRowIds: [m.vm.obj.id]
|
||||
@@ -1853,7 +1774,7 @@ async function clickHandler(menuItem) {
|
||||
//
|
||||
//
|
||||
function generateMenu(vm) {
|
||||
let menuOptions = {
|
||||
const menuOptions = {
|
||||
isMain: false,
|
||||
readOnly: vm.formState.readOnly,
|
||||
icon: "$ayiTruckLoading",
|
||||
@@ -1888,8 +1809,6 @@ function generateMenu(vm) {
|
||||
});
|
||||
}
|
||||
|
||||
//REPORTS
|
||||
//Report not Print, print is a further option
|
||||
menuOptions.menuItems.push({
|
||||
title: "Report",
|
||||
icon: "$ayiFileAlt",
|
||||
@@ -1897,8 +1816,7 @@ function generateMenu(vm) {
|
||||
vm: vm
|
||||
});
|
||||
|
||||
//get last report selected
|
||||
let lastReport = window.$gz.form.getLastReport(FORM_KEY);
|
||||
const lastReport = window.$gz.form.getLastReport(FORM_KEY);
|
||||
if (lastReport != null) {
|
||||
menuOptions.menuItems.push({
|
||||
title: lastReport.name,
|
||||
@@ -1947,7 +1865,6 @@ async function initForm(vm) {
|
||||
//
|
||||
//
|
||||
async function populateSelectionLists(vm) {
|
||||
//ensure the pick lists required are pre-fetched
|
||||
await window.$gz.enums.fetchEnumList("purchaseorderstatus");
|
||||
vm.selectLists.status = window.$gz.enums.getSelectionList(
|
||||
"purchaseorderstatus"
|
||||
@@ -2028,88 +1945,4 @@ async function fetchTranslatedText(vm) {
|
||||
"PurchaseOrderCustom16"
|
||||
]);
|
||||
}
|
||||
/* {
|
||||
data: {
|
||||
id: 4,
|
||||
concurrency: 7343586,
|
||||
serial: 4,
|
||||
notes: "Eius tenetur magnam nostrum qui doloribus velit.",
|
||||
wiki: null,
|
||||
customFields: null,
|
||||
tags: ["black", "green", "zebra", "zone0"],
|
||||
vendorMemo: "Et quis eaque repellat.",
|
||||
dropShipToCustomerId: null,
|
||||
referenceNumber: "578929",
|
||||
vendorId: 2,
|
||||
orderedDate: "2020-05-03T07:57:42.014786Z",
|
||||
expectedReceiveDate: "2020-05-08T07:57:42.014786Z",
|
||||
status: 2,
|
||||
projectId: null,
|
||||
text1: "Natus pariatur.",
|
||||
text2: "Provident repudiandae nobis et.",
|
||||
items: [
|
||||
{
|
||||
id: 15,
|
||||
concurrency: 7343586,
|
||||
purchaseOrderId: 4,
|
||||
partId: 13,
|
||||
partWarehouseId: 2,
|
||||
quantityOrdered: 65.0,
|
||||
quantityReceived: 0.0,
|
||||
purchaseOrderCost: 15.6812,
|
||||
receivedCost: 0.0,
|
||||
receivedDate: null,
|
||||
partRequestedById: null,
|
||||
workOrderItemPartRequestId: null,
|
||||
purchaseTaxCodeId: 3,
|
||||
vendorPartNumber: "man-695831",
|
||||
partViz: "695831",
|
||||
warehouseViz: "WHS- Lera Brook",
|
||||
partRequestedByViz: null,
|
||||
workOrderItemPartRequestViz: null,
|
||||
purchaseTaxCodeViz: "Sales & Goods",
|
||||
netTotalViz: 1019.278,
|
||||
TaxAViz: 71.34946,
|
||||
TaxBViz: 71.34946,
|
||||
lineTotalViz: 1161.97692
|
||||
}
|
||||
],
|
||||
hasSelectableWarehouses: true,
|
||||
hasPartRequest: false,
|
||||
hasTaxes: true,
|
||||
hasReceipt: false,
|
||||
hasVendorNumber: true,
|
||||
hasUnreceived: true
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
//RESTOCK REQUIRED
|
||||
if (
|
||||
useInventory &&
|
||||
window.$gz.role.canOpen(window.$gz.type.WorkOrderItemPartRequest)
|
||||
) {
|
||||
sub.push({
|
||||
title: "PurchaseOrderUIRestockList",
|
||||
icon: "$ayiClipboardList",
|
||||
route: "/inv-part-restocks",
|
||||
key: key++
|
||||
});
|
||||
}
|
||||
|
||||
//PART REQUESTS
|
||||
if (
|
||||
useInventory &&
|
||||
window.$gz.role.canOpen(window.$gz.type.WorkOrderItemPartRequest)
|
||||
) {
|
||||
sub.push({
|
||||
title: "WorkOrderItemPartRequestList",
|
||||
icon: "$ayiParachuteBox",
|
||||
route: "/inv-part-requests",
|
||||
key: key++
|
||||
});
|
||||
}
|
||||
|
||||
*/
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user