wui-components-v2 1.2.34 → 1.2.36

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.
@@ -16,19 +16,32 @@ const emit = defineEmits<{
16
16
  (e: 'click'): void
17
17
  }>()
18
18
 
19
- const props = defineProps<{
20
- columns: Columns[]
21
- collapseNum?: number
22
- primaryColumn?: Columns
23
- secondColumn?: Columns
24
- labelColumn?: Columns
25
- data: Entities
26
- model: FoldCardModel
27
- sourceId: string
28
- groups: Groups
29
- enumColumn?: Enums
30
- index: number
31
- }>()
19
+ const props = withDefaults(
20
+ defineProps<{
21
+ columns: Columns[]
22
+ collapseNum?: number
23
+ primaryColumn?: Columns
24
+ secondColumn?: Columns
25
+ labelColumn?: Columns
26
+ data: Entities
27
+ model: FoldCardModel
28
+ sourceId: string
29
+ groups: Groups
30
+ enumColumn?: Enums
31
+ index: number
32
+ /**
33
+ * 是否显示详情弹窗(detailPopup),透传给 LabelValue。默认 true。
34
+ */
35
+ showDetailPopup?: boolean
36
+ /**
37
+ * 自定义详情按钮回调,透传给 LabelValue。showDetailPopup 为 false 时优先使用
38
+ */
39
+ detailButtonHandle?: (data: Entities) => void
40
+ }>(),
41
+ {
42
+ showDetailPopup: true,
43
+ }
44
+ )
32
45
  const contentRef = ref<any>()
33
46
  const { currentThemeColor } = useManualTheme()
34
47
  // 展示内容
