af-mobile-client-vue3 1.2.39 → 1.2.41
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/XCellList/index.vue +4 -2
- package/src/components/data/XFormGroup/index.vue +29 -1
- package/src/components/data/XFormItem/index.vue +49 -4
- package/src/utils/queryFormDefaultRangePicker.ts +57 -57
- package/src/views/component/XCellListView/index.vue +63 -22
- package/src/views/component/XFormGroupView/index.vue +11 -7
package/package.json
CHANGED
|
@@ -141,6 +141,9 @@ const title = ref('')
|
|
|
141
141
|
// 按钮权限
|
|
142
142
|
const buttonPermissions = ref([])
|
|
143
143
|
|
|
144
|
+
// 默认参数
|
|
145
|
+
const defaultParams = {}
|
|
146
|
+
|
|
144
147
|
const slots = useSlots()
|
|
145
148
|
|
|
146
149
|
// 当前组件实例(不推荐使用,可能会在后续的版本更迭中调整,暂时用来绑定函数的上下文)
|
|
@@ -235,7 +238,6 @@ function initComponent() {
|
|
|
235
238
|
|
|
236
239
|
// 初始化条件参数
|
|
237
240
|
function initConditionParams(formItems, isQuery) {
|
|
238
|
-
const defaultParams = {}
|
|
239
241
|
let hasDefaults: boolean
|
|
240
242
|
|
|
241
243
|
// 从表单配置中获取所有默认值
|
|
@@ -287,7 +289,7 @@ function onRefresh() {
|
|
|
287
289
|
finishedText.value = '加载完成'
|
|
288
290
|
finished.value = false
|
|
289
291
|
loading.value = true
|
|
290
|
-
onLoad()
|
|
292
|
+
onLoad(defaultParams)
|
|
291
293
|
}, 100)
|
|
292
294
|
}
|
|
293
295
|
|
|
@@ -9,11 +9,13 @@ const props = withDefaults(defineProps<{
|
|
|
9
9
|
serviceName?: string
|
|
10
10
|
groupFormData?: object
|
|
11
11
|
mode?: string
|
|
12
|
+
isScrollspy?: boolean
|
|
12
13
|
}>(), {
|
|
13
14
|
configName: '',
|
|
14
15
|
serviceName: undefined,
|
|
15
16
|
groupFormData: () => ({}),
|
|
16
17
|
mode: '查询',
|
|
18
|
+
isScrollspy: true,
|
|
17
19
|
})
|
|
18
20
|
const emit = defineEmits(['submit'])
|
|
19
21
|
|
|
@@ -22,6 +24,7 @@ interface Form {
|
|
|
22
24
|
serviceName?: string
|
|
23
25
|
groupFormData?: object
|
|
24
26
|
mode?: string
|
|
27
|
+
isScrollspy?: boolean
|
|
25
28
|
}
|
|
26
29
|
|
|
27
30
|
const groupItems = ref([])
|
|
@@ -89,7 +92,7 @@ defineExpose({ init })
|
|
|
89
92
|
|
|
90
93
|
<template>
|
|
91
94
|
<div v-if="isInit" id="x-form-group">
|
|
92
|
-
<VanTabs scrollspy sticky :offset-top="offsetTop">
|
|
95
|
+
<VanTabs :scrollspy="propsData.isScrollspy" sticky :offset-top="offsetTop">
|
|
93
96
|
<VanTab
|
|
94
97
|
v-for="(item, index) in groupItems"
|
|
95
98
|
:key="item.groupName ? (item.groupName + index) : index"
|
|
@@ -99,6 +102,10 @@ defineExpose({ init })
|
|
|
99
102
|
class="x-form-group-item"
|
|
100
103
|
:class="{ 'is-last': index === groupItems.length - 1 }"
|
|
101
104
|
>
|
|
105
|
+
<div v-if="item.describe && propsData.isScrollspy && (item.groupName || item.slotName)" class="form-group-title">
|
|
106
|
+
<span class="form-group-bar" />
|
|
107
|
+
<span class="form-group-text">{{ item.describe }}</span>
|
|
108
|
+
</div>
|
|
102
109
|
<XForm
|
|
103
110
|
ref="xFormListRef"
|
|
104
111
|
:is-group-form="true"
|
|
@@ -140,4 +147,25 @@ defineExpose({ init })
|
|
|
140
147
|
.x-form-group-item.is-last {
|
|
141
148
|
min-height: calc(100vh - var(--van-nav-bar-height) - 40px);
|
|
142
149
|
}
|
|
150
|
+
.form-group-title {
|
|
151
|
+
display: flex;
|
|
152
|
+
align-items: center;
|
|
153
|
+
padding-top: 12px;
|
|
154
|
+
background: none;
|
|
155
|
+
margin: 0 0 4px 0;
|
|
156
|
+
}
|
|
157
|
+
.form-group-bar {
|
|
158
|
+
width: 4px;
|
|
159
|
+
height: 20px;
|
|
160
|
+
background: #1989fa;
|
|
161
|
+
border-radius: 4px;
|
|
162
|
+
margin-right: 8px;
|
|
163
|
+
flex-shrink: 0;
|
|
164
|
+
}
|
|
165
|
+
.form-group-text {
|
|
166
|
+
font-weight: 600;
|
|
167
|
+
font-size: 15px;
|
|
168
|
+
color: #222;
|
|
169
|
+
letter-spacing: 0.5px;
|
|
170
|
+
}
|
|
143
171
|
</style>
|
|
@@ -187,6 +187,27 @@ function getDefaultValue() {
|
|
|
187
187
|
const getDefaultByType = () => {
|
|
188
188
|
const def = mode !== '查询' ? attr.formDefault : attr.queryFormDefault
|
|
189
189
|
|
|
190
|
+
if (['treeSelect', 'select', 'checkbox'].includes(attr.type) && ['curOrgId', 'curDepId', 'curUserId'].includes(def)) {
|
|
191
|
+
if (def === 'curOrgId') {
|
|
192
|
+
if (attr.type === 'treeSelect') {
|
|
193
|
+
treeValue.value = userState.f.resources.orgs
|
|
194
|
+
}
|
|
195
|
+
return attr.type === 'select' ? userState.f.resources.orgid : [userState.f.resources.orgid]
|
|
196
|
+
}
|
|
197
|
+
if (def === 'curDepId') {
|
|
198
|
+
if (attr.type === 'treeSelect') {
|
|
199
|
+
treeValue.value = userState.f.resources.deps
|
|
200
|
+
}
|
|
201
|
+
return attr.type === 'select' ? userState.f.resources.depids : [userState.f.resources.depids]
|
|
202
|
+
}
|
|
203
|
+
if (def === 'curUserId') {
|
|
204
|
+
if (attr.type === 'treeSelect') {
|
|
205
|
+
treeValue.value = userState.f.resources.name
|
|
206
|
+
}
|
|
207
|
+
return attr.type === 'select' ? userState.f.resources.id : [userState.f.resources.id]
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
190
211
|
// 数组类型默认值
|
|
191
212
|
const arrayTypes = ['uploader', 'checkbox', 'file', 'area', 'image', 'treeSelect']
|
|
192
213
|
if (arrayTypes.includes(attr.type)) {
|
|
@@ -716,10 +737,34 @@ defineExpose({
|
|
|
716
737
|
reset,
|
|
717
738
|
})
|
|
718
739
|
|
|
740
|
+
// 数据处理
|
|
741
|
+
function cleanEmptyChildren(options, fieldNames = { text: 'label', value: 'value', children: 'children' }) {
|
|
742
|
+
if (!Array.isArray(options))
|
|
743
|
+
return options
|
|
744
|
+
|
|
745
|
+
const childrenKey = fieldNames.children || 'children'
|
|
746
|
+
|
|
747
|
+
return options.map((option) => {
|
|
748
|
+
// 深拷贝选项,避免修改原始数据
|
|
749
|
+
const newOption = { ...option }
|
|
750
|
+
|
|
751
|
+
// 如果存在children属性且是空数组
|
|
752
|
+
if (newOption[childrenKey] && Array.isArray(newOption[childrenKey]) && newOption[childrenKey].length === 0) {
|
|
753
|
+
delete newOption[childrenKey]
|
|
754
|
+
}
|
|
755
|
+
// 如果存在children属性且非空,则递归处理
|
|
756
|
+
else if (newOption[childrenKey] && Array.isArray(newOption[childrenKey])) {
|
|
757
|
+
newOption[childrenKey] = cleanEmptyChildren(newOption[childrenKey], fieldNames)
|
|
758
|
+
}
|
|
759
|
+
return newOption
|
|
760
|
+
})
|
|
761
|
+
}
|
|
762
|
+
|
|
719
763
|
// 级联选择完成事件
|
|
720
|
-
function onTreeSelectFinish(
|
|
721
|
-
|
|
722
|
-
|
|
764
|
+
function onTreeSelectFinish({ selectedOptions }) {
|
|
765
|
+
const index = selectedOptions.length - 1
|
|
766
|
+
treeValue.value = selectedOptions[index].label
|
|
767
|
+
modelData.value = [selectedOptions[index].value]
|
|
723
768
|
showTreeSelect.value = false
|
|
724
769
|
}
|
|
725
770
|
|
|
@@ -1217,7 +1262,7 @@ function emitFunc(func, data) {
|
|
|
1217
1262
|
overlay-class="date-picker-overlay"
|
|
1218
1263
|
>
|
|
1219
1264
|
<VanCascader
|
|
1220
|
-
:options="option"
|
|
1265
|
+
:options="cleanEmptyChildren(option, attr.customFieldName ? attr.customFieldName : { text: 'label', value: 'value', children: 'children' })"
|
|
1221
1266
|
:field-names="attr.customFieldName ? attr.customFieldName : { text: 'label', value: 'value', children: 'children' }"
|
|
1222
1267
|
:title="attr.name"
|
|
1223
1268
|
:closeable="true"
|
|
@@ -1,57 +1,57 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 根据类型获取日期区间字符串
|
|
3
|
-
* @param type '当年' | 'curMonth' | '当日'
|
|
4
|
-
* @param show 区分实际值还是显示值, true为实际值, false为显示值
|
|
5
|
-
* @returns [start, end] 例:['2024-01-01 00:00:00', '2024-12-31 23:59:59']
|
|
6
|
-
*/
|
|
7
|
-
export function getRangeByType(type: string, show: boolean): [string, string] {
|
|
8
|
-
const now = new Date()
|
|
9
|
-
const year = now.getFullYear()
|
|
10
|
-
const month = (now.getMonth() + 1).toString().padStart(2, '0')
|
|
11
|
-
const day = now.getDate().toString().padStart(2, '0')
|
|
12
|
-
|
|
13
|
-
if (!show) {
|
|
14
|
-
if (type === 'curYear') {
|
|
15
|
-
return [
|
|
16
|
-
`${year}-01-01 00:00:00`,
|
|
17
|
-
`${year}-12-31 23:59:59`,
|
|
18
|
-
]
|
|
19
|
-
}
|
|
20
|
-
if (type === 'curMonth') {
|
|
21
|
-
const lastDay = new Date(year, now.getMonth() + 1, 0).getDate()
|
|
22
|
-
return [
|
|
23
|
-
`${year}-${month}-01 00:00:00`,
|
|
24
|
-
`${year}-${month}-${lastDay.toString().padStart(2, '0')} 23:59:59`,
|
|
25
|
-
]
|
|
26
|
-
}
|
|
27
|
-
if (type === 'curDay') {
|
|
28
|
-
return [
|
|
29
|
-
`${year}-${month}-${day} 00:00:00`,
|
|
30
|
-
`${year}-${month}-${day} 23:59:59`,
|
|
31
|
-
]
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
if (show) {
|
|
35
|
-
if (type === 'curYear') {
|
|
36
|
-
return [
|
|
37
|
-
`${year}-01-01`,
|
|
38
|
-
`${year}-12-31`,
|
|
39
|
-
]
|
|
40
|
-
}
|
|
41
|
-
if (type === 'curMonth') {
|
|
42
|
-
const lastDay = new Date(year, now.getMonth() + 1, 0).getDate()
|
|
43
|
-
return [
|
|
44
|
-
`${year}-${month}-01`,
|
|
45
|
-
`${year}-${month}-${lastDay.toString().padStart(2, '0')}`,
|
|
46
|
-
]
|
|
47
|
-
}
|
|
48
|
-
if (type === 'curDay') {
|
|
49
|
-
return [
|
|
50
|
-
`${year}-${month}-${day}`,
|
|
51
|
-
`${year}-${month}-${day}`,
|
|
52
|
-
]
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
// 兜底返回空字符串数组
|
|
56
|
-
return ['', '']
|
|
57
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* 根据类型获取日期区间字符串
|
|
3
|
+
* @param type '当年' | 'curMonth' | '当日'
|
|
4
|
+
* @param show 区分实际值还是显示值, true为实际值, false为显示值
|
|
5
|
+
* @returns [start, end] 例:['2024-01-01 00:00:00', '2024-12-31 23:59:59']
|
|
6
|
+
*/
|
|
7
|
+
export function getRangeByType(type: string, show: boolean): [string, string] {
|
|
8
|
+
const now = new Date()
|
|
9
|
+
const year = now.getFullYear()
|
|
10
|
+
const month = (now.getMonth() + 1).toString().padStart(2, '0')
|
|
11
|
+
const day = now.getDate().toString().padStart(2, '0')
|
|
12
|
+
|
|
13
|
+
if (!show) {
|
|
14
|
+
if (type === 'curYear') {
|
|
15
|
+
return [
|
|
16
|
+
`${year}-01-01 00:00:00`,
|
|
17
|
+
`${year}-12-31 23:59:59`,
|
|
18
|
+
]
|
|
19
|
+
}
|
|
20
|
+
if (type === 'curMonth') {
|
|
21
|
+
const lastDay = new Date(year, now.getMonth() + 1, 0).getDate()
|
|
22
|
+
return [
|
|
23
|
+
`${year}-${month}-01 00:00:00`,
|
|
24
|
+
`${year}-${month}-${lastDay.toString().padStart(2, '0')} 23:59:59`,
|
|
25
|
+
]
|
|
26
|
+
}
|
|
27
|
+
if (type === 'curDay') {
|
|
28
|
+
return [
|
|
29
|
+
`${year}-${month}-${day} 00:00:00`,
|
|
30
|
+
`${year}-${month}-${day} 23:59:59`,
|
|
31
|
+
]
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
if (show) {
|
|
35
|
+
if (type === 'curYear') {
|
|
36
|
+
return [
|
|
37
|
+
`${year}-01-01`,
|
|
38
|
+
`${year}-12-31`,
|
|
39
|
+
]
|
|
40
|
+
}
|
|
41
|
+
if (type === 'curMonth') {
|
|
42
|
+
const lastDay = new Date(year, now.getMonth() + 1, 0).getDate()
|
|
43
|
+
return [
|
|
44
|
+
`${year}-${month}-01`,
|
|
45
|
+
`${year}-${month}-${lastDay.toString().padStart(2, '0')}`,
|
|
46
|
+
]
|
|
47
|
+
}
|
|
48
|
+
if (type === 'curDay') {
|
|
49
|
+
return [
|
|
50
|
+
`${year}-${month}-${day}`,
|
|
51
|
+
`${year}-${month}-${day}`,
|
|
52
|
+
]
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
// 兜底返回空字符串数组
|
|
56
|
+
return ['', '']
|
|
57
|
+
}
|
|
@@ -1,19 +1,26 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import XCellList from '@af-mobile-client-vue3/components/data/XCellList/index.vue'
|
|
3
3
|
import NormalDataLayout from '@af-mobile-client-vue3/components/layout/NormalDataLayout/index.vue'
|
|
4
|
+
import { useUserStore } from '@af-mobile-client-vue3/stores/modules/user'
|
|
4
5
|
import { defineEmits, ref } from 'vue'
|
|
5
6
|
import { useRouter } from 'vue-router'
|
|
6
7
|
|
|
7
8
|
// 定义事件
|
|
8
9
|
const emit = defineEmits(['deleteRow'])
|
|
10
|
+
const userInfo = useUserStore().getUserInfo()
|
|
9
11
|
// 访问路由
|
|
10
12
|
const router = useRouter()
|
|
11
13
|
// 获取默认值
|
|
12
14
|
const idKey = ref('o_id')
|
|
13
15
|
|
|
14
16
|
// 简易crud表单测试
|
|
15
|
-
const configName = ref('
|
|
17
|
+
// const configName = ref('orderCarInMobileCRUD')
|
|
18
|
+
// const serviceName = ref('af-gaslink')
|
|
19
|
+
// const configName = ref('lngPriceManageMobileCRUD')
|
|
20
|
+
const configName = ref('测试2')
|
|
16
21
|
const serviceName = ref('af-gaslink')
|
|
22
|
+
// const configName = ref('mobile_liushuiQueryCRUD')
|
|
23
|
+
// const serviceName = ref('af-revenue')
|
|
17
24
|
|
|
18
25
|
// 资源权限测试
|
|
19
26
|
// const configName = ref('crud_sources_test')
|
|
@@ -49,11 +56,11 @@ const serviceName = ref('af-gaslink')
|
|
|
49
56
|
function toDetail(item) {
|
|
50
57
|
router.push({
|
|
51
58
|
name: 'XFormGroupView',
|
|
52
|
-
query: {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
},
|
|
59
|
+
// query: {
|
|
60
|
+
// id: item[idKey.value],
|
|
61
|
+
// id: item.rr_id,
|
|
62
|
+
// o_id: item.o_id,
|
|
63
|
+
// },
|
|
57
64
|
})
|
|
58
65
|
}
|
|
59
66
|
|
|
@@ -69,19 +76,35 @@ function toDetail(item) {
|
|
|
69
76
|
// },
|
|
70
77
|
// })
|
|
71
78
|
// }
|
|
79
|
+
function addOption() {
|
|
80
|
+
router.push({
|
|
81
|
+
name: 'XFormGroupView',
|
|
82
|
+
// params: { id: totalCount.value },
|
|
83
|
+
// query: {
|
|
84
|
+
// configName: configName.value,
|
|
85
|
+
// serviceName: serviceName.value,
|
|
86
|
+
// mode: '新增',
|
|
87
|
+
// },
|
|
88
|
+
})
|
|
89
|
+
// 如果存在回调函数,调用它并传递true表示已处理
|
|
90
|
+
// if (typeof callback === 'function') {
|
|
91
|
+
// callback(true)
|
|
92
|
+
// }
|
|
93
|
+
}
|
|
72
94
|
|
|
73
95
|
// 修改功能
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
//
|
|
79
|
-
//
|
|
80
|
-
//
|
|
81
|
-
//
|
|
82
|
-
//
|
|
83
|
-
//
|
|
84
|
-
|
|
96
|
+
function updateRow(result) {
|
|
97
|
+
console.log('用户----', userInfo)
|
|
98
|
+
router.push({
|
|
99
|
+
name: 'XFormGroupView',
|
|
100
|
+
// params: { id: result.o_id, openid: result.o_id },
|
|
101
|
+
// query: {
|
|
102
|
+
// configName: configName.value,
|
|
103
|
+
// serviceName: serviceName.value,
|
|
104
|
+
// mode: '修改',
|
|
105
|
+
// },
|
|
106
|
+
})
|
|
107
|
+
}
|
|
85
108
|
|
|
86
109
|
// 删除功能
|
|
87
110
|
function deleteRow(result) {
|
|
@@ -92,13 +115,31 @@ function deleteRow(result) {
|
|
|
92
115
|
<template>
|
|
93
116
|
<NormalDataLayout id="XCellListView" title="工作计划">
|
|
94
117
|
<template #layout_content>
|
|
118
|
+
<!-- <XCellList -->
|
|
119
|
+
<!-- :config-name="configName" -->
|
|
120
|
+
<!-- :service-name="serviceName" -->
|
|
121
|
+
<!-- :custom-add="true" -->
|
|
122
|
+
<!-- :custom-edit="true" -->
|
|
123
|
+
<!-- :id-key="idKey" -->
|
|
124
|
+
<!-- @to-detail="toDetail" -->
|
|
125
|
+
<!-- @delete-row="deleteRow" -->
|
|
126
|
+
<!-- @update="updateRow" -->
|
|
127
|
+
<!-- @add="addOption" -->
|
|
128
|
+
<!-- /> -->
|
|
129
|
+
|
|
130
|
+
<!-- :fix-query-form="{ u_f_price_state: ['生效', '待生效'] }" -->
|
|
131
|
+
|
|
132
|
+
<!-- <XCellList -->
|
|
133
|
+
<!-- config-name="ApplyMobileSuperviseCRUD" -->
|
|
134
|
+
<!-- service-name="af-apply" -->
|
|
135
|
+
<!-- @to-detail="toDetail" -->
|
|
136
|
+
<!-- @delete-row="deleteRow" -->
|
|
137
|
+
<!-- /> -->
|
|
138
|
+
|
|
95
139
|
<XCellList
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
:fix-query-form="{ o_f_oper_name: 'edu_test' }"
|
|
99
|
-
:id-key="idKey"
|
|
140
|
+
service-name="af-revenue"
|
|
141
|
+
config-name="userfiles_sel_address"
|
|
100
142
|
@to-detail="toDetail"
|
|
101
|
-
@delete-row="deleteRow"
|
|
102
143
|
/>
|
|
103
144
|
</template>
|
|
104
145
|
</NormalDataLayout>
|
|
@@ -5,16 +5,19 @@ import { showDialog } from 'vant'
|
|
|
5
5
|
import { ref } from 'vue'
|
|
6
6
|
import { useRoute } from 'vue-router'
|
|
7
7
|
|
|
8
|
+
// const configName = ref('reviewFormGroup')
|
|
9
|
+
// const serviceName = ref('af-revenue')
|
|
10
|
+
|
|
8
11
|
// 纯表单
|
|
9
|
-
const configName = ref('form_check_test')
|
|
10
|
-
const serviceName = ref('af-system')
|
|
12
|
+
// const configName = ref('form_check_test')
|
|
13
|
+
// const serviceName = ref('af-system')
|
|
11
14
|
|
|
12
15
|
// const configName = ref("计划下发Form")
|
|
13
16
|
// const serviceName = ref("af-linepatrol")
|
|
14
17
|
|
|
15
18
|
// 表单组
|
|
16
|
-
|
|
17
|
-
|
|
19
|
+
const configName = ref('lngChargeAuditMobileFormGroup')
|
|
20
|
+
const serviceName = ref('af-gaslink')
|
|
18
21
|
|
|
19
22
|
const formData = ref({})
|
|
20
23
|
const formGroup = ref(null)
|
|
@@ -22,7 +25,8 @@ const route = useRoute()
|
|
|
22
25
|
const isInit = ref(false)
|
|
23
26
|
function submit(_result) {
|
|
24
27
|
showDialog({ message: '提交成功' }).then(() => {
|
|
25
|
-
|
|
28
|
+
console.log('12121')
|
|
29
|
+
// history.back()
|
|
26
30
|
})
|
|
27
31
|
}
|
|
28
32
|
|
|
@@ -63,8 +67,8 @@ function submit(_result) {
|
|
|
63
67
|
<!-- v-if="isInit" -->
|
|
64
68
|
<XFormGroup
|
|
65
69
|
ref="formGroup"
|
|
66
|
-
|
|
67
|
-
|
|
70
|
+
config-name="appapplyuserinfoFormGroup"
|
|
71
|
+
service-name="af-apply"
|
|
68
72
|
:group-form-data="formData"
|
|
69
73
|
mode="新增"
|
|
70
74
|
@submit="submit"
|