Reports create page get dynamic field and save.

This commit is contained in:
Cüneyt Şentürk
2020-01-18 19:24:29 +03:00
parent 336e581ab7
commit 7efc4cf7b9
22 changed files with 192 additions and 128 deletions

View File

@ -281,6 +281,10 @@
</el-select>
<component v-bind:is="add_new_html" @submit="onSubmit"></component>
<select :name="name" class="d-none" v-model="real_model">
<option v-for="(label, value) in selectOptions" :value="value">{{ label }}</option>
</select>
</base-input>
</template>

View File

@ -42,6 +42,20 @@ export default class Form {
continue;
}
if (form_element.getAttribute('data-field')) {
if (!this[form_element.getAttribute('data-field')]) {
var field = {};
this[form_element.getAttribute('data-field')] = field;
}
if (!this[form_element.getAttribute('data-field')][name]) {
this[form_element.getAttribute('data-field')][name] = '';
}
continue;
}
if (type == 'radio') {
if (!this[name]) {
this[name] = (form_element.getAttribute('value') ? 1 : 0) || 0;

View File

@ -28,28 +28,54 @@ const app = new Vue({
data: function () {
return {
form: new Form('report'),
bulk_action: new BulkAction('reports')
bulk_action: new BulkAction('reports'),
report_fields: '',
}
},
methods: {
onChangeClass(class_name) {
axios.get(url + '/common/reports/groups', {
axios.get(url + '/common/reports/fields', {
params: {
class: class_name
}
})
.then(response => {
let options = response.data.data;
let form = this.form;
let html = response.data.html;
this.$children.forEach(select => {
if (select.name == 'group') {
select.selectOptions = options;
}
this.report_fields = Vue.component('add-new-component', (resolve, reject) => {
resolve({
template : '<div id="report-fields" class="row col-md-12">' + html + '</div>',
mixins: [
Global
],
created: function() {
this.form = form;
},
data: function () {
return {
form: {},
}
},
watch: {
form: function (form) {
this.$emit("change", form);
}
},
})
});
})
.catch(error => {
});
},
onChangeReportFields(event) {
this.form = event;
}
}
});