This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
export default {
|
||||
version: "8.0.0-alpha.124",
|
||||
version: "8.0.0-alpha.125",
|
||||
copyright: "© 1999-2021, Ground Zero Tech-Works Inc."
|
||||
};
|
||||
|
||||
@@ -128,6 +128,11 @@
|
||||
"
|
||||
@update:name="unitChange"
|
||||
></gz-pick-list>
|
||||
<template v-slot:append v-if="canOpenMeter()">
|
||||
<v-btn outlined small color="primary" @click="openMeter">
|
||||
<v-icon>$ayiWeight</v-icon></v-btn
|
||||
>
|
||||
</template>
|
||||
</v-col>
|
||||
|
||||
<v-col
|
||||
@@ -355,7 +360,8 @@ export default {
|
||||
availableBulkUnits: [],
|
||||
selectedBulkUnits: [],
|
||||
selectedBulkUnitTags: [],
|
||||
bulkUnitTableHeaders: []
|
||||
bulkUnitTableHeaders: [],
|
||||
isMetered: false
|
||||
};
|
||||
},
|
||||
props: {
|
||||
@@ -405,46 +411,81 @@ export default {
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
async updateContractIfApplicable() {
|
||||
canOpenMeter: function() {
|
||||
return (
|
||||
this.isMetered == true &&
|
||||
this.value.items[this.activeWoItemIndex].units[this.activeItemIndex]
|
||||
.id != 0
|
||||
);
|
||||
},
|
||||
openMeter: function() {
|
||||
if (this.canOpenMeter()) {
|
||||
this.$router.push({
|
||||
name: "meter-readings",
|
||||
params: {
|
||||
workorderitemunitid: this.value.items[this.activeWoItemIndex].units[
|
||||
this.activeItemIndex
|
||||
].id,
|
||||
unitid: this.value.items[this.activeWoItemIndex].units[
|
||||
this.activeItemIndex
|
||||
].unitId,
|
||||
unitname: this.value.items[this.activeWoItemIndex].units[
|
||||
this.activeItemIndex
|
||||
].unitViz
|
||||
}
|
||||
});
|
||||
|
||||
// this.$router.push({
|
||||
// name: "meter-readings",
|
||||
// params: {
|
||||
// aType: window.$gz.type.Unit,
|
||||
// objectId: this.$route.params.recordid
|
||||
// }
|
||||
// });
|
||||
}
|
||||
},
|
||||
async handleUnitChange() {
|
||||
const id = this.value.items[this.activeWoItemIndex].units[
|
||||
this.activeItemIndex
|
||||
].unitId;
|
||||
if (!id || id == 0) {
|
||||
return;
|
||||
}
|
||||
let res = await window.$gz.api.get(`unit/active-contract/${id}`);
|
||||
let res = await window.$gz.api.get(`unit/work-order-info/${id}`);
|
||||
if (res.error) {
|
||||
window.$gz.eventBus.$emit(
|
||||
"notify-warning",
|
||||
window.$gz.errorHandler.errorToString(res, this)
|
||||
);
|
||||
} else {
|
||||
if (res.data.id == 0) {
|
||||
//no contract, just bail
|
||||
return;
|
||||
}
|
||||
//has contract, if it differs from main work order contract then offer to set it
|
||||
if (res.data.id == this.value.contractId) {
|
||||
//same contract, just bail
|
||||
//yes the date could not be different but we're not going to pick that nit, they can just unset and set if it matters
|
||||
return;
|
||||
}
|
||||
//Prompt user to use new contract
|
||||
const prompt = this.$ay
|
||||
.t("ApplyUnitContract")
|
||||
.replace("{0}", res.data.name);
|
||||
//METER READING
|
||||
this.isMetered = res.data.isMetered;
|
||||
|
||||
let dialogResult = await window.$gz.dialog.confirmGenericPreTranslated(
|
||||
prompt,
|
||||
"question"
|
||||
);
|
||||
if (dialogResult == false) {
|
||||
return;
|
||||
} else {
|
||||
this.value.contractId = res.data.id;
|
||||
this.value.isDirty = true;
|
||||
this.pvm.formState.dirty = true;
|
||||
this.$emit("change");
|
||||
//CONTRACT
|
||||
if (res.data.contract.id != 0) {
|
||||
//has contract, if it differs from main work order contract then offer to set it
|
||||
if (res.data.id == this.value.contractId) {
|
||||
//same contract, just bail
|
||||
//yes the date could not be different but we're not going to pick that nit, they can just unset and set if it matters
|
||||
return;
|
||||
}
|
||||
//Prompt user to use new contract
|
||||
const prompt = this.$ay
|
||||
.t("ApplyUnitContract")
|
||||
.replace("{0}", res.data.name);
|
||||
|
||||
let dialogResult = await window.$gz.dialog.confirmGenericPreTranslated(
|
||||
prompt,
|
||||
"question"
|
||||
);
|
||||
if (dialogResult == false) {
|
||||
return;
|
||||
} else {
|
||||
this.value.contractId = res.data.id;
|
||||
this.value.isDirty = true;
|
||||
this.pvm.formState.dirty = true;
|
||||
this.$emit("change");
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -607,7 +648,7 @@ export default {
|
||||
this.value.items[this.activeWoItemIndex].units[
|
||||
this.activeItemIndex
|
||||
].warrantyViz = null;
|
||||
await this.updateContractIfApplicable();
|
||||
await this.handleUnitChange();
|
||||
},
|
||||
newItem() {
|
||||
let newIndex = this.value.items[this.activeWoItemIndex].units.length;
|
||||
|
||||
@@ -68,7 +68,7 @@ import chartBarHorizontalControl from "./components/chart-bar-horizontal-control
|
||||
//DEVELOPMENT MODE
|
||||
//THIS SHOULD BE FALSE IN RELEASE
|
||||
//************************************************************
|
||||
const DEV_MODE = false;
|
||||
const DEV_MODE = true;
|
||||
//************************************************************
|
||||
//**************************************************************
|
||||
//**************************************************************
|
||||
|
||||
@@ -99,6 +99,7 @@ export default {
|
||||
}
|
||||
} else {
|
||||
vm.obj.unitId = this.$route.params.unitid;
|
||||
vm.obj.workOrderItemUnitId = this.$route.params.workorderitemunitid;
|
||||
window.$gz.form.setFormState({
|
||||
vm: vm,
|
||||
loading: false
|
||||
|
||||
Reference in New Issue
Block a user