index_2.js 67 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310
  1. 
  2. var app = angular.module('app', [
  3. ]);
  4. app.controller("appCtrl", ["$http", "$compile", "$scope", "$timeout", function ($http, $compile, $scope, $timeout) {
  5. var self = this;
  6. var s4 = new SM4Util();
  7. self.userId = $.cookie("GlWorkPlatform-userid");
  8. self.userName = $.cookie("GlWorkPlatform-username");
  9. self.userCName = $.cookie("GlWorkPlatform-chineseName");
  10. self.get_AccessToken = localStorage.getItem("GlWorkPlatform-AccessToken");
  11. self.userTypeEng = $.cookie("GlWorkPlatform-userTypeEng");
  12. self.outToken = localStorage.getItem("main-token");
  13. var base64 = new Base64(); //声明base解码和编码类
  14. var postCfg = {
  15. headers: {
  16. 'Content-Type': 'application/json',
  17. 'Authorization': "Bearer " + self.get_AccessToken
  18. }
  19. };
  20. self.CrossPage = window.parent.CrossPage;
  21. self.loading = false;
  22. //////设置背景图片*************************************************************--zyg--20230424
  23. self.set_imgurl = "";
  24. if (apiurljs.login.indexOf("http://139.129.27.3:85") != -1) {
  25. self.set_imgurl = "http://139.129.27.3:8511/web/UploadAttach";
  26. } else {
  27. self.set_imgurl = apiurljs.login.split("glwork")[0] + "glworkweb/UploadAttach";
  28. }
  29. var get_userInfoJsonStr_1 = localStorage.getItem("GlWorkPlatform-userInfoJsonStr");
  30. self.get_userInfoJsonStr = strToJson(s4.decryptData_CBC(get_userInfoJsonStr_1))
  31. //console.log(JSON.stringify(self.get_userInfoJsonStr));
  32. //console.log(self.get_userInfoJsonStr.bkimageurl);
  33. $("body").css("background-image", "url(" + self.set_imgurl + self.get_userInfoJsonStr.bkimageurl + ")");
  34. //////设置背景图片*************************************************************--zyg--20230424
  35. ////监听框架页面发送的打开桌面设置的时机---zyg---20230426
  36. window.addEventListener('message', function (event) {
  37. //通过origin属性判断消息来源地址
  38. if (event.data.name == "openLayerSetting") {
  39. //jzsetLat(event.data.arg);
  40. var getJson = event.data.arg;
  41. self.btnSeting();
  42. }
  43. }, false);
  44. // 按顺序定义模块 的背景颜色
  45. //self.colorArray = [
  46. // ["#c23915", "#c23915", "#2e8ccc", "#be213e", "#91009b", "#94c849", "#462c02", "#b00f0f", "#547f17"],
  47. // ["#94c849", "#2e8ccc", "#91009b", "#be213e", "#c23915", "#2e8ccc", "#f09709", "#1a8fc2", "#be213e"],
  48. // ["#1f4ba0", "#b00f0f", "#d91236", "#1a8fc2", "#547f17", "#ab21a5", "#c40000", "#0057bd", "#1f53a0"]
  49. //]
  50. self.colorArray = [
  51. "#d2f4e0", "#fcdce1", "#d5e7f5", "#feedcf", "#e0f2f2", "#eae9f7", "#e5f6ff", "#fff0f0", "#f8f7c7", "#ffe4d4", "#e6fafc", "#e6fafc", "#edfad5", "#dbffd8", "#e9f4f9", "#e8e2d9", "#ffdbf1", "#f8eec7", "#d8f7f5", "#e6e2e2",
  52. "#d2f4e0", "#fcdce1", "#d5e7f5", "#feedcf", "#e0f2f2", "#eae9f7", "#e5f6ff", "#fff0f0", "#f8f7c7", "#ffe4d4", "#e6fafc", "#e6fafc", "#edfad5", "#dbffd8", "#e9f4f9", "#e8e2d9", "#ffdbf1", "#f8eec7", "#d8f7f5", "#e6e2e2",
  53. "#d2f4e0", "#fcdce1", "#d5e7f5", "#feedcf", "#e0f2f2", "#eae9f7", "#e5f6ff", "#fff0f0", "#f8f7c7", "#ffe4d4", "#e6fafc", "#e6fafc", "#edfad5", "#dbffd8", "#e9f4f9", "#e8e2d9", "#ffdbf1", "#f8eec7", "#d8f7f5", "#e6e2e2",
  54. "#d2f4e0", "#fcdce1", "#d5e7f5", "#feedcf", "#e0f2f2", "#eae9f7", "#e5f6ff", "#fff0f0", "#f8f7c7", "#ffe4d4", "#e6fafc", "#e6fafc", "#edfad5", "#dbffd8", "#e9f4f9", "#e8e2d9", "#ffdbf1", "#f8eec7", "#d8f7f5", "#e6e2e2",
  55. "#d2f4e0", "#fcdce1", "#d5e7f5", "#feedcf", "#e0f2f2", "#eae9f7", "#e5f6ff", "#fff0f0", "#f8f7c7", "#ffe4d4", "#e6fafc", "#e6fafc", "#edfad5", "#dbffd8", "#e9f4f9", "#e8e2d9", "#ffdbf1", "#f8eec7", "#d8f7f5", "#e6e2e2"
  56. ]
  57. ////打开设置弹出层
  58. self.btnSeting = function () {
  59. ////////初始化----拼接 自定义桌面-设置弹出层--左侧的初始化---zyg---start--20230505
  60. self.init_layerLeftSortArea(self.querySetArray);
  61. ////////初始化----拼接 自定义桌面-设置弹出层--左侧的初始化---zyg---end--20230505
  62. self.get_allMenu();///右侧应用功能重新加载
  63. self.getPluginData();///右侧插件,重新加载
  64. sp.layer("#layer_setting", 1);
  65. };
  66. /////左侧--清空 设置层
  67. self.leftBtnClear = function () {
  68. $("#layerLeftSortArea").html("");
  69. ///右侧菜单,全部显示--start
  70. $("#layerRight_ApplayParts").html("");
  71. var set_rhtModule_all = "";
  72. angular.forEach(self.allMenu, function (item4, index4) {
  73. item4.hasUse = false;
  74. var set_rhtModule = '<div class="main-module" data-modeuletype="0" data-pkid="' + item4.PKID + '" style="background:' + self.colorArray[index4] + '">' +
  75. //'<span class="gmt-number" ng-show="!!item.CONTENT_TOTAL" ng-bind="item.CONTENT_TOTAL || 0"></span>'+
  76. '<img src="../../js/indexTwo/img/' + item4.SRCIMG + '.png" alt="' + item4.CNAME + '">' +
  77. '<p class="sp-text-ellipsis">' + item4.CNAME + '</p>' +
  78. '<div class="logo-del" title="删除" ng-click="ctl.btnDelSingle()"><i class="fa fa-trash"></i></div>' +
  79. '</div>'
  80. //console.log(set_rhtModule);
  81. set_rhtModule_all += set_rhtModule;
  82. });
  83. //console.log(set_rhtModule_all);
  84. var append_rgh = '<div class="module-box module-box-right ui-sortable" ng-sort>' + set_rhtModule_all + '</div>';
  85. $("#layerRight_ApplayParts").append($compile(append_rgh)($scope));
  86. ///右侧菜单,全部显示--end
  87. ///右侧插件,全部显示--start
  88. $("#layerRight_PlginParts").html("");
  89. var set_rhtModule_all = "";
  90. angular.forEach(self.pluginArray, function (item4, index4) {
  91. item4.hasUse = false;
  92. var set_rhtModule = '<div class="main-module rgh-plugin-col" data-modeuletype="1" data-pgcode="' + item4.PGCODE + '" data-widthratio="' + item4.CTYPEMODEL_NAME + '">' +
  93. '<img src="' + item4.IMAGESMALL_set + '" />' +
  94. '<div class="sp-page sp-color-white" style="margin-top: -40px; background: rgba(176, 15, 15,0.6);">' + item4.CNAME + '</div>' +
  95. '<div class="sp-page" style="color: #ddd; margin-top: -20px; background: rgba(176, 15, 15,0.6); ">' + item4.CTYPEMODEL_NAME + '</div>' +
  96. '<div class="logo-del" title="删除" ng-click="ctl.btnDelSingle()"><i class="fa fa-trash"></i></div>' +
  97. '</div>';
  98. //console.log(set_rhtModule);
  99. set_rhtModule_all += set_rhtModule;
  100. });
  101. var append_rgh = '<div class="module-box module-box-right ui-sortable" ng-sort>' + set_rhtModule_all + '</div>';
  102. $("#layerRight_PlginParts").append($compile(append_rgh)($scope));
  103. ///右侧插件,全部显示--end
  104. };
  105. /////左侧添加行列按钮
  106. self.leftBtnAddCol = function (num) {
  107. if (num == 1) {
  108. var appendHtml = '<div class="row"><div class="col-sm-12 sp-pl-15 sp-pr-15 layer-col-part" data-col="col-sm-12">' +
  109. '<div class="main-title" ng-title>应用组</div>' +
  110. '<div class="module-box module-box-left ui-sortable" style="border:1px solid #ddd; min-height:222px;" ng-sort>' +
  111. '</div>' +
  112. '<div class="module-box-delete" ng-click="ctl.btnDeleteCol()"><i class="fa fa-trash"> </i> 删除</div>' +
  113. '</div></div>';
  114. $("#layerLeftSortArea").append($compile(appendHtml)($scope));
  115. } else if (num == 2) {
  116. var appendHtml = '<div class="row"><div class="col-sm-6 sp-pl-15 sp-pr-15 layer-col-part" data-col="col-sm-6">' +
  117. '<div class="main-title" ng-title>应用组</div>' +
  118. '<div class="module-box module-box-left ui-sortable" style="border:1px solid #ddd; min-height:222px;" ng-sort>' +
  119. '</div>' +
  120. '<div class="module-box-delete" ng-click="ctl.btnDeleteCol()"><i class="fa fa-trash"> </i> 删除</div>' +
  121. '</div>' +
  122. '<div class="col-sm-6 sp-pl-15 sp-pr-15 layer-col-part" data-col="col-sm-6">' +
  123. '<div class="main-title" ng-title>应用组</div>' +
  124. '<div class="module-box module-box-left ui-sortable" style="border:1px solid #ddd; min-height:222px;" ng-sort>' +
  125. '</div>' +
  126. '<div class="module-box-delete" ng-click="ctl.btnDeleteCol()"><i class="fa fa-trash"> </i> 删除</div>' +
  127. '</div></div>';
  128. $("#layerLeftSortArea").append($compile(appendHtml)($scope));
  129. } else if (num == 4) {
  130. var appendHtml = '<div class="row"><div class="col-sm-3 sp-pl-15 sp-pr-15 layer-col-part" data-col="col-sm-3">' +
  131. '<div class="main-title" ng-title>应用组</div>' +
  132. '<div class="module-box module-box-left module-box-4 ui-sortable" style="border:1px solid #ddd; min-height:222px;" ng-sort>' +
  133. '</div>' +
  134. '<div class="module-box-delete" ng-click="ctl.btnDeleteCol()"><i class="fa fa-trash"> </i> 删除</div>' +
  135. '</div>' +
  136. '<div class="col-sm-3 sp-pl-15 sp-pr-15 layer-col-part" data-col="col-sm-3">' +
  137. '<div class="main-title" ng-title>应用组</div>' +
  138. '<div class="module-box module-box-left module-box-4 ui-sortable" style="border:1px solid #ddd; min-height:222px;" ng-sort>' +
  139. '</div>' +
  140. '<div class="module-box-delete" ng-click="ctl.btnDeleteCol()"><i class="fa fa-trash"> </i> 删除</div>' +
  141. '</div>' +
  142. '<div class="col-sm-3 sp-pl-15 sp-pr-15 layer-col-part" data-col="col-sm-3">' +
  143. '<div class="main-title" ng-title>应用组</div>' +
  144. '<div class="module-box module-box-left module-box-4 ui-sortable" style="border:1px solid #ddd; min-height:222px;" ng-sort>' +
  145. '</div>' +
  146. '<div class="module-box-delete" ng-click="ctl.btnDeleteCol()"><i class="fa fa-trash"> </i> 删除</div>' +
  147. '</div>' +
  148. '<div class="col-sm-3 sp-pl-15 sp-pr-15 layer-col-part" data-col="col-sm-3">' +
  149. '<div class="main-title" ng-title>应用组</div>' +
  150. '<div class="module-box module-box-left module-box-4 ui-sortable" style="border:1px solid #ddd; min-height:222px;" ng-sort>' +
  151. '</div>' +
  152. '<div class="module-box-delete" ng-click="ctl.btnDeleteCol()"><i class="fa fa-trash"> </i> 删除</div>' +
  153. '</div></div>';
  154. $("#layerLeftSortArea").append($compile(appendHtml)($scope));
  155. } else { return; }
  156. };
  157. ////删除区域---zyg--20230506
  158. self.btnDeleteCol = function () {
  159. //console.log(event.target);
  160. //console.log($(event.target).parent().parent().find(".layer-col-part").length);
  161. //console.log($(event.target).parent().find(".module-box").find(".main-module").length);
  162. if (confirm("您确定要删除当前区域吗?")) {
  163. var get_layerColPart_length = $(event.target).parent().parent().find(".layer-col-part").length;
  164. $(event.target).parent().find(".module-box").find(".main-module").each(function () {
  165. var get_modeuletype = $(this).attr("data-modeuletype");
  166. if (get_modeuletype == "0") {
  167. var get_pkid = $(this).attr("data-pkid");
  168. //console.log(get_pkid);
  169. self.allMenu.forEach(function (item) {
  170. if (item.PKID == get_pkid) {
  171. item.hasUse = false;
  172. }
  173. });
  174. } else {
  175. var get_pgcode = $(this).attr("data-pgcode");
  176. self.pluginArray.forEach(function (item) {
  177. if (item.PGCODE == get_pgcode) {
  178. item.hasUse = false;
  179. }
  180. });
  181. }
  182. });
  183. if (get_layerColPart_length == 1) {
  184. $(event.target).parent().parent().remove();
  185. } else {
  186. $(event.target).parent().remove();
  187. }
  188. ///右侧菜单,重新显示--start
  189. $("#layerRight_ApplayParts").html("");
  190. var set_rhtModule_all = "";
  191. angular.forEach(self.allMenu, function (item4, index4) {
  192. if (!item4.hasUse) {
  193. var set_rhtModule = '<div class="main-module" data-modeuletype="0" data-pkid="' + item4.PKID + '" style="background:' + self.colorArray[index4] + '">' +
  194. //'<span class="gmt-number" ng-show="!!item.CONTENT_TOTAL" ng-bind="item.CONTENT_TOTAL || 0"></span>'+
  195. '<img src="../../js/indexTwo/img/' + item4.SRCIMG + '.png" alt="' + item4.CNAME + '">' +
  196. '<p class="sp-text-ellipsis">' + item4.CNAME + '</p>' +
  197. '<div class="logo-del" title="删除" ng-click="ctl.btnDelSingle()"><i class="fa fa-trash"></i></div>' +
  198. '</div>'
  199. //console.log(set_rhtModule);
  200. set_rhtModule_all += set_rhtModule;
  201. }
  202. });
  203. //console.log(set_rhtModule_all);
  204. var append_rgh = '<div class="module-box module-box-right ui-sortable" ng-sort>' + set_rhtModule_all + '</div>';
  205. $("#layerRight_ApplayParts").append($compile(append_rgh)($scope));
  206. ///右侧菜单,全部显示--end
  207. ///右侧插件,重新显示--start
  208. $("#layerRight_PlginParts").html("");
  209. var set_rhtModule_all = "";
  210. angular.forEach(self.pluginArray, function (item4, index4) {
  211. if (!item4.hasUse) {
  212. var set_rhtModule = '<div class="main-module rgh-plugin-col" data-modeuletype="1" data-pgcode="' + item4.PGCODE + '" data-widthratio="' + item4.CTYPEMODEL_NAME + '">' +
  213. '<img src="' + item4.IMAGESMALL_set + '" />' +
  214. '<div class="sp-page sp-color-white" style="margin-top: -40px; background: rgba(176, 15, 15,0.6);">' + item4.CNAME + '</div>' +
  215. '<div class="sp-page" style="color: #ddd; margin-top: -20px; background: rgba(176, 15, 15,0.6); ">' + item4.CTYPEMODEL_NAME + '</div>' +
  216. '<div class="logo-del" title="删除" ng-click="ctl.btnDelSingle()"><i class="fa fa-trash"></i></div>' +
  217. '</div>';
  218. //console.log(set_rhtModule);
  219. set_rhtModule_all += set_rhtModule;
  220. }
  221. });
  222. var append_rgh = '<div class="module-box module-box-right ui-sortable" ng-sort>' + set_rhtModule_all + '</div>';
  223. $("#layerRight_PlginParts").append($compile(append_rgh)($scope));
  224. ///右侧插件,重新显示--end
  225. //console.log($(obj).parent().attr("data-col"));
  226. }
  227. };
  228. ///删除单个元素
  229. self.btnDelSingle = function () {
  230. if (confirm("您确定要删除吗?")) {
  231. var parentElem = $(event.target).parent().parent();
  232. //console.log($(event.target));
  233. //console.log(parentElem);
  234. var get_modeuletype = parentElem.attr("data-modeuletype");
  235. //console.log(get_modeuletype);
  236. if (get_modeuletype == "0") {
  237. var get_pkid = parentElem.attr("data-pkid");
  238. //console.log(get_pkid);
  239. self.allMenu.forEach(function (item) {
  240. if (item.PKID == get_pkid) {
  241. item.hasUse = false;
  242. }
  243. });
  244. parentElem.remove();
  245. ///右侧菜单,重新显示--start
  246. $("#layerRight_ApplayParts").html("");
  247. var set_rhtModule_all = "";
  248. angular.forEach(self.allMenu, function (item4, index4) {
  249. if (!item4.hasUse) {
  250. var set_rhtModule = '<div class="main-module" data-modeuletype="0" data-pkid="' + item4.PKID + '" style="background:' + self.colorArray[index4] + '">' +
  251. //'<span class="gmt-number" ng-show="!!item.CONTENT_TOTAL" ng-bind="item.CONTENT_TOTAL || 0"></span>'+
  252. '<img src="../../js/indexTwo/img/' + item4.SRCIMG + '.png" alt="' + item4.CNAME + '">' +
  253. '<p class="sp-text-ellipsis">' + item4.CNAME + '</p>' +
  254. '<div class="logo-del" title="删除" ng-click="ctl.btnDelSingle()"><i class="fa fa-trash"></i></div>' +
  255. '</div>'
  256. //console.log(set_rhtModule);
  257. set_rhtModule_all += set_rhtModule;
  258. }
  259. });
  260. //console.log(set_rhtModule_all);
  261. var append_rgh = '<div class="module-box module-box-right ui-sortable" ng-sort>' + set_rhtModule_all + '</div>';
  262. $("#layerRight_ApplayParts").append($compile(append_rgh)($scope));
  263. ///右侧菜单,全部显示--end
  264. } else {
  265. var get_pgcode = parentElem.attr("data-pgcode");
  266. self.pluginArray.forEach(function (item) {
  267. if (item.PGCODE == get_pgcode) {
  268. item.hasUse = false;
  269. }
  270. });
  271. parentElem.remove();
  272. ///右侧插件,重新显示--start
  273. $("#layerRight_PlginParts").html("");
  274. var set_rhtModule_all = "";
  275. angular.forEach(self.pluginArray, function (item4, index4) {
  276. if (!item4.hasUse) {
  277. var set_rhtModule = '<div class="main-module rgh-plugin-col" data-modeuletype="1" data-pgcode="' + item4.PGCODE + '" data-widthratio="' + item4.CTYPEMODEL_NAME + '">' +
  278. '<img src="' + item4.IMAGESMALL_set + '" />' +
  279. '<div class="sp-page sp-color-white" style="margin-top: -40px; background: rgba(176, 15, 15,0.6);">' + item4.CNAME + '</div>' +
  280. '<div class="sp-page" style="color: #ddd; margin-top: -20px; background: rgba(176, 15, 15,0.6); ">' + item4.CTYPEMODEL_NAME + '</div>' +
  281. '<div class="logo-del" title="删除" ng-click="ctl.btnDelSingle()"><i class="fa fa-trash"></i></div>' +
  282. '</div>';
  283. //console.log(set_rhtModule);
  284. set_rhtModule_all += set_rhtModule;
  285. }
  286. });
  287. var append_rgh = '<div class="module-box module-box-right ui-sortable" ng-sort>' + set_rhtModule_all + '</div>';
  288. $("#layerRight_PlginParts").append($compile(append_rgh)($scope));
  289. ///右侧插件,重新显示--end
  290. }
  291. }
  292. };
  293. ////右侧--选项卡切换
  294. self.rightActiveTab = 0;
  295. self.rightBtnClick = function (num) {
  296. self.rightActiveTab = num;
  297. };
  298. // 将所有菜单的最后一代obj提取出来
  299. function extractObj(arr, toArr) {
  300. $.each(arr, function (index, item) {
  301. if (typeof item.C_H_I_L_D == "undefined" || item.C_H_I_L_D.length < 1) {
  302. toArr.push(item);
  303. return toArr;
  304. } else {
  305. return extractObj(item.C_H_I_L_D, toArr);
  306. }
  307. });
  308. }
  309. //原始数据
  310. self.rows = []; //declare an empty array
  311. // 所有菜单
  312. self.allMenu = [];
  313. self.get_allMenu = function () {
  314. self.allMenu = [];
  315. var data = {
  316. userid: self.userId
  317. };
  318. $http.post(apiurljs.login + "UserPower/PermissionsDecrypt", { data: s4.encryptData_CBC("") }, postCfg)
  319. .success(function (obj) {
  320. //var res = strToJson(s4.decryptData_CBC(obj.data));
  321. var res = obj;
  322. //console.log(JSON.stringify(res));
  323. if (sp.isval(res.data.rows)) {
  324. self.noDataTip = 1;
  325. self.rows = res.data.rows;
  326. // 所有菜单保存到 self.allMenu 中
  327. extractObj(res.data.rows, self.allMenu);
  328. angular.forEach(self.allMenu, function (item4, index4) {
  329. item4.hasUse = false;
  330. });
  331. //console.log(JSON.stringify(self.allMenu));
  332. ///将已选中的应用功能过滤掉
  333. if (sp.isval(self.querySetArray)) {
  334. var set_hasUseArray = [];
  335. angular.forEach(self.querySetArray, function (item) {
  336. angular.forEach(item.row, function (item2) {
  337. angular.forEach(item2.data, function (item3) {
  338. if (item3.moduleType == "0") {
  339. set_hasUseArray.push(item3);
  340. }
  341. });
  342. });
  343. });
  344. angular.forEach(self.allMenu, function (item4, index4) {
  345. angular.forEach(set_hasUseArray, function (item2, index2) {
  346. if (item4.PKID == item2.PKID) {
  347. //$("#layerRight_ApplayParts")
  348. item4.hasUse = true;
  349. }
  350. });
  351. });
  352. }
  353. $("#layerRight_ApplayParts").html("");
  354. var set_rhtModule_all = "";
  355. angular.forEach(self.allMenu, function (item4, index4) {
  356. if (!item4.hasUse) {
  357. var set_rhtModule = '<div class="main-module" data-modeuletype="0" data-pkid="' + item4.PKID + '" style="background:' + self.colorArray[index4] + '">' +
  358. //'<span class="gmt-number" ng-show="!!item.CONTENT_TOTAL" ng-bind="item.CONTENT_TOTAL || 0"></span>'+
  359. '<img src="../../js/indexTwo/img/' + item4.SRCIMG + '.png" alt="' + item4.CNAME + '">' +
  360. '<p class="sp-text-ellipsis">' + item4.CNAME + '</p>' +
  361. '<div class="logo-del" title="删除" ng-click="ctl.btnDelSingle()"><i class="fa fa-trash"></i></div>' +
  362. '</div>'
  363. //console.log(set_rhtModule);
  364. set_rhtModule_all += set_rhtModule;
  365. }
  366. });
  367. //console.log(set_rhtModule_all);
  368. var append_rgh = '<div class="module-box module-box-right ui-sortable" ng-sort>' + set_rhtModule_all + '</div>';
  369. $("#layerRight_ApplayParts").append($compile(append_rgh)($scope));
  370. //console.log(JSON.stringify(self.allMenu))
  371. } else {
  372. self.noDataTip = 0;
  373. }
  374. })
  375. };
  376. ////第一次进入页面,初始化数据时,获取菜单数据
  377. self.get_allMenu_init = function () {
  378. self.rows = [];
  379. self.allMenu = [];
  380. var data = {
  381. userid: self.userId
  382. };
  383. $http.post(apiurljs.login + "UserPower/PermissionsDecrypt", { data: s4.encryptData_CBC("") }, postCfg)
  384. .success(function (obj) {
  385. //var res = strToJson(s4.decryptData_CBC(obj.data));
  386. var res = obj;
  387. //console.log(JSON.stringify(res));
  388. if (sp.isval(res.data.rows)) {
  389. self.noDataTip = 1;
  390. self.rows = res.data.rows;
  391. // 所有菜单保存到 self.allMenu 中
  392. extractObj(res.data.rows, self.allMenu);
  393. angular.forEach(self.allMenu, function (item4, index4) {
  394. item4.hasUse = false;
  395. });
  396. //console.log(JSON.stringify(self.allMenu));
  397. self.querySettingByUserid();////检索自定义桌面配置数据
  398. } else {
  399. self.noDataTip = 0;
  400. }
  401. })
  402. }
  403. self.get_allMenu_init();
  404. ////检索保存的设置--zyg--20230426---检索自定义桌面配置数据
  405. self.querySetArray = [];
  406. self.querySetArray_lengthArray = [];
  407. self.querySettingByUserid = function () {
  408. self.querySetArray = [];
  409. self.querySetArray_lengthArray = [];
  410. self.loading = true;
  411. var postData = {
  412. "userid": self.userId
  413. }
  414. $http.post(apiurljs.login + "g2work/desktop/queryDataUserDefaultData", JSON.stringify(postData), postCfg)
  415. .success(function (obj) {
  416. //var res = strToJson(s4.decryptData_CBC(obj.data));
  417. var res = obj;
  418. //console.log(JSON.stringify(res));
  419. if (res.success) {
  420. if (sp.isval(res.data)) {
  421. self.querySetArray = strToJson(s4.decryptData_CBC(res.data));
  422. console.log(self.querySetArray)
  423. //console.log(JSON.stringify(self.querySetArray));
  424. for (var i = 0; i < self.querySetArray.length; i++) {
  425. self.querySetArray_lengthArray.push(i);
  426. }
  427. //console.log(JSON.stringify(self.querySetArray));
  428. //console.log(self.querySetArray.length);
  429. var set_hasUseArray = [];///声明已有菜单数组
  430. angular.forEach(self.querySetArray, function (item, index) {
  431. angular.forEach(item.row, function (item2) {
  432. angular.forEach(item2.data, function (item3) {
  433. //item3.CONTENT_TOTAL = 0;
  434. if (item3.moduleType == "1") {
  435. ///插件类型,重新赋值缩略图base64
  436. if (index <= 2) {
  437. var postData_2 = {
  438. "id": item3.ID
  439. }
  440. $http.post(apiurljs.login + "g2app/plugin/queryData", JSON.stringify(postData_2), postCfg)
  441. .success(function (obj2) {
  442. //console.log(item3.ID);
  443. //console.log(JSON.stringify(obj2.data));
  444. //console.log(obj2.data.CTYPEMODEL);
  445. item3.CTYPEMODEL = obj2.data.CTYPEMODEL;
  446. item3.IMAGESMALL = "../../" + obj2.data.IMAGEURL;
  447. //console.log(obj2.data.IMAGEURL);
  448. item3.URL = obj2.data.URL;
  449. if (item3.URL.indexOf("tpl/") != -1 || item3.URL.indexOf("tpk/") != -1) {
  450. item3.URL_set = "../../" + item3.URL;
  451. } else {
  452. item3.URL_set = item3.URL + "?token=" + self.outToken;
  453. }
  454. if (item3.CTYPEMODEL == "C01") {
  455. item3.CTYPEMODEL_NAME = "满宽适应";
  456. } else if (item3.CTYPEMODEL == "C02") {
  457. item3.CTYPEMODEL_NAME = "二分之一";
  458. } else {
  459. item3.CTYPEMODEL_NAME = "四分之一";
  460. }
  461. if (sp.isval(item3.IMAGESMALL) && item3.IMAGESMALL != "XXXXX") {
  462. item3.IMAGESMALL_set = item3.IMAGESMALL;
  463. } else {
  464. item3.IMAGESMALL_set = "image/upimg.jpg";
  465. }
  466. $timeout(function () {
  467. ///设置iframe高度
  468. self.setIframeHgt("iframe_" + item3.PGCODE);
  469. }, 500);
  470. });
  471. } else {
  472. $timeout(function () {
  473. var postData_2 = {
  474. "id": item3.ID
  475. }
  476. $http.post(apiurljs.login + "g2app/plugin/queryData", JSON.stringify(postData_2), postCfg)
  477. .success(function (obj2) {
  478. //console.log(item3.ID);
  479. //console.log(JSON.stringify(obj2.data));
  480. //console.log(obj2.data.CTYPEMODEL);
  481. item3.CTYPEMODEL = obj2.data.CTYPEMODEL;
  482. item3.IMAGESMALL = "../../" + obj2.data.IMAGEURL;
  483. //console.log(obj2.data.IMAGEURL);
  484. item3.URL = obj2.data.URL;
  485. if (item3.URL.indexOf("tpl/") != -1 || item3.URL.indexOf("tpk/") != -1) {
  486. item3.URL_set = "../../" + item3.URL;
  487. } else {
  488. item3.URL_set = item3.URL + "?token=" + self.outToken;
  489. }
  490. if (item3.CTYPEMODEL == "C01") {
  491. item3.CTYPEMODEL_NAME = "满宽适应";
  492. } else if (item3.CTYPEMODEL == "C02") {
  493. item3.CTYPEMODEL_NAME = "二分之一";
  494. } else {
  495. item3.CTYPEMODEL_NAME = "四分之一";
  496. }
  497. if (sp.isval(item3.IMAGESMALL) && item3.IMAGESMALL != "XXXXX") {
  498. item3.IMAGESMALL_set = item3.IMAGESMALL;
  499. } else {
  500. item3.IMAGESMALL_set = "image/upimg.jpg";
  501. }
  502. $timeout(function () {
  503. ///设置iframe高度
  504. self.setIframeHgt("iframe_" + item3.PGCODE);
  505. }, 3000);
  506. });
  507. },2000)
  508. }
  509. } else {
  510. ////已有菜单,重新赋值文件路径、图标
  511. angular.forEach(self.allMenu, function (item4, index4) {
  512. if (item3.PKID == item4.PKID) {
  513. item3.CNAME = item4.CNAME;
  514. item3.FILEN = item4.FILEN;
  515. item3.SRCIMG = item4.SRCIMG;
  516. item3.SRCIMG32 = item4.SRCIMG32;
  517. item3.OPENTYPE = item4.OPENTYPE;///增加打开类型字段,1为新窗口;0为框架内打开
  518. }
  519. });
  520. if (item3.FILEN.indexOf("code") > -1) {
  521. var postData_2 = {
  522. userid: self.userId,
  523. param: {
  524. lm: item3.FILEN.split("?")[1].split("&")[0].split("=")[1],
  525. readstatus: 0,
  526. }
  527. }
  528. $http.post(apiurljs.login + "g2app/filepublishing/queryReadStatusWithfpRedis", JSON.stringify(postData_2), postCfg)
  529. .success(function (obj2) {
  530. item3.COUNT = obj2.data.TOTALCOUNT;//1000;
  531. set_hasUseArray.push(item3);
  532. console.log(item3)
  533. })
  534. }
  535. }
  536. });
  537. });
  538. });
  539. angular.forEach(self.allMenu, function (item4, index4) {
  540. angular.forEach(set_hasUseArray, function (item2, index2) {
  541. if (item4.PKID == item2.PKID) {
  542. //$("#layerRight_ApplayParts")
  543. item4.hasUse = true;
  544. }
  545. });
  546. });
  547. $("#layerRight_ApplayParts").html("");
  548. var set_rhtModule_all = "";
  549. angular.forEach(self.allMenu, function (item4, index4) {
  550. if (!item4.hasUse) {
  551. var set_rhtModule = '<div class="main-module" data-modeuletype="0" data-pkid="' + item4.PKID + '" style="background:' + self.colorArray[index4] + '">' +
  552. //'<span class="gmt-number" ng-show="!!item.CONTENT_TOTAL" ng-bind="item.CONTENT_TOTAL || 0"></span>'+
  553. '<img src="../../js/indexTwo/img/' + item4.SRCIMG + '.png" alt="' + item4.CNAME + '">' +
  554. '<p class="sp-text-ellipsis">' + item4.CNAME + '</p>' +
  555. '<div class="logo-del" title="删除" ng-click="ctl.btnDelSingle()"><i class="fa fa-trash"></i></div>' +
  556. '</div>'
  557. //console.log(set_rhtModule);
  558. set_rhtModule_all += set_rhtModule;
  559. }
  560. });
  561. //console.log(set_rhtModule_all);
  562. var append_rgh = '<div class="module-box module-box-right ui-sortable" ng-sort>' + set_rhtModule_all + '</div>';
  563. $("#layerRight_ApplayParts").append($compile(append_rgh)($scope));
  564. $timeout(function () {
  565. self.loading = false;
  566. }, 3000);
  567. self.getPluginData();///加载插件列表
  568. } else {
  569. self.querySetArray = [];
  570. self.loading = false;
  571. self.getPluginData();///加载插件列表
  572. }
  573. } else {
  574. self.querySetArray = [];
  575. self.loading = false;
  576. sp.dialog(res.message);
  577. self.getPluginData();///加载插件列表
  578. }
  579. });
  580. };
  581. ////设置iframe自适应子页面高度
  582. self.setIframeHgt = function (idstr) {
  583. //console.log(idstr);
  584. var Iframe = document.getElementById(idstr);
  585. try {
  586. // 声明变量取值
  587. var bHeight = Iframe.contentWindow.document.body.scrollHeight;
  588. var dHeight = Iframe.contentWindow.document.documentElement.scrollHeight;
  589. //if (idstr == "iframe_PGCOMP20") {
  590. // console.log(bHeight);
  591. // console.log(dHeight);
  592. //}
  593. var height = Math.max(bHeight, dHeight); // 取最大值
  594. Iframe.height = height;
  595. } catch (ex) {
  596. if (ex.stack.indexOf(" from accessing a cross-origin frame") != -1) {
  597. Iframe.height = 300;
  598. }
  599. }
  600. $timeout(function () {
  601. self.setIframeHgt(idstr);
  602. },3000);
  603. };
  604. ////////初始化----拼接 自定义桌面-设置弹出层--左侧的初始化---zyg---start--20230505
  605. self.init_layerLeftSortArea = function (arrayData) {
  606. $("#layerLeftSortArea").html("");
  607. var set_row_all = "";
  608. angular.forEach(arrayData, function (item1, index1) {
  609. var set_layerColPart_all = "";
  610. angular.forEach(item1.row, function (item2, index2) {
  611. var set_mainModule_all = "";
  612. angular.forEach(item2.data, function (item3, index3) {
  613. if (item3.moduleType == 0) {
  614. var set_bgcolror = self.colorArray[index3];
  615. var set_mainModule = '<div class="main-module" style="background:' + set_bgcolror + '" data-pkid="' + item3.PKID + '" data-modeuletype="0">' +
  616. //'<span class="gmt-number" ng-show="!!item3.CONTENT_TOTAL" ng-bind="item3.CONTENT_TOTAL || 0"></span>'+
  617. '<img src="../../js/indexTwo/img/' + item3.SRCIMG + '.png" alt="' + item3.SRCIMG + '">' +
  618. '<p class="sp-text-ellipsis">' + item3.CNAME + '</p>' +
  619. '<div class="logo-del" title="删除" ng-click="ctl.btnDelSingle()"><i class="fa fa-trash"></i></div>' +
  620. '</div>';
  621. set_mainModule_all += set_mainModule;
  622. //console.log(set_mainModule);
  623. } else {
  624. if (item3.URL.indexOf("tpl/") != -1 || item3.URL.indexOf("tpk/") != -1) {
  625. item3.URL_set = "../../" + item3.URL;
  626. } else {
  627. item3.URL_set = item3.URL + "?token=" + self.outToken;
  628. }
  629. if (item3.CTYPEMODEL == "C01") {
  630. item3.CTYPEMODEL_NAME = "满宽适应";
  631. } else if (item3.CTYPEMODEL == "C02") {
  632. item3.CTYPEMODEL_NAME = "二分之一";
  633. } else {
  634. item3.CTYPEMODEL_NAME = "四分之一";
  635. }
  636. if (sp.isval(item3.IMAGESMALL) && item3.IMAGESMALL != "XXXXX") {
  637. item3.IMAGESMALL_set = item3.IMAGESMALL;
  638. } else {
  639. item3.IMAGESMALL_set = "image/upimg.jpg";
  640. }
  641. //console.log(item3.IMAGESMALL_set);
  642. var set_mainModule = '<div class="main-module rgh-plugin-col" data-modeuletype="1" data-pgcode="' + item3.PGCODE + '" data-widthratio="' + item3.CTYPEMODEL_NAME + '">' +
  643. '<img src="' + item3.IMAGESMALL_set + '" />' +
  644. '<div class="sp-page sp-color-white" style="margin-top: -40px; background: rgba(176, 15, 15,0.6);">' + item3.CNAME + '</div>' +
  645. '<div class="sp-page" style="color: #ddd; margin-top: -20px; background: rgba(176, 15, 15,0.6); ">' + item3.CTYPEMODEL_NAME + '</div>' +
  646. '<div class="logo-del" title="删除" ng-click="ctl.btnDelSingle()"><i class="fa fa-trash"></i></div>' +
  647. '</div>';
  648. set_mainModule_all += set_mainModule;
  649. }
  650. });
  651. var set_class = item2.colClass;
  652. var set_layerColPart = '<div class="sp-pl-15 sp-pr-15 layer-col-part ' + set_class + '" data-col="' + set_class + '">' +
  653. '<div class="main-title" ng-title >' + item2.colName + '</div>' +
  654. '<div class="module-box module-box-left ui-sortable" style="border:1px solid #ddd; min-height:222px;" ng-sort>' +
  655. '' + set_mainModule_all + '' +
  656. '</div>' +
  657. '<div class="module-box-delete" ng-click="ctl.btnDeleteCol()"><i class="fa fa-trash"> </i> 删除</div>' +
  658. '</div>';
  659. //console.log(set_layerColPart);
  660. set_layerColPart_all += set_layerColPart;
  661. });
  662. var set_row = '<div class="row">' + set_layerColPart_all + '</div>';
  663. //console.log(set_row);
  664. set_row_all += set_row;
  665. });
  666. $("#layerLeftSortArea").append($compile(set_row_all)($scope));
  667. }
  668. ////////初始化----拼接 自定义桌面-设置弹出层--左侧的初始化---zyg---end--20230505
  669. ////加载插件列表*****************************************************************************************
  670. self.pluginArray_all = [];///全部
  671. self.pluginArray = [];///经过过滤
  672. self.getPluginData = function () {
  673. self.pluginArray_all = [];///全部
  674. self.pluginArray = [];///经过过滤
  675. var postData = {
  676. "dtype": "",
  677. "kinds": "",
  678. "imagemark": false
  679. };
  680. ///为了演示
  681. $http.post(apiurljs.login + "g2app/plugin/queryDataListWithCtypemodel", { data: s4.encryptData_CBC(JSON.stringify(postData)) }, postCfg)
  682. .success(function (obj) {
  683. //var res = strToJson(s4.decryptData_CBC(obj.data));
  684. var res = obj.data;
  685. if (sp.isval(res)) {
  686. if (sp.isval(res["满宽适应"])) {
  687. angular.forEach(res["满宽适应"], function (item) {
  688. item.CTYPEMODEL_NAME = "满宽适应";
  689. self.pluginArray.push(item);
  690. });
  691. }
  692. if (sp.isval(res["二分之一"])) {
  693. angular.forEach(res["二分之一"], function (item) {
  694. item.CTYPEMODEL_NAME = "二分之一";
  695. self.pluginArray.push(item);
  696. });
  697. }
  698. if (sp.isval(res["四分之一"])) {
  699. angular.forEach(res["四分之一"], function (item) {
  700. item.CTYPEMODEL_NAME = "四分之一";
  701. self.pluginArray.push(item);
  702. });
  703. }
  704. angular.forEach(self.pluginArray, function (item, index) {
  705. item.indexnum = index;
  706. item.hasUse = false;
  707. if (sp.isval(item.IMAGESMALL) && item.IMAGESMALL != "XXXXX") {
  708. item.IMAGESMALL_set = item.IMAGESMALL;
  709. } else {
  710. item.IMAGESMALL_set = "image/upimg.jpg";
  711. }
  712. });
  713. self.pluginArray_all = self.pluginArray;///全部
  714. ///将已选中的插件过滤掉
  715. if (sp.isval(self.querySetArray)) {
  716. var set_hasUseArray = [];
  717. angular.forEach(self.querySetArray, function (item) {
  718. angular.forEach(item.row, function (item2) {
  719. angular.forEach(item2.data, function (item3) {
  720. if (item3.moduleType == "1") {
  721. set_hasUseArray.push(item3);
  722. }
  723. });
  724. });
  725. });
  726. angular.forEach(self.pluginArray, function (item4, index4) {
  727. angular.forEach(set_hasUseArray, function (item2, index2) {
  728. if (item4.PGCODE == item2.PGCODE) {
  729. //$("#layerRight_ApplayParts")
  730. item4.hasUse = true;
  731. }
  732. });
  733. });
  734. }
  735. //console.log(JSON.stringify(self.pluginArray));
  736. $("#layerRight_PlginParts").html("");
  737. var set_rhtModule_all = "";
  738. angular.forEach(self.pluginArray, function (item4, index4) {
  739. if (!item4.hasUse) {
  740. var set_rhtModule = '<div class="main-module rgh-plugin-col" data-modeuletype="1" data-pgcode="' + item4.PGCODE + '" data-widthratio="' + item4.CTYPEMODEL_NAME + '">' +
  741. '<img src="' + item4.IMAGESMALL_set + '" />' +
  742. '<div class="sp-page sp-color-white" style="margin-top: -40px; background: rgba(176, 15, 15,0.6);">' + item4.CNAME + '</div>' +
  743. '<div class="sp-page" style="color: #ddd; margin-top: -20px; background: rgba(176, 15, 15,0.6); ">' + item4.CTYPEMODEL_NAME + '</div>' +
  744. '<div class="logo-del" title="删除" ng-click="ctl.btnDelSingle()"><i class="fa fa-trash"></i></div>' +
  745. '</div>';
  746. //console.log(set_rhtModule);
  747. set_rhtModule_all += set_rhtModule;
  748. }
  749. });
  750. var append_rgh = '<div class="module-box module-box-right ui-sortable" ng-sort>' + set_rhtModule_all + '</div>';
  751. $("#layerRight_PlginParts").append($compile(append_rgh)($scope));
  752. //$scope.$apply(self.pluginArray);
  753. } else {
  754. self.pluginArray = [];
  755. }
  756. });
  757. };
  758. ////保存设置---
  759. self.btnSaveSetting_title = "保 存";
  760. self.btnSaveSetting = function () {
  761. if ($("#layerLeftSortArea").find(".row").length > 0) {
  762. self.btnSaveSetting_title = "请稍等,正在保存中..";
  763. var row_array = [];
  764. $("#layerLeftSortArea").find(".row").each(function () {
  765. var total_json = [];
  766. $(this).find(".layer-col-part").each(function () {
  767. var colClass = $(this).attr("data-col");
  768. var colName = $(this).find(".main-title").text();
  769. var set_data_json = [];
  770. $(this).find(".main-module").each(function () {
  771. var get_modeuletype = $(this).attr("data-modeuletype");
  772. //console.log(get_modeuletype);
  773. if (get_modeuletype == "0") {
  774. var get_pkid = $(this).attr("data-pkid");
  775. angular.forEach(self.allMenu, function (item2) {
  776. if (item2.PKID == get_pkid) {
  777. var boxjson = {
  778. "moduleType": get_modeuletype,
  779. "PKID": get_pkid,
  780. "CNAME": item2.CNAME,
  781. "FILEN": item2.FILEN,
  782. "SRCIMG": item2.SRCIMG,
  783. "SRCIMG32": item2.SRCIMG32
  784. }
  785. set_data_json.push(boxjson);
  786. }
  787. })
  788. } else {
  789. var get_pgcode = $(this).attr("data-pgcode");
  790. angular.forEach(self.pluginArray_all, function (item2) {
  791. //console.log(item2.PGCODE);
  792. if (item2.PGCODE == get_pgcode) {
  793. var boxjson = {
  794. "ID":item2.ID,
  795. "moduleType": get_modeuletype,
  796. "CTYPEMODEL": item2.CTYPEMODEL,
  797. "CNAME": item2.CNAME,
  798. "IMAGESMALL": "",
  799. "URL": item2.URL,
  800. "PGCODE": item2.PGCODE
  801. }
  802. set_data_json.push(boxjson);
  803. }
  804. })
  805. }
  806. })
  807. //console.log(JSON.stringify(set_data_json));
  808. var set_part_json = {
  809. "colClass": colClass,
  810. "colName": colName,
  811. "data": set_data_json
  812. }
  813. total_json.push(set_part_json);
  814. });
  815. var set_total_json = {
  816. "row": total_json
  817. }
  818. row_array.push(set_total_json);
  819. });
  820. //console.log(JSON.stringify(row_array));
  821. $timeout(function () {
  822. var postData = {
  823. "userid": self.userId,
  824. "data": s4.encryptData_CBC(JSON.stringify(row_array))
  825. }
  826. ///console.log(JSON.stringify(postData));
  827. $http.post(apiurljs.login + "g2work/desktop/saveDataUserDefaultData", JSON.stringify(postData), postCfg)
  828. .success(function (obj) {
  829. //var res = strToJson(s4.decryptData_CBC(obj.data));
  830. ///{"message":"数据检索成功。","code":0,"data":1,"success":true}
  831. //console.log(JSON.stringify(obj));
  832. var res = obj;
  833. if (res.success) {
  834. self.querySettingByUserid();
  835. sp.closeCenter("#layer_setting");
  836. } else {
  837. alert(res.message);
  838. }
  839. self.btnSaveSetting_title = "保 存";
  840. });
  841. }, 100);
  842. } else {
  843. alert("您好,布局不能为空!");
  844. }
  845. };
  846. ////关闭设置
  847. self.btnCloseSetting = function () {
  848. self.btnSaveSetting_title = "保 存";
  849. sp.closeCenter("#layer_setting");
  850. };
  851. ////
  852. self.btnClickPkModule = function (itemdata) {
  853. //console.log(itemdata);
  854. //alert(itemdata.OPENTYPE);
  855. if (itemdata.FILEN == "") {
  856. sp.dialog("功能开发中!");
  857. return
  858. }
  859. if (itemdata.FILEN.indexOf("@token") > -1) {
  860. ///判断moduleType字段,当其为1时打开新窗口;0时在框架内打开
  861. if (itemdata.OPENTYPE == "1") {
  862. window.open("../../" + itemdata.FILEN.replace("@token", self.outToken));
  863. } else {
  864. window.parent.sp.addTabNav(itemdata.PKID, itemdata.CNAME, itemdata.FILEN.replace("@token", self.outToken));
  865. }
  866. } else {
  867. ///判断moduleType字段,当其为1时打开新窗口;0时在框架内打开
  868. if (itemdata.OPENTYPE == "1") {
  869. window.open("../../"+itemdata.FILEN);
  870. } else {
  871. window.parent.sp.addTabNav(itemdata.PKID, itemdata.CNAME, itemdata.FILEN);
  872. }
  873. }
  874. };
  875. ////恢复缺省设置
  876. self.leftBtnRestoreInit = function () {
  877. if (confirm("您确定要恢复缺省设置吗?")) {
  878. var postData = {
  879. "userid": self.userId
  880. }
  881. $http.post(apiurljs.login + "g2work/desktop/createDataUserDefaultData", JSON.stringify(postData), postCfg)
  882. .success(function (obj) {
  883. var res = obj;
  884. //console.log(JSON.stringify(obj))
  885. if (res.success) {
  886. var defaultData = strToJson(s4.decryptData_CBC(res.data));
  887. //console.log(JSON.stringify(defaultData));
  888. ///////
  889. var set_hasUseArray = [];
  890. angular.forEach(defaultData, function (item) {
  891. angular.forEach(item.row, function (item2) {
  892. angular.forEach(item2.data, function (item3) {
  893. set_hasUseArray.push(item3);
  894. if (item3.moduleType == "1") {
  895. var postData_2 = {
  896. "id": item3.ID
  897. }
  898. $http.post(apiurljs.login + "g2app/plugin/queryData", JSON.stringify(postData_2), postCfg)
  899. .success(function (obj2) {
  900. item3.IMAGESMALL = "../../" + obj2.data.IMAGEURL;
  901. if (sp.isval(item3.IMAGESMALL) && item3.IMAGESMALL != "XXXXX") {
  902. item3.IMAGESMALL_set = item3.IMAGESMALL;
  903. } else {
  904. item3.IMAGESMALL_set = "image/upimg.jpg";
  905. }
  906. });
  907. }
  908. });
  909. });
  910. });
  911. $timeout(function () {
  912. ////////初始化----拼接 自定义桌面-设置弹出层--左侧的初始化---zyg---start--20230505
  913. self.init_layerLeftSortArea(defaultData);
  914. }, 1000);
  915. ///右侧--应用功能---start
  916. angular.forEach(self.allMenu, function (item4, index4) {
  917. item4.hasUse = false;
  918. angular.forEach(set_hasUseArray, function (item2, index2) {
  919. if (item4.PKID == item2.PKID) {
  920. //$("#layerRight_ApplayParts")
  921. item4.hasUse = true;
  922. }
  923. });
  924. });
  925. $("#layerRight_ApplayParts").html("");
  926. var set_rhtModule_all = "";
  927. angular.forEach(self.allMenu, function (item4, index4) {
  928. if (!item4.hasUse) {
  929. var set_rhtModule = '<div class="main-module" data-modeuletype="0" data-pkid="' + item4.PKID + '" style="background:' + self.colorArray[index4] + '">' +
  930. //'<span class="gmt-number" ng-show="!!item.CONTENT_TOTAL" ng-bind="item.CONTENT_TOTAL || 0"></span>'+
  931. '<img src="../../js/indexTwo/img/' + item4.SRCIMG + '.png" alt="' + item4.CNAME + '">' +
  932. '<p class="sp-text-ellipsis">' + item4.CNAME + '</p>' +
  933. '<div class="logo-del" title="删除" ng-click="ctl.btnDelSingle()"><i class="fa fa-trash"></i></div>' +
  934. '</div>'
  935. //console.log(set_rhtModule);
  936. set_rhtModule_all += set_rhtModule;
  937. }
  938. });
  939. //console.log(set_rhtModule_all);
  940. var append_rgh = '<div class="module-box module-box-right ui-sortable" ng-sort>' + set_rhtModule_all + '</div>';
  941. $("#layerRight_ApplayParts").append($compile(append_rgh)($scope));
  942. ///右侧--应用功能---end
  943. ///右侧--插件--start--zyg
  944. angular.forEach(self.pluginArray, function (item4, index4) {
  945. item4.hasUse = false;
  946. angular.forEach(set_hasUseArray, function (item2, index2) {
  947. if (item4.PGCODE == item2.PGCODE) {
  948. //$("#layerRight_ApplayParts")
  949. item4.hasUse = true;
  950. }
  951. });
  952. });
  953. $("#layerRight_PlginParts").html("");
  954. var set_rhtModule_all = "";
  955. angular.forEach(self.pluginArray, function (item4, index4) {
  956. if (!item4.hasUse) {
  957. var set_rhtModule = '<div class="main-module rgh-plugin-col" data-modeuletype="1" data-pgcode="' + item4.PGCODE + '" data-widthratio="' + item4.CTYPEMODEL_NAME + '">' +
  958. '<img src="' + item4.IMAGESMALL_set + '" />' +
  959. '<div class="sp-page sp-color-white" style="margin-top: -40px; background: rgba(176, 15, 15,0.6);">' + item4.CNAME + '</div>' +
  960. '<div class="sp-page" style="color: #ddd; margin-top: -20px; background: rgba(176, 15, 15,0.6); ">' + item4.CTYPEMODEL_NAME + '</div>' +
  961. '<div class="logo-del" title="删除" ng-click="ctl.btnDelSingle()"><i class="fa fa-trash"></i></div>' +
  962. '</div>';
  963. //console.log(set_rhtModule);
  964. set_rhtModule_all += set_rhtModule;
  965. }
  966. });
  967. var append_rgh = '<div class="module-box module-box-right ui-sortable" ng-sort>' + set_rhtModule_all + '</div>';
  968. $("#layerRight_PlginParts").append($compile(append_rgh)($scope));
  969. ///右侧--插件--end--zyg
  970. }
  971. });
  972. }
  973. }
  974. }]);
  975. ///拖拽范围
  976. app.directive('ngSort', function () {
  977. return {
  978. link: function (scope, element, attrs) {
  979. $(element).sortable({
  980. containment: ".sp-layer2-body", //约束排序动作只能在一个指定的范围内发生。
  981. connectWith: ".module-box",////允许sortable对象连接另一个sortable对象,可将item元素拖拽到另一个中
  982. cursor: "move",
  983. placeholder: 'ui-sort-placeholder',
  984. beforeStop: function (event, ui) {
  985. //console.log(ui);
  986. //console.log(ui.item);
  987. ///这是当前拖放子元素
  988. var get_ui_modeuletype = ui.item.context.dataset.modeuletype;
  989. ///这是当前拖放子元素
  990. var get_ui_item_parent = $(ui.item).parent();
  991. var get_classCol = get_ui_item_parent.parent().attr("data-col");
  992. //console.log(get_classCol);
  993. if (get_ui_modeuletype == 0) {
  994. ///判断应用功能属性
  995. var set_siblingModuleType = -1;
  996. get_ui_item_parent.find(".main-module").each(function () {
  997. if ($(this).attr('data-modeuletype') == 1) {
  998. set_siblingModuleType = 1;
  999. }
  1000. });
  1001. if (set_siblingModuleType == 1) {
  1002. alert("您好,应用功能、桌面插件,不能占用同一个区域");
  1003. return false;
  1004. }
  1005. ////判断 区域和 插件、功能对应关系--20230502--zyg--srart
  1006. if (get_classCol == "col-sm-12") {
  1007. alert('你好,“应用功能”只能拖放在“二分之一”区域中');
  1008. return false;
  1009. }
  1010. if (get_classCol == "col-sm-3") {
  1011. alert('你好,“应用功能”只能拖放在“二分之一”区域中');
  1012. return false;
  1013. }
  1014. ////判断 区域和 插件、功能对应关系--20230502--zyg--end
  1015. }
  1016. if (get_ui_modeuletype == 1) {
  1017. ///判断桌面插件属性
  1018. var set_siblingModuleType = -1;
  1019. get_ui_item_parent.find(".main-module").each(function () {
  1020. if ($(this).attr('data-modeuletype') == 0) {
  1021. set_siblingModuleType = 0;
  1022. }
  1023. });
  1024. if (set_siblingModuleType == 0) {
  1025. alert("您好,桌面插件、应用功能,不能占用同一个区域");
  1026. return false;
  1027. }
  1028. ////判断 区域和 插件、功能对应关系--20230502--zyg--srart
  1029. var get_widthratio = ui.item.context.dataset.widthratio;
  1030. //console.log(get_widthratio);
  1031. if (get_widthratio == "满宽适应") {
  1032. if (get_classCol != "col-sm-12") {
  1033. alert('你好,“桌面插件-满宽适应”只能拖放在“满宽适应”区域中');
  1034. return false;
  1035. }
  1036. }
  1037. if (get_widthratio == "二分之一") {
  1038. if (get_classCol != "col-sm-6") {
  1039. alert('你好,“桌面插件-二分之一”只能拖放在“二分之一”区域中');
  1040. return false;
  1041. }
  1042. }
  1043. if (get_widthratio == "四分之一") {
  1044. if (get_classCol != "col-sm-3") {
  1045. alert('你好,“桌面插件-四分之一”只能拖放在“四分之一”区域中');
  1046. return false;
  1047. }
  1048. }
  1049. ////判断 区域和 插件、功能对应关系--20230502--zyg--end
  1050. }
  1051. //console.log(scope.ctl.allMenu);
  1052. scope.ctl.allMenu.forEach(function (item) {
  1053. item.hasUse = false;
  1054. });
  1055. scope.ctl.pluginArray.forEach(function (item) {
  1056. item.hasUse = false;
  1057. });
  1058. $("#layerLeftSortArea").find(".main-module").each(function () {
  1059. if ($(this).attr("data-modeuletype") == "0") {
  1060. var get_pkid = $(this).attr("data-pkid");
  1061. //console.log(get_pkid);
  1062. scope.ctl.allMenu.forEach(function (item) {
  1063. if (item.PKID == get_pkid) {
  1064. item.hasUse = true;
  1065. }
  1066. });
  1067. } else {
  1068. var get_pgcode = $(this).attr("data-pgcode");
  1069. //console.log(get_pkid);
  1070. scope.ctl.pluginArray.forEach(function (item) {
  1071. if (item.PGCODE == get_pgcode) {
  1072. item.hasUse = true;
  1073. }
  1074. });
  1075. }
  1076. });
  1077. scope.$apply();
  1078. //console.log(JSON.stringify(scope.ctl.allMenu));
  1079. //console.log(JSON.stringify(scope.ctl.pluginArray));
  1080. }
  1081. }).disableSelection(); //禁用选择拖拽目标里的内容
  1082. }
  1083. }
  1084. })
  1085. // 点击编辑标题 ng-title
  1086. app.directive('ngTitle', function () {
  1087. return {
  1088. link: function (scope, element, attrs) {
  1089. $(element).click(function () {
  1090. if ($(element).children('input').length != 0) {
  1091. return false;
  1092. }
  1093. var str = $(element).html();
  1094. str = '<input type="text" value="' + str + '">';
  1095. $(element).html(str);
  1096. $(element).children('input').select();
  1097. var input = $(element).children('input');
  1098. var submit = function () {
  1099. var val = $(element).children('input').val();
  1100. $(element).html(val);
  1101. }
  1102. input.blur(submit).keydown(function (event) {
  1103. if (event.keyCode == 13) {
  1104. submit();
  1105. }
  1106. });
  1107. });
  1108. }
  1109. }
  1110. });
  1111. app.filter('trustAsResourceUrl', ['$sce', function ($sce) {
  1112. return function (val) {
  1113. return $sce.trustAsResourceUrl(val);
  1114. };
  1115. }])