UNPKG

@jecloud/func

Version:

JECloud 功能库

1 lines 3.48 kB
var e=this&&this.__extends||function(){var e=function(t,o){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])},e(t,o)};return function(t,o){function n(){this.constructor=t}e(t,o),t.prototype=null===o?Object.create(o):(n.prototype=o.prototype,new n)}}();import t from"./func-info";import o from"../base";import n from"../query/dictionary-param";import r from"../../../field";import{get as i,cloneDeep as c,pick as s,isNotEmpty as a}from"@jecloud/utils";import{parseFunc as u,keyToData as f}from"./util";import{FuncButtonTypeEnum as d}from"../../enum/func-enum";var p=function(o){function p(e){var n=o.call(this)||this;return n.basic={columns:new Map,fields:new Map,childs:new Map,buttons:new Map,ids:new Map,children:new Map,dictionarys:new Map},n.model=[],n.strategys=[],n.groupQuerys=[],n.defaults={values:{}},n.columns={func:[],select:[],data:[]},n.fields={form:[],exps:[],anchor:[],groupQuery:[],childFunc:[],uploadFile:[],updateFiles:[],textcode:[],history:[],badge:[],codeGenFieldInfo:[]},n.buttons={common:[],form:[],grid:[],group:[],locate:[],action:[]},n.exps={bind:[],empty:[],readonly:[],visible:[]},n.querys={func:{keyword:[],mark:[],tree:[],group:[],groupAll:[]},select:{keyword:[],mark:[],tree:[],group:[],groupAll:[]}},n.children=[],n._dataCache=new Map,n.info=new t(e.info),n.model=e.model,n.perms=e.perms,Object.assign(n,s(n.info,["funcId","funcCode","funcName"])),u({func:n,options:e}),n}return e(p,o),p.prototype.getData=function(e){var t=this,o=e.split("."),s=i(this,e);if(!s)return console.warn("功能【"+this.info.funcCode+"】未找到数据值:"+e),s;if(this._dataCache.has(e))return this._dataCache.get(e);var a=null,u=o[0];switch(u){case"fields":case"columns":case"buttons":case"children":a=f({keys:s,sourceMap:this.basic[u]});break;case"querys":o.includes("tree")?(a=[],s.forEach((function(e){var o=t.basic.fields.get(e),i=t.basic.columns.get(e);if(null==o?void 0:o.configInfo){var c=r.parseConfigInfo({configInfo:o.configInfo,type:"tree"}),s=o.otherConfig,u=s.queryField,f=s.nodeField,d=s.rootId;(null==c?void 0:c.code)&&a.push(new n({ddCode:c.code,ddName:i.text,queryField:u,nodeField:f,rootId:d,nodeInfo:i.code,enableValue:i.treeQueryValue,async:c.async,config:c}))}}))):a=f({keys:s,sourceMap:this.basic.columns})}return this._dataCache.set(e,c(a)),this._dataCache.get(e)},p.prototype.getQuerys=function(e,t){return void 0===t&&(t="func"),this.getData("querys."+t+"."+e)},p.prototype.getPerm=function(e){var t,o=e.type,n=e.code,r=this.info.funcCode,i="";switch(o){case"button":i="pc-func-button-"+r+"-"+n+"-show";break;case"config":i="pc-func-"+r+"-config";break;case"show":i="pc-func-"+r+"-show"}return null===(t=this.perms)||void 0===t?void 0:t.includes(i)},p.prototype.getFormEditPerm=function(){var e=this.buttons.form.find((function(e){return d.FORM_SAVE_BUTTON===e})),t=this.getPerm({type:"button",code:d.FORM_SAVE_BUTTON});return e&&t},p.prototype.hasConfigPerm=function(){return this.getPerm({type:"config"})},p.prototype.hasShowPerm=function(){return this.getPerm({type:"show"})},p.prototype.getValidRules=function(e){var t=this,o=e.type,n={};return"grid"===o?this.basic.columns.forEach((function(o){var r=t.basic.fields.get(o.field);if(r&&!o.hidden&&o.editable){var i=r.getRules(e);a(i)&&(n[r.name]=i)}})):this.basic.fields.forEach((function(t){var o=t.getRules(e);a(o)&&(n[t.name]=o)})),n},p}(o);export default p;