This commit is contained in:
826
ayanova/src/components/work-order-item-parts.vue
Normal file
826
ayanova/src/components/work-order-item-parts.vue
Normal file
@@ -0,0 +1,826 @@
|
|||||||
|
<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">$ayiBoxes</v-icon>
|
||||||
|
{{ $ay.t("WorkOrderItemPartList") }}
|
||||||
|
<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="partsTable"
|
||||||
|
dense
|
||||||
|
:item-class="itemRowClasses"
|
||||||
|
@click:row="handleRowClick"
|
||||||
|
:show-select="$vuetify.breakpoint.xs"
|
||||||
|
single-select
|
||||||
|
>
|
||||||
|
<template v-slot:[`item.taxOnTax`]="{ item }">
|
||||||
|
<v-simple-checkbox
|
||||||
|
v-model="item.taxOnTax"
|
||||||
|
disabled
|
||||||
|
></v-simple-checkbox>
|
||||||
|
</template>
|
||||||
|
</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, 'WorkOrderItemPartServiceStartDate')"
|
||||||
|
cols="12"
|
||||||
|
sm="6"
|
||||||
|
lg="4"
|
||||||
|
xl="3"
|
||||||
|
>
|
||||||
|
<gz-date-time-picker
|
||||||
|
:label="$ay.t('WorkOrderItemPartServiceStartDate')"
|
||||||
|
v-model="
|
||||||
|
value.items[activeWoItemIndex].parts[activeItemIndex]
|
||||||
|
.serviceStartDate
|
||||||
|
"
|
||||||
|
:readonly="formState.readOnly"
|
||||||
|
:disabled="isDeleted"
|
||||||
|
:ref="
|
||||||
|
`Items[${activeWoItemIndex}].parts[${activeItemIndex}].serviceStartDate`
|
||||||
|
"
|
||||||
|
data-cy="serviceStartDate"
|
||||||
|
:error-messages="
|
||||||
|
form().serverErrors(
|
||||||
|
this,
|
||||||
|
`Items[${activeWoItemIndex}].parts[${activeItemIndex}].serviceStartDate`
|
||||||
|
)
|
||||||
|
"
|
||||||
|
@input="
|
||||||
|
fieldValueChanged(
|
||||||
|
`Items[${activeWoItemIndex}].parts[${activeItemIndex}].serviceStartDate`
|
||||||
|
)
|
||||||
|
"
|
||||||
|
></gz-date-time-picker>
|
||||||
|
</v-col>
|
||||||
|
|
||||||
|
<v-col
|
||||||
|
v-if="form().showMe(this, 'WorkOrderItemPartServiceStopDate')"
|
||||||
|
cols="12"
|
||||||
|
sm="6"
|
||||||
|
lg="4"
|
||||||
|
xl="3"
|
||||||
|
>
|
||||||
|
<gz-date-time-picker
|
||||||
|
:label="$ay.t('WorkOrderItemPartServiceStopDate')"
|
||||||
|
v-model="
|
||||||
|
value.items[activeWoItemIndex].parts[activeItemIndex]
|
||||||
|
.serviceStopDate
|
||||||
|
"
|
||||||
|
:readonly="formState.readOnly"
|
||||||
|
:disabled="isDeleted"
|
||||||
|
:ref="
|
||||||
|
`Items[${activeWoItemIndex}].parts[${activeItemIndex}].serviceStopDate`
|
||||||
|
"
|
||||||
|
data-cy="serviceStopDate"
|
||||||
|
:rules="[
|
||||||
|
form().datePrecedence(
|
||||||
|
this,
|
||||||
|
`Items[${activeWoItemIndex}].parts[${activeItemIndex}].serviceStartDate`,
|
||||||
|
`Items[${activeWoItemIndex}].parts[${activeItemIndex}].serviceStopDate`
|
||||||
|
)
|
||||||
|
]"
|
||||||
|
:error-messages="
|
||||||
|
form().serverErrors(
|
||||||
|
this,
|
||||||
|
`Items[${activeWoItemIndex}].parts[${activeItemIndex}].serviceStopDate`
|
||||||
|
)
|
||||||
|
"
|
||||||
|
@input="
|
||||||
|
fieldValueChanged(
|
||||||
|
`Items[${activeWoItemIndex}].parts[${activeItemIndex}].serviceStopDate`
|
||||||
|
)
|
||||||
|
"
|
||||||
|
></gz-date-time-picker>
|
||||||
|
</v-col>
|
||||||
|
|
||||||
|
<v-col
|
||||||
|
v-if="form().showMe(this, 'WorkOrderItemPartServiceRateQuantity')"
|
||||||
|
cols="12"
|
||||||
|
sm="6"
|
||||||
|
lg="4"
|
||||||
|
xl="3"
|
||||||
|
>
|
||||||
|
<gz-decimal
|
||||||
|
v-model="
|
||||||
|
value.items[activeWoItemIndex].parts[activeItemIndex]
|
||||||
|
.serviceRateQuantity
|
||||||
|
"
|
||||||
|
:readonly="formState.readOnly || isDeleted"
|
||||||
|
:disabled="isDeleted"
|
||||||
|
:label="$ay.t('WorkOrderItemPartServiceRateQuantity')"
|
||||||
|
:ref="
|
||||||
|
`Items[${activeWoItemIndex}].parts[${activeItemIndex}].serviceRateQuantity`
|
||||||
|
"
|
||||||
|
data-cy="partServiceRateQuantity"
|
||||||
|
:error-messages="
|
||||||
|
form().serverErrors(
|
||||||
|
this,
|
||||||
|
`Items[${activeWoItemIndex}].parts[${activeItemIndex}].serviceRateQuantity`
|
||||||
|
)
|
||||||
|
"
|
||||||
|
:rules="[
|
||||||
|
form().decimalValid(
|
||||||
|
this,
|
||||||
|
`Items[${activeWoItemIndex}].parts[${activeItemIndex}].serviceRateQuantity`
|
||||||
|
),
|
||||||
|
form().required(
|
||||||
|
this,
|
||||||
|
`Items[${activeWoItemIndex}].parts[${activeItemIndex}].serviceRateQuantity`
|
||||||
|
)
|
||||||
|
]"
|
||||||
|
@input="
|
||||||
|
fieldValueChanged(`Items[${activeWoItemIndex}].parts[
|
||||||
|
${activeItemIndex}
|
||||||
|
].serviceRateQuantity`)
|
||||||
|
"
|
||||||
|
></gz-decimal>
|
||||||
|
</v-col>
|
||||||
|
|
||||||
|
<v-col
|
||||||
|
v-if="form().showMe(this, 'WorkOrderItemPartServiceRateID')"
|
||||||
|
cols="12"
|
||||||
|
sm="6"
|
||||||
|
lg="4"
|
||||||
|
xl="3"
|
||||||
|
>
|
||||||
|
<gz-pick-list
|
||||||
|
:aya-type="$ay.ayt().ServiceRate"
|
||||||
|
:variant="'contractid:' + value.contractId"
|
||||||
|
:show-edit-icon="true"
|
||||||
|
v-model="
|
||||||
|
value.items[activeWoItemIndex].parts[activeItemIndex]
|
||||||
|
.serviceRateId
|
||||||
|
"
|
||||||
|
:readonly="formState.readOnly || isDeleted"
|
||||||
|
:disabled="isDeleted"
|
||||||
|
:label="$ay.t('WorkOrderItemPartServiceRateID')"
|
||||||
|
:ref="
|
||||||
|
`Items[${activeWoItemIndex}].parts[${activeItemIndex}].serviceRateId`
|
||||||
|
"
|
||||||
|
data-cy="parts.serviceRateId"
|
||||||
|
:error-messages="
|
||||||
|
form().serverErrors(
|
||||||
|
this,
|
||||||
|
`Items[${activeWoItemIndex}].parts[${activeItemIndex}].serviceRateId`
|
||||||
|
)
|
||||||
|
"
|
||||||
|
@input="
|
||||||
|
fieldValueChanged(
|
||||||
|
`Items[${activeWoItemIndex}].parts[${activeItemIndex}].serviceRateId`
|
||||||
|
)
|
||||||
|
"
|
||||||
|
@update:name="rateChange"
|
||||||
|
></gz-pick-list>
|
||||||
|
</v-col>
|
||||||
|
|
||||||
|
<v-col
|
||||||
|
v-if="form().showMe(this, 'WorkOrderItemPartUserID')"
|
||||||
|
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].parts[activeItemIndex].userId
|
||||||
|
"
|
||||||
|
:readonly="formState.readOnly || isDeleted"
|
||||||
|
:disabled="isDeleted"
|
||||||
|
:label="$ay.t('WorkOrderItemPartUserID')"
|
||||||
|
:ref="
|
||||||
|
`Items[${activeWoItemIndex}].parts[${activeItemIndex}].userId`
|
||||||
|
"
|
||||||
|
data-cy="parts.userid"
|
||||||
|
:error-messages="
|
||||||
|
form().serverErrors(
|
||||||
|
this,
|
||||||
|
`Items[${activeWoItemIndex}].parts[${activeItemIndex}].userId`
|
||||||
|
)
|
||||||
|
"
|
||||||
|
@input="
|
||||||
|
fieldValueChanged(
|
||||||
|
`Items[${activeWoItemIndex}].parts[${activeItemIndex}].userId`
|
||||||
|
)
|
||||||
|
"
|
||||||
|
@update:name="userChange"
|
||||||
|
></gz-pick-list>
|
||||||
|
</v-col>
|
||||||
|
|
||||||
|
<v-col
|
||||||
|
v-if="form().showMe(this, 'WorkOrderItemPartNoChargeQuantity')"
|
||||||
|
cols="12"
|
||||||
|
sm="6"
|
||||||
|
lg="4"
|
||||||
|
xl="3"
|
||||||
|
>
|
||||||
|
<gz-decimal
|
||||||
|
v-model="
|
||||||
|
value.items[activeWoItemIndex].parts[activeItemIndex]
|
||||||
|
.noChargeQuantity
|
||||||
|
"
|
||||||
|
:readonly="formState.readOnly || isDeleted"
|
||||||
|
:disabled="isDeleted"
|
||||||
|
:label="$ay.t('WorkOrderItemPartNoChargeQuantity')"
|
||||||
|
:ref="
|
||||||
|
`Items[${activeWoItemIndex}].parts[${activeItemIndex}].noChargeQuantity`
|
||||||
|
"
|
||||||
|
data-cy="partNoChargeQuantity"
|
||||||
|
:error-messages="
|
||||||
|
form().serverErrors(
|
||||||
|
this,
|
||||||
|
`Items[${activeWoItemIndex}].parts[${activeItemIndex}].noChargeQuantity`
|
||||||
|
)
|
||||||
|
"
|
||||||
|
:rules="[
|
||||||
|
form().decimalValid(
|
||||||
|
this,
|
||||||
|
`Items[${activeWoItemIndex}].parts[${activeItemIndex}].noChargeQuantity`
|
||||||
|
),
|
||||||
|
form().required(
|
||||||
|
this,
|
||||||
|
`Items[${activeWoItemIndex}].parts[${activeItemIndex}].noChargeQuantity`
|
||||||
|
)
|
||||||
|
]"
|
||||||
|
@input="
|
||||||
|
fieldValueChanged(`Items[${activeWoItemIndex}].parts[
|
||||||
|
${activeItemIndex}
|
||||||
|
].noChargeQuantity`)
|
||||||
|
"
|
||||||
|
></gz-decimal>
|
||||||
|
</v-col>
|
||||||
|
|
||||||
|
<v-col
|
||||||
|
v-if="form().showMe(this, 'WorkOrderItemPartTaxRateSaleID')"
|
||||||
|
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]
|
||||||
|
.taxCodeSaleId
|
||||||
|
"
|
||||||
|
:readonly="formState.readOnly || isDeleted"
|
||||||
|
:disabled="isDeleted"
|
||||||
|
:label="$ay.t('WorkOrderItemPartTaxRateSaleID')"
|
||||||
|
:ref="
|
||||||
|
`Items[${activeWoItemIndex}].parts[${activeItemIndex}].taxCodeSaleId`
|
||||||
|
"
|
||||||
|
data-cy="partTaxCodeSaleId"
|
||||||
|
:error-messages="
|
||||||
|
form().serverErrors(
|
||||||
|
this,
|
||||||
|
`Items[${activeWoItemIndex}].parts[${activeItemIndex}].taxCodeSaleId`
|
||||||
|
)
|
||||||
|
"
|
||||||
|
@input="
|
||||||
|
fieldValueChanged(
|
||||||
|
`Items[${activeWoItemIndex}].parts[${activeItemIndex}].taxCodeSaleId`
|
||||||
|
)
|
||||||
|
"
|
||||||
|
@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, 'WorkOrderItemPartServiceDetails')"
|
||||||
|
cols="12"
|
||||||
|
>
|
||||||
|
<v-textarea
|
||||||
|
v-model="
|
||||||
|
value.items[activeWoItemIndex].parts[activeItemIndex]
|
||||||
|
.serviceDetails
|
||||||
|
"
|
||||||
|
:readonly="formState.readOnly"
|
||||||
|
:disabled="isDeleted"
|
||||||
|
:label="$ay.t('WorkOrderItemPartServiceDetails')"
|
||||||
|
:error-messages="
|
||||||
|
form().serverErrors(
|
||||||
|
this,
|
||||||
|
`Items[${activeWoItemIndex}].parts[
|
||||||
|
${activeItemIndex}
|
||||||
|
].serviceDetails`
|
||||||
|
)
|
||||||
|
"
|
||||||
|
:ref="
|
||||||
|
`Items[${activeWoItemIndex}].parts[
|
||||||
|
${activeItemIndex}
|
||||||
|
].serviceDetails`
|
||||||
|
"
|
||||||
|
data-cy="partserviceDetails"
|
||||||
|
@input="
|
||||||
|
fieldValueChanged(`Items[${activeWoItemIndex}].parts[
|
||||||
|
${activeItemIndex}
|
||||||
|
].serviceDetails`)
|
||||||
|
"
|
||||||
|
auto-grow
|
||||||
|
></v-textarea>
|
||||||
|
</v-col>
|
||||||
|
</template>
|
||||||
|
</v-row>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<script>
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/* XXXeslint-disable */
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
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].parts[
|
||||||
|
this.activeItemIndex
|
||||||
|
].userViz = newName;
|
||||||
|
},
|
||||||
|
rateChange(newName) {
|
||||||
|
this.value.items[this.activeWoItemIndex].parts[
|
||||||
|
this.activeItemIndex
|
||||||
|
].serviceRateViz = newName;
|
||||||
|
},
|
||||||
|
taxCodeChange(newName) {
|
||||||
|
this.value.items[this.activeWoItemIndex].parts[
|
||||||
|
this.activeItemIndex
|
||||||
|
].taxCodeSaleViz = newName;
|
||||||
|
},
|
||||||
|
newItem() {
|
||||||
|
let newIndex = this.value.items[this.activeWoItemIndex].parts.length;
|
||||||
|
|
||||||
|
this.value.items[this.activeWoItemIndex].parts.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,
|
||||||
|
taxName: null,
|
||||||
|
price: 0,
|
||||||
|
priceOverride: null,
|
||||||
|
//costViz: 0,
|
||||||
|
// listPriceViz: 0,
|
||||||
|
//taxAViz: 0,
|
||||||
|
//taxBViz: 0,
|
||||||
|
//lineTotalViz: 0,
|
||||||
|
//unitOfMeasureViz: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].parts[
|
||||||
|
this.activeItemIndex
|
||||||
|
].deleted = false;
|
||||||
|
this.setDefaultView();
|
||||||
|
},
|
||||||
|
deleteItem() {
|
||||||
|
this.value.items[this.activeWoItemIndex].parts[
|
||||||
|
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].parts.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].parts[
|
||||||
|
this.activeItemIndex
|
||||||
|
].isDirty = true;
|
||||||
|
window.$gz.form.fieldValueChanged(this.pvm, ref);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
itemRowClasses: function(item) {
|
||||||
|
let ret = "";
|
||||||
|
const isDeleted =
|
||||||
|
this.value.items[this.activeWoItemIndex].parts[item.index].deleted ===
|
||||||
|
true;
|
||||||
|
|
||||||
|
const hasError = this.form().childRowHasError(
|
||||||
|
this,
|
||||||
|
`Items[${this.activeWoItemIndex}].Parts[${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].parts[this.activeItemIndex] ==
|
||||||
|
null
|
||||||
|
) {
|
||||||
|
this.setDefaultView();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
this.value.items[this.activeWoItemIndex].parts[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, "WorkOrderItemPartServiceStartDate")) {
|
||||||
|
headers.push({
|
||||||
|
text: this.$ay.t("WorkOrderItemPartServiceStartDate"),
|
||||||
|
align: "right",
|
||||||
|
value: "serviceStartDate"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.form().showMe(this, "WorkOrderItemPartServiceStopDate")) {
|
||||||
|
headers.push({
|
||||||
|
text: this.$ay.t("WorkOrderItemPartServiceStopDate"),
|
||||||
|
align: "right",
|
||||||
|
value: "serviceStopDate"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.form().showMe(this, "WorkOrderItemPartServiceRateQuantity")) {
|
||||||
|
headers.push({
|
||||||
|
text: this.$ay.t("WorkOrderItemPartServiceRateQuantity"),
|
||||||
|
align: "right",
|
||||||
|
value: "serviceRateQuantity"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.form().showMe(this, "WorkOrderItemPartServiceRateID")) {
|
||||||
|
headers.push({
|
||||||
|
text: this.$ay.t("WorkOrderItemPartServiceRateID"),
|
||||||
|
align: "left",
|
||||||
|
value: "serviceRateViz"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.form().showMe(this, "WorkOrderItemPartServiceDetails")) {
|
||||||
|
headers.push({
|
||||||
|
text: this.$ay.t("WorkOrderItemPartServiceDetails"),
|
||||||
|
align: "left",
|
||||||
|
value: "serviceDetails"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.form().showMe(this, "WorkOrderItemPartUserID")) {
|
||||||
|
headers.push({
|
||||||
|
text: this.$ay.t("WorkOrderItemPartUserID"),
|
||||||
|
align: "left",
|
||||||
|
value: "userViz"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.form().showMe(this, "WorkOrderItemPartNoChargeQuantity")) {
|
||||||
|
headers.push({
|
||||||
|
text: this.$ay.t("WorkOrderItemPartNoChargeQuantity"),
|
||||||
|
align: "right",
|
||||||
|
value: "noChargeQuantity"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.form().showMe(this, "PartUnitOfMeasureViz")) {
|
||||||
|
headers.push({
|
||||||
|
text: this.$ay.t("UnitOfMeasure"),
|
||||||
|
align: "left",
|
||||||
|
value: "unitOfMeasureViz"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.form().showMe(this, "PartCostViz")) {
|
||||||
|
headers.push({
|
||||||
|
text: this.$ay.t("Cost"),
|
||||||
|
align: "right",
|
||||||
|
value: "costViz"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.form().showMe(this, "PartListPriceViz")) {
|
||||||
|
headers.push({
|
||||||
|
text: this.$ay.t("ListPrice"),
|
||||||
|
align: "right",
|
||||||
|
value: "listPriceViz"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.form().showMe(this, "PartPriceViz")) {
|
||||||
|
headers.push({
|
||||||
|
text: this.$ay.t("PriceOverride"),
|
||||||
|
align: "right",
|
||||||
|
value: "priceOverride"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.form().showMe(this, "PartPriceViz")) {
|
||||||
|
headers.push({
|
||||||
|
text: this.$ay.t("Price"),
|
||||||
|
align: "right",
|
||||||
|
value: "priceViz"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.form().showMe(this, "WorkOrderItemPartTaxRateSaleID")) {
|
||||||
|
headers.push({
|
||||||
|
text: this.$ay.t("Tax"),
|
||||||
|
align: "left",
|
||||||
|
value: "taxCodeSaleViz"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.form().showMe(this, "PartNetViz")) {
|
||||||
|
headers.push({
|
||||||
|
text: this.$ay.t("NetPrice"),
|
||||||
|
align: "right",
|
||||||
|
value: "netViz"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.form().showMe(this, "PartTaxAViz")) {
|
||||||
|
headers.push({
|
||||||
|
text: this.$ay.t("TaxAAmt"),
|
||||||
|
align: "right",
|
||||||
|
value: "taxAViz"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.form().showMe(this, "PartTaxBViz")) {
|
||||||
|
headers.push({
|
||||||
|
text: this.$ay.t("TaxBAmt"),
|
||||||
|
align: "right",
|
||||||
|
value: "taxBViz"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.form().showMe(this, "PartLineTotalViz")) {
|
||||||
|
headers.push({
|
||||||
|
text: this.$ay.t("LineTotal"),
|
||||||
|
align: "right",
|
||||||
|
value: "lineTotalViz"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return headers;
|
||||||
|
},
|
||||||
|
itemList: function() {
|
||||||
|
return this.value.items[this.activeWoItemIndex].parts.map((x, i) => {
|
||||||
|
return {
|
||||||
|
index: i,
|
||||||
|
id: x.id,
|
||||||
|
serviceStartDate: window.$gz.locale.utcDateToShortDateAndTimeLocalized(
|
||||||
|
x.serviceStartDate,
|
||||||
|
this.pvm.timeZoneName,
|
||||||
|
this.pvm.languageName,
|
||||||
|
this.pvm.hour12
|
||||||
|
),
|
||||||
|
serviceStopDate: window.$gz.locale.utcDateToShortDateAndTimeLocalized(
|
||||||
|
x.serviceStopDate,
|
||||||
|
this.pvm.timeZoneName,
|
||||||
|
this.pvm.languageName,
|
||||||
|
this.pvm.hour12
|
||||||
|
),
|
||||||
|
|
||||||
|
serviceRateQuantity: window.$gz.locale.decimalLocalized(
|
||||||
|
x.serviceRateQuantity,
|
||||||
|
this.pvm.languageName
|
||||||
|
),
|
||||||
|
serviceRateViz: x.serviceRateViz,
|
||||||
|
userViz: x.userViz,
|
||||||
|
noChargeQuantity: window.$gz.locale.decimalLocalized(
|
||||||
|
x.noChargeQuantity,
|
||||||
|
this.pvm.languageName
|
||||||
|
),
|
||||||
|
unitOfMeasureViz: x.unitOfMeasureViz,
|
||||||
|
costViz: window.$gz.locale.currencyLocalized(
|
||||||
|
x.costViz,
|
||||||
|
this.pvm.languageName,
|
||||||
|
this.pvm.currencyName
|
||||||
|
),
|
||||||
|
listPriceViz: window.$gz.locale.currencyLocalized(
|
||||||
|
x.listPriceViz,
|
||||||
|
this.pvm.languageName,
|
||||||
|
this.pvm.currencyName
|
||||||
|
),
|
||||||
|
priceViz: window.$gz.locale.currencyLocalized(
|
||||||
|
x.priceViz,
|
||||||
|
this.pvm.languageName,
|
||||||
|
this.pvm.currencyName
|
||||||
|
),
|
||||||
|
taxCodeSaleViz: x.taxCodeSaleViz,
|
||||||
|
priceOverride: window.$gz.locale.currencyLocalized(
|
||||||
|
x.priceOverride,
|
||||||
|
this.pvm.languageName,
|
||||||
|
this.pvm.currencyName
|
||||||
|
),
|
||||||
|
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
|
||||||
|
),
|
||||||
|
serviceDetails: window.$gz.util.truncateString(x.serviceDetails, 50)
|
||||||
|
};
|
||||||
|
});
|
||||||
|
},
|
||||||
|
formState: function() {
|
||||||
|
return this.pvm.formState;
|
||||||
|
},
|
||||||
|
formCustomTemplateKey: function() {
|
||||||
|
return this.pvm.formCustomTemplateKey;
|
||||||
|
},
|
||||||
|
showTable: function() {
|
||||||
|
return this.value.items[this.activeWoItemIndex].parts.length > 1;
|
||||||
|
},
|
||||||
|
canAdd: function() {
|
||||||
|
return this.pvm.rights.change && this.pvm.subRights.parts.create;
|
||||||
|
},
|
||||||
|
canDelete: function() {
|
||||||
|
return (
|
||||||
|
this.activeItemIndex != null &&
|
||||||
|
this.pvm.rights.change &&
|
||||||
|
this.pvm.subRights.parts.delete
|
||||||
|
);
|
||||||
|
}
|
||||||
|
//----
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
||||||
Reference in New Issue
Block a user