af-mobile-client-vue3 1.3.65 → 1.3.67
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
|
@@ -195,7 +195,7 @@ function handlePhotoUpload(photoData: any) {
|
|
|
195
195
|
if (index !== -1) {
|
|
196
196
|
delete imageList.value[index].message
|
|
197
197
|
imageList.value[index].status = 'done'
|
|
198
|
-
imageList.value[index].
|
|
198
|
+
imageList.value[index].photo_name = photoData.name
|
|
199
199
|
imageList.value[index].type = mimeType
|
|
200
200
|
}
|
|
201
201
|
else {
|
|
@@ -210,7 +210,7 @@ function handlePhotoUpload(photoData: any) {
|
|
|
210
210
|
|
|
211
211
|
const doneIds = Object.values(imageList.value)
|
|
212
212
|
.filter(item => item.status === 'done')
|
|
213
|
-
.map(item => item.
|
|
213
|
+
.map(item => item.photo_name)
|
|
214
214
|
|
|
215
215
|
if (props.outerIndex !== undefined)
|
|
216
216
|
emit('updateFileList', doneIds, props.outerIndex)
|
|
@@ -273,7 +273,7 @@ function deleteFileFunction(file: any) {
|
|
|
273
273
|
if (props.isAsyncUpload) {
|
|
274
274
|
doneIds.value = Object.values(imageList.value)
|
|
275
275
|
.filter(item => item.status === 'done')
|
|
276
|
-
.map(item => item.
|
|
276
|
+
.map(item => item.photo_name)
|
|
277
277
|
}
|
|
278
278
|
else {
|
|
279
279
|
doneIds.value = Object.values(imageList.value)
|
|
@@ -300,7 +300,7 @@ function deleteFileFunction(file: any) {
|
|
|
300
300
|
if (props.isAsyncUpload) {
|
|
301
301
|
doneIds.value = Object.values(imageList.value)
|
|
302
302
|
.filter(item => item.status === 'done')
|
|
303
|
-
.map(item => item.
|
|
303
|
+
.map(item => item.photo_name)
|
|
304
304
|
}
|
|
305
305
|
else {
|
|
306
306
|
doneIds.value = Object.values(imageList.value)
|
|
@@ -119,6 +119,42 @@ let debouncedDepLinkFunc: (() => void) | null = null
|
|
|
119
119
|
let debouncedUpdateOptions: (() => void) | null = null
|
|
120
120
|
|
|
121
121
|
const { attr, form, mode, serviceName, getDataParams, columnsField } = props
|
|
122
|
+
// 配置的表单值格式(仅针对 datePicker 生效)
|
|
123
|
+
// 作用:统一控制日期值的格式化输入/输出与选择器展示粒度
|
|
124
|
+
// 可选:'YYYY' | 'YYYY-MM' | 'YYYY-MM-DD' | 'YYYY-MM-DD HH' | 'YYYY-MM-DD HH:mm' | 'YYYY-MM-DD HH:mm:ss'
|
|
125
|
+
const formValueFormat = computed(() => {
|
|
126
|
+
// 默认全格式
|
|
127
|
+
return (attr && (attr as any).formValueFormat) || 'YYYY-MM-DD HH:mm:ss'
|
|
128
|
+
})
|
|
129
|
+
|
|
130
|
+
// 根据 formValueFormat 动态计算日期列类型(决定 VanDatePicker 展示年/月/日)
|
|
131
|
+
// 例如:YYYY 只显示年;YYYY-MM 显示年、月;YYYY-MM-DD 显示年、月、日
|
|
132
|
+
const dateColumnsType = computed(() => {
|
|
133
|
+
const format = formValueFormat.value
|
|
134
|
+
const columns: string[] = ['year']
|
|
135
|
+
if (format.includes('MM'))
|
|
136
|
+
columns.push('month')
|
|
137
|
+
if (format.includes('DD'))
|
|
138
|
+
columns.push('day')
|
|
139
|
+
return columns as any
|
|
140
|
+
})
|
|
141
|
+
|
|
142
|
+
// 是否包含时间(决定是否展示时间页签与 VanTimePicker)
|
|
143
|
+
const hasTime = computed(() => formValueFormat.value.includes('HH'))
|
|
144
|
+
|
|
145
|
+
// 根据 formValueFormat 动态计算时间列类型(决定时/分/秒的展示)
|
|
146
|
+
// 例如:包含 HH 显示小时;包含 mm 显示分钟;包含 ss 显示秒
|
|
147
|
+
const timeColumnsType = computed(() => {
|
|
148
|
+
const format = formValueFormat.value
|
|
149
|
+
const columns: string[] = []
|
|
150
|
+
if (format.includes('HH'))
|
|
151
|
+
columns.push('hour')
|
|
152
|
+
if (format.includes('mm'))
|
|
153
|
+
columns.push('minute')
|
|
154
|
+
if (format.includes('ss'))
|
|
155
|
+
columns.push('second')
|
|
156
|
+
return columns as any
|
|
157
|
+
})
|
|
122
158
|
const calendarShow = ref(false)
|
|
123
159
|
const option = ref([])
|
|
124
160
|
const pickerValue = ref(undefined)
|
|
@@ -185,9 +221,16 @@ function checkModel(val = props.modelValue) {
|
|
|
185
221
|
*/
|
|
186
222
|
function getDefaultValue() {
|
|
187
223
|
const val = props.modelValue
|
|
188
|
-
|
|
189
|
-
|
|
224
|
+
console.warn('>>>>>props', props)
|
|
225
|
+
console.warn('>>>> attr', attr)
|
|
226
|
+
// 如果有有效值,直接返回(datePicker 初始值需按 formValueFormat 归一)
|
|
227
|
+
// 目的:外部通过 formData 传入的初始值在组件挂载即与配置格式一致
|
|
190
228
|
if (checkModel(val)) {
|
|
229
|
+
if (attr.type === 'datePicker' && typeof val === 'string') {
|
|
230
|
+
const parsed = dayjs(val)
|
|
231
|
+
if (parsed.isValid())
|
|
232
|
+
return parsed.format(formValueFormat.value)
|
|
233
|
+
}
|
|
191
234
|
return val
|
|
192
235
|
}
|
|
193
236
|
|
|
@@ -233,7 +276,8 @@ function getDefaultValue() {
|
|
|
233
276
|
return specialDefaults[attr.type]
|
|
234
277
|
}
|
|
235
278
|
|
|
236
|
-
//
|
|
279
|
+
// 日期时间类型:调用 getDateRange,并传入 formValueFormat
|
|
280
|
+
// 说明:让初始化/查询默认值同样遵循配置的格式显示
|
|
237
281
|
const dateTypes = ['rangePicker', 'yearPicker', 'monthPicker', 'yearRangePicker', 'monthRangePicker', 'datePicker', 'timePicker']
|
|
238
282
|
if (dateTypes.includes(attr.type)) {
|
|
239
283
|
return getDateRange({
|
|
@@ -243,6 +287,7 @@ function getDefaultValue() {
|
|
|
243
287
|
queryType: attr.queryType,
|
|
244
288
|
queryValueFormat: attr.queryValueFormat,
|
|
245
289
|
name: attr.name ?? '',
|
|
290
|
+
formValueFormat: formValueFormat.value,
|
|
246
291
|
}) ?? []
|
|
247
292
|
}
|
|
248
293
|
|
|
@@ -261,6 +306,7 @@ function getDateRange({
|
|
|
261
306
|
queryType,
|
|
262
307
|
queryValueFormat: defaultFormat,
|
|
263
308
|
name,
|
|
309
|
+
formValueFormat: formFormat,
|
|
264
310
|
}: {
|
|
265
311
|
type: string
|
|
266
312
|
formDefault: string
|
|
@@ -268,6 +314,8 @@ function getDateRange({
|
|
|
268
314
|
queryType?: string
|
|
269
315
|
queryValueFormat?: string
|
|
270
316
|
name: string
|
|
317
|
+
// 新增:用于优先覆盖 datePicker 的显示/存储格式
|
|
318
|
+
formValueFormat?: string
|
|
271
319
|
}): string | [string, string] | undefined {
|
|
272
320
|
const formatMap: Record<string, string> = {
|
|
273
321
|
yearPicker: 'YYYY',
|
|
@@ -278,7 +326,9 @@ function getDateRange({
|
|
|
278
326
|
rangePicker: 'YYYY-MM-DD HH:mm:ss',
|
|
279
327
|
}
|
|
280
328
|
if (mode) {
|
|
281
|
-
|
|
329
|
+
// datePicker 优先使用 formValueFormat(否则退回 queryValueFormat 或默认映射)
|
|
330
|
+
const preferFormat = type === 'datePicker' ? (formFormat || defaultFormat) : defaultFormat
|
|
331
|
+
const format = preferFormat || formatMap[type]
|
|
282
332
|
const val = mode === '查询' ? queryFormDefault : defaultValue
|
|
283
333
|
let start: string, end: string
|
|
284
334
|
switch (val) {
|
|
@@ -376,8 +426,8 @@ function updateFile(files, _index) {
|
|
|
376
426
|
function formTypeCheck(attr, value) {
|
|
377
427
|
if (mode === '查询')
|
|
378
428
|
return
|
|
379
|
-
if (!attr.rule || !attr.rule.required || attr.rule.required === 'false')
|
|
380
|
-
|
|
429
|
+
// if (!attr.rule || !attr.rule.required || attr.rule.required === 'false')
|
|
430
|
+
// return
|
|
381
431
|
switch (attr.rule.type) {
|
|
382
432
|
case 'string':
|
|
383
433
|
if (value.length === 0) {
|
|
@@ -649,24 +699,53 @@ function onPickerConfirm({ selectedOptions }) {
|
|
|
649
699
|
|
|
650
700
|
// 日期时间选择数据
|
|
651
701
|
const dateTimePickerValue = ref<any>({})
|
|
702
|
+
// 展示日期时间选择器:根据 formValueFormat 初始化 VanDatePicker/VanTimePicker 的当前值
|
|
703
|
+
// 规则:
|
|
704
|
+
// - 若已有字符串值,按 formValueFormat 解析并拆分为日期/时间数组
|
|
705
|
+
// - 若无值,按当前时间生成匹配格式的默认数组
|
|
652
706
|
function showDataTimePicker() {
|
|
653
707
|
if (props.modelValue && typeof props.modelValue === 'string') {
|
|
654
|
-
|
|
655
|
-
const [
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
708
|
+
const base = dayjs(props.modelValue as string, formValueFormat.value)
|
|
709
|
+
const dateArr: string[] = []
|
|
710
|
+
dateArr.push(base.format('YYYY'))
|
|
711
|
+
if (dateColumnsType.value.includes('month'))
|
|
712
|
+
dateArr.push(base.format('MM'))
|
|
713
|
+
if (dateColumnsType.value.includes('day'))
|
|
714
|
+
dateArr.push(base.format('DD'))
|
|
715
|
+
const timeArr: string[] = []
|
|
716
|
+
if (hasTime.value) {
|
|
717
|
+
if (timeColumnsType.value.includes('hour'))
|
|
718
|
+
timeArr.push(base.format('HH'))
|
|
719
|
+
if (timeColumnsType.value.includes('minute'))
|
|
720
|
+
timeArr.push(base.format('mm'))
|
|
721
|
+
if (timeColumnsType.value.includes('second'))
|
|
722
|
+
timeArr.push(base.format('ss'))
|
|
723
|
+
}
|
|
661
724
|
dateTimePickerValue.value = {
|
|
662
|
-
date,
|
|
663
|
-
time,
|
|
725
|
+
date: dateArr,
|
|
726
|
+
time: timeArr.length ? timeArr : ['00', '00', '00'].slice(0, timeColumnsType.value.length),
|
|
664
727
|
}
|
|
665
728
|
}
|
|
666
729
|
else {
|
|
730
|
+
const now = dayjs()
|
|
731
|
+
const dateArr: string[] = []
|
|
732
|
+
dateArr.push(now.format('YYYY'))
|
|
733
|
+
if (dateColumnsType.value.includes('month'))
|
|
734
|
+
dateArr.push(now.format('MM'))
|
|
735
|
+
if (dateColumnsType.value.includes('day'))
|
|
736
|
+
dateArr.push(now.format('DD'))
|
|
737
|
+
const timeArr: string[] = []
|
|
738
|
+
if (hasTime.value) {
|
|
739
|
+
if (timeColumnsType.value.includes('hour'))
|
|
740
|
+
timeArr.push(now.format('HH'))
|
|
741
|
+
if (timeColumnsType.value.includes('minute'))
|
|
742
|
+
timeArr.push(now.format('mm'))
|
|
743
|
+
if (timeColumnsType.value.includes('second'))
|
|
744
|
+
timeArr.push(now.format('ss'))
|
|
745
|
+
}
|
|
667
746
|
dateTimePickerValue.value = {
|
|
668
|
-
date:
|
|
669
|
-
time: ['00', '00', '00'],
|
|
747
|
+
date: dateArr,
|
|
748
|
+
time: timeArr.length ? timeArr : ['00', '00', '00'].slice(0, timeColumnsType.value.length),
|
|
670
749
|
}
|
|
671
750
|
}
|
|
672
751
|
showDatePicker.value = true
|
|
@@ -695,11 +774,19 @@ function onAreaConfirm({ selectedOptions }) {
|
|
|
695
774
|
}]
|
|
696
775
|
}
|
|
697
776
|
|
|
777
|
+
// 日期时间选择确认:将选择的年月日(+时分秒)拼装后,最终使用 formValueFormat 输出到 v-model
|
|
698
778
|
function onDateTimePickerConfirm() {
|
|
699
779
|
showDatePicker.value = false
|
|
700
|
-
const
|
|
701
|
-
const
|
|
702
|
-
|
|
780
|
+
const dateParts = dateTimePickerValue.value.date as string[]
|
|
781
|
+
const timeParts = (dateTimePickerValue.value.time as string[]) || []
|
|
782
|
+
const year = dateParts[0]
|
|
783
|
+
const month = dateParts[1] || '01'
|
|
784
|
+
const day = dateParts[2] || '01'
|
|
785
|
+
const hour = hasTime.value && timeParts[0] ? timeParts[0] : '00'
|
|
786
|
+
const minute = hasTime.value && timeParts[1] ? timeParts[1] : '00'
|
|
787
|
+
const second = hasTime.value && timeParts[2] ? timeParts[2] : '00'
|
|
788
|
+
const full = `${year}-${month}-${day} ${hour}:${minute}:${second}`
|
|
789
|
+
modelData.value = dayjs(full, 'YYYY-MM-DD HH:mm:ss').format(formValueFormat.value)
|
|
703
790
|
}
|
|
704
791
|
|
|
705
792
|
function onPickerCancel() {
|
|
@@ -1065,7 +1152,7 @@ function findOptionInTree(options, value) {
|
|
|
1065
1152
|
<VanPopup v-model:show="showDatePicker" position="bottom" teleport="body" overlay-class="date-picker-overlay">
|
|
1066
1153
|
<VanPickerGroup
|
|
1067
1154
|
:title="attr.name"
|
|
1068
|
-
:tabs="['选择日期', '选择时间']"
|
|
1155
|
+
:tabs="hasTime ? ['选择日期', '选择时间'] : ['选择日期']"
|
|
1069
1156
|
next-step-text="下一步"
|
|
1070
1157
|
:confirm-button-text="attr.confirmButtonText ? attr.confirmButtonText : '确认'"
|
|
1071
1158
|
:cancel-button-text="attr.cancelButtonText ? attr.cancelButtonText : '取消'"
|
|
@@ -1074,11 +1161,12 @@ function findOptionInTree(options, value) {
|
|
|
1074
1161
|
>
|
|
1075
1162
|
<VanDatePicker
|
|
1076
1163
|
v-model="dateTimePickerValue.date"
|
|
1077
|
-
:columns-type="attr.dateColumnsType ||
|
|
1164
|
+
:columns-type="attr.dateColumnsType || dateColumnsType"
|
|
1078
1165
|
/>
|
|
1079
1166
|
<VanTimePicker
|
|
1167
|
+
v-if="hasTime"
|
|
1080
1168
|
v-model="dateTimePickerValue.time"
|
|
1081
|
-
:columns-type="attr.timeColumnsType ||
|
|
1169
|
+
:columns-type="attr.timeColumnsType || timeColumnsType"
|
|
1082
1170
|
:min-time="attr.minTime ? attr.minTime : '00:00:00'"
|
|
1083
1171
|
:max-time="attr.maxTime ? attr.maxTime : '23:59:59'"
|
|
1084
1172
|
/>
|
|
@@ -1097,12 +1185,12 @@ function findOptionInTree(options, value) {
|
|
|
1097
1185
|
:is-link="true"
|
|
1098
1186
|
:placeholder="attr.placeholder ? attr.placeholder : `请选择${attr.name}`"
|
|
1099
1187
|
:rules="[{ required: attr.rule.required === 'true', message: `请选择${attr.name}` }]"
|
|
1100
|
-
@click="readonly ? null : (
|
|
1188
|
+
@click="readonly ? null : showDataTimePicker()"
|
|
1101
1189
|
/>
|
|
1102
1190
|
<VanPopup v-model:show="showDatePicker" position="bottom" teleport="body" overlay-class="date-picker-overlay">
|
|
1103
1191
|
<VanPickerGroup
|
|
1104
1192
|
:title="attr.name"
|
|
1105
|
-
:tabs="['选择日期', '选择时间']"
|
|
1193
|
+
:tabs="hasTime ? ['选择日期', '选择时间'] : ['选择日期']"
|
|
1106
1194
|
next-step-text="下一步"
|
|
1107
1195
|
:confirm-button-text="attr.confirmButtonText ? attr.confirmButtonText : '确认'"
|
|
1108
1196
|
:cancel-button-text="attr.cancelButtonText ? attr.cancelButtonText : '取消'"
|
|
@@ -1111,11 +1199,12 @@ function findOptionInTree(options, value) {
|
|
|
1111
1199
|
>
|
|
1112
1200
|
<VanDatePicker
|
|
1113
1201
|
v-model="dateTimePickerValue.date"
|
|
1114
|
-
:columns-type="attr.dateColumnsType ||
|
|
1202
|
+
:columns-type="attr.dateColumnsType || dateColumnsType"
|
|
1115
1203
|
/>
|
|
1116
1204
|
<VanTimePicker
|
|
1205
|
+
v-if="hasTime"
|
|
1117
1206
|
v-model="dateTimePickerValue.time"
|
|
1118
|
-
:columns-type="attr.timeColumnsType ||
|
|
1207
|
+
:columns-type="attr.timeColumnsType || timeColumnsType"
|
|
1119
1208
|
:min-time="attr.minTime ? attr.minTime : '00:00:00'"
|
|
1120
1209
|
:max-time="attr.maxTime ? attr.maxTime : '23:59:59'"
|
|
1121
1210
|
/>
|