wui-components-v2 1.0.87 → 1.0.89
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/components/batch-upload-file/batch-upload-file.vue +69 -0
- package/components/form-control/form-control.vue +28 -0
- package/components/label-value/label-value.vue +22 -12
- package/components/video-play/video-play.vue +34 -0
- package/components/wui-edit-page/wui-edit-page.vue +6 -13
- package/package.json +1 -1
- package/utils/index.ts +20 -4
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import { defineEmits, defineOptions, onBeforeMount, ref } from 'vue'
|
|
3
|
+
|
|
4
|
+
defineOptions({
|
|
5
|
+
name: 'BatchUploadFile',
|
|
6
|
+
})
|
|
7
|
+
const emit = defineEmits(['handleFileChange'])
|
|
8
|
+
const fileTypes = [
|
|
9
|
+
{
|
|
10
|
+
label: '照片',
|
|
11
|
+
value: 'image',
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
label: '视频',
|
|
15
|
+
value: 'video',
|
|
16
|
+
},
|
|
17
|
+
// {
|
|
18
|
+
// label: '文件',
|
|
19
|
+
// value: 'file',
|
|
20
|
+
// },
|
|
21
|
+
]
|
|
22
|
+
const fileType = ref<any>('image')
|
|
23
|
+
const show = ref(false)
|
|
24
|
+
const action = ref('')
|
|
25
|
+
const hydrocarbonProgramToken = ref('')
|
|
26
|
+
const token = ref('')
|
|
27
|
+
onBeforeMount(() => {
|
|
28
|
+
action.value = uni.getStorageSync('BASE_URL')
|
|
29
|
+
hydrocarbonProgramToken.value = uni.getStorageSync('HYDROCARBON_PROGRAM_TOKEN')
|
|
30
|
+
token.value = uni.getStorageSync('TOKEN')
|
|
31
|
+
})
|
|
32
|
+
function handleFileChange(e: any) {
|
|
33
|
+
show.value = false
|
|
34
|
+
emit('handleFileChange', e)
|
|
35
|
+
}
|
|
36
|
+
</script>
|
|
37
|
+
|
|
38
|
+
<template>
|
|
39
|
+
<wd-popup v-model="show" custom-style="border-radius:32rpx;" @close="show = false">
|
|
40
|
+
<view class="p-3">
|
|
41
|
+
<wd-radio-group v-model="fileType" shape="dot">
|
|
42
|
+
<wd-radio v-for="item in fileTypes" :key="item.value" :value="item.value">
|
|
43
|
+
{{ item.label }}
|
|
44
|
+
</wd-radio>
|
|
45
|
+
</wd-radio-group>
|
|
46
|
+
<wd-upload
|
|
47
|
+
custom-class="custom-upload"
|
|
48
|
+
:multiple="true" :accept="fileType"
|
|
49
|
+
:header="{ 'hydrocarbon-program-token': hydrocarbonProgramToken, 'hydrocarbon-token': token }"
|
|
50
|
+
:action="`${action}/v3/upload`" @success="(e) => { handleFileChange(e) }"
|
|
51
|
+
>
|
|
52
|
+
<view class="p-t-3">
|
|
53
|
+
<wd-button size="small" type="info" block class="w-200px">
|
|
54
|
+
确定
|
|
55
|
+
</wd-button>
|
|
56
|
+
</view>
|
|
57
|
+
</wd-upload>
|
|
58
|
+
</view>
|
|
59
|
+
</wd-popup>
|
|
60
|
+
<wd-button size="small" type="info" @click="show = true">
|
|
61
|
+
批量上传
|
|
62
|
+
</wd-button>
|
|
63
|
+
</template>
|
|
64
|
+
|
|
65
|
+
<style scoped>
|
|
66
|
+
:deep(.custom-upload .wd-upload__preview) {
|
|
67
|
+
display: none !important;
|
|
68
|
+
}
|
|
69
|
+
</style>
|
|
@@ -15,6 +15,21 @@ const props = defineProps<{
|
|
|
15
15
|
entity?: { [key: string]: string }
|
|
16
16
|
enumColumn?: Enums
|
|
17
17
|
}>()
|
|
18
|
+
const fileTypes = [
|
|
19
|
+
{
|
|
20
|
+
label: '照片',
|
|
21
|
+
value: 'image',
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
label: '视频',
|
|
25
|
+
value: 'video',
|
|
26
|
+
},
|
|
27
|
+
// {
|
|
28
|
+
// label: '文件',
|
|
29
|
+
// value: 'file',
|
|
30
|
+
// },
|
|
31
|
+
]
|
|
32
|
+
const fileType = ref<any>('image')
|
|
18
33
|
const action = ref<string>('')
|
|
19
34
|
const hydrocarbonProgramToken = ref<string>('')
|
|
20
35
|
const token = ref<string>('')
|
|
@@ -245,7 +260,13 @@ defineExpose({
|
|
|
245
260
|
:placeholder="`请输入${item.title}`"
|
|
246
261
|
/>
|
|
247
262
|
<wd-cell v-else-if="ControlTypeSupportor.getControlType(item, props.entity && props.entity[item.sourceId]) === 'file' || ControlTypeSupportor.getControlType(item, props.entity && props.entity[item.sourceId]) === 'relfile' " :prop="item.sourceId" :title="item.title" title-width="100px">
|
|
263
|
+
<wd-radio-group v-if="!item.disabled" v-model="fileType" inline shape="dot" custom-class="custom-radio">
|
|
264
|
+
<wd-radio v-for="(titem, index) in fileTypes" :key="index" :value="titem.value">
|
|
265
|
+
{{ titem.label }}
|
|
266
|
+
</wd-radio>
|
|
267
|
+
</wd-radio-group>
|
|
248
268
|
<wd-upload
|
|
269
|
+
:accept="fileType"
|
|
249
270
|
:disabled="item.disabled"
|
|
250
271
|
:limit="1"
|
|
251
272
|
:header="{ 'hydrocarbon-program-token': hydrocarbonProgramToken, 'hydrocarbon-token': token }"
|
|
@@ -292,3 +313,10 @@ defineExpose({
|
|
|
292
313
|
</wd-form>
|
|
293
314
|
</view>
|
|
294
315
|
</template>
|
|
316
|
+
|
|
317
|
+
<style scoped>
|
|
318
|
+
:deep(.custom-radio){
|
|
319
|
+
display: flex;
|
|
320
|
+
padding: 4px;
|
|
321
|
+
}
|
|
322
|
+
</style>
|
|
@@ -3,6 +3,7 @@ import { computed, defineOptions, defineProps } from 'vue'
|
|
|
3
3
|
import type { Columns, Entities } from '../../type'
|
|
4
4
|
import { downloadFile, formatItemData } from '../../utils'
|
|
5
5
|
import ControlTypeSupportor from '../../utils/control-type-supportor'
|
|
6
|
+
import videoPlay from '../video-play/video-play.vue'
|
|
6
7
|
|
|
7
8
|
defineOptions({
|
|
8
9
|
name: 'LabelValue',
|
|
@@ -14,15 +15,19 @@ const props = defineProps<{
|
|
|
14
15
|
const clums = computed(() => {
|
|
15
16
|
return props.exhibitData.filter(item => !item.title?.includes('y'))
|
|
16
17
|
})
|
|
18
|
+
const videoPlayRef = ref()
|
|
19
|
+
// function splitUrlStr(str: string) {
|
|
20
|
+
// if (str) {
|
|
21
|
+
// const strarr = str.split('&')
|
|
22
|
+
// return strarr[strarr.length - 1].split('=')[1] || ''
|
|
23
|
+
// }
|
|
24
|
+
// else {
|
|
25
|
+
// return '暂无文件'
|
|
26
|
+
// }
|
|
27
|
+
// }
|
|
17
28
|
|
|
18
|
-
function
|
|
19
|
-
|
|
20
|
-
const strarr = str.split('&')
|
|
21
|
-
return strarr[strarr.length - 1].split('=')[1] || ''
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
return '暂无文件'
|
|
25
|
-
}
|
|
29
|
+
function openVideo(uitem: any) {
|
|
30
|
+
videoPlayRef.value.open(uitem.url)
|
|
26
31
|
}
|
|
27
32
|
|
|
28
33
|
function isControlType(item: Columns): string {
|
|
@@ -37,14 +42,15 @@ function isControlType(item: Columns): string {
|
|
|
37
42
|
</view>
|
|
38
43
|
<view v-if="isControlType(item) === 'file' || isControlType(item) === 'relfile'" class="flex-1 text-gray-800 dark:text-white">
|
|
39
44
|
<view v-if="data.fieldMap[item.sourceId]">
|
|
40
|
-
<view v-for="(
|
|
41
|
-
<wd-img enable-preview :width="100" :height="100" :src="url">
|
|
45
|
+
<view v-for="(uitem, uindex) in formatItemData(data.fieldMap[item.sourceId], isControlType(item))" :key="uindex">
|
|
46
|
+
<wd-img v-if="['png', 'jpg', 'jpeg'].includes(uitem.type)" enable-preview :width="100" :height="100" :src="uitem.url">
|
|
42
47
|
<template #error>
|
|
43
|
-
<view class="error-wrap">
|
|
48
|
+
<!-- <view class="error-wrap">
|
|
44
49
|
<wd-button type="text" @click="downloadFile(url)">
|
|
45
50
|
{{ splitUrlStr(url) || '' }}
|
|
46
51
|
</wd-button>
|
|
47
|
-
</view>
|
|
52
|
+
</view> -->
|
|
53
|
+
无图片
|
|
48
54
|
</template>
|
|
49
55
|
<template #loading>
|
|
50
56
|
<view class="loading-wrap">
|
|
@@ -52,6 +58,9 @@ function isControlType(item: Columns): string {
|
|
|
52
58
|
</view>
|
|
53
59
|
</template>
|
|
54
60
|
</wd-img>
|
|
61
|
+
<view v-else-if="['mp4', 'mov', 'wmv', 'avi', 'rmvb', 'flv', 'mkv'].includes(uitem.type)" style="width: 70px;height: 70px;display: flex;align-items: center;justify-content: center;border: 1px solid #ccc;border-radius: 4px;" @click="openVideo(uitem)">
|
|
62
|
+
<wd-icon name="play-circle-filled" size="22px" />
|
|
63
|
+
</view>
|
|
55
64
|
</view>
|
|
56
65
|
</view>
|
|
57
66
|
</view>
|
|
@@ -59,4 +68,5 @@ function isControlType(item: Columns): string {
|
|
|
59
68
|
{{ formatItemData(data.fieldMap[item.sourceId], isControlType(item)) }}
|
|
60
69
|
</view>
|
|
61
70
|
</view>
|
|
71
|
+
<videoPlay ref="videoPlayRef" />
|
|
62
72
|
</template>
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { defineOptions, ref } from 'vue'
|
|
3
|
+
|
|
4
|
+
defineOptions({
|
|
5
|
+
name: 'VideoPlay',
|
|
6
|
+
})
|
|
7
|
+
const key = ref(1)
|
|
8
|
+
const show = ref(false)
|
|
9
|
+
const url = ref('')
|
|
10
|
+
defineExpose({
|
|
11
|
+
open: (e: any) => {
|
|
12
|
+
key.value++
|
|
13
|
+
console.log(e)
|
|
14
|
+
show.value = true
|
|
15
|
+
url.value = e
|
|
16
|
+
},
|
|
17
|
+
})
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
<template>
|
|
21
|
+
<wd-popup v-model="show" :lazy-render="false">
|
|
22
|
+
<view :key="key">
|
|
23
|
+
<video
|
|
24
|
+
style="width: 300px;height: 225px;"
|
|
25
|
+
:src="url"
|
|
26
|
+
controls
|
|
27
|
+
/>
|
|
28
|
+
</view>
|
|
29
|
+
</wd-popup>
|
|
30
|
+
</template>
|
|
31
|
+
|
|
32
|
+
<style>
|
|
33
|
+
|
|
34
|
+
</style>
|
|
@@ -9,6 +9,7 @@ import { useGlobalToast } from '../../composables/useGlobalToast'
|
|
|
9
9
|
import foldCard from '../fold-card/fold-card.vue'
|
|
10
10
|
import { generateHighResolutionID } from '../../utils/index'
|
|
11
11
|
import TreeSelectControl from '../tree-select/index.vue'
|
|
12
|
+
import batchUploadFile from '../batch-upload-file/batch-upload-file.vue'
|
|
12
13
|
|
|
13
14
|
defineOptions({
|
|
14
15
|
name: 'WuiEditPage',
|
|
@@ -683,17 +684,11 @@ function handleFileChange(e: any, group: Groups) {
|
|
|
683
684
|
</view>
|
|
684
685
|
<view v-else>
|
|
685
686
|
<view v-if="!group.readOnly" class="w-upload flex justify-center gap-2">
|
|
686
|
-
<
|
|
687
|
+
<batchUploadFile
|
|
687
688
|
v-if="group.batchAddFileField && group.batchAddFileField.extControlType === 'file'"
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
@success="(e) => { handleFileChange(e, group) }"
|
|
692
|
-
>
|
|
693
|
-
<wd-button size="small" type="info">
|
|
694
|
-
批量上传
|
|
695
|
-
</wd-button>
|
|
696
|
-
</wd-upload>
|
|
689
|
+
@handle-file-change="(e) => { handleFileChange(e, group) }"
|
|
690
|
+
/>
|
|
691
|
+
|
|
697
692
|
<wd-button v-if="group.buttons.includes('selectAdd')" :disabled="canClick(group)" type="info" size="small" @click="gotoSlect(group)">
|
|
698
693
|
选择
|
|
699
694
|
</wd-button>
|
|
@@ -734,7 +729,5 @@ function handleFileChange(e: any, group: Groups) {
|
|
|
734
729
|
</template>
|
|
735
730
|
|
|
736
731
|
<style scoped>
|
|
737
|
-
|
|
738
|
-
display: none;
|
|
739
|
-
}
|
|
732
|
+
|
|
740
733
|
</style>
|
package/package.json
CHANGED
package/utils/index.ts
CHANGED
|
@@ -42,22 +42,38 @@ 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 [
|
|
45
|
+
return [{
|
|
46
|
+
url: `${baseUrl}/v3/files${a.base.path}?@token=${token}&@programToken=${hydrocarbonProgramToken}&name=${a.base.fileName || ''}`,
|
|
47
|
+
name: a.base.path.fileName,
|
|
48
|
+
type: a.base.type,
|
|
49
|
+
}]
|
|
46
50
|
}
|
|
47
51
|
else if (Array.isArray(data)) {
|
|
48
52
|
return data.map((item) => {
|
|
49
53
|
if (item.includes('@R@')) {
|
|
50
54
|
const a = JSON.parse(item.split('@R@')[1])
|
|
51
|
-
return
|
|
55
|
+
return [{
|
|
56
|
+
url: `${baseUrl}/v3/files${a.base.path}?@token=${token}&@programToken=${hydrocarbonProgramToken}&name=${a.base.fileName || ''}`,
|
|
57
|
+
name: a.base.path.fileName,
|
|
58
|
+
type: a.base.type,
|
|
59
|
+
}]
|
|
52
60
|
}
|
|
53
61
|
else {
|
|
54
62
|
const a = JSON.parse(item)
|
|
55
|
-
return
|
|
63
|
+
return [{
|
|
64
|
+
url: `${baseUrl}/v3/files${a.base.path}?@token=${token}&@programToken=${hydrocarbonProgramToken}&name=${a.base.fileName || ''}`,
|
|
65
|
+
name: a.base.path.fileName,
|
|
66
|
+
type: a.base.type,
|
|
67
|
+
}]
|
|
56
68
|
}
|
|
57
69
|
})
|
|
58
70
|
}
|
|
59
71
|
else {
|
|
60
|
-
return
|
|
72
|
+
return [{
|
|
73
|
+
url: data.url,
|
|
74
|
+
name: data.name,
|
|
75
|
+
type: data.name.split('.')[1],
|
|
76
|
+
}]
|
|
61
77
|
}
|
|
62
78
|
}
|
|
63
79
|
return ''
|