new item issue and multiple selected value fixed..

This commit is contained in:
Cüneyt Şentürk 2020-12-26 18:38:07 +03:00
parent ed33992643
commit 0c2c5dd890
4 changed files with 102 additions and 7 deletions

View File

@ -168,15 +168,20 @@ class CreateDocumentItemsAndTotals extends Job
}
if (empty($item['item_id'])) {
$new_item = $this->dispatch(new CreateItem([
$new_item_request = [
'company_id' => $this->request['company_id'],
'name' => $item['name'],
'description' => $item['description'],
'sale_price' => $item['price'],
'purchase_price' => $item['price'],
'tax_ids' => $item['tax_ids'],
'enabled' => '1'
]));
];
if (!empty($item['tax_ids'])) {
$new_item_request['tax_ids'] = $item['tax_ids'];
}
$new_item = $this->dispatch(new CreateItem($new_item_request));
$item['item_id'] = $new_item->id;
}

View File

@ -605,17 +605,71 @@ export default {
selected: function (selected) {
if (!this.multiple) {
this.selected = selected.toString();
} else {
if (Array.isArray(this.selected) && !this.selected.length) {
this.selected = selected;
} else {
let is_string = false;
let pre_value = [];
selected.forEach(item => {
if (typeof item != 'string') {
is_string = true;
pre_value.push(item.toString());
}
});
if (is_string) {
this.selected = pre_value;
}
}
}
},
value: function (selected) {
this.selected = selected;
if (!this.multiple) {
this.selected = selected.toString();
} else {
if (Array.isArray(this.selected) && !this.selected.length) {
this.selected = selected;
} else {
let is_string = false;
let pre_value = [];
selected.forEach(item => {
if (typeof item != 'string') {
is_string = true;
pre_value.push(item.toString());
}
});
if (is_string) {
this.selected = pre_value;
}
}
}
this.change();
},
model: function (selected) {
this.selected = selected;
if (!this.multiple) {
this.selected = selected.toString();
} else {
let is_string = false;
let pre_value = [];
selected.forEach(item => {
if (typeof item != 'string') {
is_string = true;
pre_value.push(item.toString());
}
});
if (is_string) {
this.selected = pre_value;
}
}
this.change();
},

View File

@ -817,11 +817,41 @@ export default {
selected: function (selected) {
if (!this.multiple) {
this.selected = selected.toString();
} else {
let is_string = false;
let pre_value = [];
selected.forEach(item => {
if (typeof item != 'string') {
is_string = true;
pre_value.push(item.toString());
}
});
if (is_string) {
this.selected = pre_value;
}
}
},
value: function (selected) {
this.selected = selected;
if (!this.multiple) {
this.selected = selected;
} else {
let is_string = false;
let pre_value = [];
selected.forEach(item => {
if (typeof item != 'string') {
is_string = true;
pre_value.push(item.toString());
}
});
if (is_string) {
this.selected = pre_value;
}
}
this.change();
},

View File

@ -73,7 +73,7 @@ const app = new Vue({
let grand_total = 0;
// items calculate
this.items.forEach(function(item) {
this.items.forEach(function(item, index) {
let discount = 0;
item.total = item.price * item.quantity;
@ -188,6 +188,12 @@ const app = new Vue({
sub_total += item.total;
grand_total += item.grand_total;
this.form.items[index].description = item.description;
this.form.items[index].quantity = item.quantity;
this.form.items[index].price = item.price;
this.form.items[index].discount = item.discount;
this.form.items[index].total = item.total;
}, this);
this.totals.sub = sub_total;