re-factor / cleanup
This commit is contained in:
@@ -49,10 +49,10 @@
|
||||
<!-- ############################################################### -->
|
||||
<v-col cols="12" class="mb-10">
|
||||
<v-data-table
|
||||
v-model="selectedRow"
|
||||
:headers="headerList"
|
||||
:items="itemList"
|
||||
item-key="index"
|
||||
v-model="selectedRow"
|
||||
class="elevation-1"
|
||||
disable-pagination
|
||||
disable-filtering
|
||||
@@ -61,9 +61,9 @@
|
||||
data-cy="outsideServicesTable"
|
||||
dense
|
||||
:item-class="itemRowClasses"
|
||||
@click:row="handleRowClick"
|
||||
:show-select="$vuetify.breakpoint.xs"
|
||||
single-select
|
||||
@click:row="handleRowClick"
|
||||
>
|
||||
</v-data-table>
|
||||
</v-col>
|
||||
@@ -73,8 +73,8 @@
|
||||
<v-btn
|
||||
v-if="canDelete && isDeleted"
|
||||
large
|
||||
@click="unDeleteItem"
|
||||
color="primary"
|
||||
@click="unDeleteItem"
|
||||
>{{ $ay.t("Undelete")
|
||||
}}<v-icon right large>$ayiTrashRestoreAlt</v-icon></v-btn
|
||||
>
|
||||
@@ -87,18 +87,18 @@
|
||||
xl="3"
|
||||
>
|
||||
<gz-pick-list
|
||||
:aya-type="$ay.ayt().Unit"
|
||||
show-edit-icon
|
||||
:ref="
|
||||
`Items[${activeWoItemIndex}].outsideServices[${activeItemIndex}].unitId`
|
||||
"
|
||||
v-model="
|
||||
value.items[activeWoItemIndex].outsideServices[activeItemIndex]
|
||||
.unitId
|
||||
"
|
||||
:aya-type="$ay.ayt().Unit"
|
||||
show-edit-icon
|
||||
:readonly="formState.readOnly || isDeleted"
|
||||
:disabled="isDeleted"
|
||||
:label="$ay.t('Unit')"
|
||||
:ref="
|
||||
`Items[${activeWoItemIndex}].outsideServices[${activeItemIndex}].unitId`
|
||||
"
|
||||
data-cy="outsideServices.unitId"
|
||||
:rules="[
|
||||
form().required(
|
||||
@@ -131,18 +131,18 @@
|
||||
xl="3"
|
||||
>
|
||||
<gz-pick-list
|
||||
:aya-type="$ay.ayt().Vendor"
|
||||
show-edit-icon
|
||||
:ref="
|
||||
`Items[${activeWoItemIndex}].outsideServices[${activeItemIndex}].vendorSentToId`
|
||||
"
|
||||
v-model="
|
||||
value.items[activeWoItemIndex].outsideServices[activeItemIndex]
|
||||
.vendorSentToId
|
||||
"
|
||||
:aya-type="$ay.ayt().Vendor"
|
||||
show-edit-icon
|
||||
:readonly="formState.readOnly || isDeleted"
|
||||
:disabled="isDeleted"
|
||||
:label="$ay.t('WorkOrderItemOutsideServiceVendorSentToID')"
|
||||
:ref="
|
||||
`Items[${activeWoItemIndex}].outsideServices[${activeItemIndex}].vendorSentToId`
|
||||
"
|
||||
data-cy="outsideServices.vendorSentToId"
|
||||
:error-messages="
|
||||
form().serverErrors(
|
||||
@@ -167,6 +167,9 @@
|
||||
xl="3"
|
||||
>
|
||||
<v-text-field
|
||||
:ref="
|
||||
`Items[${activeWoItemIndex}].outsideServices[${activeItemIndex}].rmaNumber`
|
||||
"
|
||||
v-model="
|
||||
value.items[activeWoItemIndex].outsideServices[activeItemIndex]
|
||||
.rmaNumber
|
||||
@@ -174,21 +177,18 @@
|
||||
: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`
|
||||
)
|
||||
"
|
||||
data-cy="outsideServices.rma"
|
||||
@input="
|
||||
fieldValueChanged(
|
||||
`Items[${activeWoItemIndex}].outsideServices[${activeItemIndex}].rmaNumber`
|
||||
)
|
||||
"
|
||||
data-cy="outsideServices.rma"
|
||||
></v-text-field>
|
||||
</v-col>
|
||||
<v-col
|
||||
@@ -199,6 +199,9 @@
|
||||
xl="3"
|
||||
>
|
||||
<gz-currency
|
||||
:ref="
|
||||
`Items[${activeWoItemIndex}].outsideServices[${activeItemIndex}].repairCost`
|
||||
"
|
||||
v-model="
|
||||
value.items[activeWoItemIndex].outsideServices[activeItemIndex]
|
||||
.repairCost
|
||||
@@ -207,9 +210,6 @@
|
||||
:readonly="formState.readOnly || isDeleted"
|
||||
:disabled="isDeleted"
|
||||
:label="$ay.t('WorkOrderItemOutsideServiceRepairCost')"
|
||||
:ref="
|
||||
`Items[${activeWoItemIndex}].outsideServices[${activeItemIndex}].repairCost`
|
||||
"
|
||||
data-cy="outsideServices.repairCost"
|
||||
:error-messages="
|
||||
form().serverErrors(
|
||||
@@ -239,6 +239,9 @@
|
||||
xl="3"
|
||||
>
|
||||
<gz-currency
|
||||
:ref="
|
||||
`Items[${activeWoItemIndex}].outsideServices[${activeItemIndex}].repairPrice`
|
||||
"
|
||||
v-model="
|
||||
value.items[activeWoItemIndex].outsideServices[activeItemIndex]
|
||||
.repairPrice
|
||||
@@ -247,9 +250,6 @@
|
||||
:readonly="formState.readOnly || isDeleted"
|
||||
:disabled="isDeleted"
|
||||
:label="$ay.t('WorkOrderItemOutsideServiceRepairPrice')"
|
||||
:ref="
|
||||
`Items[${activeWoItemIndex}].outsideServices[${activeItemIndex}].repairPrice`
|
||||
"
|
||||
data-cy="outsideServices.repairPrice"
|
||||
:error-messages="
|
||||
form().serverErrors(
|
||||
@@ -281,18 +281,18 @@
|
||||
xl="3"
|
||||
>
|
||||
<gz-pick-list
|
||||
:aya-type="$ay.ayt().Vendor"
|
||||
show-edit-icon
|
||||
:ref="
|
||||
`Items[${activeWoItemIndex}].outsideServices[${activeItemIndex}].vendorSentViaId`
|
||||
"
|
||||
v-model="
|
||||
value.items[activeWoItemIndex].outsideServices[activeItemIndex]
|
||||
.vendorSentViaId
|
||||
"
|
||||
:aya-type="$ay.ayt().Vendor"
|
||||
show-edit-icon
|
||||
:readonly="formState.readOnly || isDeleted"
|
||||
:disabled="isDeleted"
|
||||
:label="$ay.t('WorkOrderItemOutsideServiceVendorSentViaID')"
|
||||
:ref="
|
||||
`Items[${activeWoItemIndex}].outsideServices[${activeItemIndex}].vendorSentViaId`
|
||||
"
|
||||
data-cy="outsideServices.vendorSentViaId"
|
||||
:error-messages="
|
||||
form().serverErrors(
|
||||
@@ -319,6 +319,9 @@
|
||||
xl="3"
|
||||
>
|
||||
<v-text-field
|
||||
:ref="
|
||||
`Items[${activeWoItemIndex}].outsideServices[${activeItemIndex}].trackingNumber`
|
||||
"
|
||||
v-model="
|
||||
value.items[activeWoItemIndex].outsideServices[activeItemIndex]
|
||||
.trackingNumber
|
||||
@@ -326,21 +329,18 @@
|
||||
: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`
|
||||
)
|
||||
"
|
||||
data-cy="outsideServices.trackingNumber"
|
||||
@input="
|
||||
fieldValueChanged(
|
||||
`Items[${activeWoItemIndex}].outsideServices[${activeItemIndex}].trackingNumber`
|
||||
)
|
||||
"
|
||||
data-cy="outsideServices.trackingNumber"
|
||||
></v-text-field>
|
||||
</v-col>
|
||||
<v-col
|
||||
@@ -351,6 +351,9 @@
|
||||
xl="3"
|
||||
>
|
||||
<gz-currency
|
||||
:ref="
|
||||
`Items[${activeWoItemIndex}].outsideServices[${activeItemIndex}].shippingCost`
|
||||
"
|
||||
v-model="
|
||||
value.items[activeWoItemIndex].outsideServices[activeItemIndex]
|
||||
.shippingCost
|
||||
@@ -359,9 +362,6 @@
|
||||
:readonly="formState.readOnly || isDeleted"
|
||||
:disabled="isDeleted"
|
||||
:label="$ay.t('WorkOrderItemOutsideServiceShippingCost')"
|
||||
:ref="
|
||||
`Items[${activeWoItemIndex}].outsideServices[${activeItemIndex}].shippingCost`
|
||||
"
|
||||
data-cy="outsideServices.shippingCost"
|
||||
:error-messages="
|
||||
form().serverErrors(
|
||||
@@ -391,6 +391,9 @@
|
||||
xl="3"
|
||||
>
|
||||
<gz-currency
|
||||
:ref="
|
||||
`Items[${activeWoItemIndex}].outsideServices[${activeItemIndex}].shippingPrice`
|
||||
"
|
||||
v-model="
|
||||
value.items[activeWoItemIndex].outsideServices[activeItemIndex]
|
||||
.shippingPrice
|
||||
@@ -399,9 +402,6 @@
|
||||
:readonly="formState.readOnly || isDeleted"
|
||||
:disabled="isDeleted"
|
||||
:label="$ay.t('WorkOrderItemOutsideServiceShippingPrice')"
|
||||
:ref="
|
||||
`Items[${activeWoItemIndex}].outsideServices[${activeItemIndex}].shippingPrice`
|
||||
"
|
||||
data-cy="outsideServices.shippingPrice"
|
||||
:error-messages="
|
||||
form().serverErrors(
|
||||
@@ -431,16 +431,16 @@
|
||||
xl="3"
|
||||
>
|
||||
<gz-date-time-picker
|
||||
:label="$ay.t('WorkOrderItemOutsideServiceDateSent')"
|
||||
:ref="
|
||||
`Items[${activeWoItemIndex}].outsideServices[${activeItemIndex}].sentDate`
|
||||
"
|
||||
v-model="
|
||||
value.items[activeWoItemIndex].outsideServices[activeItemIndex]
|
||||
.sentDate
|
||||
"
|
||||
:label="$ay.t('WorkOrderItemOutsideServiceDateSent')"
|
||||
:readonly="formState.readOnly"
|
||||
:disabled="isDeleted"
|
||||
:ref="
|
||||
`Items[${activeWoItemIndex}].outsideServices[${activeItemIndex}].sentDate`
|
||||
"
|
||||
data-cy="outsideServices.sentDate"
|
||||
:error-messages="
|
||||
form().serverErrors(
|
||||
@@ -464,16 +464,16 @@
|
||||
xl="3"
|
||||
>
|
||||
<gz-date-time-picker
|
||||
:label="$ay.t('WorkOrderItemOutsideServiceDateETA')"
|
||||
:ref="
|
||||
`Items[${activeWoItemIndex}].outsideServices[${activeItemIndex}].etaDate`
|
||||
"
|
||||
v-model="
|
||||
value.items[activeWoItemIndex].outsideServices[activeItemIndex]
|
||||
.etaDate
|
||||
"
|
||||
:label="$ay.t('WorkOrderItemOutsideServiceDateETA')"
|
||||
:readonly="formState.readOnly"
|
||||
:disabled="isDeleted"
|
||||
:ref="
|
||||
`Items[${activeWoItemIndex}].outsideServices[${activeItemIndex}].etaDate`
|
||||
"
|
||||
data-cy="outsideServices.etaDate"
|
||||
:error-messages="
|
||||
form().serverErrors(
|
||||
@@ -497,16 +497,16 @@
|
||||
xl="3"
|
||||
>
|
||||
<gz-date-time-picker
|
||||
:label="$ay.t('WorkOrderItemOutsideServiceDateReturned')"
|
||||
:ref="
|
||||
`Items[${activeWoItemIndex}].outsideServices[${activeItemIndex}].returnDate`
|
||||
"
|
||||
v-model="
|
||||
value.items[activeWoItemIndex].outsideServices[activeItemIndex]
|
||||
.returnDate
|
||||
"
|
||||
:label="$ay.t('WorkOrderItemOutsideServiceDateReturned')"
|
||||
:readonly="formState.readOnly"
|
||||
:disabled="isDeleted"
|
||||
:ref="
|
||||
`Items[${activeWoItemIndex}].outsideServices[${activeItemIndex}].returnDate`
|
||||
"
|
||||
data-cy="outsideServices.returnDate"
|
||||
:error-messages="
|
||||
form().serverErrors(
|
||||
@@ -530,18 +530,18 @@
|
||||
xl="3"
|
||||
>
|
||||
<gz-pick-list
|
||||
:aya-type="$ay.ayt().TaxCode"
|
||||
show-edit-icon
|
||||
:ref="
|
||||
`Items[${activeWoItemIndex}].outsideServices[${activeItemIndex}].taxCodeId`
|
||||
"
|
||||
v-model="
|
||||
value.items[activeWoItemIndex].outsideServices[activeItemIndex]
|
||||
.taxCodeId
|
||||
"
|
||||
:aya-type="$ay.ayt().TaxCode"
|
||||
show-edit-icon
|
||||
:readonly="formState.readOnly || isDeleted"
|
||||
:disabled="isDeleted"
|
||||
:label="$ay.t('TaxCode')"
|
||||
:ref="
|
||||
`Items[${activeWoItemIndex}].outsideServices[${activeItemIndex}].taxCodeId`
|
||||
"
|
||||
data-cy="outsideServices.taxCodeId"
|
||||
:error-messages="
|
||||
form().serverErrors(
|
||||
@@ -563,6 +563,9 @@
|
||||
cols="12"
|
||||
>
|
||||
<v-textarea
|
||||
:ref="
|
||||
`Items[${activeWoItemIndex}].outsideServices[${activeItemIndex}].notes`
|
||||
"
|
||||
v-model="
|
||||
value.items[activeWoItemIndex].outsideServices[activeItemIndex]
|
||||
.notes
|
||||
@@ -576,16 +579,13 @@
|
||||
`Items[${activeWoItemIndex}].outsideServices[${activeItemIndex}].notes`
|
||||
)
|
||||
"
|
||||
:ref="
|
||||
`Items[${activeWoItemIndex}].outsideServices[${activeItemIndex}].notes`
|
||||
"
|
||||
data-cy="outsideServices.notes"
|
||||
auto-grow
|
||||
@input="
|
||||
fieldValueChanged(
|
||||
`Items[${activeWoItemIndex}].outsideServices[${activeItemIndex}].notes`
|
||||
)
|
||||
"
|
||||
auto-grow
|
||||
></v-textarea>
|
||||
</v-col>
|
||||
</template>
|
||||
@@ -594,15 +594,6 @@
|
||||
</template>
|
||||
<script>
|
||||
export default {
|
||||
created() {
|
||||
this.setDefaultView();
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
activeItemIndex: null,
|
||||
selectedRow: []
|
||||
};
|
||||
},
|
||||
props: {
|
||||
value: {
|
||||
default: null,
|
||||
@@ -621,162 +612,11 @@ export default {
|
||||
type: Number
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
activeWoItemIndex(val, oldVal) {
|
||||
if (val != oldVal) {
|
||||
this.setDefaultView();
|
||||
}
|
||||
},
|
||||
gotoIndex(val, oldVal) {
|
||||
if (val != oldVal) {
|
||||
let gotoIndex = val;
|
||||
if (val < 0) {
|
||||
//it's a create request
|
||||
gotoIndex = this.newItem();
|
||||
}
|
||||
this.selectedRow = [{ index: gotoIndex }];
|
||||
this.activeItemIndex = gotoIndex;
|
||||
this.$nextTick(() => {
|
||||
const el = this.$refs.outsideservicetopform;
|
||||
if (el) {
|
||||
el.scrollIntoView({ behavior: "smooth" });
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
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() {
|
||||
const newIndex = this.value.items[this.activeWoItemIndex].outsideServices
|
||||
.length;
|
||||
|
||||
this.value.items[this.activeWoItemIndex].outsideServices.push({
|
||||
id: 0,
|
||||
concurrency: 0,
|
||||
unitId: 0, //zero to break rule on new
|
||||
notes: null,
|
||||
vendorSentToId: null,
|
||||
vendorSentViaId: null,
|
||||
rmaNumber: null,
|
||||
trackingNumber: null,
|
||||
repairCost: 0,
|
||||
repairPrice: 0,
|
||||
shippingCost: 0,
|
||||
shippingPrice: 0,
|
||||
sentDate: window.$gz.locale.nowUTC8601String(),
|
||||
etaDate: null,
|
||||
returnDate: null,
|
||||
taxCodeId: null, //Is it labor or parts tax code? wasn't in v7 leaving empty for now
|
||||
isDirty: true,
|
||||
workOrderItemId: this.value.items[this.activeWoItemIndex].id,
|
||||
uid: Date.now(),
|
||||
unitViz: null,
|
||||
vendorSentToViz: null,
|
||||
vendorSentViaViz: null,
|
||||
taxCodeViz: null
|
||||
});
|
||||
this.$emit("change");
|
||||
this.selectedRow = [{ index: newIndex }];
|
||||
this.activeItemIndex = newIndex;
|
||||
//trigger rule breaking / validation
|
||||
this.$nextTick(() => {
|
||||
this.value.items[this.activeWoItemIndex].outsideServices[
|
||||
this.activeItemIndex
|
||||
].unitId = null;
|
||||
this.fieldValueChanged(
|
||||
`Items[${this.activeWoItemIndex}].outsideServices[${this.activeItemIndex}].unitId`
|
||||
);
|
||||
});
|
||||
return newIndex; //for create new on goto
|
||||
},
|
||||
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");
|
||||
},
|
||||
deleteAllItem() {
|
||||
this.value.items[this.activeWoItemIndex].outsideServices.forEach(
|
||||
z => (z.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;
|
||||
}
|
||||
//---
|
||||
data() {
|
||||
return {
|
||||
activeItemIndex: null,
|
||||
selectedRow: []
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
isDeleted: function() {
|
||||
@@ -1087,6 +927,166 @@ export default {
|
||||
}
|
||||
|
||||
//----
|
||||
},
|
||||
watch: {
|
||||
activeWoItemIndex(val, oldVal) {
|
||||
if (val != oldVal) {
|
||||
this.setDefaultView();
|
||||
}
|
||||
},
|
||||
gotoIndex(val, oldVal) {
|
||||
if (val != oldVal) {
|
||||
let gotoIndex = val;
|
||||
if (val < 0) {
|
||||
//it's a create request
|
||||
gotoIndex = this.newItem();
|
||||
}
|
||||
this.selectedRow = [{ index: gotoIndex }];
|
||||
this.activeItemIndex = gotoIndex;
|
||||
this.$nextTick(() => {
|
||||
const el = this.$refs.outsideservicetopform;
|
||||
if (el) {
|
||||
el.scrollIntoView({ behavior: "smooth" });
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
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() {
|
||||
const newIndex = this.value.items[this.activeWoItemIndex].outsideServices
|
||||
.length;
|
||||
|
||||
this.value.items[this.activeWoItemIndex].outsideServices.push({
|
||||
id: 0,
|
||||
concurrency: 0,
|
||||
unitId: 0, //zero to break rule on new
|
||||
notes: null,
|
||||
vendorSentToId: null,
|
||||
vendorSentViaId: null,
|
||||
rmaNumber: null,
|
||||
trackingNumber: null,
|
||||
repairCost: 0,
|
||||
repairPrice: 0,
|
||||
shippingCost: 0,
|
||||
shippingPrice: 0,
|
||||
sentDate: window.$gz.locale.nowUTC8601String(),
|
||||
etaDate: null,
|
||||
returnDate: null,
|
||||
taxCodeId: null, //Is it labor or parts tax code? wasn't in v7 leaving empty for now
|
||||
isDirty: true,
|
||||
workOrderItemId: this.value.items[this.activeWoItemIndex].id,
|
||||
uid: Date.now(),
|
||||
unitViz: null,
|
||||
vendorSentToViz: null,
|
||||
vendorSentViaViz: null,
|
||||
taxCodeViz: null
|
||||
});
|
||||
this.$emit("change");
|
||||
this.selectedRow = [{ index: newIndex }];
|
||||
this.activeItemIndex = newIndex;
|
||||
//trigger rule breaking / validation
|
||||
this.$nextTick(() => {
|
||||
this.value.items[this.activeWoItemIndex].outsideServices[
|
||||
this.activeItemIndex
|
||||
].unitId = null;
|
||||
this.fieldValueChanged(
|
||||
`Items[${this.activeWoItemIndex}].outsideServices[${this.activeItemIndex}].unitId`
|
||||
);
|
||||
});
|
||||
return newIndex; //for create new on goto
|
||||
},
|
||||
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");
|
||||
},
|
||||
deleteAllItem() {
|
||||
this.value.items[this.activeWoItemIndex].outsideServices.forEach(
|
||||
z => (z.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;
|
||||
}
|
||||
//---
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user