若依前后端不分离

前端获取表格选中行:

let rows = $.map($("#" + table.options.id).bootstrapTable('getSelections'), function (row) {return row;});

或者
let rows = $('#bootstrap-table').bootstrapTable('getSelections');

数组使用:

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

---------------------------------------------------------------------------------------------------

 

 获取当前登录账号、获取当前时间:

ShiroUtils.getLoginName()
DateUtils.getNowDate()

联动下拉框:

先用div包裹需要联动的下拉框,并写上id="link_select"

<div id="link_select">
<div class="form-group">
<label class="col-sm-3 control-label is-required">下拉框一:</label>
<div class="col-sm-8">
<select name="werks" class="first form-control m-b" required></select>
</div>
</div>

<div class="form-group">
<label class="col-sm-3 control-label is-required">下拉框二:</label>
<div class="col-sm-8">
<select name="position" class="second form-control m-b" required></select>
</div>
</div>
</div>

再添加

<th:block th:include="include :: jquery-cxselect-js" />

最后

$('#link_select').cxSelect({
selects: ['first', 'second'],
required: true,
jsonValue: 'v',
data: [
{'v': 'val1', 'n': '选项一', 's': [
{'v': '1', 'n': '选项一的1'},
{'v': '2', 'n': '选项一的2'},
{'v': '3', 'n': '选项一的3'}
]},
{'v': 'val2', 'n': '选项二', 's': [
{'v': '1', 'n': '选项二的1'},
{'v': '2', 'n': '选项二的2'}
]},
]
});

 

 

2023-06-06

---------------------------------------------------------------------------------------------------

获取提交表单时的数据:

let data = $("#form-lb_out-add").serializeArray();

 

 

 

 

 

 

 

 

 

 

2023-06-07

---------------------------------------------------------------------------------------------------

结束

posted @ 2023-05-08 10:01  长毛君吃面  阅读(1053)  评论(0)    收藏  举报