提交按钮 修改状态
前台代码
<div class="btn-group-sm hidden-xs" id="toolbar" role="group">
<a class="btn btn-success" onclick="commitAll()">
<i class="fa fa-commit"></i> 提前完成
</a>
</div>
前台发送请求
function commit(id) {
$.modal.confirm("确定提交该条" + $.table._option.modalName + "信息吗?", function () {
var url = $.common.isEmpty(id) ? $.table._option.commitUrl : $.table._option.commitUrl.replace("{id}", id);
var data = {"ids": id};
$.operate.submit(url, "post", "json", data);
});
}
// 批量提交信息
function commitAll() {
//debugger;
var rows = $.common.isEmpty($.table._option.uniqueId) ? $.table.selectFirstColumns() : $.table.selectColumns($.table._option.uniqueId);
if (rows.length == 0) {
$.modal.alertWarning("请至少选择一条记录");
return;
}
$.modal.confirm("确认要提交选中的" + rows.length + "条数据吗?", function () {
//debugger;
var url = $.table._option.commitUrl;
//var url='http://127.0.0.1:9988/media/taskAll/commit';
var data = {"ids": rows.join()};
$.operate.submit(url, "post", "json", data);
});
}
controller层
/**
* 提交总任务
*/
@RequiresPermissions("media:taskAll:commit")
@Log(title = "总任务", businessType = BusinessType.DELETE)
@RequestMapping("/commit")
@ResponseBody
public AjaxResult commit(String ids) {
return toAjax(taskAllService.updateTaskAllByIds(ids));
}
service层
public int updateTaskAllByIds(String ids);
impl
/**
* @param
* @return int
* 提交
* @author 王志海
* @date 2019/11/14 3:06 PM
*/
@Override
public int updateTaskAllByIds(String ids) {
String[] idArr = Convert.toStrArray(ids);
return taskAllMapper.updateTaskAllByIds(idArr);
}
mapper层
public int updateTaskAllByIds(String[] ids);
注意事项
模块间调用service要在controller层引入
@Autowired
private ITaskService taskService;
sql
<update id="updateTaskAllByIds" parameterType="String">
update kj_task_all set task_type = 0
where id in
<foreach collection="array" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</update>
网友评论