|
|
@ -2,8 +2,15 @@ import { Field, Popup, DatetimePicker } from 'vant' |
|
|
|
import { VisualEditorComponent } from '@/visual-editor/visual-editor.utils' |
|
|
|
import { VisualEditorComponent } from '@/visual-editor/visual-editor.utils' |
|
|
|
import { createFieldProps } from './createFieldProps' |
|
|
|
import { createFieldProps } from './createFieldProps' |
|
|
|
import { useGlobalProperties } from '@/hooks/useGlobalProperties' |
|
|
|
import { useGlobalProperties } from '@/hooks/useGlobalProperties' |
|
|
|
import { createEditorInputProp, createEditorTableProp } from '@/visual-editor/visual-editor.props' |
|
|
|
import { |
|
|
|
|
|
|
|
createEditorInputNumberProp, |
|
|
|
|
|
|
|
createEditorInputProp, |
|
|
|
|
|
|
|
createEditorSelectProp, |
|
|
|
|
|
|
|
createEditorSwitchProp |
|
|
|
|
|
|
|
} from '@/visual-editor/visual-editor.props' |
|
|
|
import { reactive } from 'vue' |
|
|
|
import { reactive } from 'vue' |
|
|
|
|
|
|
|
import { isDate } from '@/visual-editor/utils/is' |
|
|
|
|
|
|
|
import dayjs from 'dayjs' |
|
|
|
|
|
|
|
|
|
|
|
export default { |
|
|
|
export default { |
|
|
|
key: 'datetimePicker', |
|
|
|
key: 'datetimePicker', |
|
|
@ -16,14 +23,11 @@ export default { |
|
|
|
showPicker: false, |
|
|
|
showPicker: false, |
|
|
|
text: '' |
|
|
|
text: '' |
|
|
|
}) |
|
|
|
}) |
|
|
|
const customFieldName = { |
|
|
|
|
|
|
|
text: 'label', |
|
|
|
|
|
|
|
value: 'value' |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const onConfirm = (value) => { |
|
|
|
const onConfirm = (value) => { |
|
|
|
props.modelValue = value.value |
|
|
|
const date = isDate(value) ? dayjs(value).format(props.format) : value |
|
|
|
state.text = value[props.valueKey || 'text'] |
|
|
|
props.modelValue = date |
|
|
|
|
|
|
|
state.text = date |
|
|
|
state.showPicker = false |
|
|
|
state.showPicker = false |
|
|
|
console.log(props) |
|
|
|
console.log(props) |
|
|
|
} |
|
|
|
} |
|
|
@ -52,7 +56,6 @@ export default { |
|
|
|
<DatetimePicker |
|
|
|
<DatetimePicker |
|
|
|
ref={(el) => registerRef(el, block._vid)} |
|
|
|
ref={(el) => registerRef(el, block._vid)} |
|
|
|
{...props} |
|
|
|
{...props} |
|
|
|
columnsFieldNames={customFieldName} |
|
|
|
|
|
|
|
onConfirm={onConfirm} |
|
|
|
onConfirm={onConfirm} |
|
|
|
onCancel={() => (state.showPicker = false)} |
|
|
|
onCancel={() => (state.showPicker = false)} |
|
|
|
/> |
|
|
|
/> |
|
|
@ -73,37 +76,54 @@ export default { |
|
|
|
defaultValue: 'datetimePicker' |
|
|
|
defaultValue: 'datetimePicker' |
|
|
|
}), |
|
|
|
}), |
|
|
|
label: createEditorInputProp({ label: '输入框左侧文本', defaultValue: '时间选择器' }), |
|
|
|
label: createEditorInputProp({ label: '输入框左侧文本', defaultValue: '时间选择器' }), |
|
|
|
columns: createEditorTableProp({ |
|
|
|
title: createEditorInputProp({ label: '顶部栏标题', defaultValue: '选择时间' }), |
|
|
|
label: '数据项', |
|
|
|
type: createEditorSelectProp({ |
|
|
|
option: { |
|
|
|
label: '时间类型', |
|
|
|
options: [ |
|
|
|
options: [ |
|
|
|
{ |
|
|
|
{ |
|
|
|
label: '显示值', |
|
|
|
label: 'date', |
|
|
|
field: 'label' |
|
|
|
val: 'date' |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
label: '绑定值', |
|
|
|
label: 'time', |
|
|
|
field: 'value' |
|
|
|
val: 'time' |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
label: '备注', |
|
|
|
label: 'year-month', |
|
|
|
field: 'comments' |
|
|
|
val: 'year-month' |
|
|
|
} |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
showKey: 'label' |
|
|
|
|
|
|
|
}, |
|
|
|
}, |
|
|
|
defaultValue: [ |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
label: '杭州', |
|
|
|
label: 'month-day', |
|
|
|
value: 'hangzhou' |
|
|
|
val: 'month-day' |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
label: '上海', |
|
|
|
label: 'datehour', |
|
|
|
value: 'shanghai' |
|
|
|
val: 'datehour' |
|
|
|
} |
|
|
|
} |
|
|
|
] |
|
|
|
], |
|
|
|
|
|
|
|
defaultValue: 'time' |
|
|
|
|
|
|
|
}), |
|
|
|
|
|
|
|
format: createEditorInputProp({ |
|
|
|
|
|
|
|
label: '选择时间后格式化值', |
|
|
|
|
|
|
|
tips: 'YYYY-MM-DD HH:mm:ss', |
|
|
|
|
|
|
|
defaultValue: 'YYYY-MM-DD HH:mm:ss' |
|
|
|
|
|
|
|
}), |
|
|
|
|
|
|
|
cancelButtonText: createEditorInputProp({ label: '取消按钮文字' }), |
|
|
|
|
|
|
|
columnsOrder: createEditorInputProp({ |
|
|
|
|
|
|
|
label: '自定义列排序数组', |
|
|
|
|
|
|
|
tips: '可选值为:year、month、day、hour、minute,传多个值以英文逗号隔开' |
|
|
|
|
|
|
|
}), |
|
|
|
|
|
|
|
confirmButtonText: createEditorInputProp({ label: '确认按钮文字' }), |
|
|
|
|
|
|
|
filter: createEditorInputProp({ label: '选项过滤函数' }), |
|
|
|
|
|
|
|
formatter: createEditorInputProp({ label: '选项格式化函数' }), |
|
|
|
|
|
|
|
itemHeight: createEditorInputProp({ |
|
|
|
|
|
|
|
label: '选项高度', |
|
|
|
|
|
|
|
tips: '支持 px vw vh rem 单位,默认 px' |
|
|
|
}), |
|
|
|
}), |
|
|
|
valueKey: createEditorInputProp({ label: '选项对象的键名', defaultValue: 'label' }), |
|
|
|
loading: createEditorSwitchProp({ label: '是否显示加载状态' }), |
|
|
|
|
|
|
|
showToolbar: createEditorSwitchProp({ label: '是否显示顶部栏' }), |
|
|
|
|
|
|
|
swipeDuration: createEditorInputProp({ label: '快速滑动时惯性滚动的时长,单位ms' }), |
|
|
|
|
|
|
|
visibleItemCount: createEditorInputNumberProp({ label: '可见的选项个数' }), |
|
|
|
placeholder: createEditorInputProp({ label: '占位符', defaultValue: '请选择' }), |
|
|
|
placeholder: createEditorInputProp({ label: '占位符', defaultValue: '请选择' }), |
|
|
|
...createFieldProps() |
|
|
|
...createFieldProps() |
|
|
|
}, |
|
|
|
}, |
|
|
|