This commit is contained in:
2021-04-02 19:17:17 +00:00
parent aecaed01f7
commit 82d912d7c9
3 changed files with 243 additions and 43 deletions

View File

@@ -1,6 +1,48 @@
<template> <template>
<div> <div>
<h1>WorkOrder header</h1> <h1>WorkOrder header</h1>
<v-row>
<v-col cols="12" sm="6" lg="4" xl="3" v-if="value.serial != 0">
<template v-if="canEditSerial">
<v-text-field
v-model="value.serial"
:readonly="formState.readOnly"
:label="$ay.t('WorkOrderSerialNumber')"
ref="serial"
data-cy="serial"
:rules="[
form().integerValid(this, 'serial'),
form().required(this, 'serial')
]"
:error-messages="form().serverErrors(this, 'serial')"
@input="fieldValueChanged('serial')"
></v-text-field>
</template>
<template v-else>
<div>
<span class="text-caption">
{{ $ay.t("WorkOrderSerialNumber") }}</span
>
</div>
<div>
<span class="text-h5">{{ value.serial }}</span>
</div>
</template>
</v-col>
<v-col v-if="form().showMe(this, 'Notes')" cols="12">
<v-textarea
v-model="value.notes"
:readonly="formState.readOnly"
:label="$ay.t('WorkOrderSummary')"
:error-messages="form().serverErrors(this, 'notes')"
ref="notes"
data-cy="notes"
@input="fieldValueChanged('notes')"
auto-grow
></v-textarea>
</v-col>
</v-row>
</div> </div>
</template> </template>
<script> <script>
@@ -10,18 +52,19 @@
export default { export default {
data() { data() {
return {}; return {
canEditSerial: window.$gz.role.hasRole([
window.$gz.role.AUTHORIZATION_ROLES.BizAdminFull
])
};
}, },
props: { props: {
value: { value: {
default: "{}", default: null,
type: String type: Object
}, },
formKey: { type: String, default: "" }, //used to grab template from store pvm: {
readonly: Boolean,
disabled: Boolean,
parentVM: {
default: null, default: null,
type: Object type: Object
} }
@@ -32,14 +75,108 @@ export default {
return window.$gz.form; return window.$gz.form;
}, },
fieldValueChanged(ref) { fieldValueChanged(ref) {
if ( if (!this.formState.loading && !this.formState.readonly) {
!this.parentVM.formState.loading && window.$gz.form.fieldValueChanged(this.pvm, ref);
!this.parentVM.formState.readonly
) {
window.$gz.form.fieldValueChanged(this.parentVM, ref);
} }
} }
}, },
computed: {} computed: {
formState: function() {
return this.pvm.formState;
},
formCustomTemplateKey: function() {
return this.pvm.formCustomTemplateKey;
}
}
}; };
/*
data: {
id: 10,
concurrency: 7713074,
serial: 10,
notes:
"Sequi quia est occaecati vel aperiam dicta praesentium velit et.",
wiki: null,
customFields: null,
tags: ["orange", "violet"],
customerId: 14,
projectId: null,
internalReferenceNumber: "irf-4603",
customerReferenceNumber: "crf-4720",
customerContactName: "contact name here",
fromQuoteId: null,
fromPMId: null,
fromCSRId: null,
serviceDate: "2020-09-03T03:06:41.238542Z",
completeByDate: "2020-09-08T03:06:41.238542Z",
invoiceNumber: null,
customerSignature: null,
customerSignatureName: null,
customerSignatureCaptured: "0001-01-01T00:00:00Z",
postAddress: null,
postCity: null,
postRegion: null,
postCountry: null,
postCode: null,
address: null,
city: null,
region: null,
country: null,
latitude: null,
longitude: null,
items: [
{
id: 20,
concurrency: 7713074,
notes: "itemnotes",
wiki: null,
customFields: null,
tags: [],
workOrderId: 10,
techNotes: "technotes",
workorderItemStatusId: null,
workorderItemPriorityId: null,
requestDate: "2020-09-03T03:06:41.238542Z",
warrantyService: false,
isDirty: false,
expenses: [],
labors: [],
loans: [],
parts: [],
partRequests: [],
scheduledUsers: [
{
id: 39,
concurrency: 7713074,
userId: 30,
estimatedQuantity: 1,
startDate: null,
stopDate: null,
serviceRateId: null,
isDirty: false,
workOrderItemId: 20
},
{
id: 40,
concurrency: 7713074,
userId: 10,
estimatedQuantity: 2,
startDate: null,
stopDate: null,
serviceRateId: null,
isDirty: false,
workOrderItemId: 20
}
],
tasks: [],
travels: [],
units: [],
outsideServices: []
}
],
states: [],
isDirty: false
}
}
*/
</script> </script>

View File

