close #1353 Fixed: Invoice item selected tax not calculate real time

This commit is contained in:
Cüneyt Şentürk 2020-03-13 15:45:23 +03:00
parent 7c027ad135
commit 0f34bd066f
4 changed files with 39 additions and 23 deletions

View File

@ -74,7 +74,7 @@
</el-option> </el-option>
</el-option-group> </el-option-group>
<el-option v-if="addNew.status && options.length != 0" class="el-select__footer" :value="add_new"> <el-option v-if="addNew.status && options.length != 0" class="el-select__footer" :disabled="true" :value="add_new">
<div @click="onAddItem"> <div @click="onAddItem">
<i class="fas fa-plus"></i> <i class="fas fa-plus"></i>
<span> <span>
@ -147,7 +147,7 @@
</el-option> </el-option>
</el-option-group> </el-option-group>
<el-option v-if="addNew.status && options.length != 0" class="el-select__footer" :value="add_new"> <el-option v-if="addNew.status && options.length != 0" class="el-select__footer" :disabled="true" :value="add_new">
<div @click="onAddItem"> <div @click="onAddItem">
<i class="fas fa-plus"></i> <i class="fas fa-plus"></i>
<span> <span>
@ -220,7 +220,7 @@
</el-option> </el-option>
</el-option-group> </el-option-group>
<el-option v-if="addNew.status && options.length != 0" class="el-select__footer" :value="add_new"> <el-option v-if="addNew.status && options.length != 0" class="el-select__footer" :disabled="true" :value="add_new">
<div @click="onAddItem"> <div @click="onAddItem">
<i class="fas fa-plus"></i> <i class="fas fa-plus"></i>
<span> <span>
@ -293,7 +293,7 @@
</el-option> </el-option>
</el-option-group> </el-option-group>
<el-option v-if="addNew.status && options.length != 0" class="el-select__footer" :value="add_new"> <el-option v-if="addNew.status && options.length != 0" class="el-select__footer" :disabled="true" :value="add_new">
<div @click="onAddItem"> <div @click="onAddItem">
<i class="fas fa-plus"></i> <i class="fas fa-plus"></i>
<span> <span>
@ -366,7 +366,7 @@
</el-option> </el-option>
</el-option-group> </el-option-group>
<el-option v-if="addNew.status && options.length != 0" class="el-select__footer" :value="add_new"> <el-option v-if="addNew.status && options.length != 0" class="el-select__footer" :disabled="true" :value="add_new">
<div @click="onAddItem"> <div @click="onAddItem">
<i class="fas fa-plus"></i> <i class="fas fa-plus"></i>
<span> <span>
@ -549,12 +549,12 @@ export default {
methods: { methods: {
change() { change() {
if (typeof(this.real_model) === 'object') { if (typeof(this.real_model) === 'object' && typeof(this.real_model.type) !== 'undefined') {
return false; return false;
} }
this.$emit('change', this.real_model);
this.$emit('interface', this.real_model); this.$emit('interface', this.real_model);
this.$emit('change', this.real_model);
}, },
async onAddItem() { async onAddItem() {
@ -679,6 +679,10 @@ export default {
this.form.loading = false; this.form.loading = false;
if (response.data.success) { if (response.data.success) {
if (!this.selectOptions.length) {
this.selectOptions = {};
}
this.selectOptions[response.data.data[this.add_new.field.key]] = response.data.data[this.add_new.field.value]; this.selectOptions[response.data.data[this.add_new.field.key]] = response.data.data[this.add_new.field.value];
this.new_options[response.data.data[this.add_new.field.key]] = response.data.data[this.add_new.field.value]; this.new_options[response.data.data[this.add_new.field.key]] = response.data.data[this.add_new.field.value];
@ -688,8 +692,6 @@ export default {
this.real_model = response.data.data[this.add_new.field.key].toString(); this.real_model = response.data.data[this.add_new.field.key].toString();
} }
this.change();
this.add_new.show = false; this.add_new.show = false;
this.add_new.html = ''; this.add_new.html = '';
@ -698,6 +700,10 @@ export default {
if (this.multiple) { if (this.multiple) {
this.hide_selected = false; this.hide_selected = false;
} }
this.$emit('new', response.data.data);
this.change();
} }
}) })
.catch(error => { .catch(error => {
@ -726,6 +732,10 @@ export default {
this.selectOptions = options; this.selectOptions = options;
if (Object.keys(this.new_options).length) { if (Object.keys(this.new_options).length) {
if (!this.selectOptions.length) {
this.selectOptions = {};
}
for (let [key, value] of Object.entries(this.new_options)) { for (let [key, value] of Object.entries(this.new_options)) {
if (!this.selectOptions[key]) { if (!this.selectOptions[key]) {
this.selectOptions[key] = value; this.selectOptions[key] = value;

View File

@ -74,7 +74,7 @@
</el-option> </el-option>
</el-option-group> </el-option-group>
<el-option v-if="addNew.status && options.length != 0" class="el-select__footer" :value="add_new"> <el-option v-if="addNew.status && options.length != 0" class="el-select__footer" :disabled="true" :value="add_new">
<div @click="onAddItem"> <div @click="onAddItem">
<i class="fas fa-plus"></i> <i class="fas fa-plus"></i>
<span> <span>
@ -147,7 +147,7 @@
</el-option> </el-option>
</el-option-group> </el-option-group>
<el-option v-if="addNew.status && options.length != 0" class="el-select__footer" :value="add_new"> <el-option v-if="addNew.status && options.length != 0" class="el-select__footer" :disabled="true" :value="add_new">
<div @click="onAddItem"> <div @click="onAddItem">
<i class="fas fa-plus"></i> <i class="fas fa-plus"></i>
<span> <span>
@ -220,7 +220,7 @@
</el-option> </el-option>
</el-option-group> </el-option-group>
<el-option v-if="addNew.status && options.length != 0" class="el-select__footer" :value="add_new"> <el-option v-if="addNew.status && options.length != 0" class="el-select__footer" :disabled="true" :value="add_new">
<div @click="onAddItem"> <div @click="onAddItem">
<i class="fas fa-plus"></i> <i class="fas fa-plus"></i>
<span> <span>
@ -293,7 +293,7 @@
</el-option> </el-option>
</el-option-group> </el-option-group>
<el-option v-if="addNew.status && options.length != 0" class="el-select__footer" :value="add_new"> <el-option v-if="addNew.status && options.length != 0" class="el-select__footer" :disabled="true" :value="add_new">
<div @click="onAddItem"> <div @click="onAddItem">
<i class="fas fa-plus"></i> <i class="fas fa-plus"></i>
<span> <span>
@ -390,7 +390,7 @@
</el-option> </el-option>
</el-option-group> </el-option-group>
<el-option v-if="!loading && addNew.status && selectOptions != null && selectOptions.length != 0" class="el-select__footer" :value="add_new"> <el-option v-if="!loading && addNew.status && selectOptions != null && selectOptions.length != 0" class="el-select__footer" :disabled="true" :value="add_new">
<div @click="onAddItem"> <div @click="onAddItem">
<i class="fas fa-plus"></i> <i class="fas fa-plus"></i>
<span> <span>
@ -634,8 +634,8 @@ export default {
return false; return false;
} }
this.$emit('change', this.real_model);
this.$emit('interface', this.real_model); this.$emit('interface', this.real_model);
this.$emit('change', this.real_model);
this.selectOptions.forEach(item => { this.selectOptions.forEach(item => {
if (item.id == this.real_model) { if (item.id == this.real_model) {
@ -687,13 +687,15 @@ export default {
this.new_options[response.data.data[this.add_new.field.key]] = response.data.data; this.new_options[response.data.data[this.add_new.field.key]] = response.data.data;
this.real_model = response.data.data[this.add_new.field.key]; this.real_model = response.data.data[this.add_new.field.key];
this.change();
if (this.title) { if (this.title) {
this.$children[0].$children[0].visible = false; this.$children[0].$children[0].visible = false;
} else { } else {
this.$children[0].visible = false; this.$children[0].visible = false;
} }
this.$emit('new', response.data.data);
this.change();
} }
}) })
.catch(error => { .catch(error => {
@ -804,12 +806,14 @@ export default {
this.new_options[response.data.data[this.add_new.field.key]] = response.data.data[this.add_new.field.value]; this.new_options[response.data.data[this.add_new.field.key]] = response.data.data[this.add_new.field.value];
this.real_model = response.data.data[this.add_new.field.key];//.toString(); this.real_model = response.data.data[this.add_new.field.key];//.toString();
this.change();
this.add_new.show = false; this.add_new.show = false;
this.add_new.html = ''; this.add_new.html = '';
this.add_new_html = null; this.add_new_html = null;
this.$emit('new', response.data.data);
this.change();
} }
}) })
.catch(error => { .catch(error => {

View File

@ -133,9 +133,10 @@
] ]
] ]
])}}" ])}}"
:collapse="false" :collapse="true"
@interface="row.tax_id = $event" @interface="row.tax_id = $event"
@change="onCalculateTotal($event)" @change="onCalculateTotal()"
@new="taxes.push($event)"
:form-error="form.errors.get('items.' + index + '.tax_id')" :form-error="form.errors.get('items.' + index + '.tax_id')"
:no-data-text="'{{ trans('general.no_data') }}'" :no-data-text="'{{ trans('general.no_data') }}'"
:no-matching-data-text="'{{ trans('general.no_matching_data') }}'" :no-matching-data-text="'{{ trans('general.no_matching_data') }}'"

View File

@ -133,9 +133,10 @@
] ]
] ]
])}}" ])}}"
:collapse="false" :collapse="true"
@interface="row.tax_id = $event" @interface="row.tax_id = $event"
@change="onCalculateTotal($event)" @change="onCalculateTotal()"
@new="taxes.push($event)"
:form-error="form.errors.get('items.' + index + '.tax_id')" :form-error="form.errors.get('items.' + index + '.tax_id')"
:no-data-text="'{{ trans('general.no_data') }}'" :no-data-text="'{{ trans('general.no_data') }}'"
:no-matching-data-text="'{{ trans('general.no_matching_data') }}'" :no-matching-data-text="'{{ trans('general.no_matching_data') }}'"