Reports create page get dynamic field and save.
This commit is contained in:
@ -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>
|
||||
|
||||
|
14
resources/assets/js/plugins/form.js
vendored
14
resources/assets/js/plugins/form.js
vendored
@ -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;
|
||||
|
40
resources/assets/js/views/common/reports.js
vendored
40
resources/assets/js/views/common/reports.js
vendored
@ -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;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
Reference in New Issue
Block a user