This commit is contained in:
2021-05-10 23:44:14 +00:00
parent 5d5ebfb1e0
commit 3ff5ce1d0f
2 changed files with 828 additions and 4 deletions

View File

@@ -0,0 +1,742 @@
<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"
>$ayiMoneyBillWave</v-icon
>
{{ $ay.t("WorkOrderItemLaborList") }}
<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="laborsTable"
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, 'WorkOrderItemLaborName')"
cols="12"
sm="6"
lg="4"
xl="3"
>
<v-text-field
v-model="
value.items[activeWoItemIndex].labors[activeItemIndex].name
"
:readonly="formState.readOnly"
:disabled="isDeleted"
:label="$ay.t('WorkOrderItemLaborName')"
:ref="
`Items[${activeWoItemIndex}].labors[
${activeItemIndex}
].name`
"
:error-messages="
form().serverErrors(
this,
`Items[${activeWoItemIndex}].labors[
${activeItemIndex}
].name`
)
"
@input="
fieldValueChanged(`Items[${activeWoItemIndex}].labors[
${activeItemIndex}
].name`)
"
></v-text-field>
</v-col>
<v-col
v-if="form().showMe(this, 'WorkOrderItemLaborTotalCost')"
cols="12"
sm="6"
lg="4"
xl="3"
>
<gz-currency
v-model="
value.items[activeWoItemIndex].labors[activeItemIndex].totalCost
"
:readonly="formState.readOnly || isDeleted"
:disabled="isDeleted"
:label="$ay.t('WorkOrderItemLaborTotalCost')"
:ref="
`Items[${activeWoItemIndex}].labors[${activeItemIndex}].totalCost`
"
data-cy="laborTotalCost"
:error-messages="
form().serverErrors(
this,
`Items[${activeWoItemIndex}].labors[${activeItemIndex}].totalCost`
)
"
:rules="[
form().decimalValid(
this,
`Items[${activeWoItemIndex}].labors[${activeItemIndex}].totalCost`
),
form().required(
this,
`Items[${activeWoItemIndex}].labors[${activeItemIndex}].totalCost`
)
]"
@input="
fieldValueChanged(`Items[${activeWoItemIndex}].labors[
${activeItemIndex}
].totalCost`)
"
></gz-currency>
</v-col>
<v-col
v-if="form().showMe(this, 'WorkOrderItemLaborChargeAmount')"
cols="12"
sm="6"
lg="4"
xl="3"
>
<gz-currency
v-model="
value.items[activeWoItemIndex].labors[activeItemIndex]
.chargeAmount
"
:readonly="formState.readOnly || isDeleted"
:disabled="isDeleted"
:label="$ay.t('WorkOrderItemLaborChargeAmount')"
:ref="
`Items[${activeWoItemIndex}].labors[${activeItemIndex}].chargeAmount`
"
data-cy="laborChargeAmount"
:error-messages="
form().serverErrors(
this,
`Items[${activeWoItemIndex}].labors[${activeItemIndex}].chargeAmount`
)
"
:rules="[
form().decimalValid(
this,
`Items[${activeWoItemIndex}].labors[${activeItemIndex}].chargeAmount`
),
form().required(
this,
`Items[${activeWoItemIndex}].labors[${activeItemIndex}].chargeAmount`
)
]"
@input="
fieldValueChanged(`Items[${activeWoItemIndex}].labors[
${activeItemIndex}
].chargeAmount`)
"
></gz-currency>
</v-col>
<v-col
v-if="form().showMe(this, 'WorkOrderItemLaborChargeToCustomer')"
cols="12"
sm="6"
lg="4"
xl="3"
>
<v-checkbox
v-model="
value.items[activeWoItemIndex].labors[activeItemIndex]
.chargeToCustomer
"
:readonly="formState.readOnly"
:disabled="isDeleted"
:label="$ay.t('WorkOrderItemLaborChargeToCustomer')"
:ref="
`Items[${activeWoItemIndex}].labors[${activeItemIndex}].chargeToCustomer`
"
data-cy="chargeToCustomer"
:error-messages="
form().serverErrors(
this,
`Items[${activeWoItemIndex}].labors[${activeItemIndex}].chargeToCustomer`
)
"
@change="
fieldValueChanged(`Items[${activeWoItemIndex}].labors[
${activeItemIndex}
].chargeToCustomer`)
"
></v-checkbox>
</v-col>
<v-col
v-if="form().showMe(this, 'WorkOrderItemLaborTaxPaid')"
cols="12"
sm="6"
lg="4"
xl="3"
>
<gz-currency
v-model="
value.items[activeWoItemIndex].labors[activeItemIndex].taxPaid
"
:readonly="formState.readOnly || isDeleted"
:disabled="isDeleted"
:label="$ay.t('WorkOrderItemLaborTaxPaid')"
:ref="
`Items[${activeWoItemIndex}].labors[${activeItemIndex}].taxPaid`
"
data-cy="laborTaxPaid"
:error-messages="
form().serverErrors(
this,
`Items[${activeWoItemIndex}].labors[${activeItemIndex}].taxPaid`
)
"
:rules="[
form().decimalValid(
this,
`Items[${activeWoItemIndex}].labors[${activeItemIndex}].taxPaid`
),
form().required(
this,
`Items[${activeWoItemIndex}].labors[${activeItemIndex}].taxPaid`
)
]"
@input="
fieldValueChanged(`Items[${activeWoItemIndex}].labors[
${activeItemIndex}
].taxPaid`)
"
></gz-currency>
</v-col>
<v-col
v-if="form().showMe(this, 'WorkOrderItemLaborChargeTaxCodeID')"
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].labors[activeItemIndex]
.chargeTaxCodeId
"
:readonly="formState.readOnly || isDeleted"
:disabled="isDeleted"
:label="$ay.t('WorkOrderItemLaborChargeTaxCodeID')"
:ref="
`Items[${activeWoItemIndex}].labors[${activeItemIndex}].chargeTaxCodeId`
"
data-cy="laborChargeTaxCode"
:error-messages="
form().serverErrors(
this,
`Items[${activeWoItemIndex}].labors[${activeItemIndex}].chargeTaxCodeId`
)
"
@input="
fieldValueChanged(
`Items[${activeWoItemIndex}].labors[${activeItemIndex}].chargeTaxCodeId`
)
"
@update:name="taxCodeChange"
></gz-pick-list>
</v-col>
<v-col
v-if="form().showMe(this, 'WorkOrderItemLaborReimburseUser')"
cols="12"
sm="6"
lg="4"
xl="3"
>
<v-checkbox
v-model="
value.items[activeWoItemIndex].labors[activeItemIndex]
.reimburseUser
"
:readonly="formState.readOnly"
:disabled="isDeleted"
:label="$ay.t('WorkOrderItemLaborReimburseUser')"
:ref="
`Items[${activeWoItemIndex}].labors[${activeItemIndex}].reimburseUser`
"
data-cy="laborReimburseUser"
:error-messages="
form().serverErrors(
this,
`Items[${activeWoItemIndex}].labors[${activeItemIndex}].reimburseUser`
)
"
@change="
fieldValueChanged(`Items[${activeWoItemIndex}].labors[
${activeItemIndex}
].reimburseUser`)
"
></v-checkbox>
</v-col>
<v-col
v-if="form().showMe(this, 'WorkOrderItemLaborUserID')"
cols="12"
sm="6"
lg="4"
xl="3"
>
<gz-pick-list
:aya-type="$ay.ayt().User"
variant="tech"
:show-edit-icon="true"
v-model="
value.items[activeWoItemIndex].labors[activeItemIndex].userId
"
:readonly="formState.readOnly || isDeleted"
:disabled="isDeleted"
:label="$ay.t('WorkOrderItemLaborUserID')"
:ref="
`Items[${activeWoItemIndex}].labors[${activeItemIndex}].userId`
"
data-cy="laborUser"
:error-messages="
form().serverErrors(
this,
`Items[${activeWoItemIndex}].labors[${activeItemIndex}].userId`
)
"
@input="
fieldValueChanged(
`Items[${activeWoItemIndex}].labors[${activeItemIndex}].userId`
)
"
@update:name="userChange"
></gz-pick-list>
</v-col>
<v-col
v-if="form().showMe(this, 'WorkOrderItemLaborDescription')"
cols="12"
>
<v-textarea
v-model="
value.items[activeWoItemIndex].labors[activeItemIndex].description
"
:readonly="formState.readOnly"
:disabled="isDeleted"
:label="$ay.t('WorkOrderItemLaborDescription')"
:error-messages="
form().serverErrors(
this,
`Items[${activeWoItemIndex}].labors[
${activeItemIndex}
].description`
)
"
:ref="
`Items[${activeWoItemIndex}].labors[
${activeItemIndex}
].description`
"
data-cy="laborDescription"
@input="
fieldValueChanged(`Items[${activeWoItemIndex}].labors[
${activeItemIndex}
].description`)
"
auto-grow
></v-textarea>
</v-col>
</template>
</v-row>
</div>
</template>
<script>
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
/* XXXeslint-disable */
////////////////////////////////////////////////////////////////////////////////////////////////////////////
/*
public long? UserId { get; set; }
public DateTime? ServiceStartDate { get; set; }
public DateTime? ServiceStopDate { get; set; }
public long? ServiceRateId { get; set; }
public string ServiceDetails { get; set; }
public decimal ServiceRateQuantity { get; set; }
public decimal NoChargeQuantity { get; set; }
public long? ServiceBankId { get; set; }
public long? TaxCodeSaleId { get; set; }
public decimal BasePrice { get; set; }//Rate price per unit at time of entry
public decimal Price { get; set; }//contract adjusted price or a copy of BasePrice if no contract
public decimal ManualDiscountPct { get; set; }// (V7 "Discount") ad-hoc / % off of the contractprice (which is always set regardless if contract or not) entered manually
l.Add(new FormField { TKey = "WorkOrderItemLaborServiceStartDate", FieldKey = "WorkOrderItemLaborServiceStartDate", TKeySection = "WorkOrderItemLabors" });
l.Add(new FormField { TKey = "WorkOrderItemLaborServiceStopDate", FieldKey = "WorkOrderItemLaborServiceStopDate", TKeySection = "WorkOrderItemLabors" });
l.Add(new FormField { TKey = "WorkOrderItemLaborServiceRateQuantity", FieldKey = "WorkOrderItemLaborServiceRateQuantity", TKeySection = "WorkOrderItemLabors" });
l.Add(new FormField { TKey = "WorkOrderItemLaborServiceRateID", FieldKey = "WorkOrderItemLaborServiceRateID", TKeySection = "WorkOrderItemLabors" });
l.Add(new FormField { TKey = "WorkOrderItemLaborServiceDetails", FieldKey = "WorkOrderItemLaborServiceDetails", TKeySection = "WorkOrderItemLabors" });
l.Add(new FormField { TKey = "WorkOrderItemLaborUserID", FieldKey = "WorkOrderItemLaborUserID", TKeySection = "WorkOrderItemLabors" });
l.Add(new FormField { TKey = "WorkOrderItemLaborNoChargeQuantity", FieldKey = "WorkOrderItemLaborNoChargeQuantity", TKeySection = "WorkOrderItemLabors" });
l.Add(new FormField { TKey = "WorkOrderItemLaborTaxRateSaleID", FieldKey = "WorkOrderItemLaborTaxRateSaleID", TKeySection = "WorkOrderItemLabors" });
l.Add(new FormField { TKey = "WorkOrderItemLaborManualDiscountPct", FieldKey = "WorkOrderItemLaborManualDiscountPct", TKeySection = "WorkOrderItemLabors" });
l.Add(new FormField { TKey = "WorkOrderItemLaborBasePrice", FieldKey = "WorkOrderItemLaborBasePrice", TKeySection = "WorkOrderItemLabors" });
l.Add(new FormField { TKey = "WorkOrderItemLaborPrice", FieldKey = "WorkOrderItemLaborPrice", TKeySection = "WorkOrderItemLabors" });
l.Add(new FormField { TKey = "WorkOrderItemLaborServiceStartDate", FieldKey = "WorkOrderItemLaborServiceStartDate", TKeySection = "WorkOrderItemLabors" });
"WorkOrderItemLaborBanked": "Banked",
"WorkOrderItemLaborRateCharge": "Rate Charge",
"WorkOrderItemLaborList": "Labors",
"WorkOrderItemLaborNoChargeQuantity": "No Charge Quantity",
"WorkOrderItemLaborServiceDetails": "Service Details",
"WorkOrderItemLaborServiceRateID": "Service Rate",
"WorkOrderItemLaborServiceRateQuantity": "Service Rate Quantity",
"WorkOrderItemLaborServiceStartDate": "Service Start Date Time",
"WorkOrderItemLaborServiceStopDate": "Service Stop Date Time",
"WorkOrderItemLaborTaxCodeID": "Tax Code",
"WorkOrderItemLaborTaxRateSaleID": "Sales tax",
"WorkOrderItemLaborUIBankWarning": "Are you sure you want to Bank this record?\r\n(Once this record is banked it will be locked and can no longer be edited)",
"WorkOrderItemLaborUIReBankWarning": "This item is already banked",
"WorkOrderItemLaborUserID": "User",
WorkOrderItemLaborManualDiscountPct
WorkOrderItemLaborBasePrice
WorkOrderItemLaborPrice
"CREATE TABLE aworkorderitemlabor (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, workorderitemid BIGINT NOT NULL REFERENCES aworkorderitem (id), "
+ "userid BIGINT REFERENCES auser, servicestartdate TIMESTAMP, servicestopdate TIMESTAMP, servicerateid BIGINT REFERENCES aservicerate, servicedetails text, "
+ "serviceratequantity DECIMAL(19,5) NOT NULL default 0, nochargequantity DECIMAL(19,5) NOT NULL default 0, servicebankid BIGINT REFERENCES aservicebank, "
+ "taxcodesaleid BIGINT REFERENCES ataxcode, baseprice DECIMAL(38,18) NOT NULL default 0, price DECIMAL(38,18) NOT NULL default 0, "
+ "manualdiscountpct DECIMAL(8,5) NOT NULL default 0 "
*/
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: {
userChange(newName) {
this.value.items[this.activeWoItemIndex].labors[
this.activeItemIndex
].userViz = newName;
},
taxCodeChange(newName) {
this.value.items[this.activeWoItemIndex].labors[
this.activeItemIndex
].chargeTaxCodeViz = newName;
},
newItem() {
let newIndex = this.value.items[this.activeWoItemIndex].labors.length;
this.value.items[this.activeWoItemIndex].labors.push({
id: 0,
concurrency: 0,
description: null,
name: null,
totalCost: 0,
chargeAmount: 0,
taxPaid: 0,
chargeTaxCodeId: 0,
chargeTaxCodeViz: null,
reimburseUser: false,
userId: null,
userViz: null,
chargeToCustomer: false,
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].labors[
this.activeItemIndex
].deleted = false;
this.setDefaultView();
},
deleteItem() {
this.value.items[this.activeWoItemIndex].labors[
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].labors.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].labors[
this.activeItemIndex
].isDirty = true;
window.$gz.form.fieldValueChanged(this.pvm, ref);
// //set viz if applicable
// if(ref==""){
// let selectedPartWarehouse = vm.$refs.partWarehouseId.getFullSelectionValue();
// }
}
},
itemRowClasses: function(item) {
let ret = "";
const isDeleted =
this.value.items[this.activeWoItemIndex].labors[item.index].deleted ===
true;
const hasError = this.form().childRowHasError(
this,
`Items[${this.activeWoItemIndex}].Labors[${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].labors[this.activeItemIndex] ==
null
) {
this.setDefaultView();
return true;
}
return (
this.value.items[this.activeWoItemIndex].labors[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, "WorkOrderItemLaborName")) {
headers.push({
text: this.$ay.t("WorkOrderItemLaborName"),
align: "left",
value: "name"
});
}
if (this.form().showMe(this, "WorkOrderItemLaborTotalCost")) {
headers.push({
text: this.$ay.t("WorkOrderItemLaborTotalCost"),
align: "right",
value: "totalCost"
});
}
if (this.form().showMe(this, "WorkOrderItemLaborChargeAmount")) {
headers.push({
text: this.$ay.t("WorkOrderItemLaborChargeAmount"),
align: "right",
value: "chargeAmount"
});
}
if (this.form().showMe(this, "WorkOrderItemLaborChargeToCustomer")) {
headers.push({
text: this.$ay.t("WorkOrderItemLaborChargeToCustomer"),
align: "center",
value: "chargeToCustomer"
});
}
if (this.form().showMe(this, "WorkOrderItemLaborTaxPaid")) {
headers.push({
text: this.$ay.t("WorkOrderItemLaborTaxPaid"),
align: "right",
value: "taxPaid"
});
}
if (this.form().showMe(this, "WorkOrderItemLaborChargeTaxCodeID")) {
headers.push({
text: this.$ay.t("WorkOrderItemLaborChargeTaxCodeID"),
align: "left",
value: "chargeTaxCodeViz"
});
}
if (this.form().showMe(this, "WorkOrderItemLaborReimburseUser")) {
headers.push({
text: this.$ay.t("WorkOrderItemLaborReimburseUser"),
align: "center",
value: "reimburseUser"
});
}
if (this.form().showMe(this, "WorkOrderItemLaborUserID")) {
headers.push({
text: this.$ay.t("WorkOrderItemLaborUserID"),
align: "left",
value: "userViz"
});
}
return headers;
},
itemList: function() {
return this.value.items[this.activeWoItemIndex].labors.map((x, i) => {
return {
index: i,
id: x.id,
name: x.name,
totalCost: window.$gz.locale.currencyLocalized(
x.totalCost,
this.pvm.languageName,
this.pvm.currencyName
),
chargeAmount: window.$gz.locale.currencyLocalized(
x.chargeAmount,
this.pvm.languageName,
this.pvm.currencyName
),
chargeToCustomer: x.chargeToCustomer,
taxPaid: window.$gz.locale.currencyLocalized(
x.taxPaid,
this.pvm.languageName,
this.pvm.currencyName
),
chargeTaxCodeViz: x.chargeTaxCodeViz,
reimburseUser: x.reimburseUser,
userViz: x.userViz
};
});
},
formState: function() {
return this.pvm.formState;
},
formCustomTemplateKey: function() {
return this.pvm.formCustomTemplateKey;
},
showTable: function() {
return this.value.items[this.activeWoItemIndex].labors.length > 1;
},
canAdd: function() {
return this.pvm.rights.change && this.pvm.subRights.labors.create;
},
canDelete: function() {
return (
this.activeItemIndex != null &&
this.pvm.rights.change &&
this.pvm.subRights.labors.delete
);
}
}
};
</script>

View File

@@ -737,6 +737,10 @@ async function saveItems(vm) {
z => (z.workorderItemId = vm.obj.items[i].id)
);
vm.obj.items[i].labors.forEach(
z => (z.workorderItemId = vm.obj.items[i].id)
);
//todo: other grandchildren
}
}
@@ -751,6 +755,9 @@ async function saveItems(vm) {
if (!vm.saveResult.fatal) {
await saveScheduledUsers(vm, i);
}
if (!vm.saveResult.fatal) {
await saveLabors(vm, i);
}
//todo: other grandchildren
//------
}
@@ -865,9 +872,6 @@ async function saveScheduledUsers(vm, woItemIndex) {
return; //made it
}
/////////////////////////////
// SCHEDULED USERS
//
async function deleteScheduledUsers(vm, woItemIndex) {
//walk the array backwards as items may be spliced out
for (
@@ -898,6 +902,71 @@ async function deleteScheduledUsers(vm, woItemIndex) {
return;
}
/////////////////////////////
// SCHEDULED USERS
//
async function saveLabors(vm, woItemIndex) {
//DELETE FLAGGED ITEMS FIRST
await deleteLabors(vm, woItemIndex);
if (vm.saveResult.fatal) {
return;
}
for (let i = 0; i < vm.obj.items[woItemIndex].labors.length; i++) {
let o = vm.obj.items[woItemIndex].labors[i];
if (o.isDirty) {
const isPost = o.id == 0;
let res = await window.$gz.api.upsert(`${API_BASE_URL}items/labors`, o);
if (res.error) {
handleSaveError(vm, {
error: res.error,
itemUid: vm.obj.items[woItemIndex].uid,
childKey: "labors",
childUid: o.uid
});
} else {
//update any server changed fields
//always updated:
o.concurrency = res.data.concurrency;
o.isDirty = false;
//new records only...
if (isPost) {
o.id = res.data.id;
o.workOrderItemId = res.data.workOrderItemId;
}
}
}
}
return; //made it
}
async function deleteLabors(vm, woItemIndex) {
//walk the array backwards as items may be spliced out
for (var i = vm.obj.items[woItemIndex].labors.length - 1; i >= 0; i--) {
const d = vm.obj.items[woItemIndex].labors[i];
if (!d.deleted) {
continue;
}
let res = await window.$gz.api.remove(
`${API_BASE_URL}items/labors/${d.id}`
);
if (res.error) {
handleSaveError(vm, {
error: res.error,
itemUid: vm.obj.items[woItemIndex].uid,
childKey: "labors",
childUid: d.uid
});
} else {
vm.obj.items[woItemIndex].labors.splice(i, 1);
}
}
//----
return;
}
//todo: other grandchildren
//######################################### UTILITY METHODS ###########################################
@@ -1273,7 +1342,20 @@ async function fetchTranslatedText(vm) {
"WorkOrderItemExpenseReimburseUser",
"WorkOrderItemExpenseTaxPaid",
"WorkOrderItemExpenseTotalCost",
"WorkOrderItemExpenseUserID"
"WorkOrderItemExpenseUserID",
"WorkOrderItemLaborList",
"WorkOrderItemLaborServiceStartDate",
"WorkOrderItemLaborServiceStopDate",
"WorkOrderItemLaborServiceRateQuantity",
"WorkOrderItemLaborServiceRateID",
"WorkOrderItemLaborServiceDetails",
"WorkOrderItemLaborUserID",
"WorkOrderItemLaborNoChargeQuantity",
"WorkOrderItemLaborTaxRateSaleID",
"WorkOrderItemLaborManualDiscountPct",
"WorkOrderItemLaborBasePrice",
"WorkOrderItemLaborPrice",
"WorkOrderItemLaborServiceStartDate"
]);
}