123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291 |
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="UTF-8">
- <title>选择标签</title>
- <script type="text/javascript" src="${ctx}/assets/lib/jquery/1.9.1/jquery.min.js"></script>
- <style type="text/css">
- ul.ztree {margin-top: 10px;border: 1px solid #617775;background: #f0f6e4;width:220px;height:360px;overflow-y:scroll;overflow-x:auto;}
- .bq{font-size:14px;padding:5px 0 5px 30px;font-family: Microsoft YaHei;color:#4d4d4d;}
- .lm_lm{margin:10px 10px;}
- .lable{margin-right:5px;diaplay:inline;}
- </style>
- <link rel="stylesheet" type="text/css" media="screen" href="${ctx}/assets/lib/zTree/v3/css/zTreeStyle/zTreeStyle.css" >
- <script src="${ctx}/assets/lib/zTree/v3/js/jquery.ztree.all-3.5.min.js" type="text/javascript" ></script>
- <script type="text/javascript">
- String.prototype.replaceAll = function(s1,s2){
- return this.replace(new RegExp(s1,"gm"),s2);
- }
- var labels=eval(${labels!});
-
- var setting = {
- check: {
- enable: true,
- chkStyle: "radio",
- radioType: "all"
- },
- view: {
- dblClickExpand: false
- },
- data: {
- simpleData: {
- enable: true,
- idKey: "columnid",
- pIdKey: "parentid",
- rootPId: 0
- }
- },
- callback: {
- onClick: onClick,
- onCheck: onCheck
- }
- };
- var zNodes =${columns};
- function onClick(e, treeId, treeNode) {
- var zTree = $.fn.zTree.getZTreeObj("treeDemo");
- zTree.checkNode(treeNode, !treeNode.checked, null, true);
-
- return false;
- }
- function onCheck(e, treeId, treeNode) {
- var zTree = $.fn.zTree.getZTreeObj("treeDemo"),
- nodes = zTree.getCheckedNodes(true),
- columnNames = "";
- columnIDs="";
- for (var i=0;i<nodes.length; i++) {
- if(i>0){
- columnNames +=",";
- columnIDs +=",";
- }
- columnNames += nodes[i].name;
- columnIDs += nodes[i].columnid;
- }
- $("#columnName").val(columnNames);
- $("#columnID").val(columnIDs);
- tagColumnIDs=columnIDs
- $("#treeDemo").hide();
- }
- function showMenu() {
- $("#treeDemo").show();
- var cityObj = $("#columnName");
- var cityOffset = $("#columnName").offset();
- $("#menuContent").css({left:cityOffset.left + "px", top:cityOffset.top + cityObj.outerHeight() + "px"}).slideDown("fast");
- $("body").bind("mousedown", onBodyDown);
- }
- function hideMenu() {
- $("#menuContent").fadeOut("fast");
- $("body").unbind("mousedown", onBodyDown);
-
- }
- function onBodyDown(event) {
- if (!(event.target.id == "menuBtn" || event.target.id == "columnName" || event.target.id == "menuContent" || $(event.target).parents("#menuContent").length>0)) {
- hideMenu();
- }
-
- }
-
- $(document).ready(function(){
- $.fn.zTree.init($("#treeDemo"), setting, zNodes);
- });
- function findByLabelID(labelID){
- var la;
- $.each(labels, function(index,item) {
- if(item.labelID==labelID){
- la= item;
- }
- })
- return la;
- }
- var tagColumnIDs="";
- var _workbench=$("#workbench",parent.document.body).contents();
- var cmstag=_workbench.find("[objid='${objid}']").attr("cmstag");
- var context=_workbench.find("[objid='${objid}']")[0].outerHTML;
- //var context=_workbench.find("[objid='${objid}']")[0].innerHTML;
- //alert(context);
- var labelID1="";
- $(function(){
- //document.getElementById("context").value = context;
- //$("#context").append(context);//获取内容
- $.each(labels, function(index,item) {
- if(item.labelName.indexOf("-") >= 0){
- var lable='<div class="bq"><input type="radio" id="'+item.labelID+'" name="a" class="lable" >'+item.labelName+'';
- lable+='</div>';
- $("#labels1").append(lable);
- }else{
- var lable1='<div class="bq"><input type="radio" id="'+item.labelID+'" name="a" class="lable" >'+item.labelName+'';
- lable+='</div>';
- $("#labels").append(lable1);
- }
-
- if(cmstag!=null&&cmstag!="undefined"){
- labelID1=cmstag.split(":")[0];
- $("#"+labelID1).attr("checked","checked");
- }
- if(cmstag!=null&&cmstag.indexOf(":")==-1){
- $("#"+cmstag).attr("checked","checked");
- }
- ft();
- })
- function ft(){
- var thisLabel=findByLabelID($("input[name='a']:checked").attr("id"));
- //console.log(thisLabel);
- if(thisLabel!=null){
- var paramForm="";
- var labelID=thisLabel.labelID;
- if(cmstag!=null&&cmstag!="undefined"){
- labelID1=cmstag.split(":")[0];
- }
- if(thisLabel.params!=null){
- $.each(thisLabel.params,function(index,param){
- paramForm+="<div class='lm_lm'>"
- paramForm+="<label style='padding-right:10px;'>"+param.paramLabel+"</label>";
- if(param.paramInput=="text"){
- if(labelID=="fylb"){
- var fylbValue=_workbench.find("[labeltype='xxlblb']").attr("cmstag");
- if(fylbValue!=null){
- fylbValue=fylbValue.split(";")[1].split("=")[1];
- }else{
- alert("请先动态化列表");
- window.parent.closeDialog(window.parent.dialogIndex);
- return;
- }
- paramForm+="<input name='"+param.paramName+"' type='hidden' value="+fylbValue+" class='param'/>";
- }else{
- paramForm+="<input name='"+param.paramName+"' class='param'/>";
-
- }
-
- }else if(param.paramInput=="columnTree"){
- paramForm+="<input class='param' name='"+param.paramName+"' id='columnID' type='hidden'/><input id='columnName' type='text' readonly value='' onclick='showMenu();' />";
- }else if(param.paramInput=="select"){
- paramForm+="<input type='radio' name='"+param.paramName+"' class='param' value='focusBox' /><img src='/images'><input type='radio' name='"+param.paramName+"' class='param' value='ocusif'/><img src='/images'> ";
- }
-
-
- paramForm+="</div>"
-
- }) }
-
- $("#setParam").html(paramForm);
- if(labelID==labelID1&&cmstag!=null&&cmstag.indexOf(":")>=0&&labelID!="fylb"){
- var cmstage1=cmstag.split(":")[1];
- var cmstages=cmstage1.split(";");
- for(var i=0;i<cmstages.length;i++){
- if(labelID=="clj"||labelID=="qt"){
- $("[name='"+cmstages[i].split("=")[0]+"']").val(cmstag.split("=")[1]);
- }else{
- $("[name='"+cmstages[i].split("=")[0]+"']").val(cmstages[i].split("=")[1]);
- }
-
- if(cmstages[i].split("=")[0]=="columnID"){
- var zTree = $.fn.zTree.getZTreeObj("treeDemo");
- var node=zTree.getNodeByParam("columnid",cmstages[i].split("=")[1]);
- var columnName=$("#columnName").val();
- if(columnName!=node.name){
- zTree.checkNode(node, !node.checked, null, true);
- $("#columnName").val(node.name);
- $("#columnID").val(node.columnid);
- }
-
- }
- }
- }}
- }
- $(".lable").click(function(){
- ft();
- })
- $("#qd").click(function(){
- var thisLabel=findByLabelID($("input[name='a']:checked").attr("id"));
- if(typeof(thisLabel)=="undefined"){
- alert("请选择标签");
- }
-
- $.each(thisLabel.eles,function(index,ele){
-
- $.each(ele.attrs,function(i,attr){
- value=attr.value;
- $(".param").each(function(){
- value=value.replaceAll("#"+$(this).attr("name")+"#",$(this).val());
- })
- if(attr.key=="show"){
- _workbench.find("[objid='${objid}']")[0].innerHTML=value;
- }else{
-
- if(index==0){
- _workbench.find("[objid='${objid}']").find(ele.jquerySelect).addBack().attr(attr.key,value);
- }else{
- _workbench.find("[objid='${objid}']").find(ele.jquerySelect).attr(attr.key,value);
- }
- }
- })
- })
-
- window.parent.closeDialog(window.parent.dialogIndex);
- })
-
-
- $("#qdbj").click(function(){
- var thisLabel=findByLabelID($("input[name='a']:checked").attr("id"));
- if(typeof(thisLabel)=="undefined"){
- window.parent.closeDialog(window.parent.dialogIndex);
- //调用编辑 页面
- edit();
- }
- $.each(thisLabel.eles,function(index,ele){
-
- $.each(ele.attrs,function(i,attr){
- value=attr.value;
- $(".param").each(function(){
- value=value.replaceAll("#"+$(this).attr("name")+"#",$(this).val());
- })
- if(attr.key=="show"){
- _workbench.find("[objid='${objid}']")[0].innerHTML=value;
- }else{
-
- if(index==0){
- _workbench.find("[objid='${objid}']").find(ele.jquerySelect).addBack().attr(attr.key,value);
- }else{
- _workbench.find("[objid='${objid}']").find(ele.jquerySelect).attr(attr.key,value);
- }
- }
- })
- })
-
- window.parent.closeDialog(window.parent.dialogIndex);
- //调用编辑 页面
- edit();
- })
-
-
- })
-
- function edit(){
- window.parent.showDialog('p_setproperty','编辑代码',"/myconsole/dynamic/edit?objID="+'${objid}'+"&labelType="+'${labelType}',900,565);
- }
- </script>
- </head>
- <body>
- <div>
- <div id="labels" style="padding-bottom:20px;float:left;width:50%;"></div>
- <div id="labels1" style="padding-bottom:20px;"></div>
- </div>
- <div id="menuContent" class="menuContent" style="display:none; position: absolute;">
- <ul id="treeDemo" class="ztree" style="margin-top:0; width:180px; height: 300px;"></ul>
- </div>
-
- <div id="setParam" style="font-size:14px;padding:5px 0 5px 30px;font-family: Microsoft YaHei;color:#4d4d4d;"></div>
- <div style="text-align:center;margin-top:40px;"><button id="qd" style="background:#4285f4;border-radius:5px;color:#fff;border:none;padding:8px 18px;font-size:13px;margin-right: 10px;">确定</button><button id="qdbj" style="background:#4285f4;border-radius:5px;color:#fff;border:none;padding:8px 18px;font-size:13px;">保存并编辑</button></div>
- </body>
- </html>
|