This commit is contained in:
2021-07-08 23:44:31 +00:00
parent e951dd2c87
commit 225c5f182a
2 changed files with 65 additions and 0 deletions

View File

@@ -21,6 +21,17 @@
</v-list-item-icon>
<v-list-item-title>{{ $ay.t("New") }}</v-list-item-title>
</v-list-item>
<v-list-item
v-if="hasSelection && !formState.readOnly"
@click="generateUnit"
>
<v-list-item-icon>
<v-icon>$ayiFan</v-icon>
</v-list-item-icon>
<v-list-item-title>{{
$ay.t("WorkOrderGenerateUnit")
}}</v-list-item-title>
</v-list-item>
<v-list-item v-if="canAdd" @click="partAssemblyDialog = true">
<v-list-item-icon>
<v-icon>$ayiObjectGroup</v-icon>
@@ -504,6 +515,23 @@ export default {
}
},
methods: {
generateUnit() {
const thisPart = this.value.items[this.activeWoItemIndex].parts[
this.activeItemIndex
];
this.$router.push({
name: "svc-units",
params: {
recordid: 0,
genFromPart: {
customerId: this.value.customerId,
partId: thisPart.partId,
purchaseDate: this.value.serviceDate,
serial: thisPart.serials
}
}
});
},
async selectSerials() {
this.availableSerials.splice(0);
this.selectedSerials.splice(0);

View File

@@ -759,6 +759,43 @@ export default {
"Copy"
)}`;
setDirty = true;
} else {
//check for generate unit from part info on route params
//(set by workorder item part when user selects generate unit from part)
let gen = this.$route.params.genFromPart;
if (gen) {
/* genFromPart: {
customerId: this.value.customerId,
partId: thisPart.partId,
purchaseDate: this.value.serviceDate,
serial: thisPart.serials
}
/*
owner is workorder customer
Description is part name
purchased here is true
purchased date is service date of workorder
Serial number is part serial number if set
*/
//get the part then set the values accordingly
let res = await window.$gz.api.get(`part/${gen.partId}`);
if (res.error) {
window.$gz.eventBus.$emit(
"notify-warning",
window.$gz.errorHandler.errorToString(res, this)
);
} else {
let p = res.data;
this.obj.boughtHere = true;
this.obj.customerId = gen.customerId;
this.obj.serial = gen.serial;
this.obj.purchasedDate = gen.purchaseDate;
this.obj.description = p.partNumber + " " + p.name;
}
setDirty = true;
}
}
}