@jecloud/func
Version:
JECloud 功能库
1 lines • 1.82 kB
JavaScript
import{isPlainObject as t,encode as e,pick as r}from"@jecloud/utils";import i from"../model/query/dictionary-param";import{FuncTreeTypeEnum as o}from"../enum";var n=function(){function n(t){this.type=o.DD,this.rootId="ROOT",this.onlyItem=!1,this.multiple=!1,this.dictionarys=[],this.async=!1,this.j_query=[],this.querys=[],Object.assign(this,r(t,["type","rootId","onlyItem","multiple","funcCode","async","j_query","querys"])),this.addDictionary(t.dictionarys)}return n.prototype.addDictionary=function(e){var r=this;if(void 0===e&&(e=[]),this.type===o.DD)return t(e)&&(e=[e]),e.filter((function(t){return t.async})).length&&(this.async=!0),e.forEach((function(t){r.dictionarys.push(new i(t))})),this},n.prototype.toParams=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];switch(this.type){case o.FUNC:return this.toFuncTreeParams.apply(this,t);case o.DD:return this.toDicTreeParams.apply(this,t);default:return{}}},n.prototype.toDicTreeParams=function(t){var r=(t?this.dictionarys.filter((function(e){return e.nodeInfo===t.nodeInfo})):this.dictionarys).map((function(e){return Object.assign(e.toParams(),t,{})}));return{node:this.rootId,onlyItem:this.onlyItem,excludes:this.multiple?"":"checked",strData:e(r)}},n.prototype.toFuncTreeParams=function(t){var r,i=(void 0===t?{}:t).rootId;return{node:null!=i?i:this.rootId,onlyItem:!0,excludes:this.multiple?"":"checked",funcCode:this.funcCode,tableCode:this.tableCode,j_query:e((null!==(r=this.querys)&&void 0!==r?r:[]).concat(this.j_query))}},n.prototype.setQuerys=function(t){var e=t.querys,r=void 0===e?[]:e;this.j_query=r},n.prototype.initQuerys=function(t){var e=t.$func;if(this.type!==o.FUNC)return[];var r=[];return(null==e?void 0:e.parentFunc)&&(r.push.apply(r,e.store.getDefaults().querys),this.setQuerys({querys:r})),r},n}();export default n;