取消新增逻辑

This commit is contained in:
liaozetao
2024-03-21 15:06:26 +08:00
parent 0880cedd77
commit 2959a7ec7c

View File

@@ -109,6 +109,7 @@ export default {
return {
isEdit: false,
items: [],
cache: {},
};
},
setup() {
@@ -133,6 +134,7 @@ export default {
$this.renderTableInfo();
});
$(".js-add").click(function () {
$this.cache = {};
$("#minValue").val("");
$("#maxValue").val("");
$("#addModal").modal("show");
@@ -161,6 +163,10 @@ export default {
minValue: minValue,
maxValue: maxValue,
};
this.cache = {
minValue: minValue,
maxValue: maxValue,
};
this.items.splice(this.items.length, 0, item);
this.items = this.items.sort((a, b) => {
if (a.minValue < b.minValue) {
@@ -182,6 +188,16 @@ export default {
if (apiResult(res)) {
this.disableTableInfo();
this.getTableInfo();
} else {
let cache = this.cache;
let items = this.items;
for (let i = 0; i < items.length; i++) {
let item = items[i];
if (cache.minValue == item.minValue && cache.maxValue == item.maxValue) {
this.items.splice(i, 1);
break;
}
}
}
});
},
@@ -224,7 +240,7 @@ export default {
);
} else {
tds.push(
`<td><i class="glyphicon glyphicon-remove js-remove-item" data-idx="${i}"><input class="input-sm" name="minValue" data-idx="${i}" value="${item.minValue}"></td>`
`<td><i class="glyphicon glyphicon-remove js-remove-item" data-idx="${i}"></i><input class="input-sm" name="minValue" data-idx="${i}" value="${item.minValue}"></td>`
);
}
tds.push(