wui-components-v2 1.2.31 → 1.2.33

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.
@@ -2,7 +2,7 @@
2
2
  import { computed, defineOptions, defineProps, ref } from 'vue'
3
3
  import { useRouter } from 'uni-mini-router'
4
4
  import { onLoad } from '@dcloudio/uni-app'
5
- import type { ClassEditConfigs, Columns, EditButtonConfig, Entities, Enums, Fields, Groups, rowActions } from '../../type'
5
+ import type { ClassEditConfigs, Columns, DeleteButtonConfig, DetailButtonConfig, EditButtonConfig, Entities, Enums, Fields, Groups, rowActions } from '../../type'
6
6
  import ActionPopup from '../action-popup/action-popup.vue'
7
7
  import { actionDataSave, copyDataApi, deleteData, editPageConfig } from '../../api/page'
8
8
  import { useGlobalToast } from '../../composables/useGlobalToast'
@@ -41,6 +41,16 @@ const props = defineProps<{
41
41
  * 不传时走组件内置的 edit() 跳转逻辑。
42
42
  */
43
43
  editButtonConfig?: EditButtonConfig
44
+ /**
45
+ * 自定义删除按钮配置:动态文字 / 显隐 / 点击行为。
46
+ * 不传时走组件内置的 del() 逻辑。
47
+ */
48
+ deleteButtonConfig?: DeleteButtonConfig
49
+ /**
50
+ * 自定义详情按钮配置:动态文字 / 显隐 / 点击行为。
51
+ * 不传时走组件内置的 detail() 跳转逻辑。
52
+ */
53
+ detailButtonConfig?: DetailButtonConfig
44
54
  }>()
45
55
  const toast = useGlobalToast()
46
56
  const message = useGlobalMessage()
@@ -134,6 +144,86 @@ function editButtonClick() {
134
144
  edit()
135
145
  }
136
146
 
147
+ // ===== 自定义删除按钮(deleteButtonConfig) =====
148
+ // 按钮文字:优先用 deleteButtonConfig.label,否则默认「删除」
149
+ const deleteButtonLabel = computed(() => {
150
+ if (props.deleteButtonConfig?.label) {
151
+ try {
152
+ return props.deleteButtonConfig.label(props.data, editButtonCtx.value) || '删除'
153
+ } catch (e) {
154
+ console.error('[deleteButtonConfig.label] 执行异常', e)
155
+ }
156
+ }
157
+ return '删除'
158
+ })
159
+
160
+ // 是否显示:优先用 deleteButtonConfig.show,否则默认显示
161
+ const deleteButtonShow = computed(() => {
162
+ if (props.deleteButtonConfig?.show) {
163
+ try {
164
+ return props.deleteButtonConfig.show(props.data, editButtonCtx.value)
165
+ } catch (e) {
166
+ console.error('[deleteButtonConfig.show] 执行异常', e)
167
+ return true
168
+ }
169
+ }
170
+ // 未配置自定义时,沿用原有「singleDelete 且 visible」逻辑
171
+ return props.item.buttons.includes('singleDelete') && isActionVisible(props.buttonDeleteAction)
172
+ })
173
+
174
+ // 点击:优先走 deleteButtonConfig.clickAction,否则回退默认 del() 逻辑
175
+ function deleteButtonClick() {
176
+ if (props.deleteButtonConfig?.clickAction) {
177
+ try {
178
+ props.deleteButtonConfig.clickAction(props.data, editButtonCtx.value)
179
+ } catch (e) {
180
+ console.error('[deleteButtonConfig.clickAction] 执行异常', e)
181
+ }
182
+ return
183
+ }
184
+ del()
185
+ }
186
+
187
+ // ===== 自定义详情按钮(detailButtonConfig) =====
188
+ // 按钮文字:优先用 detailButtonConfig.label,否则默认「详情」
189
+ const detailButtonLabel = computed(() => {
190
+ if (props.detailButtonConfig?.label) {
191
+ try {
192
+ return props.detailButtonConfig.label(props.data, editButtonCtx.value) || '详情'
193
+ } catch (e) {
194
+ console.error('[detailButtonConfig.label] 执行异常', e)
195
+ }
196
+ }
197
+ return '详情'
198
+ })
199
+
200
+ // 是否显示:优先用 detailButtonConfig.show,否则默认显示
201
+ const detailButtonShow = computed(() => {
202
+ if (props.detailButtonConfig?.show) {
203
+ try {
204
+ return props.detailButtonConfig.show(props.data, editButtonCtx.value)
205
+ } catch (e) {
206
+ console.error('[detailButtonConfig.show] 执行异常', e)
207
+ return true
208
+ }
209
+ }
210
+ // 未配置自定义时,沿用原有「detail 按钮存在」逻辑
211
+ return props.item.buttons.includes('detail')
212
+ })
213
+
214
+ // 点击:优先走 detailButtonConfig.clickAction,否则回退默认 detail() 跳转
215
+ function detailButtonClick() {
216
+ if (props.detailButtonConfig?.clickAction) {
217
+ try {
218
+ props.detailButtonConfig.clickAction(props.data, editButtonCtx.value)
219
+ } catch (e) {
220
+ console.error('[detailButtonConfig.clickAction] 执行异常', e)
221
+ }
222
+ return
223
+ }
224
+ detail()
225
+ }
226
+
137
227
  const actionItem = ref<Groups>()
