templateLabel.zml 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. <script>
  2. //所有子行业 map 根据 行业 分组
  3. var subIndustryMap = new Z.HashMap();
  4. <#for key : subIndustryMap.keySet()>
  5. subIndustryMap.put('${key}', ${Jsons.toString(subIndustryMap.get(key))});
  6. </#for>
  7. //所有属性分类 map 根据 行业 分组
  8. var attributeCatMap = new Z.HashMap();
  9. <#for key : attributeCatMap.keySet()>
  10. attributeCatMap.put('${key}', ${Jsons.toString(attributeCatMap.get(key))});
  11. </#for>
  12. //所有属性分类 map 根据 分类 分组
  13. var attributeMap = new Z.HashMap();
  14. <#for key : attributeMap.keySet()>
  15. attributeMap.put('${key}', ${Jsons.toString(attributeMap.get(key))});
  16. </#for>
  17. var indIdarr = Z.AR.toArray("${indIdarr}", ",");
  18. var attrIdarr = Z.AR.toArray("${attrIdarr}", ",");
  19. function doLabelIdSet(type, attaid, btn)
  20. {
  21. if (type == "industry")
  22. {
  23. if(Z.AR.contains(indIdarr, attaid))
  24. {
  25. Z.AR.remove(indIdarr, attaid);
  26. Z(btn).removeClass("z-active");
  27. }
  28. else
  29. {
  30. indIdarr.push(attaid);
  31. Z(btn).addClass("z-active");
  32. }
  33. }
  34. else if (type == "attribute")
  35. {
  36. if (Z.AR.contains(attrIdarr, attaid))
  37. {
  38. Z.AR.remove(attrIdarr, attaid);
  39. Z(btn).removeClass("z-active");
  40. }
  41. else
  42. {
  43. attrIdarr.push(attaid);
  44. Z(btn).addClass("z-active");
  45. }
  46. }
  47. }
  48. function doIndustrySelect()
  49. {//选择行业
  50. var dialog = new Z.Dialog();
  51. dialog.title = "选择行业";
  52. dialog.url = "industrySelect.htm" ;
  53. dialog.width = 360;
  54. dialog.height = 400;
  55. dialog.fixed = true;
  56. dialog.scroll = true;
  57. dialog.execute();
  58. }
  59. var nativeIndustryId = '${template.getIndustryId()}';
  60. var nativeindIdarr = Z.AR.toArray("${indIdarr}", ",");
  61. var nativeattrIdarr = Z.AR.toArray("${attrIdarr}", ",");
  62. var selectIndustryId = nativeIndustryId;
  63. function doShowSubIndustry(industryId, industryName)
  64. {//显示子行业 industryId 父行业ID ,industryName父行业名
  65. Z("#industryId").val(industryName);
  66. selectIndustryId = industryId;
  67. //清空选中信息
  68. indIdarr = [];
  69. var subArr = subIndustryMap.get(""+industryId);
  70. var subListHtml = "";
  71. if(subArr != null && typeof(subArr) != "undefined" && subArr.length > 0)
  72. {
  73. Z.each(subArr, function(sub, i){
  74. var active = "";
  75. if(industryId == nativeIndustryId && Z.AR.contains(nativeindIdarr, ""+sub.industrySubId))
  76. {//如果切换回来 保存原来的选择
  77. active = "z-active";
  78. indIdarr.push(""+sub.industrySubId);
  79. }
  80. subListHtml += '<button name="subName" id="sub_'+sub.industrySubId+'" type="button" class="z-button z-large z-bordered z-blue-bd z-mg-r6 z-mg-t6 z-hover '+active+'" onclick="doLabelIdSet(\'industry\', \''+sub.industrySubId+'\',this)">'+sub.industrySubName+'</button>';
  81. });
  82. }
  83. Z("#subList").html(subListHtml);
  84. }
  85. function doShowSubAttribute(industryId, industryName)
  86. {//显示 行业 关联标签属性
  87. var attributeInfoHtml = "";
  88. //获取行业对应的所有分类
  89. var catList = attributeCatMap.get(""+industryId);
  90. //清空属性选中信息
  91. attrIdarr = [];
  92. if (typeof(catList) != "undefined" && catList.hasOwnProperty("length") && catList.length > 0)
  93. {
  94. attributeInfoHtml += '<table class="z-table z-bordered z-pd6">';
  95. Z.each(catList, function(cat, i){
  96. var trColor = (i%2 == 0) ? "#f3fdfc" : "";
  97. attributeInfoHtml += '<tr class="z-h40" bgcolor="'+trColor+'">';
  98. attributeInfoHtml += '<td width="10%">'+cat.attributeCatName+':</td>';
  99. attributeInfoHtml += '<td width="*">';
  100. //获取 行业下分类 下的 属性
  101. var attributeList = attributeMap.get(""+cat.attributeCatId);
  102. if (typeof(attributeList) != "undefined" && attributeList != null && attributeList.hasOwnProperty("length") && attributeList.length > 0)
  103. {
  104. Z.each(attributeList, function(attr, j){
  105. var active = "";
  106. if(industryId == nativeIndustryId && Z.AR.contains(nativeattrIdarr, ""+attr.attributeId))
  107. {//如果切换回来 保存原来的选择
  108. active = "z-active";
  109. attrIdarr.push(""+attr.attributeId);
  110. }
  111. attributeInfoHtml += '<button name="attrId" id="sub_'+attr.attributeId+'" type="button" class="z-button z-large z-bordered z-blue-bd z-mg-r6 z-mg-t6 z-hover '+active+'" onclick="doLabelIdSet(\'attribute\', \''+attr.attributeId+'\',this)">'+attr.attributeName+'</button>';
  112. });
  113. }
  114. attributeInfoHtml += '</td>';
  115. attributeInfoHtml += '</tr>';
  116. });
  117. attributeInfoHtml += '</table>';
  118. }
  119. Z("#attributeInfo").html(attributeInfoHtml);
  120. }
  121. function doTemplateLabelExec()
  122. {//提交关联操作
  123. if (indIdarr.length == 0)
  124. {
  125. Z.alert("请选择一个或多个子行业");
  126. return;
  127. }
  128. if (attrIdarr.length == 0)
  129. {
  130. Z.alert("请选择 一个或多个属性");
  131. return;
  132. }
  133. var ajax = new Z.Ajax();
  134. ajax.setClassName("LabelPresenter");
  135. ajax.setMethodName("doTemplateLabelRelation");
  136. ajax.addParam("mediaId", '${template.getMediaId()}');
  137. ajax.addParam("industryId", selectIndustryId);
  138. ajax.addParam("industrySubIds", Z.AR.toString(indIdarr, ","));
  139. ajax.addParam("attributeIds", Z.AR.toString(attrIdarr, ","));
  140. ajax.setFailureAlert();
  141. ajax.setSuccess(function(){
  142. Z.success("关联成功", function(){parent.location.reload();})
  143. });
  144. ajax.execute();
  145. }
  146. </script>
  147. <div class="z-w100p z-overflow-x-hidden z-overflow-y-scroll" style="height:516px" >
  148. <table class="z-table z-bordered z-pd6">
  149. <tr class="z-h40" bgcolor="${oddColor}">
  150. <td width="10%" >产品类型:</td>
  151. <td width="*"> ${DesignTypeDao.name(template.getTypeId())}</td>
  152. </tr>
  153. <tr class="z-h40" bgcolor="#FFFFFF">
  154. <td>行业:</td>
  155. <td><input name="industryId" id="industryId" class="z-input zi-bd-none zi-shadow-none z-blue z-w120 " type="text" value="${Global.get(DesignIndustryCache.class).getIndustryName(template.getIndustryId())}" readonly>&nbsp;&nbsp;<button class="z-button z-blue" onclick="doIndustrySelect();">修改行业</button></td>
  156. </tr>
  157. <tr class="z-h40" bgcolor="${oddColor}">
  158. <td>子行业:</td>
  159. <td id="subList">
  160. <#for item : inSubList>
  161. <button name="subName" id="sub_${item.getIndustrySubId()}" type="button" class="z-button z-large z-bordered z-mg-r6 z-mg-t6 z-blue-bd z-hover <#if subsList.contains(item.getIndustrySubId()+"")>z-active</#if>" onclick="doLabelIdSet('industry', '${item.getIndustrySubId()}',this)">${item.getIndustrySubName()}</button>
  162. </#for>
  163. </td>
  164. </tr>
  165. </table><br>
  166. ${zhiqim_manager_title("关联属性")}
  167. <div id ="attributeInfo">
  168. <table class="z-table z-bordered z-pd6">
  169. <#for item : attrCatList>
  170. <tr class="z-h40" bgcolor="<#if (item_index%2)==0>${oddColor}</#if>">
  171. <td width="10%">${item.getAttributeCatName()}:</td>
  172. <td width="*">
  173. <#for aitem : map.get(item.getAttributeCatId())>
  174. <button name="attrId" id="sub_${aitem.getAttributeId()}" type="button" class="z-button z-large z-mg-r6 z-mg-t6 z-bordered z-blue-bd z-hover <#if attrList.contains(aitem.getAttributeId()+"")>z-active</#if>" onclick="Z.EL.toggleClass(this, 'z-active');doLabelIdSet('attribute', '${aitem.getAttributeId()}')">${aitem.getAttributeName()}</button>
  175. </#for>
  176. </td>
  177. </tr>
  178. </#for>
  179. </table>
  180. </div>
  181. <div class="z-absolute z-w100p z-h80 z-text-center z-bg-gray" style="bottom:0;left:0">
  182. <button class="z-button ${zmr_color_class} z-w150 z-h50 z-mg-t15 z-mg-l5 z-mg-l20 zi-px22" type="button" onclick="doTemplateLabelExec();">提交</button>
  183. <button class="z-button z-w150 z-h50 z-mg-t15 z-mg-l5 z-mg-l20 zi-px22" type="button" onclick="parent.location.reload();">关闭</button>
  184. </div>
  185. </div>