This commit is contained in:
2021-05-26 21:31:31 +00:00
parent ab0df7eeaf
commit 31451efde0

View File

@@ -48,13 +48,19 @@
disable-filtering
disable-sort
hide-default-footer
data-cy="partsTable"
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>
@@ -67,258 +73,6 @@
>{{ $ay.t("Undelete")
}}<v-icon right large>$ayiTrashRestoreAlt</v-icon></v-btn
>
<v-col
v-if="form().showMe(this, 'WorkOrderItemPartQuantity')"
cols="12"
sm="6"
lg="4"
xl="3"
>
<gz-decimal
v-model="
value.items[activeWoItemIndex].parts[activeItemIndex].quantity
"
:readonly="formState.readOnly || isDeleted"
:disabled="isDeleted"
:label="$ay.t('WorkOrderItemPartQuantity')"
:ref="
`Items[${activeWoItemIndex}].parts[${activeItemIndex}].quantity`
"
data-cy="partQuantity"
:error-messages="
form().serverErrors(
this,
`Items[${activeWoItemIndex}].parts[${activeItemIndex}].quantity`
)
"
:rules="[
form().decimalValid(
this,
`Items[${activeWoItemIndex}].parts[${activeItemIndex}].quantity`
),
form().required(
this,
`Items[${activeWoItemIndex}].parts[${activeItemIndex}].quantity`
)
]"
@input="
fieldValueChanged(`Items[${activeWoItemIndex}].parts[
${activeItemIndex}
].quantity`)
"
></gz-decimal>
</v-col>
<v-col
v-if="form().showMe(this, 'WorkOrderItemPartPartID')"
cols="12"
sm="6"
lg="4"
xl="3"
>
<gz-pick-list
:aya-type="$ay.ayt().Part"
:show-edit-icon="true"
v-model="
value.items[activeWoItemIndex].parts[activeItemIndex].partId
"
:readonly="formState.readOnly || isDeleted"
:disabled="isDeleted"
:label="$ay.t('WorkOrderItemPartPartID')"
:ref="
`Items[${activeWoItemIndex}].parts[${activeItemIndex}].partId`
"
data-cy="parts.partId"
:error-messages="
form().serverErrors(
this,
`Items[${activeWoItemIndex}].parts[${activeItemIndex}].partId`
)
"
@input="
fieldValueChanged(
`Items[${activeWoItemIndex}].parts[${activeItemIndex}].partId`
)
"
@update:name="partChange"
></gz-pick-list>
</v-col>
<v-col
v-if="form().showMe(this, 'WorkOrderItemPartPartWarehouseID')"
cols="12"
sm="6"
lg="4"
xl="3"
>
<gz-pick-list
:aya-type="$ay.ayt().PartWarehouse"
:show-edit-icon="true"
v-model="
value.items[activeWoItemIndex].parts[activeItemIndex]
.partWarehouseId
"
:readonly="formState.readOnly || isDeleted"
:disabled="isDeleted"
:label="$ay.t('WorkOrderItemPartPartWarehouseID')"
:ref="
`Items[${activeWoItemIndex}].parts[${activeItemIndex}].partWarehouseId`
"
data-cy="parts.partWarehouseId"
:error-messages="
form().serverErrors(
this,
`Items[${activeWoItemIndex}].parts[${activeItemIndex}].partWarehouseId`
)
"
@input="
fieldValueChanged(
`Items[${activeWoItemIndex}].parts[${activeItemIndex}].partWarehouseId`
)
"
@update:name="warehouseChange"
></gz-pick-list>
</v-col>
<v-col
v-if="form().showMe(this, 'WorkOrderItemPartDescription')"
cols="12"
sm="6"
lg="4"
xl="3"
>
<v-text-field
v-model="
value.items[activeWoItemIndex].parts[activeItemIndex].description
"
:readonly="formState.readOnly || isDeleted"
:disabled="isDeleted"
:label="$ay.t('WorkOrderItemPartDescription')"
:ref="
`Items[${activeWoItemIndex}].parts[${activeItemIndex}].description`
"
data-cy="partQuantity"
:error-messages="
form().serverErrors(
this,
`Items[${activeWoItemIndex}].parts[${activeItemIndex}].description`
)
"
@input="
fieldValueChanged(`Items[${activeWoItemIndex}].parts[
${activeItemIndex}
].description`)
"
></v-text-field>
</v-col>
<v-col
v-if="form().showMe(this, 'WorkOrderItemPartTaxPartSaleID')"
cols="12"
sm="6"
lg="4"
xl="3"
>
<gz-pick-list
:aya-type="$ay.ayt().TaxCode"
:show-edit-icon="true"
v-model="
value.items[activeWoItemIndex].parts[activeItemIndex]
.taxPartSaleId
"
:readonly="formState.readOnly || isDeleted"
:disabled="isDeleted"
:label="$ay.t('WorkOrderItemPartTaxPartSaleID')"
:ref="
`Items[${activeWoItemIndex}].parts[${activeItemIndex}].taxPartSaleId`
"
data-cy="partTaxCodeSaleId"
:error-messages="
form().serverErrors(
this,
`Items[${activeWoItemIndex}].parts[${activeItemIndex}].taxPartSaleId`
)
"
@input="
fieldValueChanged(
`Items[${activeWoItemIndex}].parts[${activeItemIndex}].taxPartSaleId`
)
"
@update:name="taxCodeChange"
></gz-pick-list>
</v-col>
<v-col
v-if="form().showMe(this, 'PartPriceOverride')"
cols="12"
sm="6"
lg="4"
xl="3"
>
<gz-currency
v-model="
value.items[activeWoItemIndex].parts[activeItemIndex]
.priceOverride
"
can-clear
:readonly="formState.readOnly || isDeleted"
:disabled="isDeleted"
:label="$ay.t('PriceOverride')"
:ref="
`Items[${activeWoItemIndex}].parts[${activeItemIndex}].priceOverride`
"
data-cy="partpriceoverride"
:error-messages="
form().serverErrors(
this,
`Items[${activeWoItemIndex}].parts[${activeItemIndex}].priceOverride`
)
"
:rules="[
form().decimalValid(
this,
`Items[${activeWoItemIndex}].parts[${activeItemIndex}].priceOverride`
)
]"
@input="
fieldValueChanged(`Items[${activeWoItemIndex}].parts[
${activeItemIndex}
].priceOverride`)
"
></gz-currency>
</v-col>
<v-col v-if="form().showMe(this, 'WorkOrderItemPartSerials')" cols="12">
<v-textarea
v-model="
value.items[activeWoItemIndex].parts[activeItemIndex].serials
"
:readonly="formState.readOnly"
:disabled="isDeleted"
:label="$ay.t('PurchaseOrderItemSerialNumbers')"
:error-messages="
form().serverErrors(
this,
`Items[${activeWoItemIndex}].parts[
${activeItemIndex}
].serials`
)
"
:ref="
`Items[${activeWoItemIndex}].parts[
${activeItemIndex}
].serials`
"
data-cy="partSerials"
@input="
fieldValueChanged(`Items[${activeWoItemIndex}].parts[
${activeItemIndex}
].serials`)
"
auto-grow
></v-textarea>
</v-col>
</template>
</v-row>
</div>
@@ -393,24 +147,20 @@ export default {
},
methods: {
warehouseChange(newName) {
this.value.items[this.activeWoItemIndex].parts[
this.value.items[this.activeWoItemIndex].partRequests[
this.activeItemIndex
].partWarehouseViz = newName;
},
partChange(newName) {
this.value.items[this.activeWoItemIndex].parts[
this.value.items[this.activeWoItemIndex].partRequests[
this.activeItemIndex
].partViz = newName;
},
taxCodeChange(newName) {
this.value.items[this.activeWoItemIndex].parts[
this.activeItemIndex
].taxPartSaleViz = newName;
},
newItem() {
let newIndex = this.value.items[this.activeWoItemIndex].parts.length;
let newIndex = this.value.items[this.activeWoItemIndex].partRequests
.length;
this.value.items[this.activeWoItemIndex].parts.push({
this.value.items[this.activeWoItemIndex].partRequests.push({
id: 0,
concurrency: 0,
userId: null,
@@ -419,11 +169,8 @@ export default {
partId: null,
partWarehouseId: null,
quantity: 1,
taxPartSaleId: null,
price: 0,
priceOverride: null,
cost: 0,
listPrice: 0,
received: null,
purchaseOrderItemId: null,
isDirty: true,
workOrderItemId: this.value.items[this.activeWoItemIndex].id,
uid: Date.now() //used for error tracking / display
@@ -433,13 +180,13 @@ export default {
this.activeItemIndex = newIndex;
},
unDeleteItem() {
this.value.items[this.activeWoItemIndex].parts[
this.value.items[this.activeWoItemIndex].partRequests[
this.activeItemIndex
].deleted = false;
this.setDefaultView();
},
deleteItem() {
this.value.items[this.activeWoItemIndex].parts[
this.value.items[this.activeWoItemIndex].partRequests[
this.activeItemIndex
].deleted = true;
this.setDefaultView();
@@ -447,7 +194,7 @@ export default {
},
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].parts.length == 1) {
if (this.value.items[this.activeWoItemIndex].partRequests.length == 1) {
this.selectedRow = [{ index: 0 }];
this.activeItemIndex = 0;
} else {
@@ -465,7 +212,7 @@ export default {
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].parts[
this.value.items[this.activeWoItemIndex].partRequests[
this.activeItemIndex
].isDirty = true;
window.$gz.form.fieldValueChanged(this.pvm, ref);
@@ -474,12 +221,12 @@ export default {
itemRowClasses: function(item) {
let ret = "";
const isDeleted =
this.value.items[this.activeWoItemIndex].parts[item.index].deleted ===
true;
this.value.items[this.activeWoItemIndex].partRequests[item.index]
.deleted === true;
const hasError = this.form().childRowHasError(
this,
`Items[${this.activeWoItemIndex}].Parts[${item.index}].`
`Items[${this.activeWoItemIndex}].PartRequests[${item.index}].`
);
if (isDeleted) {
@@ -495,15 +242,17 @@ export default {
computed: {
isDeleted: function() {
if (
this.value.items[this.activeWoItemIndex].parts[this.activeItemIndex] ==
null
this.value.items[this.activeWoItemIndex].partRequests[
this.activeItemIndex
] == null
) {
this.setDefaultView();
return true;
}
return (
this.value.items[this.activeWoItemIndex].parts[this.activeItemIndex]
.deleted === true
this.value.items[this.activeWoItemIndex].partRequests[
this.activeItemIndex
].deleted === true
);
},
parentDeleted: function() {
@@ -593,35 +342,40 @@ export default {
return headers;
},
itemList: function() {
return this.value.items[this.activeWoItemIndex].parts.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: x.received
};
});
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;
@@ -630,16 +384,16 @@ export default {
return this.pvm.formCustomTemplateKey;
},
showTable: function() {
return this.value.items[this.activeWoItemIndex].parts.length > 1;
return this.value.items[this.activeWoItemIndex].partRequests.length > 1;
},
canAdd: function() {
return this.pvm.rights.change && this.pvm.subRights.parts.create;
return this.pvm.rights.change && this.pvm.subRights.partRequests.create;
},
canDelete: function() {
return (
this.activeItemIndex != null &&
this.pvm.rights.change &&
this.pvm.subRights.parts.delete
this.pvm.subRights.partRequests.delete
);
}
//----