af-mobile-client-vue3 1.1.22 → 1.1.23

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.1.22",
4
+ "version": "1.1.23",
5
5
  "description": "Vue + Vite component lib",
6
6
  "license": "MIT",
7
7
  "engines": {
@@ -2,6 +2,7 @@
2
2
  import XBadge from '@af-mobile-client-vue3/components/data/XBadge/index.vue'
3
3
  import XCellListFilter from '@af-mobile-client-vue3/components/data/XCellListFilter/index.vue'
4
4
  import { getConfigByName, query } from '@af-mobile-client-vue3/services/api/common'
5
+ import { getRangeByType } from '@af-mobile-client-vue3/utils/queryFormDefaultRangePicker'
5
6
  import LoadError from '@af-mobile-client-vue3/views/common/LoadError.vue'
6
7
  import {
7
8
  showConfirmDialog,
@@ -108,8 +109,12 @@ const finishedText = ref('加载完成')
108
109
  // 避免查询多次
109
110
  const isLastPage = ref(false)
110
111
 
112
+ // 条件参数(查询框)
111
113
  const conditionParams = ref(undefined)
112
114
 
115
+ // 查询参数(配置自带的默认值)
116
+ const queryDefaultParams = ref({})
117
+
113
118
  // 主要按钮的状态
114
119
  const buttonState = ref(undefined)
115
120
 
@@ -178,9 +183,47 @@ function initComponent() {
178
183
  allActions.value.push({ text: '删除', func: 'deleteRow' })
179
184
  }
180
185
  splitArrayAt(allActions.value, 3)
186
+
187
+ // 初始化条件参数(从表单默认值中获取)
188
+ initConditionParams(result.formJson)
181
189
  }, serviceName)
182
190
  }
183
191
 
192
+ // 初始化条件参数
193
+ function initConditionParams(formItems) {
194
+ if (!formItems || !Array.isArray(formItems) || formItems.length === 0)
195
+ return
196
+
197
+ const defaultParams = {}
198
+ let hasDefaults = false
199
+
200
+ // 从表单配置中获取所有默认值
201
+ formItems.forEach((item) => {
202
+ if (item.model) {
203
+ // 根据查询模式获取对应的默认值
204
+ if (item.queryFormDefault !== undefined && item.queryFormDefault !== null) {
205
+ if (item.type === 'rangePicker' && item.queryType === 'BETWEEN') {
206
+ defaultParams[item.model] = getRangeByType(item.queryFormDefault, false)
207
+ }
208
+ else {
209
+ defaultParams[item.model] = item.queryFormDefault
210
+ }
211
+ hasDefaults = true
212
+ }
213
+ }
214
+ })
215
+
216
+ // 如果有默认值,则设置到条件参数中并立即执行查询
217
+ if (hasDefaults) {
218
+ queryDefaultParams.value = defaultParams
219
+
220
+ // 延迟执行第一次查询,确保组件完全加载
221
+ setTimeout(() => {
222
+ onRefresh()
223
+ }, 100)
224
+ }
225
+ }
226
+
184
227
  // 刷新数据
