This commit is contained in:
2021-06-16 23:02:02 +00:00
parent e1912d5f14
commit 68768a47c6
4 changed files with 58 additions and 16 deletions

View File

@@ -243,6 +243,10 @@ export default {
gotoIndex: {
default: null,
type: Number
},
addNew: {
default: null,
type: Number
}
},
watch: {
@@ -253,8 +257,13 @@ export default {
},
gotoIndex(val, oldVal) {
if (val != oldVal) {
this.selectedRow = [{ index: val }];
this.activeItemIndex = val;
let gotoIndex = val;
if (val < 0) {
//it's a create request
gotoIndex = this.newItem();
}
this.selectedRow = [{ index: gotoIndex }];
this.activeItemIndex = gotoIndex;
this.$nextTick(() => {
const el = this.$refs.unittopform;
if (el) {
@@ -301,6 +310,8 @@ export default {
`Items[${this.activeWoItemIndex}].units[${this.activeItemIndex}].unitId`
);
});
return newIndex; //for create new on goto
},
unDeleteItem() {
this.value.items[this.activeWoItemIndex].units[

View File

@@ -11,7 +11,7 @@
>
{{ $ay.t("WorkOrderItemList") }}
<v-btn large icon v-bind="attrs" v-on="on">
<v-icon small color="primary">$ayiEllipsisV</v-icon>
<v-icon color="primary">$ayiEllipsisV</v-icon>
</v-btn>
</div>
</template>
@@ -35,6 +35,20 @@
</v-list-item-icon>
<v-list-item-title>{{ $ay.t("Undelete") }}</v-list-item-title>
</v-list-item>
<template v-if="hasData && hasSelection && pvm.rights.change">
<v-divider></v-divider>
<v-subheader>{{ $ay.t("Add") }}</v-subheader>
<v-list-item
v-if="pvm.subRights.units.create"
@click="newSubItem($ay.ayt.WorkOrderItemUnit)"
>
<v-list-item-icon>
<v-icon>$ayiFan</v-icon>
</v-list-item-icon>
<v-list-item-title>{{ $ay.t("Unit") }}</v-list-item-title>
</v-list-item>
</template>
</v-list>
</v-menu>
</v-col>
@@ -362,13 +376,7 @@
GRANDCHILDREN
############################################################################ -->
<v-col
cols="12"
v-if="
pvm.subRights.units.visible &&
form().showMe(this, 'WorkOrderItemUnitList')
"
>
<v-col cols="12" v-show="showUnits">
<GzWoItemUnits
v-model="value"
:pvm="pvm"
@@ -795,6 +803,15 @@ export default {
this.fieldValueChanged(`items[${this.activeItemIndex}].notes`);
});
},
newSubItem(atype) {
//new Id value to use (by convention goto negative will trigger create and then goto instead of simple goto)
let newId = -Math.abs(Date.now());
switch (atype) {
case window.$gz.WorkOrderItemUnit:
this.gotoUnitIndex = newId;
break;
}
},
unDeleteItem() {
this.value.items[this.activeItemIndex].deleted = false;
//CHILDREN
@@ -1026,6 +1043,14 @@ and it's probably not a big list to fill anyway
this.pvm.rights.change &&
this.pvm.subRights.items.delete
);
},
showUnits: function() {
return (
this.pvm.subRights.units.visible &&
this.form().showMe(this, "WorkOrderItemUnitList") &&
this.value.items[this.activeItemIndex].units &&
this.value.items[this.activeItemIndex].units.length > 0
);
}
}
};