版权声明:有一种生活不去经历不知其中艰辛,有一种艰辛不去体会,不会知道其中快乐,有一种快乐,没有拥有不知其中纯粹 https://blog.csdn.net/wwwzydcom/article/details/83242776
前台JS
// 更新操作
function openModifySaleChanceDialog() {
var rows = $('#dg').datagrid("getSelections");
// console.log(rows);
if (rows.length ==0){
$.messager.alert('来自Crm','请选择一条记录更新')
return;
}
if (rows.length >1){
$.messager.alert('来自Crm','只能选择一条记录更新')
return;
}
/**
* 1.回填表单数据
* 2.显示弹窗
*/
$('#fm').form('load',rows[0]);
$('#dlg').dialog('open').dialog('setTitle','更新营销机会');
}
批量删除操作
数组的形式,前台请求通过相同的名称连接在一起ids= &ids=
Controller层
//批量的删除
@RequestMapping("deleteSaleChanceBatch")
@ResponseBody
public ResultInfo deleteSaleChanceBatch(Integer[] ids){
saleChanceService.deleteBatch(ids);
return success(CrmConstant.OPS_SUCCESS_MSG);
}
Service层
//批量的删除
@RequestMapping("deleteSaleChanceBatch")
@ResponseBody
public ResultInfo deleteSaleChanceBatch(Integer[] ids){
saleChanceService.deleteBatch(ids);
return success(CrmConstant.OPS_SUCCESS_MSG);
}
Dao
public Integer deleteBatch(Integer[] ids) throws DataAccessException{
AssertUtil.isTrue(null==ids||ids.length==0,"请选择待删除记录!");
return baseDao.deleteBatch(ids);
}
xml的文件
<!--批量删除-->
<update id="deleteBatch">
UPDATE t_sale_chance SET is_valid=0 WHERE id IN (
<foreach collection="array" item="item" separator=",">
#{item}
</foreach>
)
</update>
foreach
对于动态SQL 非常必须的,主是要迭代一个集合,通常是用于IN 条件。
List 实例将使用“list”做为键,数组实例以“array” 做为键。