若依框架前端批量删除
【代码】若依框架前端批量删除。
·
function remove(row) {
var url = prefix + "/remove";
var params = {"ids" : row};
if(window.confirm("是否删除箱号为" + row + "数据")){
$.post(url,params,function (result){
if (result.code != 0){
$.modal.msgError("删除失败,请联系管理员");
}
query();
})
}
}
function removeAll(){
var url = prefix + "/remove";
var ids = [];
var cols= $('#bootstrap-table').bootstrapTable('getSelections');
for (var i = 0; i<cols.length;i++){
ids.push(cols[i].boxNumber)
}
//join使数组变成字符串类型
var params = {"ids": ids.join()};
if(window.confirm("是否删除箱号为" + ids.toString() + "数据")){
if (ids.length == 0){
$.modal.msgError("最少要选择一个箱号进行删除");
}else {
$.post(url,params,function (result){
if (result.code != 0){
$.modal.msgError("删除失败,请联系管理员");
}
query();
})
}
}
}
添加每行按钮
function query() {
//取到上面字段的值
var boxNumber = $("#boxNumber").val()
var workOrder = $("#workOrder").val()
var model = $("#model").val()
var createDate = $("#createDate").val()
var updateDate = $("#updateDate").val()
//如果这些条件都等于空 说明操作并没有输入条件
if (model == "" && boxNumber == "" && workOrder == "" && updateDate =="" && createDate=="" ) {
$.modal.msgError("最少填写一个条件进行搜索");
} else {
table.set("bootstrap-table");
table.options.formId = $('form').attr('id');
var params = $("#bootstrap-table").bootstrapTable('getOptions');
$("#bootstrap-table").bootstrapTable('refresh', params);
var options = {
url: prefix + "/list",
createUrl: prefix + "/add",
updateUrl: prefix + "/edit/{id}",
removeUrl: prefix + "/remove",
exportUrl: prefix + "/export",
tablePrint: prefix + "/tablePrint",
modalName: "Pack装箱箱子",
columns: [
{
checkbox: true
},
{
title: '操作',
align: 'center',
formatter: function (value, row, index) {
var actions = [];
actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.boxNumber + '\')"><i class="fa fa-edit"></i>打印</a> ');
// actions.push('<a class="btn btn-success btn-xs ' +'" href="javascript:void(0)" onclick="$.modal.NoOpen(\'详情\', \'/system/DgMesDataPackBox/showData/\'+ \'' + row.boxNumber + '\' , \'1000\', \'1000\')"><i class="fa fa-edit"></i>详情</a> ');
actions.push('<a class="btn btn-success btn-xs ' +'" href="javascript:void(0)" onclick="$.modal.NoOpen(\'详情\', \'/system/DgMesDataPackBox/showDataInfo/\'+ \'' + row.boxNumber + '\' , \'1000\', \'1000\')"><i class="fa fa-edit"></i>详情</a> ');
actions.push('<a class="btn btn-success btn-xs ' +'" href="javascript:void(0)" onclick="$.table.sogExcel(\'/system/DgMesDataPackBox/export/\'+ \'' + row.boxNumber + '\',null)"><i class="fa fa-remove"></i>导出</a>');
actions.push('<a class="btn btn-success btn-xs ' +'" href="javascript:void(0)" onclick="remove(\'' + row.boxNumber + '\')"><i class="fa fa-remove"></i>删除</a> ');
return actions.join('');
}
}
]
};
$.table.init(options);
}
}
后端
controller
@RequiresPermissions("system:DgMesDataPackBox:remove")
@Log(title = "Pack装箱箱子", businessType = BusinessType.DELETE)
@PostMapping("/remove")
@ResponseBody
public AjaxResult remove(String ids) {
return toAjax(mesDataPackBoxService.deleteDgMesDataPackBoxByIds(ids));
}
service和实现类
public int deleteDgMesDataPackBoxByIds(String ids);
@Transactional
@Override
public int deleteDgMesDataPackBoxByIds(String ids) {
dgMesDataPackBoxMapper.deleteDgMesDataPackBoxCellByBoxNumbers(Convert.toStrArray(ids));
return dgMesDataPackBoxMapper.deleteDgMesDataPackBoxByIds(Convert.toStrArray(ids));
}
mapper
public int deleteDgMesDataPackBoxCellByBoxNumbers(String[] boxNumbers);
<delete id="deleteDgMesDataPackBoxCellByBoxNumbers" parameterType="String">
delete from dg_mes_data_pack_box_cell where box_number in
<foreach item="boxNumber" collection="array" open="(" separator="," close=")">
#{boxNumber}
</foreach>
</delete>
更多推荐
已为社区贡献1条内容
所有评论(0)