af-mobile-client-vue3 1.6.22 → 1.6.24

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.6.22",
4
+ "version": "1.6.24",
5
5
  "packageManager": "pnpm@10.13.1",
6
6
  "description": "Vue + Vite component lib",
7
7
  "engines": {
@@ -1022,7 +1022,7 @@ async function validateAllForms() {
1022
1022
  }
1023
1023
 
1024
1024
  // 组织提交数据
1025
- function organizeSubmitData() {
1025
+ async function organizeSubmitData() {
1026
1026
  // 获取用户信息组件数据
1027
1027
  const userInfoData = userInfoRef.value?.getData()
1028
1028
  // 获取用气设备组件数据
@@ -1299,25 +1299,31 @@ function organizeSubmitData() {
1299
1299
  let location = ''
1300
1300
  // 获取安检单上传时的人员定位
1301
1301
  if (safeConfig.value?.needLocation) {
1302
- mobileUtil.execute({
1303
- param: {},
1304
- funcName: 'getLocationResult',
1305
- callbackFunc: (res: any) => {
1306
- if (res?.status === 'success') {
1307
- try {
1308
- const locationResult = JSON.parse(res.data.location)
1309
- if (
1310
- typeof locationResult.longitude === 'number'
1311
- && typeof locationResult.latitude === 'number'
1312
- ) {
1313
- location = `${locationResult.longitude},${locationResult.latitude}`
1302
+ // 使用 Promise 包装回调
1303
+ location = await new Promise((resolve) => {
1304
+ mobileUtil.execute({
1305
+ param: {},
1306
+ funcName: 'getLocationResult',
1307
+ callbackFunc: (res: any) => {
1308
+ console.log('获取位置结果:', res)
1309
+ if (res?.status === 'success') {
1310
+ try {
1311
+ const locationResult = JSON.parse(res.data.location)
1312
+ if (
1313
+ typeof locationResult.longitude === 'number'
1314
+ && typeof locationResult.latitude === 'number'
1315
+ ) {
1316
+ resolve(`${locationResult.longitude},${locationResult.latitude}`)
1317
+ return
1318
+ }
1319
+ }
1320
+ catch (err) {
1321
+ console.error('定位数据解析失败:', err)
1314
1322
  }
1315
1323
  }
1316
- catch (err) {
1317
- console.error('定位数据解析失败:', err)
1318
- }
1319
- }
1320
- },
1324
+ resolve('') // 获取失败返回空字符串
1325
+ },
1326
+ })
1321
1327
  })
1322
1328
  }
1323
1329
  return {
@@ -1522,7 +1528,7 @@ async function saveDraftData() {
1522
1528
  const param = {
1523
1529
  id: checkId.value,
1524
1530
  draftType: draftType.value,
1525
- f_temporary_storage: organizeSubmitData(),
1531
+ f_temporary_storage: await organizeSubmitData(),
1526
1532
  f_temporary_date: formatNow(),
1527
1533
  }
1528
1534
  await runLogic('saveDraft', param, 'af-safecheck')
@@ -1576,7 +1582,7 @@ async function onSubmit() {
1576
1582
  }
1577
1583
 
1578
1584
  // 用户确认提交,组织提交数据
1579
- const submitData = organizeSubmitData()
1585
+ const submitData = await organizeSubmitData()
1580
1586
  console.log('提交数据:', submitData)
1581
1587
 
1582
1588
  // 自定义校验
@@ -98,6 +98,8 @@ const formType = {
98
98
  text: 'text', // 表单项类型
99
99
  number: 'number',
100
100
  date: 'date',
101
+ year: 'year',
102
+ yearMonth: 'yearMonth',
101
103
  radio: 'radio',
102
104
  checkbox: 'checkbox',
103
105
  multipleSelect: 'multipleSelect',
@@ -117,11 +119,27 @@ const debouncedCustomFunc = ref<((ctx: any, cfg: any, userDetail: any, safeConfi
117
119
  // 拍照/上传相关信息
118
120
  const cameraData = ref(undefined)
119
121
  // 日期选择器默认值
120
- const datePickerDefault = ref([
121
- dayjs().format('YYYY'),
122
- dayjs().format('MM'),
123
- dayjs().format('DD'),
124
- ])
122
+ const datePickerDefault = ref<string[]>([])
123
+
124
+ watch(() => currentVal[dataStructure.fieldType], (type) => {
125
+ if (type === formType.year)
126
+ datePickerDefault.value = [dayjs().format('YYYY')]
127
+ else if (type === formType.yearMonth)
128
+ datePickerDefault.value = [dayjs().format('YYYY'), dayjs().format('MM')]
129
+ else if (type === formType.date)
130
+ datePickerDefault.value = [dayjs().format('YYYY'), dayjs().format('MM'), dayjs().format('DD')]
131
+ else
132
+ datePickerDefault.value = []
133
+ }, { immediate: true })
134
+
135
+ const columnsType = computed(() => {
136
+ const type = currentVal[dataStructure.fieldType]
137
+ if (type === formType.year)
138
+ return ['year'] as any
139
+ if (type === formType.yearMonth)
140
+ return ['year', 'month'] as any
141
+ return ['year', 'month', 'day'] as any
142
+ })
125
143
 
126
144
  function safeParseJson(jsonStr: any): any {
127
145
  if (typeof jsonStr !== 'string')
@@ -141,6 +159,8 @@ function confirm(selVal, selObj) {
141
159
 
142
160
  switch (currentVal[dataStructure.fieldType]) {
143
161
  case formType.date:
162
+ case formType.year:
163
+ case formType.yearMonth:
144
164
  currentVal.value = selVal.selectedValues.join('-')
145
165
  selVal = currentVal.value
146
166
  showPicker.value = false
@@ -249,7 +269,7 @@ const datePickerMaxDate = computed(() => {
249
269
  @blur="confirm"
250
270
  />
251
271
  <VanField
252
- v-else-if="currentVal[dataStructure.fieldType] === formType.date"
272
+ v-else-if="currentVal[dataStructure.fieldType] === formType.date || currentVal[dataStructure.fieldType] === formType.year || currentVal[dataStructure.fieldType] === formType.yearMonth"
253
273
  v-model="currentVal[dataStructure.fieldValue]"
254
274
  center
255
275
  is-link
@@ -392,7 +412,7 @@ const datePickerMaxDate = computed(() => {
392
412
  </VanField>
393
413
  <!-- {{ currentVal }} -->
394
414
  <VanPopup v-model:show="showPicker" position="bottom">
395
- <VanDatePicker v-model="datePickerDefault" :min-date="datePickerMinDate" :max-date="datePickerMaxDate" @confirm="confirm" @cancel="showPicker = false" />
415
+ <VanDatePicker v-model="datePickerDefault" :columns-type="columnsType" :min-date="datePickerMinDate" :max-date="datePickerMaxDate" @confirm="confirm" @cancel="showPicker = false" />
396
416
  </VanPopup>
397
417
  <slot :item="currentVal" />
398
418
  </template>