w-ui-v1 1.0.50 → 1.0.52

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "w-ui-v1",
3
- "version": "1.0.50",
3
+ "version": "1.0.52",
4
4
  "description": "w-ui",
5
5
  "author": "wgxshh",
6
6
  "license": "ISC",
@@ -2,202 +2,214 @@ const hydrocarbonProgramToken = uni.getStorageSync('hydrocarbonProgramToken') ||
2
2
  const token = uni.getStorageSync('token') || ''
3
3
  const baseUrl = uni.getStorageSync('baseUrl') || '/'
4
4
  // 单项数据转换
5
- export function getValue(content: any, title: any): any {
6
-
7
- // 判断title 是否为字符串,是否有 '时间'字符
8
- if (typeof title === 'string') {
9
- // 判断title 是否有 '时间'字符
10
- if (title.includes('时间')) {
11
- // 判断是否为数组
12
- if (Array.isArray(content)) {
13
- const newArr = content.map((item) => {
14
- return formatTime(splitString(item))
15
- })
16
-
17
- // 数组转换为字符串
18
- return newArr.join(',')
19
- }
20
- else {
21
- return formatTime(content)
22
- }
23
- }
24
- }
25
-
26
- // 判断是否为JSON字符串
27
- if (typeof content === 'string' && content.startsWith('{') && content.endsWith('}')) {
28
- // 解析JSON字符串
29
- const obj = JSON.parse(content)
30
-
31
- // 图片链接
32
- if (obj.base?.path && (obj.base?.type.includes('jpg') || obj.base?.type.includes('png') || obj.base?.type.includes('jpeg'))) {
33
-
34
- return {
35
- url: `${baseUrl}/v3/files${obj.base.path}?@token=${token}&@programToken=${hydrocarbonProgramToken}`,
36
- type: '图片',
37
- }
38
- }
39
-
40
- //文件链接
41
- if (obj.base?.path && (obj.base?.type.includes('docx') || obj.base?.type.includes('txt') || obj.base?.type.includes('dat') || obj.base?.type.includes('md'))) {
42
-
43
- return {
44
- url: `${baseUrl}/v3/files${obj.base.path}?@token=${token}&@programToken=${hydrocarbonProgramToken}`,
45
- name: obj.base.fileName,
46
- type: '文件',
47
- }
48
- }
49
- //判断音频链接
50
- if (obj.base?.path && (obj.base?.type.includes('wav'))) {
51
-
52
- return {
53
- url: `${baseUrl}/v3/files${obj.base.path}?@token=${token}&@programToken=${hydrocarbonProgramToken}`,
54
- name: obj.base.fileName,
55
- type: '音频',
56
- author: uni.getStorageSync('userInfo').name
57
- }
58
- }
59
-
60
-
61
- }
62
-
63
- // 判断是否为数组
64
- if (Array.isArray(content)) {
65
-
66
- const newArr = content.map((item) => {
67
- return splitString(item)
68
- })
69
-
70
- //判断newArr[0] 是否为对象类型
71
- if (newArr[0] && typeof newArr[0] === 'object') {
72
- return newArr
73
- }
74
-
75
- // 数组转换为字符串
76
- return newArr.join(',')
77
- }
78
-
79
- return splitString(content)
5
+ export function getValue(content : any, title : any) : any {
6
+
7
+ // 判断title 是否为字符串,是否有 '时间'字符
8
+ if (typeof title === 'string') {
9
+ // 判断title 是否有 '时间'字符
10
+ if (title.includes('时间')) {
11
+ // 判断是否为数组
12
+ if (Array.isArray(content)) {
13
+ const newArr = content.map((item) => {
14
+ return formatTime(splitString(item))
15
+ })
16
+
17
+ // 数组转换为字符串
18
+ return newArr.join(',')
19
+ }
20
+ else {
21
+ return formatTime(content)
22
+ }
23
+ }
24
+ }
25
+
26
+ // 判断是否为JSON字符串
27
+ if (typeof content === 'string' && content.startsWith('{') && content.endsWith('}')) {
28
+ // 解析JSON字符串
29
+ const obj = JSON.parse(content)
30
+
31
+ // 图片链接
32
+ if (obj.base?.path && (obj.base?.type.includes('jpg') || obj.base?.type.includes('png') || obj.base?.type.includes('jpeg'))) {
33
+
34
+ return {
35
+ url: `${baseUrl}/v3/files${obj.base.path}?@token=${token}&@programToken=${hydrocarbonProgramToken}`,
36
+ type: '图片',
37
+ }
38
+ }
39
+
40
+ //文件链接
41
+ if (obj.base?.path && (obj.base?.type.includes('docx') || obj.base?.type.includes('txt') || obj.base?.type.includes('dat') || obj.base?.type.includes('md'))) {
42
+
43
+ return {
44
+ url: `${baseUrl}/v3/files${obj.base.path}?@token=${token}&@programToken=${hydrocarbonProgramToken}`,
45
+ name: obj.base.fileName,
46
+ type: '文件',
47
+ }
48
+ }
49
+ //判断音频链接
50
+ if (obj.base?.path && (obj.base?.type.includes('wav'))) {
51
+
52
+ return {
53
+ url: `${baseUrl}/v3/files${obj.base.path}?@token=${token}&@programToken=${hydrocarbonProgramToken}`,
54
+ name: obj.base.fileName,
55
+ type: '音频',
56
+ author: uni.getStorageSync('userInfo').name
57
+ }
58
+ }
59
+
60
+
61
+ }
62
+
63
+ // 判断是否为数组
64
+ if (Array.isArray(content)) {
65
+
66
+ const newArr = content.map((item) => {
67
+ return splitString(item)
68
+ })
69
+
70
+ //判断newArr[0] 是否为对象类型
71
+ if (newArr[0] && typeof newArr[0] === 'object') {
72
+ return newArr
73
+ }
74
+
75
+ // 数组转换为字符串
76
+ return newArr.join(',')
77
+ }
78
+
79
+ return splitString(content)
80
80
  }
81
81
 
82
82
  // 根据 "@R@" 分割字符串,取{key,value}/any
83
- function splitString(str: string) {
84
- // 判断是否为字符串类型
85
- if (typeof str !== 'string') {
86
- // 如果不是字符串类型,直接返回
87
- return str
88
- }
89
-
90
- if (str.includes('@,@')) {
91
- let arr = splitStringtoArr(str)
92
- return arr.map((item: any) => {
93
- // 判断是否有 "@R@"
94
- if (item.includes('@R@')) {
95
- // 分割字符串
96
- const splitStr = item.split('@R@')
97
-
98
- return { value: splitStr[0], label: splitStr[1] }
99
- }
100
- else {
101
-
102
- return item
103
- }
104
- })
105
-
106
- }
107
-
108
- // 判断是否有 "@R@"
109
- if (str.includes('@R@')) {
110
- // 分割字符串
111
- const splitStr = str.split('@R@')
112
- // 返回分割后的字符串
113
- return { value: splitStr[0], label: splitStr[1] }
114
- }
115
- else {
116
- // 返回原字符串
117
- return str
118
- }
83
+ function splitString(str : string) {
84
+ // 判断是否为字符串类型
85
+ if (typeof str !== 'string') {
86
+ // 如果不是字符串类型,直接返回
87
+ return str
88
+ }
89
+
90
+ if (str.includes('@,@')) {
91
+ let arr = splitStringtoArr(str)
92
+ return arr.map((item : any) => {
93
+ // 判断是否有 "@R@"
94
+ if (item.includes('@R@')) {
95
+ // 分割字符串
96
+ const splitStr = item.split('@R@')
97
+
98
+ return { value: splitStr[0], label: splitStr[1] }
99
+ }
100
+ else {
101
+
102
+ return item
103
+ }
104
+ })
105
+
106
+ }
107
+
108
+ // 判断是否有 "@R@"
109
+ if (str.includes('@R@')) {
110
+ // 分割字符串
111
+ const splitStr = str.split('@R@')
112
+ // 返回分割后的字符串
113
+ return { value: splitStr[0], label: splitStr[1] }
114
+ }
115
+ else {
116
+ // 返回原字符串
117
+ return str
118
+ }
119
119
 
120
120
  }
121
121
 
122
122
  // 根据 "@,@" 分割字符串,得到数组
123
- function splitStringtoArr(str: string) {
123
+ function splitStringtoArr(str : string) {
124
124
 
125
- // 分割字符串
126
- const splitStr = str.split('@,@')
127
- // 返回分割后的数组
128
- return splitStr
125
+ // 分割字符串
126
+ const splitStr = str.split('@,@')
127
+ // 返回分割后的数组
128
+ return splitStr
129
129
 
130
130
  }
131
131
 
132
132
  // 判断字符串中是否存在'y'字符
133
- export function hasY(str: string) {
134
- // 判断是否为字符串
135
- if (typeof str === 'string') {
136
- return str.includes('y')
137
- }
138
- return false
133
+ export function hasY(str : string) {
134
+ // 判断是否为字符串
135
+ if (typeof str === 'string') {
136
+ return str.includes('y')
137
+ }
138
+ return false
139
139
  }
140
140
 
141
141
  // 格式化时间
142
- function formatTime(str: string) {
143
- if (typeof str === 'string') {
144
- // 去掉小数点
145
- return str.split('.')[0]
146
- }
147
- return str
142
+ function formatTime(str : string) {
143
+ if (typeof str === 'string') {
144
+ // 去掉小数点
145
+ return str.split('.')[0]
146
+ }
147
+ return str
148
148
  }
149
149
 
150
150
  //下载文件
151
- export const downloadFile = (url: any) => {
152
- uni.downloadFile({
153
- url: url, // 文件的网络地址
154
- success: (res) => {
155
- if (res.statusCode === 200) {
156
- console.log('下载成功', res.tempFilePath);
157
- // 打开文件(如PDF、Word等)
158
- uni.openDocument({
159
- filePath: res.tempFilePath,
160
- showMenu: true,
161
- success: () => console.log('打开文件成功')
162
- });
163
- // // 将临时文件保存到本地
164
- // uni.saveFile({
165
- // tempFilePath: res.tempFilePath,
166
- // success: (saveRes) => {
167
- // console.log('文件保存成功', saveRes.savedFilePath);
168
- // const savedFilePath = saveRes.savedFilePath; // 保存后的路径
169
- // // 打开文件(如PDF、Word等)
170
- // uni.openDocument({
171
- // filePath: savedFilePath,
172
- // success: () => console.log('打开文件成功')
173
- // });
174
- // uni.showToast({
175
- // title: '文件保存成功',
176
- // icon: 'success'
177
- // });
178
- // },
179
- // fail: (saveErr) => {
180
- // console.error('文件保存失败', saveErr);
181
- // uni.showToast({
182
- // title: '文件保存失败',
183
- // icon: 'none'
184
- // });
185
- // }
186
- // });
187
- } else {
188
- console.error('下载失败', res);
189
- uni.showToast({
190
- title: '下载失败',
191
- icon: 'none'
192
- });
193
- }
194
- },
195
- fail: (err) => {
196
- console.error('下载失败', err);
197
- uni.showToast({
198
- title: '下载失败',
199
- icon: 'none'
200
- });
201
- }
202
- });
151
+ export const downloadFile = (url : any) => {
152
+ uni.downloadFile({
153
+ url: url, // 文件的网络地址
154
+ success: (res) => {
155
+ if (res.statusCode === 200) {
156
+ console.log('下载成功', res.tempFilePath);
157
+ // 打开文件(如PDF、Word等)
158
+ uni.openDocument({
159
+ filePath: res.tempFilePath,
160
+ showMenu: true,
161
+ success: () => console.log('打开文件成功')
162
+ });
163
+ // // 将临时文件保存到本地
164
+ // uni.saveFile({
165
+ // tempFilePath: res.tempFilePath,
166
+ // success: (saveRes) => {
167
+ // console.log('文件保存成功', saveRes.savedFilePath);
168
+ // const savedFilePath = saveRes.savedFilePath; // 保存后的路径
169
+ // // 打开文件(如PDF、Word等)
170
+ // uni.openDocument({
171
+ // filePath: savedFilePath,
172
+ // success: () => console.log('打开文件成功')
173
+ // });
174
+ // uni.showToast({
175
+ // title: '文件保存成功',
176
+ // icon: 'success'
177
+ // });
178
+ // },
179
+ // fail: (saveErr) => {
180
+ // console.error('文件保存失败', saveErr);
181
+ // uni.showToast({
182
+ // title: '文件保存失败',
183
+ // icon: 'none'
184
+ // });
185
+ // }
186
+ // });
187
+ } else {
188
+ console.error('下载失败', res);
189
+ uni.showToast({
190
+ title: '下载失败',
191
+ icon: 'none'
192
+ });
193
+ }
194
+ },
195
+ fail: (err) => {
196
+ console.error('下载失败', err);
197
+ uni.showToast({
198
+ title: '下载失败',
199
+ icon: 'none'
200
+ });
201
+ }
202
+ });
203
+ }
204
+
205
+ //获取枚举颜色 content: 406795063630012418@R@轴2
206
+ export const getEnumColor = (enumMap : any[] = [], content : string) => {
207
+ if(typeof content!=='string') return null
208
+ let css=enumMap.find((item : any) => {
209
+
210
+ return item.value === content
211
+ })
212
+
213
+ return css?.css
214
+
203
215
  }
package/w-card/w-card.vue CHANGED
@@ -14,7 +14,7 @@ import {
14
14
  ref,
15
15
  defineEmits,
16
16
  } from 'vue'
17
- import { hasY, getValue, downloadFile } from './utils/utils'
17
+ import { hasY, getValue, downloadFile,getEnumColor } from './utils/utils'
18
18
  import { deletePageData } from '../utils/apis/pageConfig'
19
19
  import { useMessage, useToast } from 'wot-design-uni'
20
20
  import WAudio from '../w-audio/w-audio.vue'
@@ -45,6 +45,10 @@ const props = defineProps({
45
45
  actionType: {
46
46
  type: String,
47
47
  default: ''
48
+ },
49
+ enumMap:{
50
+ type:Object,
51
+ default:{}
48
52
  }
49
53
  })
50
54
 
@@ -92,10 +96,12 @@ const items = computed(() => {
92
96
  // 过滤掉title 中有 'y'字符的列
93
97
  return !hasY(item.title)
94
98
  }).map((item: any) => {
99
+
95
100
  return {
101
+ css:getEnumColor(props.enumMap[item.mstrucId],props.itemData?.fieldMap[item.id]),
96
102
  title: item.title,
97
103
  controlType: item.controlType,
98
- content: getValue(props.itemData?.fieldMap[item.id], item.title),
104
+ content: getValue(props.itemData?.fieldMap[item.id], item.title),//格式化数据
99
105
  data: props.itemData?.fieldMap[item.id],
100
106
  id: item.id,
101
107
  mstrucId: item.mstrucId,
@@ -221,8 +227,13 @@ const getTitleValue = (value: any, title: string) => {
221
227
  </script>
222
228
 
223
229
  <template>
224
- <wd-card
225
- :title="getTitleValue(visibleItems.find((item) => item.id === page.primaryColumn?.id), page.primaryColumn?.title) || ' '" custom-title-class="card-title-class">
230
+ <wd-card >
231
+ <template #title>
232
+ <view class="card-title-class">
233
+ {{getTitleValue(visibleItems.find((item) => item.id === page.primaryColumn?.id), page.primaryColumn?.title) || ' '}}
234
+ </view>
235
+ </template>
236
+
226
237
  <view class="table_collapse">
227
238
  <view v-for="(item, index) in visibleItems" :key="index" class="cloum">
228
239
 
@@ -263,10 +274,11 @@ const getTitleValue = (value: any, title: string) => {
263
274
  </view>
264
275
  </view>
265
276
 
266
- <view v-else class="value" v-html="item.content?.label ? item.content?.label : item.content">
277
+ <view v-else class="value" :style="item.css" v-html="item.content?.label ? item.content?.label : item.content">
267
278
 
268
279
  </view>
269
-
280
+
281
+
270
282
  </view>
271
283
  <view class="expand-btn-container">
272
284
  <wd-button v-if="showMore" type="icon" :icon="isExpanded ? 'arrow-up' : 'arrow-down'" size="small"