webpackJsonp([56],{hMVY:function(e,i,o){"use strict";Object.defineProperty(i,"__esModule",{value:!0});var n=o("Dd8w"),t=o.n(n),r=o("vLgD");var s={name:"regionalManagement",mounted:function(){this.checkPermission(["region:edit"])&&this.btns.push({text:"编辑",onClick:this.handleEdit}),this.checkPermission(["region:delete"])&&this.btns.push({text:"删除",onClick:this.handleDelete,color:"red"})},data:function(){return{btns:[],regionForm:{},regionRules:{local_name:[this.MixinRequired("请输入地区名称！")]},dialogRegionVisible:!1}},methods:{handleEdit:function(e){this.regionForm=this.MixinClone(e),this.dialogRegionVisible=!0},handleDelete:function(e){var i=this;this.$confirm("确认要删除这个地区吗？").then(function(){var o;(o=e.id,Object(r.a)({url:"admin/systems/regions/"+o,method:"delete"})).then(function(){i.$message.success("删除成功！"),i.$refs.regionEditor.refresh("delete")})}).catch(function(){})},handleAdd:function(e,i,o){this.regionForm={parent_id:i?i.id:0,cod:1},this.dialogRegionVisible=!0},submitRegionForm:function(e){var i=this;this.$refs[e].validate(function(e){if(!e)return i.$message.error("表单填写有误，请检查！"),!1;var o,n=i.regionForm.id;n?function(e,i){return Object(r.a)({url:"admin/systems/regions/"+e,method:"put",data:i})}(n,i.regionForm).then(function(e){i.dialogRegionVisible=!1,i.$message.success("保存成功！"),i.$refs.regionEditor.refresh("edit",t()({},i.regionForm,{id:i.regionForm.id,text:i.regionForm.local_name}))}):(o=i.regionForm,Object(r.a)({url:"admin/systems/regions",method:"post",data:o})).then(function(e){i.dialogRegionVisible=!1,i.$message.success("添加成功！"),i.$refs.regionEditor.refresh("add")})})}}},l=o("XyMi"),a=Object(l.a)(s,function(){var e=this,i=e.$createElement,o=e._self._c||i;return o("div",[o("en-grade-editor",{ref:"regionEditor",attrs:{"type-text":"地区",api:e.MixinRegionApi,btns:e.btns,maxLevel:4,"params-names":{id:"id",text:"local_name"}},on:{"add-click":e.handleAdd}}),e._v(" "),o("el-dialog",{attrs:{title:e.regionForm.id?"编辑地区":"添加地区",width:"500px",visible:e.dialogRegionVisible,"modal-append-to-body":!1,"close-on-click-modal":!1,"close-on-press-escape":!1},on:{"update:visible":function(i){e.dialogRegionVisible=i}}},[o("el-form",{ref:"regionForm",attrs:{model:e.regionForm,rules:e.regionRules,"label-width":"130px"}},[o("el-form-item",{attrs:{label:"地区名称",prop:"local_name"}},[o("el-input",{model:{value:e.regionForm.local_name,callback:function(i){e.$set(e.regionForm,"local_name",i)},expression:"regionForm.local_name"}})],1),e._v(" "),o("el-form-item",{attrs:{label:"邮政编号"}},[o("el-input",{attrs:{maxlength:6},model:{value:e.regionForm.zipcode,callback:function(i){e.$set(e.regionForm,"zipcode",i)},expression:"regionForm.zipcode"}})],1)],1),e._v(" "),o("span",{staticClass:"dialog-footer",attrs:{slot:"footer"},slot:"footer"},[o("el-button",{on:{click:function(i){e.dialogRegionVisible=!1}}},[e._v("取 消")]),e._v(" "),o("el-button",{attrs:{type:"primary"},on:{click:function(i){return e.submitRegionForm("regionForm")}}},[e._v("确 定")])],1)],1)],1)},[],!1,null,null,null);i.default=a.exports}});