This commit is contained in:
2021-01-15 23:44:35 +00:00
parent 4036794dd3
commit d864ef4bc9
2 changed files with 38 additions and 2 deletions

View File

@@ -130,6 +130,8 @@ export default {
} }
}, },
methods: { methods: {
//Get full selection for use on forms where we need the
//full selection including name, active, id
getFullSelectionValue() { getFullSelectionValue() {
return this.lastSelection; return this.lastSelection;
}, },

View File

@@ -19,6 +19,15 @@
</v-col> </v-col>
<v-col cols="12"> <v-col cols="12">
<gz-pick-list
v-if="!formState.readOnly"
:ayaType="ayaTypes().Part"
:showEditIcon="true"
:label="$ay.t('Part')"
ref="partId"
data-cy="partId"
@input="addItem()"
></gz-pick-list>
<v-simple-table> <v-simple-table>
<template v-slot:default> <template v-slot:default>
<thead> <thead>
@@ -264,7 +273,8 @@ export default {
serverError: {} serverError: {}
}, },
rights: window.$gz.role.defaultRightsObject(), rights: window.$gz.role.defaultRightsObject(),
ayaType: window.$gz.type.PartAssembly ayaType: window.$gz.type.PartAssembly,
selectedPart: null
}; };
}, },
//WATCHERS //WATCHERS
@@ -302,8 +312,32 @@ export default {
} }
}, },
methods: { methods: {
addItem: function() {
let vm = this;
let selected = vm.$refs.partId.getFullSelectionValue();
if (selected == null) {
return;
}
let index = vm.obj.items.findIndex(z => z.partId == selected.id);
if (index != -1) {
//already in the list
return;
}
vm.obj.items.push({
partAssemblyId: vm.obj.id,
partId: selected.id,
partDisplay: selected.name
});
},
removeItem: function(item) { removeItem: function(item) {
console.log(item); let vm = this;
let index = vm.obj.items.findIndex(z => z.partId == item.partId);
if (index == -1) {
return;
}
vm.obj.items.splice(index, 1);
vm.formState.dirty = true;
}, },
canSave: function() { canSave: function() {
return this.formState.valid && this.formState.dirty; return this.formState.valid && this.formState.dirty;