You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
2 lines
4.4 KiB
2 lines
4.4 KiB
var g=Object.defineProperty,f=Object.defineProperties;var E=Object.getOwnPropertyDescriptors;var D=Object.getOwnPropertySymbols;var I=Object.prototype.hasOwnProperty,N=Object.prototype.propertyIsEnumerable;var y=(e,t,a)=>t in e?g(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a,n=(e,t)=>{for(var a in t||(t={}))I.call(t,a)&&y(e,a,t[a]);if(D)for(var a of D(t))N.call(t,a)&&y(e,a,t[a]);return e},P=(e,t)=>f(e,E(t));var h=(e,t,a)=>(y(e,typeof t!="symbol"?t+"":t,a),a);var i=(e,t,a)=>new Promise((s,r)=>{var m=o=>{try{d(a.next(o))}catch(p){r(p)}},l=o=>{try{d(a.throw(o))}catch(p){r(p)}},d=o=>o.done?s(o.value):Promise.resolve(o.value).then(m,l);d((a=a.apply(e,t)).next())});import{af as c,ag as u,Y as k}from"./index-f4658ae7.js";import{c as F}from"./ParamsUtils-3cbc5822.js";import{splitAtString as x}from"./ParamUtils-cdc24dd6.js";const K=["MyPK","OID","No","NodeID","WorkID"];class B{constructor(t,a="",s=""){h(this,"EnName","");h(this,"PKVal","");h(this,"queryArgs",[]);h(this,"extraParams",new Map);h(this,"data",{});h(this,"checkPKVal",()=>{let t=!1;for(const a of K)if(this.getData()[a]){t=!0;break}return t?!0:(k.error("\u6267\u884C\u5B9E\u4F53["+this.EnName+"]\uFF0C \u51FA\u73B0\u9519\u8BEF\uFF1A\u6CA1\u6709\u7ED9pk\u8D4B\u503C,\u8BF7\u5148\u8BBE\u7F6E\u4E3B\u952E"),!1)});this.EnName=t,this.PKVal=a,s&&(this[s]=a)}set No(t){this.data.No=t}get No(){return this.getData().No}set MyPK(t){this.data.MyPK=t}get MyPK(){return this.getData().MyPK}set OID(t){this.data.OID=t}get OID(){return this.getData().OID}set NodeID(t){this.data.NodeID=t}get NodeID(){return this.getData().NodeID}set WorkID(t){this.data.WorkID=t}get WorkID(){return this.getData().WorkID}setPK(t){this.PKVal=t}setVal(t,a){this.data[t]=a,this.data.hasOwnProperty(t)&&typeof this[t]!="function"&&(this[t]=a)}getVal(t){return this.data[t]}setData(t){this.data=t}decodeExtraParams(){const{AtPara:t}=this.data;t&&t.startsWith("@")&&x(t).forEach(s=>{const[r,m]=s.split("=");this.extraParams.set(r,m)})}getUrlParams(){const t={};return this.EnName&&(t.EnName=this.EnName),this.PKVal&&(t.PKVal=this.PKVal),t.t=Date.now()+"",t}encodeExtraParams(){let t="";for(const[a,s]of this.extraParams)t+=`@${a}=${s}`;return t}collectProperties(){const t=Object.keys(this);for(const a of t)if(this.data.hasOwnProperty(a)){this.data[a]=this[a];continue}}generateFormData(){this.collectProperties();const t=JSON.parse(JSON.stringify(this.data));delete t.AtPara;const a=Object.keys(t),s=new FormData;for(const r of a)s.append(r,`${this.data[r]}`);return s.append("AtPara",this.encodeExtraParams()),a.includes("pkval")||s.append("pkval",""),s}Init(){return i(this,null,function*(){try{this.data=yield c.post(u,null,{params:n({DoType:"Entity_Init"},this.getUrlParams())}),this.mountProperty(),this.decodeExtraParams()}catch(t){}})}mountProperty(){const t=Object.keys(this.data);for(const a of t)try{if(typeof this[a]=="function")continue;this[a]=this.data[a]}catch(s){}}Update(){return i(this,null,function*(){yield c.post(u,this.generateFormData(),{params:n({DoType:"Entity_Update"},this.getUrlParams())})})}Delete(){return i(this,null,function*(){yield c.post(u,this.generateFormData(),{params:n({DoType:"Entity_Delete"},this.getUrlParams())})})}RetrieveFromDBSources(){return i(this,null,function*(){return this.data=yield c.post(u,this.generateFormData(),{params:n({DoType:"Entity_RetrieveFromDBSources"},this.getUrlParams())}),this.decodeExtraParams(),this.data.RetrieveFromDBSources})}Retrieve(...t){return i(this,null,function*(){this.queryArgs=t,this.data=yield c.post(u,this.generateFormData(),{params:P(n({DoType:"Entity_Init"},this.getUrlParams()),{Paras:F(this.queryArgs)})}),this.decodeExtraParams()})}Insert(){return i(this,null,function*(){this.data=yield c.post(u,this.generateFormData(),{params:n({DoType:"Entity_Insert"},this.getUrlParams())}),this.decodeExtraParams()})}DoMethodReturnString(t,...a){return i(this,null,function*(){return yield this.execEntityMethod(t,a)})}DoMethodReturnJSON(t,...a){return i(this,null,function*(){return yield this.execEntityMethod(t,a)})}execEntityMethod(s){return i(this,arguments,function*(t,a=[]){if(!this.checkPKVal())return;const r=new FormData;return a.length>0&&r.append("paras",a.join("~")),yield c.post(u,r,{params:{DoType:"Entity_DoMethodReturnString",EnName:this.EnName,PKVal:encodeURIComponent(this.PKVal),MethodName:t,t:Date.now()}})})}getData(){return this.data}getPara(t){return this.extraParams.get(t)}setPara(t,a){this.extraParams.set(t,a)}}export{B as default};
|