wui-components-v2 1.2.35 → 1.2.37
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/components/wui-list/wui-list.vue +35 -12
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
|
-
import { defineOptions,
|
|
2
|
+
import { defineOptions, onMounted, onUnmounted, ref } from 'vue'
|
|
3
3
|
import { onLoad } from '@dcloudio/uni-app'
|
|
4
4
|
import { listData, pageConfig, pageKey } from '../../api/page'
|
|
5
5
|
import foldCard2 from '../fold-card2/fold-card2.vue'
|
|
@@ -15,8 +15,12 @@ import { useEnums } from '../../composables/useEnumes'
|
|
|
15
15
|
defineOptions({
|
|
16
16
|
name: 'WuiList',
|
|
17
17
|
})
|
|
18
|
-
withDefaults(
|
|
18
|
+
const props = withDefaults(
|
|
19
19
|
defineProps<{
|
|
20
|
+
/** 数据源 ID,用于获取页面配置和列表数据 */
|
|
21
|
+
sourceId?: string
|
|
22
|
+
/** 查询条件字符串,用于列表数据筛选 */
|
|
23
|
+
query?: string
|
|
20
24
|
isShowAction?: boolean
|
|
21
25
|
detailButtonHandle?: (data: Entities) => void
|
|
22
26
|
/**
|
|
@@ -37,6 +41,10 @@ withDefaults(
|
|
|
37
41
|
* 不传时走组件内置的「编辑」按钮逻辑。
|
|
38
42
|
*/
|
|
39
43
|
editButtonConfig?: EditButtonConfig
|
|
44
|
+
/**
|
|
45
|
+
* 是否显示搜索区域,默认显示。
|
|
46
|
+
*/
|
|
47
|
+
showSearch?: boolean
|
|
40
48
|
/**
|
|
41
49
|
* 是否显示详情弹窗(detailPopup)。默认 true。
|
|
42
50
|
* 为 true 时:字段配置了 detail 按钮时显示可点击的 detailPopup 弹窗
|
|
@@ -51,9 +59,15 @@ withDefaults(
|
|
|
51
59
|
showTopButtons: true,
|
|
52
60
|
// 标题旁标签默认不展示
|
|
53
61
|
showLabel: false,
|
|
62
|
+
// 搜索区域默认显示
|
|
63
|
+
showSearch: true,
|
|
54
64
|
// 详情弹窗默认显示
|
|
55
65
|
showDetailPopup: true,
|
|
56
|
-
|
|
66
|
+
// 数据源 ID 默认为空
|
|
67
|
+
sourceId: '',
|
|
68
|
+
// 查询条件默认为空
|
|
69
|
+
query: '',
|
|
70
|
+
},
|
|
57
71
|
)
|
|
58
72
|
|
|
59
73
|
const Zpaging = ref<any>(null)
|
|
@@ -98,7 +112,6 @@ const config = ref<Config>({
|
|
|
98
112
|
buttonEditAction: {},
|
|
99
113
|
})
|
|
100
114
|
const { getEnums, enumColumn } = useEnums({ config })
|
|
101
|
-
const sourceId = ref('')
|
|
102
115
|
const datas = ref<Entities[]>([])
|
|
103
116
|
const pageTitle = ref('')
|
|
104
117
|
const searchData = ref('')
|
|
@@ -107,8 +120,13 @@ const pageType = ref('')
|
|
|
107
120
|
const mainCode = ref('')
|
|
108
121
|
const queryKey = ref('') // 用于导出接口的列表查询 key
|
|
109
122
|
const addEvent = generateHighResolutionID() // 全局事件名称
|
|
123
|
+
// 优先使用 props 传入的 sourceId,未传则走 onLoad 路由获取
|
|
124
|
+
const internalSourceId = ref(props.sourceId)
|
|
110
125
|
onLoad((option: any) => {
|
|
111
|
-
|
|
126
|
+
// 如果 props 没传 sourceId,则从路由参数获取
|
|
127
|
+
if (!internalSourceId.value) {
|
|
128
|
+
internalSourceId.value = option.sourceId
|
|
129
|
+
}
|
|
112
130
|
pageTitle.value = option.title
|
|
113
131
|
pageType.value = option.pageType
|
|
114
132
|
mainCode.value = option.mainCode || ''
|
|
@@ -131,7 +149,7 @@ onUnmounted(() => {
|
|
|
131
149
|
})
|
|
132
150
|
async function getPageConfig() {
|
|
133
151
|
try {
|
|
134
|
-
const res = await pageConfig(
|
|
152
|
+
const res = await pageConfig(internalSourceId.value)
|
|
135
153
|
if (res.ltmplConfig) {
|
|
136
154
|
config.value = res.ltmplConfig
|
|
137
155
|
console.log('config', config.value)
|
|
@@ -156,6 +174,10 @@ async function queryList(pageNo: number, pageSize: number) {
|
|
|
156
174
|
// paging.value.reload() // 手动触发加载
|
|
157
175
|
// })
|
|
158
176
|
let qre = tabSearchData.value || searchData.value
|
|
177
|
+
// 合并 props.query(父级传入的查询条件)
|
|
178
|
+
if (props.query) {
|
|
179
|
+
qre = qre ? `${qre}&${props.query}` : props.query
|
|
180
|
+
}
|
|
159
181
|
if (config.value.defaultCriteriaValue) {
|
|
160
182
|
for (const key in config.value.defaultCriteriaValue) {
|
|
161
183
|
if (Object.prototype.hasOwnProperty.call(config.value.defaultCriteriaValue, key)) {
|
|
@@ -168,7 +190,7 @@ async function queryList(pageNo: number, pageSize: number) {
|
|
|
168
190
|
}
|
|
169
191
|
|
|
170
192
|
try {
|
|
171
|
-
const res = await pageKey(
|
|
193
|
+
const res = await pageKey(internalSourceId.value, mainCode.value, qre) // 获取key
|
|
172
194
|
const data = await listData(res.key, pageNo, pageSize) // 获取数据
|
|
173
195
|
// 缓存最新一次的 queryKey,给顶部「导出」接口使用
|
|
174
196
|
queryKey.value = res.key || res.data?.key || ''
|
|
@@ -218,6 +240,7 @@ function tabSearchClick(data: any) {
|
|
|
218
240
|
<template #top>
|
|
219
241
|
<slot name="top" />
|
|
220
242
|
<Search
|
|
243
|
+
v-if="showSearch"
|
|
221
244
|
:main-code="mainCode"
|
|
222
245
|
:enum-column="enumColumn"
|
|
223
246
|
:criteria="config.criteria"
|
|
@@ -230,7 +253,7 @@ function tabSearchClick(data: any) {
|
|
|
230
253
|
:add-event="addEvent"
|
|
231
254
|
:main-code="mainCode"
|
|
232
255
|
:buttons="config.buttons"
|
|
233
|
-
:source-id="
|
|
256
|
+
:source-id="internalSourceId"
|
|
234
257
|
:page-title="pageTitle"
|
|
235
258
|
:page-type="pageType"
|
|
236
259
|
:config="config"
|
|
@@ -250,7 +273,7 @@ function tabSearchClick(data: any) {
|
|
|
250
273
|
:index="index"
|
|
251
274
|
:enum-column="enumColumn"
|
|
252
275
|
:collapse-num="5"
|
|
253
|
-
:source-id="
|
|
276
|
+
:source-id="internalSourceId"
|
|
254
277
|
:groups="config"
|
|
255
278
|
:data="item"
|
|
256
279
|
:columns="config.columns"
|
|
@@ -272,7 +295,7 @@ function tabSearchClick(data: any) {
|
|
|
272
295
|
:actions="config.actions"
|
|
273
296
|
:row-actions="config.rowActions"
|
|
274
297
|
:ractions="config.ractions"
|
|
275
|
-
:source-id="
|
|
298
|
+
:source-id="internalSourceId"
|
|
276
299
|
:item="config"
|
|
277
300
|
:code="item.code"
|
|
278
301
|
:page-type="pageType"
|
|
@@ -291,7 +314,7 @@ function tabSearchClick(data: any) {
|
|
|
291
314
|
:index="index"
|
|
292
315
|
:enum-column="enumColumn"
|
|
293
316
|
:collapse-num="collapseNum"
|
|
294
|
-
:source-id="
|
|
317
|
+
:source-id="internalSourceId"
|
|
295
318
|
:groups="config"
|
|
296
319
|
:data="item"
|
|
297
320
|
:columns="config.columns"
|
|
@@ -314,7 +337,7 @@ function tabSearchClick(data: any) {
|
|
|
314
337
|
:actions="config.actions"
|
|
315
338
|
:row-actions="config.rowActions"
|
|
316
339
|
:ractions="config.ractions"
|
|
317
|
-
:source-id="
|
|
340
|
+
:source-id="internalSourceId"
|
|
318
341
|
:item="config"
|
|
319
342
|
:code="item.code"
|
|
320
343
|
:page-type="pageType"
|