wui-components-v2 1.0.85 → 1.0.86
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.
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { computed, defineOptions, defineProps } from 'vue'
|
|
3
|
-
import type { Columns, Entities } from '../../type'
|
|
3
|
+
import type { Columns, Entities, Fields } from '../../type'
|
|
4
4
|
import { downloadFile, formatItemData } from '../../utils'
|
|
5
|
+
import ControlTypeSupportor from '../../utils/control-type-supportor'
|
|
5
6
|
|
|
6
7
|
defineOptions({
|
|
7
8
|
name: 'LabelValue',
|
|
@@ -23,6 +24,10 @@ function splitUrlStr(str: string) {
|
|
|
23
24
|
return '暂无文件'
|
|
24
25
|
}
|
|
25
26
|
}
|
|
27
|
+
|
|
28
|
+
function isControlType(item: Columns): string {
|
|
29
|
+
return ControlTypeSupportor.getControlType({ ...item, disabled: false, defaultValue: '', transDefaultValue: '', required: false }, props.data.fieldMap[item.sourceId])
|
|
30
|
+
}
|
|
26
31
|
</script>
|
|
27
32
|
|
|
28
33
|
<template>
|
|
@@ -30,24 +35,28 @@ function splitUrlStr(str: string) {
|
|
|
30
35
|
<view class="mr-2 w-20 p-1 text-gray-500 dark:text-white">
|
|
31
36
|
{{ item.title }}:
|
|
32
37
|
</view>
|
|
33
|
-
<view v-if="item
|
|
34
|
-
<
|
|
35
|
-
<
|
|
36
|
-
<
|
|
37
|
-
<
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
<
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
38
|
+
<view v-if="isControlType(item) === 'file' || isControlType(item) === 'relfile'" class="flex-1 text-gray-800 dark:text-white">
|
|
39
|
+
<view v-if="data.fieldMap[item.sourceId]">
|
|
40
|
+
<view v-for="(url, uindex) in formatItemData(data.fieldMap[item.sourceId], isControlType(item))" :key="uindex">
|
|
41
|
+
<wd-img enable-preview :width="100" :height="100" :src="url">
|
|
42
|
+
<template #error>
|
|
43
|
+
<view class="error-wrap">
|
|
44
|
+
<wd-button type="text" @click="downloadFile(url)">
|
|
45
|
+
{{ splitUrlStr(url) || '' }}
|
|
46
|
+
</wd-button>
|
|
47
|
+
</view>
|
|
48
|
+
</template>
|
|
49
|
+
<template #loading>
|
|
50
|
+
<view class="loading-wrap">
|
|
51
|
+
<wd-loading />
|
|
52
|
+
</view>
|
|
53
|
+
</template>
|
|
54
|
+
</wd-img>
|
|
55
|
+
</view>
|
|
56
|
+
</view>
|
|
48
57
|
</view>
|
|
49
58
|
<view v-else class="flex flex-1 items-center text-gray-800 dark:text-white">
|
|
50
|
-
{{ formatItemData(data.fieldMap[item.sourceId], item
|
|
59
|
+
{{ formatItemData(data.fieldMap[item.sourceId], isControlType(item)) }}
|
|
51
60
|
</view>
|
|
52
61
|
</view>
|
|
53
62
|
</template>
|
package/package.json
CHANGED
|
@@ -131,6 +131,10 @@ ControlTypeSupportor.getControlType = function (fieldConfig: Fields, fieldValue?
|
|
|
131
131
|
if (!!fieldValue && typeof (fieldValue) == 'string' && !fieldValue.includes('@R@') && itemType === 'relselect' && fieldValue.includes('download-files/')) {
|
|
132
132
|
itemType = 'file'
|
|
133
133
|
}
|
|
134
|
+
|
|
135
|
+
if (fieldValue && Array.isArray(fieldValue) && itemType === 'relselect' && fieldValue[0].includes('valid')) {
|
|
136
|
+
itemType = 'file'
|
|
137
|
+
}
|
|
134
138
|
return itemType
|
|
135
139
|
}
|
|
136
140
|
|
package/utils/index.ts
CHANGED
|
@@ -42,11 +42,19 @@ export function formatItemData(data: any, type: string) {
|
|
|
42
42
|
// 判断是否为JSON文件
|
|
43
43
|
if (typeof data === 'string') {
|
|
44
44
|
const a = JSON.parse(data)
|
|
45
|
-
return `${baseUrl}/v3/files${a.base.path}?@token=${token}&@programToken=${hydrocarbonProgramToken}&name=${a.base.fileName || ''}`
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
45
|
+
return [`${baseUrl}/v3/files${a.base.path}?@token=${token}&@programToken=${hydrocarbonProgramToken}&name=${a.base.fileName || ''}`]
|
|
46
|
+
}
|
|
47
|
+
else if (Array.isArray(data)) {
|
|
48
|
+
return data.map((item) => {
|
|
49
|
+
if (item.includes('@R@')) {
|
|
50
|
+
const a = JSON.parse(item.split('@R@')[1])
|
|
51
|
+
return `${baseUrl}/v3/files${a.base.path}?@token=${token}&@programToken=${hydrocarbonProgramToken}&name=${a.base.fileName || ''}`
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
const a = JSON.parse(item)
|
|
55
|
+
return `${baseUrl}/v3/files${a.base.path}?@token=${token}&@programToken=${hydrocarbonProgramToken}&name=${a.base.fileName || ''}`
|
|
56
|
+
}
|
|
57
|
+
})
|
|
50
58
|
}
|
|
51
59
|
else {
|
|
52
60
|
return data.url
|