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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/w-detail/w-detail.vue +190 -174
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "w-ui-v1",
3
- "version": "1.0.18",
3
+ "version": "1.0.20",
4
4
  "description": "w-ui",
5
5
  "author": "wgxshh",
6
6
  "license": "ISC",
@@ -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
- computed,
6
- ref,
7
- defineProps
8
- } from 'vue'
9
- import {
10
- detailPageConfig,
11
- detailPageData,
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
- 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: [] })
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
- 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
- }
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
- loading.value=true
47
- detailPageData(sourceId.value, code.value).then((res: any) => {
48
- pageData.value = res.data.entity
49
- getPageConfig()
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
- uni.navigateTo({
56
- url: `/pages/detail/detail?sourceId=${item.pointSourceId}&code=${PItem.code}`
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
- 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
- uni.showToast({
75
- title: '文件保存成功',
76
- icon: 'success'
77
- });
78
- },
79
- fail: (saveErr) => {
80
- console.error('文件保存失败', saveErr);
81
- uni.showToast({
82
- title: '文件保存失败',
83
- icon: 'none'
84
- });
85
- }
86
- });
87
- } else {
88
- console.error('下载失败', res);
89
- uni.showToast({
90
- title: '下载失败',
91
- icon: 'none'
92
- });
93
- }
94
- },
95
- fail: (err) => {
96
- console.error('下载失败', err);
97
- uni.showToast({
98
- title: '下载失败',
99
- icon: 'none'
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
- <view>
108
- <view v-if="loading" style="height: 100px;display: flex;justify-content: center;align-items: center;">
109
- <wd-loading />
110
- </view>
111
- <wd-collapse v-model="value" v-else>
112
- <wd-collapse-item :title="item.title" :name="item.id" v-for="(item, index) in pageConf.groups" :key="index">
113
- <wd-card class="card" title=" " v-if="item.type === 'fieldGroup'">
114
- <view v-for="(subItem, subIndex) in item.fields" :key='subIndex' style='margin-bottom: 15px;'>
115
- <wd-row v-if="!subItem.hidden">
116
- <wd-col :span="6">
117
- <view class="label">
118
- {{ subItem.title }}:
119
- </view>
120
- </wd-col>
121
- <wd-col :span="18">
122
- <wd-img v-if="getValue(pageData.fieldMap[subItem.sourceId], subItem.title)?.type === '图片'" width="100rpx"
123
- height="100rpx" :src="getValue(pageData.fieldMap[subItem.sourceId], subItem.title).url"
124
- :enable-preview="true" />
125
- <view v-else class="value">
126
- {{ getValue(pageData.fieldMap[subItem.sourceId], subItem.title) }}
127
- </view>
128
- </wd-col>
129
- </wd-row>
130
- </view>
131
-
132
- <template #footer>
133
- <wd-button size="small" icon="view-module" type="text" v-if="item.buttons.includes('detail')">详情</wd-button>
134
- </template>
135
- </wd-card>
136
- <view v-if="item.type === 'relation'">
137
- <wd-card class="card" title=" " v-for="(PItem, PIndex) in pageData.arrayMap[item.id]" :key="PIndex">
138
- <view v-for="(subItem, subIndex) in item.fields" :key='subIndex' style='margin-bottom: 15px;'>
139
- <wd-row v-if="!subItem.hidden">
140
- <wd-col :span="6">
141
- <view class="label">
142
- {{ subItem.title }}:
143
- </view>
144
- </wd-col>
145
- <wd-col :span="18">
146
- <wd-img v-if="getValue(PItem.fieldMap[subItem.sourceId], subItem.title)?.type === '图片'"
147
- width="100rpx" height="100rpx" :src="getValue(PItem.fieldMap[subItem.sourceId], subItem.title).url"
148
- :enable-preview="true" />
149
- <view v-else-if="getValue(PItem.fieldMap[subItem.sourceId], subItem.title)?.type ==='文件'" class="value">
150
- <wd-text type="primary" @click="downloadFile(getValue(PItem.fieldMap[subItem.sourceId], subItem.title).url)" :text="getValue(PItem.fieldMap[subItem.sourceId], subItem.title).name"/>
151
- </view>
152
- <view v-else class="value">
153
- {{ getValue(PItem.fieldMap[subItem.sourceId], subItem.title) }}
154
- </view>
155
- </wd-col>
156
- </wd-row>
157
- </view>
158
-
159
- <template #footer>
160
- <wd-button @click="goto(PItem,item)" size="small" icon="view-module" type="text"
161
- v-if="item.buttons.includes('detail')">详情</wd-button>
162
- </template>
163
- </wd-card>
164
- </view>
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
- </wd-collapse-item>
168
- </wd-collapse>
169
- </view>
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
- white-space: normal;
176
- word-break: break-all;
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
- .value {
180
- //文字换行
181
- white-space: normal;
182
- word-break: break-all;
183
- color: #333;
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>