beehole-store-server
Version:
www.bee-hole.com
1 lines • 4.7 kB
JavaScript
(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-2d0b8b5f"],{"309e":function(e,t,n){"use strict";n.r(t);n("d81d"),n("4de4"),n("d3b7"),n("b0c0");var i=n("fcb7"),r=n("2dd7"),o=n("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:r["a"],SelectDept:o["a"]},data:function(){var e=function(e,t,n){""===t?n(new Error("部门名不允许为空")):n()};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,pid:void 0,name:void 0,deptFullName:void 0,sort:0,type:"dept",leader:void 0,phone:void 0,address:void 0,zipCode:void 0,email:void 0,status:"1"},open:!1,rules:{pid:[{required:!1,message:this.$t("component.gangwei.dept.fater.not.null"),trigger:"blur"}],name:[{required:!0,message:this.$t("component.gangwei.dept.dept_name.not.null"),validator:e,trigger:"change"}],sort:[{required:!0,message:this.$t("component.gangwei.dept.sort.not.null"),trigger:"blur"}],email:[{type:"email",message:this.$t("component.gangwei.dept.email.not.null"),trigger:["blur","change"]}],phone:[{pattern:/^1[3|4|5|6|7|8|9][0-9]\d{8}$/,message:this.$t("component.gangwei.dept.phone.not.null"),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?this.deptTypeOptions.filter((function(e){return"org"!==e.value})).map((function(e){return e.value})):"company"===e?this.deptTypeOptions.filter((function(e){return"org"!==e.value&&"company"!==e.value})).map((function(e){return e.value})):this.deptTypeOptions.filter((function(e){return"dept"===e.value})).map((function(e){return e.value})),null!==t&&""!==t&&"undefined"!==t&&void 0!==t){null===e&&(this.deptTypeEnableValue=this.deptTypeOptions.filter((function(e){return"org"===e.value})).map((function(e){return e.value})));var n=this.form.type,i=this.deptTypeEnableValue.filter((function(e){return e===n}));this.form.type=0===i.length?this.deptTypeEnableValue[0]:n}else this.form.type=this.deptTypeEnableValue[0]},handleAdd:function(e){var t=this;this.parentIdShow=!0,this.oldParentId="",this.deptTypeEnableValue=this.deptTypeOptions.map((function(e){return e.value})),void 0!==e&&(this.currentRow=e,this.oldParentId=e.id,this.form.pid={ids:e.id,names:e.name},this.getDeptTypeEnableValue(e.type)),Object(i["c"])(void 0!==e?e.id:"0").then((function(e){t.form.treeSort=e})),this.$emit("getTreeselect"),this.formTitle=this.$t("component.gangwei.dept.add.dept"),this.open=!0},setNodeData:function(e){this.currentRow.name=e.name,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.type},handleUpdate:function(e){var t=this;this.currentRow=e,this.open=!0,this.formTitle=this.$t("component.gangwei.dept.update.dept"),this.hasChild=e.children.length>0,this.spinning=!this.spinning;var n=e.id;Object(i["d"])(n).then((function(e){t.oldParentId=e.pid,t.form=e,"0"!==e.pid?(t.parentIdShow=!0,Object(i["d"])(e.pid).then((function(e){t.getDeptTypeEnableValue(e.type)}))):(t.parentIdShow=!1,t.getDeptTypeEnableValue(null)),"company"===e.deptType&&(t.selectScope="nonDept"),Object(i["d"])(e.pid).then((function(n){t.form.pid={ids:e.pid,names:n.name}})),t.spinning=!t.spinning})),this.$emit("getTreeselect",e)},submitForm:function(){var e=this;this.$refs.form.validate((function(t){if(!t)return!1;var n=JSON.parse(JSON.stringify(e.form));void 0!==e.form.pid&&(n.pid=e.form.pid.ids),void 0!==e.form.id?Object(i["m"])(n).then((function(t){e.$message.success("修改成功",3),e.oldParentId!==e.form.pid.ids?e.$emit("ok"):Object(i["d"])(e.form.id).then((function(t){e.setNodeData(t)})),e.cancel()})):Object(i["a"])(n).then((function(t){e.$message.success("新增成功",3),e.$emit("ok"),e.cancel()}))}))},onLoadData:function(e){return new Promise((function(t){e.dataRef.children?t():Object(i["h"])(e.dataRef.id,1).then((function(n){e.dataRef.children=n,t()}))}))}}}}}]);