Files
akmon/pages/test/supadbtest.uvue
2026-01-20 08:04:15 +08:00

113 lines
3.2 KiB
Plaintext
Raw Permalink Blame History

<template>
<supadb ref="udb" :collection="collectionList" field="name,id" :where="where" page-data="replace" :orderby="orderby"
getcount="exact" :page-size="pageSize" :page-current="pageCurrent"
v-slot:default="{ data, pagination, hasmore ,loading, error }" loadtime="manual" :datafunc="addAkPrefix"
@load="onqueryload">
<view v-if="loading">加载<E58AA0>?..</view>
<view v-else-if="error">{{ error }}</view>
<view v-else>
<view v-for="(item, idx) in (data as Array<UTSJSONObject>)" :key="idx">
<!-- #ifdef APP-ANDROID -->
<view>{{ item.get("name") }} - {{ item.get("id") }}</view>
<!-- #endif -->
<!-- #ifndef APP-ANDROID -->
<view>{{ item.name }} - {{ item.id }}</view>
<!-- #endif -->
</view>
<!-- 分页按钮 -->
<view class="pagination-btns">
<button @click="prevPage" >上一<E4B88A>?/button>
<!-- Platform-specific pagination display for UTSJSONObject compatibility -->
<!-- #ifdef APP-ANDROID || APP-IOS -->
<text>第{{ (pagination as UTSJSONObject).getNumber("current") }}页</text>
<!-- #endif -->
<!-- #ifndef APP-ANDROID || APP-IOS -->
<text>第{{ (pagination as any)["current"] }}页</text>
<!-- #endif -->
<button @click="nextPage" :disabled="hasmore==false">下一<E4B88B>?/button>
</view>
</view>
</supadb>
</template>
<script>
type Showdata = {
name : String,
id : Number
}
export default {
data() {
return {
// supadb: null as SupadbComponentPublicInstance | null,
showdata: [] as Array<UTSJSONObject>,
collectionList: 'system_dept',
where: {},
orderby: '',
totalcount: 0,
pageSize: 20,
pageCurrent: 1,
};
},
onReady() {
// this.supadb = this.$refs["udb"] as SupadbComponentPublicInstance;
// this.supadb?.loadData?.({ clear: false })
},
methods: { onqueryload(data : UTSJSONObject[]) {
console.log('Data loaded:', data);
this.showdata = data
// const ttt:Showdata= data//{name:'aaa',id:1}
// this.showdata = [ttt]//data as Array<Showdata>
// // console.log(this.showdata[0])
// Removed map operation for UTS compatibility
},
onPageChanged(page : number) {
this.pageCurrent = page;
// this.supadb?.loadData?.({ clear: false })
}, addAkPrefix: function (items : UTSJSONObject[]) {
// Replace map operation with for loop
const result: UTSJSONObject[] = []
for (let i = 0; i < items.length; i++) {
const item = items[i]
let newItem = new UTSJSONObject(item); // 复制原对象
// Platform-specific property access for UTSJSONObject compatibility
let name: any = null
// #ifdef APP-ANDROID || APP-IOS
// Native platform: use UTSJSONObject methods
name = item.get("name");
// #endif
// #ifndef APP-ANDROID || APP-IOS
// Web platform: direct property access
name = (item as any)["name"];
// #endif
if (typeof name === "string") {
newItem.set("name", "ak_" + name);
}
result.push(newItem)
}
return result
},
prevPage()
{
this.pageCurrent = this.pageCurrent -1;
console.log(this.pageCurrent)
},
nextPage()
{
this.pageCurrent +=1;
console.log(this.pageCurrent)
}
}
};
</script>
<style scoped>
/* 添加您的样式 */
</style>