$(function() {
var options = {
url: prefix + "/list",
createUrl: prefix + "/add",
updateUrl: prefix + "/edit/{id}",
modalName: "机构",
clickToSelect: true,
columns: [{
radio: true
},
{
field: 'id',
title: '代理表',
visible: false
},
{
field: 'rugrChief',
title: '机构联系人'
},
{
field: 'rugrPhone',
title: '机构电话'
},
{
field: 'rugrJoindate',
title: '创建时间'
},
{
field: 'link',
title: '推广链接',
visible: false
},
{
title: '推广链接',
align: 'center',
formatter: function(value, row, index) {
var actions = [];
actions.push('<input type="button" value="点击复制链接" class="fa fa-link" οnclick="copy(\'' + row.link + '\')"/>');
return actions.join('');
}
}]
};
$.table.init(options);
});
// row.link,获取当前行的link字段
// 复制方法,创建一个input标签,给input标签的value属性赋值,复制之后删除此标签
function copy(link) {
let oInput = document.createElement("input");
oInput.value = link;
document.body.appendChild(oInput);
oInput.select(); // 选择对象;
document.execCommand("Copy"); // 执行浏览器复制命令
$.modal.msgSuccess('已复制!');
oInput.remove();
}
给表格每一行添加复制链接按钮
最新推荐文章于 2022-10-27 10:07:19 发布