(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-2d0b8b5f"],{"309e":function(e,t,r){"use strict";r.r(t);r("4de4"),r("d81d"),r("b64b"),r("d3b7");var n=r("fcb7"),i=r("2dd7"),a=r("6b01");t["default"]={name:"CreateForm",props:{deptTypeOptions:{type:Array,required:!0},statusOptions:{type:Array,required:!0},deptOptions:{type:Array,required:!0},expandedKeys:{type:Array,required:!0}},components:{AntModal:i["a"],SelectDept:a["a"]},data:function(){return{loading:!1,parentIdShow:!1,hasChild:!1,selectScope:"all",deptTypeEnableValue:[],formTitle:"",currentRow:void 0,oldParentId:"",spinning:!1,delayTime:200,customStyle:"background: #fff;ssborder-radius: 4px;margin-bottom: 24px;border: 0;overflow: hidden",form:{id:void 0,parentId:void 0,deptCode:void 0,deptName:void 0,deptFullName:void 0,treeSort:0,deptType:"dept",leader:void 0,phone:void 0,address:void 0,zipCode:void 0,email:void 0,status:"0"},open:!1,rules:{parentId:[{required:!0,message:"上级部门不能为空",trigger:"blur"}],deptCode:[{required:!0,message:"部门编码不能为空",trigger:"blur"}],deptType:[{required:!0,message:"部门类型不能为空",trigger:"blur"}],deptName:[{required:!0,message:"部门名称不能为空",trigger:"blur"}],treeSort:[{required:!0,message:"排序不能为空",trigger:"blur"}],email:[{type:"email",message:"请输入正确的邮箱地址",trigger:["blur","change"]}],phone:[{pattern:/^1[3|4|5|6|7|8|9][0-9]\d{8}$/,message:"请输入正确的手机号码",trigger:"blur"}]}}},filters:{},created:function(){},computed:{},watch:{},methods:{onDeptTypeChange:function(e){"company"===e.target.value?this.selectScope="nonDept":this.selectScope="all"},onSelectDept:function(e){this.getDeptTypeEnableValue(e.types)},cancel:function(){this.open=!1,this.$emit("close")},reset:function(){void 0!==this.$refs.form&&this.$refs.form.resetFields()},getDeptTypeEnableValue:function(e){var t=this.form.id;if(this.deptTypeEnableValue="org"===e||"company"===e?this.deptTypeOptions.filter((function(e){return"org"!==e.dictValue})).map((function(e){return e.dictValue})):this.deptTypeOptions.filter((function(e){return"dept"===e.dictValue})).map((function(e){return e.dictValue})),null!==t&&""!==t&&"undefined"!==t&&void 0!==t){null===e&&(this.deptTypeEnableValue=this.deptTypeOptions.filter((function(e){return"org"===e.dictValue})).map((function(e){return e.dictValue})));var r=this.form.deptType,n=this.deptTypeEnableValue.filter((function(e){return e===r}));this.form.deptType=0===n.length?this.deptTypeEnableValue[0]:r}else this.form.deptType=this.deptTypeEnableValue[0]},handleAdd:function(e){var t=this;this.parentIdShow=!0,this.oldParentId="",this.deptTypeEnableValue=this.deptTypeOptions.map((function(e){return e.dictValue})),void 0!==e&&(this.currentRow=e,this.oldParentId=e.id,this.form.parentId={ids:e.id,names:e.deptName},this.getDeptTypeEnableValue(e.deptType)),Object(n["d"])(void 0!==e?e.id:"0").then((function(e){t.form.treeSort=e.data})),this.$emit("getTreeselect"),this.formTitle="添加部门",this.open=!0},setNodeData:function(e){this.currentRow.deptName=e.deptName,this.currentRow.deptCode=e.deptCode,this.currentRow.leader=e.leader,this.currentRow.phone=e.phone,this.currentRow.email=e.email,this.currentRow.status=e.status,this.currentRow.treeSort=e.treeSort,this.currentRow.createTime=e.createTime,this.currentRow.deptType=e.deptType},handleUpdate:function(e){var t=this;this.currentRow=e,this.open=!0,this.formTitle="修改部门",this.hasChild=e.children.length>0,this.spinning=!this.spinning;var r=e.id;Object(n["e"])(r).then((function(e){t.oldParentId=e.data.parentId,t.form=e.data,"0"!==e.data.parentId?(t.parentIdShow=!0,t.getDeptTypeEnableValue(e.data.parentDeptType)):(t.parentIdShow=!1,t.getDeptTypeEnableValue(null)),"company"===e.data.deptType&&(t.selectScope="nonDept"),t.form.parentId={ids:e.data.parentId,names:e.data.parentName},t.spinning=!t.spinning})),this.$emit("getTreeselect",e)},submitForm:function(){var e=this;this.$refs.form.validate((function(t){if(!t)return!1;var r=JSON.parse(JSON.stringify(e.form));void 0!==e.form.parentId&&(r.parentId=e.form.parentId.ids),void 0!==e.form.id?Object(n["o"])(r).then((function(t){e.$message.success("修改成功",3),e.oldParentId!==e.form.parentId.ids?e.$emit("ok"):e.setNodeData(t.data),e.cancel()})):Object(n["a"])(r).then((function(t){e.$message.success("新增成功",3),e.oldParentId!==e.form.parentId.ids?e.$emit("ok"):e.appendTreeNode(e.currentRow,t.data),e.cancel()}))}))},onLoadData:function(e){return new Promise((function(t){e.dataRef.children?t():Object(n["i"])(e.dataRef.id,1).then((function(r){e.dataRef.children=r.data,t()}))}))}}}}}]);