af-mobile-client-vue3 1.3.67 → 1.3.69
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/src/components/data/XBadge/index.vue +80 -14
- package/src/components/data/XCellList/index.vue +16 -4
- package/src/components/data/XFormItem/index.vue +2 -2
- package/src/router/routes.ts +421 -421
- package/src/utils/queryFormDefaultRangePicker.ts +57 -57
- package/src/views/component/XCellListView/index.vue +109 -134
- package/src/views/component/XFormGroupView/index.vue +78 -82
- package/src/views/component/XFormView/index.vue +17 -18
- package/src/views/component/XOlMapView/XLocationPicker/index.vue +118 -118
package/package.json
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { getDictItemByValue } from '@af-mobile-client-vue3/utils/dictUtil'
|
|
3
|
+
import dayjs from 'dayjs/esm/index'
|
|
3
4
|
import { ref } from 'vue'
|
|
4
5
|
|
|
5
|
-
const { serviceName, dictName, dictValue } = defineProps<{
|
|
6
|
+
const { serviceName, dictName, dictValue, dictType } = defineProps<{
|
|
6
7
|
serviceName: string
|
|
7
8
|
dictName: string | null | undefined
|
|
8
|
-
dictValue: string | null | undefined
|
|
9
|
+
dictValue: string | number | null | undefined
|
|
10
|
+
// 用于非字典型的格式化展示:如日期/小数/整数等
|
|
11
|
+
dictType?: 'date' | 'dateTime' | 'towDecimal' | 'fourDecimal' | 'int' | string
|
|
9
12
|
}>()
|
|
10
13
|
|
|
11
14
|
// 字面值
|
|
@@ -18,23 +21,86 @@ initComponent()
|
|
|
18
21
|
|
|
19
22
|
// 组件初始化
|
|
20
23
|
function initComponent() {
|
|
21
|
-
if (dictValue === null || dictValue === undefined) {
|
|
24
|
+
if (dictValue === null || dictValue === undefined || dictValue === '') {
|
|
22
25
|
label.value = '--'
|
|
26
|
+
className.value = ''
|
|
23
27
|
return
|
|
24
28
|
}
|
|
25
|
-
|
|
26
|
-
|
|
29
|
+
|
|
30
|
+
// 1) 优先使用字典映射
|
|
31
|
+
if (dictName && dictName !== '') {
|
|
32
|
+
getDictItemByValue(dictName, serviceName, String(dictValue), (result) => {
|
|
33
|
+
if (result == null) {
|
|
34
|
+
// 字典未命中,退回到格式化/原值
|
|
35
|
+
applyFormatFallback()
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
label.value = result.label
|
|
39
|
+
className.value = `badge-${result.status}`
|
|
40
|
+
}
|
|
41
|
+
})
|
|
27
42
|
return
|
|
28
43
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
44
|
+
|
|
45
|
+
// 2) 无字典名时,按 dictType 做格式化
|
|
46
|
+
applyFormatFallback()
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function applyFormatFallback() {
|
|
50
|
+
className.value = ''
|
|
51
|
+
if (!dictType || dictType === '') {
|
|
52
|
+
label.value = String(dictValue)
|
|
53
|
+
return
|
|
54
|
+
}
|
|
55
|
+
switch (dictType) {
|
|
56
|
+
case 'date':
|
|
57
|
+
label.value = formatDateLike(dictValue, 'YYYY-MM-DD')
|
|
58
|
+
break
|
|
59
|
+
case 'dateTime':
|
|
60
|
+
label.value = formatDateLike(dictValue, 'YYYY-MM-DD HH:mm:ss')
|
|
61
|
+
break
|
|
62
|
+
case 'towDecimal':
|
|
63
|
+
label.value = formatNumberLike(dictValue, 2)
|
|
64
|
+
break
|
|
65
|
+
case 'fourDecimal':
|
|
66
|
+
label.value = formatNumberLike(dictValue, 4)
|
|
67
|
+
break
|
|
68
|
+
case 'int':
|
|
69
|
+
label.value = formatNumberLike(dictValue, 0)
|
|
70
|
+
break
|
|
71
|
+
default:
|
|
72
|
+
label.value = String(dictValue)
|
|
73
|
+
break
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function pad2(num: number): string {
|
|
78
|
+
return String(num).padStart(2, '0')
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function formatDateLike(val: string | number, pattern: string): string {
|
|
82
|
+
// 1️⃣ 先判断时间是否合法
|
|
83
|
+
const date = dayjs(val)
|
|
84
|
+
if (!date.isValid()) {
|
|
85
|
+
console.warn('时间字符串不合法:', val)
|
|
86
|
+
return val as string
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// 2️⃣ 判断格式字符串是否有效(简单校验,格式字符串非空)
|
|
90
|
+
if (!pattern || typeof pattern !== 'string') {
|
|
91
|
+
console.warn('格式字符串不合法:', pattern)
|
|
92
|
+
return val as string
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// 3️⃣ 使用 dayjs 格式化
|
|
96
|
+
return date.format(pattern)
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function formatNumberLike(val: string | number, digits: number): string {
|
|
100
|
+
const num = typeof val === 'number' ? val : Number(val)
|
|
101
|
+
if (Number.isNaN(num))
|
|
102
|
+
return String(val)
|
|
103
|
+
return num.toFixed(digits)
|
|
38
104
|
}
|
|
39
105
|
</script>
|
|
40
106
|
|
|
@@ -841,7 +841,13 @@ function handleCheckboxChange(item: any, checked: boolean) {
|
|
|
841
841
|
:class="{ 'selectable-title': isMultiSelectMode }"
|
|
842
842
|
@click="handleTitleClick(item, $event)"
|
|
843
843
|
>
|
|
844
|
-
|
|
844
|
+
<XBadge
|
|
845
|
+
:style="handleFunctionStyle(column.styleFunctionForValue, item)"
|
|
846
|
+
:dict-name="column.dictName"
|
|
847
|
+
:dict-value="item[column.dataIndex]"
|
|
848
|
+
:dict-type="column.slotType"
|
|
849
|
+
:service-name="serviceName"
|
|
850
|
+
/>
|
|
845
851
|
</p>
|
|
846
852
|
</div>
|
|
847
853
|
<div v-for="(column) in subTitleColumns" :key="`subtitle_${column.dataIndex}`" class="sub-title">
|
|
@@ -851,7 +857,9 @@ function handleCheckboxChange(item: any, checked: boolean) {
|
|
|
851
857
|
>
|
|
852
858
|
<XBadge
|
|
853
859
|
:style="handleFunctionStyle(column.styleFunctionForValue, item)"
|
|
854
|
-
:dict-name="column.dictName"
|
|
860
|
+
:dict-name="column.dictName"
|
|
861
|
+
:dict-value="item[column.dataIndex]"
|
|
862
|
+
:dict-type="column.slotType"
|
|
855
863
|
:service-name="serviceName"
|
|
856
864
|
/>
|
|
857
865
|
</p>
|
|
@@ -876,7 +884,9 @@ function handleCheckboxChange(item: any, checked: boolean) {
|
|
|
876
884
|
{{ (column.showLabel === undefined || column.showLabel) ? `${column.title}: ` : '' }}
|
|
877
885
|
<XBadge
|
|
878
886
|
:style="handleFunctionStyle(column.styleFunctionForValue, item)"
|
|
879
|
-
:dict-name="column.dictName"
|
|
887
|
+
:dict-name="column.dictName"
|
|
888
|
+
:dict-value="item[column.dataIndex]"
|
|
889
|
+
:dict-type="column.slotType"
|
|
880
890
|
:service-name="serviceName"
|
|
881
891
|
/>
|
|
882
892
|
</p>
|
|
@@ -924,7 +934,9 @@ function handleCheckboxChange(item: any, checked: boolean) {
|
|
|
924
934
|
</span>
|
|
925
935
|
<XBadge
|
|
926
936
|
:style="handleFunctionStyle(column.styleFunctionForValue, item)"
|
|
927
|
-
:dict-name="column.dictName"
|
|
937
|
+
:dict-name="column.dictName"
|
|
938
|
+
:dict-value="item[column.dataIndex]"
|
|
939
|
+
:dict-type="column.slotType"
|
|
928
940
|
:service-name="serviceName"
|
|
929
941
|
/>
|
|
930
942
|
</p>
|
|
@@ -424,7 +424,7 @@ function updateFile(files, _index) {
|
|
|
424
424
|
|
|
425
425
|
// 表单校验的类型校验
|
|
426
426
|
function formTypeCheck(attr, value) {
|
|
427
|
-
if (mode === '查询')
|
|
427
|
+
if (mode === '查询' || mode === '预览')
|
|
428
428
|
return
|
|
429
429
|
// if (!attr.rule || !attr.rule.required || attr.rule.required === 'false')
|
|
430
430
|
// return
|
|
@@ -575,7 +575,7 @@ const readonly = computed(() => {
|
|
|
575
575
|
})
|
|
576
576
|
// 提示内容
|
|
577
577
|
const placeholder = computed(() => {
|
|
578
|
-
if (attr.addOrEdit === 'readonly')
|
|
578
|
+
if (attr.addOrEdit === 'readonly' || mode === '预览')
|
|
579
579
|
return '暂无内容 ~ '
|
|
580
580
|
else
|
|
581
581
|
return attr.placeholder ? attr.placeholder : `请选择${attr.name}`
|