This commit is contained in:
2021-01-19 18:09:56 +00:00
parent 7ed64b0c94
commit 2fb6ead12d

View File

@@ -3,6 +3,7 @@
<gz-report-selector ref="reportSelector"></gz-report-selector>
<div v-if="formState.ready">
<gz-error :errorBoxMessage="formState.errorBoxMessage"></gz-error>
{{ obj }}
<v-form ref="form">
<v-row>
<v-col cols="12">
@@ -16,8 +17,45 @@
data-cy="selectedPartId"
></gz-pick-list>
</v-col>
PartSerialNumbersAvailable list here
{{ obj }}
<v-col cols="12" sm="6" v-if="!formState.readOnly">
<v-textarea
v-model="newSerial"
:label="$ay.t('PartSerialNumbersAvailable')"
clearable
no-resize
rows="4"
ref="newSerial"
data-cy="newSerial"
append-outer-icon="$ayiPlus"
@click:append-outer="addItem()"
></v-textarea>
</v-col>
<v-col cols="12">
<v-simple-table>
<template v-slot:default>
<thead>
<tr>
<th />
<!-- <th class="text-left">
{{ $ay.t("PartSerialNumbersAvailable") }}
</th> -->
</tr>
</thead>
<tbody>
<tr v-for="(item, index) in sortedList()" :key="index">
<td>
{{ item }}
<v-icon class="ml-6" @click="removeItem(index)">
$ayiTrashAlt
</v-icon>
</td>
</tr>
</tbody>
</template>
</v-simple-table>
</v-col>
</v-row>
</v-form>
</div>
@@ -106,7 +144,8 @@ export default {
},
rights: window.$gz.role.defaultRightsObject(),
ayaType: window.$gz.type.Part,
selectedPartId: Number(this.$route.params.recordid)
selectedPartId: Number(this.$route.params.recordid),
newSerial: null
};
},
@@ -128,16 +167,38 @@ export default {
}
},
methods: {
sortedList: function() {
if (this.obj == null || this.obj.length == 0) {
return [];
}
return this.obj.slice().sort();
},
removeItem: function(index) {
vm.obj.splice(index, 1);
vm.formState.dirty = true;
},
canSave: function() {
return this.formState.valid && this.formState.dirty;
},
addItem: function() {
if (this.newSerial == null || this.newSerial == "") {
return;
}
//add to list, may be in various formats so handle that
let splitted = this.newSerial.split(/[\s,]+/).filter(Boolean);
splitted = [...splitted, ...this.obj];
let uniqueItems = [...new Set(splitted)];
uniqueItems.sort();
console.log(uniqueItems);
//1,2,3,1,014369160,5,3,9,qw
},
ayaTypes: function() {
return window.$gz.type;
},
// form() {
// return window.$gz.form;
// },
form() {
return window.$gz.form;
},
// fieldValueChanged(ref) {
// if (
// this.formState.ready &&
@@ -281,14 +342,14 @@ function generateMenu(vm) {
let menuOptions = {
isMain: false,
readOnly: vm.formState.readOnly,
icon: "$ayiProjectDiagram",
title: "Project",
helpUrl: "form-svc-projects",
icon: null,
title: "PartSerialNumbersAvailable",
helpUrl: "form-inv-part-serials",
formData: {
ayaType: window.$gz.type.Project,
recordId: vm.$route.params.recordid,
formCustomTemplateKey: FORM_CUSTOM_TEMPLATE_KEY,
recordName: vm.obj.name
// ayaType: window.$gz.type.Par,
// recordId: vm.$route.params.recordid,
// formCustomTemplateKey: FORM_CUSTOM_TEMPLATE_KEY,
// recordName: vm.obj.name
},
menuItems: []
};