wui-components-v2 1.2.64 → 1.2.66
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.
|
@@ -12,8 +12,10 @@ defineOptions({
|
|
|
12
12
|
})
|
|
13
13
|
|
|
14
14
|
// ★ 显式 emit click,保证微信小程序下 @click 能正常触发(小程序自定义组件不会自动透传原生 tap)
|
|
15
|
+
// select:勾选模式下点击整行卡片时触发,携带记录 code
|
|
15
16
|
const emit = defineEmits<{
|
|
16
17
|
(e: 'click'): void
|
|
18
|
+
(e: 'select', code: string): void
|
|
17
19
|
}>()
|
|
18
20
|
|
|
19
21
|
const props = withDefaults(
|
|
@@ -29,6 +31,10 @@ const props = withDefaults(
|
|
|
29
31
|
groups: Groups
|
|
30
32
|
enumColumn?: Enums
|
|
31
33
|
index: number
|
|
34
|
+
/**
|
|
35
|
+
* 是否处于勾选模式。为 true 时点击整行触发 select 事件。
|
|
36
|
+
*/
|
|
37
|
+
selectMode?: boolean
|
|
32
38
|
/**
|
|
33
39
|
* 标题旁标签是否展示,由父级读取控制,默认不展示。
|
|
34
40
|
*/
|
|
@@ -138,7 +144,7 @@ function toggleCollapse(contentId: string) {
|
|
|
138
144
|
<!-- 订单卡片2 -->
|
|
139
145
|
<view
|
|
140
146
|
class="ma-2 overflow-hidden rounded-xl bg-white shadow-sm dark:bg-[var(--wot-dark-background2)]"
|
|
141
|
-
@click="emit('click')"
|
|
147
|
+
@click.stop="selectMode ? emit('select', data.code) : emit('click')"
|
|
142
148
|
>
|
|
143
149
|
<!-- 订单头部 -->
|
|
144
150
|
<view v-if="props.primaryColumn" class="flex items-center justify-between border-b border-gray-100 p-4">
|
|
@@ -34,6 +34,11 @@ const props = withDefaults(
|
|
|
34
34
|
* 是否处于批量操作(勾选)模式。为 true 时「批量操作」按钮文本切换为「取消批量操作」。
|
|
35
35
|
*/
|
|
36
36
|
batchEditing?: boolean
|
|
37
|
+
/**
|
|
38
|
+
* 是否存在批量操作能力(config.buttons 含 batchDelete/batchEdit,或有 multible action)。
|
|
39
|
+
* 为 false 时不展示「批量操作」按钮。
|
|
40
|
+
*/
|
|
41
|
+
batchOpsVisible?: boolean
|
|
37
42
|
}>(),
|
|
38
43
|
{
|
|
39
44
|
showButtons: true,
|
|
@@ -279,7 +284,13 @@ console.log(props.buttons, '33333')
|
|
|
279
284
|
>
|
|
280
285
|
{{ props.config?.exportBtnTitle || '导出' }}
|
|
281
286
|
</wd-button>
|
|
282
|
-
<wd-button
|
|
287
|
+
<wd-button
|
|
288
|
+
v-if="props.batchOpsVisible !== false"
|
|
289
|
+
class="flex-1"
|
|
290
|
+
type="primary"
|
|
291
|
+
@click="emit('batchEdit')"
|
|
292
|
+
:icon="props.batchEditing ? 'close' : 'edit'"
|
|
293
|
+
>
|
|
283
294
|
{{ props.batchEditing ? '取消批量操作' : props.config?.editBtnTitle || '批量操作' }}
|
|
284
295
|
</wd-button>
|
|
285
296
|
</view>
|
|
@@ -1,13 +1,21 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
|
-
import { computed, defineOptions, defineProps } from 'vue'
|
|
2
|
+
import { computed, defineEmits, defineOptions, defineProps } from 'vue'
|
|
3
3
|
import type { Columns, Entities, Enums, FoldCardModel, Groups } from '../../type'
|
|
4
4
|
import { formatItemData } from '../../utils'
|
|
5
5
|
import ControlTypeSupportor from '../../utils/control-type-supportor'
|
|
6
6
|
|
|
7
7
|
defineOptions({
|
|
8
8
|
name: 'ProductCard',
|
|
9
|
+
// 关闭属性透传,避免根节点原生 @click 与显式 emit('click') 重复触发
|
|
10
|
+
inheritAttrs: false,
|
|
9
11
|
})
|
|
10
12
|
|
|
13
|
+
// 显式 emit click / select,供外层 @click / @select 监听整行点击
|
|
14
|
+
const emit = defineEmits<{
|
|
15
|
+
(e: 'click'): void
|
|
16
|
+
(e: 'select', code: string): void
|
|
17
|
+
}>()
|
|
18
|
+
|
|
11
19
|
const props = defineProps<{
|
|
12
20
|
columns: Columns[]
|
|
13
21
|
collapseNum?: number
|
|
@@ -22,6 +30,10 @@ const props = defineProps<{
|
|
|
22
30
|
cardShowCols?: Columns[]
|
|
23
31
|
index: number
|
|
24
32
|
mainPicture?: Columns
|
|
33
|
+
/**
|
|
34
|
+
* 是否处于勾选模式。为 true 时点击整行触发 select 事件。
|
|
35
|
+
*/
|
|
36
|
+
selectMode?: boolean
|
|
25
37
|
}>()
|
|
26
38
|
|
|
27
39
|
// 标签字段
|
|
@@ -45,7 +57,10 @@ function isControlType(item: Columns): string {
|
|
|
45
57
|
<!-- 订单卡片容器 -->
|
|
46
58
|
<view class="mx-auto max-w-md space-y-4">
|
|
47
59
|
<!-- 订单卡片2 -->
|
|
48
|
-
<view
|
|
60
|
+
<view
|
|
61
|
+
class="ma-2 overflow-hidden rounded-xl bg-white p-2 shadow-sm dark:bg-[var(--wot-dark-background2)]"
|
|
62
|
+
@click="selectMode ? emit('select', data.code) : emit('click')"
|
|
63
|
+
>
|
|
49
64
|
<view class="flex">
|
|
50
65
|
<!-- 图片 -->
|
|
51
66
|
<wd-img
|
|
@@ -184,8 +184,21 @@ const allChecked = computed(() => {
|
|
|
184
184
|
const hasSelected = computed(() => selectedCodes.value.size > 0)
|
|
185
185
|
/** 是否处于勾选模式(常驻 batchSelect 或点「批量编辑」动态进入 selectMode) */
|
|
186
186
|
const inSelectMode = computed(() => props.batchSelect || selectMode.value)
|
|
187
|
-
/**
|
|
188
|
-
|
|
187
|
+
/**
|
|
188
|
+
* 是否存在批量操作能力:config.buttons 含 batchDelete 或 batchEdit,
|
|
189
|
+
* 或 batchActionButtons 有数据(multible === true 的 action)。
|
|
190
|
+
* 供顶部「批量操作」按钮与底部批量操作条共用。
|
|
191
|
+
*/
|
|
192
|
+
const hasBatchOperation = computed(
|
|
193
|
+
() =>
|
|
194
|
+
config.value.buttons.includes('batchDelete') ||
|
|
195
|
+
config.value.buttons.includes('batchEdit') ||
|
|
196
|
+
batchActionButtons.value.length > 0
|
|
197
|
+
)
|
|
198
|
+
/**
|
|
199
|
+
* 批量操作条是否显示:进入勾选模式且存在可执行操作时显示。
|
|
200
|
+
*/
|
|
201
|
+
const showBatchBar = computed(() => inSelectMode.value && hasBatchOperation.value)
|
|
189
202
|
/** 顶部「批量编辑」点击后动态进入的勾选模式开关 */
|
|
190
203
|
const selectMode = ref(false)
|
|
191
204
|
/**
|
|
@@ -203,7 +216,8 @@ const batchActionButtons = computed(() => {
|
|
|
203
216
|
}
|
|
204
217
|
const merged = [...(config.value.customButtons || []), ...(config.value.actions || [])]
|
|
205
218
|
const seen = new Set<string>()
|
|
206
|
-
|
|
219
|
+
// 仅收集标记为批量操作(multible === true)的 action,并按 id 去重
|
|
220
|
+
return merged.filter(item => item.multible === true && (seen.has(item.id) ? false : (seen.add(item.id), true)))
|
|
207
221
|
})
|
|
208
222
|
/** 已选 code 的逗号分隔字符串,供批量接口与弹窗透传 */
|
|
209
223
|
const selectedCodesStr = computed(() => Array.from(selectedCodes.value).join(','))
|
|
@@ -323,6 +337,10 @@ function batchDelete() {
|
|
|
323
337
|
// 批量执行 action:需要表单输入则弹窗,否则直接提交
|
|
324
338
|
async function batchAction(item: rowActions) {
|
|
325
339
|
if (item?.path) {
|
|
340
|
+
if (!hasSelected.value) {
|
|
341
|
+
toast.warning({ msg: '请先勾选要处理的记录' })
|
|
342
|
+
return
|
|
343
|
+
}
|
|
326
344
|
uni.navigateTo({
|
|
327
345
|
url: item.path + '?sourceId=' + internalSourceId.value + '&codes=' + selectedCodesStr.value,
|
|
328
346
|
})
|
|
@@ -512,6 +530,7 @@ function tabSearchClick(data: any) {
|
|
|
512
530
|
:show-buttons="showTopButtons"
|
|
513
531
|
:query-key="queryKey"
|
|
514
532
|
:batch-editing="selectMode"
|
|
533
|
+
:batch-ops-visible="hasBatchOperation"
|
|
515
534
|
@batch-edit="toggleBatchEdit"
|
|
516
535
|
/>
|
|
517
536
|
</view>
|
|
@@ -537,27 +556,31 @@ function tabSearchClick(data: any) {
|
|
|
537
556
|
model="complex"
|
|
538
557
|
:card-show-cols="config.cardShowCols"
|
|
539
558
|
:main-picture="config.mainPicture"
|
|
559
|
+
:select-mode="inSelectMode"
|
|
560
|
+
@select="toggleSelect"
|
|
540
561
|
>
|
|
541
562
|
<template #buttons>
|
|
542
|
-
<
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
563
|
+
<view v-if="!inSelectMode" @click.stop>
|
|
564
|
+
<slot name="cardBotomButtons" :data="item" />
|
|
565
|
+
<CardBotomButtons
|
|
566
|
+
:primary-column="config.primaryColumn"
|
|
567
|
+
:add-event="addEvent"
|
|
568
|
+
:detail-button-handle="detailButtonHandle"
|
|
569
|
+
:zpaging="Zpaging"
|
|
570
|
+
:enum-column="enumColumn"
|
|
571
|
+
:actions="config.actions"
|
|
572
|
+
:row-actions="config.rowActions"
|
|
573
|
+
:ractions="config.ractions"
|
|
574
|
+
:source-id="internalSourceId"
|
|
575
|
+
:item="config"
|
|
576
|
+
:code="item.code"
|
|
577
|
+
:page-type="pageType"
|
|
578
|
+
:data="item"
|
|
579
|
+
:is-show-action="isShowAction"
|
|
580
|
+
:copy-mode="config.copyMode"
|
|
581
|
+
:edit-button-config="editButtonConfig"
|
|
582
|
+
/>
|
|
583
|
+
</view>
|
|
561
584
|
</template>
|
|
562
585
|
</productCard>
|
|
563
586
|
</view>
|
|
@@ -579,6 +602,8 @@ function tabSearchClick(data: any) {
|
|
|
579
602
|
:show-detail-popup="showDetailPopup"
|
|
580
603
|
:detail-button-handle="detailButtonHandle"
|
|
581
604
|
model="complex"
|
|
605
|
+
:select-mode="inSelectMode"
|
|
606
|
+
@select="toggleSelect"
|
|
582
607
|
>
|
|
583
608
|
<template #select>
|
|
584
609
|
<view v-if="inSelectMode" @click.stop>
|
|
@@ -586,27 +611,29 @@ function tabSearchClick(data: any) {
|
|
|
586
611
|
</view>
|
|
587
612
|
</template>
|
|
588
613
|
<template #buttons>
|
|
589
|
-
<
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
614
|
+
<view v-if="!inSelectMode" @click.stop>
|
|
615
|
+
<slot name="cardBotomButtons" :data="item" />
|
|
616
|
+
<CardBotomButtons
|
|
617
|
+
:primary-column="config.primaryColumn"
|
|
618
|
+
:add-event="addEvent"
|
|
619
|
+
:detail-button-handle="detailButtonHandle"
|
|
620
|
+
:zpaging="Zpaging"
|
|
621
|
+
:enum-column="enumColumn"
|
|
622
|
+
:actions="config.actions"
|
|
623
|
+
:row-actions="config.rowActions"
|
|
624
|
+
:ractions="config.ractions"
|
|
625
|
+
:source-id="internalSourceId"
|
|
626
|
+
:item="config"
|
|
627
|
+
:code="item.code"
|
|
628
|
+
:page-type="pageType"
|
|
629
|
+
:data="item"
|
|
630
|
+
:button-delete-action="config.buttonDeleteAction"
|
|
631
|
+
:button-edit-action="config.buttonEditAction"
|
|
632
|
+
:is-show-action="isShowAction"
|
|
633
|
+
:copy-mode="config.copyMode"
|
|
634
|
+
:edit-button-config="editButtonConfig"
|
|
635
|
+
/>
|
|
636
|
+
</view>
|
|
610
637
|
</template>
|
|
611
638
|
</foldCard2>
|
|
612
639
|
</view>
|
package/package.json
CHANGED