wui-components-v2 1.0.96 → 1.0.98
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.
|
@@ -6,6 +6,7 @@ import type { ClassEditConfigs, Entities, Fields, Groups, rowActions } from '../
|
|
|
6
6
|
import ActionPopup from '../action-popup/action-popup.vue'
|
|
7
7
|
import { actionDataSave } from '../../api/page'
|
|
8
8
|
import { useGlobalToast } from '../../composables/useGlobalToast'
|
|
9
|
+
import { comparator } from '../../utils/index'
|
|
9
10
|
|
|
10
11
|
defineOptions({
|
|
11
12
|
name: 'CardBotomButtons',
|
|
@@ -27,7 +28,7 @@ onLoad((option: any) => {
|
|
|
27
28
|
})
|
|
28
29
|
const router = useRouter()
|
|
29
30
|
|
|
30
|
-
//
|
|
31
|
+
// rowActions按钮
|
|
31
32
|
const anctions = computed(() => {
|
|
32
33
|
const rowActions = props.rowActions || []
|
|
33
34
|
return [...rowActions.filter(isShowAction)]
|
|
@@ -54,7 +55,7 @@ function edit() {
|
|
|
54
55
|
|
|
55
56
|
const actionItem = ref<Groups>()
|
|
56
57
|
const actionItemShow = ref(false)
|
|
57
|
-
// 打开
|
|
58
|
+
// 打开rowActions弹框
|
|
58
59
|
async function action(subitem: rowActions) {
|
|
59
60
|
console.log(subitem)
|
|
60
61
|
if (subitem.writes.length) {
|
|
@@ -88,12 +89,12 @@ function detail() {
|
|
|
88
89
|
router.push(`/pages/details-page/index?sourceId=${props.sourceId}&id=${props.code}&title=${props.item.title}`)
|
|
89
90
|
}
|
|
90
91
|
|
|
91
|
-
//
|
|
92
|
+
// 判断按钮是否满足条件显示
|
|
92
93
|
function isShowAction(item: rowActions) {
|
|
93
94
|
if (item.preposes.length > 0) {
|
|
94
95
|
return item.preposes.every((prepose: Fields) => {
|
|
95
|
-
//
|
|
96
|
-
return prepose.
|
|
96
|
+
// 判断字段值是否满足要求
|
|
97
|
+
return comparator(prepose.comparator || 'equal', props.data.fieldMap[prepose.sourceId], prepose.defaultValue)
|
|
97
98
|
})
|
|
98
99
|
}
|
|
99
100
|
return true
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { computed, defineOptions, defineProps, ref } from 'vue'
|
|
3
3
|
import type { Columns, Entities } from '../../type'
|
|
4
|
-
import { formatItemData } from '../../utils'
|
|
4
|
+
import { downloadFile, formatItemData } from '../../utils'
|
|
5
5
|
import ControlTypeSupportor from '../../utils/control-type-supportor'
|
|
6
6
|
import VideoPlay from '../video-play/video-play.vue'
|
|
7
|
+
import { useManualTheme } from '../../composables/useManualTheme'
|
|
7
8
|
|
|
8
9
|
defineOptions({
|
|
9
10
|
name: 'LabelValue',
|
|
@@ -12,20 +13,11 @@ const props = defineProps<{
|
|
|
12
13
|
exhibitData: Columns[]
|
|
13
14
|
data: Entities
|
|
14
15
|
}>()
|
|
16
|
+
const { primary } = useManualTheme()
|
|
15
17
|
const clums = computed(() => {
|
|
16
18
|
return props.exhibitData.filter(item => !item.title?.includes('y'))
|
|
17
19
|
})
|
|
18
20
|
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
|
-
// }
|
|
28
|
-
|
|
29
21
|
function openVideo(uitem: any) {
|
|
30
22
|
videoPlayRef.value.open(uitem.url)
|
|
31
23
|
}
|
|
@@ -42,23 +34,19 @@ function isControlType(item: Columns): string {
|
|
|
42
34
|
</view>
|
|
43
35
|
<view
|
|
44
36
|
v-if="isControlType(item) === 'file' || isControlType(item) === 'relfile'"
|
|
45
|
-
class="flex-1 text-gray-800 dark:text-white"
|
|
37
|
+
class="flex flex-1 items-center text-gray-800 dark:text-white"
|
|
46
38
|
>
|
|
47
39
|
<view v-if="data.fieldMap[item.sourceId]">
|
|
48
40
|
<view
|
|
49
41
|
v-for="(uitem, uindex) in formatItemData(data.fieldMap[item.sourceId], isControlType(item))"
|
|
50
42
|
:key="uindex"
|
|
51
43
|
>
|
|
44
|
+
<!-- 图片 -->
|
|
52
45
|
<wd-img
|
|
53
46
|
v-if="['png', 'jpg', 'jpeg'].includes(uitem.type)" enable-preview :width="100" :height="100"
|
|
54
47
|
:src="uitem.url"
|
|
55
48
|
>
|
|
56
49
|
<template #error>
|
|
57
|
-
<!-- <view class="error-wrap">
|
|
58
|
-
<wd-button type="text" @click="downloadFile(url)">
|
|
59
|
-
{{ splitUrlStr(url) || '' }}
|
|
60
|
-
</wd-button>
|
|
61
|
-
</view> -->
|
|
62
50
|
无图片
|
|
63
51
|
</template>
|
|
64
52
|
<template #loading>
|
|
@@ -67,6 +55,7 @@ function isControlType(item: Columns): string {
|
|
|
67
55
|
</view>
|
|
68
56
|
</template>
|
|
69
57
|
</wd-img>
|
|
58
|
+
<!-- 视频 -->
|
|
70
59
|
<view
|
|
71
60
|
v-else-if="['mp4', 'mov', 'wmv', 'avi', 'rmvb', 'flv', 'mkv'].includes(uitem.type)"
|
|
72
61
|
style="width: 70px;height: 70px;display: flex;align-items: center;justify-content: center;border: 1px solid #ccc;border-radius: 4px;"
|
|
@@ -74,6 +63,12 @@ function isControlType(item: Columns): string {
|
|
|
74
63
|
>
|
|
75
64
|
<wd-icon name="play-circle-filled" size="22px" />
|
|
76
65
|
</view>
|
|
66
|
+
<!-- 文件 -->
|
|
67
|
+
<view v-else-if="['doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx', 'pdf', 'txt', 'zip', 'rar', '7z', 'gz', 'bz2', 'tar', 'iso', 'exe', 'dmg', 'apk', 'apk', 'apk', 'apk', 'apk', 'apk', 'apk', 'apk'].includes(uitem.type)">
|
|
68
|
+
<span :style="{ color: primary }" @click="downloadFile(uitem.url)">
|
|
69
|
+
{{ uitem.name }}
|
|
70
|
+
</span>
|
|
71
|
+
</view>
|
|
77
72
|
</view>
|
|
78
73
|
</view>
|
|
79
74
|
</view>
|
|
@@ -146,6 +146,7 @@ export function useManualTheme() {
|
|
|
146
146
|
return {
|
|
147
147
|
// 状态
|
|
148
148
|
theme: computed(() => store.theme),
|
|
149
|
+
// 主题色
|
|
149
150
|
primary: computed(() => store.themeVars.colorTheme),
|
|
150
151
|
isDark: computed(() => store.isDark),
|
|
151
152
|
followSystem: computed(() => store.followSystem),
|
package/package.json
CHANGED
package/type.ts
CHANGED
|
@@ -1,3 +1,23 @@
|
|
|
1
|
+
export type Comparator =
|
|
2
|
+
| 'contain'
|
|
3
|
+
| 'equal'
|
|
4
|
+
| 'equals'
|
|
5
|
+
| 'unequal'
|
|
6
|
+
| 'unequals'
|
|
7
|
+
| 'includeOne'
|
|
8
|
+
| 'include_anyone'
|
|
9
|
+
| 'include_all'
|
|
10
|
+
| 'noless'
|
|
11
|
+
| 'nogreater'
|
|
12
|
+
| 'less'
|
|
13
|
+
| 'greater'
|
|
14
|
+
| 'exclude'
|
|
15
|
+
| 'noLess'
|
|
16
|
+
| 'noGreater'
|
|
17
|
+
| 'Less'
|
|
18
|
+
| 'Greater'
|
|
19
|
+
| 'none1' | 'none1n'
|
|
20
|
+
|
|
1
21
|
// 列表字段配置
|
|
2
22
|
export interface Columns {
|
|
3
23
|
controlType: string
|
|
@@ -50,6 +70,7 @@ export interface Fields extends Columns {
|
|
|
50
70
|
required: boolean
|
|
51
71
|
max?: string
|
|
52
72
|
min?: string
|
|
73
|
+
comparator?: Comparator
|
|
53
74
|
}
|
|
54
75
|
|
|
55
76
|
// 编辑按钮配置
|
package/utils/index.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { Comparator } from '../type'
|
|
2
|
+
|
|
1
3
|
const baseUrl = uni.getStorageSync('BASE_URL')
|
|
2
4
|
const token = uni.getStorageSync('TOKEN')
|
|
3
5
|
const hydrocarbonProgramToken = uni.getStorageSync('HYDROCARBON_PROGRAM_TOKEN')
|
|
@@ -44,7 +46,7 @@ export function formatItemData(data: any, type: string) {
|
|
|
44
46
|
const a = JSON.parse(data)
|
|
45
47
|
return [{
|
|
46
48
|
url: `${baseUrl}/v3/files${a.base.path}?@token=${token}&@programToken=${hydrocarbonProgramToken}&name=${a.base.fileName || ''}`,
|
|
47
|
-
name: a.base.
|
|
49
|
+
name: a.base.fileName,
|
|
48
50
|
type: a.base.type,
|
|
49
51
|
}]
|
|
50
52
|
}
|
|
@@ -54,7 +56,7 @@ export function formatItemData(data: any, type: string) {
|
|
|
54
56
|
const a = JSON.parse(item.split('@R@')[1])
|
|
55
57
|
return [{
|
|
56
58
|
url: `${baseUrl}/v3/files${a.base.path}?@token=${token}&@programToken=${hydrocarbonProgramToken}&name=${a.base.fileName || ''}`,
|
|
57
|
-
name: a.base.
|
|
59
|
+
name: a.base.fileName,
|
|
58
60
|
type: a.base.type,
|
|
59
61
|
}]
|
|
60
62
|
}
|
|
@@ -62,7 +64,7 @@ export function formatItemData(data: any, type: string) {
|
|
|
62
64
|
const a = JSON.parse(item)
|
|
63
65
|
return [{
|
|
64
66
|
url: `${baseUrl}/v3/files${a.base.path}?@token=${token}&@programToken=${hydrocarbonProgramToken}&name=${a.base.fileName || ''}`,
|
|
65
|
-
name: a.base.
|
|
67
|
+
name: a.base.fileName,
|
|
66
68
|
type: a.base.type,
|
|
67
69
|
}]
|
|
68
70
|
}
|
|
@@ -95,7 +97,7 @@ export function generateHighResolutionID(): string {
|
|
|
95
97
|
}
|
|
96
98
|
|
|
97
99
|
// 下载文件
|
|
98
|
-
export function downloadFile(url:
|
|
100
|
+
export function downloadFile(url: string) {
|
|
99
101
|
console.log('下载', url)
|
|
100
102
|
uni.downloadFile({
|
|
101
103
|
url, // 文件的网络地址
|
|
@@ -138,3 +140,172 @@ function getAfterLastMatch(str: string, pattern: string) {
|
|
|
138
140
|
return null
|
|
139
141
|
return str.substring(lastIndex + pattern.length)
|
|
140
142
|
}
|
|
143
|
+
|
|
144
|
+
/****
|
|
145
|
+
*
|
|
146
|
+
* 根据comparator、defaultValue、val
|
|
147
|
+
* 判断按钮是否满洲显示
|
|
148
|
+
*
|
|
149
|
+
*
|
|
150
|
+
*/
|
|
151
|
+
export function comparator(
|
|
152
|
+
comparator: Comparator,
|
|
153
|
+
val: string,
|
|
154
|
+
defaultValue: string,
|
|
155
|
+
): boolean {
|
|
156
|
+
let dvs: string[]
|
|
157
|
+
let value = val
|
|
158
|
+
if (val && val.indexOf && val.indexOf('@R@') > 0) {
|
|
159
|
+
const vs = val.split('@R@')
|
|
160
|
+
value = vs[1]
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
if (!comparator) {
|
|
164
|
+
comparator = 'equals'
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
if (comparator === 'none1') {
|
|
168
|
+
return !value || value === ''
|
|
169
|
+
}
|
|
170
|
+
else if (comparator === 'none1n') {
|
|
171
|
+
return !!value && value !== ''
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
if (!defaultValue) {
|
|
175
|
+
return true
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
if (!value && value !== '0') {
|
|
179
|
+
return false
|
|
180
|
+
}
|
|
181
|
+
let vals
|
|
182
|
+
switch (comparator) {
|
|
183
|
+
case 'contain':
|
|
184
|
+
return value.includes(defaultValue)
|
|
185
|
+
case 'equal':
|
|
186
|
+
case 'equals':
|
|
187
|
+
return isEqual(value, defaultValue)
|
|
188
|
+
case 'exclude':
|
|
189
|
+
dvs = toArray(defaultValue)
|
|
190
|
+
vals = toArray(value)
|
|
191
|
+
for (let i = 0; i < dvs.length; i++) {
|
|
192
|
+
for (let j = 0; j < vals.length; j++) {
|
|
193
|
+
if (dvs[i] === vals[j]) {
|
|
194
|
+
return false
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
return true
|
|
199
|
+
case 'includeOne':
|
|
200
|
+
case 'include_anyone':
|
|
201
|
+
dvs = toArray(defaultValue)
|
|
202
|
+
vals = toArray(value)
|
|
203
|
+
for (let i = 0; i < dvs.length; i++) {
|
|
204
|
+
for (let j = 0; j < vals.length; j++) {
|
|
205
|
+
if (dvs[i] === vals[j]) {
|
|
206
|
+
return true
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
return false
|
|
211
|
+
|
|
212
|
+
case 'include_all':
|
|
213
|
+
{ dvs = toArray(defaultValue)
|
|
214
|
+
vals = toArray(value)
|
|
215
|
+
let count = 0
|
|
216
|
+
const targetCount = dvs.length
|
|
217
|
+
for (let i = 0; i < dvs.length; i++) {
|
|
218
|
+
for (let j = 0; j < vals.length; j++) {
|
|
219
|
+
if (dvs[i] === vals[j]) {
|
|
220
|
+
count++
|
|
221
|
+
break
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
return targetCount <= count }
|
|
226
|
+
case 'Greater':
|
|
227
|
+
case 'greater':
|
|
228
|
+
if (!Number.isNaN(Number(value)) && !Number.isNaN(Number(defaultValue))) {
|
|
229
|
+
return Number(value) > Number(defaultValue)
|
|
230
|
+
}
|
|
231
|
+
else {
|
|
232
|
+
return value > defaultValue
|
|
233
|
+
}
|
|
234
|
+
case 'Less':
|
|
235
|
+
case 'less':
|
|
236
|
+
if (!Number.isNaN(Number(value)) && !Number.isNaN(Number(defaultValue))) {
|
|
237
|
+
return Number(value) < Number(defaultValue)
|
|
238
|
+
}
|
|
239
|
+
else {
|
|
240
|
+
return value < defaultValue
|
|
241
|
+
}
|
|
242
|
+
case 'noGreater':
|
|
243
|
+
case 'nogreater':
|
|
244
|
+
if (!Number.isNaN(Number(value)) && !Number.isNaN(Number(defaultValue))) {
|
|
245
|
+
return Number(value) <= Number(defaultValue)
|
|
246
|
+
}
|
|
247
|
+
else {
|
|
248
|
+
return value <= defaultValue
|
|
249
|
+
}
|
|
250
|
+
case 'noLess':
|
|
251
|
+
case 'noless':
|
|
252
|
+
if (!Number.isNaN(Number(value)) && !Number.isNaN(Number(defaultValue))) {
|
|
253
|
+
return Number(value) >= Number(defaultValue)
|
|
254
|
+
}
|
|
255
|
+
else {
|
|
256
|
+
return value >= defaultValue
|
|
257
|
+
}
|
|
258
|
+
case 'unequal':
|
|
259
|
+
case 'unequals':
|
|
260
|
+
return !isEqual(value, defaultValue)
|
|
261
|
+
default:
|
|
262
|
+
console.log(`暂不支持的比较关系:${comparator};请联系管理员添加。`)
|
|
263
|
+
return false // 兜底返回值
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
function isEqual(value: string, defaultValue: string) {
|
|
268
|
+
if (defaultValue === '是' || defaultValue === '否' || defaultValue === 'true' || defaultValue === 'false') {
|
|
269
|
+
if (value === 'true' || value === '是') {
|
|
270
|
+
if (defaultValue === '是' || defaultValue === 'true') {
|
|
271
|
+
return true
|
|
272
|
+
}
|
|
273
|
+
else {
|
|
274
|
+
return false
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
else if (value === 'false' || value === '否') {
|
|
278
|
+
if (defaultValue === '否' || defaultValue === 'false') {
|
|
279
|
+
return true
|
|
280
|
+
}
|
|
281
|
+
else {
|
|
282
|
+
return false
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
else {
|
|
286
|
+
return false
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
else {
|
|
290
|
+
if (!Number.isNaN(Number(value)) && !Number.isNaN(Number(defaultValue))) {
|
|
291
|
+
return Number(value) === Number(defaultValue)
|
|
292
|
+
}
|
|
293
|
+
else {
|
|
294
|
+
return value === defaultValue
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
function toArray(value: string) {
|
|
300
|
+
let val
|
|
301
|
+
if (typeof value == 'string') {
|
|
302
|
+
val = value.split(',')
|
|
303
|
+
}
|
|
304
|
+
else if (Array.isArray(value)) {
|
|
305
|
+
val = value
|
|
306
|
+
}
|
|
307
|
+
else {
|
|
308
|
+
val = [value]
|
|
309
|
+
}
|
|
310
|
+
return val
|
|
311
|
+
}
|