|
@@ -1,66 +1,19 @@
|
|
|
<template>
|
|
|
- <el-popover :disabled="disabled" :width="180" popper-class="is-pure el-picker__popper" trigger="click">
|
|
|
- <template #reference>
|
|
|
- <div
|
|
|
- class="hc-date-time-input el-input el-input--prefix el-input--suffix el-date-editor el-date-editor--time"
|
|
|
- @keydown.shift.up="keyupShiftUp"
|
|
|
- @keydown.shift.down="keyupShiftDown"
|
|
|
- @keydown.shift.left="keyupShiftLeft"
|
|
|
- @keydown.shift.right="keyupShiftRight">
|
|
|
- <div :class="isFocus?'is-focus':''" class="el-input__wrapper">
|
|
|
- <span class="el-input__prefix">
|
|
|
- <span class="el-input__prefix-inner">
|
|
|
- <HcIcon class="el-icon el-input__icon" name="time"/>
|
|
|
- </span>
|
|
|
- </span>
|
|
|
- <input :id="keyname" ref="timePickerRef" :disabled="disabled" :name="keyname"
|
|
|
- :placeholder="placeholder" :readonly="readonly"
|
|
|
- :value="modelValues" autocomplete="off" class="el-input__inner" type="text"
|
|
|
- @blur="timePickerBlur"
|
|
|
- @focus="timePickerFocus">
|
|
|
- <span v-if="clearable" v-show="modelValues" class="el-input__suffix">
|
|
|
- <span class="el-input__suffix-inner">
|
|
|
- <HcIcon class="el-icon el-input__icon" name="close-circle"/>
|
|
|
- </span>
|
|
|
- </span>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- </template>
|
|
|
- <div class="el-time-panel">
|
|
|
- <div class="el-time-panel__content has-seconds">
|
|
|
- <div class="el-time-spinner has-seconds">
|
|
|
- <el-scrollbar class="el-time-spinner__wrapper">
|
|
|
- <ul class="el-scrollbar__view el-time-spinner__list">
|
|
|
- <li class="el-time-spinner__item">00</li>
|
|
|
- <li class="el-time-spinner__item">01</li>
|
|
|
- <li class="el-time-spinner__item is-active">02</li>
|
|
|
- <li class="el-time-spinner__item">02</li>
|
|
|
- </ul>
|
|
|
- </el-scrollbar>
|
|
|
- <el-scrollbar class="el-time-spinner__wrapper">
|
|
|
- <ul class="el-scrollbar__view el-time-spinner__list">
|
|
|
- <li class="el-time-spinner__item">00</li>
|
|
|
- <li class="el-time-spinner__item">01</li>
|
|
|
- <li class="el-time-spinner__item is-active">02</li>
|
|
|
- <li class="el-time-spinner__item">02</li>
|
|
|
- </ul>
|
|
|
- </el-scrollbar>
|
|
|
- <el-scrollbar class="el-time-spinner__wrapper">
|
|
|
- <ul class="el-scrollbar__view el-time-spinner__list">
|
|
|
- <li class="el-time-spinner__item">00</li>
|
|
|
- <li class="el-time-spinner__item">01</li>
|
|
|
- <li class="el-time-spinner__item is-active">02</li>
|
|
|
- <li class="el-time-spinner__item">02</li>
|
|
|
- </ul>
|
|
|
- </el-scrollbar>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- <div class="el-time-panel__footer">
|
|
|
- <button class="el-time-panel__btn cancel" type="button">取消</button>
|
|
|
- <button class="el-time-panel__btn confirm" type="button">确定</button>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- </el-popover>
|
|
|
+ <el-time-picker :id="keyname"
|
|
|
+ v-model="modelValues"
|
|
|
+ :clearable="clearable"
|
|
|
+ :disabled="disabled"
|
|
|
+ :format="format"
|
|
|
+ :keyname="keyname"
|
|
|
+ :placeholder="placeholder"
|
|
|
+ :readonly="readonly"
|
|
|
+ :value-format="valueFormat"
|
|
|
+ style="width: 100%;height: 100%;"
|
|
|
+ @change="timePickerChange"
|
|
|
+ @keydown.shift.up="keyupShiftUp"
|
|
|
+ @keydown.shift.down="keyupShiftDown"
|
|
|
+ @keydown.shift.left="keyupShiftLeft"
|
|
|
+ @keydown.shift.right="keyupShiftRight"></el-time-picker>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
@@ -71,17 +24,21 @@ export default {
|
|
|
|
|
|
<script setup>
|
|
|
import {ref, watch} from 'vue'
|
|
|
-import HcIcon from "~src/global/components/hc-icon/index.vue"
|
|
|
+import {ElTimePicker} from 'z-element-plus'
|
|
|
+import 'dayjs/locale/zh-cn'
|
|
|
|
|
|
const props = defineProps({
|
|
|
modelValue: {
|
|
|
- type: [String, Number],
|
|
|
- default: 1
|
|
|
+ type: [Date, String, Number, Array]
|
|
|
},
|
|
|
format: {
|
|
|
type: String,
|
|
|
default: 'HH:mm:ss'
|
|
|
},
|
|
|
+ valueFormat: {
|
|
|
+ type: String,
|
|
|
+ default: 'HH:mm:ss'
|
|
|
+ },
|
|
|
keyname: {
|
|
|
type: String,
|
|
|
default: ''
|
|
@@ -102,18 +59,10 @@ const props = defineProps({
|
|
|
type: String,
|
|
|
default: ''
|
|
|
},
|
|
|
- onKeydown: {
|
|
|
- type: [Array],
|
|
|
- default: () => {
|
|
|
- return []
|
|
|
- }
|
|
|
- },
|
|
|
})
|
|
|
|
|
|
//变量
|
|
|
const modelValues = ref(props.modelValue)
|
|
|
-const timePickerRef = ref(null)
|
|
|
-const isFocus = ref(false)
|
|
|
|
|
|
//监听
|
|
|
watch(() => [
|
|
@@ -123,51 +72,30 @@ watch(() => [
|
|
|
})
|
|
|
|
|
|
//事件
|
|
|
-const emit = defineEmits(['update:modelValue', 'change', 'blur', 'focus', 'visible-change',])
|
|
|
-//@keyDowns='dateKeydown'
|
|
|
+const emit = defineEmits(['update:modelValue', 'change', 'keydowns'])
|
|
|
|
|
|
const timePickerChange = (val) => {
|
|
|
- console.log(val)
|
|
|
emit('update:modelValue', val)
|
|
|
emit('change', val)
|
|
|
}
|
|
|
|
|
|
-//失去焦点
|
|
|
-const timePickerBlur = (e) => {
|
|
|
- isFocus.value = false
|
|
|
- emit('blur', e)
|
|
|
-}
|
|
|
-
|
|
|
-//获取焦点
|
|
|
-const timePickerFocus = (e) => {
|
|
|
- isFocus.value = true
|
|
|
- emit('focus', e)
|
|
|
-}
|
|
|
-
|
|
|
//向上
|
|
|
const keyupShiftUp = (e) => {
|
|
|
- console.log(e)
|
|
|
+ emit('keydowns', {type: 'up', name: {target: {id: props.keyname}}, key: props.keyname, e});
|
|
|
}
|
|
|
|
|
|
//向下
|
|
|
const keyupShiftDown = (e) => {
|
|
|
- console.log(e)
|
|
|
+ emit('keydowns', {type: 'down', name: {target: {id: props.keyname}}, key: props.keyname, e});
|
|
|
}
|
|
|
|
|
|
//向左
|
|
|
const keyupShiftLeft = (e) => {
|
|
|
- console.log(e)
|
|
|
+ emit('keydowns', {type: 'left', name: {target: {id: props.keyname}}, key: props.keyname, e});
|
|
|
}
|
|
|
|
|
|
//向右
|
|
|
const keyupShiftRight = (e) => {
|
|
|
- console.log(e)
|
|
|
+ emit('keydowns', {type: 'right', name: {target: {id: props.keyname}}, key: props.keyname, e});
|
|
|
}
|
|
|
</script>
|
|
|
-
|
|
|
-<style lang="scss" scoped>
|
|
|
-.hc-date-time-input {
|
|
|
- height: 100%;
|
|
|
- width: 100%;
|
|
|
-}
|
|
|
-</style>
|