185
228
  function onRefresh() {
186
229
  isError.value = false
@@ -197,6 +240,8 @@ function onRefresh() {
197
240
 
198
241
  // 加载数据
199
242
  function onLoad() {
243
+ if (!refreshing.value)
244
+ return
200
245
  if (refreshing.value) {
201
246
  list.value = []
202
247
  pageNo.value = 1
@@ -206,6 +251,23 @@ function onLoad() {
206
251
  let searchVal = searchValue.value
207
252
  if (searchVal === '')
208
253
  searchVal = undefined
254
+
255
+ // 确保conditionParams不是undefined
256
+ if (conditionParams.value === undefined)
257
+ conditionParams.value = {}
258
+ const mergedParams = mergeParams(queryDefaultParams.value, conditionParams.value)
259
+
260
+ // 输出查询条件,便于调试
261
+ console.log('查询条件:', {
262
+ pageNo: pageNo.value,
263
+ pageSize,
264
+ conditionParams: {
265
+ $queryValue: searchVal,
266
+ ...fixQueryForm,
267
+ ...mergedParams,
268
+ },
269
+ })
270
+
209
271
  query({
210
272
  queryParamsName: configName,
211
273
  pageNo: pageNo.value,
@@ -213,7 +275,7 @@ function onLoad() {
213
275
  conditionParams: {
214
276
  $queryValue: searchVal,
215
277
  ...fixQueryForm,
216
- ...conditionParams.value,
278
+ ...mergedParams,
217
279
  },
218
280
  sortField: orderVal?.value,
219
281
  sortOrder: sortordVal?.value,
@@ -240,6 +302,18 @@ function onLoad() {
240
302
  }
241
303
  }
242
304
 
305
+ // 合并参数
306
+ function mergeParams(defaultParams: object, overrideParams: object) {
307
+ const result = { ...defaultParams }
308
+ for (const [key, value] of Object.entries(overrideParams)) {
309
+ // 只有当overrideParams中的值不是undefined或空字符串时才覆盖
310
+ if (value !== undefined) {
311
+ result[key] = value
312
+ }
313
+ }
314
+ return result
315
+ }
316
+
243
317
  // 区分主要操作列与其他操作列
244
318
  function splitArrayAt<T>(array: T[], index: number) {
245
319
  mainActions.value = array.slice(0, index)
@@ -11,6 +11,7 @@ import { runLogic } from '@af-mobile-client-vue3/services/api/common'
11
11
  import { searchToListOption, searchToOption } from '@af-mobile-client-vue3/services/v3Api'
12
12
  import { useUserStore } from '@af-mobile-client-vue3/stores/modules/user'
13
13
  import { getDict } from '@af-mobile-client-vue3/utils/dictUtil'
14
+ import { getRangeByType } from '@af-mobile-client-vue3/utils/queryFormDefaultRangePicker'
14
15
  import { executeStrFunctionByContext } from '@af-mobile-client-vue3/utils/runEvalFunction'
15
16
  import { areaList } from '@vant/area-data'
16
17
  import { debounce } from 'lodash-es'
@@ -187,7 +188,7 @@ function getDefaultValue() {
187
188
  if (props.modelValue && Array.isArray(props.modelValue) && props.modelValue.length > 1)
188
189
  return `${props.modelValue[0]} ~ ${props.modelValue[1]}`
189
190
  else
190
- return props.modelValue
191
+ return props.modelValue !== undefined ? props.modelValue : querySelectDefaultValue.value
191
192
  case 'addressSearch':
192
193
  return props.modelValue
193
194
  default:
@@ -205,9 +206,14 @@ watch(() => props.modelValue, (newVal) => {
205
206
  localValue.value = Array.isArray(newVal) ? newVal : []
206
207
  }
207
208
  else {
208
- localValue.value = newVal !== undefined ? newVal : getDefaultValue()
209
209
  if (attr.type === 'rangePicker') {
210
- pickerValue.value = newVal !== undefined ? `${newVal[0]} ~ ${newVal[1]}` : ''
210
+ console.log('newVal', newVal)
211
+ pickerValue.value = newVal !== undefined ? `${newVal[0]} ~ ${newVal[1]}` : getDefaultValue()
212
+ console.log('11111111111', getDefaultValue())
213
+ }
214
+ else {
215
+ console.log('newVal', newVal)
216
+ localValue.value = newVal !== undefined ? newVal : getDefaultValue()
211
217
  }
212
218
  }
213
219
  })
@@ -459,6 +465,16 @@ function init() {
459
465
  // querySelectDefaultValue.value = attr.queryFormDefault
460
466
  }
461
467
  }
468
+
469
+ if (attr.type === 'rangePicker') {
470
+ if (attr.formDefault)
471
+ formSelectDefaultValue.value = attr.formDefault
472
+ if (attr.queryFormDefault) {
473
+ const dateArray = getRangeByType(attr.queryFormDefault, true)
474
+ pickerValue.value = `${dateArray[0]} ~ ${dateArray[1]}`
475
+ querySelectDefaultValue.value = pickerValue.value
476
+ }
477
+ }
462
478
  }
463
479
 
464
480
  function getDataCallback(res) {
@@ -0,0 +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,19 +1,24 @@
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('crud_oper_log_manage')
16
- const serviceName = ref('af-system')
17
+ // const configName = ref('orderCarInMobileCRUD')
18
+ // const serviceName = ref('af-gaslink')
19
+ // const configName = ref('lngPriceManageMobileCRUD')
20
+ const configName = ref('测试')
21
+ const serviceName = ref('af-gaslink')
17
22
 
18
23
  // 资源权限测试
19
24
  // const configName = ref('crud_sources_test')
@@ -49,11 +54,11 @@ const serviceName = ref('af-system')
49
54
  function toDetail(item) {
50
55
  router.push({
51
56
  name: 'XFormGroupView',
52
- query: {
53
- id: item[idKey.value],
54
- // id: item.rr_id,
55
- // o_id: item.o_id,
56
- },
57
+ // query: {
58
+ // id: item[idKey.value],
59
+ // id: item.rr_id,
60
+ // o_id: item.o_id,
61
+ // },
57
62
  })
58
63
  }
59
64
 
@@ -69,19 +74,40 @@ function toDetail(item) {
69
74
  // },
70
75
  // })
71
76
  // }
77
+ function addOption(callback) {
78
+ router.push({
79
+ name: 'XFormGroupView',
80
+ // params: { id: totalCount.value },
81
+ // query: {
82
+ // configName: configName.value,
83
+ // serviceName: serviceName.value,
84
+ // mode: '新增',
85
+ // },
86
+ })
87
+ // 如果存在回调函数,调用它并传递true表示已处理
88
+ if (typeof callback === 'function') {
89
+ callback(true)
90
+ }
91
+ }
72
92
 
73
93
  // 修改功能
74
- // function updateRow(result) {
75
- // router.push({
76
- // name: 'XFormView',
77
- // params: { id: result.o_id, openid: result.o_id },
78
- // query: {
79
- // configName: configName.value,
80
- // serviceName: serviceName.value,
81
- // mode: '修改',
82
- // },
83
- // })
84
- // }
94
+ function updateRow(result, callback) {
95
+ console.log('用户----', userInfo)
96
+ router.push({
97
+ name: 'XFormGroupView',
98
+ // params: { id: result.o_id, openid: result.o_id },
99
+ // query: {
100
+ // configName: configName.value,
101
+ // serviceName: serviceName.value,
102
+ // mode: '修改',
103
+ // },
104
+ })
105
+
106
+ // 如果存在回调函数,调用它并传递true表示已处理
107
+ if (typeof callback === 'function') {
108
+ callback(true)
109
+ }
110
+ }
85
111
 
86
112
  // 删除功能
87
113
  function deleteRow(result) {
@@ -95,11 +121,23 @@ function deleteRow(result) {
95
121
  <XCellList
96
122
  :config-name="configName"
97
123
  :service-name="serviceName"
98
- :fix-query-form="{ o_f_oper_name: 'edu_test' }"
99
124
  :id-key="idKey"
100
125
  @to-detail="toDetail"
101
126
  @delete-row="deleteRow"
127
+ @update="updateRow"
128
+ @add="addOption"
102
129
  />
130
+
131
+ <!-- :fix-query-form="{ u_f_price_state: ['生效', '待生效'] }" -->
132
+
133
+ <!-- <XCellList -->
134
+ <!-- :config-name="configName" -->
135
+ <!-- :service-name="serviceName" -->
136
+ <!-- :fix-query-form="{ o_f_oper_name: 'edu_test' }" -->
137
+ <!-- :id-key="idKey" -->
138
+ <!-- @to-detail="toDetail" -->
139
+ <!-- @delete-row="deleteRow" -->
140
+ <!-- /> -->
103
141
  </template>
104
142
  </NormalDataLayout>
105
143
  </template>
@@ -5,9 +5,12 @@ 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")