@@ -143,12 +156,12 @@ function toggleCollapse(contentId: string) {
143
156
  <view class="mb-3">
144
157
  <!-- 订单信息 -->
145
158
  <view class="text-sm space-y-3">
146
- <LabelValue :exhibit-data="exhibitData" :data="data" :index="index" />
159
+ <LabelValue :exhibit-data="exhibitData" :data="data" :index="index" :show-detail-popup="showDetailPopup" :detail-button-handle="detailButtonHandle" />
147
160
 
148
161
  <!-- 可折叠内容 -->
149
162
  <view :id="`${data.code}`" ref="contentRef">
150
163
  <view class="space-y-3">
151
- <LabelValue :exhibit-data="collapseData" :data="data" :index="index" />
164
+ <LabelValue :exhibit-data="collapseData" :data="data" :index="index" :show-detail-popup="showDetailPopup" :detail-button-handle="detailButtonHandle" />
152
165
  </view>
153
166
  </view>
154
167
  </view>
@@ -10,6 +10,24 @@ import LabelValue from '../label-value/label-value.vue'
10
10
  defineOptions({
11
11
  name: 'WuiDetailsPage',
12
12
  })
13
+
14
+ const props = withDefaults(
15
+ defineProps<{
16
+ /**
17
+ * 是否显示详情弹窗(detailPopup),透传给 LabelValue。默认 true。
18
+ * 为 true 时:字段配置了 detail 按钮时显示可点击的 detailPopup 弹窗
19
+ * 为 false 时:字段配置了 detail 按钮时显示可点击的文字,点击跳转详情页面
20
+ */
21
+ showDetailPopup?: boolean
22
+ /**
23
+ * 自定义详情按钮回调,透传给 LabelValue / CardBotomButtons。showDetailPopup 为 false 时优先使用
24
+ */
25
+ detailButtonHandle?: (data: Entities) => void
26
+ }>(),
27
+ {
28
+ showDetailPopup: true,
29
+ }
30
+ )
13
31
  const sourceId = ref('')
14
32
  const id = ref('')
15
33
  const title = ref('')
@@ -130,7 +148,13 @@ async function getDetailData() {
130
148
  :name="group.id"
131
149
  >
132
150
  <view v-if="group.type === 'fieldGroup'" class="text-sm space-y-3">
133
- <LabelValue :index="index" :exhibit-data="group.fields" :data="data" />
151
+ <LabelValue
152
+ :index="index"
153
+ :exhibit-data="group.fields"
154
+ :data="data"
155
+ :show-detail-popup="props.showDetailPopup"
156
+ :detail-button-handle="props.detailButtonHandle"
157
+ />
134
158
  </view>
135
159
  <view v-if="group.type === 'relation'">
136
160
  <view v-for="(field, subindex) in data.arrayMap[group.id]" :key="field.code">
@@ -140,6 +164,8 @@ async function getDetailData() {
140
164
  :groups="group"
141
165
  :source-id="sourceId"
142
166
  :columns="group.fields"
167
+ :show-detail-popup="props.showDetailPopup"
168
+ :detail-button-handle="props.detailButtonHandle"
143
169
  model="complex"
144
170
  :data="field"
145
171
  >
@@ -152,6 +178,7 @@ async function getDetailData() {
152
178
  :item="groups"
153
179
  :code="field.code"
154
180
  :data="data"
181
+ :detail-button-handle="props.detailButtonHandle"
155
182
  />
156
183
  </template>
157
184
  </foldCard>
@@ -1,5 +1,5 @@
1
1
  <script lang="ts" setup>
2
- import { defineOptions, defineProps, onMounted, onUnmounted, ref } from 'vue'
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
  /**
@@ -53,7 +57,11 @@ withDefaults(
53
57
  showLabel: false,
54
58
  // 详情弹窗默认显示
55
59
  showDetailPopup: true,
56
- }
60
+ // 数据源 ID 默认为空
61
+ sourceId: '',
62
+ // 查询条件默认为空
63
+ query: '',
64
+ },
57
65
  )
58
66
 
59
67
  const Zpaging = ref<any>(null)
@@ -98,7 +106,6 @@ const config = ref<Config>({
98
106
  buttonEditAction: {},
99
107
  })
100
108
  const { getEnums, enumColumn } = useEnums({ config })
101
- const sourceId = ref('')
102
109
  const datas = ref<Entities[]>([])
103
110
  const pageTitle = ref('')
104
111
  const searchData = ref('')
@@ -107,8 +114,13 @@ const pageType = ref('')
107
114
  const mainCode = ref('')
108
115
  const queryKey = ref('') // 用于导出接口的列表查询 key
109
116
  const addEvent = generateHighResolutionID() // 全局事件名称
117
+ // 优先使用 props 传入的 sourceId,未传则走 onLoad 路由获取
118
+ const internalSourceId = ref(props.sourceId)
110
119
  onLoad((option: any) => {
111
- sourceId.value = option.sourceId
120
+ // 如果 props 没传 sourceId,则从路由参数获取
121
+ if (!internalSourceId.value) {
122
+ internalSourceId.value = option.sourceId
123
+ }
112
124
  pageTitle.value = option.title
113
125
  pageType.value = option.pageType
114
126
  mainCode.value = option.mainCode || ''
@@ -131,7 +143,7 @@ onUnmounted(() => {
131
143
  })
132
144
  async function getPageConfig() {
133
145
  try {
134
- const res = await pageConfig(sourceId.value)
146
+ const res = await pageConfig(internalSourceId.value)
135
147
  if (res.ltmplConfig) {
136
148
  config.value = res.ltmplConfig
137
149
  console.log('config', config.value)
@@ -156,6 +168,10 @@ async function queryList(pageNo: number, pageSize: number) {
156
168
  // paging.value.reload() // 手动触发加载
157
169
  // })
158
170
  let qre = tabSearchData.value || searchData.value
171
+ // 合并 props.query(父级传入的查询条件)
172
+ if (props.query) {
173
+ qre = qre ? `${qre}&${props.query}` : props.query
174
+ }
159
175
  if (config.value.defaultCriteriaValue) {
160
176
  for (const key in config.value.defaultCriteriaValue) {
161
177
  if (Object.prototype.hasOwnProperty.call(config.value.defaultCriteriaValue, key)) {
@@ -168,7 +184,7 @@ async function queryList(pageNo: number, pageSize: number) {
168
184
  }
169
185
 
170
186
  try {
171
- const res = await pageKey(sourceId.value, mainCode.value, qre) // 获取key
187
+ const res = await pageKey(internalSourceId.value, mainCode.value, qre) // 获取key
172
188
  const data = await listData(res.key, pageNo, pageSize) // 获取数据
173
189
  // 缓存最新一次的 queryKey,给顶部「导出」接口使用
174
190
  queryKey.value = res.key || res.data?.key || ''
@@ -230,7 +246,7 @@ function tabSearchClick(data: any) {
230
246
  :add-event="addEvent"
231
247
  :main-code="mainCode"
232
248
  :buttons="config.buttons"
233
- :source-id="sourceId"
249
+ :source-id="internalSourceId"
234
250
  :page-title="pageTitle"
235
251
  :page-type="pageType"
236
252
  :config="config"
@@ -250,7 +266,7 @@ function tabSearchClick(data: any) {
250
266
  :index="index"
251
267
  :enum-column="enumColumn"
252
268
  :collapse-num="5"
253
- :source-id="sourceId"
269
+ :source-id="internalSourceId"
254
270
  :groups="config"
255
271
  :data="item"
256
272
  :columns="config.columns"
@@ -272,7 +288,7 @@ function tabSearchClick(data: any) {
272
288
  :actions="config.actions"
273
289
  :row-actions="config.rowActions"
274
290
  :ractions="config.ractions"
275
- :source-id="sourceId"
291
+ :source-id="internalSourceId"
276
292
  :item="config"
277
293
  :code="item.code"
278
294
  :page-type="pageType"
@@ -291,7 +307,7 @@ function tabSearchClick(data: any) {
291
307
  :index="index"
292
308
  :enum-column="enumColumn"
293
309
  :collapse-num="collapseNum"
294
- :source-id="sourceId"
310
+ :source-id="internalSourceId"
295
311
  :groups="config"
296
312
  :data="item"
297
313
  :columns="config.columns"
@@ -314,7 +330,7 @@ function tabSearchClick(data: any) {
314
330
  :actions="config.actions"
315
331
  :row-actions="config.rowActions"
316
332
  :ractions="config.ractions"
317
- :source-id="sourceId"
333
+ :source-id="internalSourceId"
318
334
  :item="config"
319
335
  :code="item.code"
320
336
  :page-type="pageType"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wui-components-v2",
3
- "version": "1.2.34",
3
+ "version": "1.2.36",
4
4
  "description": "wui 组件库",
5
5
  "author": "wgxshh",
6
6
  "license": "MIT",