Web Client zu Wardrobe Master
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

125 lines
3.4 KiB

1 year ago
<template>
<div>
<div style="margin-bottom: 20px;">
<b-form @reset="onReset">
<b-form-group
id="ip-g-1"
1 year ago
label="Bezeichnung:"
label-for="bezeichnung"
1 year ago
description="Name des Zertifikat-Typs:"
>
<b-form-input
1 year ago
id="bezeichnung"
v-model="form.bezeichnung"
1 year ago
required
placeholder="Name eingeben"
size="50"
>
</b-form-input>
1 year ago
</b-form-group>
1 year ago
<b-button variant="primary" @click="onSubmit()">Neu eintragen</b-button>
<b-button variant="secondary" @click="onUpdate()">Aktualisieren</b-button>
<b-button variant="danger" @click="onDelete()">Löschen</b-button>
<b-button type="reset" variant="danger">Reset</b-button>
</b-form>
</div>
<div>
<b-table striped hover bordered head-variant="dark" selectable :select-mode="selectMode" :items="certs" :fields="fields" @row-selected="onRowSelect"></b-table>
</div>
</div>
</template>
<script>
export default {
data() {
return {
selectMode: 'single',
componentKey: 0,
certs: [],
form:{
id: "",
1 year ago
bezeichnung: "",
1 year ago
},
fields: [
{
key: 'id',
sortable: true
},
{
1 year ago
key: 'bezeichnung',
1 year ago
sortable: true
},
]
}
},
created() {
this.fetch();
}
,
methods: {
onRowSelect(items) {
this.selected = items;
// alert(JSON.stringify(this.selected));
this.onFill(this.selected);
},
async fetch() {
console.log("fetching...");
this.certs = await fetch(
1 year ago
'http://localhost:8081/api/v1/typ'
1 year ago
).then(res => res.json())
},
async onSubmit() {
// event.preventDefault();
this.form.id = "";
console.log("submitting...");
1 year ago
await this.$http.$post('http://localhost:8081/api/v1/typ', this.form);
1 year ago
// return result;
// this.subm(this.form);
this.fetch();
},
async onUpdate() {
// event.preventDefault();
console.log("updating...");
console.log("Laufzeit: ", this.form.laufzeit)
console.log(this.form);
1 year ago
await this.$http.$put('http://localhost:8081/api/v1/typ/'+this.form.id, this.form);
1 year ago
// return result;
// this.subm(this.form);
this.fetch();
},
async onDelete() {
// event.preventDefault();
console.log("updating...");
1 year ago
await this.$http.$delete('http://localhost:8081/api/v1/typ/'+this.form.id);
1 year ago
// return result;
// this.subm(this.form);
this.fetch();
},
onReset(event) {
event.preventDefault();
this.form.name = '';
this.form.laufzeit = 0;
},
onFill(item) {
// alert(JSON.stringify(item));
if(item.length !== 0) {
1 year ago
this.form.bezeichnung = item[0].bezeichnung;
1 year ago
this.form.id = item[0].id;
this.form.laufzeit = parseInt(item[0].laufzeit);
1 year ago
console.log(JSON.stringify(item[0].bezeichnung));
1 year ago
}
}
}
}
</script>