yxk_pc_mdh/gyhl/static/js/252.57d3ac7420b69c1cb579.js

1 line
8.3 KiB
JavaScript

webpackJsonp([252],{EWL1:function(e,t){},Y9l4:function(e,t,a){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=a("d7EF"),s=a.n(i),r=a("//Fk"),n=a.n(r),o=a("mvHQ"),l=a.n(o),c=a("BO1k"),d=a.n(c),p=a("bzuE"),h={data:function(){return{rulesForm:{name:[{required:!0,message:"请输入组织名称",trigger:"blur"}],type:[{required:!0,message:"请选择组织类型",trigger:"change"}],parentId:[{required:!0,message:"请选择上级组织",trigger:"change"}]},total:0,pageSizes:[10,20,50],search_data:{pageno:1,pagesize:10},formData:{parentId:0},typeList:[],depts:[],btnDelDisabled:!0,btnOtherDisabled:!0,rowIds:[],tableData:[],dialogVisible:!1,pictLoading:!1,chooseID:void 0,dialogTitle:"新增部门",config:p.a,depOptions:[],selectDeptId:""}},mounted:function(){this.getList(),this.initData()},methods:{treeFindPath:function(e,t){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];if(!e)return[];var i=!0,s=!1,r=void 0;try{for(var n,o=d()(e);!(i=(n=o.next()).done);i=!0){var l=n.value;if(a.push(l.id),t(l))return a;if(l.children){var c=this.treeFindPath(l.children,t,a);if(c.length)return c}a.pop()}}catch(e){s=!0,r=e}finally{try{!i&&o.return&&o.return()}finally{if(s)throw r}}return[]},setDeptList:function(e){var t=!0,a=!1,i=void 0;try{for(var s,r=d()(e);!(t=(s=r.next()).done);t=!0){var n=s.value;n.hasChildren?this.setDeptList(n.children):n.children=void 0}}catch(e){a=!0,i=e}finally{try{!t&&r.return&&r.return()}finally{if(a)throw i}}},setDefaultDept:function(){if(this.depOptions.length>0&&this.formData.parentId){var e=l()(this.formData.parentId),t=this.treeFindPath(this.depOptions,function(t){return t.id===e});this.selectDeptId=JSON.parse(l()(t))}},handleChange:function(e){this.formData.parentId=e.length>0?e[e.length-1]:0,this.selectDeptId=e},initData:function(){var e=this;n.a.all([this.$api.dictAPI.getDictsByType("dept_type"),this.$api.commonAPI.getDeptsTree()]).then(function(t){var a=s()(t,2),i=a[0],r=a[1];0===i.code&&(e.typeList=i.datas),0===r.code&&(e.depOptions=r.data.children,e.setDefaultDept(),e.setDeptList(e.depOptions))}).catch(function(e){console.log(e)})},getList:function(){var e=this;this.pictLoading=!0,this.$api.deptAPI.list(this.search_data).then(function(t){e.pictLoading=!1,t.data?(e.depts=t.data?t.data:[],e.tableData=e.buildTree(t.data)):e.tableData=[]}).catch(function(e){console.log(e)})},buildTree:function(e){for(var t={},a=[],i=0;i<e.length;i++)t[e[i].deptId]=e[i];for(var s=0;s<e.length;s++){var r=t[e[s].parentId];r?(!r.children&&(r.children=[]),r.children.push(e[s])):a.push(e[s])}return a},search:function(){this.search_data.pageno=1,this.getList()},handleCurrentChange:function(e){this.search_data.pageno=e,this.getList()},handleSizeChange:function(e){this.search_data.pagesize=e,this.getList()},add:function(){this.dialogVisible=!0,this.chooseID="",this.formData={parentId:0},this.selectDeptId="",this.dialogTitle="新增部门",void 0!==this.$refs.form&&this.$refs.form.resetFields()},openDetails:function(e){this.dialogVisible=!0,this.chooseID=e.deptId,this.dialogTitle="编辑部门",void 0!==this.$refs.form&&this.$refs.form.resetFields(),this.selectDeptId=e.parentId,this.formData={},this.formData.deptId=e.deptId,this.formData.parentId=e.parentId,this.formData.type=e.type?e.type:"",this.$set(this.formData,"name",e.name),this.$set(this.formData,"orderNum",e.orderNum?e.orderNum:""),this.setDefaultDept()},save:function(e){var t=this;this.$refs[e].validate(function(e){if(!e)return!1;t.chooseID?t.$api.deptAPI.update(t.formData).then(function(e){0===e.code?(t.initData(),t.$message({message:e.msg,type:"success"}),t.dialogVisible=!1,t.getList()):t.$message({message:e.msg,type:"error"})}).catch(function(e){t.$message({message:res.msg,type:"success"})}):t.$api.deptAPI.add(t.formData).then(function(e){0===e.code?(t.initData(),t.$message({message:e.msg,type:"success"}),t.dialogVisible=!1,t.getList()):t.$message({message:e.msg,type:"error"})}).catch(function(e){t.$message({message:res.msg,type:"success"})})})},remove:function(){var e=this,t=[];this.rowIds.forEach(function(e){t.push(e.deptId)});var a={deptId:t[0]};this.$confirm("确认删除选中的部门吗?","提示",{type:"warning"}).then(function(){e.$api.deptAPI.remove(a).then(function(t){0===t.code?(e.$message({message:t.msg,type:"success"}),e.getList(),e.initData()):e.$message({message:t.msg?t.msg:"删除失败,请重试",type:"error"})}).catch(function(t){e.$message({message:"删除失败,请重试",type:"error"})})})},handleSelectionChange:function(e){this.rowIds=e,this.setBtn(e)},setBtn:function(e){var t=!0,a=!0;e.length>0?(a=!1,1==e.length&&(t=!1)):(t=!0,a=!0),this.btnDelDisabled=a,this.btnOtherDisabled=t}}},f={render:function(){var e=this,t=e.$createElement,a=e._self._c||t;return a("div",{staticClass:"sys-box knowledge-box"},[a("div",{staticClass:"sys-operate"},[a("el-button",{attrs:{type:"primary"},on:{click:function(t){return e.add()}}},[e._v("新增")]),e._v(" "),a("el-button",{attrs:{type:"primary",disabled:e.btnOtherDisabled},on:{click:function(t){return e.remove()}}},[e._v("删除")])],1),e._v(" "),a("div",{staticClass:"sys-search"},[a("el-form",{attrs:{inline:""}},[a("el-form-item",{attrs:{label:"部门名称"}},[a("el-input",{attrs:{placeholder:"请填写部门名称"},model:{value:e.search_data.deptName,callback:function(t){e.$set(e.search_data,"deptName",t)},expression:"search_data.deptName"}})],1),e._v(" "),a("el-form-item",[a("el-button",{attrs:{type:"primary"},on:{click:function(t){return e.search()}}},[e._v("查询")])],1)],1)],1),e._v(" "),a("div",{staticClass:"sys-table"},[a("el-table",{directives:[{name:"loading",rawName:"v-loading",value:e.pictLoading,expression:"pictLoading"}],attrs:{data:e.tableData,"row-key":"deptId","default-expand-all":"",border:"","tree-props":{children:"children",hasChildren:"hasChildren"},"header-cell-style":{fontWeight:"normal",textAlign:"center",backgroundColor:"#eceff4",color:"#222"}},on:{"row-click":e.openDetails,"selection-change":e.handleSelectionChange}},[a("el-table-column",{attrs:{type:"selection",width:"55",align:"center"}}),e._v(" "),a("el-table-column",{attrs:{type:"index",label:"序号",width:"100",align:"center"}}),e._v(" "),a("el-table-column",{attrs:{prop:"name",label:"组织名称","show-overflow-tooltip":""}}),e._v(" "),a("el-table-column",{attrs:{prop:"typeName",align:"center",label:"组织类型","show-overflow-tooltip":""}}),e._v(" "),a("el-table-column",{attrs:{prop:"orderNum",align:"center",label:"排序号","show-overflow-tooltip":""}})],1)],1),e._v(" "),a("el-dialog",{attrs:{title:e.dialogTitle,center:"",visible:e.dialogVisible,width:"600px"},on:{"update:visible":function(t){e.dialogVisible=t}}},[a("el-form",{ref:"form",staticClass:"company-form",attrs:{"label-width":"80px",model:e.formData,rules:e.rulesForm}},[a("el-form-item",{attrs:{label:"上级组织"}},[a("el-cascader",{staticStyle:{width:"100%"},attrs:{options:e.depOptions,props:{expandTrigger:"hover",label:"text",value:"id",checkStrictly:!0},clearable:""},on:{change:e.handleChange},model:{value:e.selectDeptId,callback:function(t){e.selectDeptId=t},expression:"selectDeptId"}})],1),e._v(" "),a("el-form-item",{attrs:{prop:"name",label:"组织名称"}},[a("el-input",{attrs:{placeholder:"请输入组织名称"},model:{value:e.formData.name,callback:function(t){e.$set(e.formData,"name",t)},expression:"formData.name"}})],1),e._v(" "),a("el-form-item",{attrs:{label:"组织类型"}},[a("el-select",{staticStyle:{width:"100%"},attrs:{clearable:"",placeholder:"请选择"},on:{change:function(t){return e.$forceUpdate()}},model:{value:e.formData.type,callback:function(t){e.$set(e.formData,"type",t)},expression:"formData.type"}},e._l(e.typeList,function(e){return a("el-option",{key:e.id,attrs:{label:e.name,value:e.id}})}),1)],1),e._v(" "),a("el-form-item",{attrs:{label:"排序"}},[a("el-input",{attrs:{placeholder:"由系统自动产生"},model:{value:e.formData.orderNum,callback:function(t){e.$set(e.formData,"orderNum",t)},expression:"formData.orderNum"}})],1)],1),e._v(" "),a("span",{staticClass:"dialog-footer",attrs:{slot:"footer"},slot:"footer"},[a("el-button",{attrs:{type:"primary"},on:{click:function(t){e.dialogVisible=!1}}},[e._v(e._s(e.config.cancelText))]),e._v(" "),a("el-button",{attrs:{type:"primary"},on:{click:function(t){return e.save("form")}}},[e._v("保存")])],1)],1)],1)},staticRenderFns:[]};var u=a("VU/8")(h,f,!1,function(e){a("EWL1"),a("td+D")},"data-v-16c2bf76",null);t.default=u.exports},"td+D":function(e,t){}});