403 lines
13 KiB
Vue
403 lines
13 KiB
Vue
<template>
|
|
<div v-if="value != null" class="mt-8">
|
|
<v-row>
|
|
<v-col cols="12">
|
|
<v-menu offset-y>
|
|
<template v-slot:activator="{ on, attrs }">
|
|
<div class="text-h6">
|
|
<v-icon large color="primary" class="mr-2">$ayiBoxes</v-icon>
|
|
{{ $ay.t("WorkOrderItemPartList") }}
|
|
<v-btn v-if="!parentDeleted" large icon v-bind="attrs" v-on="on">
|
|
<v-icon small color="primary">$ayiEllipsisV</v-icon>
|
|
</v-btn>
|
|
</div>
|
|
</template>
|
|
<v-list>
|
|
<v-list-item v-if="canAdd" @click="newItem">
|
|
<v-list-item-icon>
|
|
<v-icon>$ayiPlus</v-icon>
|
|
</v-list-item-icon>
|
|
<v-list-item-title>{{ $ay.t("New") }}</v-list-item-title>
|
|
</v-list-item>
|
|
<v-list-item v-if="canDelete && !isDeleted" @click="deleteItem">
|
|
<v-list-item-icon>
|
|
<v-icon>$ayiTrashAlt</v-icon>
|
|
</v-list-item-icon>
|
|
<v-list-item-title>{{ $ay.t("SoftDelete") }}</v-list-item-title>
|
|
</v-list-item>
|
|
<v-list-item v-if="canDelete && isDeleted" @click="unDeleteItem">
|
|
<v-list-item-icon>
|
|
<v-icon>$ayiTrashRestoreAlt</v-icon>
|
|
</v-list-item-icon>
|
|
<v-list-item-title>{{ $ay.t("Undelete") }}</v-list-item-title>
|
|
</v-list-item>
|
|
</v-list>
|
|
</v-menu>
|
|
</v-col>
|
|
|
|
<template v-if="showTable">
|
|
<!-- ############################################################### -->
|
|
<v-col cols="12" class="mb-10">
|
|
<v-data-table
|
|
:headers="headerList"
|
|
:items="itemList"
|
|
item-key="index"
|
|
v-model="selectedRow"
|
|
class="elevation-1"
|
|
disable-pagination
|
|
disable-filtering
|
|
disable-sort
|
|
hide-default-footer
|
|
data-cy="partRequestsTable"
|
|
dense
|
|
:item-class="itemRowClasses"
|
|
@click:row="handleRowClick"
|
|
:show-select="$vuetify.breakpoint.xs"
|
|
single-select
|
|
>
|
|
<template v-slot:[`item.purchaseOrderOnOrderViz`]="{ item }">
|
|
<v-simple-checkbox
|
|
v-model="item.purchaseOrderOnOrderViz"
|
|
disabled
|
|
></v-simple-checkbox>
|
|
</template>
|
|
</v-data-table>
|
|
</v-col>
|
|
</template>
|
|
<template v-if="activeItemIndex != null">
|
|
<v-btn
|
|
v-if="canDelete && isDeleted"
|
|
large
|
|
@click="unDeleteItem"
|
|
color="primary"
|
|
>{{ $ay.t("Undelete")
|
|
}}<v-icon right large>$ayiTrashRestoreAlt</v-icon></v-btn
|
|
>
|
|
</template>
|
|
</v-row>
|
|
</div>
|
|
</template>
|
|
<script>
|
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
/* XXXeslint-disable */
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
/*
|
|
WORKORDER ITEM PART REQUEST
|
|
l.Add(new FormField { TKey = "WorkOrderItemPartRequestPartID", FieldKey = "WorkOrderItemPartRequestPartID", TKeySection = "WorkOrderItemPartRequests" });
|
|
l.Add(new FormField { TKey = "WorkOrderItemPartRequestPartWarehouseID", FieldKey = "WorkOrderItemPartRequestPartWarehouseID", TKeySection = "WorkOrderItemPartRequests" });
|
|
l.Add(new FormField { TKey = "WorkOrderItemPartRequestQuantity", FieldKey = "WorkOrderItemPartRequestQuantity", TKeySection = "WorkOrderItemPartRequests" });
|
|
l.Add(new FormField { TKey = "PartUPC", FieldKey = "PartRequestPartUPC", TKeySection = "WorkOrderItemPartRequests" });
|
|
l.Add(new FormField { TKey = "PurchaseOrder", FieldKey = "WorkOrderItemPartRequestPurchaseOrder", TKeySection = "WorkOrderItemPartRequests" });
|
|
l.Add(new FormField { TKey = "PurchaseOrderExpectedReceiveDate", FieldKey = "WorkOrderItemPartRequestExpectedReceiveDate", TKeySection = "WorkOrderItemPartRequests" });
|
|
l.Add(new FormField { TKey = "PurchaseOrderOrderedDate", FieldKey = "WorkOrderItemPartRequestOrderedDate", TKeySection = "WorkOrderItemPartRequests" });
|
|
l.Add(new FormField { TKey = "WorkOrderItemPartRequestOnOrder", FieldKey = "WorkOrderItemPartRequestOnOrder", TKeySection = "WorkOrderItemPartRequests" });
|
|
l.Add(new FormField { TKey = "WorkOrderItemPartRequestReceived", FieldKey = "WorkOrderItemPartRequestReceived", TKeySection = "WorkOrderItemPartRequests" });
|
|
{
|
|
"0": {
|
|
"id": 39,
|
|
"concurrency": 8121176,
|
|
"partId": 3,
|
|
"partViz": "565221",
|
|
"upcViz": "2202707210364",
|
|
"partWarehouseId": 1,
|
|
"partWarehouseViz": "Default",
|
|
"quantity": 1,
|
|
"purchaseOrderItemId": null,
|
|
"purchaseOrderViz": null,
|
|
"purchaseOrderIdViz": null,
|
|
"purchaseOrderDateViz": null,
|
|
"purchaseOrderExpectedDateViz": null,
|
|
"purchaseOrderOnOrderViz": false,
|
|
"received": 0,
|
|
"isDirty": false,
|
|
"workOrderItemId": 20
|
|
}
|
|
}
|
|
*/
|
|
export default {
|
|
created() {
|
|
this.setDefaultView();
|
|
},
|
|
data() {
|
|
return {
|
|
activeItemIndex: null,
|
|
selectedRow: []
|
|
};
|
|
},
|
|
props: {
|
|
value: {
|
|
default: null,
|
|
type: Object
|
|
},
|
|
pvm: {
|
|
default: null,
|
|
type: Object
|
|
},
|
|
activeWoItemIndex: {
|
|
default: null,
|
|
type: Number
|
|
}
|
|
},
|
|
watch: {
|
|
activeWoItemIndex(val, oldVal) {
|
|
if (val != oldVal) {
|
|
this.setDefaultView();
|
|
}
|
|
}
|
|
},
|
|
methods: {
|
|
warehouseChange(newName) {
|
|
this.value.items[this.activeWoItemIndex].partRequests[
|
|
this.activeItemIndex
|
|
].partWarehouseViz = newName;
|
|
},
|
|
partChange(newName) {
|
|
this.value.items[this.activeWoItemIndex].partRequests[
|
|
this.activeItemIndex
|
|
].partViz = newName;
|
|
},
|
|
newItem() {
|
|
let newIndex = this.value.items[this.activeWoItemIndex].partRequests
|
|
.length;
|
|
|
|
this.value.items[this.activeWoItemIndex].partRequests.push({
|
|
id: 0,
|
|
concurrency: 0,
|
|
userId: null,
|
|
description: null,
|
|
serials: null,
|
|
partId: null,
|
|
partWarehouseId: null,
|
|
quantity: 1,
|
|
received: null,
|
|
purchaseOrderItemId: null,
|
|
isDirty: true,
|
|
workOrderItemId: this.value.items[this.activeWoItemIndex].id,
|
|
uid: Date.now() //used for error tracking / display
|
|
});
|
|
this.$emit("change");
|
|
this.selectedRow = [{ index: newIndex }];
|
|
this.activeItemIndex = newIndex;
|
|
},
|
|
unDeleteItem() {
|
|
this.value.items[this.activeWoItemIndex].partRequests[
|
|
this.activeItemIndex
|
|
].deleted = false;
|
|
this.setDefaultView();
|
|
},
|
|
deleteItem() {
|
|
this.value.items[this.activeWoItemIndex].partRequests[
|
|
this.activeItemIndex
|
|
].deleted = true;
|
|
this.setDefaultView();
|
|
this.$emit("change");
|
|
},
|
|
setDefaultView: function() {
|
|
//if only one record left then display it otherwise just let the datatable show what the user can click on
|
|
if (this.value.items[this.activeWoItemIndex].partRequests.length == 1) {
|
|
this.selectedRow = [{ index: 0 }];
|
|
this.activeItemIndex = 0;
|
|
} else {
|
|
this.selectedRow = [];
|
|
this.activeItemIndex = null; //select nothing in essence resetting a child selects and this one too clearing form
|
|
}
|
|
},
|
|
handleRowClick: function(item) {
|
|
this.activeItemIndex = item.index;
|
|
this.selectedRow = [{ index: item.index }];
|
|
},
|
|
form() {
|
|
return window.$gz.form;
|
|
},
|
|
fieldValueChanged(ref) {
|
|
if (!this.formState.loading && !this.formState.readonly) {
|
|
//flag this record dirty so it gets picked up by save
|
|
this.value.items[this.activeWoItemIndex].partRequests[
|
|
this.activeItemIndex
|
|
].isDirty = true;
|
|
window.$gz.form.fieldValueChanged(this.pvm, ref);
|
|
}
|
|
},
|
|
itemRowClasses: function(item) {
|
|
let ret = "";
|
|
const isDeleted =
|
|
this.value.items[this.activeWoItemIndex].partRequests[item.index]
|
|
.deleted === true;
|
|
|
|
const hasError = this.form().childRowHasError(
|
|
this,
|
|
`Items[${this.activeWoItemIndex}].PartRequests[${item.index}].`
|
|
);
|
|
|
|
if (isDeleted) {
|
|
ret += this.form().tableRowDeletedClass();
|
|
}
|
|
if (hasError) {
|
|
ret += this.form().tableRowErrorClass();
|
|
}
|
|
return ret;
|
|
}
|
|
//---
|
|
},
|
|
computed: {
|
|
isDeleted: function() {
|
|
if (
|
|
this.value.items[this.activeWoItemIndex].partRequests[
|
|
this.activeItemIndex
|
|
] == null
|
|
) {
|
|
this.setDefaultView();
|
|
return true;
|
|
}
|
|
return (
|
|
this.value.items[this.activeWoItemIndex].partRequests[
|
|
this.activeItemIndex
|
|
].deleted === true
|
|
);
|
|
},
|
|
parentDeleted: function() {
|
|
return this.value.items[this.activeWoItemIndex].deleted === true;
|
|
},
|
|
|
|
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 = [];
|
|
|
|
if (this.form().showMe(this, "WorkOrderItemPartRequestPartID")) {
|
|
headers.push({
|
|
text: this.$ay.t("WorkOrderItemPartRequestPartID"),
|
|
align: "left",
|
|
value: "partViz"
|
|
});
|
|
}
|
|
|
|
if (this.form().showMe(this, "WorkOrderItemPartRequestPartWarehouseID")) {
|
|
headers.push({
|
|
text: this.$ay.t("WorkOrderItemPartRequestPartWarehouseID"),
|
|
align: "left",
|
|
value: "partWarehouseViz"
|
|
});
|
|
}
|
|
|
|
if (this.form().showMe(this, "WorkOrderItemPartRequestQuantity")) {
|
|
headers.push({
|
|
text: this.$ay.t("WorkOrderItemPartRequestQuantity"),
|
|
align: "right",
|
|
value: "quantity"
|
|
});
|
|
}
|
|
|
|
if (this.form().showMe(this, "PartRequestPartUPC")) {
|
|
headers.push({
|
|
text: this.$ay.t("PartUPC"),
|
|
align: "left",
|
|
value: "upcViz"
|
|
});
|
|
}
|
|
|
|
if (this.form().showMe(this, "WorkOrderItemPartRequestPurchaseOrder")) {
|
|
headers.push({
|
|
text: this.$ay.t("PurchaseOrder"),
|
|
align: "left",
|
|
value: "purchaseOrderViz"
|
|
});
|
|
}
|
|
|
|
if (this.form().showMe(this, "WorkOrderItemPartRequestOrderedDate")) {
|
|
headers.push({
|
|
text: this.$ay.t("PurchaseOrderOrderedDate"),
|
|
align: "right",
|
|
value: "purchaseOrderDateViz"
|
|
});
|
|
}
|
|
|
|
if (
|
|
this.form().showMe(this, "WorkOrderItemPartRequestExpectedReceiveDate")
|
|
) {
|
|
headers.push({
|
|
text: this.$ay.t("PurchaseOrderExpectedReceiveDate"),
|
|
align: "right",
|
|
value: "purchaseOrderExpectedDateViz"
|
|
});
|
|
}
|
|
|
|
if (this.form().showMe(this, "WorkOrderItemPartRequestOnOrder")) {
|
|
headers.push({
|
|
text: this.$ay.t("WorkOrderItemPartRequestOnOrder"),
|
|
value: "purchaseOrderOnOrderViz"
|
|
});
|
|
}
|
|
|
|
if (this.form().showMe(this, "WorkOrderItemPartRequestReceived")) {
|
|
headers.push({
|
|
text: this.$ay.t("WorkOrderItemPartRequestReceived"),
|
|
align: "right",
|
|
value: "received"
|
|
});
|
|
}
|
|
|
|
return headers;
|
|
},
|
|
itemList: function() {
|
|
return this.value.items[this.activeWoItemIndex].partRequests.map(
|
|
(x, i) => {
|
|
return {
|
|
index: i,
|
|
id: x.id,
|
|
partViz: x.partViz,
|
|
partWarehouseViz: x.partWarehouseViz,
|
|
quantity: window.$gz.locale.decimalLocalized(
|
|
x.quantity,
|
|
this.pvm.languageName
|
|
),
|
|
upcViz: x.upcViz,
|
|
purchaseOrderViz: x.purchaseOrderViz,
|
|
purchaseOrderIdViz: x.purchaseOrderIdViz,
|
|
purchaseOrderDateViz: window.$gz.locale.utcDateToShortDateAndTimeLocalized(
|
|
x.purchaseOrderDateViz,
|
|
this.pvm.timeZoneName,
|
|
this.pvm.languageName,
|
|
this.pvm.hour12
|
|
),
|
|
purchaseOrderExpectedDateViz: window.$gz.locale.utcDateToShortDateAndTimeLocalized(
|
|
x.purchaseOrderExpectedDateViz,
|
|
this.pvm.timeZoneName,
|
|
this.pvm.languageName,
|
|
this.pvm.hour12
|
|
),
|
|
purchaseOrderOnOrderViz: x.purchaseOrderOnOrderViz,
|
|
received: window.$gz.locale.decimalLocalized(
|
|
x.received,
|
|
this.pvm.languageName
|
|
)
|
|
};
|
|
}
|
|
);
|
|
},
|
|
formState: function() {
|
|
return this.pvm.formState;
|
|
},
|
|
formCustomTemplateKey: function() {
|
|
return this.pvm.formCustomTemplateKey;
|
|
},
|
|
showTable: function() {
|
|
return this.value.items[this.activeWoItemIndex].partRequests.length > 1;
|
|
},
|
|
canAdd: function() {
|
|
return this.pvm.rights.change && this.pvm.subRights.partRequests.create;
|
|
},
|
|
canDelete: function() {
|
|
return (
|
|
this.activeItemIndex != null &&
|
|
this.pvm.rights.change &&
|
|
this.pvm.subRights.partRequests.delete
|
|
);
|
|
}
|
|
//----
|
|
}
|
|
};
|
|
</script>
|