Files
raven-client/ayanova/src/components/work-order-item-outside-services.vue
2021-05-27 20:00:48 +00:00

1107 lines
37 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"
>$ayiLuggageCart</v-icon
>
{{ $ay.t("WorkOrderItemOutsideServiceList") }}
<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="outsideServicesTable"
dense
:item-class="itemRowClasses"
@click:row="handleRowClick"
:show-select="$vuetify.breakpoint.xs"
single-select
>
</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
>
<v-col
v-if="form().showMe(this, 'WorkOrderItemOutsideServiceUnit')"
cols="12"
sm="6"
lg="4"
xl="3"
>
<gz-pick-list
:aya-type="$ay.ayt().Unit"
:show-edit-icon="true"
v-model="
value.items[activeWoItemIndex].outsideServices[activeItemIndex]
.unitId
"
:readonly="formState.readOnly || isDeleted"
:disabled="isDeleted"
:label="$ay.t('Unit')"
:ref="
`Items[${activeWoItemIndex}].outsideServices[${activeItemIndex}].unitId`
"
data-cy="outsideServices.unitId"
:error-messages="
form().serverErrors(
this,
`Items[${activeWoItemIndex}].outsideServices[${activeItemIndex}].unitId`
)
"
@input="
fieldValueChanged(
`Items[${activeWoItemIndex}].outsideServices[${activeItemIndex}].unitId`
)
"
@update:name="unitChange"
></gz-pick-list>
</v-col>
<v-col
v-if="
form().showMe(this, 'WorkOrderItemOutsideServiceVendorSentToID')
"
cols="12"
sm="6"
lg="4"
xl="3"
>
<gz-pick-list
:aya-type="$ay.ayt().Vendor"
:show-edit-icon="true"
v-model="
value.items[activeWoItemIndex].outsideServices[activeItemIndex]
.vendorSentToId
"
:readonly="formState.readOnly || isDeleted"
:disabled="isDeleted"
:label="$ay.t('WorkOrderItemOutsideServiceVendorSentToID')"
:ref="
`Items[${activeWoItemIndex}].outsideServices[${activeItemIndex}].vendorSentToId`
"
data-cy="outsideServices.vendorSentToId"
:error-messages="
form().serverErrors(
this,
`Items[${activeWoItemIndex}].outsideServices[${activeItemIndex}].vendorSentToId`
)
"
@input="
fieldValueChanged(
`Items[${activeWoItemIndex}].outsideServices[${activeItemIndex}].vendorSentToId`
)
"
@update:name="vendorSentToChange"
></gz-pick-list>
</v-col>
<v-col
v-if="form().showMe(this, 'WorkOrderItemOutsideServiceRMANumber')"
cols="12"
sm="6"
lg="4"
xl="3"
>
<v-text-field
v-model="
value.items[activeWoItemIndex].outsideServices[activeItemIndex]
.rmaNumber
"
:readonly="formState.readOnly"
:disabled="isDeleted"
:label="$ay.t('WorkOrderItemOutsideServiceRMANumber')"
:ref="
`Items[${activeWoItemIndex}].outsideServices[
${activeItemIndex}
].rmaNumber`
"
:error-messages="
form().serverErrors(
this,
`Items[${activeWoItemIndex}].outsideServices[
${activeItemIndex}
].rmaNumber`
)
"
@input="
fieldValueChanged(`Items[${activeWoItemIndex}].outsideServices[
${activeItemIndex}
].rmaNumber`)
"
></v-text-field>
</v-col>
<v-col
v-if="form().showMe(this, 'WorkOrderItemOutsideServiceRepairCost')"
cols="12"
sm="6"
lg="4"
xl="3"
>
<gz-currency
v-model="
value.items[activeWoItemIndex].outsideServices[activeItemIndex]
.repairCost
"
can-clear
:readonly="formState.readOnly || isDeleted"
:disabled="isDeleted"
:label="$ay.t('WorkOrderItemOutsideServiceRepairCost')"
:ref="
`Items[${activeWoItemIndex}].outsideServices[${activeItemIndex}].repairCost`
"
data-cy="outsideServicepriceoverride"
:error-messages="
form().serverErrors(
this,
`Items[${activeWoItemIndex}].outsideServices[${activeItemIndex}].repairCost`
)
"
:rules="[
form().decimalValid(
this,
`Items[${activeWoItemIndex}].outsideServices[${activeItemIndex}].repairCost`
)
]"
@input="
fieldValueChanged(`Items[${activeWoItemIndex}].outsideServices[
${activeItemIndex}
].repairCost`)
"
></gz-currency>
</v-col>
<v-col
v-if="form().showMe(this, 'WorkOrderItemOutsideServiceRepairPrice')"
cols="12"
sm="6"
lg="4"
xl="3"
>
<gz-currency
v-model="
value.items[activeWoItemIndex].outsideServices[activeItemIndex]
.repairPrice
"
can-clear
:readonly="formState.readOnly || isDeleted"
:disabled="isDeleted"
:label="$ay.t('WorkOrderItemOutsideServiceRepairPrice')"
:ref="
`Items[${activeWoItemIndex}].outsideServices[${activeItemIndex}].repairPrice`
"
data-cy="outsideServicepriceoverride"
:error-messages="
form().serverErrors(
this,
`Items[${activeWoItemIndex}].outsideServices[${activeItemIndex}].repairPrice`
)
"
:rules="[
form().decimalValid(
this,
`Items[${activeWoItemIndex}].outsideServices[${activeItemIndex}].repairPrice`
)
]"
@input="
fieldValueChanged(`Items[${activeWoItemIndex}].outsideServices[
${activeItemIndex}
].repairPrice`)
"
></gz-currency>
</v-col>
<v-col
v-if="
form().showMe(this, 'WorkOrderItemOutsideServiceVendorSentViaID')
"
cols="12"
sm="6"
lg="4"
xl="3"
>
<gz-pick-list
:aya-type="$ay.ayt().Vendor"
:show-edit-icon="true"
v-model="
value.items[activeWoItemIndex].outsideServices[activeItemIndex]
.vendorSentViaId
"
:readonly="formState.readOnly || isDeleted"
:disabled="isDeleted"
:label="$ay.t('WorkOrderItemOutsideServiceVendorSentViaID')"
:ref="
`Items[${activeWoItemIndex}].outsideServices[${activeItemIndex}].vendorSentViaId`
"
data-cy="outsideServices.vendorSentViaId"
:error-messages="
form().serverErrors(
this,
`Items[${activeWoItemIndex}].outsideServices[${activeItemIndex}].vendorSentViaId`
)
"
@input="
fieldValueChanged(
`Items[${activeWoItemIndex}].outsideServices[${activeItemIndex}].vendorSentViaId`
)
"
@update:name="vendorSentViaChange"
></gz-pick-list>
</v-col>
<v-col
v-if="
form().showMe(this, 'WorkOrderItemOutsideServiceTrackingNumber')
"
cols="12"
sm="6"
lg="4"
xl="3"
>
<v-text-field
v-model="
value.items[activeWoItemIndex].outsideServices[activeItemIndex]
.trackingNumber
"
:readonly="formState.readOnly"
:disabled="isDeleted"
:label="$ay.t('WorkOrderItemOutsideServiceTrackingNumber')"
:ref="
`Items[${activeWoItemIndex}].outsideServices[
${activeItemIndex}
].trackingNumber`
"
:error-messages="
form().serverErrors(
this,
`Items[${activeWoItemIndex}].outsideServices[
${activeItemIndex}
].trackingNumber`
)
"
@input="
fieldValueChanged(`Items[${activeWoItemIndex}].outsideServices[
${activeItemIndex}
].trackingNumber`)
"
></v-text-field>
</v-col>
<v-col
v-if="form().showMe(this, 'WorkOrderItemOutsideServiceShippingCost')"
cols="12"
sm="6"
lg="4"
xl="3"
>
<gz-currency
v-model="
value.items[activeWoItemIndex].outsideServices[activeItemIndex]
.shippingCost
"
can-clear
:readonly="formState.readOnly || isDeleted"
:disabled="isDeleted"
:label="$ay.t('WorkOrderItemOutsideServiceShippingCost')"
:ref="
`Items[${activeWoItemIndex}].outsideServices[${activeItemIndex}].shippingCost`
"
data-cy="outsideServicepriceoverride"
:error-messages="
form().serverErrors(
this,
`Items[${activeWoItemIndex}].outsideServices[${activeItemIndex}].shippingCost`
)
"
:rules="[
form().decimalValid(
this,
`Items[${activeWoItemIndex}].outsideServices[${activeItemIndex}].shippingCost`
)
]"
@input="
fieldValueChanged(`Items[${activeWoItemIndex}].outsideServices[
${activeItemIndex}
].shippingCost`)
"
></gz-currency>
</v-col>
<v-col
v-if="form().showMe(this, 'WorkOrderItemOutsideServiceShippingPrice')"
cols="12"
sm="6"
lg="4"
xl="3"
>
<gz-currency
v-model="
value.items[activeWoItemIndex].outsideServices[activeItemIndex]
.shippingPrice
"
can-clear
:readonly="formState.readOnly || isDeleted"
:disabled="isDeleted"
:label="$ay.t('WorkOrderItemOutsideServiceShippingPrice')"
:ref="
`Items[${activeWoItemIndex}].outsideServices[${activeItemIndex}].shippingPrice`
"
data-cy="outsideServicepriceoverride"
:error-messages="
form().serverErrors(
this,
`Items[${activeWoItemIndex}].outsideServices[${activeItemIndex}].shippingPrice`
)
"
:rules="[
form().decimalValid(
this,
`Items[${activeWoItemIndex}].outsideServices[${activeItemIndex}].shippingPrice`
)
]"
@input="
fieldValueChanged(`Items[${activeWoItemIndex}].outsideServices[
${activeItemIndex}
].shippingPrice`)
"
></gz-currency>
</v-col>
<v-col
v-if="form().showMe(this, 'WorkOrderItemOutsideServiceDateSent')"
cols="12"
sm="6"
lg="4"
xl="3"
>
<gz-date-time-picker
:label="$ay.t('WorkOrderItemOutsideServiceDateSent')"
v-model="
value.items[activeWoItemIndex].outsideServices[activeItemIndex]
.sentDate
"
:readonly="formState.readOnly"
:disabled="isDeleted"
:ref="
`Items[${activeWoItemIndex}].outsideServices[${activeItemIndex}].sentDate`
"
data-cy="outsideServiceSentDate"
:error-messages="
form().serverErrors(
this,
`Items[${activeWoItemIndex}].outsideServices[${activeItemIndex}].sentDate`
)
"
@input="
fieldValueChanged(
`Items[${activeWoItemIndex}].outsideServices[${activeItemIndex}].sentDate`
)
"
></gz-date-time-picker>
</v-col>
<v-col
v-if="form().showMe(this, 'WorkOrderItemOutsideServiceDateETA')"
cols="12"
sm="6"
lg="4"
xl="3"
>
<gz-date-time-picker
:label="$ay.t('WorkOrderItemOutsideServiceDateETA')"
v-model="
value.items[activeWoItemIndex].outsideServices[activeItemIndex]
.etaDate
"
:readonly="formState.readOnly"
:disabled="isDeleted"
:ref="
`Items[${activeWoItemIndex}].outsideServices[${activeItemIndex}].etaDate`
"
data-cy="outsideServiceEtaDate"
:error-messages="
form().serverErrors(
this,
`Items[${activeWoItemIndex}].outsideServices[${activeItemIndex}].etaDate`
)
"
@input="
fieldValueChanged(
`Items[${activeWoItemIndex}].outsideServices[${activeItemIndex}].etaDate`
)
"
></gz-date-time-picker>
</v-col>
<v-col
v-if="form().showMe(this, 'WorkOrderItemOutsideServiceDateReturned')"
cols="12"
sm="6"
lg="4"
xl="3"
>
<gz-date-time-picker
:label="$ay.t('WorkOrderItemOutsideServiceDateReturned')"
v-model="
value.items[activeWoItemIndex].outsideServices[activeItemIndex]
.returnDate
"
:readonly="formState.readOnly"
:disabled="isDeleted"
:ref="
`Items[${activeWoItemIndex}].outsideServices[${activeItemIndex}].returnDate`
"
data-cy="outsideServiceDateReturned"
:error-messages="
form().serverErrors(
this,
`Items[${activeWoItemIndex}].outsideServices[${activeItemIndex}].returnDate`
)
"
@input="
fieldValueChanged(
`Items[${activeWoItemIndex}].outsideServices[${activeItemIndex}].returnDate`
)
"
></gz-date-time-picker>
</v-col>
<v-col
v-if="form().showMe(this, 'WorkOrderItemOutsideServiceTaxCode')"
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].outsideServices[activeItemIndex]
.taxCodeId
"
:readonly="formState.readOnly || isDeleted"
:disabled="isDeleted"
:label="$ay.t('TaxCode')"
:ref="
`Items[${activeWoItemIndex}].outsideServices[${activeItemIndex}].taxCodeId`
"
data-cy="outsideServiceTaxCodeSaleId"
:error-messages="
form().serverErrors(
this,
`Items[${activeWoItemIndex}].outsideServices[${activeItemIndex}].taxCodeId`
)
"
@input="
fieldValueChanged(
`Items[${activeWoItemIndex}].outsideServices[${activeItemIndex}].taxCodeId`
)
"
@update:name="taxCodeChange"
></gz-pick-list>
</v-col>
<v-col
v-if="form().showMe(this, 'WorkOrderItemOutsideServiceNotes')"
cols="12"
>
<v-textarea
v-model="
value.items[activeWoItemIndex].outsideServices[activeItemIndex]
.notes
"
:readonly="formState.readOnly"
:disabled="isDeleted"
:label="$ay.t('WorkOrderItemOutsideServiceNotes')"
:error-messages="
form().serverErrors(
this,
`Items[${activeWoItemIndex}].outsideServices[
${activeItemIndex}
].notes`
)
"
:ref="
`Items[${activeWoItemIndex}].outsideServices[
${activeItemIndex}
].notes`
"
data-cy="outsideServiceNotes"
@input="
fieldValueChanged(`Items[${activeWoItemIndex}].outsideServices[
${activeItemIndex}
].notes`)
"
auto-grow
></v-textarea>
</v-col>
</template>
</v-row>
</div>
</template>
<script>
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
/* XXXeslint-disable */
////////////////////////////////////////////////////////////////////////////////////////////////////////////
/*
//WORKORDER ITEM OUTSIDE SERVICES
l.Add(new FormField { TKey = "WorkOrderItemOutsideServiceNotes", FieldKey = "WorkOrderItemOutsideServiceNotes", TKeySection = "WorkOrderItemOutsideServices" });
l.Add(new FormField { TKey = "Unit", FieldKey = "WorkOrderItemOutsideServiceUnit", TKeySection = "WorkOrderItemOutsideServices" });
l.Add(new FormField { TKey = "WorkOrderItemOutsideServiceVendorSentToID", FieldKey = "WorkOrderItemOutsideServiceVendorSentToID", TKeySection = "WorkOrderItemOutsideServices" });
l.Add(new FormField { TKey = "WorkOrderItemOutsideServiceVendorSentViaID", FieldKey = "WorkOrderItemOutsideServiceVendorSentViaID", TKeySection = "WorkOrderItemOutsideServices" });
l.Add(new FormField { TKey = "WorkOrderItemOutsideServiceRMANumber", FieldKey = "WorkOrderItemOutsideServiceRMANumber", TKeySection = "WorkOrderItemOutsideServices" });
l.Add(new FormField { TKey = "WorkOrderItemOutsideServiceTrackingNumber", FieldKey = "WorkOrderItemOutsideServiceTrackingNumber", TKeySection = "WorkOrderItemOutsideServices" });
l.Add(new FormField { TKey = "WorkOrderItemOutsideServiceRepairCost", FieldKey = "WorkOrderItemOutsideServiceRepairCost", TKeySection = "WorkOrderItemOutsideServices" });
l.Add(new FormField { TKey = "WorkOrderItemOutsideServiceRepairPrice", FieldKey = "WorkOrderItemOutsideServiceRepairPrice", TKeySection = "WorkOrderItemOutsideServices" });
l.Add(new FormField { TKey = "WorkOrderItemOutsideServiceShippingCost", FieldKey = "WorkOrderItemOutsideServiceShippingCost", TKeySection = "WorkOrderItemOutsideServices" });
l.Add(new FormField { TKey = "WorkOrderItemOutsideServiceShippingPrice", FieldKey = "WorkOrderItemOutsideServiceShippingPrice", TKeySection = "WorkOrderItemOutsideServices" });
l.Add(new FormField { TKey = "WorkOrderItemOutsideServiceDateSent", FieldKey = "WorkOrderItemOutsideServiceDateSent", TKeySection = "WorkOrderItemOutsideServices" });
l.Add(new FormField { TKey = "WorkOrderItemOutsideServiceDateETA", FieldKey = "WorkOrderItemOutsideServiceDateETA", TKeySection = "WorkOrderItemOutsideServices" });
l.Add(new FormField { TKey = "WorkOrderItemOutsideServiceDateReturned", FieldKey = "WorkOrderItemOutsideServiceDateReturned", TKeySection = "WorkOrderItemOutsideServices" });
l.Add(new FormField { TKey = "TaxCode", FieldKey = "WorkOrderItemOutsideServiceTaxCode", TKeySection = "WorkOrderItemOutsideServices" });
l.Add(new FormField { TKey = "Cost", FieldKey = "OutsideServiceCostViz", TKeySection = "WorkOrderItemOutsideServices" });
l.Add(new FormField { TKey = "Price", FieldKey = "OutsideServicePriceViz", TKeySection = "WorkOrderItemOutsideServices" });
l.Add(new FormField { TKey = "NetPrice", FieldKey = "OutsideServiceNetViz", TKeySection = "WorkOrderItemOutsideServices" });
l.Add(new FormField { TKey = "TaxAAmt", FieldKey = "OutsideServiceTaxAViz", TKeySection = "WorkOrderItemOutsideServices" });
l.Add(new FormField { TKey = "TaxBAmt", FieldKey = "OutsideServiceTaxBViz", TKeySection = "WorkOrderItemOutsideServices" });
l.Add(new FormField { TKey = "LineTotal", FieldKey = "OutsideServiceLineTotalViz", TKeySection = "WorkOrderItemOutsideServices" });
## ORDER:
Unit, SentTo, RMA, RepairCost, RepairPrice, SentVia, TrackingNumber,ShipCost,
ShipPrice, DateSent, DateEta, DateReturned, TaxCode, *PricingFields(table)
"0": {
"id": 49,
"concurrency": 8133532,
"notes": "Eius dolorem vel voluptates.",
"unitId": 19,
"unitViz": "16647021",
"vendorSentToId": 4,
"vendorSentToViz": "Jacobi Inc",
"vendorSentViaId": 8,
"vendorSentViaViz": "Zemlak - Olson",
"rmaNumber": "RMA253437",
"trackingNumber": "TR25046151",
"repairCost": 395.3889733391766,
"repairPrice": 593.0834600087649,
"shippingCost": 17.189500311943476,
"shippingPrice": 25.784250467915214,
"sentDate": "2021-06-01T16:00:00Z",
"etaDate": "2021-06-08T16:00:00Z",
"returnDate": "2021-06-09T16:00:00Z",
"taxCodeId": 1,
"taxCodeViz": "Sales only",
"costViz": 412.5784736511201,
"priceViz": 618.8677104766801,
"netViz": 618.8677104766801,
"taxAViz": 30.943385523834007,
"taxBViz": 0,
"lineTotalViz": 649.8110960005141,
"isDirty": false,
"workOrderItemId": 24
}
}
*/
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: {
unitChange(newName) {
this.value.items[this.activeWoItemIndex].outsideServices[
this.activeItemIndex
].unitViz = newName;
},
vendorSentToChange(newName) {
this.value.items[this.activeWoItemIndex].outsideServices[
this.activeItemIndex
].vendorSentToViz = newName;
},
vendorSentViaChange(newName) {
this.value.items[this.activeWoItemIndex].outsideServices[
this.activeItemIndex
].vendorSentViaViz = newName;
},
taxCodeChange(newName) {
this.value.items[this.activeWoItemIndex].outsideServices[
this.activeItemIndex
].taxCodeViz = newName;
},
newItem() {
let newIndex = this.value.items[this.activeWoItemIndex].outsideServices
.length;
this.value.items[this.activeWoItemIndex].outsideServices.push({
id: 0,
concurrency: 0,
userId: null,
//userViz: null,
serviceStartDate: window.$gz.locale.nowUTC8601String(),
serviceStopDate: window.$gz.locale.nowUTC8601String(), //TODO:sb now plus one hour to match v7
serviceRateId: null,
serviceDetails: null,
serviceRateQuantity: 1,
noChargeQuantity: 0,
serviceBankId: null,
taxCodeSaleId: null,
price: 0,
priceOverride: 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].outsideServices[
this.activeItemIndex
].deleted = false;
this.setDefaultView();
},
deleteItem() {
this.value.items[this.activeWoItemIndex].outsideServices[
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].outsideServices.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].outsideServices[
this.activeItemIndex
].isDirty = true;
window.$gz.form.fieldValueChanged(this.pvm, ref);
}
},
itemRowClasses: function(item) {
let ret = "";
const isDeleted =
this.value.items[this.activeWoItemIndex].outsideServices[item.index]
.deleted === true;
const hasError = this.form().childRowHasError(
this,
`Items[${this.activeWoItemIndex}].OutsideServices[${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].outsideServices[
this.activeItemIndex
] == null
) {
this.setDefaultView();
return true;
}
return (
this.value.items[this.activeWoItemIndex].outsideServices[
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, "WorkOrderItemOutsideServiceUnit")) {
headers.push({
text: this.$ay.t("Unit"),
align: "left",
value: "unitViz"
});
}
if (
this.form().showMe(this, "WorkOrderItemOutsideServiceVendorSentToID")
) {
headers.push({
text: this.$ay.t("WorkOrderItemOutsideServiceVendorSentToID"),
align: "left",
value: "vendorSentToViz"
});
}
if (this.form().showMe(this, "WorkOrderItemOutsideServiceRMANumber")) {
headers.push({
text: this.$ay.t("WorkOrderItemOutsideServiceRMANumber"),
align: "left",
value: "rmaNumber"
});
}
if (this.form().showMe(this, "WorkOrderItemOutsideServiceRepairCost")) {
headers.push({
text: this.$ay.t("WorkOrderItemOutsideServiceRepairCost"),
align: "right",
value: "repairCost"
});
}
if (this.form().showMe(this, "WorkOrderItemOutsideServiceRepairPrice")) {
headers.push({
text: this.$ay.t("WorkOrderItemOutsideServiceRepairPrice"),
align: "right",
value: "repairPrice"
});
}
if (
this.form().showMe(this, "WorkOrderItemOutsideServiceVendorSentViaID")
) {
headers.push({
text: this.$ay.t("WorkOrderItemOutsideServiceVendorSentViaID"),
align: "left",
value: "vendorSentViaViz"
});
}
if (
this.form().showMe(this, "WorkOrderItemOutsideServiceTrackingNumber")
) {
headers.push({
text: this.$ay.t("WorkOrderItemOutsideServiceTrackingNumber"),
align: "left",
value: "trackingNumber"
});
}
if (this.form().showMe(this, "WorkOrderItemOutsideServiceShippingCost")) {
headers.push({
text: this.$ay.t("WorkOrderItemOutsideServiceShippingCost"),
align: "right",
value: "shippingCost"
});
}
if (
this.form().showMe(this, "WorkOrderItemOutsideServiceShippingPrice")
) {
headers.push({
text: this.$ay.t("WorkOrderItemOutsideServiceShippingPrice"),
align: "right",
value: "shippingPrice"
});
}
if (this.form().showMe(this, "WorkOrderItemOutsideServiceDateSent")) {
headers.push({
text: this.$ay.t("WorkOrderItemOutsideServiceDateSent"),
align: "right",
value: "sentDate"
});
}
if (this.form().showMe(this, "WorkOrderItemOutsideServiceDateETA")) {
headers.push({
text: this.$ay.t("WorkOrderItemOutsideServiceDateETA"),
align: "right",
value: "etaDate"
});
}
if (this.form().showMe(this, "WorkOrderItemOutsideServiceDateReturned")) {
headers.push({
text: this.$ay.t("WorkOrderItemOutsideServiceDateReturned"),
align: "right",
value: "returnDate"
});
}
if (this.form().showMe(this, "WorkOrderItemOutsideServiceNotes")) {
headers.push({
text: this.$ay.t("WorkOrderItemOutsideServiceNotes"),
align: "left",
value: "notes"
});
}
if (this.form().showMe(this, "OutsideServiceCostViz")) {
headers.push({
text: this.$ay.t("Cost"),
align: "right",
value: "costViz"
});
}
if (this.form().showMe(this, "OutsideServicePriceViz")) {
headers.push({
text: this.$ay.t("Price"),
align: "right",
value: "priceViz"
});
}
if (this.form().showMe(this, "OutsideServiceNetViz")) {
headers.push({
text: this.$ay.t("NetPrice"),
align: "right",
value: "netViz"
});
}
if (this.form().showMe(this, "WorkOrderItemOutsideServiceTaxCode")) {
headers.push({
text: this.$ay.t("Tax"),
align: "left",
value: "taxCodeViz"
});
}
if (this.form().showMe(this, "OutsideServiceTaxAViz")) {
headers.push({
text: this.$ay.t("TaxAAmt"),
align: "right",
value: "taxAViz"
});
}
if (this.form().showMe(this, "OutsideServiceTaxBViz")) {
headers.push({
text: this.$ay.t("TaxBAmt"),
align: "right",
value: "taxBViz"
});
}
if (this.form().showMe(this, "OutsideServiceLineTotalViz")) {
headers.push({
text: this.$ay.t("LineTotal"),
align: "right",
value: "lineTotalViz"
});
}
return headers;
},
itemList: function() {
return this.value.items[this.activeWoItemIndex].outsideServices.map(
(x, i) => {
return {
index: i,
id: x.id,
unitViz: x.unitViz,
vendorSentToViz: x.vendorSentToViz,
rmaNumber: x.rmaNumber,
repairCost: window.$gz.locale.currencyLocalized(
x.repairCost,
this.pvm.languageName,
this.pvm.currencyName
),
repairPrice: window.$gz.locale.currencyLocalized(
x.repairPrice,
this.pvm.languageName,
this.pvm.currencyName
),
vendorSentViaViz: x.vendorSentViaViz,
trackingNumber: x.trackingNumber,
shippingCost: window.$gz.locale.currencyLocalized(
x.shippingCost,
this.pvm.languageName,
this.pvm.currencyName
),
shippingPrice: window.$gz.locale.currencyLocalized(
x.shippingPrice,
this.pvm.languageName,
this.pvm.currencyName
),
sentDate: window.$gz.locale.utcDateToShortDateAndTimeLocalized(
x.sentDate,
this.pvm.timeZoneName,
this.pvm.languageName,
this.pvm.hour12
),
etaDate: window.$gz.locale.utcDateToShortDateAndTimeLocalized(
x.etaDate,
this.pvm.timeZoneName,
this.pvm.languageName,
this.pvm.hour12
),
returnDate: window.$gz.locale.utcDateToShortDateAndTimeLocalized(
x.returnDate,
this.pvm.timeZoneName,
this.pvm.languageName,
this.pvm.hour12
),
notes: window.$gz.util.truncateString(
x.notes,
this.pvm.maxTableNotesLength
),
costViz: window.$gz.locale.currencyLocalized(
x.costViz,
this.pvm.languageName,
this.pvm.currencyName
),
priceViz: window.$gz.locale.currencyLocalized(
x.priceViz,
this.pvm.languageName,
this.pvm.currencyName
),
taxCodeViz: x.taxCodeViz,
netViz: window.$gz.locale.currencyLocalized(
x.netViz,
this.pvm.languageName,
this.pvm.currencyName
),
taxAViz: window.$gz.locale.currencyLocalized(
x.taxAViz,
this.pvm.languageName,
this.pvm.currencyName
),
taxBViz: window.$gz.locale.currencyLocalized(
x.taxBViz,
this.pvm.languageName,
this.pvm.currencyName
),
lineTotalViz: window.$gz.locale.currencyLocalized(
x.lineTotalViz,
this.pvm.languageName,
this.pvm.currencyName
)
};
}
);
},
formState: function() {
return this.pvm.formState;
},
formCustomTemplateKey: function() {
return this.pvm.formCustomTemplateKey;
},
showTable: function() {
return (
this.value.items[this.activeWoItemIndex].outsideServices.length > 1
);
},
canAdd: function() {
return (
this.pvm.rights.change && this.pvm.subRights.outsideServices.create
);
},
canDelete: function() {
return (
this.activeItemIndex != null &&
this.pvm.rights.change &&
this.pvm.subRights.outsideServices.delete
);
}
//----
}
};
</script>