cuikaidong
2025-08-08 c495c1ae53473d54af136ea00da84bf51c50d521
1
(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-30b836a7"],{"5d56":function(e,t,n){"use strict";var a=n("bbaf"),i=n.n(a);i.a},bbaf:function(e,t,n){},ea50:function(e,t,n){"use strict";n.r(t);var a=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("a-card",{staticClass:"tree_con",attrs:{loading:e.cardLoading,bordered:!1}},[n("a-spin",{attrs:{spinning:e.loading}},[n("a-alert",{staticStyle:{"margin-right":"54px","padding-left":"5px"},attrs:{type:"info",showIcon:!1}},[n("div",{attrs:{slot:"message"},slot:"message"},[this.currSelected.title?n("span",[e._v(e._s(e.getCurrSelectedTitle()))]):n("span",[e._v("无")])])]),n("div",{staticClass:"drawer-bootom-button"},[n("a-dropdown",{attrs:{trigger:["click"],placement:"bottomCenter"}},[n("a-menu",{attrs:{slot:"overlay"},slot:"overlay"},[n("a-menu-item",{key:"1",on:{click:e.expandAll}},[e._v("展开所有")]),n("a-menu-item",{key:"2",on:{click:e.closeAll}},[e._v("合并所有")]),n("a-menu-item",{key:"3",on:{click:e.refreshTree}},[e._v("刷新")])],1),n("a-button",[n("a-icon",{attrs:{type:"bars"}})],1)],1)],1),n("a-input-search",{staticStyle:{width:"100%","margin-top":"10px"},attrs:{placeholder:"检索 类别编码/名称",allowClear:""},on:{search:e.handleSearch,change:e.handleChange},model:{value:e.searchInput,callback:function(t){e.searchInput=t},expression:"searchInput"}}),n("a-form",[n("a-form-item",[n("a-tree",{ref:"tree",attrs:{checkable:"",checkStrictly:e.checkStrictly,expandedKeys:e.expandedKeys,checkedKeys:e.checkedKeys,selectedKeys:e.selectedKeys,treeData:e.treeDataSource,autoExpandParent:e.autoExpandParent},on:{check:e.onCheck,select:e.onSelect,expand:e.onExpand}})],1)],1)],1)],1)},i=[],c=n("0fea"),s=n("f933"),r={name:"BaseTree",props:{editDisable:{type:Boolean,default:function(){return!0}}},components:{Tooltip:s["a"]},data:function(){return{searchInput:"",cardLoading:!1,loading:!1,treeDataSource:[],selectedKeys:[],expandedKeys:[],checkedKeys:[],checkedId:[],url:{getBaseTree:"/mdc/mdcequipment/loadTree",deleteBatch:"/mdc/mdcequipment/deleteBatch"},searchValue:"",dataList:[],autoExpandParent:!1,checkStrictly:!1,allTreeKeys:[],currSelected:{},currentSlectList:[],hiding:!1,mathChange:""}},created:function(){this.queryTreeData()},methods:{switchCheckStrictly:function(e){1==e?this.checkStrictly=!1:2==e&&(this.checkStrictly=!0)},checkALL:function(e){this.checkedKeys=this.allTreeKeys,this.currentSlectList=this.treeDataSource},cancelCheckALL:function(){this.checkedKeys=[],this.currentSlectList=[]},onCheck:function(e,t){if(this.checkStrictly?this.checkedKeys=e.checked:this.checkedKeys=e,1==t.checked)this.currentSlectList.push(t.node.dataRef);else for(var n=0;n<this.currentSlectList.length;n++)this.currentSlectList[n].key==t.node.dataRef.key&&this.currentSlectList.splice(n,1)},clearSelect:function(){this.checkedKeys=[],this.currentSlectList=[]},getCurrSelectedTitle:function(){return this.currSelected.title?this.currSelected.title:""},onSelect:function(e,t){this.hiding=!1;var n=t.node.dataRef;this.currSelected=Object.assign({},n),this.selectedKeys=[n.key],this.$emit("sendSelectBaseTree",this.selectedKeys)},handleEdit:function(e){this.$refs.tierModalForm.edit(e),this.$refs.tierModalForm.title="编辑层级",this.$refs.tierModalForm.disableSubmit=!1},onExpand:function(e){this.expandedKeys=e,this.autoExpandParent=!1},queryTreeData:function(){var e=this;this.loading=!0,this.cardLoading=!0,Object(c["c"])(this.url.getBaseTree).then((function(t){t.success?(e.dataList=[],e.allTreeKeys=[],e.treeDataSource=t.result,e.generateList(t.result)):e.$notification.warning({message:"消息",description:t.message})})).finally((function(){e.loading=!1,e.cardLoading=!1}))},handleChange:function(){var e=this,t=this.searchInput,n=this.dataList.map((function(n){return n.title.indexOf(t)>-1?e.getParentKey(n.key,e.treeDataSource):null})).filter((function(e,t,n){return e&&n.indexOf(e)===t}));Object.assign(this,{expandedKeys:n,searchValue:t,autoExpandParent:!0})},handleSearch:function(e){var t=this,n=e,a=this.dataList.map((function(e){return e.title.indexOf(n)>-1?t.getParentKey(e.key,t.treeDataSource):null})).filter((function(e,t,n){return e&&n.indexOf(e)===t}));Object.assign(this,{expandedKeys:a,searchValue:n,autoExpandParent:!0})},getParentKey:function(e,t){for(var n,a=0;a<t.length;a++){var i=t[a];i.children&&(i.children.some((function(t){return t.key===e}))?n=i.key:this.getParentKey(e,i.children)&&(n=this.getParentKey(e,i.children)))}return n},generateList:function(e){for(var t=0;t<e.length;t++){var n=e[t],a=n.key,i=n.title;this.dataList.push({key:a,title:i}),this.allTreeKeys.push(a),n.children&&this.generateList(n.children)}},expandAll:function(){this.expandedKeys=this.allTreeKeys},closeAll:function(){this.expandedKeys=["-1"]},refreshTree:function(){this.queryTreeData()},batchDel:function(e){if(this.url.deleteBatch){var t=e.id;if(t){var n=this;this.$confirm({title:"确认删除",content:"是否删除选中数据?",onOk:function(){n.loading=!0,Object(c["a"])(n.url.deleteBatch,{ids:t}).then((function(e){e.success?(n.$notification.success({message:"消息",description:e.message}),n.queryTreeData()):n.$notification.warning({message:"消息",description:e.message})})).finally((function(){n.loading=!1}))}})}else this.$notification.warning({message:"消息",description:"请选择一条记录"})}else this.$message.error("请设置url.deleteBatch属性!")},modalFormOk:function(e){this.queryTreeData()}},watch:{currSelected:function(e){this.$emit("getCurrSelected",e)},currentSlectList:function(e){this.$emit("getcurrentSlectList",e)},checkedKeys:function(e){this.$emit("getcheckedKeys",e)}}},l=r,o=(n("5d56"),n("2877")),d=Object(o["a"])(l,a,i,!1,null,"e973d794",null);t["default"]=d.exports}}]);