af-mobile-client-vue3 1.0.72 → 1.0.73
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/XCellList.md +275 -0
- package/src/components/data/XCellList/index.vue +15 -13
- package/src/components/data/XCellListFilter/index.vue +3 -2
- package/src/components/data/XForm/index.vue +0 -4
- package/src/components/data/XFormItem/index.vue +33 -35
package/package.json
CHANGED
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
# 移动端配置化表单/列表组件文档
|
|
2
|
+
|
|
3
|
+
## 组件概述
|
|
4
|
+
|
|
5
|
+
这是一个基于 Vue 3 + TypeScript + Vant 4 开发的移动端配置化查询列表组件系统,主要包含以下组件:
|
|
6
|
+
|
|
7
|
+
- `XCellList`: 列表容器组件
|
|
8
|
+
- `XCellListFilter`: 列表筛选组件
|
|
9
|
+
- `XFormItem`: 表单项组件
|
|
10
|
+
- `XForm`: 表单容器组件
|
|
11
|
+
- `XFormGroup`: 表单分组组件
|
|
12
|
+
|
|
13
|
+
## 功能特性
|
|
14
|
+
|
|
15
|
+
### 列表功能
|
|
16
|
+
- ✅ 下拉刷新
|
|
17
|
+
- ✅ 上拉加载
|
|
18
|
+
- ✅ 搜索过滤
|
|
19
|
+
- ✅ 多条件筛选
|
|
20
|
+
- ✅ 排序功能
|
|
21
|
+
- ✅ 卡片式布局
|
|
22
|
+
- ✅ 批量操作
|
|
23
|
+
- ✅ 自定义操作按钮
|
|
24
|
+
|
|
25
|
+
### 表单功能
|
|
26
|
+
- ✅ 支持多种表单项类型
|
|
27
|
+
- ✅ 表单分组
|
|
28
|
+
- ✅ 表单验证
|
|
29
|
+
- ✅ 动态显示隐藏
|
|
30
|
+
- ✅ 表单联动
|
|
31
|
+
- ✅ 数据字典
|
|
32
|
+
- ✅ 自定义校验规则
|
|
33
|
+
|
|
34
|
+
## 使用示例
|
|
35
|
+
|
|
36
|
+
### 基础列表
|
|
37
|
+
|
|
38
|
+
```vue
|
|
39
|
+
<template>
|
|
40
|
+
<XCellList
|
|
41
|
+
config-name="listConfig"
|
|
42
|
+
:service-name="serviceName"
|
|
43
|
+
@to-detail="handleDetail"
|
|
44
|
+
/>
|
|
45
|
+
</template>
|
|
46
|
+
|
|
47
|
+
<script setup lang="ts">
|
|
48
|
+
const serviceName = 'userService'
|
|
49
|
+
|
|
50
|
+
const handleDetail = (item) => {
|
|
51
|
+
// 处理详情点击
|
|
52
|
+
}
|
|
53
|
+
</script>
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### 带筛选的表单
|
|
57
|
+
|
|
58
|
+
```vue
|
|
59
|
+
<template>
|
|
60
|
+
<XFormGroup
|
|
61
|
+
:config-name="configName"
|
|
62
|
+
:service-name="serviceName"
|
|
63
|
+
:group-form-data="formData"
|
|
64
|
+
mode="查询"
|
|
65
|
+
@submit="handleSubmit"
|
|
66
|
+
/>
|
|
67
|
+
</template>
|
|
68
|
+
|
|
69
|
+
<script setup lang="ts">
|
|
70
|
+
const configName = 'searchForm'
|
|
71
|
+
const serviceName = 'userService'
|
|
72
|
+
const formData = ref({})
|
|
73
|
+
|
|
74
|
+
const handleSubmit = (data) => {
|
|
75
|
+
console.log('表单提交:', data)
|
|
76
|
+
}
|
|
77
|
+
</script>
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## API 文档
|
|
81
|
+
|
|
82
|
+
### XCellList Props
|
|
83
|
+
|
|
84
|
+
| 参数 | 说明 | 类型 | 默认值 |
|
|
85
|
+
|------|------|------|--------|
|
|
86
|
+
| configName | 配置名称 | string | - |
|
|
87
|
+
| serviceName | 服务名称 | string | - |
|
|
88
|
+
| fixQueryForm | 固定查询参数 | object | null |
|
|
89
|
+
| idKey | 主键字段 | string | 'o_id' |
|
|
90
|
+
|
|
91
|
+
### XCellList Events
|
|
92
|
+
|
|
93
|
+
| 事件名 | 说明 | 回调参数 |
|
|
94
|
+
|------|------|------|
|
|
95
|
+
| toDetail | 点击详情时触发 | item: 当前项数据 |
|
|
96
|
+
| addOption | 点击新增按钮时触发 | - |
|
|
97
|
+
|
|
98
|
+
### XFormGroup Props
|
|
99
|
+
|
|
100
|
+
| 参数 | 说明 | 类型 | 默认值 |
|
|
101
|
+
|------|------|------|--------|
|
|
102
|
+
| configName | 配置名称 | string | '' |
|
|
103
|
+
| serviceName | 服务名称 | string | - |
|
|
104
|
+
| groupFormData | 表单数据 | object | {} |
|
|
105
|
+
| mode | 表单模式 | '查询' \| '新增' \| '修改' | '查询' |
|
|
106
|
+
|
|
107
|
+
### XFormItem Props
|
|
108
|
+
|
|
109
|
+
| 参数 | 说明 | 类型 | 默认值 |
|
|
110
|
+
|------|------|------|--------|
|
|
111
|
+
| attr | 表单项配置 | FormItemAttr | - |
|
|
112
|
+
| form | 表单数据对象 | object | - |
|
|
113
|
+
| mode | 表单模式 | string | '查询' |
|
|
114
|
+
| showLabel | 是否显示标签 | boolean | true |
|
|
115
|
+
|
|
116
|
+
## 配置说明
|
|
117
|
+
|
|
118
|
+
### 列表配置
|
|
119
|
+
|
|
120
|
+
```typescript
|
|
121
|
+
interface ListConfig {
|
|
122
|
+
// 列配置
|
|
123
|
+
columnJson: {
|
|
124
|
+
// 列类型: mobile_header_column | mobile_subtitle_column | mobile_details_column | mobile_footer_column
|
|
125
|
+
mobileColumnType: string
|
|
126
|
+
// 数据字段
|
|
127
|
+
dataIndex: string
|
|
128
|
+
// 标题
|
|
129
|
+
title: string
|
|
130
|
+
// 展示类型
|
|
131
|
+
slotType?: 'badge' | 'action'
|
|
132
|
+
// 操作按钮配置
|
|
133
|
+
actionArr?: Array<{
|
|
134
|
+
text: string
|
|
135
|
+
func: string
|
|
136
|
+
}>
|
|
137
|
+
}[]
|
|
138
|
+
|
|
139
|
+
// 按钮状态
|
|
140
|
+
buttonState: {
|
|
141
|
+
add?: boolean
|
|
142
|
+
edit?: boolean
|
|
143
|
+
delete?: boolean
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// 是否显示排序
|
|
147
|
+
showSortIcon?: boolean
|
|
148
|
+
|
|
149
|
+
// 查询表单配置
|
|
150
|
+
formJson: FormItem[]
|
|
151
|
+
}
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### 表单配置
|
|
155
|
+
|
|
156
|
+
```typescript
|
|
157
|
+
interface FormItem {
|
|
158
|
+
// 表单项类型
|
|
159
|
+
type: 'input' | 'select' | 'date' | 'checkbox' | 'radio' | 'switch' | 'textarea' | 'uploader'
|
|
160
|
+
|
|
161
|
+
// 字段名
|
|
162
|
+
model: string
|
|
163
|
+
|
|
164
|
+
// 标签名
|
|
165
|
+
name: string
|
|
166
|
+
|
|
167
|
+
// 校验规则
|
|
168
|
+
rule?: {
|
|
169
|
+
required: string
|
|
170
|
+
type: 'string' | 'number' | 'integer' | 'float'
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// 占位提示
|
|
174
|
+
placeholder?: string
|
|
175
|
+
|
|
176
|
+
// 数据源配置
|
|
177
|
+
keyName?: string
|
|
178
|
+
|
|
179
|
+
// 是否只读
|
|
180
|
+
readonly?: boolean
|
|
181
|
+
|
|
182
|
+
// 是否禁用
|
|
183
|
+
disabled?: boolean
|
|
184
|
+
}
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
## 高级功能
|
|
188
|
+
|
|
189
|
+
### 表单联动
|
|
190
|
+
|
|
191
|
+
```typescript
|
|
192
|
+
// 配置联动显示函数
|
|
193
|
+
const showFormItemFunc = `function(form, attr, data, mode) {
|
|
194
|
+
return form.type === '1'
|
|
195
|
+
}`
|
|
196
|
+
|
|
197
|
+
// 配置值变化函数
|
|
198
|
+
const dataChangeFunc = `function(form, attr, data, mode) {
|
|
199
|
+
if(form.type === '1') {
|
|
200
|
+
form.name = 'test'
|
|
201
|
+
}
|
|
202
|
+
}`
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
### 自定义样式
|
|
206
|
+
|
|
207
|
+
```typescript
|
|
208
|
+
// 配置样式函数
|
|
209
|
+
const styleFunctionForValue = `function(value) {
|
|
210
|
+
return {
|
|
211
|
+
color: value > 100 ? 'red' : 'green'
|
|
212
|
+
}
|
|
213
|
+
}`
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
## 注意事项
|
|
217
|
+
|
|
218
|
+
1. 配置名称必须与后端配置一致
|
|
219
|
+
2. 表单验证规则需要按照规范配置
|
|
220
|
+
3. 自定义函数需要使用字符串形式
|
|
221
|
+
4. 数据源配置支持多种方式:
|
|
222
|
+
- logic@: 逻辑处理
|
|
223
|
+
- config@: 配置数据
|
|
224
|
+
- search@: 搜索数据
|
|
225
|
+
|
|
226
|
+
## 最佳实践
|
|
227
|
+
|
|
228
|
+
1. 合理使用表单分组
|
|
229
|
+
2. 适当配置表单联动
|
|
230
|
+
3. 统一管理配置文件
|
|
231
|
+
4. 做好错误处理
|
|
232
|
+
5. 优化列表性能
|
|
233
|
+
|
|
234
|
+
## 常见问题
|
|
235
|
+
|
|
236
|
+
1. Q: 如何配置自定义校验规则?
|
|
237
|
+
A: 在 rule 中配置 validator 函数
|
|
238
|
+
|
|
239
|
+
2. Q: 如何实现表单联动?
|
|
240
|
+
A: 使用 showFormItemFunc 和 dataChangeFunc 配置联动逻辑
|
|
241
|
+
|
|
242
|
+
3. Q: 如何自定义列表样式?
|
|
243
|
+
A: 使用 styleFunctionForValue 配置样式函数
|
|
244
|
+
|
|
245
|
+
## 更新日志
|
|
246
|
+
|
|
247
|
+
### v1.0.0
|
|
248
|
+
- 初始版本发布
|
|
249
|
+
- 支持基础列表功能
|
|
250
|
+
- 支持表单配置
|
|
251
|
+
|
|
252
|
+
### v1.1.0
|
|
253
|
+
- 添加表单联动
|
|
254
|
+
- 优化列表性能
|
|
255
|
+
- 修复已知问题
|
|
256
|
+
|
|
257
|
+
## 后续规划
|
|
258
|
+
|
|
259
|
+
1. [ ] 支持更多表单类型
|
|
260
|
+
2. [ ] 添加表单预览功能
|
|
261
|
+
3. [ ] 优化列表性能
|
|
262
|
+
4. [ ] 完善错误处理
|
|
263
|
+
5. [ ] 添加单元测试
|
|
264
|
+
|
|
265
|
+
## 贡献指南
|
|
266
|
+
|
|
267
|
+
欢迎提交 Issue 和 PR,请遵循以下规范:
|
|
268
|
+
|
|
269
|
+
1. 遵循代码规范
|
|
270
|
+
2. 添加必要的测试
|
|
271
|
+
3. 更新相关文档
|
|
272
|
+
|
|
273
|
+
## 许可证
|
|
274
|
+
|
|
275
|
+
MIT License
|
|
@@ -16,9 +16,9 @@ import XBadge from '@af-mobile-client-vue3/components/data/XBadge/index.vue'
|
|
|
16
16
|
import { getConfigByName, query } from '@af-mobile-client-vue3/services/api/common'
|
|
17
17
|
import LoadError from '@af-mobile-client-vue3/views/common/LoadError.vue'
|
|
18
18
|
import XCellListFilter from '@af-mobile-client-vue3/components/data/XCellListFilter/index.vue'
|
|
19
|
-
import { useRouter } from
|
|
19
|
+
import { useRouter } from 'vue-router'
|
|
20
20
|
|
|
21
|
-
const { configName, serviceName } = withDefaults(defineProps<{
|
|
21
|
+
const { configName, serviceName, fixQueryForm } = withDefaults(defineProps<{
|
|
22
22
|
configName?: string
|
|
23
23
|
fixQueryForm?: object
|
|
24
24
|
idKey?: string
|
|
@@ -30,10 +30,10 @@ const { configName, serviceName } = withDefaults(defineProps<{
|
|
|
30
30
|
serviceName: undefined,
|
|
31
31
|
})
|
|
32
32
|
|
|
33
|
-
const router = useRouter()
|
|
34
|
-
|
|
35
33
|
const emit = defineEmits(['toDetail', 'addOption'])
|
|
36
34
|
|
|
35
|
+
const router = useRouter()
|
|
36
|
+
|
|
37
37
|
const orderVal = ref(undefined)
|
|
38
38
|
|
|
39
39
|
const sortordVal = ref(undefined)
|
|
@@ -105,11 +105,10 @@ const buttonState = ref(undefined)
|
|
|
105
105
|
const groupFormItems = ref({})
|
|
106
106
|
const title = ref('')
|
|
107
107
|
|
|
108
|
-
onBeforeMount(() =>{
|
|
108
|
+
onBeforeMount(() => {
|
|
109
109
|
initComponent()
|
|
110
110
|
})
|
|
111
111
|
|
|
112
|
-
|
|
113
112
|
// 组件初始化
|
|
114
113
|
function initComponent() {
|
|
115
114
|
getConfigByName(configName, (result) => {
|
|
@@ -265,19 +264,21 @@ function onSelectMenu(item: any, event: any) {
|
|
|
265
264
|
emit(event.func, item)
|
|
266
265
|
}).catch(() => {
|
|
267
266
|
})
|
|
268
|
-
}
|
|
267
|
+
}
|
|
268
|
+
else if (event.text === '修改') {
|
|
269
269
|
router.push({
|
|
270
270
|
name: 'XForm',
|
|
271
271
|
// params: { id: item },
|
|
272
272
|
query: {
|
|
273
273
|
groupFormItems: JSON.stringify(groupFormItems.value),
|
|
274
|
-
serviceName
|
|
274
|
+
serviceName,
|
|
275
275
|
formData: JSON.stringify(item),
|
|
276
276
|
mode: '修改',
|
|
277
277
|
},
|
|
278
278
|
})
|
|
279
|
-
//emit('addOption', totalCount.value)
|
|
280
|
-
}
|
|
279
|
+
// emit('addOption', totalCount.value)
|
|
280
|
+
}
|
|
281
|
+
else {
|
|
281
282
|
emit(event.func, item)
|
|
282
283
|
}
|
|
283
284
|
}
|
|
@@ -289,12 +290,12 @@ function addOption() {
|
|
|
289
290
|
// params: { id: totalCount.value },
|
|
290
291
|
query: {
|
|
291
292
|
groupFormItems: JSON.stringify(groupFormItems.value),
|
|
292
|
-
serviceName
|
|
293
|
+
serviceName,
|
|
293
294
|
formData: JSON.stringify({}),
|
|
294
295
|
mode: '新增',
|
|
295
296
|
},
|
|
296
297
|
})
|
|
297
|
-
//emit('addOption', totalCount.value)
|
|
298
|
+
// emit('addOption', totalCount.value)
|
|
298
299
|
}
|
|
299
300
|
</script>
|
|
300
301
|
|
|
@@ -309,11 +310,12 @@ function addOption() {
|
|
|
309
310
|
@search="onRefresh"
|
|
310
311
|
/>
|
|
311
312
|
</VanCol>
|
|
312
|
-
<VanCol span="2" class
|
|
313
|
+
<VanCol span="2" class="search-icon">
|
|
313
314
|
<XCellListFilter
|
|
314
315
|
v-model:sortord-val="sortordVal"
|
|
315
316
|
v-model:order-val="orderVal"
|
|
316
317
|
v-model:condition-params="conditionParams"
|
|
318
|
+
:fix-query-form="fixQueryForm"
|
|
317
319
|
:order-list="orderList"
|
|
318
320
|
:form-query="formQueryList"
|
|
319
321
|
:button-state="buttonState"
|
|
@@ -13,6 +13,7 @@ import XGridDropOption from '@af-mobile-client-vue3/components/core/XGridDropOpt
|
|
|
13
13
|
import XFormItem from '@af-mobile-client-vue3/components/data/XFormItem/index.vue'
|
|
14
14
|
|
|
15
15
|
const props = defineProps<{
|
|
16
|
+
fixQueryForm?: object
|
|
16
17
|
orderVal?: string
|
|
17
18
|
sortordVal?: string
|
|
18
19
|
orderList?: any[]
|
|
@@ -44,7 +45,7 @@ const colFieldNames = {
|
|
|
44
45
|
}
|
|
45
46
|
|
|
46
47
|
// 查询条件参数 !!!!!建议最后点击确认的时候完成这个的整理
|
|
47
|
-
const conditionParams = ref({})
|
|
48
|
+
const conditionParams = ref({fixQueryForm: props.fixQueryForm})
|
|
48
49
|
|
|
49
50
|
// 重置某个选项
|
|
50
51
|
function resetOptionItem(type) {
|
|
@@ -56,7 +57,7 @@ function resetOption() {
|
|
|
56
57
|
currentOrderVal.value = undefined
|
|
57
58
|
currentSortordVal.value = undefined
|
|
58
59
|
// 条件参数
|
|
59
|
-
conditionParams.value = {}
|
|
60
|
+
conditionParams.value = {fixQueryForm: props.fixQueryForm}
|
|
60
61
|
}
|
|
61
62
|
function checkOrderOption() {
|
|
62
63
|
let isCheck = true
|
|
@@ -4,11 +4,9 @@ import {
|
|
|
4
4
|
CellGroup as VanCellGroup,
|
|
5
5
|
Form as VanForm,
|
|
6
6
|
} from 'vant'
|
|
7
|
-
import { useRoute } from 'vue-router'
|
|
8
7
|
import type { FormInstance } from 'vant'
|
|
9
8
|
import { computed, defineEmits, defineProps, onBeforeMount, reactive, ref, watch } from 'vue'
|
|
10
9
|
import XFormItem from '@af-mobile-client-vue3/components/data/XFormItem/index.vue'
|
|
11
|
-
import NormalDataLayout from "@af-mobile-client-vue3/components/layout/NormalDataLayout/index.vue";
|
|
12
10
|
|
|
13
11
|
interface FormItem {
|
|
14
12
|
addOrEdit: string
|
|
@@ -36,7 +34,6 @@ const props = withDefaults(defineProps<{
|
|
|
36
34
|
mode: '查询',
|
|
37
35
|
submitButton: true,
|
|
38
36
|
})
|
|
39
|
-
const route = useRoute()
|
|
40
37
|
const emits = defineEmits(['onSubmit'])
|
|
41
38
|
const formRef = ref<FormInstance>()
|
|
42
39
|
const myFormItems = ref<FormItem[]>([])
|
|
@@ -149,7 +146,6 @@ defineExpose({ init, form, formGroupName, validate })
|
|
|
149
146
|
<slot />
|
|
150
147
|
</div>
|
|
151
148
|
</VanForm>
|
|
152
|
-
|
|
153
149
|
</template>
|
|
154
150
|
|
|
155
151
|
<style scoped>
|
|
@@ -26,7 +26,7 @@ import XGridDropOption from '@af-mobile-client-vue3/components/core/XGridDropOpt
|
|
|
26
26
|
import type { Numeric } from 'vant/es/utils'
|
|
27
27
|
import { getDict } from '@af-mobile-client-vue3/utils/dictUtil'
|
|
28
28
|
import { executeStrFunctionByContext } from '@af-mobile-client-vue3/utils/runEvalFunction'
|
|
29
|
-
import {
|
|
29
|
+
import { useUserStore } from '@af-mobile-client-vue3/stores/modules/user'
|
|
30
30
|
import { debounce } from 'lodash-es'
|
|
31
31
|
import { searchToListOption, searchToOption } from '@af-mobile-client-vue3/services/v3Api'
|
|
32
32
|
|
|
@@ -84,11 +84,11 @@ const props = defineProps({
|
|
|
84
84
|
|
|
85
85
|
})
|
|
86
86
|
|
|
87
|
+
const emits = defineEmits(['update:modelValue'])
|
|
87
88
|
// 判断并初始化防抖函数
|
|
88
|
-
let debouncedUserLinkFunc: Function | null = null
|
|
89
|
-
let debouncedDepLinkFunc: Function | null = null
|
|
89
|
+
let debouncedUserLinkFunc: Function | null = null
|
|
90
|
+
let debouncedDepLinkFunc: Function | null = null
|
|
90
91
|
|
|
91
|
-
const emits = defineEmits(['update:modelValue'])
|
|
92
92
|
const { attr, form, mode, serviceName, getDataParams, columnsField } = props
|
|
93
93
|
const calendarShow = ref(false)
|
|
94
94
|
const option = ref([])
|
|
@@ -176,12 +176,11 @@ onBeforeMount(() => {
|
|
|
176
176
|
init()
|
|
177
177
|
showFormItemFunc()
|
|
178
178
|
dataChangeFunc()
|
|
179
|
-
if (attr?.keyName?.toString()?.startsWith('search@根据表单项[') && attr?.keyName?.toString().endsWith(']联动人员'))
|
|
179
|
+
if (attr?.keyName?.toString()?.startsWith('search@根据表单项[') && attr?.keyName?.toString().endsWith(']联动人员'))
|
|
180
180
|
debouncedUserLinkFunc = debounce(() => updateResOptions('人员'), 200)
|
|
181
|
-
|
|
182
|
-
if (attr?.keyName?.toString()?.startsWith('search@根据表单项[') && attr?.keyName?.toString().endsWith(']联动部门'))
|
|
181
|
+
|
|
182
|
+
if (attr?.keyName?.toString()?.startsWith('search@根据表单项[') && attr?.keyName?.toString().endsWith(']联动部门'))
|
|
183
183
|
debouncedDepLinkFunc = debounce(() => updateResOptions('部门'), 200)
|
|
184
|
-
}
|
|
185
184
|
})
|
|
186
185
|
// 是否展示表单左侧label文字
|
|
187
186
|
const labelData = computed(() => {
|
|
@@ -222,52 +221,52 @@ function init() {
|
|
|
222
221
|
if (result)
|
|
223
222
|
option.value = result
|
|
224
223
|
}, serviceName)
|
|
225
|
-
}
|
|
224
|
+
}
|
|
225
|
+
else if (attr.keyName && attr.keyName.includes('search@')) {
|
|
226
226
|
let source = attr.keyName.substring(7)
|
|
227
227
|
const userid = currUser.value
|
|
228
228
|
let roleName = 'roleName'
|
|
229
229
|
if (source.startsWith('根据角色[') && source.endsWith(']获取人员')) {
|
|
230
230
|
const startIndex = source.indexOf('[') + 1
|
|
231
|
-
const endIndex = source.indexOf(']',startIndex)
|
|
231
|
+
const endIndex = source.indexOf(']', startIndex)
|
|
232
232
|
roleName = source.substring(startIndex, endIndex)
|
|
233
233
|
source = '根据角色获取人员'
|
|
234
234
|
}
|
|
235
235
|
const searchData = { source, userid, roleName }
|
|
236
|
-
if (source.startsWith('根据表单项[')
|
|
236
|
+
if (source.startsWith('根据表单项[') && source.endsWith(']联动人员'))
|
|
237
237
|
updateResOptions('人员')
|
|
238
|
-
|
|
238
|
+
else if (source.startsWith('根据表单项[') && source.endsWith(']联动部门'))
|
|
239
239
|
updateResOptions('部门')
|
|
240
|
-
|
|
241
|
-
searchToListOption(searchData,res => getDataCallback(res))
|
|
242
|
-
|
|
243
|
-
searchToOption(searchData,res => getDataCallback(res))
|
|
244
|
-
|
|
245
|
-
|
|
240
|
+
else if (attr.type === 'select' || attr.type === 'checkbox')
|
|
241
|
+
searchToListOption(searchData, res => getDataCallback(res))
|
|
242
|
+
else
|
|
243
|
+
searchToOption(searchData, res => getDataCallback(res))
|
|
244
|
+
}
|
|
245
|
+
else {
|
|
246
246
|
initRadioValue()
|
|
247
247
|
}
|
|
248
248
|
}
|
|
249
249
|
}
|
|
250
250
|
|
|
251
|
-
function getDataCallback
|
|
251
|
+
function getDataCallback(res) {
|
|
252
252
|
option.value = res
|
|
253
|
-
if (attr.type === 'radio')
|
|
253
|
+
if (attr.type === 'radio')
|
|
254
254
|
initRadioValue()
|
|
255
|
-
}
|
|
256
255
|
}
|
|
257
256
|
|
|
258
|
-
async function updateResOptions
|
|
259
|
-
if (attr?.keyName?.toString()?.startsWith('search@根据表单项[') && attr?.keyName?.toString()?.endsWith(`]联动${type}`)){
|
|
260
|
-
const searchData = {source: `获取${type}`, userid: currUser.value}
|
|
257
|
+
async function updateResOptions(type) {
|
|
258
|
+
if (attr?.keyName?.toString()?.startsWith('search@根据表单项[') && attr?.keyName?.toString()?.endsWith(`]联动${type}`)) {
|
|
259
|
+
const searchData = { source: `获取${type}`, userid: currUser.value }
|
|
261
260
|
const startIndex = attr.keyName.indexOf('[') + 1
|
|
262
|
-
const endIndex = attr.keyName.indexOf(']',startIndex)
|
|
263
|
-
const formModel = attr.keyName.substring(startIndex, endIndex).replace('.','_')
|
|
261
|
+
const endIndex = attr.keyName.indexOf(']', startIndex)
|
|
262
|
+
const formModel = attr.keyName.substring(startIndex, endIndex).replace('.', '_')
|
|
264
263
|
// console.log(form)
|
|
265
264
|
const formModelData = form[formModel]
|
|
266
|
-
if (formModel?.length && formModelData?.length){
|
|
267
|
-
await searchToListOption(searchData,res => {
|
|
265
|
+
if (formModel?.length && formModelData?.length) {
|
|
266
|
+
await searchToListOption(searchData, (res) => {
|
|
268
267
|
// console.log(res)
|
|
269
268
|
// console.log(form)
|
|
270
|
-
getDataCallback(res.filter(h => {
|
|
269
|
+
getDataCallback(res.filter((h) => {
|
|
271
270
|
return formModelData['0'] === h.f_organization_id || formModelData['0'] === h.f_department_id || formModelData['0'] === h.parentid
|
|
272
271
|
// if (formModel.indexOf('org') > -1) {
|
|
273
272
|
// return formModelData?.includes(h.orgid || h.f_organization_id || h.parentid)
|
|
@@ -343,17 +342,16 @@ function updateFile(files, _index) {
|
|
|
343
342
|
emits('update:modelValue', localValue.value)
|
|
344
343
|
}
|
|
345
344
|
// 监听表单发生变化后触发展示函数
|
|
346
|
-
watch(
|
|
345
|
+
watch(() => form, (_oldVal, _newVal) => {
|
|
347
346
|
showFormItemFunc()
|
|
348
347
|
// 数据源来自人员联动时更新数据
|
|
349
|
-
if (attr?.keyName?.toString()?.startsWith('search@根据表单项[') && attr?.keyName?.toString().endsWith(']联动人员'))
|
|
348
|
+
if (attr?.keyName?.toString()?.startsWith('search@根据表单项[') && attr?.keyName?.toString().endsWith(']联动人员'))
|
|
350
349
|
debouncedUserLinkFunc()
|
|
351
|
-
|
|
350
|
+
|
|
352
351
|
// 数据源来自部门联动时更新数据
|
|
353
|
-
if (attr?.keyName?.toString()?.startsWith('search@根据表单项[') && attr?.keyName?.toString().endsWith(']联动部门'))
|
|
352
|
+
if (attr?.keyName?.toString()?.startsWith('search@根据表单项[') && attr?.keyName?.toString().endsWith(']联动部门'))
|
|
354
353
|
debouncedDepLinkFunc()
|
|
355
|
-
|
|
356
|
-
}, {deep: true})
|
|
354
|
+
}, { deep: true })
|
|
357
355
|
</script>
|
|
358
356
|
|
|
359
357
|
<template>
|