af-mobile-client-vue3 1.0.85 → 1.0.87

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,7 +1,7 @@
1
1
  {
2
2
  "name": "af-mobile-client-vue3",
3
3
  "type": "module",
4
- "version": "1.0.85",
4
+ "version": "1.0.87",
5
5
  "description": "Vue + Vite component lib",
6
6
  "license": "MIT",
7
7
  "engines": {
@@ -1,5 +1,6 @@
1
1
  <script setup lang="ts">
2
2
  import {
3
+ Button as vanButton,
3
4
  Uploader as vanUploader,
4
5
  } from 'vant'
5
6
  import { onMounted, ref } from 'vue'
@@ -97,7 +98,11 @@ onMounted(() => {
97
98
  :after-read="fileUpload"
98
99
  :show-upload="false"
99
100
  :deletable="false"
100
- />
101
+ >
102
+ <vanButton icon="photograph" type="primary">
103
+ 上传
104
+ </vanButton>
105
+ </van-uploader>
101
106
  <van-uploader
102
107
  v-else-if="props.authority === 'admin'"
103
108
  v-model="imageList"
@@ -105,7 +110,11 @@ onMounted(() => {
105
110
  :preview-image="true"
106
111
  :after-read="fileUpload"
107
112
  :before-delete="deleteFileFunction"
108
- />
113
+ >
114
+ <vanButton icon="photograph" type="primary">
115
+ 上传
116
+ </vanButton>
117
+ </van-uploader>
109
118
  </template>
110
119
 
111
120
  <style scoped lang="less">
@@ -1,275 +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
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
@@ -101,10 +101,17 @@ const showDatePicker = ref(false)
101
101
  const showTimePicker = ref(false)
102
102
  const showArea = ref(false)
103
103
  const errorMessage = ref('')
104
+
105
+ // 表单默认值
106
+ // 输入-非查询
104
107
  const formInputDefaultValue = ref('')
108
+ // 输入-查询
105
109
  const queryInputDefaultValue = ref('')
110
+ // 选择-非查询
106
111
  const formSelectDefaultValue = ref([])
112
+ // 选择-查询
107
113
  const querySelectDefaultValue = ref([])
114
+
108
115
  // eslint-disable-next-line ts/no-use-before-define
109
116
  const currUser = computed(() => userState.f.resources.id)
110
117
  // 是否展示当前项
@@ -140,10 +147,17 @@ const localValue = computed({
140
147
  // return props.modelValue
141
148
  // }
142
149
  switch (attr.type) {
150
+ case 'uploader':
151
+ if (mode === '查询') {
152
+ // console.log(querySelectDefaultValue.value)
153
+ return props.modelValue !== undefined ? props.modelValue : querySelectDefaultValue.value
154
+ }
155
+ else {
156
+ return props.modelValue !== undefined ? props.modelValue : formSelectDefaultValue.value
157
+ }
143
158
  case 'switch':
144
159
  return props.modelValue !== undefined ? props.modelValue : false
145
160
  case 'checkbox':
146
- case 'uploader':
147
161
  case 'file':
148
162
  case 'image':
149
163
  case 'datePicker':
@@ -392,7 +406,7 @@ function init() {
392
406
 
393
407
  if (attr.type === 'checkbox' || attr.type === 'uploader' || attr.type === 'file' || attr.type === 'image' || attr.type === 'datePicker' || attr.type === 'timePicker' || attr.type === 'select') {
394
408
  if (attr.formDefault) {
395
- if (attr.type === 'checkbox')
409
+ if (attr.type === 'checkbox' || attr.type === 'image' || attr.type === 'file')
396
410
  formSelectDefaultValue.value = attr.formDefault
397
411
  else
398
412
  formSelectDefaultValue.value.push(attr.formDefault)