This commit is contained in:
2021-05-24 20:13:05 +00:00
parent 4d77a62f78
commit d5706f6dd7

View File

@@ -89,27 +89,25 @@
xl="3" xl="3"
> >
<v-text-field <v-text-field
v-model=" v-model="value.items[activeWoItemIndex].tasks[activeItemIndex].name"
value.items[activeWoItemIndex].expenses[activeItemIndex].name
"
:readonly="formState.readOnly" :readonly="formState.readOnly"
:disabled="isDeleted" :disabled="isDeleted"
:label="$ay.t('WorkOrderItemExpenseName')" :label="$ay.t('WorkOrderItemExpenseName')"
:ref=" :ref="
`Items[${activeWoItemIndex}].expenses[ `Items[${activeWoItemIndex}].tasks[
${activeItemIndex} ${activeItemIndex}
].name` ].name`
" "
:error-messages=" :error-messages="
form().serverErrors( form().serverErrors(
this, this,
`Items[${activeWoItemIndex}].expenses[ `Items[${activeWoItemIndex}].tasks[
${activeItemIndex} ${activeItemIndex}
].name` ].name`
) )
" "
@input=" @input="
fieldValueChanged(`Items[${activeWoItemIndex}].expenses[ fieldValueChanged(`Items[${activeWoItemIndex}].tasks[
${activeItemIndex} ${activeItemIndex}
].name`) ].name`)
" "
@@ -125,33 +123,33 @@
> >
<gz-currency <gz-currency
v-model=" v-model="
value.items[activeWoItemIndex].expenses[activeItemIndex].totalCost value.items[activeWoItemIndex].tasks[activeItemIndex].totalCost
" "
:readonly="formState.readOnly || isDeleted" :readonly="formState.readOnly || isDeleted"
:disabled="isDeleted" :disabled="isDeleted"
:label="$ay.t('WorkOrderItemExpenseTotalCost')" :label="$ay.t('WorkOrderItemExpenseTotalCost')"
:ref=" :ref="
`Items[${activeWoItemIndex}].expenses[${activeItemIndex}].totalCost` `Items[${activeWoItemIndex}].tasks[${activeItemIndex}].totalCost`
" "
data-cy="expenseTotalCost" data-cy="expenseTotalCost"
:error-messages=" :error-messages="
form().serverErrors( form().serverErrors(
this, this,
`Items[${activeWoItemIndex}].expenses[${activeItemIndex}].totalCost` `Items[${activeWoItemIndex}].tasks[${activeItemIndex}].totalCost`
) )
" "
:rules="[ :rules="[
form().decimalValid( form().decimalValid(
this, this,
`Items[${activeWoItemIndex}].expenses[${activeItemIndex}].totalCost` `Items[${activeWoItemIndex}].tasks[${activeItemIndex}].totalCost`
), ),
form().required( form().required(
this, this,
`Items[${activeWoItemIndex}].expenses[${activeItemIndex}].totalCost` `Items[${activeWoItemIndex}].tasks[${activeItemIndex}].totalCost`
) )
]" ]"
@input=" @input="
fieldValueChanged(`Items[${activeWoItemIndex}].expenses[ fieldValueChanged(`Items[${activeWoItemIndex}].tasks[
${activeItemIndex} ${activeItemIndex}
].totalCost`) ].totalCost`)
" "
@@ -167,34 +165,33 @@
> >
<gz-currency <gz-currency
v-model=" v-model="
value.items[activeWoItemIndex].expenses[activeItemIndex] value.items[activeWoItemIndex].tasks[activeItemIndex].chargeAmount
.chargeAmount
" "
:readonly="formState.readOnly || isDeleted" :readonly="formState.readOnly || isDeleted"
:disabled="isDeleted" :disabled="isDeleted"
:label="$ay.t('WorkOrderItemExpenseChargeAmount')" :label="$ay.t('WorkOrderItemExpenseChargeAmount')"
:ref=" :ref="
`Items[${activeWoItemIndex}].expenses[${activeItemIndex}].chargeAmount` `Items[${activeWoItemIndex}].tasks[${activeItemIndex}].chargeAmount`
" "
data-cy="expenseChargeAmount" data-cy="expenseChargeAmount"
:error-messages=" :error-messages="
form().serverErrors( form().serverErrors(
this, this,
`Items[${activeWoItemIndex}].expenses[${activeItemIndex}].chargeAmount` `Items[${activeWoItemIndex}].tasks[${activeItemIndex}].chargeAmount`
) )
" "
:rules="[ :rules="[
form().decimalValid( form().decimalValid(
this, this,
`Items[${activeWoItemIndex}].expenses[${activeItemIndex}].chargeAmount` `Items[${activeWoItemIndex}].tasks[${activeItemIndex}].chargeAmount`
), ),
form().required( form().required(
this, this,
`Items[${activeWoItemIndex}].expenses[${activeItemIndex}].chargeAmount` `Items[${activeWoItemIndex}].tasks[${activeItemIndex}].chargeAmount`
) )
]" ]"
@input=" @input="
fieldValueChanged(`Items[${activeWoItemIndex}].expenses[ fieldValueChanged(`Items[${activeWoItemIndex}].tasks[
${activeItemIndex} ${activeItemIndex}
].chargeAmount`) ].chargeAmount`)
" "
@@ -210,24 +207,24 @@
> >
<v-checkbox <v-checkbox
v-model=" v-model="
value.items[activeWoItemIndex].expenses[activeItemIndex] value.items[activeWoItemIndex].tasks[activeItemIndex]
.chargeToCustomer .chargeToCustomer
" "
:readonly="formState.readOnly" :readonly="formState.readOnly"
:disabled="isDeleted" :disabled="isDeleted"
:label="$ay.t('WorkOrderItemExpenseChargeToCustomer')" :label="$ay.t('WorkOrderItemExpenseChargeToCustomer')"
:ref=" :ref="
`Items[${activeWoItemIndex}].expenses[${activeItemIndex}].chargeToCustomer` `Items[${activeWoItemIndex}].tasks[${activeItemIndex}].chargeToCustomer`
" "
data-cy="chargeToCustomer" data-cy="chargeToCustomer"
:error-messages=" :error-messages="
form().serverErrors( form().serverErrors(
this, this,
`Items[${activeWoItemIndex}].expenses[${activeItemIndex}].chargeToCustomer` `Items[${activeWoItemIndex}].tasks[${activeItemIndex}].chargeToCustomer`
) )
" "
@change=" @change="
fieldValueChanged(`Items[${activeWoItemIndex}].expenses[ fieldValueChanged(`Items[${activeWoItemIndex}].tasks[
${activeItemIndex} ${activeItemIndex}
].chargeToCustomer`) ].chargeToCustomer`)
" "
@@ -243,33 +240,33 @@
> >
<gz-currency <gz-currency
v-model=" v-model="
value.items[activeWoItemIndex].expenses[activeItemIndex].taxPaid value.items[activeWoItemIndex].tasks[activeItemIndex].taxPaid
" "
:readonly="formState.readOnly || isDeleted" :readonly="formState.readOnly || isDeleted"
:disabled="isDeleted" :disabled="isDeleted"
:label="$ay.t('WorkOrderItemExpenseTaxPaid')" :label="$ay.t('WorkOrderItemExpenseTaxPaid')"
:ref=" :ref="
`Items[${activeWoItemIndex}].expenses[${activeItemIndex}].taxPaid` `Items[${activeWoItemIndex}].tasks[${activeItemIndex}].taxPaid`
" "
data-cy="expenseTaxPaid" data-cy="expenseTaxPaid"
:error-messages=" :error-messages="
form().serverErrors( form().serverErrors(
this, this,
`Items[${activeWoItemIndex}].expenses[${activeItemIndex}].taxPaid` `Items[${activeWoItemIndex}].tasks[${activeItemIndex}].taxPaid`
) )
" "
:rules="[ :rules="[
form().decimalValid( form().decimalValid(
this, this,
`Items[${activeWoItemIndex}].expenses[${activeItemIndex}].taxPaid` `Items[${activeWoItemIndex}].tasks[${activeItemIndex}].taxPaid`
), ),
form().required( form().required(
this, this,
`Items[${activeWoItemIndex}].expenses[${activeItemIndex}].taxPaid` `Items[${activeWoItemIndex}].tasks[${activeItemIndex}].taxPaid`
) )
]" ]"
@input=" @input="
fieldValueChanged(`Items[${activeWoItemIndex}].expenses[ fieldValueChanged(`Items[${activeWoItemIndex}].tasks[
${activeItemIndex} ${activeItemIndex}
].taxPaid`) ].taxPaid`)
" "
@@ -287,28 +284,28 @@
:aya-type="$ay.ayt().TaxCode" :aya-type="$ay.ayt().TaxCode"
:show-edit-icon="true" :show-edit-icon="true"
v-model=" v-model="
value.items[activeWoItemIndex].expenses[activeItemIndex] value.items[activeWoItemIndex].tasks[activeItemIndex]
.chargeTaxCodeId .chargeTaxCodeId
" "
:readonly="formState.readOnly || isDeleted" :readonly="formState.readOnly || isDeleted"
:disabled="isDeleted" :disabled="isDeleted"
:label="$ay.t('WorkOrderItemExpenseChargeTaxCodeID')" :label="$ay.t('WorkOrderItemExpenseChargeTaxCodeID')"
:ref=" :ref="
`Items[${activeWoItemIndex}].expenses[${activeItemIndex}].chargeTaxCodeId` `Items[${activeWoItemIndex}].tasks[${activeItemIndex}].chargeTaxCodeId`
" "
data-cy="expenseChargeTaxCode" data-cy="expenseChargeTaxCode"
:error-messages=" :error-messages="
form().serverErrors( form().serverErrors(
this, this,
`Items[${activeWoItemIndex}].expenses[${activeItemIndex}].chargeTaxCodeId` `Items[${activeWoItemIndex}].tasks[${activeItemIndex}].chargeTaxCodeId`
) )
" "
@input=" @input="
fieldValueChanged( fieldValueChanged(
`Items[${activeWoItemIndex}].expenses[${activeItemIndex}].chargeTaxCodeId` `Items[${activeWoItemIndex}].tasks[${activeItemIndex}].chargeTaxCodeId`
) )
" "
@update:name="taxCodeChange" @update:name="statusChange"
></gz-pick-list> ></gz-pick-list>
</v-col> </v-col>
@@ -321,24 +318,24 @@
> >
<v-checkbox <v-checkbox
v-model=" v-model="
value.items[activeWoItemIndex].expenses[activeItemIndex] value.items[activeWoItemIndex].tasks[activeItemIndex]
.reimburseUser .reimburseUser
" "
:readonly="formState.readOnly" :readonly="formState.readOnly"
:disabled="isDeleted" :disabled="isDeleted"
:label="$ay.t('WorkOrderItemExpenseReimburseUser')" :label="$ay.t('WorkOrderItemExpenseReimburseUser')"
:ref=" :ref="
`Items[${activeWoItemIndex}].expenses[${activeItemIndex}].reimburseUser` `Items[${activeWoItemIndex}].tasks[${activeItemIndex}].reimburseUser`
" "
data-cy="expenseReimburseUser" data-cy="expenseReimburseUser"
:error-messages=" :error-messages="
form().serverErrors( form().serverErrors(
this, this,
`Items[${activeWoItemIndex}].expenses[${activeItemIndex}].reimburseUser` `Items[${activeWoItemIndex}].tasks[${activeItemIndex}].reimburseUser`
) )
" "
@change=" @change="
fieldValueChanged(`Items[${activeWoItemIndex}].expenses[ fieldValueChanged(`Items[${activeWoItemIndex}].tasks[
${activeItemIndex} ${activeItemIndex}
].reimburseUser`) ].reimburseUser`)
" "
@@ -357,24 +354,24 @@
variant="tech" variant="tech"
:show-edit-icon="true" :show-edit-icon="true"
v-model=" v-model="
value.items[activeWoItemIndex].expenses[activeItemIndex].userId value.items[activeWoItemIndex].tasks[activeItemIndex].userId
" "
:readonly="formState.readOnly || isDeleted" :readonly="formState.readOnly || isDeleted"
:disabled="isDeleted" :disabled="isDeleted"
:label="$ay.t('WorkOrderItemExpenseUserID')" :label="$ay.t('WorkOrderItemExpenseUserID')"
:ref=" :ref="
`Items[${activeWoItemIndex}].expenses[${activeItemIndex}].userId` `Items[${activeWoItemIndex}].tasks[${activeItemIndex}].userId`
" "
data-cy="expenseUser" data-cy="expenseUser"
:error-messages=" :error-messages="
form().serverErrors( form().serverErrors(
this, this,
`Items[${activeWoItemIndex}].expenses[${activeItemIndex}].userId` `Items[${activeWoItemIndex}].tasks[${activeItemIndex}].userId`
) )
" "
@input=" @input="
fieldValueChanged( fieldValueChanged(
`Items[${activeWoItemIndex}].expenses[${activeItemIndex}].userId` `Items[${activeWoItemIndex}].tasks[${activeItemIndex}].userId`
) )
" "
@update:name="userChange" @update:name="userChange"
@@ -387,8 +384,7 @@
> >
<v-textarea <v-textarea
v-model=" v-model="
value.items[activeWoItemIndex].expenses[activeItemIndex] value.items[activeWoItemIndex].tasks[activeItemIndex].description
.description
" "
:readonly="formState.readOnly" :readonly="formState.readOnly"
:disabled="isDeleted" :disabled="isDeleted"
@@ -396,19 +392,19 @@
:error-messages=" :error-messages="
form().serverErrors( form().serverErrors(
this, this,
`Items[${activeWoItemIndex}].expenses[ `Items[${activeWoItemIndex}].tasks[
${activeItemIndex} ${activeItemIndex}
].description` ].description`
) )
" "
:ref=" :ref="
`Items[${activeWoItemIndex}].expenses[ `Items[${activeWoItemIndex}].tasks[
${activeItemIndex} ${activeItemIndex}
].description` ].description`
" "
data-cy="expenseDescription" data-cy="expenseDescription"
@input=" @input="
fieldValueChanged(`Items[${activeWoItemIndex}].expenses[ fieldValueChanged(`Items[${activeWoItemIndex}].tasks[
${activeItemIndex} ${activeItemIndex}
].description`) ].description`)
" "
@@ -463,32 +459,25 @@ export default {
}, },
methods: { methods: {
userChange(newName) { userChange(newName) {
this.value.items[this.activeWoItemIndex].expenses[ this.value.items[this.activeWoItemIndex].tasks[
this.activeItemIndex this.activeItemIndex
].userViz = newName; ].completedByUserViz = newName;
}, },
taxCodeChange(newName) { statusChange(newName) {
this.value.items[this.activeWoItemIndex].expenses[ this.value.items[this.activeWoItemIndex].tasks[
this.activeItemIndex this.activeItemIndex
].chargeTaxCodeViz = newName; ].statusViz = newName;
}, },
newItem() { newItem() {
let newIndex = this.value.items[this.activeWoItemIndex].expenses.length; let newIndex = this.value.items[this.activeWoItemIndex].tasks.length;
this.value.items[this.activeWoItemIndex].tasks.push({
this.value.items[this.activeWoItemIndex].expenses.push({
id: 0, id: 0,
concurrency: 0, concurrency: 0,
description: null, sequence: newIndex + 1, //indexes are zero based but sequences are visible to user so 1 based
name: null, task: null,
totalCost: 0, status: 1, //incomplete==1
chargeAmount: 0, completedByUserId: null,
taxPaid: 0, completedDate: null,
chargeTaxCodeId: 0,
chargeTaxCodeViz: null,
reimburseUser: false,
userId: null,
userViz: null,
chargeToCustomer: false,
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
@@ -498,13 +487,13 @@ export default {
this.activeItemIndex = newIndex; this.activeItemIndex = newIndex;
}, },
unDeleteItem() { unDeleteItem() {
this.value.items[this.activeWoItemIndex].expenses[ this.value.items[this.activeWoItemIndex].tasks[
this.activeItemIndex this.activeItemIndex
].deleted = false; ].deleted = false;
this.setDefaultView(); this.setDefaultView();
}, },
deleteItem() { deleteItem() {
this.value.items[this.activeWoItemIndex].expenses[ this.value.items[this.activeWoItemIndex].tasks[
this.activeItemIndex this.activeItemIndex
].deleted = true; ].deleted = true;
this.setDefaultView(); this.setDefaultView();
@@ -512,7 +501,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].expenses.length == 1) { if (this.value.items[this.activeWoItemIndex].tasks.length == 1) {
this.selectedRow = [{ index: 0 }]; this.selectedRow = [{ index: 0 }];
this.activeItemIndex = 0; this.activeItemIndex = 0;
} else { } else {
@@ -530,7 +519,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].expenses[ this.value.items[this.activeWoItemIndex].tasks[
this.activeItemIndex this.activeItemIndex
].isDirty = true; ].isDirty = true;
window.$gz.form.fieldValueChanged(this.pvm, ref); window.$gz.form.fieldValueChanged(this.pvm, ref);
@@ -544,8 +533,8 @@ export default {
itemRowClasses: function(item) { itemRowClasses: function(item) {
let ret = ""; let ret = "";
const isDeleted = const isDeleted =
this.value.items[this.activeWoItemIndex].expenses[item.index] this.value.items[this.activeWoItemIndex].tasks[item.index].deleted ===
.deleted === true; true;
const hasError = this.form().childRowHasError( const hasError = this.form().childRowHasError(
this, this,
@@ -564,15 +553,14 @@ export default {
computed: { computed: {
isDeleted: function() { isDeleted: function() {
if ( if (
this.value.items[this.activeWoItemIndex].expenses[ this.value.items[this.activeWoItemIndex].tasks[this.activeItemIndex] ==
this.activeItemIndex null
] == null
) { ) {
this.setDefaultView(); this.setDefaultView();
return true; return true;
} }
return ( return (
this.value.items[this.activeWoItemIndex].expenses[this.activeItemIndex] this.value.items[this.activeWoItemIndex].tasks[this.activeItemIndex]
.deleted === true .deleted === true
); );
}, },
@@ -678,7 +666,7 @@ export default {
return headers; return headers;
}, },
itemList: function() { itemList: function() {
return this.value.items[this.activeWoItemIndex].expenses.map((x, i) => { return this.value.items[this.activeWoItemIndex].tasks.map((x, i) => {
return { return {
index: i, index: i,
id: x.id, id: x.id,
@@ -727,16 +715,16 @@ export default {
return this.pvm.formCustomTemplateKey; return this.pvm.formCustomTemplateKey;
}, },
showTable: function() { showTable: function() {
return this.value.items[this.activeWoItemIndex].expenses.length > 1; return this.value.items[this.activeWoItemIndex].tasks.length > 1;
}, },
canAdd: function() { canAdd: function() {
return this.pvm.rights.change && this.pvm.subRights.expenses.create; return this.pvm.rights.change && this.pvm.subRights.tasks.create;
}, },
canDelete: function() { canDelete: function() {
return ( return (
this.activeItemIndex != null && this.activeItemIndex != null &&
this.pvm.rights.change && this.pvm.rights.change &&
this.pvm.subRights.expenses.delete this.pvm.subRights.tasks.delete
); );
} }
} }