若依前后端不分离
前端获取表格选中行:
let rows = $.map($("#" + table.options.id).bootstrapTable('getSelections'), function (row) {return row;});
数组使用:
let arr = [];
arr.push();
无需点击的弹层:
$.modal.msg("默认反馈");
$.modal.msgError("错误反馈");
$.modal.msgSuccess("成功反馈");
$.modal.msgWarning("警告反馈");
点击"确认"的弹层:
$.modal.alert("默认提示");
$.modal.alertError("错误提示");
$.modal.alertSuccess("成功提示");
$.modal.alertWarning("警告提示");
$.modal.confirm("确认信息", function() {});
设置表格各列的宽度:
在<table>标签前一行加入<style>标签,如下:
<div class="col-sm-12 select-table table-bordered">
<style type="text/css">
/*设置表格布局算法:fixed-列宽由表格宽度和列宽度设定。*/
.select-table table {
table-layout:fixed;
word-break:break-all;
word-wrap:break-word;
}
</style>
<table id="bootstrap-table"></table>
</div>
动态选择是否可以点击多选框:
{
checkbox: true,
formatter: function (value, row, index) {
if (row.type === 1 && row.sendFlag === 1) {
return {disabled: false}
}else {
return {disabled: true}
}
}
},
js的onclick调用函数传参:
单个参数传值注意括号处添加 \' 转义,多个参数传值注意中间用 , 连接且加上 \' 转义才能生效。
actions.push('<a class="btn btn-danger btn-xs" ' +
'href="javascript:void(0)" ' +
'onclick="doRecall(\'' + row.corpSecret + '\',\'' + msgid + '\')">' +
'<i class="fa fa-remove"></i> 撤回</a> ');
return actions.join('');
ajax调用controller中的函数:
url 中添加 值 :
@PostMapping("/recall")
data传值:左边"item"必须对应方法中传入的参数名字,右边item必须为ajax接收到的参数名字
data: {
"item1" : item1,
"item2" : item2,
},
ajax基础语法:
$.ajax({
url: prefix + "/recall",
type: "POST",
data: {
"corpSecret" : corpSecret,
"msgid" : msgid,
},
success: function (data) {
console.log(data);
},
error: function (error) {
console.log('@error: ' + JSON.stringify(error))
}
})
切割字符串:
msgid = JSON.stringify(rows[i].response).split('\\"')[9]
2023-05-08
---------------------------------------------------------------------------------------------------
结束