This commit is contained in:
2021-07-06 23:46:28 +00:00
parent 16e4e8f4a2
commit e7110c3d2a

View File

@@ -25,7 +25,7 @@
<v-list-item
v-if="hasData && hasSelection && canAdd"
@click="copyItem"
@click="copyItemDialog = true"
>
<v-list-item-icon>
<v-icon>$ayiCopy</v-icon>
@@ -602,6 +602,45 @@
</v-col>
</template>
</v-row>
<!-- ################################################################################-->
<!-- ########################## COPY WOITEM DIALOG ###############################-->
<!-- ################################################################################-->
<template>
<v-row justify="center">
<v-dialog v-model="copyItemDialog" max-width="600px">
<v-card>
<v-card-title>
<span class="text-h5">{{ $ay.t("CopyToWorkOrder") }}</span>
</v-card-title>
<v-card-text>
<v-text-field
v-model="copyItemWoNumber"
:label="$ay.t('WorkOrder')"
autofocus
required
type="number"
></v-text-field>
</v-card-text>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn
color="blue darken-1"
text
@click="copyItemDialog = false"
>{{ $ay.t("Cancel") }}</v-btn
>
<v-btn
color="blue darken-1"
text
@click="copyItemToWorkOrder()"
:disabled="!copyItemWoNumber"
>{{ $ay.t("OK") }}</v-btn
>
</v-card-actions>
</v-card>
</v-dialog>
</v-row>
</template>
</div>
</template>
<script>
@@ -649,7 +688,9 @@ export default {
gotoTaskIndex: null,
gotoScheduledUserIndex: null,
gotoTravelIndex: null,
gotoUnitIndex: null
gotoUnitIndex: null,
copyItemDialog: false,
copyItemWoNumber: null
};
},
props: {
@@ -827,8 +868,42 @@ export default {
}
},
methods: {
copyItem() {
alert("COPY");
async copyItemToWorkOrder() {
/*
needs to display wo selector dialog as simple input text for workorder number
this is so that there is no need to work with infinite lists to select from when they probably just know the number anyway and we don't care what wo they select with the loosey goosey rules now
Enter wo number and click on ok or cancel
if ok then it looks up that wo number record id, navigates to that workorder with the woitem to be copied in the route param
Wo form needs to spot that route param and insert that item into a new woitem record ** if the wo is not locked** if it's locked then an error message should state so
or do we just let the server tell them about it and assume they will unlock it before save next time
User is left with a existing wo opened, a new woitem added and the wo is dirty and ready to save
*/
if (!this.copyItemWoNumber) {
return;
}
//get id from number then push open
let res = await window.$gz.api.get(
"workorder/id-from-number/" + this.copyItemWoNumber
);
if (res.error) {
window.$gz.eventBus.$emit(
"notify-warning",
window.$gz.errorHandler.errorToString(res, this)
);
return;
}
this.$router.push({
name: "workorder-edit",
params: {
recordid: res.data,
copyItem: this.value.items[this.activeItemIndex]
}
});
this.copyItemDialog = false;
},
newItem() {
let newIndex = this.value.items.length;