新增删除功能

This commit is contained in:
liaozetao
2023-10-18 16:54:04 +08:00
parent 2adafe5600
commit 770a2f37c0
5 changed files with 105 additions and 19 deletions

View File

@@ -29,26 +29,34 @@ export default {
}
},
// 构建下拉组合框
build: function (url, idstr, defval) {
build: function (val, idstr, defval) {
var _this = this;
if (url) {
$.ajax({
type: 'post',
url: url,
dataType: 'json',
success: function (json) {
$(idstr).empty();
$.each(json, function (n, value) {
$(idstr).append("<option value='" + value.oval + "' data-value='" + value.oval + "'>" + value.otxt + "</option>");
});
$(idstr).btComboBox();
_this.setDef(idstr, defval);
}
});
if (val) {
if (Object.prototype.toString.call(val) === '[object Object]') {
$(idstr).empty();
$.each(val, function (n, value) {
$(idstr).append("<option value='" + value.oval + "' data-value='" + value.oval + "'>" + value.otxt + "</option>");
});
$(idstr).btComboBox();
_this.setDef(idstr, defval);
} else {
$.ajax({
type: 'post',
url: val,
dataType: 'json',
success: function (json) {
$(idstr).empty();
$.each(json, function (n, value) {
$(idstr).append("<option value='" + value.oval + "' data-value='" + value.oval + "'>" + value.otxt + "</option>");
});
$(idstr).btComboBox();
_this.setDef(idstr, defval);
}
});
}
} else {
$(idstr).btComboBox();
_this.setDef(idstr, defval);
}
}
}

View File

@@ -594,6 +594,15 @@ export default {
$("#radishRenewPrice").val("");
$("#radishOriginalPrice").val("");
$("input:radio[name='goldSale']")[0].checked = true;
$("input:radio[name='radishSale']")[0].checked = true;
$("input:radio[name='enable']")[0].checked = true;
$("input:radio[name='isSale']")[0].checked = true;
$("input:radio[name='isNobleLimit']")[0].checked = true;
$("input:radio[name='isMonsterLimit']")[0].checked = true;
$("input:radio[name='isWeekStarLimit']")[0].checked = true;
$("input:radio[name='isActivityLimit']")[0].checked = true;
$("#nobleId").btComboBox('disable');
ComboboxHelper.setDef("#nobleId", '0');

View File

@@ -358,7 +358,7 @@ export default {
width: '5%',
valign: 'middle',
formatter: function (val, row, index) {
return '<button class="btn btn-sm btn-success opt-edit" data-index="' + index + '">编辑</button>';
return '<button class="btn btn-sm btn-success opt-edit" data-index="' + index + '">编辑</button>' + '<button class="btn btn-sm btn-default opt-del" data-index="' + index + '">删除</button>';
}
}
],
@@ -490,6 +490,29 @@ export default {
});
}
});
$('#table').on('click', '.opt-del', function () {
const currentData = $('#table').bootstrapTable('getData')[$(this).data('index')];
var id = currentData.id;
const msg = '确定要删除吗?';
if (confirm(msg)) {
$.ajax({
type: "get",
url: "/admin/seize-treasure/convert/item/del?id=" + id,
dataType: "json",
success: function (json) {
if (json.success == 'true' || json.code == 200) {
$("#tipMsg").text("删除成功");
$("#tipModal").modal('show');
TableHelper.doRefresh("#table");
} else {
$("#tipMsg").text("删除失败." + json.message);
$("#tipModal").modal('show');
}
}
});
}
});
});
}
},

View File

@@ -279,7 +279,7 @@ export default {
width: '5%',
valign: 'middle',
formatter: function (val, row, index) {
return '<button class="btn btn-sm btn-success opt-edit" data-index="' + index + '">编辑</button>';
return '<button class="btn btn-sm btn-success opt-edit" data-index="' + index + '">编辑</button>' + '<button class="btn btn-sm btn-default opt-del" data-index="' + index + '">删除</button>';
}
}
],
@@ -365,6 +365,29 @@ export default {
});
$("#deployedModal").modal('show');
});
$('#table').on('click', '.opt-del', function () {
const currentData = $('#table').bootstrapTable('getData')[$(this).data('index')];
var id = currentData.id;
const msg = '确定要删除吗?';
if (confirm(msg)) {
$.ajax({
type: "get",
url: "/admin/seize-treasure/pool/item/del?id=" + id,
dataType: "json",
success: function (json) {
if (json.success == 'true' || json.code == 200) {
$("#tipMsg").text("删除成功");
$("#tipModal").modal('show');
TableHelper.doRefresh("#table");
} else {
$("#tipMsg").text("删除失败." + json.message);
$("#tipModal").modal('show');
}
}
});
}
});
},
optEdit() {
$('#table').on('click', '.opt-edit', function () {

View File

@@ -340,7 +340,7 @@ export default {
width: '5%',
valign: 'middle',
formatter: function (val, row, index) {
return '<button class="btn btn-sm btn-success opt-edit" data-index="' + index + '">编辑</button>';
return '<button class="btn btn-sm btn-success opt-edit" data-index="' + index + '">编辑</button>' + '<button class="btn btn-sm btn-default opt-del" data-index="' + index + '">删除</button>';
}
}
],
@@ -501,6 +501,29 @@ export default {
}
});
});
$('#table').on('click', '.opt-del', function () {
const currentData = $('#table').bootstrapTable('getData')[$(this).data('index')];
var id = currentData.id;
const msg = '确定要删除吗?';
if (confirm(msg)) {
$.ajax({
type: "get",
url: "/admin/seize-treasure/reward/del?id=" + id,
dataType: "json",
success: function (json) {
if (json.success == 'true' || json.code == 200) {
$("#tipMsg").text("删除成功");
$("#tipModal").modal('show');
TableHelper.doRefresh("#table");
} else {
$("#tipMsg").text("删除失败." + json.message);
$("#tipModal").modal('show');
}
}
});
}
});
}
},
unmounted() {