mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-24 10:22:18 +00:00
Konto new
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
import konto from './stv/konto.js';
|
||||
|
||||
export default {
|
||||
konto
|
||||
};
|
||||
@@ -0,0 +1,31 @@
|
||||
export default {
|
||||
tabulatorConfig(config, self) {
|
||||
config.ajaxURL = 'api/frontend/v1/stv/konto/get';
|
||||
config.ajaxParams = () => {
|
||||
const params = {
|
||||
person_id: self.modelValue.person_id || self.modelValue.map(e => e.person_id),
|
||||
only_open: self.filter,
|
||||
studiengang_kz: self.studiengang_kz_intern ? self.stg_kz : ''
|
||||
};
|
||||
return params;
|
||||
};
|
||||
config.ajaxRequestFunc = (url, config, params) => this.$fhcApi.post(url, params, config);
|
||||
config.ajaxResponse = (url, params, response) => response.data;
|
||||
|
||||
return config;
|
||||
},
|
||||
checkDoubles(data) {
|
||||
return this.$fhcApi.post('api/frontend/v1/stv/konto/checkDoubles', data, {
|
||||
confirmErrorHandler: error => true
|
||||
});
|
||||
},
|
||||
insert(data) {
|
||||
return this.$fhcApi.post('api/frontend/v1/stv/konto/insert', data);
|
||||
},
|
||||
edit(data) {
|
||||
return this.$fhcApi.post('api/frontend/v1/stv/konto/update', data);
|
||||
},
|
||||
getBuchungstypen() {
|
||||
return this.$fhcApi.get('api/frontend/v1/stv/konto/getBuchungstypen');
|
||||
}
|
||||
};
|
||||
@@ -157,7 +157,7 @@ export default {
|
||||
})
|
||||
.catch(this.$fhcAlert.handleSystemError);
|
||||
this.$fhcApi
|
||||
.get('api/frontend/v1/stv/konto/getBuchungstypen')
|
||||
.factory.stv.konto.getBuchungstypen()
|
||||
.then(result => {
|
||||
this.lists.buchungstypen = result.data;
|
||||
})
|
||||
|
||||
@@ -1,14 +1,17 @@
|
||||
import {CoreFilterCmpt} from "../../../filter/Filter.js";
|
||||
import FormInput from "../../../Form/Input.js";
|
||||
import KontoNew from "./Konto/New.js";
|
||||
import KontoEdit from "./Konto/Edit.js";
|
||||
|
||||
// TODO(chris): Phrasen
|
||||
// TODO(chris): multi pers
|
||||
// TODO(chris): new header(multi pers), edit/row, gegenb.(date) multi, löschen multi, best. multi(recht)
|
||||
// TODO(chris): gegenb.(date) multi, löschen multi, best. multi(recht)
|
||||
|
||||
export default {
|
||||
components: {
|
||||
CoreFilterCmpt,
|
||||
FormInput,
|
||||
KontoNew,
|
||||
KontoEdit
|
||||
},
|
||||
props: {
|
||||
@@ -25,6 +28,11 @@ export default {
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
personIds() {
|
||||
if (this.modelValue.person_id)
|
||||
return [this.modelValue.person_id];
|
||||
return this.modelValue.map(e => e.person_id);
|
||||
},
|
||||
stg_kz() {
|
||||
if (this.modelValue.studiengang_kz)
|
||||
return this.modelValue.studiengang_kz;
|
||||
@@ -153,24 +161,13 @@ export default {
|
||||
return columns;
|
||||
},
|
||||
tabulatorOptions() {
|
||||
return {
|
||||
ajaxURL: 'api/frontend/v1/stv/konto/get',
|
||||
ajaxParams: () => {
|
||||
const params = {
|
||||
person_id: this.modelValue.person_id || this.modelValue.map(e => e.person_id),
|
||||
only_open: this.filter,
|
||||
studiengang_kz: this.studiengang_kz_intern ? this.stg_kz : ''
|
||||
};
|
||||
return params;
|
||||
},
|
||||
ajaxRequestFunc: (url, config, params) => {
|
||||
return this.$fhcApi.post(url, params, config);
|
||||
},
|
||||
ajaxResponse: (url, params, response) => response.data,
|
||||
return this.$fhcApi.factory.stv.konto.tabulatorConfig({
|
||||
dataTree: true,
|
||||
columns: this.tabulatorColumns,
|
||||
selectable: true,
|
||||
selectableRangeMode: 'click',
|
||||
index: 'buchungsnr',
|
||||
};
|
||||
}, this);
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
@@ -186,6 +183,9 @@ export default {
|
||||
if (!data)
|
||||
return this.reload();
|
||||
this.$refs.table.tabulator.updateData(data);
|
||||
},
|
||||
actionNew() {
|
||||
this.$refs.new.open();
|
||||
}
|
||||
},
|
||||
created() {
|
||||
@@ -221,8 +221,13 @@ export default {
|
||||
table-only
|
||||
:side-menu="false"
|
||||
:tabulator-options="tabulatorOptions"
|
||||
new-btn-show
|
||||
new-btn-label="Buchung"
|
||||
:new-btn-disabled="stg_kz === ''"
|
||||
@click:new="actionNew"
|
||||
>
|
||||
</core-filter-cmpt>
|
||||
<konto-new ref="new" :config="config" @saved="updateData" :person-ids="personIds" :stg-kz="stg_kz"></konto-new>
|
||||
<konto-edit ref="edit" :config="config" @saved="updateData"></konto-edit>
|
||||
</div>`
|
||||
};
|
||||
@@ -35,14 +35,14 @@ export default {
|
||||
this.loading = true;
|
||||
|
||||
this.$refs.form
|
||||
.post('api/frontend/v1/stv/konto/update', this.data)
|
||||
.factory.stv.konto.edit(this.data)
|
||||
.then(result => {
|
||||
this.$emit('saved', result.data);
|
||||
this.loading = false;
|
||||
this.$refs.modal.hide();
|
||||
this.$fhcAlert.alertSuccess('Daten wurden gespeichert');
|
||||
})
|
||||
.catch(error => {console.log(error); // TODO(chris): check if working with current fhcApi
|
||||
.catch(error => {
|
||||
this.$fhcAlert.handleSystemError(error);
|
||||
this.loading = false;
|
||||
});
|
||||
|
||||
@@ -0,0 +1,199 @@
|
||||
import BsModal from "../../../../Bootstrap/Modal.js";
|
||||
import BsConfirm from "../../../../Bootstrap/Confirm.js";
|
||||
import CoreForm from "../../../../Form/Form.js";
|
||||
import FormValidation from "../../../../Form/Validation.js";
|
||||
import FormInput from "../../../../Form/Input.js";
|
||||
|
||||
// TODO(chris): Phrasen
|
||||
|
||||
export default {
|
||||
components: {
|
||||
BsModal,
|
||||
CoreForm,
|
||||
FormValidation,
|
||||
FormInput
|
||||
},
|
||||
inject: {
|
||||
lists: {
|
||||
from: 'lists'
|
||||
},
|
||||
defaultSemester: {
|
||||
from: 'defaultSemester'
|
||||
}
|
||||
},
|
||||
props: {
|
||||
personIds: {
|
||||
type: Array,
|
||||
required: true
|
||||
},
|
||||
stgKz: {
|
||||
type: Number,
|
||||
required: true
|
||||
},
|
||||
config: {
|
||||
type: Object,
|
||||
default: {}
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
loading: false,
|
||||
data: {}
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
reversedSems() {
|
||||
return this.lists.studiensemester.toReversed();
|
||||
},
|
||||
activeBuchungstypen() {
|
||||
return this.lists.buchungstypen.filter(e => e.aktiv);
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
save() {
|
||||
this.$refs.form.clearValidation();
|
||||
this.loading = true;
|
||||
|
||||
const data = {...{
|
||||
person_id: this.personIds,
|
||||
studiengang_kz: this.stgKz
|
||||
}, ...this.data};
|
||||
|
||||
this.$refs.form
|
||||
.factory.stv.konto.checkDoubles(data)
|
||||
.then(result => result.data
|
||||
? Promise.all(
|
||||
result.errors
|
||||
.filter(e => e.type == 'confirm')
|
||||
.map(e => BsConfirm.popup(Vue.h('div', {class:'text-preline'}, e.message)))
|
||||
)
|
||||
: Promise.resolve())
|
||||
.then(() => data)
|
||||
.then(this.$refs.form.factory.stv.konto.insert)
|
||||
.then(result => {
|
||||
this.$emit('saved', result.data);
|
||||
this.loading = false;
|
||||
this.$refs.modal.hide();
|
||||
this.$fhcAlert.alertSuccess('Daten wurden gespeichert');
|
||||
})
|
||||
.catch(error => {
|
||||
if (error)
|
||||
this.$fhcAlert.handleSystemError(error);
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
open() {
|
||||
this.data = {
|
||||
betrag: '-0.00',
|
||||
mahnspanne: 30,
|
||||
buchungsdatum: new Date(),
|
||||
studiensemester_kurzbz: this.defaultSemester
|
||||
};
|
||||
this.$refs.modal.show();
|
||||
},
|
||||
preventCloseOnLoading(ev) {
|
||||
if (this.loading)
|
||||
ev.returnValue = false;
|
||||
},
|
||||
checkDefaultBetrag(ev) {
|
||||
const typ = this.lists.buchungstypen.filter(e => e.buchungstyp_kurzbz == ev).pop();
|
||||
const amount = typ.standardbetrag || '-0.00';
|
||||
const text = typ.standardtext || '';
|
||||
const creditpoints = typ.credit_points || '';
|
||||
|
||||
if (!this.data.betrag || this.data.betrag == '-0.00')
|
||||
this.data.betrag = amount;
|
||||
|
||||
if (!this.data.buchungstext)
|
||||
this.data.buchungstext = text;
|
||||
|
||||
if (this.config.showCreditpoints && this.data.credit_points == '0.00')
|
||||
this.data.credit_points = creditpoints;
|
||||
}
|
||||
},
|
||||
template: `
|
||||
<core-form ref="form" class="stv-details-konto-edit" @submit.prevent="save">
|
||||
<bs-modal ref="modal" @hide-bs-modal="preventCloseOnLoading">
|
||||
<form-validation></form-validation>
|
||||
|
||||
<fieldset :disabled="loading">
|
||||
<form-input
|
||||
type="select"
|
||||
v-model="data.buchungstyp_kurzbz"
|
||||
name="buchungstyp_kurzbz"
|
||||
label="Typ"
|
||||
@update:model-value="checkDefaultBetrag"
|
||||
>
|
||||
<option v-for="typ in activeBuchungstypen" :key="typ.buchungstyp_kurzbz" :value="typ.buchungstyp_kurzbz" :class="typ.aktiv ? '' : 'text-decoration-line-through text-muted'">
|
||||
{{ typ.beschreibung }}
|
||||
</option>
|
||||
</form-input>
|
||||
<form-input
|
||||
v-model="data.betrag"
|
||||
name="betrag"
|
||||
label="Betrag"
|
||||
>
|
||||
</form-input>
|
||||
<form-input
|
||||
type="DatePicker"
|
||||
v-model="data.buchungsdatum"
|
||||
name="buchungsdatum"
|
||||
label="Buchungsdatum"
|
||||
:enable-time-picker="false"
|
||||
auto-apply
|
||||
>
|
||||
</form-input>
|
||||
<form-input
|
||||
v-model="data.buchungstext"
|
||||
name="buchungstext"
|
||||
label="Buchungstext"
|
||||
>
|
||||
</form-input>
|
||||
<form-input
|
||||
v-if="config.showMahnspanne"
|
||||
v-model="data.mahnspanne"
|
||||
name="mahnspanne"
|
||||
label="Mahnspanne"
|
||||
>
|
||||
</form-input>
|
||||
<form-input
|
||||
type="select"
|
||||
v-model="data.studiensemester_kurzbz"
|
||||
name="studiensemester_kurzbz"
|
||||
label="Studiensemester"
|
||||
>
|
||||
<option v-for="sem in reversedSems" :key="sem.studiensemester_kurzbz" :value="sem.studiensemester_kurzbz">
|
||||
{{ sem.studiensemester_kurzbz }}
|
||||
</option>
|
||||
</form-input>
|
||||
<form-input
|
||||
v-if="config.showCreditpoints"
|
||||
v-model="data.credit_points"
|
||||
name="credit_points"
|
||||
label="Credit Points"
|
||||
>
|
||||
</form-input>
|
||||
<form-input
|
||||
type="textarea"
|
||||
v-model="data.anmerkung"
|
||||
name="anmerkung"
|
||||
label="Anmerkung"
|
||||
>
|
||||
</form-input>
|
||||
</fieldset>
|
||||
|
||||
<template #title>
|
||||
New Buchung
|
||||
<template v-if="personIds.length > 1">
|
||||
({{ personIds.length }} Studenten)
|
||||
</template>
|
||||
</template>
|
||||
<template #footer>
|
||||
<button type="submit" class="btn btn-primary" :disabled="loading">
|
||||
<i v-if="loading" class="fa fa-spinner fa-spin"></i>
|
||||
Speichern
|
||||
</button>
|
||||
</template>
|
||||
</bs-modal>
|
||||
</core-form>`
|
||||
};
|
||||
Reference in New Issue
Block a user