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-filtering
disable-sort disable-sort
hide-default-footer hide-default-footer
data-cy="partsTable" data-cy="partRequestsTable"
dense dense
:item-class="itemRowClasses" :item-class="itemRowClasses"
@click:row="handleRowClick" @click:row="handleRowClick"
:show-select="$vuetify.breakpoint.xs" :show-select="$vuetify.breakpoint.xs"
single-select single-select
> >
<template v-slot:[`item.purchaseOrderOnOrderViz`]="{ item }">
<v-simple-checkbox
v-model="item.purchaseOrderOnOrderViz"
disabled
></v-simple-checkbox>
</template>
</v-data-table> </v-data-table>
</v-col> </v-col>
</template> </template>
@@ -67,258 +73,6 @@
>{{ $ay.t("Undelete") >{{ $ay.t("Undelete")
}}<v-icon right large>$ayiTrashRestoreAlt</v-icon></v-btn }}<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> </template>
</v-row> </v-row>
</div> </div>
@@ -393,24 +147,20 @@ export default {
}, },
methods: { methods: {
warehouseChange(newName) { warehouseChange(newName) {
this.value.items[this.activeWoItemIndex].parts[ this.value.items[this.activeWoItemIndex].partRequests[
this.activeItemIndex this.activeItemIndex
].partWarehouseViz = newName; ].partWarehouseViz = newName;
}, },
partChange(newName) { partChange(newName) {
this.value.items[this.activeWoItemIndex].parts[ this.value.items[this.activeWoItemIndex].partRequests[
this.activeItemIndex this.activeItemIndex
].partViz = newName; ].partViz = newName;
}, },
taxCodeChange(newName) {
this.value.items[this.activeWoItemIndex].parts[
this.activeItemIndex
].taxPartSaleViz = newName;
},
newItem() { 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, id: 0,
concurrency: 0, concurrency: 0,
userId: null, userId: null,
@@ -419,11 +169,8 @@ export default {
partId: null, partId: null,
partWarehouseId: null, partWarehouseId: null,
quantity: 1, quantity: 1,
taxPartSaleId: null, received: null,
price: 0, purchaseOrderItemId: null,
priceOverride: null,
cost: 0,
listPrice: 0,
isDirty: true, isDirty: true,
workOrderItemId: this.value.items[this.activeWoItemIndex].id, workOrderItemId: this.value.items[this.activeWoItemIndex].id,
uid: Date.now() //used for error tracking / display uid: Date.now() //used for error tracking / display
@@ -433,13 +180,13 @@ export default {
this.activeItemIndex = newIndex; this.activeItemIndex = newIndex;
}, },
unDeleteItem() { unDeleteItem() {
this.value.items[this.activeWoItemIndex].parts[ this.value.items[this.activeWoItemIndex].partRequests[
this.activeItemIndex this.activeItemIndex
].deleted = false; ].deleted = false;
this.setDefaultView(); this.setDefaultView();
}, },
deleteItem() { deleteItem() {
this.value.items[this.activeWoItemIndex].parts[ this.value.items[this.activeWoItemIndex].partRequests[
this.activeItemIndex this.activeItemIndex
].deleted = true; ].deleted = true;
this.setDefaultView(); this.setDefaultView();
@@ -447,7 +194,7 @@ export default {
}, },
setDefaultView: function() { setDefaultView: function() {
//if only one record left then display it otherwise just let the datatable show what the user can click on //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.selectedRow = [{ index: 0 }];
this.activeItemIndex = 0; this.activeItemIndex = 0;
} else { } else {
@@ -465,7 +212,7 @@ export default {
fieldValueChanged(ref) { fieldValueChanged(ref) {
if (!this.formState.loading && !this.formState.readonly) { if (!this.formState.loading && !this.formState.readonly) {
//flag this record dirty so it gets picked up by save //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 this.activeItemIndex
].isDirty = true; ].isDirty = true;
window.$gz.form.fieldValueChanged(this.pvm, ref); window.$gz.form.fieldValueChanged(this.pvm, ref);
@@ -474,12 +221,12 @@ export default {
itemRowClasses: function(item) { itemRowClasses: function(item) {
let ret = ""; let ret = "";
const isDeleted = const isDeleted =
this.value.items[this.activeWoItemIndex].parts[item.index].deleted === this.value.items[this.activeWoItemIndex].partRequests[item.index]
true; .deleted === true;
const hasError = this.form().childRowHasError( const hasError = this.form().childRowHasError(
this, this,
`Items[${this.activeWoItemIndex}].Parts[${item.index}].` `Items[${this.activeWoItemIndex}].PartRequests[${item.index}].`
); );
if (isDeleted) { if (isDeleted) {
@@ -495,15 +242,17 @@ export default {
computed: { computed: {
isDeleted: function() { isDeleted: function() {
if ( if (
this.value.items[this.activeWoItemIndex].parts[this.activeItemIndex] == this.value.items[this.activeWoItemIndex].partRequests[
null this.activeItemIndex
] == null
) { ) {
this.setDefaultView(); this.setDefaultView();
return true; return true;
} }
return ( return (
this.value.items[this.activeWoItemIndex].parts[this.activeItemIndex] this.value.items[this.activeWoItemIndex].partRequests[
.deleted === true this.activeItemIndex
].deleted === true
); );
}, },
parentDeleted: function() { parentDeleted: function() {
@@ -593,35 +342,40 @@ export default {
return headers; return headers;
}, },
itemList: function() { itemList: function() {
return this.value.items[this.activeWoItemIndex].parts.map((x, i) => { return this.value.items[this.activeWoItemIndex].partRequests.map(
return { (x, i) => {
index: i, return {
id: x.id, index: i,
partViz: x.partViz, id: x.id,
partWarehouseViz: x.partWarehouseViz, partViz: x.partViz,
quantity: window.$gz.locale.decimalLocalized( partWarehouseViz: x.partWarehouseViz,
x.quantity, quantity: window.$gz.locale.decimalLocalized(
this.pvm.languageName x.quantity,
), this.pvm.languageName
upcViz: x.upcViz, ),
purchaseOrderViz: x.purchaseOrderViz, upcViz: x.upcViz,
purchaseOrderIdViz: x.purchaseOrderIdViz, purchaseOrderViz: x.purchaseOrderViz,
purchaseOrderDateViz: window.$gz.locale.utcDateToShortDateAndTimeLocalized( purchaseOrderIdViz: x.purchaseOrderIdViz,
x.purchaseOrderDateViz, purchaseOrderDateViz: window.$gz.locale.utcDateToShortDateAndTimeLocalized(
this.pvm.timeZoneName, x.purchaseOrderDateViz,
this.pvm.languageName, this.pvm.timeZoneName,
this.pvm.hour12 this.pvm.languageName,
), this.pvm.hour12
purchaseOrderExpectedDateViz: window.$gz.locale.utcDateToShortDateAndTimeLocalized( ),
x.purchaseOrderExpectedDateViz, purchaseOrderExpectedDateViz: window.$gz.locale.utcDateToShortDateAndTimeLocalized(
this.pvm.timeZoneName, x.purchaseOrderExpectedDateViz,
this.pvm.languageName, this.pvm.timeZoneName,
this.pvm.hour12 this.pvm.languageName,
), this.pvm.hour12
purchaseOrderOnOrderViz: x.purchaseOrderOnOrderViz, ),
received: x.received purchaseOrderOnOrderViz: x.purchaseOrderOnOrderViz,
}; received: window.$gz.locale.decimalLocalized(
}); x.received,
this.pvm.languageName
)
};
}
);
}, },
formState: function() { formState: function() {
return this.pvm.formState; return this.pvm.formState;
@@ -630,16 +384,16 @@ export default {
return this.pvm.formCustomTemplateKey; return this.pvm.formCustomTemplateKey;
}, },
showTable: function() { showTable: function() {
return this.value.items[this.activeWoItemIndex].parts.length > 1; return this.value.items[this.activeWoItemIndex].partRequests.length > 1;
}, },
canAdd: function() { canAdd: function() {
return this.pvm.rights.change && this.pvm.subRights.parts.create; return this.pvm.rights.change && this.pvm.subRights.partRequests.create;
}, },
canDelete: function() { canDelete: function() {
return ( return (
this.activeItemIndex != null && this.activeItemIndex != null &&
this.pvm.rights.change && this.pvm.rights.change &&
this.pvm.subRights.parts.delete this.pvm.subRights.partRequests.delete
); );
} }
//---- //----