wui-components-v2 1.0.44 → 1.0.46
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.
|
@@ -522,14 +522,23 @@ function rowEdit(group: Groups, field: Entities) {
|
|
|
522
522
|
|
|
523
523
|
// 显示数据
|
|
524
524
|
if (pageConfig.value.entity.arrayMap[group.id]) {
|
|
525
|
-
|
|
526
|
-
|
|
525
|
+
const index = pageConfig.value.entity.arrayMap[group.id].findIndex((item: any) => item.code === newData.id)
|
|
526
|
+
console.log('index', index)
|
|
527
|
+
pageConfig.value.entity.arrayMap[group.id][index] = {
|
|
527
528
|
arrayMap: {},
|
|
528
529
|
code: '',
|
|
529
530
|
fieldMap: {
|
|
530
531
|
...newData,
|
|
531
532
|
},
|
|
532
|
-
}
|
|
533
|
+
}
|
|
534
|
+
// pageConfig.value.entity.arrayMap[group.id] = pageConfig.value.entity.arrayMap[group.id].filter((item: any) => item.code !== newData.id)
|
|
535
|
+
// pageConfig.value.entity.arrayMap[group.id].push({
|
|
536
|
+
// arrayMap: {},
|
|
537
|
+
// code: '',
|
|
538
|
+
// fieldMap: {
|
|
539
|
+
// ...newData,
|
|
540
|
+
// },
|
|
541
|
+
// })
|
|
533
542
|
}
|
|
534
543
|
|
|
535
544
|
console.log(rowData.value, group.id, 'rowData.value')
|
|
@@ -43,7 +43,7 @@ function initFormData() {
|
|
|
43
43
|
if (props.entity && typeof props.entity[item.sourceId] === 'object') {
|
|
44
44
|
return models[item.sourceId] = [props.entity[item.sourceId]]
|
|
45
45
|
}
|
|
46
|
-
return models[item.sourceId] = (props.entity && props.entity[item.sourceId] && [{ disabled: item.
|
|
46
|
+
return models[item.sourceId] = (props.entity && props.entity[item.sourceId] && [{ disabled: JSON.parse(props.entity[item.sourceId]).valid, url: `${action.value}/v3/files${JSON.parse(props.entity[item.sourceId])?.base.path}?@token=${token.value}&@programToken=${hydrocarbonProgramToken.value}`, name: `${JSON.parse(props.entity[item.sourceId])?.base.fileName}`, response: JSON.stringify({
|
|
47
47
|
fileKey: `$blob:${JSON.parse(props.entity[item.sourceId])?.base.bytesInfoVO.code}`,
|
|
48
48
|
}) }]) || item.transDefaultValue || []
|
|
49
49
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { computed, defineOptions, defineProps } from 'vue'
|
|
3
3
|
import type { Columns, Entities, FoldCardModel, Groups } from '../../type'
|
|
4
|
-
import { formatItemData } from '../../utils'
|
|
4
|
+
import { downloadFile, formatItemData } from '../../utils'
|
|
5
5
|
|
|
6
6
|
defineOptions({
|
|
7
7
|
name: 'LabelValue',
|
|
@@ -13,6 +13,11 @@ const props = defineProps<{
|
|
|
13
13
|
const clums = computed(() => {
|
|
14
14
|
return props.exhibitData.filter(item => !item.title?.includes('y'))
|
|
15
15
|
})
|
|
16
|
+
|
|
17
|
+
function splitUrlStr(str: string) {
|
|
18
|
+
const strarr = str.split('&')
|
|
19
|
+
return strarr[strarr.length - 1] || ''
|
|
20
|
+
}
|
|
16
21
|
</script>
|
|
17
22
|
|
|
18
23
|
<template>
|
|
@@ -21,7 +26,20 @@ const clums = computed(() => {
|
|
|
21
26
|
{{ item.title }}:
|
|
22
27
|
</view>
|
|
23
28
|
<view v-if="item.controlType === 'file' || item.extControlType === 'file' || item.extControlType === 'relfile'" class="flex-1 text-gray-800 dark:text-white">
|
|
24
|
-
<wd-img enable-preview :width="100" :height="100" :src="formatItemData(data.fieldMap[item.sourceId], item.extControlType || item.controlType)"
|
|
29
|
+
<wd-img enable-preview :width="100" :height="100" :src="formatItemData(data.fieldMap[item.sourceId], item.extControlType || item.controlType)">
|
|
30
|
+
<template #error>
|
|
31
|
+
<view class="error-wrap">
|
|
32
|
+
<wd-button type="text" @click="downloadFile(formatItemData(data.fieldMap[item.sourceId], item.extControlType || item.controlType))">
|
|
33
|
+
{{ splitUrlStr(formatItemData(data.fieldMap[item.sourceId], item.extControlType || item.controlType)) || '文件加载失败' }}
|
|
34
|
+
</wd-button>
|
|
35
|
+
</view>
|
|
36
|
+
</template>
|
|
37
|
+
<template #loading>
|
|
38
|
+
<view class="loading-wrap">
|
|
39
|
+
<wd-loading />
|
|
40
|
+
</view>
|
|
41
|
+
</template>
|
|
42
|
+
</wd-img>
|
|
25
43
|
</view>
|
|
26
44
|
<view v-else class="flex flex-1 items-center text-gray-800 dark:text-white">
|
|
27
45
|
{{ formatItemData(data.fieldMap[item.sourceId], item.extControlType || item.controlType) }}
|
package/package.json
CHANGED
package/utils/index.ts
CHANGED
|
@@ -39,11 +39,14 @@ export function formatItemData(data: any, type: string) {
|
|
|
39
39
|
|
|
40
40
|
if (type === 'file' || type === 'relfile') {
|
|
41
41
|
if (data) {
|
|
42
|
-
console.log('sdsadasd', data)
|
|
43
42
|
// 判断是否为JSON文件
|
|
44
43
|
if (typeof data === 'string') {
|
|
45
44
|
const a = JSON.parse(data)
|
|
46
|
-
return `${baseUrl}/v3/files${a.base.path}?@token=${token}&@programToken=${hydrocarbonProgramToken}`
|
|
45
|
+
return `${baseUrl}/v3/files${a.base.path}?@token=${token}&@programToken=${hydrocarbonProgramToken}&name=${a.base.fileName}`
|
|
46
|
+
// return {
|
|
47
|
+
// url: `${baseUrl}/v3/files${a.base.path}?@token=${token}&@programToken=${hydrocarbonProgramToken}`,
|
|
48
|
+
// name: a.base.fileName,
|
|
49
|
+
// }
|
|
47
50
|
}
|
|
48
51
|
else {
|
|
49
52
|
return data.url
|
|
@@ -66,3 +69,36 @@ export function generateHighResolutionID(): string {
|
|
|
66
69
|
counter = (counter + 1) % Number.MAX_SAFE_INTEGER
|
|
67
70
|
return `${time}-${random}-${counter.toString(36).padStart(6, '0')}`
|
|
68
71
|
}
|
|
72
|
+
|
|
73
|
+
// 下载文件
|
|
74
|
+
export function downloadFile(url: any) {
|
|
75
|
+
console.log('下载', url)
|
|
76
|
+
uni.downloadFile({
|
|
77
|
+
url, // 文件的网络地址
|
|
78
|
+
success: (res) => {
|
|
79
|
+
if (res.statusCode === 200) {
|
|
80
|
+
console.log('下载成功', res.tempFilePath)
|
|
81
|
+
// 打开文件(如PDF、Word等)
|
|
82
|
+
uni.openDocument({
|
|
83
|
+
filePath: res.tempFilePath,
|
|
84
|
+
showMenu: true,
|
|
85
|
+
success: () => console.log('打开文件成功'),
|
|
86
|
+
})
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
console.error('下载失败', res)
|
|
90
|
+
uni.showToast({
|
|
91
|
+
title: '下载失败',
|
|
92
|
+
icon: 'none',
|
|
93
|
+
})
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
fail: (err) => {
|
|
97
|
+
console.error('下载失败', err)
|
|
98
|
+
uni.showToast({
|
|
99
|
+
title: '下载失败',
|
|
100
|
+
icon: 'none',
|
|
101
|
+
})
|
|
102
|
+
},
|
|
103
|
+
})
|
|
104
|
+
}
|