createMenuList.js 4.3 KB

1
  1. var validForm,resourceFormVm=new Vue({el:"#resourceForm",data:function(){return{msConfig:{},entity:{id:getQueryString("id"),genTable:{id:getQueryString("genTable.id")},appId:"1",parentResName:"",resName:"",resType:"",menuOrder:"",menuIcon:"",visiable:"",useTag:"",permission:"",target:"",resCode:"",menuType:""},pageDictMap:{},showList:[],resource:{}}},computed:{resTypeDict:function(){return this.pageDictMap.res_type},visiableDict:function(){return this.pageDictMap.y_n},useTagDict:function(){return this.pageDictMap.y_n},resCodeDict:function(){return this.pageDictMap.res_code},menuTypeDict:function(){return this.pageDictMap.menu_type},urlPrefix:function(){return this.msConfig.gatewayRoute+this.msConfig.direwolfAdmin+"/genScheme"},saveUrl:function(){return WEB_ROOT+"/sys/resource/save"},resourceTreeUrl:function(){return WEB_ROOT+"/sys/resource/selectResourceTree?appId=1"}},methods:{getShowList:function(){var t=this,n="获取样式列表";axios.get(t.urlPrefix+"/getShowList?genTable.id="+t.entity.genTable.id).then(function(e){t.showList=getDataFromAxiosResponse(e,n)}).catch(function(e){axiosErrorTips(e,n+"异常")})},getResource:function(){var t=this,n="获取样式列表";axios.get(t.urlPrefix+"/getMenuData?genTable.id="+t.entity.genTable.id).then(function(e){t.resource=getDataFromAxiosResponse(e,n)}).catch(function(e){axiosErrorTips(e,n+"异常")})},handleResTypeChange:function(e){"1"!==e&&(this.entity.menuType="")},initFormData:function(){var n=this,i="获取信息";axios.get(n.urlPrefix+"/getRecord?genTable.id="+n.entity.genTable.id).then(function(e){var t=getDataFromAxiosResponse(e,i);t.id&&(n.entity=t,n.$nextTick(function(){schemeFormReload(t.category,t.style),toggleRelationHidden()}))}).catch(function(e){axiosErrorTips(e,i+"异常")})}},created:function(){var t=this;t.msConfig=window.__CODEGEN_CONFIG__,checkPagePermission(t.urlPrefix+"/checkCreateMenuPermission"),t.getShowList(),t.getResource();var n="获取字典信息";axios.get(dictUrl+"res_type,y_n,res_code,menu_type").then(function(e){t.pageDictMap=getDataFromAxiosResponse(e,n).data,initDict()}).catch(function(e){axiosErrorTips(e,n+"异常")})},mounted:function(){var e,a=this;"1"===$("#parentId").val()?((e=$("#resType")).val("3"),e.attr("disabled",!0)):$("#resType option[value='3']").remove(),$(".select_chosen").select2(),$("#selectMenu").click(function(){top.layer.open({type:2,title:"选择图标",area:["700px","600px"],content:"/common-assets/pages/iconSelect.html",btn:["确定","关闭"],yes:function(e,t){var n=t.find("iframe")[0].contentWindow.$("#icon").val();$("#menu-icon").attr("class","fa "+n),$("#menu-label").text(n),$("#menu-value").val(n),top.layer.close(e)},cancel:function(e){setTimeout(function(){top.layer.close(e)},100)}})}),$("#clearMenu").click(function(){$("#menu-icon").attr("class","icon- hide"),$("#menu-label").text("无"),$("#menu-value").val("")}),$("#schemeSelection").change(function(e){var t,n=$(e.currentTarget).val(),i=commonConfig.proxyPath+a.urlPrefix+"/refreshMenuForm?id="+n+"&random="+new Date,r=$.parseJSON($.ajax({url:i,type:"get",async:!1}).responseText);null!=r&&void 0!==r.type&&"success"===r.type?void 0!==r.data.resource?(t=r.data.resource,$("#resName").val(t.resName),$("#permission").val(t.permission),$("#target").val(t.target),$("#parentResName").val(""),$("#parentId").val("")):toastr.error("获取菜单数据失败!"):toastr.error(r.message||"重新菜单内容失败!")}),validForm=$("#resourceForm").validate({rules:{target:{checkTarget:!0}},errorPlacement:function(e,t){t.is(":checkbox")||t.is(":radio")||t.parent().is(".input-append")?e.insertAfter(t.parent()):e.insertAfter(t)}})}});function initDict(){$.ajax({url:WEB_ROOT+"/sys/app/selectAppTree?time="+new Date,type:"get",async:!1,success:function(e){$.each(e,function(e,t){1===t.id?$("#selectAppId").append($('<option selected = "selected" value="'+t.id+'">'+t.name+"</option>")):$("#selectAppId").append($('<option value="'+t.id+'">'+t.name+"</option>"))})}})}function doSubmit(e){if(!validForm.form())return!1;$("input[type=checkbox]").each(function(){$(this).prop("checked")?$(this).attr("value","1"):$(this).after('<input type="hidden" name="'+$(this).attr("name")+"\" value='0'>")}),formAjaxSubmit($("#resourceForm"),e)}$.validator.addMethod("checkTarget",function(e,t,n){return!(!$.isEmptyObject(e)&&"1"===resourceFormVm.entity.resType&&"03"===resourceFormVm.entity.menuType&&!e.startsWith("http"))},"资源地址不正确");