fix
This commit is contained in:
parent
85f38e9539
commit
d5438a4090
@ -21,8 +21,9 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">Товар</th>
|
||||
<th scope="col">Количество</th>
|
||||
<th scope="col">Цена</th>
|
||||
<th scope="col">Количество</th>
|
||||
<th scope="col">Сумма</th>
|
||||
<th scope="col">Действие</th>
|
||||
</tr>
|
||||
</thead>
|
||||
@ -70,6 +71,7 @@
|
||||
console.log('try to add good')
|
||||
var count = $('#count').val();
|
||||
var good = $('#good').val();
|
||||
if (count > 0 && good > 0){
|
||||
$.ajax({
|
||||
method: "GET",
|
||||
url: `/Home/GetGood`,
|
||||
@ -89,6 +91,7 @@
|
||||
countElem.value = '1'
|
||||
}
|
||||
});
|
||||
}
|
||||
})
|
||||
|
||||
saveBtn.addEventListener("click", () => {
|
||||
@ -126,7 +129,8 @@
|
||||
let price = 0;
|
||||
let count = 0;
|
||||
list.forEach((elem) => {
|
||||
resultTable.innerHTML += `<tr><td>${elem.good.goodName}</td><td>${elem.count}</td><td>${Math.round(elem.good.price * elem.count * 100) / 100}</td><td> \
|
||||
console.log(elem);
|
||||
resultTable.innerHTML += `<tr><td>${elem.good.goodName}</td><td>${elem.good.price}</td><td>${elem.count}</td><td>${Math.round(elem.good.price * elem.count * 100) / 100}</td><td> \
|
||||
<div> \
|
||||
<button onclick="deleteGood(${count})" type="button" class="btn btn-danger"> \
|
||||
<i class="fa fa-trash" aria-hidden="true"></i> \
|
||||
|
@ -72,25 +72,27 @@
|
||||
console.log('try to add good')
|
||||
var count = $('#count').val();
|
||||
var good = $('#good').val();
|
||||
$.ajax({
|
||||
method: "GET",
|
||||
url: `/Home/GetGood`,
|
||||
data: { Id: good },
|
||||
success: function (result) {
|
||||
let flag = false
|
||||
if (list.length > 0) {
|
||||
list.forEach((elem) => {
|
||||
if (elem.good.id === parseInt(result.id)) {
|
||||
console.log('good already added')
|
||||
flag = true
|
||||
}
|
||||
})
|
||||
if (count > 0 && good > 0) {
|
||||
$.ajax({
|
||||
method: "GET",
|
||||
url: `/Home/GetGood`,
|
||||
data: { Id: good },
|
||||
success: function (result) {
|
||||
let flag = false
|
||||
if (list.length > 0) {
|
||||
list.forEach((elem) => {
|
||||
if (elem.good.id === parseInt(result.id)) {
|
||||
console.log('good already added')
|
||||
flag = true
|
||||
}
|
||||
})
|
||||
}
|
||||
if (!flag) list.push({ good: result, count: count })
|
||||
reloadTable()
|
||||
countElem.value = '1'
|
||||
}
|
||||
if (!flag) list.push({ good: result, count: count })
|
||||
reloadTable()
|
||||
countElem.value = '1'
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
})
|
||||
|
||||
saveBtn.addEventListener("click", () => {
|
||||
|
Loading…
Reference in New Issue
Block a user