w-ui-v1 1.0.18 → 1.0.20
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/package.json +1 -1
- package/w-detail/w-detail.vue +190 -174
package/package.json
CHANGED
package/w-detail/w-detail.vue
CHANGED
|
@@ -1,189 +1,205 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { onLoad } from '@dcloudio/uni-app'
|
|
3
|
-
import { getValue } from '../w-card/utils/utils'
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
} from 'vue'
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
} from '../utils/apis/pageConfig'
|
|
2
|
+
import { onLoad } from '@dcloudio/uni-app'
|
|
3
|
+
import { getValue } from '../w-card/utils/utils'
|
|
4
|
+
import {
|
|
5
|
+
computed,
|
|
6
|
+
ref,
|
|
7
|
+
defineProps
|
|
8
|
+
} from 'vue'
|
|
9
|
+
import {
|
|
10
|
+
detailPageConfig,
|
|
11
|
+
detailPageData,
|
|
12
|
+
} from '../utils/apis/pageConfig'
|
|
13
13
|
|
|
14
|
-
defineOptions({
|
|
15
|
-
|
|
16
|
-
})
|
|
17
|
-
const props=defineProps({
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
})
|
|
21
|
-
const loading=ref(false)
|
|
22
|
-
const value = ref([])
|
|
23
|
-
const sourceId = ref('')
|
|
24
|
-
const code = ref('')
|
|
25
|
-
const pageData = ref([])
|
|
26
|
-
const pageConf = ref({ groups: [] })
|
|
14
|
+
defineOptions({
|
|
15
|
+
name: 'WDetail',
|
|
16
|
+
})
|
|
17
|
+
const props = defineProps({
|
|
18
|
+
sourceId: { type: String, default: '' },
|
|
19
|
+
code: { type: String, default: '' }
|
|
20
|
+
})
|
|
21
|
+
const loading = ref(false)
|
|
22
|
+
const value = ref([])
|
|
23
|
+
const sourceId = ref('')
|
|
24
|
+
const code = ref('')
|
|
25
|
+
const pageData = ref([])
|
|
26
|
+
const pageConf = ref({ groups: [] })
|
|
27
27
|
|
|
28
|
-
onLoad((option: any) => {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
})
|
|
34
|
-
// 获取页面配置
|
|
35
|
-
function getPageConfig() {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
28
|
+
onLoad((option : any) => {
|
|
29
|
+
sourceId.value = props.sourceId || option.sourceId
|
|
30
|
+
code.value = option.code || props.code
|
|
31
|
+
getPageData()
|
|
32
|
+
uni.setNavigationBarTitle({ title: "详情" })
|
|
33
|
+
})
|
|
34
|
+
// 获取页面配置
|
|
35
|
+
function getPageConfig() {
|
|
36
|
+
detailPageConfig(sourceId.value).then((res : any) => {
|
|
37
|
+
pageConf.value = res.data.dtmplConfig
|
|
38
|
+
value.value = res.data.dtmplConfig.groups.map((item : any) => {
|
|
39
|
+
return item.id
|
|
40
|
+
})
|
|
41
|
+
loading.value = false
|
|
42
|
+
})
|
|
43
|
+
}
|
|
44
44
|
|
|
45
|
-
function getPageData() {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
45
|
+
function getPageData() {
|
|
46
|
+
loading.value = true
|
|
47
|
+
detailPageData(sourceId.value, code.value).then((res : any) => {
|
|
48
|
+
pageData.value = res.data.entity
|
|
49
|
+
getPageConfig()
|
|
50
|
+
})
|
|
51
|
+
}
|
|
52
52
|
|
|
53
|
-
// 跳转详情页
|
|
54
|
-
function goto(PItem: any,item:any) {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
53
|
+
// 跳转详情页
|
|
54
|
+
function goto(PItem : any, item : any) {
|
|
55
|
+
uni.navigateTo({
|
|
56
|
+
url: `/pages/detail/detail?sourceId=${item.pointSourceId}&code=${PItem.code}`
|
|
57
|
+
})
|
|
58
|
+
}
|
|
59
59
|
|
|
60
|
-
//下载文件
|
|
61
|
-
const downloadFile=(url:any)=>{
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
60
|
+
//下载文件
|
|
61
|
+
const downloadFile = (url : any) => {
|
|
62
|
+
console.log(url)
|
|
63
|
+
uni.downloadFile({
|
|
64
|
+
url: url, // 文件的网络地址
|
|
65
|
+
success: (res) => {
|
|
66
|
+
if (res.statusCode === 200) {
|
|
67
|
+
console.log('下载成功', res.tempFilePath);
|
|
68
|
+
|
|
69
|
+
// 将临时文件保存到本地
|
|
70
|
+
uni.saveFile({
|
|
71
|
+
tempFilePath: res.tempFilePath,
|
|
72
|
+
success: (saveRes) => {
|
|
73
|
+
console.log('文件保存成功', saveRes.savedFilePath);
|
|
74
|
+
const savedFilePath = saveRes.savedFilePath; // 保存后的路径
|
|
75
|
+
// 打开文件(如PDF、Word等)
|
|
76
|
+
uni.openDocument({
|
|
77
|
+
filePath: savedFilePath,
|
|
78
|
+
success: () => console.log('打开文件成功')
|
|
79
|
+
});
|
|
80
|
+
uni.showToast({
|
|
81
|
+
title: '文件保存成功',
|
|
82
|
+
icon: 'success'
|
|
83
|
+
});
|
|
84
|
+
},
|
|
85
|
+
fail: (saveErr) => {
|
|
86
|
+
console.error('文件保存失败', saveErr);
|
|
87
|
+
uni.showToast({
|
|
88
|
+
title: '文件保存失败',
|
|
89
|
+
icon: 'none'
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
} else {
|
|
94
|
+
console.error('下载失败', res);
|
|
95
|
+
uni.showToast({
|
|
96
|
+
title: '下载失败',
|
|
97
|
+
icon: 'none'
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
fail: (err) => {
|
|
102
|
+
console.error('下载失败', err);
|
|
103
|
+
uni.showToast({
|
|
104
|
+
title: '下载失败',
|
|
105
|
+
icon: 'none'
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
}
|
|
104
110
|
</script>
|
|
105
111
|
|
|
106
112
|
<template>
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
113
|
+
<view>
|
|
114
|
+
<view v-if="loading" style="height: 100px;display: flex;justify-content: center;align-items: center;">
|
|
115
|
+
<wd-loading />
|
|
116
|
+
</view>
|
|
117
|
+
<wd-collapse v-model="value" v-else>
|
|
118
|
+
<wd-collapse-item :title="item.title" :name="item.id" v-for="(item, index) in pageConf.groups" :key="index">
|
|
119
|
+
<wd-card class="card" title=" " v-if="item.type === 'fieldGroup'">
|
|
120
|
+
<view v-for="(subItem, subIndex) in item.fields" :key='subIndex' style='margin-bottom: 15px;'>
|
|
121
|
+
<wd-row v-if="!subItem.hidden">
|
|
122
|
+
<wd-col :span="6">
|
|
123
|
+
<view class="label">
|
|
124
|
+
{{ subItem.title }}:
|
|
125
|
+
</view>
|
|
126
|
+
</wd-col>
|
|
127
|
+
<wd-col :span="18">
|
|
128
|
+
<wd-img
|
|
129
|
+
v-if="getValue(pageData.fieldMap[subItem.sourceId], subItem.title)?.type === '图片'"
|
|
130
|
+
width="100rpx" height="100rpx"
|
|
131
|
+
:src="getValue(pageData.fieldMap[subItem.sourceId], subItem.title).url"
|
|
132
|
+
:enable-preview="true" />
|
|
133
|
+
<view v-else class="value">
|
|
134
|
+
{{ getValue(pageData.fieldMap[subItem.sourceId], subItem.title) }}
|
|
135
|
+
</view>
|
|
136
|
+
</wd-col>
|
|
137
|
+
</wd-row>
|
|
138
|
+
</view>
|
|
139
|
+
|
|
140
|
+
<template #footer>
|
|
141
|
+
<wd-button size="small" icon="view-module" type="text"
|
|
142
|
+
v-if="item.buttons.includes('detail')">详情</wd-button>
|
|
143
|
+
</template>
|
|
144
|
+
</wd-card>
|
|
145
|
+
<view v-if="item.type === 'relation'">
|
|
146
|
+
<wd-card class="card" title=" " v-for="(PItem, PIndex) in pageData.arrayMap[item.id]" :key="PIndex">
|
|
147
|
+
<view v-for="(subItem, subIndex) in item.fields" :key='subIndex' style='margin-bottom: 15px;'>
|
|
148
|
+
<wd-row v-if="!subItem.hidden">
|
|
149
|
+
<wd-col :span="6">
|
|
150
|
+
<view class="label">
|
|
151
|
+
{{ subItem.title }}:
|
|
152
|
+
</view>
|
|
153
|
+
</wd-col>
|
|
154
|
+
<wd-col :span="18">
|
|
155
|
+
<wd-img
|
|
156
|
+
v-if="getValue(PItem.fieldMap[subItem.sourceId], subItem.title)?.type === '图片'"
|
|
157
|
+
width="100rpx" height="100rpx"
|
|
158
|
+
:src="getValue(PItem.fieldMap[subItem.sourceId], subItem.title).url"
|
|
159
|
+
:enable-preview="true" />
|
|
160
|
+
<view
|
|
161
|
+
v-else-if="getValue(PItem.fieldMap[subItem.sourceId], subItem.title)?.type ==='文件'"
|
|
162
|
+
class="value">
|
|
163
|
+
<wd-text type="primary"
|
|
164
|
+
@click="downloadFile(getValue(PItem.fieldMap[subItem.sourceId], subItem.title).url)"
|
|
165
|
+
:text="getValue(PItem.fieldMap[subItem.sourceId], subItem.title).name" />
|
|
166
|
+
</view>
|
|
167
|
+
<view v-else class="value">
|
|
168
|
+
{{ getValue(PItem.fieldMap[subItem.sourceId], subItem.title) }}
|
|
169
|
+
</view>
|
|
170
|
+
</wd-col>
|
|
171
|
+
</wd-row>
|
|
172
|
+
</view>
|
|
165
173
|
|
|
174
|
+
<template #footer>
|
|
175
|
+
<wd-button @click="goto(PItem,item)" size="small" icon="view-module" type="text"
|
|
176
|
+
v-if="item.buttons.includes('detail')">详情</wd-button>
|
|
177
|
+
</template>
|
|
178
|
+
</wd-card>
|
|
179
|
+
</view>
|
|
166
180
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
181
|
+
|
|
182
|
+
</wd-collapse-item>
|
|
183
|
+
</wd-collapse>
|
|
184
|
+
</view>
|
|
170
185
|
</template>
|
|
171
186
|
|
|
172
187
|
<style scoped lang="scss">
|
|
173
|
-
.label {
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
}
|
|
188
|
+
.label {
|
|
189
|
+
//文字换行
|
|
190
|
+
white-space: normal;
|
|
191
|
+
word-break: break-all;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
.value {
|
|
195
|
+
//文字换行
|
|
196
|
+
white-space: normal;
|
|
197
|
+
word-break: break-all;
|
|
198
|
+
color: #333;
|
|
199
|
+
}
|
|
178
200
|
|
|
179
|
-
.
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
}
|
|
185
|
-
.card{
|
|
186
|
-
box-shadow: rgba(0, 0, 0, 0.1) 0px 4px 17px 0px;
|
|
187
|
-
margin: 0 0 10px 0;
|
|
188
|
-
}
|
|
189
|
-
</style>
|
|
201
|
+
.card {
|
|
202
|
+
box-shadow: rgba(0, 0, 0, 0.1) 0px 4px 17px 0px;
|
|
203
|
+
margin: 0 0 10px 0;
|
|
204
|
+
}
|
|
205
|
+
</style>
|