@@ -1,6 +1,14 @@
<template> <template>
<div> <div>
<h2>WorkOrder items here</h2> <h2>WorkOrder items here</h2>
<template v-if="value.items.count > 1">
table of woitems here
</template>
<template v-if="pvm.selectedItemIndex">
woitem is selected
</template>
woitemfields
<GzWoItemScheduledUsers data-cy="woItemScheduledUsers" /> <GzWoItemScheduledUsers data-cy="woItemScheduledUsers" />
</div> </div>
</template> </template>
@@ -17,16 +25,12 @@ export default {
data() { data() {
return {}; return {};
}, },
props: { props: {
value: { value: {
default: "{}", default: null,
type: String type: Object
}, },
formKey: { type: String, default: "" }, //used to grab template from store pvm: {
readonly: Boolean,
disabled: Boolean,
parentVM: {
default: null, default: null,
type: Object type: Object
} }
@@ -37,14 +41,18 @@ export default {
return window.$gz.form; return window.$gz.form;
}, },
fieldValueChanged(ref) { fieldValueChanged(ref) {
if ( if (!this.formState.loading && !this.formState.readonly) {
!this.parentVM.formState.loading && window.$gz.form.fieldValueChanged(this.pvm, ref);
!this.parentVM.formState.readonly
) {
window.$gz.form.fieldValueChanged(this.parentVM, ref);
} }
} }
}, },
computed: {} computed: {
formState: function() {
return this.pvm.formState;
},
formCustomTemplateKey: function() {
return this.pvm.formCustomTemplateKey;
}
}
}; };
</script> </script>

View File

@@ -4,8 +4,20 @@
<div v-if="formState.ready"> <div v-if="formState.ready">
<gz-error :error-box-message="formState.errorBoxMessage"></gz-error> <gz-error :error-box-message="formState.errorBoxMessage"></gz-error>
<v-form ref="form"> <v-form ref="form">
<GzWoHeader data-cy="woHeader" /> <GzWoHeader
<GzWoItems data-cy="woItems" /> v-model="obj"
:form-key="formCustomTemplateKey"
:readonly="formState.readOnly"
:pvm="this"
data-cy="woHeader"
/>
<GzWoItems
v-model="obj"
:form-key="formCustomTemplateKey"
:readonly="formState.readOnly"
:pvm="this"
data-cy="woItems"
/>
</v-form> </v-form>
</div> </div>
<template v-if="!formState.ready"> <template v-if="!formState.ready">
@@ -73,6 +85,9 @@ export default {
}); });
generateMenu(vm); generateMenu(vm);
if (vm.obj.items.count > 0) {
selectedItemIndex = 0;
}
} catch (error) { } catch (error) {
window.$gz.errorHandler.handleFormError(error, vm); window.$gz.errorHandler.handleFormError(error, vm);
} finally { } finally {
@@ -100,19 +115,58 @@ export default {
//IMPORTANT NOTE: Fields that are NON NULLABLE in the schema for the table but *are* hideable **MUST** have a default value set here or else there will be no way to save the record //IMPORTANT NOTE: Fields that are NON NULLABLE in the schema for the table but *are* hideable **MUST** have a default value set here or else there will be no way to save the record
//I.E. Serial, usertype fields, ACTIVE //I.E. Serial, usertype fields, ACTIVE
//Also, if it's a non-nullable Enum backed field then it should have a valid selection i.e. not zero if there is no zero //Also, if it's a non-nullable Enum backed field then it should have a valid selection i.e. not zero if there is no zero
// {
// id: 0,
// concurrency: 0,
// name: null,
// active: true,
// notes: null,
// wiki: null,
// customFields: "{}",
// tags: [],
// dateStarted: window.$gz.locale.nowUTC8601String(),
// dateCompleted: null,
// workorderOverseerId: null,
// accountNumber: null
// }
{ {
data: {
id: 0, id: 0,
concurrency: 0, concurrency: 0,
name: null, serial: null,
active: true,
notes: null, notes: null,
wiki: null, wiki: null,
customFields: "{}", customFields: "{}",
tags: [], tags: [],
dateStarted: window.$gz.locale.nowUTC8601String(), customerId: null,
dateCompleted: null, projectId: null,
workorderOverseerId: null, internalReferenceNumber: null,
accountNumber: null customerReferenceNumber: null,
customerContactName: null,
fromQuoteId: null,
fromPMId: null,
fromCSRId: null,
serviceDate: null,
completeByDate: null,
invoiceNumber: null,
customerSignature: null,
customerSignatureName: null,
customerSignatureCaptured: null,
postAddress: null,
postCity: null,
postRegion: null,
postCountry: null,
postCode: null,
address: null,
city: null,
region: null,
country: null,
latitude: null,
longitude: null,
items: [],
states: [],
isDirty: false
}
}, },
formState: { formState: {
ready: false, ready: false,
@@ -125,7 +179,8 @@ export default {
serverError: {} serverError: {}
}, },
rights: window.$gz.role.defaultRightsObject(), rights: window.$gz.role.defaultRightsObject(),
ayaType: window.$gz.type.WorkOrder ayaType: window.$gz.type.WorkOrder,
selectedItemIndex: null
}; };
}, },
//WATCHERS //WATCHERS
@@ -533,8 +588,8 @@ async function initForm(vm) {
async function fetchTranslatedText(vm) { async function fetchTranslatedText(vm) {
await window.$gz.translation.cacheTranslations([ await window.$gz.translation.cacheTranslations([
"WorkOrder", "WorkOrder",
"WorkOrderName", "WorkOrderSerialNumber",
"WorkOrderNotes", "WorkOrderSummary",
"WorkOrderCustom1", "WorkOrderCustom1",
"WorkOrderCustom2", "WorkOrderCustom2",
"WorkOrderCustom3", "WorkOrderCustom3",