From 29f9b9862be379ec3a2d5a083e3e68c794f7a4ad Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Sun, 19 Sep 2021 22:59:53 +0000 Subject: [PATCH] --- ayanova/src/views/home-schedule.vue | 14 +++++-- ayanova/src/views/svc-workorder.vue | 60 +++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+), 4 deletions(-) diff --git a/ayanova/src/views/home-schedule.vue b/ayanova/src/views/home-schedule.vue index b22b514c..89f06405 100644 --- a/ayanova/src/views/home-schedule.vue +++ b/ayanova/src/views/home-schedule.vue @@ -402,10 +402,16 @@ export default { name: "workorder-edit", params: { recordid: 0, - createNew: { - createType: atype, - start: newEvent.start, - end: newEvent.end, + add: { + type: atype, + start: window.$gz.locale.localScheduleFormatToUTC8601String( + newEvent.start, + this.timeZoneName + ), + end: window.$gz.locale.localScheduleFormatToUTC8601String( + newEvent.end, + this.timeZoneName + ), userId: this.$store.state.userId, name: this.$store.state.userName } diff --git a/ayanova/src/views/svc-workorder.vue b/ayanova/src/views/svc-workorder.vue index 21660a13..bc7721ca 100644 --- a/ayanova/src/views/svc-workorder.vue +++ b/ayanova/src/views/svc-workorder.vue @@ -139,10 +139,70 @@ export default { }); setDirty = true; } else { + //sometimes we're here with some data to fill in (e.g. schedule creates new wo itemscheduled user, if so there will be a add property on the params) console.log( "svc-workorder::created new, no obj, params are:", this.$route.params ); + + if (this.$route.params.add) { + //todo: REFACTOR this is a temporary abomination, new items should be standardized somewhere else in one location + const n = this.$route.params.add; + switch (n.type) { + case this.$ay.ayt().WorkOrderItemScheduledUser: + this.obj.items.push({ + id: 0, + concurrency: 0, + notes: "-", //todo: default here at some point or just leave this TTM + wiki: null, + customFields: "{}", + tags: [], + workOrderId: null, + fromCSRId: null, + techNotes: null, + workOrderItemStatusId: null, + workOrderItemPriorityId: null, + requestDate: null, + warrantyService: false, + sequence: 1, //indexes are zero based but sequences are visible to user so 1 based + isDirty: true, + expenses: [], + labors: [], + loans: [], + parts: [], + partRequests: [], + scheduledUsers: [ + { + id: 0, + concurrency: 0, + userId: n.userId, + estimatedQuantity: window.$gz.locale.diffHoursFromUTC8601String( + n.start, + n.end + ), + startDate: n.start, + stopDate: n.end, + serviceRateId: null, + isDirty: true, + workOrderItemId: 0, + uid: Date.now(), + userViz: n.name, + serviceRateViz: null + } + ], + tasks: [], + travels: [], + units: [], + outsideServices: [], + uid: Date.now() //used for error tracking / display + }); + + break; + default: + console.log("UNKNOWN TYPE", n.type); + break; + } + } //NEW this.formState.loading = false; this.formState.ready = true;