wui-components-v2 1.2.87 → 1.2.90
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/core/index.ts +3 -1
- package/api/page.ts +30 -7
- package/components/card-botom-buttons/card-botom-buttons.vue +14 -0
- package/components/wui-list/wui-list.vue +18 -5
- package/components/wui-menus1/wui-menus.vue +5 -0
- package/composables/useMenus.ts +25 -4
- package/package.json +1 -1
- package/type.ts +2 -0
package/api/core/index.ts
CHANGED
|
@@ -43,10 +43,12 @@ function request(options: RequestOptions): Promise<any> {
|
|
|
43
43
|
timeout: options.timeout || 60000,
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
//
|
|
46
|
+
// 合并配置(header 以 defaultOptions 为准:默认项已并入 options.header,
|
|
47
|
+
// 不能被 ...options 整体覆盖,否则传自定义 header 会丢掉登录 token 等默认头)
|
|
47
48
|
const requestOptions = {
|
|
48
49
|
...defaultOptions,
|
|
49
50
|
...options,
|
|
51
|
+
header: defaultOptions.header,
|
|
50
52
|
url: baseUrl + options.url,
|
|
51
53
|
}
|
|
52
54
|
|
package/api/page.ts
CHANGED
|
@@ -7,9 +7,14 @@ interface PageConfig {
|
|
|
7
7
|
sourceId: string
|
|
8
8
|
sourceName: string
|
|
9
9
|
}
|
|
10
|
+
// targetProgram 存在时替换请求头中的 hydrocarbon-program-token(首页菜单跳转透传)
|
|
11
|
+
function targetHeader(targetProgram?: string) {
|
|
12
|
+
return targetProgram ? { header: { 'hydrocarbon-program-token': targetProgram } } : {}
|
|
13
|
+
}
|
|
14
|
+
|
|
10
15
|
// 列表页面配置
|
|
11
|
-
export async function pageConfig(sourceId: string): Promise<PageConfig> {
|
|
12
|
-
const res = (await req({ url: `/v3/ltmpl/config?sourceId=${sourceId}
|
|
16
|
+
export async function pageConfig(sourceId: string, targetProgram: string = ''): Promise<PageConfig> {
|
|
17
|
+
const res = (await req({ url: `/v3/ltmpl/config?sourceId=${sourceId}`, ...targetHeader(targetProgram) })) || {}
|
|
13
18
|
const { ltmplConfig = {} } = res
|
|
14
19
|
const { extDisplayConfig = {} } = ltmplConfig
|
|
15
20
|
return {
|
|
@@ -23,18 +28,34 @@ export async function pageConfig(sourceId: string): Promise<PageConfig> {
|
|
|
23
28
|
}
|
|
24
29
|
|
|
25
30
|
// 获取列表页面数据key
|
|
26
|
-
export function pageKey(
|
|
31
|
+
export function pageKey(
|
|
32
|
+
sourceId: string,
|
|
33
|
+
mainCode: string = '',
|
|
34
|
+
query: string = '',
|
|
35
|
+
menuId: string = '',
|
|
36
|
+
targetProgram: string = '',
|
|
37
|
+
serverKey: string = ''
|
|
38
|
+
) {
|
|
27
39
|
// menuId 未传时回退为 sourceId,保持原有行为
|
|
28
40
|
const menu = menuId || sourceId
|
|
41
|
+
// serverKey:cp_ 拼当前模块 sourceId,用于服务端路由数据源
|
|
42
|
+
const server = serverKey ? `&serverKey=${serverKey}` : ''
|
|
29
43
|
return req({
|
|
30
|
-
url: `/v3/ltmpl/query/key?sourceId=${sourceId}&mainCode=${mainCode}&menuId=${menu}&${query}`,
|
|
44
|
+
url: `/v3/ltmpl/query/key?sourceId=${sourceId}&mainCode=${mainCode}&menuId=${menu}${server}&${query}`,
|
|
45
|
+
...targetHeader(targetProgram),
|
|
31
46
|
})
|
|
32
47
|
}
|
|
33
48
|
|
|
34
49
|
// 获取列表页面数据
|
|
35
|
-
export function listData(
|
|
50
|
+
export function listData(
|
|
51
|
+
queryKey: string,
|
|
52
|
+
pageNo: number,
|
|
53
|
+
pageSize: number,
|
|
54
|
+
targetProgram: string = ''
|
|
55
|
+
): Promise<PageData> {
|
|
36
56
|
return req({
|
|
37
57
|
url: `/v3/ltmpl/query/data?queryKey=${queryKey}&pageNo=${pageNo}&pageSize=${pageSize}`,
|
|
58
|
+
...targetHeader(targetProgram),
|
|
38
59
|
})
|
|
39
60
|
}
|
|
40
61
|
|
|
@@ -109,7 +130,7 @@ export function detailPageData(sourceId: string, code: string) {
|
|
|
109
130
|
}
|
|
110
131
|
|
|
111
132
|
// action 按钮提交数据
|
|
112
|
-
export function actionDataSave(sourceId: string, codes: string = '', data: any) {
|
|
133
|
+
export function actionDataSave(sourceId: string, codes: string = '', data: any, targetProgram: string = '') {
|
|
113
134
|
return req({
|
|
114
135
|
url: `/v3/action`,
|
|
115
136
|
method: 'POST',
|
|
@@ -118,14 +139,16 @@ export function actionDataSave(sourceId: string, codes: string = '', data: any)
|
|
|
118
139
|
codes,
|
|
119
140
|
...data,
|
|
120
141
|
},
|
|
142
|
+
...targetHeader(targetProgram),
|
|
121
143
|
})
|
|
122
144
|
}
|
|
123
145
|
|
|
124
146
|
// 删除
|
|
125
|
-
export function deleteData(sourceId: string, code: string) {
|
|
147
|
+
export function deleteData(sourceId: string, code: string, targetProgram: string = '') {
|
|
126
148
|
return req({
|
|
127
149
|
url: `/v3/ltmpl/data?sourceId=${sourceId}&codes=${code}`,
|
|
128
150
|
method: 'DELETE',
|
|
151
|
+
...targetHeader(targetProgram),
|
|
129
152
|
})
|
|
130
153
|
}
|
|
131
154
|
// 复制数据(copyonly 模式):直接调用后端复制接口复制当前行
|
|
@@ -51,6 +51,8 @@ const props = defineProps<{
|
|
|
51
51
|
* 不传时走组件内置的 detail() 跳转逻辑。
|
|
52
52
|
*/
|
|
53
53
|
detailButtonConfig?: DetailButtonConfig
|
|
54
|
+
/** 行级自由按钮(rowCustomButtons),渲染到每行操作区 */
|
|
55
|
+
rowCustomButtons?: rowActions[]
|
|
54
56
|
}>()
|
|
55
57
|
const toast = useGlobalToast()
|
|
56
58
|
const message = useGlobalMessage()
|
|
@@ -382,6 +384,18 @@ const morebutns = computed(() => {
|
|
|
382
384
|
})
|
|
383
385
|
)
|
|
384
386
|
}
|
|
387
|
+
// 行级自由按钮(rowCustomButtons)固定渲染到行上,与批量操作条互不影响
|
|
388
|
+
if (props.rowCustomButtons) {
|
|
389
|
+
buts = buts.concat(
|
|
390
|
+
props.rowCustomButtons.map(item => {
|
|
391
|
+
return {
|
|
392
|
+
actionType: 'rowActions',
|
|
393
|
+
name: item.title,
|
|
394
|
+
...item,
|
|
395
|
+
}
|
|
396
|
+
})
|
|
397
|
+
)
|
|
398
|
+
}
|
|
385
399
|
if (props.actions) {
|
|
386
400
|
buts = buts.concat(
|
|
387
401
|
actions.value
|
|
@@ -181,6 +181,8 @@ const mainCode = ref('')
|
|
|
181
181
|
const queryKey = ref('') // 用于导出接口的列表查询 key
|
|
182
182
|
/** URL 跳转携带的菜单 ID,用于 pageKey 请求的 menuId 参数 */
|
|
183
183
|
const menuId = ref('')
|
|
184
|
+
/** 首页菜单携带的 targetProgram,存在时替换请求头中的 hydrocarbon-program-token */
|
|
185
|
+
const targetProgram = ref('')
|
|
184
186
|
/** URL 跳转携带的筛选默认值(key 为字段 sourceId,去掉 c_ 前缀),作为筛选条件默认值 */
|
|
185
187
|
const urlDefaultCriteria = ref<{ [key: string]: any }>({})
|
|
186
188
|
/** 用户是否已主动提交过筛选:提交后以用户条件为准,不再重新补默认值(否则清空的条件会被默认值"复活"传给后端) */
|
|
@@ -351,7 +353,7 @@ function batchDelete() {
|
|
|
351
353
|
title: '提示',
|
|
352
354
|
beforeConfirm: async ({ resolve }) => {
|
|
353
355
|
try {
|
|
354
|
-
const res = await deleteData(internalSourceId.value, codes.join(','))
|
|
356
|
+
const res = await deleteData(internalSourceId.value, codes.join(','), targetProgram.value)
|
|
355
357
|
if (res.status === 'success') {
|
|
356
358
|
toast.success({ msg: '删除成功!' })
|
|
357
359
|
props.batchDeleteSuccess?.(codes)
|
|
@@ -408,7 +410,7 @@ async function batchAction(item: rowActions) {
|
|
|
408
410
|
// 消费完立即清空,避免 messageOptions 残留
|
|
409
411
|
message.close()
|
|
410
412
|
try {
|
|
411
|
-
await actionDataSave(item.id, codes.join(','), {})
|
|
413
|
+
await actionDataSave(item.id, codes.join(','), {}, targetProgram.value)
|
|
412
414
|
toast.success({ msg: '操作成功!' })
|
|
413
415
|
clearSelection()
|
|
414
416
|
Zpaging.value.reload()
|
|
@@ -442,6 +444,7 @@ onLoad((option: any) => {
|
|
|
442
444
|
pageType.value = option.pageType
|
|
443
445
|
mainCode.value = option.mainCode || ''
|
|
444
446
|
menuId.value = option.menuId || ''
|
|
447
|
+
targetProgram.value = safeDecode(option.targetProgram)
|
|
445
448
|
uni.setNavigationBarTitle({
|
|
446
449
|
title: pageTitle.value,
|
|
447
450
|
})
|
|
@@ -488,7 +491,7 @@ onUnmounted(() => {
|
|
|
488
491
|
})
|
|
489
492
|
async function getPageConfig() {
|
|
490
493
|
try {
|
|
491
|
-
const res = await pageConfig(internalSourceId.value)
|
|
494
|
+
const res = await pageConfig(internalSourceId.value, targetProgram.value)
|
|
492
495
|
if (res.ltmplConfig) {
|
|
493
496
|
config.value = res.ltmplConfig
|
|
494
497
|
console.log('config', config.value)
|
|
@@ -558,8 +561,16 @@ async function queryList(pageNo: number, pageSize: number) {
|
|
|
558
561
|
|
|
559
562
|
try {
|
|
560
563
|
console.log('qre', qre)
|
|
561
|
-
|
|
562
|
-
const
|
|
564
|
+
// serverKey:cp_ 拼当前模块 sourceId
|
|
565
|
+
const res = await pageKey(
|
|
566
|
+
internalSourceId.value,
|
|
567
|
+
mainCode.value,
|
|
568
|
+
qre,
|
|
569
|
+
menuId.value,
|
|
570
|
+
targetProgram.value,
|
|
571
|
+
`cp_${internalSourceId.value}`
|
|
572
|
+
) // 获取key
|
|
573
|
+
const data = await listData(res.key, pageNo, pageSize, targetProgram.value) // 获取数据
|
|
563
574
|
// 缓存最新一次的 queryKey,给顶部「导出」接口使用
|
|
564
575
|
queryKey.value = res.key || res.data?.key || ''
|
|
565
576
|
// const count = await getPageTotal(key.data?.key)// 获取总数
|
|
@@ -685,6 +696,7 @@ function tabSearchClick(data: any) {
|
|
|
685
696
|
:is-show-action="isShowAction"
|
|
686
697
|
:copy-mode="config.copyMode"
|
|
687
698
|
:edit-button-config="editButtonConfig"
|
|
699
|
+
:row-custom-buttons="config.rowCustomButtons"
|
|
688
700
|
/>
|
|
689
701
|
</view>
|
|
690
702
|
</template>
|
|
@@ -739,6 +751,7 @@ function tabSearchClick(data: any) {
|
|
|
739
751
|
:is-show-action="isShowAction"
|
|
740
752
|
:copy-mode="config.copyMode"
|
|
741
753
|
:edit-button-config="editButtonConfig"
|
|
754
|
+
:row-custom-buttons="config.rowCustomButtons"
|
|
742
755
|
/>
|
|
743
756
|
</view>
|
|
744
757
|
</template>
|
|
@@ -70,6 +70,11 @@ const props = defineProps({
|
|
|
70
70
|
type: Function as PropType<(item: any) => boolean | void>,
|
|
71
71
|
default: null,
|
|
72
72
|
},
|
|
73
|
+
// 是否过滤菜单标题中的「(运维)」标记(如「设备台账(运维)」→「设备台账」),默认不过滤
|
|
74
|
+
stripOpsTag: {
|
|
75
|
+
type: Boolean,
|
|
76
|
+
default: false,
|
|
77
|
+
},
|
|
73
78
|
})
|
|
74
79
|
const languageStore = useLanguageStore()
|
|
75
80
|
const themeConfig = ref<any>({})
|
package/composables/useMenus.ts
CHANGED
|
@@ -13,6 +13,8 @@ interface Props {
|
|
|
13
13
|
icons: Icon[]
|
|
14
14
|
load: () => void
|
|
15
15
|
menuTopType: string
|
|
16
|
+
// 是否过滤菜单标题中的「(运维)」标记,默认不过滤,由调用方按需开启
|
|
17
|
+
stripOpsTag?: boolean
|
|
16
18
|
}
|
|
17
19
|
export interface MenuItem {
|
|
18
20
|
id: string
|
|
@@ -21,8 +23,24 @@ export interface MenuItem {
|
|
|
21
23
|
color: string
|
|
22
24
|
tip: string
|
|
23
25
|
pageType: string
|
|
26
|
+
targetProgram?: string
|
|
24
27
|
children?: MenuItem[]
|
|
25
28
|
}
|
|
29
|
+
// 去掉菜单标题中的「(运维)」标记(如「设备台账(运维)」→「设备台账」),中英文括号都兼容
|
|
30
|
+
function stripOpsTag(title: string) {
|
|
31
|
+
return String(title ?? '').replace(/[((]运维[))]/g, '')
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// 递归处理菜单树,清理所有层级的标题
|
|
35
|
+
function stripOpsTagDeep(items: any[]): any[] {
|
|
36
|
+
return (items || []).map((it: any) => ({
|
|
37
|
+
...it,
|
|
38
|
+
title: stripOpsTag(it.title),
|
|
39
|
+
...(Array.isArray(it.items) ? { items: stripOpsTagDeep(it.items) } : {}),
|
|
40
|
+
...(Array.isArray(it.children) ? { children: stripOpsTagDeep(it.children) } : {}),
|
|
41
|
+
}))
|
|
42
|
+
}
|
|
43
|
+
|
|
26
44
|
export function useMenus(props?: Props, pagingRef?: Ref<any>) {
|
|
27
45
|
const router = useRouter()
|
|
28
46
|
const toast = useGlobalToast()
|
|
@@ -60,10 +78,13 @@ export function useMenus(props?: Props, pagingRef?: Ref<any>) {
|
|
|
60
78
|
function goto(item: MenuItem) {
|
|
61
79
|
console.log(item.pageType)
|
|
62
80
|
switch (item.pageType) {
|
|
63
|
-
case '列表':
|
|
81
|
+
case '列表': {
|
|
64
82
|
console.log(item, 'item ')
|
|
65
|
-
|
|
83
|
+
// 菜单数据存在 targetProgram 时携带给列表页,列表页请求接口时透传
|
|
84
|
+
const targetProgram = item.targetProgram ? `&targetProgram=${item.targetProgram}` : ''
|
|
85
|
+
router.push(`/pages/list/index?sourceId=${item.id}&title=${item.title}${targetProgram}`)
|
|
66
86
|
return true
|
|
87
|
+
}
|
|
67
88
|
case '树':
|
|
68
89
|
router.push(`/pages/tree-page/index?sourceId=${item.id}&title=${item.title}`)
|
|
69
90
|
return true
|
|
@@ -142,7 +163,7 @@ export function useMenus(props?: Props, pagingRef?: Ref<any>) {
|
|
|
142
163
|
}
|
|
143
164
|
navTitle.value = res?.programName || ''
|
|
144
165
|
uni.setNavigationBarTitle({ title: res?.programName || '' }) // 设置标题
|
|
145
|
-
pagingRef?.value.complete(res?.blocks || [])
|
|
166
|
+
pagingRef?.value.complete(props?.stripOpsTag ? stripOpsTagDeep(res?.blocks || []) : (res?.blocks || []))
|
|
146
167
|
})
|
|
147
168
|
.catch((res: any) => {
|
|
148
169
|
console.log(res)
|
|
@@ -164,7 +185,7 @@ export function useMenus(props?: Props, pagingRef?: Ref<any>) {
|
|
|
164
185
|
try {
|
|
165
186
|
const res = await fastmenu()
|
|
166
187
|
if (res.fastMenu) {
|
|
167
|
-
sectionmenu.value = res.fastMenu.QuickQueryBar || []
|
|
188
|
+
sectionmenu.value = props?.stripOpsTag ? stripOpsTagDeep(res.fastMenu.QuickQueryBar || []) : (res.fastMenu.QuickQueryBar || [])
|
|
168
189
|
} else {
|
|
169
190
|
sectionmenu.value = []
|
|
170
191
|
}
|
package/package.json
CHANGED
package/type.ts
CHANGED
|
@@ -91,6 +91,8 @@ export interface Config extends Groups {
|
|
|
91
91
|
/** 模板配置的文件导出按钮(音频下载/曲线下载等),批量操作条渲染 */
|
|
92
92
|
fileExports?: any[]
|
|
93
93
|
customButtons?: rowActions[]
|
|
94
|
+
/** 行级自由按钮,渲染到每行操作区(与批量操作条互不影响) */
|
|
95
|
+
rowCustomButtons?: rowActions[]
|
|
94
96
|
rowActions?: rowActions[]
|
|
95
97
|
ractions?: rowActions[]
|
|
96
98
|
actions?: rowActions[]
|