138
228
  const actionItemShow = ref(false) // rowActions输入弹框开关
139
229
  // 打开rowActions弹框
@@ -366,18 +456,25 @@ console.log(props, '3333333333333')
366
456
  >
367
457
  {{ editButtonLabel }}
368
458
  </wd-button>
369
- <wd-button v-if="props.item.buttons.includes('detail')" size="small" type="info" @click="detail()">详情</wd-button>
459
+ <wd-button
460
+ v-if="isShowAction !== false && props.item.buttons.includes('detail') && detailButtonShow"
461
+ size="small"
462
+ type="info"
463
+ @click="detailButtonClick()"
464
+ >
465
+ {{ detailButtonLabel }}
466
+ </wd-button>
370
467
  <wd-button
371
468
  v-if="
372
469
  isShowAction !== false &&
373
470
  props.item.buttons.includes('singleDelete') &&
374
- isActionVisible(props.buttonDeleteAction)
471
+ deleteButtonShow
375
472
  "
376
473
  size="small"
377
474
  type="danger"
378
- @click="del()"
475
+ @click="deleteButtonClick()"
379
476
  >
380
- 删除
477
+ {{ deleteButtonLabel }}
381
478
  </wd-button>
382
479
  <ActionPopup
383
480
  v-model:show="actionItemShow"
@@ -33,10 +33,16 @@ const props = withDefaults(
33
33
  * 标题旁标签是否展示,由父级读取控制,默认不展示。
34
34
  */
35
35
  showLabel?: boolean
36
+ /**
37
+ * 是否显示详情弹窗(detailPopup),透传给 LabelValue。默认 true。
38
+ */
39
+ showDetailPopup?: boolean
36
40
  }>(),
37
41
  {
38
42
  // 标题旁标签默认不展示
39
43
  showLabel: false,
44
+ // 详情弹窗默认显示
45
+ showDetailPopup: true,
40
46
  }
41
47
  )
42
48
  const { currentThemeColor } = useManualTheme()
