56 lines
2.1 KiB
JavaScript
56 lines
2.1 KiB
JavaScript
(function(){
|
|
X.pageLogic['conditionquery'] = {
|
|
init : function(parms){
|
|
var me = this;
|
|
this.parms = parms;
|
|
this.callback = parms.callback;
|
|
var data = parms.extData;
|
|
var dataArr = {
|
|
eventView:data.eventView,
|
|
events:data.events
|
|
}
|
|
X.api('ck/'+ dataArr['eventView']['cksql'] +'_model_sql','post',dataArr,function(d){
|
|
$(".conditionquery-sqldata").html(d[0]['sql']);
|
|
$(".conditionquery-apidata").html(JSON.stringify(dataArr));
|
|
})
|
|
var tab = 0
|
|
layui.element.on('tab(conditionquery)', function(data){
|
|
tab = data['index']
|
|
});
|
|
|
|
$(document).on("click",'.conditionquery-copy',function(){
|
|
|
|
if(tab == 0){
|
|
selectText('conditionquery-sqldata');
|
|
}else {
|
|
selectText('conditionquery-apidata');
|
|
}
|
|
document.execCommand('copy');
|
|
layer.msg('复制成功');
|
|
|
|
})
|
|
|
|
function selectText(element) {
|
|
var text = document.getElementById(element);
|
|
//做下兼容
|
|
if (document.body.createTextRange) { //如果支持
|
|
var range = document.body.createTextRange(); //获取range
|
|
range.moveToElementText(text); //光标移上去
|
|
range.select(); //选择
|
|
} else if (window.getSelection) {
|
|
var selection = window.getSelection(); //获取selection
|
|
var range = document.createRange(); //创建range
|
|
range.selectNodeContents(text); //选择节点内容
|
|
selection.removeAllRanges(); //移除所有range
|
|
selection.addRange(range); //添加range
|
|
/*if(selection.setBaseAndExtent){
|
|
selection.setBaseAndExtent(text, 0, text, 1);
|
|
}*/
|
|
} else {
|
|
alert("复制失败");
|
|
}
|
|
}
|
|
|
|
}
|
|
};
|
|
})(); |