g-ui-web 1.4.61 → 1.4.62
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/g-ui-web.cjs
CHANGED
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
<div class="loadot"></div>
|
|
54
54
|
<div class="loadot"></div>
|
|
55
55
|
</div>
|
|
56
|
-
`;o.innerHTML=i,n.appendChild(o),(!e||e=="body")&&(o.style.position="fixed");const l=o.querySelectorAll(".loading-dots .loadot");l[0].style.backgroundColor=ph.loadingList[0],l[1].style.backgroundColor=ph.loadingList[1],l[2].style.backgroundColor=ph.loadingList[2],ph.name&&typeof ph.name=="string"&&ph.name.includes("black")&&(o.style.backgroundColor="rgba(0, 0, 0, 0.6)");const s={lg:16,md:12,sm:8,xs:5},u={lg:"12px",md:"10px",sm:"8px",xs:"4px"},c=o.querySelector(".loading-dots");c.style.gap=u[t]||"10px",l.forEach(d=>{d.style.width=`${s[t]}px`,d.style.height=`${s[t]}px`}),globalThis.gui.loading=vM})},done:function(e,t=0){a.nextTick(()=>{setTimeout(()=>{globalThis.gui.loading=vM,document.body.style.overflow="";const n=e?document.querySelector(`${e} .loading-next`):document.querySelector(".loading-next");n&&n.parentNode&&n.parentNode.removeChild(n)},t)})}};/*! js-cookie v3.0.5 | MIT */function QC(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)e[r]=n[r]}return e}var BVe={read:function(e){return e[0]==='"'&&(e=e.slice(1,-1)),e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(e){return encodeURIComponent(e).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}};function mM(e,t){function n(o,i,l){if(!(typeof document>"u")){l=QC({},t,l),typeof l.expires=="number"&&(l.expires=new Date(Date.now()+l.expires*864e5)),l.expires&&(l.expires=l.expires.toUTCString()),o=encodeURIComponent(o).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var s="";for(var u in l)l[u]&&(s+="; "+u,l[u]!==!0&&(s+="="+l[u].split(";")[0]));return document.cookie=o+"="+e.write(i,o)+s}}function r(o){if(!(typeof document>"u"||arguments.length&&!o)){for(var i=document.cookie?document.cookie.split("; "):[],l={},s=0;s<i.length;s++){var u=i[s].split("="),c=u.slice(1).join("=");try{var d=decodeURIComponent(u[0]);if(l[d]=e.read(c,d),o===d)break}catch{}}return o?l[o]:l}}return Object.create({set:n,get:r,remove:function(o,i){n(o,"",QC({},i,{expires:-1}))},withAttributes:function(o){return mM(this.converter,QC({},this.attributes,o))},withConverter:function(o){return mM(QC({},this.converter,o),this.attributes)}},{attributes:{value:Object.freeze(t)},converter:{value:Object.freeze(e)}})}var U_=mM(BVe,{path:"/"});function Zq(e,t={}){const{autoLoad:n=!0,watchParams:r,watchKeys:o,...i}=t,l=NVe(e),s=new LI(l,{...i}),u=a.reactive([...s.mergeData()]),c=s.reactiveStates,d=s.isLoading,f=s.hasError;s.onDataUpdate(()=>{const C=s.mergeData();u.length=0,u.push(...C)});const p=async C=>s.loadData(C);a.onMounted(()=>{n&&p()});const h=async(C,b)=>s.refreshData(C,b),v=async(C,b)=>C?s.refreshData(C,b):s.refreshAll(),m=async C=>s.refreshAll(C),g=async(C,b)=>s.refreshData(C,b,!0),y=C=>c[C];return r&&a.watch(typeof r=="function"?r:()=>r.value,async C=>{if(o&&o.length>0)for(const b of o)await h(b,C);else await m()},{deep:!0}),{_sourceInstance:s,sourceData:u,sourceState:c,isLoading:d,hasError:f,loadData:p,refreshData:h,reload:v,refreshAll:m,updateData:g,getState:y,mergeData:s.mergeData.bind(s),onDataUpdate:s.onDataUpdate.bind(s),clear:s.clear.bind(s),destroy:s.destroy.bind(s)}}const NVe=e=>{const t=(n,r)=>{if(!r)return n;const o=r.startsWith("/")?r.slice(1):r,i=o.includes("/")?"/":".";return String(o).split(i).reduce((l,s)=>l!=null&&s?l[s]:void 0,n)};if(e&&typeof e=="object"&&"path"in e){const n=e.fieldPath??e.resPath;return[{key:"legacy_obj_api",type:"api",api:{url:e.path,method:(e.method??"GET").toUpperCase(),params:e.params,data:e.data,headers:e.headers,transform:r=>{const o=t(r,n),i=typeof e.transformResponse=="function"?e.transformResponse(o):void 0,l=i!==void 0?i:o;return Array.isArray(l)?l:[l]}}}]}else return e},jn=async(e,t)=>{if(Array.isArray(e)){if(!e.every(r=>r&&typeof r=="object"&&"type"in r&&(r.type==="api"||r.type==="static")))return e}else{if(e&&typeof e=="object"&&!("path"in e))return[e];if(typeof e=="string"||typeof e=="number")return[{[t]:e}]}};function $n(e){return e&&typeof e=="object"&&"reactiveStates"in e&&"isLoading"in e&&"hasError"in e&&typeof e.loadData=="function"&&typeof e.refreshData=="function"&&typeof e.mergeData=="function"}function Ln(e){return e&&typeof e=="object"&&"sourceData"in e&&"_sourceInstance"in e&&typeof e.onDataUpdate=="function"}function Yn(e){return async t=>{const n=typeof window<"u"&&window.gui&&window.gui.guiDebug===!0||window.guiDebug===!0,r=(e==null?void 0:e.debug)===!0;if(!n&&!r)return;t.preventDefault();const o=e==null?void 0:e.data;Ln(o)?(console.log("🔍 [DataSource Debug] 右键触发调试,重新加载数据..."),o._sourceInstance.debugMode=!0,await o._sourceInstance.loadData(),console.log("✅ [DataSource Debug] 数据重新加载完成")):$n(o)&&(console.log("🔍 [DataSource Debug] 右键触发调试,重新加载数据..."),o.debugMode=!0,o.loadData(),console.log("✅ [DataSource Debug] 数据重新加载完成"))}}class LI{constructor(t,n={}){ys(this,"_configMap",new Map);ys(this,"_stateMap",new Map);ys(this,"_options");ys(this,"_listeners",new Set);ys(this,"reactiveStates",a.reactive({}));ys(this,"isLoading",a.ref(!1));ys(this,"hasError",a.ref(!1));ys(this,"debugMode",!1);ys(this,"pickPath",(t,n)=>{if(!n)return t;const r=n.startsWith("/")?n.slice(1):n,o=r.includes("/")?"/":".";return String(r).split(o).reduce((i,l)=>i!=null&&l?i[l]:void 0,t)});this._options={autoLoad:(n==null?void 0:n.autoLoad)||!1,retryCount:0,retryDelay:1e3,onRequest:i=>i,onResponse:i=>i,onError:()=>{},mergeTransformer:n.mergeTransformer,...n},this.cleanConfig(t).forEach(i=>{this.addSource(i)}),(this._options.autoLoad||this.isOldDataSource(t)&&((t==null?void 0:t.autoQuery)===!0||(t==null?void 0:t.autoQuery)===void 0))&&this.loadData()}addSource(t){this._configMap.set(t.key,t);const n={data:t.type==="static"?t.data??null:null,status:t.type==="static"?"success":"idle",error:null,lastUpdated:t.type==="static"?new Date:null};this._stateMap.set(t.key,n),this.reactiveStates[t.key]=n,t.type==="static"&&t.data!==void 0&&t.data!==null&&Promise.resolve().then(()=>{this.notifyListeners(t.key,t.data)})}removeSource(t){const n=this._configMap.delete(t);return this._stateMap.delete(t),delete this.reactiveStates[t],n}async loadSingle(t,n){const r=this._configMap.get(t);if(!r)throw new Error(`DataSource with key "${t}" not found`);this.updateState(t,{status:"loading",error:null});try{let o;if(r.type==="static")o=r.data;else if(r.type==="api"&&r.api)o=await this.fetchWithRetry(r,n);else throw new Error(`Invalid data source configuration for key "${t}"`);return this.updateState(t,{data:o,status:"success",error:null,lastUpdated:new Date}),this.notifyListeners(t,o),o}catch(o){const i=o instanceof Error?o:new Error(String(o));throw this.updateState(t,{status:"error",error:i}),this._options.onError(i,t),i}}async fetchWithRetry(t,n,r=0){var i;const o=t.api;try{const l=Xn.state["gui-ajax-config"]||{},s=typeof document<"u"&&((i=U_.get)==null?void 0:i.call(U_,"token"))||"",u=(l==null?void 0:l.token)||s,c={};if(u){const w=(l==null?void 0:l.tokenName)||"token";c[w]=u}l!=null&&l.sysCode&&(c.sysCode=l.sysCode),l!=null&&l.appType&&(c.appType=l.appType);const d={...c,...o.headers||{}},f={...o.headers||{}},p=t.key==="legacy_obj_api"?f:d;let h={url:o.url,method:o.method||"GET",headers:p};const v={...o.params,...n},m={...o.data,...n};h.method==="GET"?h.params=v:h.data=m,h=this._options.onRequest(h),this.debugMode&&console.log("🔍 [DataSource Debug] Request:",{url:h.url,method:h.method,params:h.params,data:h.data,fieldPath:o.fieldPath,retryCount:r,timestamp:new Date().toISOString()});const g=await ha(h),y=g.data;if(y&&typeof y=="object"&&y.code===999){const w=y.errorMsg||"Request failed with code 999";return fl&&fl.warning(w),[]}let C=this._options.onResponse(g.data),b=!1;if(o.fieldPath?(C=this.pickPath(C,o.fieldPath),b=!0):C&&typeof C=="object"&&"data"in C&&(C=this.pickPath(C,"data"),b=!0),o.transform){const w=C;let S=o.transform(w,y);C=S!==void 0?S:w}else b&&(C=Array.isArray(C)?C:[C]);return C}catch(l){if(r<this._options.retryCount)return await this.delay(this._options.retryDelay),this.fetchWithRetry(t,n,r+1);throw l}}delay(t){return new Promise(n=>setTimeout(n,t))}updateState(t,n){const r=this._stateMap.get(t);if(r){const o={...r,...n};this._stateMap.set(t,o),Object.assign(this.reactiveStates[t],o)}this.updateGlobalStatus()}updateGlobalStatus(){let t=!1,n=!1;this._stateMap.forEach(r=>{r.status==="loading"&&(t=!0),r.status==="error"&&(n=!0)}),this.isLoading&&typeof this.isLoading=="object"&&"value"in this.isLoading?this.isLoading.value=t:this.isLoading=a.ref(t),this.hasError&&typeof this.hasError=="object"&&"value"in this.hasError?this.hasError.value=n:this.hasError=a.ref(n)}notifyListeners(t,n){const r=this._stateMap.get(t);r&&this._listeners.forEach(o=>{o(t,n,r)})}normalizeMethod(t){const n=String(t??"GET").toUpperCase();return n==="POST"||n==="PUT"||n==="DELETE"?n:"GET"}isOldDataSource(t){if(!t||Array.isArray(t)||Object.getPrototypeOf(t)!==Object.prototype)return!1;const n=t.type;return!!(n!=="api"&&n!=="static")}cleanConfig(t){var n;if(this.isOldDataSource(t)){const r=t.fieldPath??t.resPath,o=t.key?((n=Xn.state["gui-ajax-config"])==null?void 0:n[t.key])??{}:Xn.state["gui-ajax-config"]??{},i={};o!=null&&o.tokenName&&(o!=null&&o.token)&&(i[o.tokenName]=o.token),o!=null&&o.sysCode&&(i.sysCode=o.sysCode),o!=null&&o.appType&&(i.appType=o.appType);const l={...i,...t.headers||{}};return[{key:"legacy_obj_api",type:"api",api:{url:t.path,method:this.normalizeMethod(t.method),params:t.params||t.data,data:t.data||t.params,headers:l,...r?{fieldPath:r}:{},transform:(s,u)=>{const c=typeof t.transformResponse=="function"?t.transformResponse(s,u):void 0;return c!==void 0?c:s}}}]}else return t}async loadData(t){const r=(t?Array.isArray(t)?t:[t]:Array.from(this._configMap.keys()).filter(o=>{var i;return((i=this._configMap.get(o))==null?void 0:i.type)==="api"})).map(o=>this.loadSingle(o).then(i=>({key:o,data:i,success:!0})).catch(i=>({key:o,error:i,success:!1})));return await Promise.all(r),this.mergeData()}async refreshData(t,n,r){if(!this._configMap.has(t))throw new Error(`DataSource with key "${t}" not found`);if(r){const i=n;return this.updateState(t,{data:i,status:"success",lastUpdated:new Date}),this.notifyListeners(t,i),i}const o=this._configMap.get(t);if(o.type==="api"&&o.api&&n&&typeof n=="object"&&!Array.isArray(n)){const i=n;return(o.api.method||"GET")==="GET"?o.api.params={...o.api.params||{},...i}:o.api.data={...o.api.data||{},...i},this._configMap.set(t,o),this.loadSingle(t)}return this.loadSingle(t,n)}async refreshAll(t){const r=Array.from(this._configMap.keys()).map(o=>{const i=t==null?void 0:t[o];return this.refreshData(o,i).then(l=>({key:o,data:l,success:!0})).catch(l=>({key:o,error:l,success:!1}))});return await Promise.all(r),this.mergeData()}getData(t){var n;return(n=this._stateMap.get(t))==null?void 0:n.data}getAllData(){const t={};return this._stateMap.forEach((n,r)=>{t[r]=n.data}),t}getState(t){return this._stateMap.get(t)}getAllStates(){const t={};return this._stateMap.forEach((n,r)=>{t[r]=n}),t}getLoadingStatus(t){var n;return((n=this._stateMap.get(t))==null?void 0:n.status)??"idle"}isSourceLoading(t){return this.getLoadingStatus(t)==="loading"}onDataUpdate(t){return this._listeners.add(t),()=>{this._listeners.delete(t)}}mergeData(t){const n=t||this._options.mergeTransformer,r=this.getAllData();if(n)return n(r);const o=Object.values(r);return o.length===1?o[0]||[]:o.flat()}clear(){this._configMap.forEach((t,n)=>{this.updateState(n,{data:null,status:"idle",error:null,lastUpdated:null})})}destroy(){this._configMap.clear(),this._stateMap.clear(),this._listeners.clear(),Object.keys(this.reactiveStates).forEach(t=>{delete this.reactiveStates[t]})}reload(t,n){if(typeof t=="string")return this.refreshData(t,n);if(t&&typeof t=="object"&&!n){const r=Array.from(this._configMap.keys());if(r.length===1)return this.refreshData(r[0],t);const o={};return r.forEach(i=>{o[i]=t}),this.refreshAll(o)}return t?this.refreshAll(t):this.refreshAll()}}var OVe={name:"zh-cn",el:{breadcrumb:{label:"面包屑"},colorpicker:{confirm:"确定",clear:"清空",defaultLabel:"颜色选择器",description:"当前颜色 {color},按 Enter 键选择新颜色",alphaLabel:"选择透明度的值"},datepicker:{now:"此刻",today:"今天",cancel:"取消",clear:"清空",confirm:"确定",dateTablePrompt:"使用方向键与 Enter 键可选择日期",monthTablePrompt:"使用方向键与 Enter 键可选择月份",yearTablePrompt:"使用方向键与 Enter 键可选择年份",selectedDate:"已选日期",selectDate:"选择日期",selectTime:"选择时间",startDate:"开始日期",startTime:"开始时间",endDate:"结束日期",endTime:"结束时间",prevYear:"前一年",nextYear:"后一年",prevMonth:"上个月",nextMonth:"下个月",year:"年",month1:"1 月",month2:"2 月",month3:"3 月",month4:"4 月",month5:"5 月",month6:"6 月",month7:"7 月",month8:"8 月",month9:"9 月",month10:"10 月",month11:"11 月",month12:"12 月",weeks:{sun:"日",mon:"一",tue:"二",wed:"三",thu:"四",fri:"五",sat:"六"},weeksFull:{sun:"星期日",mon:"星期一",tue:"星期二",wed:"星期三",thu:"星期四",fri:"星期五",sat:"星期六"},months:{jan:"一月",feb:"二月",mar:"三月",apr:"四月",may:"五月",jun:"六月",jul:"七月",aug:"八月",sep:"九月",oct:"十月",nov:"十一月",dec:"十二月"}},inputNumber:{decrease:"减少数值",increase:"增加数值"},select:{loading:"加载中",noMatch:"无匹配数据",noData:"无数据",placeholder:"请选择"},dropdown:{toggleDropdown:"切换下拉选项"},mention:{loading:"加载中"},cascader:{noMatch:"无匹配数据",loading:"加载中",placeholder:"请选择",noData:"暂无数据"},pagination:{goto:"前往",pagesize:"条/页",total:"共 {total} 条",pageClassifier:"页",page:"页",prev:"上一页",next:"下一页",currentPage:"第 {pager} 页",prevPages:"向前 {pager} 页",nextPages:"向后 {pager} 页",deprecationWarning:"你使用了一些已被废弃的用法,请参考 el-pagination 的官方文档"},dialog:{close:"关闭此对话框"},drawer:{close:"关闭此对话框"},messagebox:{title:"提示",confirm:"确定",cancel:"取消",error:"输入的数据不合法!",close:"关闭此对话框"},upload:{deleteTip:"按 Delete 键可删除",delete:"删除",preview:"查看图片",continue:"继续上传"},slider:{defaultLabel:"滑块介于 {min} 至 {max}",defaultRangeStartLabel:"选择起始值",defaultRangeEndLabel:"选择结束值"},table:{emptyText:"暂无数据",confirmFilter:"筛选",resetFilter:"重置",clearFilter:"全部",sumText:"合计"},tour:{next:"下一步",previous:"上一步",finish:"结束导览"},tree:{emptyText:"暂无数据"},transfer:{noMatch:"无匹配数据",noData:"无数据",titles:["列表 1","列表 2"],filterPlaceholder:"请输入搜索内容",noCheckedFormat:"共 {total} 项",hasCheckedFormat:"已选 {checked}/{total} 项"},image:{error:"加载失败"},pageHeader:{title:"返回"},popconfirm:{confirmButtonText:"确定",cancelButtonText:"取消"},carousel:{leftArrow:"上一张幻灯片",rightArrow:"下一张幻灯片",indicator:"幻灯片切换至索引 {index}"}}};/*! *****************************************************************************
|
|
56
|
+
`;o.innerHTML=i,n.appendChild(o),(!e||e=="body")&&(o.style.position="fixed");const l=o.querySelectorAll(".loading-dots .loadot");l[0].style.backgroundColor=ph.loadingList[0],l[1].style.backgroundColor=ph.loadingList[1],l[2].style.backgroundColor=ph.loadingList[2],ph.name&&typeof ph.name=="string"&&ph.name.includes("black")&&(o.style.backgroundColor="rgba(0, 0, 0, 0.6)");const s={lg:16,md:12,sm:8,xs:5},u={lg:"12px",md:"10px",sm:"8px",xs:"4px"},c=o.querySelector(".loading-dots");c.style.gap=u[t]||"10px",l.forEach(d=>{d.style.width=`${s[t]}px`,d.style.height=`${s[t]}px`}),globalThis.gui.loading=vM})},done:function(e,t=0){a.nextTick(()=>{setTimeout(()=>{globalThis.gui.loading=vM,document.body.style.overflow="";const n=e?document.querySelector(`${e} .loading-next`):document.querySelector(".loading-next");n&&n.parentNode&&n.parentNode.removeChild(n)},t)})}};/*! js-cookie v3.0.5 | MIT */function QC(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)e[r]=n[r]}return e}var BVe={read:function(e){return e[0]==='"'&&(e=e.slice(1,-1)),e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(e){return encodeURIComponent(e).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}};function mM(e,t){function n(o,i,l){if(!(typeof document>"u")){l=QC({},t,l),typeof l.expires=="number"&&(l.expires=new Date(Date.now()+l.expires*864e5)),l.expires&&(l.expires=l.expires.toUTCString()),o=encodeURIComponent(o).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var s="";for(var u in l)l[u]&&(s+="; "+u,l[u]!==!0&&(s+="="+l[u].split(";")[0]));return document.cookie=o+"="+e.write(i,o)+s}}function r(o){if(!(typeof document>"u"||arguments.length&&!o)){for(var i=document.cookie?document.cookie.split("; "):[],l={},s=0;s<i.length;s++){var u=i[s].split("="),c=u.slice(1).join("=");try{var d=decodeURIComponent(u[0]);if(l[d]=e.read(c,d),o===d)break}catch{}}return o?l[o]:l}}return Object.create({set:n,get:r,remove:function(o,i){n(o,"",QC({},i,{expires:-1}))},withAttributes:function(o){return mM(this.converter,QC({},this.attributes,o))},withConverter:function(o){return mM(QC({},this.converter,o),this.attributes)}},{attributes:{value:Object.freeze(t)},converter:{value:Object.freeze(e)}})}var U_=mM(BVe,{path:"/"});function Zq(e,t={}){const{autoLoad:n=!0,watchParams:r,watchKeys:o,...i}=t,l=NVe(e),s=new LI(l,{...i}),u=a.reactive([...s.mergeData()]),c=s.reactiveStates,d=s.isLoading,f=s.hasError;s.onDataUpdate(()=>{const C=s.mergeData();u.length=0,u.push(...C)});const p=async C=>s.loadData(C);a.onMounted(()=>{n&&p()});const h=async(C,b)=>s.refreshData(C,b),v=async(C,b)=>C?s.refreshData(C,b):s.refreshAll(),m=async C=>s.refreshAll(C),g=async(C,b)=>s.refreshData(C,b,!0),y=C=>c[C];return r&&a.watch(typeof r=="function"?r:()=>r.value,async C=>{if(o&&o.length>0)for(const b of o)await h(b,C);else await m()},{deep:!0}),{_sourceInstance:s,sourceData:u,sourceState:c,isLoading:d,hasError:f,loadData:p,refreshData:h,reload:v,refreshAll:m,updateData:g,getState:y,mergeData:s.mergeData.bind(s),onDataUpdate:s.onDataUpdate.bind(s),clear:s.clear.bind(s),destroy:s.destroy.bind(s)}}const NVe=e=>{const t=(n,r)=>{if(!r)return n;const o=r.startsWith("/")?r.slice(1):r,i=o.includes("/")?"/":".";return String(o).split(i).reduce((l,s)=>l!=null&&s?l[s]:void 0,n)};if(e&&typeof e=="object"&&"path"in e){const n=e.fieldPath??e.resPath;return[{key:"legacy_obj_api",type:"api",api:{url:e.path,method:(e.method??"GET").toUpperCase(),params:e.params,data:e.data,headers:e.headers,transform:r=>{const o=t(r,n),i=typeof e.transformResponse=="function"?e.transformResponse(o):void 0,l=i!==void 0?i:o;return Array.isArray(l)?l:[l]}}}]}else return e},jn=async(e,t)=>{if(Array.isArray(e)){if(!e.every(r=>r&&typeof r=="object"&&"type"in r&&(r.type==="api"||r.type==="static")))return e}else{if(e&&typeof e=="object"&&!("path"in e))return[e];if(typeof e=="string"||typeof e=="number")return[{[t]:e}]}};function $n(e){return e&&typeof e=="object"&&"reactiveStates"in e&&"isLoading"in e&&"hasError"in e&&typeof e.loadData=="function"&&typeof e.refreshData=="function"&&typeof e.mergeData=="function"}function Ln(e){return e&&typeof e=="object"&&"sourceData"in e&&"_sourceInstance"in e&&typeof e.onDataUpdate=="function"}function Yn(e){return async t=>{const n=typeof window<"u"&&window.gui&&window.gui.guiDebug===!0||window.guiDebug===!0,r=(e==null?void 0:e.debug)===!0;if(!n&&!r)return;t.preventDefault();const o=e==null?void 0:e.data;Ln(o)?(console.log("🔍 [DataSource Debug] 右键触发调试,重新加载数据..."),o._sourceInstance.debugMode=!0,await o._sourceInstance.loadData(),console.log("✅ [DataSource Debug] 数据重新加载完成")):$n(o)&&(console.log("🔍 [DataSource Debug] 右键触发调试,重新加载数据..."),o.debugMode=!0,o.loadData(),console.log("✅ [DataSource Debug] 数据重新加载完成"))}}class LI{constructor(t,n={}){ys(this,"_configMap",new Map);ys(this,"_stateMap",new Map);ys(this,"_options");ys(this,"_listeners",new Set);ys(this,"reactiveStates",a.reactive({}));ys(this,"isLoading",a.ref(!1));ys(this,"hasError",a.ref(!1));ys(this,"debugMode",!1);ys(this,"pickPath",(t,n)=>{if(!n)return t;const r=n.startsWith("/")?n.slice(1):n,o=r.includes("/")?"/":".";return String(r).split(o).reduce((i,l)=>i!=null&&l?i[l]:void 0,t)});this._options={autoLoad:(n==null?void 0:n.autoLoad)||!1,retryCount:0,retryDelay:1e3,onRequest:i=>i,onResponse:i=>i,onError:()=>{},mergeTransformer:n.mergeTransformer,...n},this.cleanConfig(t).forEach(i=>{this.addSource(i)}),(this._options.autoLoad||this.isOldDataSource(t)&&((t==null?void 0:t.autoQuery)===!0||(t==null?void 0:t.autoQuery)===void 0))&&this.loadData()}addSource(t){this._configMap.set(t.key,t);const n={data:t.type==="static"?t.data??null:null,status:t.type==="static"?"success":"idle",error:null,lastUpdated:t.type==="static"?new Date:null};this._stateMap.set(t.key,n),this.reactiveStates[t.key]=n,t.type==="static"&&t.data!==void 0&&t.data!==null&&Promise.resolve().then(()=>{this.notifyListeners(t.key,t.data)})}removeSource(t){const n=this._configMap.delete(t);return this._stateMap.delete(t),delete this.reactiveStates[t],n}async loadSingle(t,n){const r=this._configMap.get(t);if(!r)throw new Error(`DataSource with key "${t}" not found`);this.updateState(t,{status:"loading",error:null});try{let o;if(r.type==="static")o=r.data;else if(r.type==="api"&&r.api)o=await this.fetchWithRetry(r,n);else throw new Error(`Invalid data source configuration for key "${t}"`);return this.updateState(t,{data:o,status:"success",error:null,lastUpdated:new Date}),this.notifyListeners(t,o),o}catch(o){const i=o instanceof Error?o:new Error(String(o));throw this.updateState(t,{status:"error",error:i}),this._options.onError(i,t),i}}async fetchWithRetry(t,n,r=0){var i;const o=t.api;try{const l=Xn.state["gui-ajax-config"]||{},s=typeof document<"u"&&((i=U_.get)==null?void 0:i.call(U_,"token"))||"",u=(l==null?void 0:l.token)||s,c={};if(u){const w=(l==null?void 0:l.tokenName)||"token";c[w]=u}l!=null&&l.sysCode&&(c.sysCode=l.sysCode),l!=null&&l.appType&&(c.appType=l.appType);const d={...c,...o.headers||{}},f={...o.headers||{}},p=t.key==="legacy_obj_api"?f:d;let h={url:o.url,method:o.method||"GET",headers:p};const v={...o.params,...n},m={...o.data,...n};h.method==="GET"?h.params=v:h.data=m,h=this._options.onRequest(h),this.debugMode&&console.log("🔍 [DataSource Debug] Request:",{url:h.url,method:h.method,params:h.params,data:h.data,fieldPath:o.fieldPath,retryCount:r,timestamp:new Date().toISOString()});const g=await ha(h),y=g.data;if(y&&typeof y=="object"&&y.code===999){const w=y.errorMsg||"Request failed with code 999";return fl&&fl.warning(w),[]}let C=this._options.onResponse(g.data),b=!1;if(o.fieldPath?(C=this.pickPath(C,o.fieldPath),b=!0):C&&typeof C=="object"&&"data"in C&&(C=this.pickPath(C,"data"),b=!0),o.transform){const w=C;let S=o.transform(w,y);C=S!==void 0?S:w}else b&&(C=Array.isArray(C)?C:[C]);return C}catch(l){if(r<this._options.retryCount)return await this.delay(this._options.retryDelay),this.fetchWithRetry(t,n,r+1);throw l}}delay(t){return new Promise(n=>setTimeout(n,t))}updateState(t,n){const r=this._stateMap.get(t);if(r){const o={...r,...n};this._stateMap.set(t,o),Object.assign(this.reactiveStates[t],o)}this.updateGlobalStatus()}updateGlobalStatus(){let t=!1,n=!1;this._stateMap.forEach(r=>{r.status==="loading"&&(t=!0),r.status==="error"&&(n=!0)}),this.isLoading&&typeof this.isLoading=="object"&&"value"in this.isLoading?this.isLoading.value=t:this.isLoading=a.ref(t),this.hasError&&typeof this.hasError=="object"&&"value"in this.hasError?this.hasError.value=n:this.hasError=a.ref(n)}notifyListeners(t,n){const r=this._stateMap.get(t);r&&this._listeners.forEach(o=>{o(t,n,r)})}normalizeMethod(t){const n=String(t??"GET").toUpperCase();return n==="POST"||n==="PUT"||n==="DELETE"?n:"GET"}isOldDataSource(t){if(!t||Array.isArray(t)||Object.getPrototypeOf(t)!==Object.prototype)return!1;const n=t.type;return!!(n!=="api"&&n!=="static")}cleanConfig(t){var n;if(this.isOldDataSource(t)){const r=t.fieldPath??t.resPath,o=t.key?((n=Xn.state["gui-ajax-config"])==null?void 0:n[t.key])??{}:Xn.state["gui-ajax-config"]??{},i={};o!=null&&o.tokenName&&(o!=null&&o.token)&&(i[o.tokenName]=o.token),o!=null&&o.sysCode&&(i.sysCode=o.sysCode),o!=null&&o.appType&&(i.appType=o.appType);const l={...i,...t.headers||{}};return[{key:"legacy_obj_api",type:"api",api:{url:t.path,method:this.normalizeMethod(t.method),params:t.params||t.data,data:t.data||t.params,headers:l,...r?{fieldPath:r}:{},transform:(s,u)=>{const c=typeof t.transformResponse=="function"?t.transformResponse(s,u):void 0;return c!==void 0?c:s}}}]}else return t}async loadData(t){const r=(t?Array.isArray(t)?t:[t]:Array.from(this._configMap.keys()).filter(o=>{var i;return((i=this._configMap.get(o))==null?void 0:i.type)==="api"})).map(o=>this.loadSingle(o).then(i=>({key:o,data:i,success:!0})).catch(i=>({key:o,error:i,success:!1})));return await Promise.all(r),this.mergeData()}async refreshData(t,n,r){if(!this._configMap.has(t))throw new Error(`DataSource with key "${t}" not found`);if(r){const i=n;return this.updateState(t,{data:i,status:"success",lastUpdated:new Date}),this.notifyListeners(t,i),i}const o=this._configMap.get(t);if(o.type==="api"&&o.api&&n&&typeof n=="object"&&!Array.isArray(n)){const i={...n};return"_url"in i&&(o.api.url=i._url,delete i._url),(o.api.method||"GET")==="GET"?o.api.params={...o.api.params||{},...i}:o.api.data={...o.api.data||{},...i},this._configMap.set(t,o),this.loadSingle(t)}return this.loadSingle(t,n)}async refreshAll(t){const r=Array.from(this._configMap.keys()).map(o=>{const i=t==null?void 0:t[o];return this.refreshData(o,i).then(l=>({key:o,data:l,success:!0})).catch(l=>({key:o,error:l,success:!1}))});return await Promise.all(r),this.mergeData()}getData(t){var n;return(n=this._stateMap.get(t))==null?void 0:n.data}getAllData(){const t={};return this._stateMap.forEach((n,r)=>{t[r]=n.data}),t}getState(t){return this._stateMap.get(t)}getAllStates(){const t={};return this._stateMap.forEach((n,r)=>{t[r]=n}),t}getLoadingStatus(t){var n;return((n=this._stateMap.get(t))==null?void 0:n.status)??"idle"}isSourceLoading(t){return this.getLoadingStatus(t)==="loading"}onDataUpdate(t){return this._listeners.add(t),()=>{this._listeners.delete(t)}}mergeData(t){const n=t||this._options.mergeTransformer,r=this.getAllData();if(n)return n(r);const o=Object.values(r);return o.length===1?o[0]||[]:o.flat()}clear(){this._configMap.forEach((t,n)=>{this.updateState(n,{data:null,status:"idle",error:null,lastUpdated:null})})}destroy(){this._configMap.clear(),this._stateMap.clear(),this._listeners.clear(),Object.keys(this.reactiveStates).forEach(t=>{delete this.reactiveStates[t]})}reload(t,n){if(typeof t=="string")return this.refreshData(t,n);if(t&&typeof t=="object"&&!n){const r=Array.from(this._configMap.keys());if(r.length===1)return this.refreshData(r[0],t);const o={};return r.forEach(i=>{o[i]=t}),this.refreshAll(o)}return t?this.refreshAll(t):this.refreshAll()}}var OVe={name:"zh-cn",el:{breadcrumb:{label:"面包屑"},colorpicker:{confirm:"确定",clear:"清空",defaultLabel:"颜色选择器",description:"当前颜色 {color},按 Enter 键选择新颜色",alphaLabel:"选择透明度的值"},datepicker:{now:"此刻",today:"今天",cancel:"取消",clear:"清空",confirm:"确定",dateTablePrompt:"使用方向键与 Enter 键可选择日期",monthTablePrompt:"使用方向键与 Enter 键可选择月份",yearTablePrompt:"使用方向键与 Enter 键可选择年份",selectedDate:"已选日期",selectDate:"选择日期",selectTime:"选择时间",startDate:"开始日期",startTime:"开始时间",endDate:"结束日期",endTime:"结束时间",prevYear:"前一年",nextYear:"后一年",prevMonth:"上个月",nextMonth:"下个月",year:"年",month1:"1 月",month2:"2 月",month3:"3 月",month4:"4 月",month5:"5 月",month6:"6 月",month7:"7 月",month8:"8 月",month9:"9 月",month10:"10 月",month11:"11 月",month12:"12 月",weeks:{sun:"日",mon:"一",tue:"二",wed:"三",thu:"四",fri:"五",sat:"六"},weeksFull:{sun:"星期日",mon:"星期一",tue:"星期二",wed:"星期三",thu:"星期四",fri:"星期五",sat:"星期六"},months:{jan:"一月",feb:"二月",mar:"三月",apr:"四月",may:"五月",jun:"六月",jul:"七月",aug:"八月",sep:"九月",oct:"十月",nov:"十一月",dec:"十二月"}},inputNumber:{decrease:"减少数值",increase:"增加数值"},select:{loading:"加载中",noMatch:"无匹配数据",noData:"无数据",placeholder:"请选择"},dropdown:{toggleDropdown:"切换下拉选项"},mention:{loading:"加载中"},cascader:{noMatch:"无匹配数据",loading:"加载中",placeholder:"请选择",noData:"暂无数据"},pagination:{goto:"前往",pagesize:"条/页",total:"共 {total} 条",pageClassifier:"页",page:"页",prev:"上一页",next:"下一页",currentPage:"第 {pager} 页",prevPages:"向前 {pager} 页",nextPages:"向后 {pager} 页",deprecationWarning:"你使用了一些已被废弃的用法,请参考 el-pagination 的官方文档"},dialog:{close:"关闭此对话框"},drawer:{close:"关闭此对话框"},messagebox:{title:"提示",confirm:"确定",cancel:"取消",error:"输入的数据不合法!",close:"关闭此对话框"},upload:{deleteTip:"按 Delete 键可删除",delete:"删除",preview:"查看图片",continue:"继续上传"},slider:{defaultLabel:"滑块介于 {min} 至 {max}",defaultRangeStartLabel:"选择起始值",defaultRangeEndLabel:"选择结束值"},table:{emptyText:"暂无数据",confirmFilter:"筛选",resetFilter:"重置",clearFilter:"全部",sumText:"合计"},tour:{next:"下一步",previous:"上一步",finish:"结束导览"},tree:{emptyText:"暂无数据"},transfer:{noMatch:"无匹配数据",noData:"无数据",titles:["列表 1","列表 2"],filterPlaceholder:"请输入搜索内容",noCheckedFormat:"共 {total} 项",hasCheckedFormat:"已选 {checked}/{total} 项"},image:{error:"加载失败"},pageHeader:{title:"返回"},popconfirm:{confirmButtonText:"确定",cancelButtonText:"取消"},carousel:{leftArrow:"上一张幻灯片",rightArrow:"下一张幻灯片",indicator:"幻灯片切换至索引 {index}"}}};/*! *****************************************************************************
|
|
57
57
|
Copyright (c) Microsoft Corporation.
|
|
58
58
|
|
|
59
59
|
Permission to use, copy, modify, and/or distribute this software for any
|
package/lib/g-ui-web.iife.js
CHANGED
|
@@ -53,7 +53,7 @@ var Bkt=Object.defineProperty;var Okt=(st,a,eh)=>a in st?Bkt(st,a,{enumerable:!0
|
|
|
53
53
|
<div class="loadot"></div>
|
|
54
54
|
<div class="loadot"></div>
|
|
55
55
|
</div>
|
|
56
|
-
`;o.innerHTML=i,n.appendChild(o),(!e||e=="body")&&(o.style.position="fixed");const l=o.querySelectorAll(".loading-dots .loadot");l[0].style.backgroundColor=am.loadingList[0],l[1].style.backgroundColor=am.loadingList[1],l[2].style.backgroundColor=am.loadingList[2],am.name&&typeof am.name=="string"&&am.name.includes("black")&&(o.style.backgroundColor="rgba(0, 0, 0, 0.6)");const s={lg:16,md:12,sm:8,xs:5},c={lg:"12px",md:"10px",sm:"8px",xs:"4px"},d=o.querySelector(".loading-dots");d.style.gap=c[t]||"10px",l.forEach(u=>{u.style.width=`${s[t]}px`,u.style.height=`${s[t]}px`}),globalThis.gui.loading=iD})},done:function(e,t=0){a.nextTick(()=>{setTimeout(()=>{globalThis.gui.loading=iD,document.body.style.overflow="";const n=e?document.querySelector(`${e} .loading-next`):document.querySelector(".loading-next");n&&n.parentNode&&n.parentNode.removeChild(n)},t)})}};/*! js-cookie v3.0.5 | MIT */function y1(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)e[r]=n[r]}return e}var iLe={read:function(e){return e[0]==='"'&&(e=e.slice(1,-1)),e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(e){return encodeURIComponent(e).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}};function lD(e,t){function n(o,i,l){if(!(typeof document>"u")){l=y1({},t,l),typeof l.expires=="number"&&(l.expires=new Date(Date.now()+l.expires*864e5)),l.expires&&(l.expires=l.expires.toUTCString()),o=encodeURIComponent(o).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var s="";for(var c in l)l[c]&&(s+="; "+c,l[c]!==!0&&(s+="="+l[c].split(";")[0]));return document.cookie=o+"="+e.write(i,o)+s}}function r(o){if(!(typeof document>"u"||arguments.length&&!o)){for(var i=document.cookie?document.cookie.split("; "):[],l={},s=0;s<i.length;s++){var c=i[s].split("="),d=c.slice(1).join("=");try{var u=decodeURIComponent(c[0]);if(l[u]=e.read(d,u),o===u)break}catch{}}return o?l[o]:l}}return Object.create({set:n,get:r,remove:function(o,i){n(o,"",y1({},i,{expires:-1}))},withAttributes:function(o){return lD(this.converter,y1({},this.attributes,o))},withConverter:function(o){return lD(y1({},this.converter,o),this.attributes)}},{attributes:{value:Object.freeze(t)},converter:{value:Object.freeze(e)}})}var sD=lD(iLe,{path:"/"});function aH(e,t={}){const{autoLoad:n=!0,watchParams:r,watchKeys:o,...i}=t,l=lLe(e),s=new cD(l,{...i}),c=a.reactive([...s.mergeData()]),d=s.reactiveStates,u=s.isLoading,f=s.hasError;s.onDataUpdate(()=>{const C=s.mergeData();c.length=0,c.push(...C)});const p=async C=>s.loadData(C);a.onMounted(()=>{n&&p()});const h=async(C,b)=>s.refreshData(C,b),m=async(C,b)=>C?s.refreshData(C,b):s.refreshAll(),g=async C=>s.refreshAll(C),v=async(C,b)=>s.refreshData(C,b,!0),y=C=>d[C];return r&&a.watch(typeof r=="function"?r:()=>r.value,async C=>{if(o&&o.length>0)for(const b of o)await h(b,C);else await g()},{deep:!0}),{_sourceInstance:s,sourceData:c,sourceState:d,isLoading:u,hasError:f,loadData:p,refreshData:h,reload:m,refreshAll:g,updateData:v,getState:y,mergeData:s.mergeData.bind(s),onDataUpdate:s.onDataUpdate.bind(s),clear:s.clear.bind(s),destroy:s.destroy.bind(s)}}const lLe=e=>{const t=(n,r)=>{if(!r)return n;const o=r.startsWith("/")?r.slice(1):r,i=o.includes("/")?"/":".";return String(o).split(i).reduce((l,s)=>l!=null&&s?l[s]:void 0,n)};if(e&&typeof e=="object"&&"path"in e){const n=e.fieldPath??e.resPath;return[{key:"legacy_obj_api",type:"api",api:{url:e.path,method:(e.method??"GET").toUpperCase(),params:e.params,data:e.data,headers:e.headers,transform:r=>{const o=t(r,n),i=typeof e.transformResponse=="function"?e.transformResponse(o):void 0,l=i!==void 0?i:o;return Array.isArray(l)?l:[l]}}}]}else return e},Wn=async(e,t)=>{if(Array.isArray(e)){if(!e.every(r=>r&&typeof r=="object"&&"type"in r&&(r.type==="api"||r.type==="static")))return e}else{if(e&&typeof e=="object"&&!("path"in e))return[e];if(typeof e=="string"||typeof e=="number")return[{[t]:e}]}};function Hn(e){return e&&typeof e=="object"&&"reactiveStates"in e&&"isLoading"in e&&"hasError"in e&&typeof e.loadData=="function"&&typeof e.refreshData=="function"&&typeof e.mergeData=="function"}function Ln(e){return e&&typeof e=="object"&&"sourceData"in e&&"_sourceInstance"in e&&typeof e.onDataUpdate=="function"}function Gn(e){return async t=>{const n=typeof window<"u"&&window.gui&&window.gui.guiDebug===!0||window.guiDebug===!0,r=(e==null?void 0:e.debug)===!0;if(!n&&!r)return;t.preventDefault();const o=e==null?void 0:e.data;Ln(o)?(console.log("🔍 [DataSource Debug] 右键触发调试,重新加载数据..."),o._sourceInstance.debugMode=!0,await o._sourceInstance.loadData(),console.log("✅ [DataSource Debug] 数据重新加载完成")):Hn(o)&&(console.log("🔍 [DataSource Debug] 右键触发调试,重新加载数据..."),o.debugMode=!0,o.loadData(),console.log("✅ [DataSource Debug] 数据重新加载完成"))}}class cD{constructor(t,n={}){gc(this,"_configMap",new Map);gc(this,"_stateMap",new Map);gc(this,"_options");gc(this,"_listeners",new Set);gc(this,"reactiveStates",a.reactive({}));gc(this,"isLoading",a.ref(!1));gc(this,"hasError",a.ref(!1));gc(this,"debugMode",!1);gc(this,"pickPath",(t,n)=>{if(!n)return t;const r=n.startsWith("/")?n.slice(1):n,o=r.includes("/")?"/":".";return String(r).split(o).reduce((i,l)=>i!=null&&l?i[l]:void 0,t)});this._options={autoLoad:(n==null?void 0:n.autoLoad)||!1,retryCount:0,retryDelay:1e3,onRequest:i=>i,onResponse:i=>i,onError:()=>{},mergeTransformer:n.mergeTransformer,...n},this.cleanConfig(t).forEach(i=>{this.addSource(i)}),(this._options.autoLoad||this.isOldDataSource(t)&&((t==null?void 0:t.autoQuery)===!0||(t==null?void 0:t.autoQuery)===void 0))&&this.loadData()}addSource(t){this._configMap.set(t.key,t);const n={data:t.type==="static"?t.data??null:null,status:t.type==="static"?"success":"idle",error:null,lastUpdated:t.type==="static"?new Date:null};this._stateMap.set(t.key,n),this.reactiveStates[t.key]=n,t.type==="static"&&t.data!==void 0&&t.data!==null&&Promise.resolve().then(()=>{this.notifyListeners(t.key,t.data)})}removeSource(t){const n=this._configMap.delete(t);return this._stateMap.delete(t),delete this.reactiveStates[t],n}async loadSingle(t,n){const r=this._configMap.get(t);if(!r)throw new Error(`DataSource with key "${t}" not found`);this.updateState(t,{status:"loading",error:null});try{let o;if(r.type==="static")o=r.data;else if(r.type==="api"&&r.api)o=await this.fetchWithRetry(r,n);else throw new Error(`Invalid data source configuration for key "${t}"`);return this.updateState(t,{data:o,status:"success",error:null,lastUpdated:new Date}),this.notifyListeners(t,o),o}catch(o){const i=o instanceof Error?o:new Error(String(o));throw this.updateState(t,{status:"error",error:i}),this._options.onError(i,t),i}}async fetchWithRetry(t,n,r=0){var i;const o=t.api;try{const l=qn.state["gui-ajax-config"]||{},s=typeof document<"u"&&((i=sD.get)==null?void 0:i.call(sD,"token"))||"",c=(l==null?void 0:l.token)||s,d={};if(c){const w=(l==null?void 0:l.tokenName)||"token";d[w]=c}l!=null&&l.sysCode&&(d.sysCode=l.sysCode),l!=null&&l.appType&&(d.appType=l.appType);const u={...d,...o.headers||{}},f={...o.headers||{}},p=t.key==="legacy_obj_api"?f:u;let h={url:o.url,method:o.method||"GET",headers:p};const m={...o.params,...n},g={...o.data,...n};h.method==="GET"?h.params=m:h.data=g,h=this._options.onRequest(h),this.debugMode&&console.log("🔍 [DataSource Debug] Request:",{url:h.url,method:h.method,params:h.params,data:h.data,fieldPath:o.fieldPath,retryCount:r,timestamp:new Date().toISOString()});const v=await sa(h),y=v.data;if(y&&typeof y=="object"&&y.code===999){const w=y.errorMsg||"Request failed with code 999";return Xi&&Xi.warning(w),[]}let C=this._options.onResponse(v.data),b=!1;if(o.fieldPath?(C=this.pickPath(C,o.fieldPath),b=!0):C&&typeof C=="object"&&"data"in C&&(C=this.pickPath(C,"data"),b=!0),o.transform){const w=C;let S=o.transform(w,y);C=S!==void 0?S:w}else b&&(C=Array.isArray(C)?C:[C]);return C}catch(l){if(r<this._options.retryCount)return await this.delay(this._options.retryDelay),this.fetchWithRetry(t,n,r+1);throw l}}delay(t){return new Promise(n=>setTimeout(n,t))}updateState(t,n){const r=this._stateMap.get(t);if(r){const o={...r,...n};this._stateMap.set(t,o),Object.assign(this.reactiveStates[t],o)}this.updateGlobalStatus()}updateGlobalStatus(){let t=!1,n=!1;this._stateMap.forEach(r=>{r.status==="loading"&&(t=!0),r.status==="error"&&(n=!0)}),this.isLoading&&typeof this.isLoading=="object"&&"value"in this.isLoading?this.isLoading.value=t:this.isLoading=a.ref(t),this.hasError&&typeof this.hasError=="object"&&"value"in this.hasError?this.hasError.value=n:this.hasError=a.ref(n)}notifyListeners(t,n){const r=this._stateMap.get(t);r&&this._listeners.forEach(o=>{o(t,n,r)})}normalizeMethod(t){const n=String(t??"GET").toUpperCase();return n==="POST"||n==="PUT"||n==="DELETE"?n:"GET"}isOldDataSource(t){if(!t||Array.isArray(t)||Object.getPrototypeOf(t)!==Object.prototype)return!1;const n=t.type;return!!(n!=="api"&&n!=="static")}cleanConfig(t){var n;if(this.isOldDataSource(t)){const r=t.fieldPath??t.resPath,o=t.key?((n=qn.state["gui-ajax-config"])==null?void 0:n[t.key])??{}:qn.state["gui-ajax-config"]??{},i={};o!=null&&o.tokenName&&(o!=null&&o.token)&&(i[o.tokenName]=o.token),o!=null&&o.sysCode&&(i.sysCode=o.sysCode),o!=null&&o.appType&&(i.appType=o.appType);const l={...i,...t.headers||{}};return[{key:"legacy_obj_api",type:"api",api:{url:t.path,method:this.normalizeMethod(t.method),params:t.params||t.data,data:t.data||t.params,headers:l,...r?{fieldPath:r}:{},transform:(s,c)=>{const d=typeof t.transformResponse=="function"?t.transformResponse(s,c):void 0;return d!==void 0?d:s}}}]}else return t}async loadData(t){const r=(t?Array.isArray(t)?t:[t]:Array.from(this._configMap.keys()).filter(o=>{var i;return((i=this._configMap.get(o))==null?void 0:i.type)==="api"})).map(o=>this.loadSingle(o).then(i=>({key:o,data:i,success:!0})).catch(i=>({key:o,error:i,success:!1})));return await Promise.all(r),this.mergeData()}async refreshData(t,n,r){if(!this._configMap.has(t))throw new Error(`DataSource with key "${t}" not found`);if(r){const i=n;return this.updateState(t,{data:i,status:"success",lastUpdated:new Date}),this.notifyListeners(t,i),i}const o=this._configMap.get(t);if(o.type==="api"&&o.api&&n&&typeof n=="object"&&!Array.isArray(n)){const i=n;return(o.api.method||"GET")==="GET"?o.api.params={...o.api.params||{},...i}:o.api.data={...o.api.data||{},...i},this._configMap.set(t,o),this.loadSingle(t)}return this.loadSingle(t,n)}async refreshAll(t){const r=Array.from(this._configMap.keys()).map(o=>{const i=t==null?void 0:t[o];return this.refreshData(o,i).then(l=>({key:o,data:l,success:!0})).catch(l=>({key:o,error:l,success:!1}))});return await Promise.all(r),this.mergeData()}getData(t){var n;return(n=this._stateMap.get(t))==null?void 0:n.data}getAllData(){const t={};return this._stateMap.forEach((n,r)=>{t[r]=n.data}),t}getState(t){return this._stateMap.get(t)}getAllStates(){const t={};return this._stateMap.forEach((n,r)=>{t[r]=n}),t}getLoadingStatus(t){var n;return((n=this._stateMap.get(t))==null?void 0:n.status)??"idle"}isSourceLoading(t){return this.getLoadingStatus(t)==="loading"}onDataUpdate(t){return this._listeners.add(t),()=>{this._listeners.delete(t)}}mergeData(t){const n=t||this._options.mergeTransformer,r=this.getAllData();if(n)return n(r);const o=Object.values(r);return o.length===1?o[0]||[]:o.flat()}clear(){this._configMap.forEach((t,n)=>{this.updateState(n,{data:null,status:"idle",error:null,lastUpdated:null})})}destroy(){this._configMap.clear(),this._stateMap.clear(),this._listeners.clear(),Object.keys(this.reactiveStates).forEach(t=>{delete this.reactiveStates[t]})}reload(t,n){if(typeof t=="string")return this.refreshData(t,n);if(t&&typeof t=="object"&&!n){const r=Array.from(this._configMap.keys());if(r.length===1)return this.refreshData(r[0],t);const o={};return r.forEach(i=>{o[i]=t}),this.refreshAll(o)}return t?this.refreshAll(t):this.refreshAll()}}var sLe={name:"zh-cn",el:{breadcrumb:{label:"面包屑"},colorpicker:{confirm:"确定",clear:"清空",defaultLabel:"颜色选择器",description:"当前颜色 {color},按 Enter 键选择新颜色",alphaLabel:"选择透明度的值"},datepicker:{now:"此刻",today:"今天",cancel:"取消",clear:"清空",confirm:"确定",dateTablePrompt:"使用方向键与 Enter 键可选择日期",monthTablePrompt:"使用方向键与 Enter 键可选择月份",yearTablePrompt:"使用方向键与 Enter 键可选择年份",selectedDate:"已选日期",selectDate:"选择日期",selectTime:"选择时间",startDate:"开始日期",startTime:"开始时间",endDate:"结束日期",endTime:"结束时间",prevYear:"前一年",nextYear:"后一年",prevMonth:"上个月",nextMonth:"下个月",year:"年",month1:"1 月",month2:"2 月",month3:"3 月",month4:"4 月",month5:"5 月",month6:"6 月",month7:"7 月",month8:"8 月",month9:"9 月",month10:"10 月",month11:"11 月",month12:"12 月",weeks:{sun:"日",mon:"一",tue:"二",wed:"三",thu:"四",fri:"五",sat:"六"},weeksFull:{sun:"星期日",mon:"星期一",tue:"星期二",wed:"星期三",thu:"星期四",fri:"星期五",sat:"星期六"},months:{jan:"一月",feb:"二月",mar:"三月",apr:"四月",may:"五月",jun:"六月",jul:"七月",aug:"八月",sep:"九月",oct:"十月",nov:"十一月",dec:"十二月"}},inputNumber:{decrease:"减少数值",increase:"增加数值"},select:{loading:"加载中",noMatch:"无匹配数据",noData:"无数据",placeholder:"请选择"},dropdown:{toggleDropdown:"切换下拉选项"},mention:{loading:"加载中"},cascader:{noMatch:"无匹配数据",loading:"加载中",placeholder:"请选择",noData:"暂无数据"},pagination:{goto:"前往",pagesize:"条/页",total:"共 {total} 条",pageClassifier:"页",page:"页",prev:"上一页",next:"下一页",currentPage:"第 {pager} 页",prevPages:"向前 {pager} 页",nextPages:"向后 {pager} 页",deprecationWarning:"你使用了一些已被废弃的用法,请参考 el-pagination 的官方文档"},dialog:{close:"关闭此对话框"},drawer:{close:"关闭此对话框"},messagebox:{title:"提示",confirm:"确定",cancel:"取消",error:"输入的数据不合法!",close:"关闭此对话框"},upload:{deleteTip:"按 Delete 键可删除",delete:"删除",preview:"查看图片",continue:"继续上传"},slider:{defaultLabel:"滑块介于 {min} 至 {max}",defaultRangeStartLabel:"选择起始值",defaultRangeEndLabel:"选择结束值"},table:{emptyText:"暂无数据",confirmFilter:"筛选",resetFilter:"重置",clearFilter:"全部",sumText:"合计"},tour:{next:"下一步",previous:"上一步",finish:"结束导览"},tree:{emptyText:"暂无数据"},transfer:{noMatch:"无匹配数据",noData:"无数据",titles:["列表 1","列表 2"],filterPlaceholder:"请输入搜索内容",noCheckedFormat:"共 {total} 项",hasCheckedFormat:"已选 {checked}/{total} 项"},image:{error:"加载失败"},pageHeader:{title:"返回"},popconfirm:{confirmButtonText:"确定",cancelButtonText:"取消"},carousel:{leftArrow:"上一张幻灯片",rightArrow:"下一张幻灯片",indicator:"幻灯片切换至索引 {index}"}}};/*! *****************************************************************************
|
|
56
|
+
`;o.innerHTML=i,n.appendChild(o),(!e||e=="body")&&(o.style.position="fixed");const l=o.querySelectorAll(".loading-dots .loadot");l[0].style.backgroundColor=am.loadingList[0],l[1].style.backgroundColor=am.loadingList[1],l[2].style.backgroundColor=am.loadingList[2],am.name&&typeof am.name=="string"&&am.name.includes("black")&&(o.style.backgroundColor="rgba(0, 0, 0, 0.6)");const s={lg:16,md:12,sm:8,xs:5},c={lg:"12px",md:"10px",sm:"8px",xs:"4px"},d=o.querySelector(".loading-dots");d.style.gap=c[t]||"10px",l.forEach(u=>{u.style.width=`${s[t]}px`,u.style.height=`${s[t]}px`}),globalThis.gui.loading=iD})},done:function(e,t=0){a.nextTick(()=>{setTimeout(()=>{globalThis.gui.loading=iD,document.body.style.overflow="";const n=e?document.querySelector(`${e} .loading-next`):document.querySelector(".loading-next");n&&n.parentNode&&n.parentNode.removeChild(n)},t)})}};/*! js-cookie v3.0.5 | MIT */function y1(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)e[r]=n[r]}return e}var iLe={read:function(e){return e[0]==='"'&&(e=e.slice(1,-1)),e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(e){return encodeURIComponent(e).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}};function lD(e,t){function n(o,i,l){if(!(typeof document>"u")){l=y1({},t,l),typeof l.expires=="number"&&(l.expires=new Date(Date.now()+l.expires*864e5)),l.expires&&(l.expires=l.expires.toUTCString()),o=encodeURIComponent(o).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var s="";for(var c in l)l[c]&&(s+="; "+c,l[c]!==!0&&(s+="="+l[c].split(";")[0]));return document.cookie=o+"="+e.write(i,o)+s}}function r(o){if(!(typeof document>"u"||arguments.length&&!o)){for(var i=document.cookie?document.cookie.split("; "):[],l={},s=0;s<i.length;s++){var c=i[s].split("="),d=c.slice(1).join("=");try{var u=decodeURIComponent(c[0]);if(l[u]=e.read(d,u),o===u)break}catch{}}return o?l[o]:l}}return Object.create({set:n,get:r,remove:function(o,i){n(o,"",y1({},i,{expires:-1}))},withAttributes:function(o){return lD(this.converter,y1({},this.attributes,o))},withConverter:function(o){return lD(y1({},this.converter,o),this.attributes)}},{attributes:{value:Object.freeze(t)},converter:{value:Object.freeze(e)}})}var sD=lD(iLe,{path:"/"});function aH(e,t={}){const{autoLoad:n=!0,watchParams:r,watchKeys:o,...i}=t,l=lLe(e),s=new cD(l,{...i}),c=a.reactive([...s.mergeData()]),d=s.reactiveStates,u=s.isLoading,f=s.hasError;s.onDataUpdate(()=>{const C=s.mergeData();c.length=0,c.push(...C)});const p=async C=>s.loadData(C);a.onMounted(()=>{n&&p()});const h=async(C,b)=>s.refreshData(C,b),m=async(C,b)=>C?s.refreshData(C,b):s.refreshAll(),g=async C=>s.refreshAll(C),v=async(C,b)=>s.refreshData(C,b,!0),y=C=>d[C];return r&&a.watch(typeof r=="function"?r:()=>r.value,async C=>{if(o&&o.length>0)for(const b of o)await h(b,C);else await g()},{deep:!0}),{_sourceInstance:s,sourceData:c,sourceState:d,isLoading:u,hasError:f,loadData:p,refreshData:h,reload:m,refreshAll:g,updateData:v,getState:y,mergeData:s.mergeData.bind(s),onDataUpdate:s.onDataUpdate.bind(s),clear:s.clear.bind(s),destroy:s.destroy.bind(s)}}const lLe=e=>{const t=(n,r)=>{if(!r)return n;const o=r.startsWith("/")?r.slice(1):r,i=o.includes("/")?"/":".";return String(o).split(i).reduce((l,s)=>l!=null&&s?l[s]:void 0,n)};if(e&&typeof e=="object"&&"path"in e){const n=e.fieldPath??e.resPath;return[{key:"legacy_obj_api",type:"api",api:{url:e.path,method:(e.method??"GET").toUpperCase(),params:e.params,data:e.data,headers:e.headers,transform:r=>{const o=t(r,n),i=typeof e.transformResponse=="function"?e.transformResponse(o):void 0,l=i!==void 0?i:o;return Array.isArray(l)?l:[l]}}}]}else return e},Wn=async(e,t)=>{if(Array.isArray(e)){if(!e.every(r=>r&&typeof r=="object"&&"type"in r&&(r.type==="api"||r.type==="static")))return e}else{if(e&&typeof e=="object"&&!("path"in e))return[e];if(typeof e=="string"||typeof e=="number")return[{[t]:e}]}};function Hn(e){return e&&typeof e=="object"&&"reactiveStates"in e&&"isLoading"in e&&"hasError"in e&&typeof e.loadData=="function"&&typeof e.refreshData=="function"&&typeof e.mergeData=="function"}function Ln(e){return e&&typeof e=="object"&&"sourceData"in e&&"_sourceInstance"in e&&typeof e.onDataUpdate=="function"}function Gn(e){return async t=>{const n=typeof window<"u"&&window.gui&&window.gui.guiDebug===!0||window.guiDebug===!0,r=(e==null?void 0:e.debug)===!0;if(!n&&!r)return;t.preventDefault();const o=e==null?void 0:e.data;Ln(o)?(console.log("🔍 [DataSource Debug] 右键触发调试,重新加载数据..."),o._sourceInstance.debugMode=!0,await o._sourceInstance.loadData(),console.log("✅ [DataSource Debug] 数据重新加载完成")):Hn(o)&&(console.log("🔍 [DataSource Debug] 右键触发调试,重新加载数据..."),o.debugMode=!0,o.loadData(),console.log("✅ [DataSource Debug] 数据重新加载完成"))}}class cD{constructor(t,n={}){gc(this,"_configMap",new Map);gc(this,"_stateMap",new Map);gc(this,"_options");gc(this,"_listeners",new Set);gc(this,"reactiveStates",a.reactive({}));gc(this,"isLoading",a.ref(!1));gc(this,"hasError",a.ref(!1));gc(this,"debugMode",!1);gc(this,"pickPath",(t,n)=>{if(!n)return t;const r=n.startsWith("/")?n.slice(1):n,o=r.includes("/")?"/":".";return String(r).split(o).reduce((i,l)=>i!=null&&l?i[l]:void 0,t)});this._options={autoLoad:(n==null?void 0:n.autoLoad)||!1,retryCount:0,retryDelay:1e3,onRequest:i=>i,onResponse:i=>i,onError:()=>{},mergeTransformer:n.mergeTransformer,...n},this.cleanConfig(t).forEach(i=>{this.addSource(i)}),(this._options.autoLoad||this.isOldDataSource(t)&&((t==null?void 0:t.autoQuery)===!0||(t==null?void 0:t.autoQuery)===void 0))&&this.loadData()}addSource(t){this._configMap.set(t.key,t);const n={data:t.type==="static"?t.data??null:null,status:t.type==="static"?"success":"idle",error:null,lastUpdated:t.type==="static"?new Date:null};this._stateMap.set(t.key,n),this.reactiveStates[t.key]=n,t.type==="static"&&t.data!==void 0&&t.data!==null&&Promise.resolve().then(()=>{this.notifyListeners(t.key,t.data)})}removeSource(t){const n=this._configMap.delete(t);return this._stateMap.delete(t),delete this.reactiveStates[t],n}async loadSingle(t,n){const r=this._configMap.get(t);if(!r)throw new Error(`DataSource with key "${t}" not found`);this.updateState(t,{status:"loading",error:null});try{let o;if(r.type==="static")o=r.data;else if(r.type==="api"&&r.api)o=await this.fetchWithRetry(r,n);else throw new Error(`Invalid data source configuration for key "${t}"`);return this.updateState(t,{data:o,status:"success",error:null,lastUpdated:new Date}),this.notifyListeners(t,o),o}catch(o){const i=o instanceof Error?o:new Error(String(o));throw this.updateState(t,{status:"error",error:i}),this._options.onError(i,t),i}}async fetchWithRetry(t,n,r=0){var i;const o=t.api;try{const l=qn.state["gui-ajax-config"]||{},s=typeof document<"u"&&((i=sD.get)==null?void 0:i.call(sD,"token"))||"",c=(l==null?void 0:l.token)||s,d={};if(c){const w=(l==null?void 0:l.tokenName)||"token";d[w]=c}l!=null&&l.sysCode&&(d.sysCode=l.sysCode),l!=null&&l.appType&&(d.appType=l.appType);const u={...d,...o.headers||{}},f={...o.headers||{}},p=t.key==="legacy_obj_api"?f:u;let h={url:o.url,method:o.method||"GET",headers:p};const m={...o.params,...n},g={...o.data,...n};h.method==="GET"?h.params=m:h.data=g,h=this._options.onRequest(h),this.debugMode&&console.log("🔍 [DataSource Debug] Request:",{url:h.url,method:h.method,params:h.params,data:h.data,fieldPath:o.fieldPath,retryCount:r,timestamp:new Date().toISOString()});const v=await sa(h),y=v.data;if(y&&typeof y=="object"&&y.code===999){const w=y.errorMsg||"Request failed with code 999";return Xi&&Xi.warning(w),[]}let C=this._options.onResponse(v.data),b=!1;if(o.fieldPath?(C=this.pickPath(C,o.fieldPath),b=!0):C&&typeof C=="object"&&"data"in C&&(C=this.pickPath(C,"data"),b=!0),o.transform){const w=C;let S=o.transform(w,y);C=S!==void 0?S:w}else b&&(C=Array.isArray(C)?C:[C]);return C}catch(l){if(r<this._options.retryCount)return await this.delay(this._options.retryDelay),this.fetchWithRetry(t,n,r+1);throw l}}delay(t){return new Promise(n=>setTimeout(n,t))}updateState(t,n){const r=this._stateMap.get(t);if(r){const o={...r,...n};this._stateMap.set(t,o),Object.assign(this.reactiveStates[t],o)}this.updateGlobalStatus()}updateGlobalStatus(){let t=!1,n=!1;this._stateMap.forEach(r=>{r.status==="loading"&&(t=!0),r.status==="error"&&(n=!0)}),this.isLoading&&typeof this.isLoading=="object"&&"value"in this.isLoading?this.isLoading.value=t:this.isLoading=a.ref(t),this.hasError&&typeof this.hasError=="object"&&"value"in this.hasError?this.hasError.value=n:this.hasError=a.ref(n)}notifyListeners(t,n){const r=this._stateMap.get(t);r&&this._listeners.forEach(o=>{o(t,n,r)})}normalizeMethod(t){const n=String(t??"GET").toUpperCase();return n==="POST"||n==="PUT"||n==="DELETE"?n:"GET"}isOldDataSource(t){if(!t||Array.isArray(t)||Object.getPrototypeOf(t)!==Object.prototype)return!1;const n=t.type;return!!(n!=="api"&&n!=="static")}cleanConfig(t){var n;if(this.isOldDataSource(t)){const r=t.fieldPath??t.resPath,o=t.key?((n=qn.state["gui-ajax-config"])==null?void 0:n[t.key])??{}:qn.state["gui-ajax-config"]??{},i={};o!=null&&o.tokenName&&(o!=null&&o.token)&&(i[o.tokenName]=o.token),o!=null&&o.sysCode&&(i.sysCode=o.sysCode),o!=null&&o.appType&&(i.appType=o.appType);const l={...i,...t.headers||{}};return[{key:"legacy_obj_api",type:"api",api:{url:t.path,method:this.normalizeMethod(t.method),params:t.params||t.data,data:t.data||t.params,headers:l,...r?{fieldPath:r}:{},transform:(s,c)=>{const d=typeof t.transformResponse=="function"?t.transformResponse(s,c):void 0;return d!==void 0?d:s}}}]}else return t}async loadData(t){const r=(t?Array.isArray(t)?t:[t]:Array.from(this._configMap.keys()).filter(o=>{var i;return((i=this._configMap.get(o))==null?void 0:i.type)==="api"})).map(o=>this.loadSingle(o).then(i=>({key:o,data:i,success:!0})).catch(i=>({key:o,error:i,success:!1})));return await Promise.all(r),this.mergeData()}async refreshData(t,n,r){if(!this._configMap.has(t))throw new Error(`DataSource with key "${t}" not found`);if(r){const i=n;return this.updateState(t,{data:i,status:"success",lastUpdated:new Date}),this.notifyListeners(t,i),i}const o=this._configMap.get(t);if(o.type==="api"&&o.api&&n&&typeof n=="object"&&!Array.isArray(n)){const i={...n};return"_url"in i&&(o.api.url=i._url,delete i._url),(o.api.method||"GET")==="GET"?o.api.params={...o.api.params||{},...i}:o.api.data={...o.api.data||{},...i},this._configMap.set(t,o),this.loadSingle(t)}return this.loadSingle(t,n)}async refreshAll(t){const r=Array.from(this._configMap.keys()).map(o=>{const i=t==null?void 0:t[o];return this.refreshData(o,i).then(l=>({key:o,data:l,success:!0})).catch(l=>({key:o,error:l,success:!1}))});return await Promise.all(r),this.mergeData()}getData(t){var n;return(n=this._stateMap.get(t))==null?void 0:n.data}getAllData(){const t={};return this._stateMap.forEach((n,r)=>{t[r]=n.data}),t}getState(t){return this._stateMap.get(t)}getAllStates(){const t={};return this._stateMap.forEach((n,r)=>{t[r]=n}),t}getLoadingStatus(t){var n;return((n=this._stateMap.get(t))==null?void 0:n.status)??"idle"}isSourceLoading(t){return this.getLoadingStatus(t)==="loading"}onDataUpdate(t){return this._listeners.add(t),()=>{this._listeners.delete(t)}}mergeData(t){const n=t||this._options.mergeTransformer,r=this.getAllData();if(n)return n(r);const o=Object.values(r);return o.length===1?o[0]||[]:o.flat()}clear(){this._configMap.forEach((t,n)=>{this.updateState(n,{data:null,status:"idle",error:null,lastUpdated:null})})}destroy(){this._configMap.clear(),this._stateMap.clear(),this._listeners.clear(),Object.keys(this.reactiveStates).forEach(t=>{delete this.reactiveStates[t]})}reload(t,n){if(typeof t=="string")return this.refreshData(t,n);if(t&&typeof t=="object"&&!n){const r=Array.from(this._configMap.keys());if(r.length===1)return this.refreshData(r[0],t);const o={};return r.forEach(i=>{o[i]=t}),this.refreshAll(o)}return t?this.refreshAll(t):this.refreshAll()}}var sLe={name:"zh-cn",el:{breadcrumb:{label:"面包屑"},colorpicker:{confirm:"确定",clear:"清空",defaultLabel:"颜色选择器",description:"当前颜色 {color},按 Enter 键选择新颜色",alphaLabel:"选择透明度的值"},datepicker:{now:"此刻",today:"今天",cancel:"取消",clear:"清空",confirm:"确定",dateTablePrompt:"使用方向键与 Enter 键可选择日期",monthTablePrompt:"使用方向键与 Enter 键可选择月份",yearTablePrompt:"使用方向键与 Enter 键可选择年份",selectedDate:"已选日期",selectDate:"选择日期",selectTime:"选择时间",startDate:"开始日期",startTime:"开始时间",endDate:"结束日期",endTime:"结束时间",prevYear:"前一年",nextYear:"后一年",prevMonth:"上个月",nextMonth:"下个月",year:"年",month1:"1 月",month2:"2 月",month3:"3 月",month4:"4 月",month5:"5 月",month6:"6 月",month7:"7 月",month8:"8 月",month9:"9 月",month10:"10 月",month11:"11 月",month12:"12 月",weeks:{sun:"日",mon:"一",tue:"二",wed:"三",thu:"四",fri:"五",sat:"六"},weeksFull:{sun:"星期日",mon:"星期一",tue:"星期二",wed:"星期三",thu:"星期四",fri:"星期五",sat:"星期六"},months:{jan:"一月",feb:"二月",mar:"三月",apr:"四月",may:"五月",jun:"六月",jul:"七月",aug:"八月",sep:"九月",oct:"十月",nov:"十一月",dec:"十二月"}},inputNumber:{decrease:"减少数值",increase:"增加数值"},select:{loading:"加载中",noMatch:"无匹配数据",noData:"无数据",placeholder:"请选择"},dropdown:{toggleDropdown:"切换下拉选项"},mention:{loading:"加载中"},cascader:{noMatch:"无匹配数据",loading:"加载中",placeholder:"请选择",noData:"暂无数据"},pagination:{goto:"前往",pagesize:"条/页",total:"共 {total} 条",pageClassifier:"页",page:"页",prev:"上一页",next:"下一页",currentPage:"第 {pager} 页",prevPages:"向前 {pager} 页",nextPages:"向后 {pager} 页",deprecationWarning:"你使用了一些已被废弃的用法,请参考 el-pagination 的官方文档"},dialog:{close:"关闭此对话框"},drawer:{close:"关闭此对话框"},messagebox:{title:"提示",confirm:"确定",cancel:"取消",error:"输入的数据不合法!",close:"关闭此对话框"},upload:{deleteTip:"按 Delete 键可删除",delete:"删除",preview:"查看图片",continue:"继续上传"},slider:{defaultLabel:"滑块介于 {min} 至 {max}",defaultRangeStartLabel:"选择起始值",defaultRangeEndLabel:"选择结束值"},table:{emptyText:"暂无数据",confirmFilter:"筛选",resetFilter:"重置",clearFilter:"全部",sumText:"合计"},tour:{next:"下一步",previous:"上一步",finish:"结束导览"},tree:{emptyText:"暂无数据"},transfer:{noMatch:"无匹配数据",noData:"无数据",titles:["列表 1","列表 2"],filterPlaceholder:"请输入搜索内容",noCheckedFormat:"共 {total} 项",hasCheckedFormat:"已选 {checked}/{total} 项"},image:{error:"加载失败"},pageHeader:{title:"返回"},popconfirm:{confirmButtonText:"确定",cancelButtonText:"取消"},carousel:{leftArrow:"上一张幻灯片",rightArrow:"下一张幻灯片",indicator:"幻灯片切换至索引 {index}"}}};/*! *****************************************************************************
|
|
57
57
|
Copyright (c) Microsoft Corporation.
|
|
58
58
|
|
|
59
59
|
Permission to use, copy, modify, and/or distribute this software for any
|
package/lib/g-ui-web.iife.js.gz
CHANGED
|
Binary file
|
package/lib/g-ui-web.js
CHANGED
|
@@ -45572,7 +45572,7 @@ class oZ {
|
|
|
45572
45572
|
/**
|
|
45573
45573
|
* 刷新数据(参数变更时重新请求,或手动更新数据)
|
|
45574
45574
|
* @param key 数据源标识
|
|
45575
|
-
* @param paramsOrData
|
|
45575
|
+
* @param paramsOrData 请求参数或直接更新的数据,支持特殊字段 _url 用于修改请求地址
|
|
45576
45576
|
* @param manual 是否手动更新本地数据(true: 直接更新本地数据,false: 从数据源加载)
|
|
45577
45577
|
*/
|
|
45578
45578
|
async refreshData(t, n, r) {
|
|
@@ -45588,8 +45588,8 @@ class oZ {
|
|
|
45588
45588
|
}
|
|
45589
45589
|
const a = this._configMap.get(t);
|
|
45590
45590
|
if (a.type === "api" && a.api && n && typeof n == "object" && !Array.isArray(n)) {
|
|
45591
|
-
const o = n;
|
|
45592
|
-
return (a.api.method || "GET") === "GET" ? a.api.params = { ...a.api.params || {}, ...o } : a.api.data = { ...a.api.data || {}, ...o }, this._configMap.set(t, a), this.loadSingle(t);
|
|
45591
|
+
const o = { ...n };
|
|
45592
|
+
return "_url" in o && (a.api.url = o._url, delete o._url), (a.api.method || "GET") === "GET" ? a.api.params = { ...a.api.params || {}, ...o } : a.api.data = { ...a.api.data || {}, ...o }, this._configMap.set(t, a), this.loadSingle(t);
|
|
45593
45593
|
}
|
|
45594
45594
|
return this.loadSingle(t, n);
|
|
45595
45595
|
}
|
package/lib/g-ui-web.js.gz
CHANGED
|
Binary file
|
package/lib/g-ui-web.umd.cjs
CHANGED
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
<div class="loadot"></div>
|
|
54
54
|
<div class="loadot"></div>
|
|
55
55
|
</div>
|
|
56
|
-
`;o.innerHTML=i,n.appendChild(o),(!e||e=="body")&&(o.style.position="fixed");const l=o.querySelectorAll(".loading-dots .loadot");l[0].style.backgroundColor=am.loadingList[0],l[1].style.backgroundColor=am.loadingList[1],l[2].style.backgroundColor=am.loadingList[2],am.name&&typeof am.name=="string"&&am.name.includes("black")&&(o.style.backgroundColor="rgba(0, 0, 0, 0.6)");const s={lg:16,md:12,sm:8,xs:5},c={lg:"12px",md:"10px",sm:"8px",xs:"4px"},d=o.querySelector(".loading-dots");d.style.gap=c[t]||"10px",l.forEach(u=>{u.style.width=`${s[t]}px`,u.style.height=`${s[t]}px`}),globalThis.gui.loading=iD})},done:function(e,t=0){a.nextTick(()=>{setTimeout(()=>{globalThis.gui.loading=iD,document.body.style.overflow="";const n=e?document.querySelector(`${e} .loading-next`):document.querySelector(".loading-next");n&&n.parentNode&&n.parentNode.removeChild(n)},t)})}};/*! js-cookie v3.0.5 | MIT */function y1(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)e[r]=n[r]}return e}var oLe={read:function(e){return e[0]==='"'&&(e=e.slice(1,-1)),e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(e){return encodeURIComponent(e).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}};function lD(e,t){function n(o,i,l){if(!(typeof document>"u")){l=y1({},t,l),typeof l.expires=="number"&&(l.expires=new Date(Date.now()+l.expires*864e5)),l.expires&&(l.expires=l.expires.toUTCString()),o=encodeURIComponent(o).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var s="";for(var c in l)l[c]&&(s+="; "+c,l[c]!==!0&&(s+="="+l[c].split(";")[0]));return document.cookie=o+"="+e.write(i,o)+s}}function r(o){if(!(typeof document>"u"||arguments.length&&!o)){for(var i=document.cookie?document.cookie.split("; "):[],l={},s=0;s<i.length;s++){var c=i[s].split("="),d=c.slice(1).join("=");try{var u=decodeURIComponent(c[0]);if(l[u]=e.read(d,u),o===u)break}catch{}}return o?l[o]:l}}return Object.create({set:n,get:r,remove:function(o,i){n(o,"",y1({},i,{expires:-1}))},withAttributes:function(o){return lD(this.converter,y1({},this.attributes,o))},withConverter:function(o){return lD(y1({},this.converter,o),this.attributes)}},{attributes:{value:Object.freeze(t)},converter:{value:Object.freeze(e)}})}var sD=lD(oLe,{path:"/"});function aH(e,t={}){const{autoLoad:n=!0,watchParams:r,watchKeys:o,...i}=t,l=iLe(e),s=new cD(l,{...i}),c=a.reactive([...s.mergeData()]),d=s.reactiveStates,u=s.isLoading,f=s.hasError;s.onDataUpdate(()=>{const C=s.mergeData();c.length=0,c.push(...C)});const p=async C=>s.loadData(C);a.onMounted(()=>{n&&p()});const h=async(C,b)=>s.refreshData(C,b),m=async(C,b)=>C?s.refreshData(C,b):s.refreshAll(),g=async C=>s.refreshAll(C),v=async(C,b)=>s.refreshData(C,b,!0),y=C=>d[C];return r&&a.watch(typeof r=="function"?r:()=>r.value,async C=>{if(o&&o.length>0)for(const b of o)await h(b,C);else await g()},{deep:!0}),{_sourceInstance:s,sourceData:c,sourceState:d,isLoading:u,hasError:f,loadData:p,refreshData:h,reload:m,refreshAll:g,updateData:v,getState:y,mergeData:s.mergeData.bind(s),onDataUpdate:s.onDataUpdate.bind(s),clear:s.clear.bind(s),destroy:s.destroy.bind(s)}}const iLe=e=>{const t=(n,r)=>{if(!r)return n;const o=r.startsWith("/")?r.slice(1):r,i=o.includes("/")?"/":".";return String(o).split(i).reduce((l,s)=>l!=null&&s?l[s]:void 0,n)};if(e&&typeof e=="object"&&"path"in e){const n=e.fieldPath??e.resPath;return[{key:"legacy_obj_api",type:"api",api:{url:e.path,method:(e.method??"GET").toUpperCase(),params:e.params,data:e.data,headers:e.headers,transform:r=>{const o=t(r,n),i=typeof e.transformResponse=="function"?e.transformResponse(o):void 0,l=i!==void 0?i:o;return Array.isArray(l)?l:[l]}}}]}else return e},Wn=async(e,t)=>{if(Array.isArray(e)){if(!e.every(r=>r&&typeof r=="object"&&"type"in r&&(r.type==="api"||r.type==="static")))return e}else{if(e&&typeof e=="object"&&!("path"in e))return[e];if(typeof e=="string"||typeof e=="number")return[{[t]:e}]}};function Hn(e){return e&&typeof e=="object"&&"reactiveStates"in e&&"isLoading"in e&&"hasError"in e&&typeof e.loadData=="function"&&typeof e.refreshData=="function"&&typeof e.mergeData=="function"}function Ln(e){return e&&typeof e=="object"&&"sourceData"in e&&"_sourceInstance"in e&&typeof e.onDataUpdate=="function"}function Gn(e){return async t=>{const n=typeof window<"u"&&window.gui&&window.gui.guiDebug===!0||window.guiDebug===!0,r=(e==null?void 0:e.debug)===!0;if(!n&&!r)return;t.preventDefault();const o=e==null?void 0:e.data;Ln(o)?(console.log("🔍 [DataSource Debug] 右键触发调试,重新加载数据..."),o._sourceInstance.debugMode=!0,await o._sourceInstance.loadData(),console.log("✅ [DataSource Debug] 数据重新加载完成")):Hn(o)&&(console.log("🔍 [DataSource Debug] 右键触发调试,重新加载数据..."),o.debugMode=!0,o.loadData(),console.log("✅ [DataSource Debug] 数据重新加载完成"))}}class cD{constructor(t,n={}){gc(this,"_configMap",new Map);gc(this,"_stateMap",new Map);gc(this,"_options");gc(this,"_listeners",new Set);gc(this,"reactiveStates",a.reactive({}));gc(this,"isLoading",a.ref(!1));gc(this,"hasError",a.ref(!1));gc(this,"debugMode",!1);gc(this,"pickPath",(t,n)=>{if(!n)return t;const r=n.startsWith("/")?n.slice(1):n,o=r.includes("/")?"/":".";return String(r).split(o).reduce((i,l)=>i!=null&&l?i[l]:void 0,t)});this._options={autoLoad:(n==null?void 0:n.autoLoad)||!1,retryCount:0,retryDelay:1e3,onRequest:i=>i,onResponse:i=>i,onError:()=>{},mergeTransformer:n.mergeTransformer,...n},this.cleanConfig(t).forEach(i=>{this.addSource(i)}),(this._options.autoLoad||this.isOldDataSource(t)&&((t==null?void 0:t.autoQuery)===!0||(t==null?void 0:t.autoQuery)===void 0))&&this.loadData()}addSource(t){this._configMap.set(t.key,t);const n={data:t.type==="static"?t.data??null:null,status:t.type==="static"?"success":"idle",error:null,lastUpdated:t.type==="static"?new Date:null};this._stateMap.set(t.key,n),this.reactiveStates[t.key]=n,t.type==="static"&&t.data!==void 0&&t.data!==null&&Promise.resolve().then(()=>{this.notifyListeners(t.key,t.data)})}removeSource(t){const n=this._configMap.delete(t);return this._stateMap.delete(t),delete this.reactiveStates[t],n}async loadSingle(t,n){const r=this._configMap.get(t);if(!r)throw new Error(`DataSource with key "${t}" not found`);this.updateState(t,{status:"loading",error:null});try{let o;if(r.type==="static")o=r.data;else if(r.type==="api"&&r.api)o=await this.fetchWithRetry(r,n);else throw new Error(`Invalid data source configuration for key "${t}"`);return this.updateState(t,{data:o,status:"success",error:null,lastUpdated:new Date}),this.notifyListeners(t,o),o}catch(o){const i=o instanceof Error?o:new Error(String(o));throw this.updateState(t,{status:"error",error:i}),this._options.onError(i,t),i}}async fetchWithRetry(t,n,r=0){var i;const o=t.api;try{const l=qn.state["gui-ajax-config"]||{},s=typeof document<"u"&&((i=sD.get)==null?void 0:i.call(sD,"token"))||"",c=(l==null?void 0:l.token)||s,d={};if(c){const w=(l==null?void 0:l.tokenName)||"token";d[w]=c}l!=null&&l.sysCode&&(d.sysCode=l.sysCode),l!=null&&l.appType&&(d.appType=l.appType);const u={...d,...o.headers||{}},f={...o.headers||{}},p=t.key==="legacy_obj_api"?f:u;let h={url:o.url,method:o.method||"GET",headers:p};const m={...o.params,...n},g={...o.data,...n};h.method==="GET"?h.params=m:h.data=g,h=this._options.onRequest(h),this.debugMode&&console.log("🔍 [DataSource Debug] Request:",{url:h.url,method:h.method,params:h.params,data:h.data,fieldPath:o.fieldPath,retryCount:r,timestamp:new Date().toISOString()});const v=await sa(h),y=v.data;if(y&&typeof y=="object"&&y.code===999){const w=y.errorMsg||"Request failed with code 999";return Xi&&Xi.warning(w),[]}let C=this._options.onResponse(v.data),b=!1;if(o.fieldPath?(C=this.pickPath(C,o.fieldPath),b=!0):C&&typeof C=="object"&&"data"in C&&(C=this.pickPath(C,"data"),b=!0),o.transform){const w=C;let S=o.transform(w,y);C=S!==void 0?S:w}else b&&(C=Array.isArray(C)?C:[C]);return C}catch(l){if(r<this._options.retryCount)return await this.delay(this._options.retryDelay),this.fetchWithRetry(t,n,r+1);throw l}}delay(t){return new Promise(n=>setTimeout(n,t))}updateState(t,n){const r=this._stateMap.get(t);if(r){const o={...r,...n};this._stateMap.set(t,o),Object.assign(this.reactiveStates[t],o)}this.updateGlobalStatus()}updateGlobalStatus(){let t=!1,n=!1;this._stateMap.forEach(r=>{r.status==="loading"&&(t=!0),r.status==="error"&&(n=!0)}),this.isLoading&&typeof this.isLoading=="object"&&"value"in this.isLoading?this.isLoading.value=t:this.isLoading=a.ref(t),this.hasError&&typeof this.hasError=="object"&&"value"in this.hasError?this.hasError.value=n:this.hasError=a.ref(n)}notifyListeners(t,n){const r=this._stateMap.get(t);r&&this._listeners.forEach(o=>{o(t,n,r)})}normalizeMethod(t){const n=String(t??"GET").toUpperCase();return n==="POST"||n==="PUT"||n==="DELETE"?n:"GET"}isOldDataSource(t){if(!t||Array.isArray(t)||Object.getPrototypeOf(t)!==Object.prototype)return!1;const n=t.type;return!!(n!=="api"&&n!=="static")}cleanConfig(t){var n;if(this.isOldDataSource(t)){const r=t.fieldPath??t.resPath,o=t.key?((n=qn.state["gui-ajax-config"])==null?void 0:n[t.key])??{}:qn.state["gui-ajax-config"]??{},i={};o!=null&&o.tokenName&&(o!=null&&o.token)&&(i[o.tokenName]=o.token),o!=null&&o.sysCode&&(i.sysCode=o.sysCode),o!=null&&o.appType&&(i.appType=o.appType);const l={...i,...t.headers||{}};return[{key:"legacy_obj_api",type:"api",api:{url:t.path,method:this.normalizeMethod(t.method),params:t.params||t.data,data:t.data||t.params,headers:l,...r?{fieldPath:r}:{},transform:(s,c)=>{const d=typeof t.transformResponse=="function"?t.transformResponse(s,c):void 0;return d!==void 0?d:s}}}]}else return t}async loadData(t){const r=(t?Array.isArray(t)?t:[t]:Array.from(this._configMap.keys()).filter(o=>{var i;return((i=this._configMap.get(o))==null?void 0:i.type)==="api"})).map(o=>this.loadSingle(o).then(i=>({key:o,data:i,success:!0})).catch(i=>({key:o,error:i,success:!1})));return await Promise.all(r),this.mergeData()}async refreshData(t,n,r){if(!this._configMap.has(t))throw new Error(`DataSource with key "${t}" not found`);if(r){const i=n;return this.updateState(t,{data:i,status:"success",lastUpdated:new Date}),this.notifyListeners(t,i),i}const o=this._configMap.get(t);if(o.type==="api"&&o.api&&n&&typeof n=="object"&&!Array.isArray(n)){const i=n;return(o.api.method||"GET")==="GET"?o.api.params={...o.api.params||{},...i}:o.api.data={...o.api.data||{},...i},this._configMap.set(t,o),this.loadSingle(t)}return this.loadSingle(t,n)}async refreshAll(t){const r=Array.from(this._configMap.keys()).map(o=>{const i=t==null?void 0:t[o];return this.refreshData(o,i).then(l=>({key:o,data:l,success:!0})).catch(l=>({key:o,error:l,success:!1}))});return await Promise.all(r),this.mergeData()}getData(t){var n;return(n=this._stateMap.get(t))==null?void 0:n.data}getAllData(){const t={};return this._stateMap.forEach((n,r)=>{t[r]=n.data}),t}getState(t){return this._stateMap.get(t)}getAllStates(){const t={};return this._stateMap.forEach((n,r)=>{t[r]=n}),t}getLoadingStatus(t){var n;return((n=this._stateMap.get(t))==null?void 0:n.status)??"idle"}isSourceLoading(t){return this.getLoadingStatus(t)==="loading"}onDataUpdate(t){return this._listeners.add(t),()=>{this._listeners.delete(t)}}mergeData(t){const n=t||this._options.mergeTransformer,r=this.getAllData();if(n)return n(r);const o=Object.values(r);return o.length===1?o[0]||[]:o.flat()}clear(){this._configMap.forEach((t,n)=>{this.updateState(n,{data:null,status:"idle",error:null,lastUpdated:null})})}destroy(){this._configMap.clear(),this._stateMap.clear(),this._listeners.clear(),Object.keys(this.reactiveStates).forEach(t=>{delete this.reactiveStates[t]})}reload(t,n){if(typeof t=="string")return this.refreshData(t,n);if(t&&typeof t=="object"&&!n){const r=Array.from(this._configMap.keys());if(r.length===1)return this.refreshData(r[0],t);const o={};return r.forEach(i=>{o[i]=t}),this.refreshAll(o)}return t?this.refreshAll(t):this.refreshAll()}}var lLe={name:"zh-cn",el:{breadcrumb:{label:"面包屑"},colorpicker:{confirm:"确定",clear:"清空",defaultLabel:"颜色选择器",description:"当前颜色 {color},按 Enter 键选择新颜色",alphaLabel:"选择透明度的值"},datepicker:{now:"此刻",today:"今天",cancel:"取消",clear:"清空",confirm:"确定",dateTablePrompt:"使用方向键与 Enter 键可选择日期",monthTablePrompt:"使用方向键与 Enter 键可选择月份",yearTablePrompt:"使用方向键与 Enter 键可选择年份",selectedDate:"已选日期",selectDate:"选择日期",selectTime:"选择时间",startDate:"开始日期",startTime:"开始时间",endDate:"结束日期",endTime:"结束时间",prevYear:"前一年",nextYear:"后一年",prevMonth:"上个月",nextMonth:"下个月",year:"年",month1:"1 月",month2:"2 月",month3:"3 月",month4:"4 月",month5:"5 月",month6:"6 月",month7:"7 月",month8:"8 月",month9:"9 月",month10:"10 月",month11:"11 月",month12:"12 月",weeks:{sun:"日",mon:"一",tue:"二",wed:"三",thu:"四",fri:"五",sat:"六"},weeksFull:{sun:"星期日",mon:"星期一",tue:"星期二",wed:"星期三",thu:"星期四",fri:"星期五",sat:"星期六"},months:{jan:"一月",feb:"二月",mar:"三月",apr:"四月",may:"五月",jun:"六月",jul:"七月",aug:"八月",sep:"九月",oct:"十月",nov:"十一月",dec:"十二月"}},inputNumber:{decrease:"减少数值",increase:"增加数值"},select:{loading:"加载中",noMatch:"无匹配数据",noData:"无数据",placeholder:"请选择"},dropdown:{toggleDropdown:"切换下拉选项"},mention:{loading:"加载中"},cascader:{noMatch:"无匹配数据",loading:"加载中",placeholder:"请选择",noData:"暂无数据"},pagination:{goto:"前往",pagesize:"条/页",total:"共 {total} 条",pageClassifier:"页",page:"页",prev:"上一页",next:"下一页",currentPage:"第 {pager} 页",prevPages:"向前 {pager} 页",nextPages:"向后 {pager} 页",deprecationWarning:"你使用了一些已被废弃的用法,请参考 el-pagination 的官方文档"},dialog:{close:"关闭此对话框"},drawer:{close:"关闭此对话框"},messagebox:{title:"提示",confirm:"确定",cancel:"取消",error:"输入的数据不合法!",close:"关闭此对话框"},upload:{deleteTip:"按 Delete 键可删除",delete:"删除",preview:"查看图片",continue:"继续上传"},slider:{defaultLabel:"滑块介于 {min} 至 {max}",defaultRangeStartLabel:"选择起始值",defaultRangeEndLabel:"选择结束值"},table:{emptyText:"暂无数据",confirmFilter:"筛选",resetFilter:"重置",clearFilter:"全部",sumText:"合计"},tour:{next:"下一步",previous:"上一步",finish:"结束导览"},tree:{emptyText:"暂无数据"},transfer:{noMatch:"无匹配数据",noData:"无数据",titles:["列表 1","列表 2"],filterPlaceholder:"请输入搜索内容",noCheckedFormat:"共 {total} 项",hasCheckedFormat:"已选 {checked}/{total} 项"},image:{error:"加载失败"},pageHeader:{title:"返回"},popconfirm:{confirmButtonText:"确定",cancelButtonText:"取消"},carousel:{leftArrow:"上一张幻灯片",rightArrow:"下一张幻灯片",indicator:"幻灯片切换至索引 {index}"}}};/*! *****************************************************************************
|
|
56
|
+
`;o.innerHTML=i,n.appendChild(o),(!e||e=="body")&&(o.style.position="fixed");const l=o.querySelectorAll(".loading-dots .loadot");l[0].style.backgroundColor=am.loadingList[0],l[1].style.backgroundColor=am.loadingList[1],l[2].style.backgroundColor=am.loadingList[2],am.name&&typeof am.name=="string"&&am.name.includes("black")&&(o.style.backgroundColor="rgba(0, 0, 0, 0.6)");const s={lg:16,md:12,sm:8,xs:5},c={lg:"12px",md:"10px",sm:"8px",xs:"4px"},d=o.querySelector(".loading-dots");d.style.gap=c[t]||"10px",l.forEach(u=>{u.style.width=`${s[t]}px`,u.style.height=`${s[t]}px`}),globalThis.gui.loading=iD})},done:function(e,t=0){a.nextTick(()=>{setTimeout(()=>{globalThis.gui.loading=iD,document.body.style.overflow="";const n=e?document.querySelector(`${e} .loading-next`):document.querySelector(".loading-next");n&&n.parentNode&&n.parentNode.removeChild(n)},t)})}};/*! js-cookie v3.0.5 | MIT */function y1(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)e[r]=n[r]}return e}var oLe={read:function(e){return e[0]==='"'&&(e=e.slice(1,-1)),e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(e){return encodeURIComponent(e).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}};function lD(e,t){function n(o,i,l){if(!(typeof document>"u")){l=y1({},t,l),typeof l.expires=="number"&&(l.expires=new Date(Date.now()+l.expires*864e5)),l.expires&&(l.expires=l.expires.toUTCString()),o=encodeURIComponent(o).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var s="";for(var c in l)l[c]&&(s+="; "+c,l[c]!==!0&&(s+="="+l[c].split(";")[0]));return document.cookie=o+"="+e.write(i,o)+s}}function r(o){if(!(typeof document>"u"||arguments.length&&!o)){for(var i=document.cookie?document.cookie.split("; "):[],l={},s=0;s<i.length;s++){var c=i[s].split("="),d=c.slice(1).join("=");try{var u=decodeURIComponent(c[0]);if(l[u]=e.read(d,u),o===u)break}catch{}}return o?l[o]:l}}return Object.create({set:n,get:r,remove:function(o,i){n(o,"",y1({},i,{expires:-1}))},withAttributes:function(o){return lD(this.converter,y1({},this.attributes,o))},withConverter:function(o){return lD(y1({},this.converter,o),this.attributes)}},{attributes:{value:Object.freeze(t)},converter:{value:Object.freeze(e)}})}var sD=lD(oLe,{path:"/"});function aH(e,t={}){const{autoLoad:n=!0,watchParams:r,watchKeys:o,...i}=t,l=iLe(e),s=new cD(l,{...i}),c=a.reactive([...s.mergeData()]),d=s.reactiveStates,u=s.isLoading,f=s.hasError;s.onDataUpdate(()=>{const C=s.mergeData();c.length=0,c.push(...C)});const p=async C=>s.loadData(C);a.onMounted(()=>{n&&p()});const h=async(C,b)=>s.refreshData(C,b),m=async(C,b)=>C?s.refreshData(C,b):s.refreshAll(),g=async C=>s.refreshAll(C),v=async(C,b)=>s.refreshData(C,b,!0),y=C=>d[C];return r&&a.watch(typeof r=="function"?r:()=>r.value,async C=>{if(o&&o.length>0)for(const b of o)await h(b,C);else await g()},{deep:!0}),{_sourceInstance:s,sourceData:c,sourceState:d,isLoading:u,hasError:f,loadData:p,refreshData:h,reload:m,refreshAll:g,updateData:v,getState:y,mergeData:s.mergeData.bind(s),onDataUpdate:s.onDataUpdate.bind(s),clear:s.clear.bind(s),destroy:s.destroy.bind(s)}}const iLe=e=>{const t=(n,r)=>{if(!r)return n;const o=r.startsWith("/")?r.slice(1):r,i=o.includes("/")?"/":".";return String(o).split(i).reduce((l,s)=>l!=null&&s?l[s]:void 0,n)};if(e&&typeof e=="object"&&"path"in e){const n=e.fieldPath??e.resPath;return[{key:"legacy_obj_api",type:"api",api:{url:e.path,method:(e.method??"GET").toUpperCase(),params:e.params,data:e.data,headers:e.headers,transform:r=>{const o=t(r,n),i=typeof e.transformResponse=="function"?e.transformResponse(o):void 0,l=i!==void 0?i:o;return Array.isArray(l)?l:[l]}}}]}else return e},Wn=async(e,t)=>{if(Array.isArray(e)){if(!e.every(r=>r&&typeof r=="object"&&"type"in r&&(r.type==="api"||r.type==="static")))return e}else{if(e&&typeof e=="object"&&!("path"in e))return[e];if(typeof e=="string"||typeof e=="number")return[{[t]:e}]}};function Hn(e){return e&&typeof e=="object"&&"reactiveStates"in e&&"isLoading"in e&&"hasError"in e&&typeof e.loadData=="function"&&typeof e.refreshData=="function"&&typeof e.mergeData=="function"}function Ln(e){return e&&typeof e=="object"&&"sourceData"in e&&"_sourceInstance"in e&&typeof e.onDataUpdate=="function"}function Gn(e){return async t=>{const n=typeof window<"u"&&window.gui&&window.gui.guiDebug===!0||window.guiDebug===!0,r=(e==null?void 0:e.debug)===!0;if(!n&&!r)return;t.preventDefault();const o=e==null?void 0:e.data;Ln(o)?(console.log("🔍 [DataSource Debug] 右键触发调试,重新加载数据..."),o._sourceInstance.debugMode=!0,await o._sourceInstance.loadData(),console.log("✅ [DataSource Debug] 数据重新加载完成")):Hn(o)&&(console.log("🔍 [DataSource Debug] 右键触发调试,重新加载数据..."),o.debugMode=!0,o.loadData(),console.log("✅ [DataSource Debug] 数据重新加载完成"))}}class cD{constructor(t,n={}){gc(this,"_configMap",new Map);gc(this,"_stateMap",new Map);gc(this,"_options");gc(this,"_listeners",new Set);gc(this,"reactiveStates",a.reactive({}));gc(this,"isLoading",a.ref(!1));gc(this,"hasError",a.ref(!1));gc(this,"debugMode",!1);gc(this,"pickPath",(t,n)=>{if(!n)return t;const r=n.startsWith("/")?n.slice(1):n,o=r.includes("/")?"/":".";return String(r).split(o).reduce((i,l)=>i!=null&&l?i[l]:void 0,t)});this._options={autoLoad:(n==null?void 0:n.autoLoad)||!1,retryCount:0,retryDelay:1e3,onRequest:i=>i,onResponse:i=>i,onError:()=>{},mergeTransformer:n.mergeTransformer,...n},this.cleanConfig(t).forEach(i=>{this.addSource(i)}),(this._options.autoLoad||this.isOldDataSource(t)&&((t==null?void 0:t.autoQuery)===!0||(t==null?void 0:t.autoQuery)===void 0))&&this.loadData()}addSource(t){this._configMap.set(t.key,t);const n={data:t.type==="static"?t.data??null:null,status:t.type==="static"?"success":"idle",error:null,lastUpdated:t.type==="static"?new Date:null};this._stateMap.set(t.key,n),this.reactiveStates[t.key]=n,t.type==="static"&&t.data!==void 0&&t.data!==null&&Promise.resolve().then(()=>{this.notifyListeners(t.key,t.data)})}removeSource(t){const n=this._configMap.delete(t);return this._stateMap.delete(t),delete this.reactiveStates[t],n}async loadSingle(t,n){const r=this._configMap.get(t);if(!r)throw new Error(`DataSource with key "${t}" not found`);this.updateState(t,{status:"loading",error:null});try{let o;if(r.type==="static")o=r.data;else if(r.type==="api"&&r.api)o=await this.fetchWithRetry(r,n);else throw new Error(`Invalid data source configuration for key "${t}"`);return this.updateState(t,{data:o,status:"success",error:null,lastUpdated:new Date}),this.notifyListeners(t,o),o}catch(o){const i=o instanceof Error?o:new Error(String(o));throw this.updateState(t,{status:"error",error:i}),this._options.onError(i,t),i}}async fetchWithRetry(t,n,r=0){var i;const o=t.api;try{const l=qn.state["gui-ajax-config"]||{},s=typeof document<"u"&&((i=sD.get)==null?void 0:i.call(sD,"token"))||"",c=(l==null?void 0:l.token)||s,d={};if(c){const w=(l==null?void 0:l.tokenName)||"token";d[w]=c}l!=null&&l.sysCode&&(d.sysCode=l.sysCode),l!=null&&l.appType&&(d.appType=l.appType);const u={...d,...o.headers||{}},f={...o.headers||{}},p=t.key==="legacy_obj_api"?f:u;let h={url:o.url,method:o.method||"GET",headers:p};const m={...o.params,...n},g={...o.data,...n};h.method==="GET"?h.params=m:h.data=g,h=this._options.onRequest(h),this.debugMode&&console.log("🔍 [DataSource Debug] Request:",{url:h.url,method:h.method,params:h.params,data:h.data,fieldPath:o.fieldPath,retryCount:r,timestamp:new Date().toISOString()});const v=await sa(h),y=v.data;if(y&&typeof y=="object"&&y.code===999){const w=y.errorMsg||"Request failed with code 999";return Xi&&Xi.warning(w),[]}let C=this._options.onResponse(v.data),b=!1;if(o.fieldPath?(C=this.pickPath(C,o.fieldPath),b=!0):C&&typeof C=="object"&&"data"in C&&(C=this.pickPath(C,"data"),b=!0),o.transform){const w=C;let S=o.transform(w,y);C=S!==void 0?S:w}else b&&(C=Array.isArray(C)?C:[C]);return C}catch(l){if(r<this._options.retryCount)return await this.delay(this._options.retryDelay),this.fetchWithRetry(t,n,r+1);throw l}}delay(t){return new Promise(n=>setTimeout(n,t))}updateState(t,n){const r=this._stateMap.get(t);if(r){const o={...r,...n};this._stateMap.set(t,o),Object.assign(this.reactiveStates[t],o)}this.updateGlobalStatus()}updateGlobalStatus(){let t=!1,n=!1;this._stateMap.forEach(r=>{r.status==="loading"&&(t=!0),r.status==="error"&&(n=!0)}),this.isLoading&&typeof this.isLoading=="object"&&"value"in this.isLoading?this.isLoading.value=t:this.isLoading=a.ref(t),this.hasError&&typeof this.hasError=="object"&&"value"in this.hasError?this.hasError.value=n:this.hasError=a.ref(n)}notifyListeners(t,n){const r=this._stateMap.get(t);r&&this._listeners.forEach(o=>{o(t,n,r)})}normalizeMethod(t){const n=String(t??"GET").toUpperCase();return n==="POST"||n==="PUT"||n==="DELETE"?n:"GET"}isOldDataSource(t){if(!t||Array.isArray(t)||Object.getPrototypeOf(t)!==Object.prototype)return!1;const n=t.type;return!!(n!=="api"&&n!=="static")}cleanConfig(t){var n;if(this.isOldDataSource(t)){const r=t.fieldPath??t.resPath,o=t.key?((n=qn.state["gui-ajax-config"])==null?void 0:n[t.key])??{}:qn.state["gui-ajax-config"]??{},i={};o!=null&&o.tokenName&&(o!=null&&o.token)&&(i[o.tokenName]=o.token),o!=null&&o.sysCode&&(i.sysCode=o.sysCode),o!=null&&o.appType&&(i.appType=o.appType);const l={...i,...t.headers||{}};return[{key:"legacy_obj_api",type:"api",api:{url:t.path,method:this.normalizeMethod(t.method),params:t.params||t.data,data:t.data||t.params,headers:l,...r?{fieldPath:r}:{},transform:(s,c)=>{const d=typeof t.transformResponse=="function"?t.transformResponse(s,c):void 0;return d!==void 0?d:s}}}]}else return t}async loadData(t){const r=(t?Array.isArray(t)?t:[t]:Array.from(this._configMap.keys()).filter(o=>{var i;return((i=this._configMap.get(o))==null?void 0:i.type)==="api"})).map(o=>this.loadSingle(o).then(i=>({key:o,data:i,success:!0})).catch(i=>({key:o,error:i,success:!1})));return await Promise.all(r),this.mergeData()}async refreshData(t,n,r){if(!this._configMap.has(t))throw new Error(`DataSource with key "${t}" not found`);if(r){const i=n;return this.updateState(t,{data:i,status:"success",lastUpdated:new Date}),this.notifyListeners(t,i),i}const o=this._configMap.get(t);if(o.type==="api"&&o.api&&n&&typeof n=="object"&&!Array.isArray(n)){const i={...n};return"_url"in i&&(o.api.url=i._url,delete i._url),(o.api.method||"GET")==="GET"?o.api.params={...o.api.params||{},...i}:o.api.data={...o.api.data||{},...i},this._configMap.set(t,o),this.loadSingle(t)}return this.loadSingle(t,n)}async refreshAll(t){const r=Array.from(this._configMap.keys()).map(o=>{const i=t==null?void 0:t[o];return this.refreshData(o,i).then(l=>({key:o,data:l,success:!0})).catch(l=>({key:o,error:l,success:!1}))});return await Promise.all(r),this.mergeData()}getData(t){var n;return(n=this._stateMap.get(t))==null?void 0:n.data}getAllData(){const t={};return this._stateMap.forEach((n,r)=>{t[r]=n.data}),t}getState(t){return this._stateMap.get(t)}getAllStates(){const t={};return this._stateMap.forEach((n,r)=>{t[r]=n}),t}getLoadingStatus(t){var n;return((n=this._stateMap.get(t))==null?void 0:n.status)??"idle"}isSourceLoading(t){return this.getLoadingStatus(t)==="loading"}onDataUpdate(t){return this._listeners.add(t),()=>{this._listeners.delete(t)}}mergeData(t){const n=t||this._options.mergeTransformer,r=this.getAllData();if(n)return n(r);const o=Object.values(r);return o.length===1?o[0]||[]:o.flat()}clear(){this._configMap.forEach((t,n)=>{this.updateState(n,{data:null,status:"idle",error:null,lastUpdated:null})})}destroy(){this._configMap.clear(),this._stateMap.clear(),this._listeners.clear(),Object.keys(this.reactiveStates).forEach(t=>{delete this.reactiveStates[t]})}reload(t,n){if(typeof t=="string")return this.refreshData(t,n);if(t&&typeof t=="object"&&!n){const r=Array.from(this._configMap.keys());if(r.length===1)return this.refreshData(r[0],t);const o={};return r.forEach(i=>{o[i]=t}),this.refreshAll(o)}return t?this.refreshAll(t):this.refreshAll()}}var lLe={name:"zh-cn",el:{breadcrumb:{label:"面包屑"},colorpicker:{confirm:"确定",clear:"清空",defaultLabel:"颜色选择器",description:"当前颜色 {color},按 Enter 键选择新颜色",alphaLabel:"选择透明度的值"},datepicker:{now:"此刻",today:"今天",cancel:"取消",clear:"清空",confirm:"确定",dateTablePrompt:"使用方向键与 Enter 键可选择日期",monthTablePrompt:"使用方向键与 Enter 键可选择月份",yearTablePrompt:"使用方向键与 Enter 键可选择年份",selectedDate:"已选日期",selectDate:"选择日期",selectTime:"选择时间",startDate:"开始日期",startTime:"开始时间",endDate:"结束日期",endTime:"结束时间",prevYear:"前一年",nextYear:"后一年",prevMonth:"上个月",nextMonth:"下个月",year:"年",month1:"1 月",month2:"2 月",month3:"3 月",month4:"4 月",month5:"5 月",month6:"6 月",month7:"7 月",month8:"8 月",month9:"9 月",month10:"10 月",month11:"11 月",month12:"12 月",weeks:{sun:"日",mon:"一",tue:"二",wed:"三",thu:"四",fri:"五",sat:"六"},weeksFull:{sun:"星期日",mon:"星期一",tue:"星期二",wed:"星期三",thu:"星期四",fri:"星期五",sat:"星期六"},months:{jan:"一月",feb:"二月",mar:"三月",apr:"四月",may:"五月",jun:"六月",jul:"七月",aug:"八月",sep:"九月",oct:"十月",nov:"十一月",dec:"十二月"}},inputNumber:{decrease:"减少数值",increase:"增加数值"},select:{loading:"加载中",noMatch:"无匹配数据",noData:"无数据",placeholder:"请选择"},dropdown:{toggleDropdown:"切换下拉选项"},mention:{loading:"加载中"},cascader:{noMatch:"无匹配数据",loading:"加载中",placeholder:"请选择",noData:"暂无数据"},pagination:{goto:"前往",pagesize:"条/页",total:"共 {total} 条",pageClassifier:"页",page:"页",prev:"上一页",next:"下一页",currentPage:"第 {pager} 页",prevPages:"向前 {pager} 页",nextPages:"向后 {pager} 页",deprecationWarning:"你使用了一些已被废弃的用法,请参考 el-pagination 的官方文档"},dialog:{close:"关闭此对话框"},drawer:{close:"关闭此对话框"},messagebox:{title:"提示",confirm:"确定",cancel:"取消",error:"输入的数据不合法!",close:"关闭此对话框"},upload:{deleteTip:"按 Delete 键可删除",delete:"删除",preview:"查看图片",continue:"继续上传"},slider:{defaultLabel:"滑块介于 {min} 至 {max}",defaultRangeStartLabel:"选择起始值",defaultRangeEndLabel:"选择结束值"},table:{emptyText:"暂无数据",confirmFilter:"筛选",resetFilter:"重置",clearFilter:"全部",sumText:"合计"},tour:{next:"下一步",previous:"上一步",finish:"结束导览"},tree:{emptyText:"暂无数据"},transfer:{noMatch:"无匹配数据",noData:"无数据",titles:["列表 1","列表 2"],filterPlaceholder:"请输入搜索内容",noCheckedFormat:"共 {total} 项",hasCheckedFormat:"已选 {checked}/{total} 项"},image:{error:"加载失败"},pageHeader:{title:"返回"},popconfirm:{confirmButtonText:"确定",cancelButtonText:"取消"},carousel:{leftArrow:"上一张幻灯片",rightArrow:"下一张幻灯片",indicator:"幻灯片切换至索引 {index}"}}};/*! *****************************************************************************
|
|
57
57
|
Copyright (c) Microsoft Corporation.
|
|
58
58
|
|
|
59
59
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
@@ -126,7 +126,7 @@ declare class DataSource {
|
|
|
126
126
|
/**
|
|
127
127
|
* 刷新数据(参数变更时重新请求,或手动更新数据)
|
|
128
128
|
* @param key 数据源标识
|
|
129
|
-
* @param paramsOrData
|
|
129
|
+
* @param paramsOrData 请求参数或直接更新的数据,支持特殊字段 _url 用于修改请求地址
|
|
130
130
|
* @param manual 是否手动更新本地数据(true: 直接更新本地数据,false: 从数据源加载)
|
|
131
131
|
*/
|
|
132
132
|
refreshData<T = any>(key: string, paramsOrData?: Record<string, any> | T, manual?: boolean): Promise<T>;
|