webpackJsonp([15],{PHdT:function(e,t,a){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var l=a("woOf"),i=a.n(l),s=a("mtWM"),o=a.n(s),n=a("zL8q"),r={inject:["reload"],data:function(){return{addRules:{role:[{required:!0,message:"角色不可为空",trigger:"blur"},{min:1,max:20,message:"长度在 1 到 20 个字符",trigger:"blur"}],type:[{required:!0,message:"权限不可为空",trigger:"blur"}]},updateRules:{role:[{required:!0,message:"角色不可为空",trigger:"blur"},{min:1,max:20,message:"长度在 1 到 20 个字符",trigger:"blur"}],type:[{required:!0,message:"权限不可为空",trigger:"blur"}]},tableList:[],all:[],listLoading:!0,isShowAddVisible:!1,isShowUpdateVisible:!1,deleteVisible:!1,temp:{id:"",role:"",type:""},add:{role:"",type:""},update:{id:"",role:"",type:""},delete:{id:"",role:"",type:""},total:0,page:1,pageSize:5,status:[{statusId:0,label:"普通权限"},{statusId:1,label:"最高权限"}],value:"",searchName:"",filterTableDataEnd:[]}},created:function(){this.fetchData(),this.getAllData()},filters:{statusFilter:function(e){return{1:"success",2:"danger"}[e]}},methods:{search:function(){""===this.searchName?(this.filterTableDataEnd=[],this.fetchData()):this.doFilter()},fetchData:function(){var e=this;this.listLoading=!0,o.a.get("http://118.31.102.1:9200/role/getRole?pageNum="+this.page+"&pageSize="+this.pageSize).then(function(t){e.total=t.data.total;for(var a=t.data.list,l=0;l<a.length;l++)a[l].type="0"===a[l].type?"普通权限":"最高权限";e.tableList=a,e.listLoading=!1}).catch(function(t){n.Message.error(t.response.data.message),e.listLoading=!1})},getAllData:function(){var e=this;o.a.get("http://118.31.102.1:9200/role/getAllRole").then(function(t){e.all=t.data}).catch(function(e){n.Message.error(e.response.data.message)})},doFilter:function(){var e=this;this.filterTableDataEnd=[],""!==this.searchName?(this.all.forEach(function(t,a){t.id&&t.id.indexOf(e.searchName)>=0&&e.filterTableDataEnd.push(t),t.role&&t.role.indexOf(e.searchName)>=0&&e.filterTableDataEnd.push(t),t.type&&t.type.indexOf(e.searchName)>=0&&e.filterTableDataEnd.push(t)}),this.total=this.filterTableDataEnd.length,this.currentChangePage(this.filterTableDataEnd)):this.fetchData()},clickfun:function(e){console.log(e.target.innerText)},handleUpdate:function(e){this.isShowUpdateVisible=!0,this.update=i()({},e),console.log(e)},deleteUpdate:function(e){console.log(e),this.deleteVisible=!0,this.delete=i()({},e)},submitDelete:function(){var e=this;o.a.delete("http://118.31.102.1:9200/role/deleteRole?roleId="+this.delete.id).then(function(){e.deleteVisible=!1,e.$notify({title:"成功",message:"删除成功",type:"success",duration:2e3}),e.reload()}).catch(function(t){n.Message.error(t.response.data.message),e.deleteVisible=!1})},handleModifyStatus:function(e,t){this.$message({message:"操作成功",type:"success"}),console.log(e),e.status=t},addData:function(e){var t=this;this.$refs[e].validate(function(e){if(!e)return!1;o.a.post("http://118.31.102.1:9200/role/addRole",t.add).then(function(){t.isShowEditVisible=!1,t.$notify({title:"成功",message:"新增成功",type:"success",duration:2e3}),t.reload()}).catch(function(e){n.Message.error(e.response.data.message),t.deleteVisible=!1})})},updateData:function(e){var t=this;this.$refs[e].validate(function(e){if(!e)return!1;o.a.post("http://118.31.102.1:9200/role/updateRole",{id:t.update.id,role:t.update.role,type:"普通权限"===t.update.type?"0":"最高权限"===t.update.type?"1":t.update.type}).then(function(){t.isShowEditVisible=!1,t.$notify({title:"成功",message:"更新成功",type:"success",duration:2e3}),t.reload()}).catch(function(e){n.Message.error(e.response.data.message),t.deleteVisible=!1})})},handleSizeChange:function(e){this.page=e,console.log(this.page),this.fetchData()},handleCurrentChange:function(e){this.page=e,console.log(this.page),this.filterTableDataEnd.length<=0?this.fetchData():this.currentChangePage(this.filterTableDataEnd)},currentChangePage:function(e){var t=(this.page-1)*this.pageSize,a=this.page*this.pageSize;for(this.tableList=[];t<a;t++)e[t]&&this.tableList.push(e[t])}}},d={render:function(){var e=this,t=e.$createElement,a=e._self._c||t;return a("div",{staticClass:"app-container"},[a("el-col",{staticClass:"toolbar",staticStyle:{"padding-bottom":"0px"},attrs:{span:24}},[a("el-form",{attrs:{inline:!0}},[a("el-form-item",[a("el-input",{attrs:{placeholder:"ID,角色,权限",clearable:""},on:{change:e.search},model:{value:e.searchName,callback:function(t){e.searchName=t},expression:"searchName"}})],1),e._v(" "),a("el-form-item",[a("el-button",{attrs:{type:"primary"},on:{click:function(t){return e.doFilter()}}},[a("i",{staticClass:"el-icon-search"}),e._v("搜索")])],1),e._v(" "),a("el-form-item",[a("el-button",{attrs:{type:"primary"},on:{click:function(t){e.isShowAddVisible=!0}}},[e._v("新增")])],1)],1)],1),e._v(" "),a("el-table",{directives:[{name:"loading",rawName:"v-loading",value:e.listLoading,expression:"listLoading"}],staticStyle:{width:"100%"},attrs:{data:e.tableList,border:"","element-loading-text":"拼命加载中"}},[a("el-table-column",{attrs:{prop:"id",label:"ID","min-width":"200px"}}),e._v(" "),a("el-table-column",{attrs:{prop:"role",label:"角色","min-width":"150px"}}),e._v(" "),a("el-table-column",{attrs:{prop:"type","min-width":"150px",label:"权限"}}),e._v(" "),a("el-table-column",{attrs:{prop:"operation",label:"操作 "},scopedSlots:e._u([{key:"default",fn:function(t){return[a("el-button",{attrs:{size:"small",type:"primary"},on:{click:function(a){return e.handleUpdate(t.row)}}},[e._v("编辑")]),e._v(" "),a("el-button",{attrs:{size:"small",type:"danger"},on:{click:function(a){return e.deleteUpdate(t.row)}}},[e._v("删除")])]}}])})],1),e._v(" "),a("el-pagination",{staticStyle:{"text-align":"center"},attrs:{layout:"total, prev, pager, next",background:"","page-size":5,total:e.total},on:{"size-change":e.handleSizeChange,"current-change":e.handleCurrentChange}}),e._v(" "),a("el-dialog",{attrs:{title:"新增角色",visible:e.isShowAddVisible},on:{"update:visible":function(t){e.isShowAddVisible=t}}},[a("el-form",{ref:"addForm",attrs:{"label-width":"80px",model:e.add,rules:e.addRules}},[a("el-form-item",{attrs:{label:"角色",prop:"role"}},[a("el-input",{model:{value:e.add.role,callback:function(t){e.$set(e.add,"role",t)},expression:"add.role"}})],1),e._v(" "),a("el-form-item",{attrs:{label:"权限",prop:"type"},model:{value:e.add.type,callback:function(t){e.$set(e.add,"type",t)},expression:"add.type"}},[a("el-select",{attrs:{placeholder:"权限"},model:{value:e.add.type,callback:function(t){e.$set(e.add,"type",t)},expression:"add.type"}},e._l(e.status,function(e){return a("el-option",{key:e.statusId,attrs:{label:e.label,value:e.statusId}})}),1)],1)],1),e._v(" "),a("div",{staticClass:"dialog-footer",attrs:{slot:"footer"},slot:"footer"},[a("el-button",{on:{click:function(t){e.isShowAddVisible=!1}}},[e._v("取消")]),e._v(" "),a("el-button",{staticClass:"title1",attrs:{type:"primary",loading:e.listLoading},on:{click:function(t){return e.addData("addForm")}}},[e._v("确定")])],1)],1),e._v(" "),a("el-dialog",{attrs:{title:"编辑角色",visible:e.isShowUpdateVisible},on:{"update:visible":function(t){e.isShowUpdateVisible=t}}},[a("el-form",{ref:"updateForm",attrs:{"label-width":"80px",model:e.update,rules:e.updateRules}},[a("el-form-item",{attrs:{label:"ID",hidden:""}},[a("el-input",{model:{value:e.update.id,callback:function(t){e.$set(e.update,"id",t)},expression:"update.id"}})],1),e._v(" "),a("el-form-item",{attrs:{label:"角色",prop:"role"}},[a("el-input",{model:{value:e.update.role,callback:function(t){e.$set(e.update,"role",t)},expression:"update.role"}})],1),e._v(" "),a("el-form-item",{attrs:{label:"权限",prop:"type"},model:{value:e.update.type,callback:function(t){e.$set(e.update,"type",t)},expression:"update.type"}},[a("el-select",{attrs:{placeholder:"权限"},model:{value:e.update.type,callback:function(t){e.$set(e.update,"type",t)},expression:"update.type"}},e._l(e.status,function(e){return a("el-option",{key:e.statusId,attrs:{label:e.label,value:e.statusId}})}),1)],1)],1),e._v(" "),a("div",{staticClass:"dialog-footer",attrs:{slot:"footer"},slot:"footer"},[a("el-button",{on:{click:function(t){e.isShowUpdateVisible=!1}}},[e._v("取消")]),e._v(" "),a("el-button",{staticClass:"title1",attrs:{type:"primary",loading:e.listLoading},on:{click:function(t){return e.updateData("updateForm")}}},[e._v("确定")])],1)],1),e._v(" "),a("el-dialog",{attrs:{title:"删除",visible:e.deleteVisible,width:"30%"},on:{"update:visible":function(t){e.deleteVisible=t}}},[a("span",[e._v("确认删除吗")]),e._v(" "),a("span",{staticClass:"dialog-footer",attrs:{slot:"footer"},slot:"footer"},[a("el-button",{on:{click:function(t){e.deleteVisible=!1}}},[e._v("取 消")]),e._v(" "),a("el-button",{attrs:{type:"primary"},on:{click:e.submitDelete}},[e._v("确 定")])],1)])],1)},staticRenderFns:[]},u=a("VU/8")(r,d,!1,null,null,null);t.default=u.exports}});