(function () { var page = { isScroll: true, init: function ($page) { var _html = '
完成
'; $page.parent().find('.f-page-backbtn').html("取消"); $page.parent().find('.f-page-header').addClass('lr-modulelistedit-header').append(_html); renlian.clientdata.get('module', { callback: function (data) { var map = {}; var TypeMap = {}; $.each(data, function (_index, _item) { map[_item.F_Id] = _item; TypeMap[_item.F_Type] = TypeMap[_item.F_Type] || []; TypeMap[_item.F_Type].push(_item); }); // 加载我的应用 renlian.myModule.get(data, function (myModules) { var $appbox = $page.find('#lr_modulelist_edit_mymodule'); var myMap = {}; $.each(myModules, function (_index, _id) { var item = map[_id]; if (item) { var _html = '\
\
\ '+ item.F_Name + '\
-
\
'; var _$html = $(_html); _$html[0].item = item; $appbox.append(_$html); myMap[_id] = "1"; } }); // 加载全部应用 var $app = $page.find('.lr-modulelist-page'); $.each(TypeMap, function (_type, _modules) { var _html = '\
\
\
\
'; $app.append(_html); var $content = $app.find('[data-app="' + _type + '"] .content'); renlian.clientdata.get('dataItem', { code: 'function', key: _type, callback: function (data, op) { $app.find('[data-app="' + op.key + '"] .title').text(data.text); } }); $.each(_modules, function (_index, _item) { var __html = '\
\
\ '+ _item.F_Name + '' + (myMap[_item.F_Id] ? '
-
' :'
+
') +'\
'; var __$html = $(__html); __$html[0].item = _item; $content.append(__$html); }); }); }); } }); $page.delegate('.appitem', 'tap', function () { var $this = $(this); var Id = $this.attr('data-value'); if ($this.hasClass('myappitem')) { $this.remove(); $page.find('[data-value="' + Id + '"] .operation').removeClass('minus').addClass('plus').text('+'); } else { if ($this.find('.operation').hasClass('minus')) {// 去掉我的应用 $this.find('.operation').removeClass('minus').addClass('plus').text('+'); $page.find('#lr_modulelist_edit_mymodule .appitem[data-value="' + Id + '"]').remove(); } else {// 添加我的应用 var len = $page.find('#lr_modulelist_edit_mymodule .appitem').length; if (len >= 11) { renlian.layer.toast('最多添加11个应用'); } else { $this.find('.operation').removeClass('plus').addClass('minus').text('-'); var _html = '
' + $this.html() + '
'; $page.find('#lr_modulelist_edit_mymodule').append(_html); } } } }); // 注册完成按钮 $page.parent().find('#lr_modulelist_finish').on('tap', function () { var list = []; $page.find('#lr_modulelist_edit_mymodule .appitem').each(function () { var id = $(this).attr('data-value'); list.push(id); }); renlian.storage.set("mymoduleData", list); renlian.httppost(config.webapi + "renlian/adms/function/mylist/update", String(list), (res) => { }); renlian.nav.closeCurrent(); }); } }; return page; })();