wui-components-v2 1.2.83 → 1.2.85

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/api/page.ts CHANGED
@@ -141,6 +141,7 @@ export function copyDataApi(sourceId: string, code: string) {
141
141
  }
142
142
 
143
143
  // 导出 Excel 数据(GET,参数拼到 Query String)
144
+ // moduleName:模板配置 fileExports(音频下载/曲线下载等文件导出)对应的模块名,传入时按该模块导出
144
145
  export function exportLtmplExcel(params: {
145
146
  language?: string
146
147
  scope: 'current' | 'page' | 'all'
@@ -148,8 +149,10 @@ export function exportLtmplExcel(params: {
148
149
  queryKey: string
149
150
  startPageNo?: number
150
151
  endPageNo?: number
152
+ moduleName?: string
153
+ codes?: string
151
154
  }) {
152
- const { language = 'zh', scope, withDetail = false, queryKey, startPageNo, endPageNo } = params
155
+ const { language = 'zh', scope, withDetail = false, queryKey, startPageNo, endPageNo, moduleName, codes } = params
153
156
  const searchParts = [
154
157
  `language=${encodeURIComponent(language)}`,
155
158
  `scope=${encodeURIComponent(scope)}`,
@@ -158,12 +161,37 @@ export function exportLtmplExcel(params: {
158
161
  ]
159
162
  if (typeof startPageNo === 'number') searchParts.push(`startPageNo=${startPageNo}`)
160
163
  if (typeof endPageNo === 'number') searchParts.push(`endPageNo=${endPageNo}`)
164
+ if (moduleName) {
165
+ searchParts.push(`moduleName=${encodeURIComponent(moduleName)}`)
166
+ }
167
+ if (codes) {
168
+ searchParts.push(`codes=${encodeURIComponent(codes)}`)
169
+ }
161
170
  return req({
162
171
  url: `/v3/export/ltmpl-data-excel?${searchParts.join('&')}`,
163
172
  method: 'GET',
164
173
  })
165
174
  }
166
175
 
176
+ // 导出模板文件数据(音频下载/曲线下载等 fileExports,GET)
177
+ // 只需三个参数:language、codes(勾选记录)、sourceId(fileExports 配置项的 id)
178
+ export function exportLtmplFileData(params: {
179
+ language?: string
180
+ codes: string
181
+ sourceId: string
182
+ }) {
183
+ const { language = 'zh', codes, sourceId } = params
184
+ const searchParts = [
185
+ `language=${encodeURIComponent(language)}`,
186
+ `codes=${encodeURIComponent(codes)}`,
187
+ `sourceId=${encodeURIComponent(sourceId)}`,
188
+ ]
189
+ return req({
190
+ url: `/v3/export/ltmpl-data-filedata?${searchParts.join('&')}`,
191
+ method: 'GET',
192
+ })
193
+ }
194
+
167
195
  // 轮询导出状态
168
196
  export function exportStatus(exportId: string) {
169
197
  return req({
@@ -133,6 +133,7 @@ watch(() => props.src, () => {
133
133
  isPlaying.value = false
134
134
  currentTime.value = 0
135
135
  duration.value = 0
136
+ loadDuration()
136
137
  })
137
138
 
138
139
  // 暴露方法
@@ -148,10 +149,45 @@ onUnmounted(() => {
148
149
  innerAudioContext.value.destroy()
149
150
  innerAudioContext.value = null
150
151
  }
152
+ if (metaAudioContext.value) {
153
+ metaAudioContext.value.destroy()
154
+ metaAudioContext.value = null
155
+ }
151
156
  })
152
157
 
158
+ /**
159
+ * 元数据上下文:挂载时就创建(不播放),仅用于在用户点播放前
160
+ * 预加载音频时长,让右侧总时间一开始就能显示,而不是 00:00。
161
+ * 部分平台(App 端)onCanplay 时 duration 可能还是 0,onTimeUpdate 兜底。
162
+ */
163
+ const metaAudioContext = ref<UniApp.InnerAudioContext | null>(null)
164
+
165
+ function loadDuration() {
166
+ if (!props.src) return
167
+ if (metaAudioContext.value) {
168
+ metaAudioContext.value.destroy()
169
+ metaAudioContext.value = null
170
+ }
171
+ const ctx = uni.createInnerAudioContext()
172
+ metaAudioContext.value = ctx
173
+ ctx.onCanplay(() => {
174
+ const d = ctx.duration
175
+ if (d && Number.isFinite(d) && d > 0) {
176
+ duration.value = d
177
+ }
178
+ })
179
+ ctx.onError(() => {
180
+ ctx.destroy()
181
+ if (metaAudioContext.value === ctx) {
182
+ metaAudioContext.value = null
183
+ }
184
+ })
185
+ ctx.src = props.src
186
+ }
187
+
153
188
  // 需要自动播放时,挂载后立即播放
154
189
  onMounted(() => {
190
+ loadDuration()
155
191
  if (props.autoplay) {
156
192
  play()
157
193
  }
@@ -384,13 +384,16 @@ const morebutns = computed(() => {
384
384
  }
385
385
  if (props.actions) {
386
386
  buts = buts.concat(
387
- actions.value.map(item => {
388
- return {
389
- actionType: 'rowActions',
390
- name: item.title,
391
- ...item,
392
- }
393
- })
387
+ actions.value
388
+ // 列表级批量 action(multible === true)只在底部批量操作条展示,不渲染到行上
389
+ .filter(item => item.multible !== true)
390
+ .map(item => {
391
+ return {
392
+ actionType: 'rowActions',
393
+ name: item.title,
394
+ ...item,
395
+ }
396
+ })
394
397
  )
395
398
  }
396
399
  return buts
@@ -0,0 +1,35 @@
1
+ <script setup lang="ts">
2
+ import { defineEmits, defineOptions, defineProps } from 'vue'
3
+ import type { FilterInTabPageItem } from '../../type'
4
+
5
+ defineOptions({
6
+ name: 'FilterInTabPage',
7
+ })
8
+
9
+ const props = defineProps<{
10
+ /** 同一 blockId 下的 tab 项(由调用方按 order 排序后传入) */
11
+ tabs: FilterInTabPageItem[]
12
+ /** 当前列表页的 sourceId,用于高亮激活 tab */
13
+ activeId: string
14
+ }>()
15
+
16
+ const emit = defineEmits<{
17
+ (e: 'change', item: FilterInTabPageItem): void
18
+ }>()
19
+
20
+ // click事件:wd-tab 回调携带 name(即 item.id),换算成 tab 项后抛给父级处理跳转
21
+ function click(event: { name: string }) {
22
+ const item = props.tabs.find(i => i.id === event.name)
23
+ if (item) {
24
+ emit('change', item)
25
+ }
26
+ }
27
+ </script>
28
+
29
+ <template>
30
+ <wd-tabs :model-value="activeId" animated slidable="always" @click="click">
31
+ <block v-for="item in tabs" :key="item.id">
32
+ <wd-tab :title="item.title" :name="item.id" />
33
+ </block>
34
+ </wd-tabs>
35
+ </template>
@@ -1,7 +1,7 @@
1
1
  <script setup lang="ts">
2
- import { ref } from 'vue'
2
+ import { computed, ref } from 'vue'
3
3
  import { useRouter } from 'uni-mini-router'
4
- import { exportLtmplExcel, exportStatus as fetchExportStatus } from '../../api/page'
4
+ import { exportLtmplExcel, exportLtmplFileData, exportStatus as fetchExportStatus } from '../../api/page'
5
5
 
6
6
  defineOptions({
7
7
  name: 'ListTopButtons',
@@ -56,6 +56,10 @@ function gotoAddPage() {
56
56
  // 导出范围弹窗
57
57
  // 点击「导出」按钮时触发,弹出当前页 / 多页 / 全部 三选一弹窗
58
58
  const exportPopupShow = ref(false)
59
+ // 当前文件导出配置项(音频下载/曲线下载等 fileExports 项):通用「导出」为 null
60
+ const activeFileExport = ref<any>(null)
61
+ // 批量操作条触发时携带的已勾选记录 codes:有值时表示按勾选记录导出,隐藏范围选择
62
+ const activeCodes = ref('')
59
63
  const exportScope = ref<'current' | 'page' | 'all'>('current')
60
64
  const exportScopeOptions = [
61
65
  { value: 'current', label: '当前页' },
@@ -89,7 +93,9 @@ function clearPollTimer() {
89
93
  }
90
94
  }
91
95
 
92
- function openExportPopup() {
96
+ function openExportPopup(fileExport: any = null, codes = '') {
97
+ activeFileExport.value = fileExport
98
+ activeCodes.value = codes
93
99
  exportScope.value = 'current'
94
100
  exportStatus.value = 'idle'
95
101
  exportProgress.value = 0
@@ -126,8 +132,8 @@ async function confirmExport() {
126
132
  }
127
133
  }
128
134
 
129
- // queryKey 必传
130
- if (!props.queryKey) {
135
+ // Excel 导出 queryKey 必传;文件导出(codes + sourceId)不需要
136
+ if (!activeFileExport.value && !props.queryKey) {
131
137
  uni.showToast({ title: '列表未就绪,无法导出', icon: 'none' })
132
138
  return
133
139
  }
@@ -140,14 +146,24 @@ async function confirmExport() {
140
146
 
141
147
  try {
142
148
  // 1. 发起导出请求,获取 exportId
143
- const exportRes: any = await exportLtmplExcel({
144
- language: 'zh',
145
- scope: exportScope.value,
146
- withDetail: props.withDetail,
147
- queryKey: props.queryKey,
148
- startPageNo,
149
- endPageNo,
150
- })
149
+ // 文件导出(音频下载/曲线下载等)只传 language/codes/sourceId,其余走 Excel 导出
150
+ let exportRes: any
151
+ if (activeFileExport.value) {
152
+ exportRes = await exportLtmplFileData({
153
+ language: 'zh',
154
+ codes: activeCodes.value,
155
+ sourceId: activeFileExport.value.id,
156
+ })
157
+ } else {
158
+ exportRes = await exportLtmplExcel({
159
+ language: 'zh',
160
+ scope: exportScope.value,
161
+ withDetail: props.withDetail,
162
+ queryKey: props.queryKey,
163
+ startPageNo,
164
+ endPageNo,
165
+ })
166
+ }
151
167
  exportId.value = exportRes?.exportId || exportRes?.data?.exportId
152
168
  if (!exportId.value) {
153
169
  exportStatus.value = 'cancelled'
@@ -204,6 +220,9 @@ function retryExport() {
204
220
  exportFileName.value = ''
205
221
  }
206
222
 
223
+ // 弹窗标题:文件导出显示对应配置的 title,通用导出显示「导出」
224
+ const exportPopupTitle = computed(() => activeFileExport.value?.title || '导出')
225
+
207
226
  function downloadExportFile() {
208
227
  if (!exportId.value) {
209
228
  uni.showToast({ title: '导出任务 ID 丢失,请重新导出', icon: 'none' })
@@ -268,6 +287,11 @@ function downloadExportFile() {
268
287
  }
269
288
 
270
289
  console.log(props.buttons, '33333')
290
+
291
+ // 供父组件(如 wui-list 底部批量操作条)触发文件导出弹窗
292
+ defineExpose({
293
+ openExportPopup,
294
+ })
271
295
  </script>
272
296
 
273
297
  <template>
@@ -279,11 +303,13 @@ console.log(props.buttons, '33333')
279
303
  class="flex-1"
280
304
  v-if="buttons.includes('exportLtmplExcel')"
281
305
  type="primary"
282
- @click="openExportPopup"
306
+ @click="openExportPopup()"
283
307
  icon="download"
284
308
  >
285
309
  {{ props.config?.exportBtnTitle || '导出' }}
286
310
  </wd-button>
311
+ <!-- 自定义按钮:由调用方(wui-list)透传插槽注入,显示在「批量操作」按钮左边 -->
312
+ <slot />
287
313
  <wd-button
288
314
  v-if="props.batchOpsVisible !== false"
289
315
  class="flex-1"
@@ -305,7 +331,7 @@ console.log(props.buttons, '33333')
305
331
  >
306
332
  <view class="export-popup bg-white dark:bg-[var(--wot-dark-background)]">
307
333
  <view class="export-popup__header">
308
- <text class="text-black dark:text-[var(--wot-dark-color)]">导出</text>
334
+ <text class="text-black dark:text-[var(--wot-dark-color)]">{{ exportPopupTitle }}</text>
309
335
  <wd-icon
310
336
  v-if="exportStatus !== 'running'"
311
337
  name="close"
@@ -315,8 +341,9 @@ console.log(props.buttons, '33333')
315
341
  />
316
342
  </view>
317
343
 
318
- <!-- 单选范围 -->
344
+ <!-- 单选范围:批量操作条按勾选记录导出时隐藏 -->
319
345
  <wd-radio-group
346
+ v-if="!activeCodes"
320
347
  v-model="exportScope"
321
348
  direction="horizontal"
322
349
  shape="dot"
@@ -328,6 +355,11 @@ console.log(props.buttons, '33333')
328
355
  </wd-radio>
329
356
  </wd-radio-group>
330
357
 
358
+ <!-- 按勾选记录导出的提示 -->
359
+ <view v-if="activeCodes" class="export-popup__tip text-black dark:text-[var(--wot-dark-color)]">
360
+ 将导出已勾选的 {{ activeCodes.split(',').length }} 条记录
361
+ </view>
362
+
331
363
  <!-- 多页时显示页码范围输入 -->
332
364
  <view v-if="exportScope === 'page'" class="export-popup__pages text-black dark:text-[var(--wot-dark-color)]">
333
365
  <text class="export-popup__pages-label">页号:</text>
@@ -1,11 +1,15 @@
1
1
  <script setup lang="ts">
2
- import { defineOptions, onMounted, onUnmounted, ref } from 'vue'
2
+ import { computed, defineOptions, onMounted, onUnmounted, ref } from 'vue'
3
3
  import { onLoad } from '@dcloudio/uni-app'
4
- import { detailPageConfig, detailPageData } from '../../api/page'
4
+ import { useRouter } from 'uni-mini-router'
5
+ import { actionDataSave, copyDataApi, deleteData, detailPageConfig, detailPageData } from '../../api/page'
5
6
  import type { Entities, Groups, dtmplConfig } from '../../type'
7
+ import ActionPopup from '../action-popup/action-popup.vue'
6
8
  import CardBotomButtons from '../card-botom-buttons/card-botom-buttons.vue'
7
9
  import foldCard from '../fold-card/fold-card.vue'
8
10
  import LabelValue from '../label-value/label-value.vue'
11
+ import { useGlobalMessage } from '../../composables/useGlobalMessage'
12
+ import { useGlobalToast } from '../../composables/useGlobalToast'
9
13
  import { generateHighResolutionID } from '../../utils/index'
10
14
 
11
15
  defineOptions({
@@ -51,6 +55,85 @@ const addEvent = generateHighResolutionID()
51
55
  const detailZpaging = { reload: () => getDetailData() }
52
56
  // 折叠面板
53
57
  const collapses = ref()
58
+ const router = useRouter()
59
+ const toast = useGlobalToast()
60
+ const message = useGlobalMessage()
61
+
62
+ // ===== 页面级底部按钮(dtmplConfig.buttons 固定按钮 + dtmplConfig.action 动态操作按钮) =====
63
+ /** 详情页支持的页面级固定按钮(编辑属于编辑页职责,详情页不渲染) */
64
+ const pageButtonKeys = ['copy', 'singleDelete']
65
+ /** 是否有页面级按钮:有才渲染底部操作栏 */
66
+ const hasPageButtons = computed(
67
+ () =>
68
+ pageConfig.value.buttons.some(key => pageButtonKeys.includes(key)) ||
69
+ (pageConfig.value.action?.length ?? 0) > 0
70
+ )
71
+ /** 需要 ActionPopup 表单输入的 action:复用 Groups 结构(fields + id)供 ActionPopup 渲染表单 */
72
+ const pageActionItem = ref<any>()
73
+ const pageActionShow = ref(false)
74
+
75
+ // 页面级 action:writes 有字段则弹表单,否则确认后直接提交
76
+ function runPageAction(item: dtmplConfig['action'] extends (infer T)[] | undefined ? T : never) {
77
+ if (item.writes && item.writes.length) {
78
+ pageActionItem.value = {
79
+ ...pageConfig.value,
80
+ fields: item.writes,
81
+ id: item.id,
82
+ }
83
+ pageActionShow.value = true
84
+ return
85
+ }
86
+ message.confirm({
87
+ msg: `确定${item.title}操作吗?`,
88
+ title: '提示',
89
+ success: async () => {
90
+ // 消费完立即清空,避免 messageOptions 残留
91
+ message.close()
92
+ try {
93
+ await actionDataSave(item.id, id.value, {})
94
+ toast.success({ msg: '操作成功!' })
95
+ getDetailData()
96
+ } catch (error) {
97
+ console.log(error)
98
+ }
99
+ },
100
+ })
101
+ }
102
+
103
+ // 页面级删除:确认后删除并返回上一页
104
+ function pageDelete() {
105
+ message.confirm({
106
+ msg: '确定要删除这条记录吗?',
107
+ title: '提示',
108
+ beforeConfirm: async ({ resolve }: { resolve: (value: boolean) => void }) => {
109
+ try {
110
+ const res = await deleteData(sourceId.value, id.value)
111
+ if (res.status === 'success') {
112
+ toast.success({ msg: '删除成功!' })
113
+ uni.navigateBack()
114
+ }
115
+ message.close()
116
+ } catch (error) {
117
+ console.log(error)
118
+ } finally {
119
+ resolve(true)
120
+ }
121
+ },
122
+ })
123
+ }
124
+
125
+ // 页面级复制:复制成功后跳转到新记录的编辑页
126
+ async function pageCopy() {
127
+ try {
128
+ const res: any = await copyDataApi(sourceId.value, id.value)
129
+ const newCode = res?.entity?.code || res?.code || res?.data?.code
130
+ uni.showToast({ title: '复制成功', icon: 'success' })
131
+ router.push(`/pages/edit-page/index?sourceId=${sourceId.value}&id=${newCode}&title=${title.value}`)
132
+ } catch (error: any) {
133
+ console.log('[copy] 复制失败', error)
134
+ uni.showToast({ title: error?.data?.message || '复制失败', icon: 'error' })
135
+ }
136
+ }
54
137
  /**
55
138
  * 简单解码:跳转端明文传参,URL 传输时浏览器/App 框架会自动编码一层,
56
139
  * 接收端解一次即可还原明文。已解码的值(无 % 或解码抛错)原样返回。
@@ -152,7 +235,7 @@ onUnmounted(() => {
152
235
  <view v-if="loading" class="flex justify-center p-3">
153
236
  <wd-loading />
154
237
  </view>
155
- <view v-else>
238
+ <view v-else :class="{ 'pb-16': hasPageButtons }">
156
239
  <wd-collapse v-model="collapses">
157
240
  <wd-collapse-item
158
241
  v-for="(group, index) in pageConfig.groups"
@@ -194,6 +277,10 @@ onUnmounted(() => {
194
277
  :add-event="addEvent"
195
278
  :zpaging="detailZpaging"
196
279
  :detail-button-handle="props.detailButtonHandle"
280
+ :row-actions="(group as any).rowActions"
281
+ :ractions="(group as any).ractions"
282
+ :actions="(group as any).actions"
283
+ :is-show-action="true"
197
284
  />
198
285
  </template>
199
286
  </foldCard>
@@ -202,6 +289,61 @@ onUnmounted(() => {
202
289
  </wd-collapse-item>
203
290
  </wd-collapse>
204
291
  </view>
205
- <slot name="botombuttons" />
292
+ <!-- 页面级底部操作栏:dtmplConfig.buttons(复制/编辑/删除)+ dtmplConfig.action(动态操作按钮) -->
293
+ <view v-if="hasPageButtons" class="detail-bottom-bar">
294
+ <view class="detail-bottom-bar__inner">
295
+ <wd-button
296
+ v-for="subitem in pageConfig.action"
297
+ :key="subitem.id"
298
+ size="small"
299
+ plain
300
+ @click="runPageAction(subitem)"
301
+ >
302
+ {{ subitem.title }}
303
+ </wd-button>
304
+ <wd-button v-if="pageConfig.buttons.includes('copy')" size="small" @click="pageCopy">复制</wd-button>
305
+ <wd-button v-if="pageConfig.buttons.includes('singleDelete')" size="small" type="danger" @click="pageDelete">
306
+ 删除
307
+ </wd-button>
308
+ </view>
309
+ <slot name="botombuttons" />
310
+ </view>
311
+ <slot v-else name="botombuttons" />
312
+ <!-- 页面级 action 表单弹窗(writes 有字段时弹出) -->
313
+ <ActionPopup
314
+ v-model:show="pageActionShow"
315
+ :field-group="pageActionItem"
316
+ :code="id"
317
+ :zpaging="detailZpaging"
318
+ @success="getDetailData"
319
+ />
206
320
  </view>
207
321
  </template>
322
+
323
+ <style scoped>
324
+ .detail-bottom-bar {
325
+ position: fixed;
326
+ left: 0;
327
+ right: 0;
328
+ bottom: 0;
329
+ z-index: 999;
330
+ padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
331
+ background: rgba(255, 255, 255, 0.98);
332
+ box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.06);
333
+ }
334
+ :global(.wot-theme-dark) .detail-bottom-bar {
335
+ background: rgba(28, 28, 30, 0.98);
336
+ }
337
+ .detail-bottom-bar__inner {
338
+ display: flex;
339
+ align-items: center;
340
+ justify-content: flex-end;
341
+ gap: 8px;
342
+ overflow-x: auto;
343
+ /* 隐藏滚动条但保留横向滚动能力,按钮过多时可滑动 */
344
+ scrollbar-width: none;
345
+ }
346
+ .detail-bottom-bar__inner::-webkit-scrollbar {
347
+ display: none;
348
+ }
349
+ </style>
@@ -502,8 +502,10 @@ async function doAction(subitem: rowActions) {
502
502
 
503
503
  // 跳转勾选页面
504
504
  function gotoSlect(group: Groups) {
505
+ // 与 form-control 约定一致:max === 1 为单选(relselect),否则多选;写死空串会让单选分组也进多选页
506
+ const extControlType = group.max === 1 ? 'relselect' : ''
505
507
  router.push(
506
- `/pages/select-list/index?sourceId=${group.id}&title=${pageTitle.value}&selectEvent=${SELECTEVENT}&sendSelectEvent=${SENDSELECTEVENT}&extControlType=${''}&cardModel=complex`
508
+ `/pages/select-list/index?sourceId=${group.id}&title=${pageTitle.value}&selectEvent=${SELECTEVENT}&sendSelectEvent=${SENDSELECTEVENT}&extControlType=${extControlType}&cardModel=complex`
507
509
  )
508
510
  // 发送数据给选择页面,延迟发送防止页面不刷新
509
511
  setTimeout(() => {
@@ -912,7 +914,8 @@ console.log(pageConfig, 'props111')
912
914
  <wd-loading />
913
915
  </view>
914
916
  <view v-else>
915
- <view v-if="!group.readOnly" class="w-upload flex justify-center gap-2">
917
+ <!-- 原生 view 上 .stop 才能真正拦截冒泡(小程序端编译为 catchtap),防止点击按钮触发折叠切换 -->
918
+ <view v-if="!group.readOnly" class="w-upload flex justify-center gap-2" @click.stop>
916
919
  <batchUploadFile
917
920
  v-if="group.batchAddFileField && group.batchAddFileField.extControlType === 'file'"
918
921
  @handle-file-change="
@@ -926,7 +929,7 @@ console.log(pageConfig, 'props111')
926
929
  :disabled="canClick(group)"
927
930
  type="info"
928
931
  size="small"
929
- @click.stop="gotoSlect(group)"
932
+ @click="gotoSlect(group)"
930
933
  >
931
934
  选择
932
935
  </wd-button>
@@ -935,7 +938,7 @@ console.log(pageConfig, 'props111')
935
938
  :disabled="canClick(group)"
936
939
  type="primary"
937
940
  size="small"
938
- @click.stop="gotoAdd(group)"
941
+ @click="gotoAdd(group)"
939
942
  >
940
943
  新增
941
944
  </wd-button>
@@ -944,7 +947,7 @@ console.log(pageConfig, 'props111')
944
947
  :disabled="canClick(group)"
945
948
  type="primary"
946
949
  size="small"
947
- @click.stop="gotoRowAdd(group)"
950
+ @click="gotoRowAdd(group)"
948
951
  >
949
952
  新增
950
953
  </wd-button>
@@ -37,6 +37,10 @@ const props = withDefaults(
37
37
  * 顶部操作按钮区(新增等)是否显示,默认显示。
38
38
  */
39
39
  showTopButtons?: boolean
40
+ /**
41
+ * 顶部自定义按钮:通过 topExtraButtons 插槽传入,
42
+ * 渲染在「批量操作」按钮左边,内容完全由使用方决定。
43
+ */
40
44
  /**
41
45
  * 标题旁标签(labelTag)是否展示,由父级读取控制,默认不展示。
42
46
  */
@@ -121,6 +125,8 @@ const props = withDefaults(
121
125
  )
122
126
 
123
127
  const Zpaging = ref<any>(null)
128
+ /** 顶部按钮组件实例:批量操作条通过它打开文件导出弹窗 */
129
+ const listTopButtonsRef = ref<any>(null)
124
130
  /** 是否已经历过首次显示:首次显示由 z-paging 自己加载,避免重复请求 */
125
131
  const hasShown = ref(false)
126
132
  /** 本次隐藏期间是否已通过刷新事件取过数:避免返回时 onShow 再重复请求一次 */
@@ -202,7 +208,9 @@ const hasBatchOperation = computed(
202
208
  () =>
203
209
  config.value.buttons.includes('batchDelete') ||
204
210
  config.value.buttons.includes('batchEdit') ||
205
- batchActionButtons.value.length > 0
211
+ batchActionButtons.value.length > 0 ||
212
+ // 配置了文件导出(音频下载/曲线下载等)时也视为有批量能力
213
+ (config.value.fileExports || []).length > 0
206
214
  )
207
215
  /**
208
216
  * 批量操作条是否显示:进入勾选模式且存在可执行操作时显示。
@@ -231,6 +239,21 @@ const batchActionButtons = computed(() => {
231
239
  /** 已选 code 的逗号分隔字符串,供批量接口与弹窗透传 */
232
240
  const selectedCodesStr = computed(() => Array.from(selectedCodes.value).join(','))
233
241
 
242
+ // ===== 文件导出(音频下载/曲线下载等) =====
243
+ /** 模板配置的文件导出按钮,入口放在底部批量操作条,不放在头部 */
244
+ const fileExportButtons = computed(() => config.value.fileExports || [])
245
+ /**
246
+ * 批量条文件导出:需先勾选记录,复用 ListTopButtons 的导出弹窗,
247
+ * 传入 fileExports 配置项(其 id 作 sourceId)和勾选 codes 后按勾选记录导出。
248
+ */
249
+ function batchFileExport(fileExport: any) {
250
+ if (!hasSelected.value) {
251
+ toast.warning({ msg: '请先勾选要导出的记录' })
252
+ return
253
+ }
254
+ listTopButtonsRef.value?.openExportPopup(fileExport, selectedCodesStr.value)
255
+ }
256
+
234
257
  // 批量 action 弹窗(需要表单输入的 action)
235
258
  const batchActionPopupShow = ref(false)
236
259
  const batchActionFieldGroup = ref<Config>()
@@ -579,6 +602,8 @@ function tabSearchClick(data: any) {
579
602
  >
580
603
  <template #top>
581
604
  <slot name="top" />
605
+ <!-- 自定义 tab 容器:tab 内容完全由使用方传入 -->
606
+ <slot name="filterTabs" />
582
607
  <Search
583
608
  v-if="showSearch"
584
609
  :main-code="mainCode"
@@ -591,6 +616,7 @@ function tabSearchClick(data: any) {
591
616
  />
592
617
  <view>
593
618
  <ListTopButtons
619
+ ref="listTopButtonsRef"
594
620
  :add-event="addEvent"
595
621
  :main-code="mainCode"
596
622
  :buttons="config.buttons"
@@ -603,7 +629,10 @@ function tabSearchClick(data: any) {
603
629
  :batch-editing="selectMode"
604
630
  :batch-ops-visible="hasBatchOperation"
605
631
  @batch-edit="toggleBatchEdit"
606
- />
632
+ >
633
+ <!-- 透传:使用方通过 topExtraButtons 插槽在顶部按钮区追加自定义按钮(显示在「批量操作」左边) -->
634
+ <slot name="topExtraButtons" />
635
+ </ListTopButtons>
607
636
  </view>
608
637
  <!-- 自定义tab搜索 -->
609
638
  <view v-if="config.split2TabCriterias">
@@ -729,6 +758,16 @@ function tabSearchClick(data: any) {
729
758
  >
730
759
  {{ subitem.title }}
731
760
  </wd-button>
761
+ <!-- 模板配置的文件导出(音频下载/曲线下载等):需先勾选记录,复用顶部导出弹窗 -->
762
+ <wd-button
763
+ v-for="fileExport in fileExportButtons"
764
+ :key="fileExport.id"
765
+ size="small"
766
+ plain
767
+ @click="batchFileExport(fileExport)"
768
+ >
769
+ {{ fileExport.title }}
770
+ </wd-button>
732
771
  <wd-button v-if="config.buttons.includes('batchDelete')" size="small" type="danger" @click="batchDelete">
733
772
  批量删除
734
773
  </wd-button>
@@ -1,6 +1,5 @@
1
1
  <script lang="ts" setup>
2
2
  import { computed, defineOptions } from 'vue'
3
- import { RainbowColorGenerator } from '../../../utils'
4
3
  import { useSectionMenus } from '../../../composables/useSectionMenus'
5
4
  import { useLanguageStore } from '../../../store/language'
6
5
 
@@ -9,43 +8,72 @@ defineOptions({
9
8
  })
10
9
  const { quickPanel } = useSectionMenus(true)
11
10
  const languageStore = useLanguageStore()
12
- const colorGenerator = new RainbowColorGenerator()
13
- const cstatistics = computed(() => {
14
- return quickPanel.value.map((item) => {
15
- const color = colorGenerator.getNextColor()
16
- return {
17
- ...item,
18
- color,
19
- }
20
- })
21
- })
11
+
12
+ // TODO: 临时假数据,仅用于预览样式;接口 QuickPanel 有数据后删除
13
+ const mockItems = [
14
+ { id: 'mock-1', title: '设备总数', count: 128, icon: '', pageType: '' },
15
+ { id: 'mock-2', title: '报警设备', count: 7, icon: '', pageType: '' },
16
+ { id: 'mock-3', title: '传感器总数', count: 456, icon: '', pageType: '' },
17
+ { id: 'mock-4', title: '离线传感器', count: 12, icon: '', pageType: '' },
18
+ { id: 'mock-5', title: '声音报警', count: 23, icon: '', pageType: '' },
19
+ { id: 'mock-6', title: '振动报警', count: 41, icon: '', pageType: '' },
20
+ { id: 'mock-7', title: '温度报警', count: 9, icon: '', pageType: '' },
21
+ ]
22
+ const stats = computed(() => (quickPanel.value.length > 0 ? quickPanel.value : mockItems))
23
+
24
+ // 前 4 项渲染为统计块,剩余项渲染为告警胶囊
25
+ const tiles = computed(() => stats.value.slice(0, 4))
26
+ const pills = computed(() => stats.value.slice(4))
27
+
28
+ // 胶囊配色循环使用(半透明底色,暗黑模式下同样适用)
29
+ const pillThemes = [
30
+ { bg: 'rgba(59, 130, 246, 0.1)', text: '#2563eb', dot: '#3b82f6' },
31
+ { bg: 'rgba(239, 68, 68, 0.1)', text: '#dc2626', dot: '#ef4444' },
32
+ { bg: 'rgba(249, 115, 22, 0.12)', text: '#ea580c', dot: '#f97316' },
33
+ { bg: 'rgba(34, 197, 94, 0.12)', text: '#16a34a', dot: '#22c55e' },
34
+ ]
35
+ function pillTheme(index: number) {
36
+ return pillThemes[index % pillThemes.length]
37
+ }
22
38
  </script>
23
39
 
24
40
  <template>
25
- <view v-if="cstatistics.length > 0" class="pb-2">
26
- <view>
27
- <view class="mb-2 flex items-center gap-2 font-semibold dark:text-white text-gray-800">
41
+ <view v-if="stats.length > 0" class="mb-3">
42
+ <view class="rounded-2xl bg-white p-4 shadow-[0_4px_16px_rgba(0,0,0,0.04)] dark:bg-black">
43
+ <view class="mb-3 flex items-center gap-2 text-size-4 font-bold text-gray-800 dark:text-white">
28
44
  {{ languageStore.t('数据统计') }}
29
45
  </view>
30
- <view class="grid grid-cols-2 gap-3">
31
- <view v-for="(item) in cstatistics" :key="item.id" :style="{ '--wbg-color': item.color }" class="relative relative overflow-hidden rounded-2xl bg-white p-5 shadow-[0_4px_16px_rgba(99,102,241,0.1)] transition-250 before:absolute before:right-0 before:top-0 before:h-20 before:w-20 before:translate-x-30% before:rounded-full before:bg-[var(--wbg-color)] dark:bg-black before:opacity-10 before:content-[''] before:-translate-y-30%">
32
- <view class="mb-3 flex items-center justify-between">
33
- <view class="h-8 w-8 flex items-center justify-center rounded-2" :style="{ background: item.color }">
34
- <svg class="h-4 w-4 text-white dark:text-white" fill="none" stroke="currentColor" viewBox="0 0 24 24">
35
- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 7h8m0 0v8m0-8l-8 8-4-4-6 6" />
36
- </svg>
37
- </view>
38
- </view>
39
- <view class="flex flex-col items-center justify-center">
40
- <view class="text-size-2xl fw-800 dark:text-white text-gray-900">
41
- {{ item.count }}
46
+ <!-- 作用域插槽:调用方可完全自定义统计内容 -->
47
+ <slot :items="stats" :tiles="tiles" :pills="pills">
48
+ <!-- 统计块 -->
49
+ <view class="grid grid-cols-4 gap-2">
50
+ <view v-for="item in tiles" :key="item.id" class="rounded-xl bg-[#f6f7f9] px-1 py-3 dark:bg-white/10">
51
+ <view class="flex items-baseline justify-center gap-0.5">
52
+ <text class="text-size-2xl font-extrabold text-gray-900 dark:text-white">{{ item.count }}</text>
53
+ <text class="text-size-3 text-gray-500 dark:text-gray-400">{{ languageStore.t('台') }}</text>
42
54
  </view>
43
- <view class="text-size-3 color-gray">
55
+ <view class="mt-1 text-center text-size-3 text-gray-500 dark:text-gray-400">
44
56
  {{ languageStore.t(item.title) }}
45
57
  </view>
46
58
  </view>
47
59
  </view>
48
- </view>
60
+ <!-- 告警胶囊 -->
61
+ <view v-if="pills.length" class="mt-3 flex flex-wrap gap-2">
62
+ <view
63
+ v-for="(item, i) in pills"
64
+ :key="item.id"
65
+ class="flex items-center gap-1.5 rounded-xl px-3 py-2"
66
+ :style="{ background: pillTheme(i).bg }"
67
+ >
68
+ <view class="h-2 w-2 rounded-full" :style="{ background: pillTheme(i).dot }" />
69
+ <text class="text-size-3 font-semibold" :style="{ color: pillTheme(i).text }">
70
+ {{ languageStore.t(item.title) }}
71
+ </text>
72
+ <text class="text-size-3 font-extrabold" :style="{ color: pillTheme(i).text }">{{ item.count }}</text>
73
+ <text class="text-size-3" :style="{ color: pillTheme(i).text, opacity: 0.7 }">{{ languageStore.t('条') }}</text>
74
+ </view>
75
+ </view>
76
+ </slot>
49
77
  </view>
50
78
  </view>
51
79
  </template>
@@ -142,8 +142,12 @@ onMounted(() => {
142
142
  <slot name="section-item-text" :item="item" :t="t" :goto="goto" />
143
143
  </template>
144
144
  </sectionMenus>
145
- <!-- 统计 -->
146
- <quickPanel v-if="themeConfig?.showHomePage && props.showQuickPanel" />
145
+ <!-- 统计 TODO: 临时去掉 themeConfig.showHomePage 判断,仅用于预览样式,看完要还原 -->
146
+ <quickPanel v-if="props.showQuickPanel">
147
+ <template #default="{ items, tiles, pills }">
148
+ <slot name="quickPanel" :items="items" :tiles="tiles" :pills="pills" />
149
+ </template>
150
+ </quickPanel>
147
151
  <!-- 消息 -->
148
152
  <!-- <wuiNotifyInfo /> -->
149
153
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wui-components-v2",
3
- "version": "1.2.83",
3
+ "version": "1.2.85",
4
4
  "description": "wui 组件库",
5
5
  "author": "wgxshh",
6
6
  "license": "MIT",
package/type.ts CHANGED
@@ -22,6 +22,25 @@ export type Comparator =
22
22
  // tab字段配置
23
23
  export interface Split2TabCriterias extends Fields {}
24
24
 
25
+ /**
26
+ * fastMenu.FilterInTabPage 项:同组列表页 tab(如声音/振动/温度报警)。
27
+ * 同组项共享同一个 blockId,order 决定排列顺序,id 即对应列表页的 sourceId。
28
+ */
29
+ export interface FilterInTabPageItem {
30
+ id: string
31
+ blockId: string
32
+ title: string
33
+ pageType: string
34
+ order: string
35
+ themeColor?: string
36
+ icon?: string
37
+ appIcon?: string
38
+ tip?: string | null
39
+ disabled?: boolean
40
+ defaultCriteriaValue?: { [key: string]: any }
41
+ [key: string]: any
42
+ }
43
+
25
44
  // 列表字段配置
26
45
  export interface Columns {
27
46
  controlType: string
@@ -69,6 +88,8 @@ export interface Config extends Groups {
69
88
  secondColumn: Columns
70
89
  criteria: Fields[]
71
90
  labelColumn?: Columns
91
+ /** 模板配置的文件导出按钮(音频下载/曲线下载等),批量操作条渲染 */
92
+ fileExports?: any[]
72
93
  customButtons?: rowActions[]
73
94
  rowActions?: rowActions[]
74
95
  ractions?: rowActions[]