webpackJsonp([53],{BYW8:function(t,e){},Qyza:function(t,e,a){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=a("mtWM"),i=a.n(n),r={created:function(){this.getData()},data:function(){return{dialogVisible:!1,curr:null,loading:!1,menus:[],menu:{departName:"",departCode:""}}},methods:{addRootMenu:function(){this.menu={parentId:0,departName:"",departCode:""},this.dialogVisible=!0},showAddDialog:function(t,e){this.menu={parentId:t.data.extra.id,departName:"",departCode:""},t.childNodes&&t.childNodes.length>0?this.menu.sort=t.childNodes[t.childNodes.length-1].data.extra.sort+1:this.menu.sort=1,this.dialogVisible=!0},addMenu:function(){var t=this;this.$refs.form.validate(function(e){e&&(t.loading=!0,t.$http.post({url:t.menu.id?"/departInfo/update":"/departInfo/save",data:t.menu}).then(function(e){t.loading=!1,e.success?(t.$message.success("保存成功"),t.dialogVisible=!1,t.getData()):t.$message.warning("添加失败")}))})},showEditDialog:function(t,e){this.menu={id:e.extra.id,departName:e.extra.departName,departCode:e.extra.departCode},this.dialogVisible=!0},moveUp:function(t,e){var a=this,n=function(t){var e=new FormData;for(var a in t)t.hasOwnProperty(a)&&e.append(a,t[a]);return e};t.previousSibling&&i.a.all([i.a.post(this.$baseUrl+"/departInfo/update",n({id:t.data.id,sort:t.previousSibling.data.extra.sort})),i.a.post(this.$baseUrl+"/departInfo/update",n({id:t.previousSibling.data.id,sort:t.data.extra.sort}))]).then(i.a.spread(function(t,e){a.getData()}))},moveDown:function(t,e){var a=this,n=function(t){var e=new FormData;for(var a in t)t.hasOwnProperty(a)&&e.append(a,t[a]);return e};t.nextSibling&&i.a.all([i.a.post(this.$baseUrl+"/departInfo/update",n({id:t.data.id,sort:t.nextSibling.data.extra.sort})),i.a.post(this.$baseUrl+"/departInfo/update",n({id:t.nextSibling.data.id,sort:t.data.extra.sort}))]).then(i.a.spread(function(t,e){a.getData()}))},remove:function(t,e){var a=this;this.$confirm("确定删除菜单？","提示",{confirmButtonText:"确定",cancelButtonText:"取消",type:"error"}).then(function(){a.$http.post({url:"/departInfo/del",data:{id:e.id}}).then(function(t){t.success?(a.$message.success("删除成功"),a.getData()):a.$message.error("删除失败")})}).catch(function(){})},getData:function(){var t=this;this.$http.get({url:"/departInfo/departTree"}).then(function(e){if(e.success){t.menus=function t(e){return e.sort(function(t,e){return t.extra.sort-e.extra.sort}),e.map(function(e){var a={id:e.id,label:e.name,parentId:e.parentId,extra:e.extra};return e.children instanceof Array&&(a.children=t(e.children)),a})}(e.data)}})},renderContent:function(t,e){var a=this,n=e.node,i=e.data;e.store;return t("span",{class:"custom-tree-node"},[t("span",[n.label]),t("span",{class:"url"},[i.extra.href]),t("span",{class:"opt"},[t("el-button",{attrs:{size:"mini",type:"text"},on:{click:function(){return a.moveUp(n,i)}},class:"up"},["上移"]),t("el-button",{attrs:{size:"mini",type:"text"},on:{click:function(){return a.moveDown(n,i)}}},["下移"]),t("el-button",{attrs:{size:"mini",type:"text"},on:{click:function(){return a.showEditDialog(n,i)}}},["编辑"]),t("el-button",{attrs:{size:"mini",type:"text"},on:{click:function(){return a.showAddDialog(n,i)}}},["添加"]),t("el-button",{attrs:{size:"mini",type:"text"},on:{click:function(){return a.remove(n,i)}}},["删除"])])])}}},o={render:function(){var t=this,e=t.$createElement,a=t._self._c||e;return a("div",{staticStyle:{width:"550px"}},[a("el-tree",{attrs:{data:t.menus,"render-content":t.renderContent,"highlight-current":!0,"expand-on-click-node":!1,"node-key":"id","default-expand-all":""}}),t._v(" "),a("el-button",{staticStyle:{"margin-left":"24px"},attrs:{size:"mini",type:"text"},on:{click:t.addRootMenu}},[t._v("添加")]),t._v(" "),a("el-dialog",{attrs:{visible:t.dialogVisible,title:"添加菜单"},on:{"update:visible":function(e){t.dialogVisible=e}}},[a("el-form",{ref:"form",attrs:{model:t.menu,size:"small"}},[a("el-form-item",{attrs:{label:"部门名称",prop:"departName",rules:[{required:!0,message:"请填写部门名",trigger:"blur"}]}},[a("el-input",{model:{value:t.menu.departName,callback:function(e){t.$set(t.menu,"departName",e)},expression:"menu.departName"}})],1),t._v(" "),a("el-form-item",{attrs:{label:"部门代码",prop:"departCode"}},[a("el-input",{model:{value:t.menu.departCode,callback:function(e){t.$set(t.menu,"departCode",e)},expression:"menu.departCode"}})],1)],1),t._v(" "),a("div",{attrs:{slot:"footer"},slot:"footer"},[a("el-button",{attrs:{size:"small"},on:{click:function(e){t.dialogVisible=!1}}},[t._v("取消")]),t._v(" "),a("el-button",{attrs:{type:"primary",loading:t.loading,size:"small"},on:{click:t.addMenu}},[t._v("保存")])],1)],1)],1)},staticRenderFns:[]};var s=a("VU/8")(r,o,!1,function(t){a("BYW8")},null,null);e.default=s.exports}});
//# sourceMappingURL=53.34986686ea9359a6a014.js.map