@@ -176,12 +182,12 @@ function toggleCollapse(contentId: string) {
176
182
  <view class="mb-3">
177
183
  <!-- 订单信息 -->
178
184
  <view class="text-sm space-y-3">
179
- <LabelValue :exhibit-data="exhibitData" :data="data" :index="index" />
185
+ <LabelValue :exhibit-data="exhibitData" :data="data" :index="index" :show-detail-popup="showDetailPopup" />
180
186
 
181
187
  <!-- 可折叠内容 -->
182
188
  <view class="fold-collapse" :class="expanded ? 'is-expanded' : 'is-collapsed'">
183
189
  <view class="space-y-3">
184
- <LabelValue :exhibit-data="collapseData" :data="data" :index="index" />
190
+ <LabelValue :exhibit-data="collapseData" :data="data" :index="index" :show-detail-popup="showDetailPopup" />
185
191
  </view>
186
192
  </view>
187
193
  </view>
@@ -16,6 +16,12 @@ const props = defineProps<{
16
16
  exhibitData: Columns[]
17
17
  data: Entities
18
18
  index: number
19
+ /**
20
+ * 是否显示详情弹窗(detailPopup)。默认 true。
21
+ * 为 true 时:字段配置了 detail 按钮时显示可点击的 detailPopup 弹窗
22
+ * 为 false 时:字段配置了 detail 按钮时仅显示「详情」文字,不可点击
23
+ */
24
+ showDetailPopup?: boolean
19
25
  }>()
20
26
  const { primary } = useManualTheme()
21
27
  const clums = computed(() => {
@@ -130,11 +136,14 @@ function isControlType(item: Columns): string {
130
136
  {{ index + 1 }}
131
137
  </view>
132
138
  <view v-else-if="item.buttons?.includes('detail')" class="flex flex-1 items-center text-gray-800 dark:text-white">
133
- <detailPopup
134
- :source="item"
135
- :text="formatItemData(data.fieldMap[item.sourceId], isControlType(item))"
136
- :code="data.fieldMap[item.sourceId]"
137
- />
139
+ <template v-if="props.showDetailPopup !== false">
140
+ <detailPopup
141
+ :source="item"
142
+ :text="formatItemData(data.fieldMap[item.sourceId], isControlType(item))"
143
+ :code="data.fieldMap[item.sourceId]"
144
+ />
145
+ </template>
146
+ <view>详情</view>
138
147
  </view>
139
148
  <openValueMore v-else :text="formatItemData(data.fieldMap[item.sourceId], isControlType(item))" />
140
149
  </view>
@@ -37,6 +37,12 @@ withDefaults(
37
37
  * 不传时走组件内置的「编辑」按钮逻辑。
38
38
  */
39
39
  editButtonConfig?: EditButtonConfig
40
+ /**
41
+ * 是否显示详情弹窗(detailPopup)。默认 true。
42
+ * 为 true 时:字段配置了 detail 按钮时显示可点击的 detailPopup 弹窗
43
+ * 为 false 时:字段配置了 detail 按钮时仅显示「详情」文字,不可点击
44
+ */
45
+ showDetailPopup?: boolean
40
46
  }>(),
41
47
  {
42
48
  // 操作按钮区域(编辑/删除/morebutns)默认显示
@@ -45,6 +51,8 @@ withDefaults(
45
51
  showTopButtons: true,
46
52
  // 标题旁标签默认不展示
47
53
  showLabel: false,
54
+ // 详情弹窗默认显示
55
+ showDetailPopup: true,
48
56
  }
49
57
  )
50
58
 
@@ -291,6 +299,7 @@ function tabSearchClick(data: any) {
291
299
  :second-column="config.secondColumn"
292
300
  :label-column="config.labelColumn"
293
301
  :show-label="showLabel"
302
+ :show-detail-popup="showDetailPopup"
294
303
  model="complex"
295
304
  >
296
305
  <template #buttons>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wui-components-v2",
3
- "version": "1.2.31",
3
+ "version": "1.2.33",
4
4
  "description": "wui 组件库",
5
5
  "author": "wgxshh",
6
6
  "license": "MIT",
package/type.ts CHANGED
@@ -95,6 +95,44 @@ export interface EditButtonConfig {
95
95
  clickAction?: (data: Entities, ctx: EditButtonCtx) => void
96
96
  }
97
97
 
98
+ /**
99
+ * 删除按钮的自定义配置。
100
+ * 用于父级在不改动组件内置删除逻辑的前提下,定制按钮文字、显隐与点击行为。
101
+ */
102
+ export interface DeleteButtonCtx {
103
+ sourceId: string
104
+ code: string
105
+ mainCode: string
106
+ pageType: string
107
+ }
108
+ export interface DeleteButtonConfig {
109
+ /** 动态按钮文字,默认「删除」 */
110
+ label?: (data: Entities, ctx: DeleteButtonCtx) => string
111
+ /** 是否显示该按钮,默认 true;返回 false 时整颗按钮隐藏 */
112
+ show?: (data: Entities, ctx: DeleteButtonCtx) => boolean
113
+ /** 点击回调;提供时优先于组件内置的 del() 逻辑 */
114
+ clickAction?: (data: Entities, ctx: DeleteButtonCtx) => void
115
+ }
116
+
117
+ /**
118
+ * 详情按钮的自定义配置。
119
+ * 用于父级在不改动组件内置详情跳转的前提下,定制按钮文字、显隐与点击行为。
120
+ */
121
+ export interface DetailButtonCtx {
122
+ sourceId: string
123
+ code: string
124
+ mainCode: string
125
+ pageType: string
126
+ }
127
+ export interface DetailButtonConfig {
128
+ /** 动态按钮文字,默认「详情」 */
129
+ label?: (data: Entities, ctx: DetailButtonCtx) => string
130
+ /** 是否显示该按钮,默认 true;返回 false 时整颗按钮隐藏 */
131
+ show?: (data: Entities, ctx: DetailButtonCtx) => boolean
132
+ /** 点击回调;提供时优先于组件内置的 detail() 跳转 */
133
+ clickAction?: (data: Entities, ctx: DetailButtonCtx) => void
134
+ }
135
+
98
136
  // 字段自定义校验规则(如 { message, pattern })
99
137
  export interface FieldRule {
100
138
  message?: string | null