Commit c4788b63 authored by 何虹's avatar 何虹 💬

表格中数字输入框点击时,复制全部;2.下拉框,日期框弹出后,点击页面其他地方要隐藏收起。

parent 063cad3f
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
>{{configData.title}}</div> >{{configData.title}}</div>
<div class="containerSelf"> <div class="containerSelf">
<el-date-picker <el-date-picker
ref='currentDom'
v-clickoutside="hidePicker"
@change='changed' @change='changed'
size='mini' size='mini'
v-model="valueInner" v-model="valueInner"
...@@ -57,6 +59,9 @@ export default { ...@@ -57,6 +59,9 @@ export default {
} }
}, },
methods: { methods: {
hidePicker() {
this.$refs.currentDom.hidePicker()
},
execAction(actionName, value) { execAction(actionName, value) {
const type = typeof actionName const type = typeof actionName
if (type === 'function') { if (type === 'function') {
......
...@@ -6,6 +6,9 @@ ...@@ -6,6 +6,9 @@
>{{configData.title}}</div> >{{configData.title}}</div>
<div class="containerSelf"> <div class="containerSelf">
<el-time-picker <el-time-picker
size='mini'
ref='currentDom'
v-clickoutside="hidePicker"
:is-range='configData.isRange' :is-range='configData.isRange'
v-model="valueInner" v-model="valueInner"
range-separator="至" range-separator="至"
...@@ -45,11 +48,11 @@ export default { ...@@ -45,11 +48,11 @@ export default {
}, },
set: function(value) { set: function(value) {
const isRange = this.configData.isRange const isRange = this.configData.isRange
if(!value){//点击清除时 if (!value) { // 点击清除时
this.$emit('input', '') this.$emit('input', '')
return return
} }
if (!isRange) {//单个时间 if (!isRange) { // 单个时间
this.$emit('input', value) this.$emit('input', value)
return return
} }
...@@ -65,6 +68,9 @@ export default { ...@@ -65,6 +68,9 @@ export default {
} }
}, },
methods: { methods: {
hidePicker() {
this.$refs.currentDom.hidePicker()
},
getDefaultTime() { getDefaultTime() {
const t1 = moment().format('HH:mm:ss') const t1 = moment().format('HH:mm:ss')
return [t1, '23:59:59'] return [t1, '23:59:59']
......
...@@ -24,6 +24,8 @@ ...@@ -24,6 +24,8 @@
</template> </template>
<template v-else-if="item.type==='elDatePicker'"> <template v-else-if="item.type==='elDatePicker'">
<el-date-picker <el-date-picker
ref='currentDom'
v-clickoutside="hidePicker"
clearable clearable
style="width:100%" style="width:100%"
size='mini' size='mini'
...@@ -39,6 +41,8 @@ ...@@ -39,6 +41,8 @@
</template> </template>
<template v-else-if="item.type==='elDatePickerDatetime'"> <template v-else-if="item.type==='elDatePickerDatetime'">
<el-date-picker <el-date-picker
ref='currentDom'
v-clickoutside="hidePicker"
clearable clearable
style="width:100%" style="width:100%"
size='mini' size='mini'
...@@ -51,6 +55,8 @@ ...@@ -51,6 +55,8 @@
</template> </template>
<template v-else-if="item.type==='elDatePickerDate'"> <template v-else-if="item.type==='elDatePickerDate'">
<el-date-picker <el-date-picker
ref='currentDom'
v-clickoutside="hidePicker"
clearable clearable
style="width:100%" style="width:100%"
size='mini' size='mini'
...@@ -63,6 +69,8 @@ ...@@ -63,6 +69,8 @@
</template> </template>
<template v-else-if="item.type==='elDatePickerMonth'"> <template v-else-if="item.type==='elDatePickerMonth'">
<el-date-picker <el-date-picker
ref='currentDom'
v-clickoutside="hidePicker"
clearable clearable
style="width:100%" style="width:100%"
size='mini' size='mini'
...@@ -75,6 +83,8 @@ ...@@ -75,6 +83,8 @@
</template> </template>
<template v-else-if="item.type==='elDatePickerMonthRange'"> <template v-else-if="item.type==='elDatePickerMonthRange'">
<el-date-picker <el-date-picker
ref='currentDom'
v-clickoutside="hidePicker"
clearable clearable
style="width:100%" style="width:100%"
size='mini' size='mini'
...@@ -383,16 +393,23 @@ ...@@ -383,16 +393,23 @@
</template> </template>
<script> <script>
import elementUiMinins from '../../ucClass/elementUiMinins' // import elementUiMinins from '../../ucClass/elementUiMinins'
import clickOutSide from '../../ucClass/click-out-side'
export default { export default {
mixins: [elementUiMinins], // mixins: [elementUiMinins],
name: 'dyncFormItemComponentChild', name: 'dyncFormItemComponentChild',
directives: {
clickoutside: clickOutSide
},
props: { props: {
type: {}, type: {},
item: {}, item: {},
formParms: {} formParms: {}
}, },
methods: { methods: {
hidePicker() {
this.$refs.currentDom.hidePicker()
},
itemClick() { itemClick() {
if (this.$listeners.searchSubmit) { if (this.$listeners.searchSubmit) {
this.$listeners.searchSubmit() this.$listeners.searchSubmit()
......
...@@ -6,7 +6,9 @@ ...@@ -6,7 +6,9 @@
<child <child
v-bind="$attrs" v-bind="$attrs"
v-on="$listeners" v-on="$listeners"
></child> >
</child>
</hs-component-shell> </hs-component-shell>
</template> </template>
<script> <script>
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
>{{configData.title}}</div> >{{configData.title}}</div>
<div class="inputCurr"> <div class="inputCurr">
<el-input-number <el-input-number
@focus="selectContent($event)"
:size='configData.size' :size='configData.size'
@keyup.enter.native="submitInput" @keyup.enter.native="submitInput"
v-model="innerValue" v-model="innerValue"
...@@ -76,6 +77,9 @@ export default { ...@@ -76,6 +77,9 @@ export default {
} }
}, },
methods: { methods: {
selectContent(e) {
e.currentTarget.select()
},
execAction(actionName, value) { execAction(actionName, value) {
const type = typeof actionName const type = typeof actionName
if (type === 'function') { if (type === 'function') {
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
> >
<el-select <el-select
:class="{'noneStyle':isReadOnly1,'noneStyle2':isReadOnly1}" :class="{'noneStyle':isReadOnly1,'noneStyle2':isReadOnly1}"
v-click-outside='handleClickOutside' v-clickoutside='handleClickOutside'
ref='elSelect' ref='elSelect'
:allow-create='configData.allowCreate' :allow-create='configData.allowCreate'
:default-first-option='configData.defaultFirstOption' :default-first-option='configData.defaultFirstOption'
...@@ -31,8 +31,8 @@ ...@@ -31,8 +31,8 @@
placeholder="" placeholder=""
> >
<el-option <el-option
v-for="item in options_" v-for="(item,index) in options_"
:key="item.value" :key="index"
:label="item.label" :label="item.label"
:value="item.value" :value="item.value"
:disabled='item.label===" "' :disabled='item.label===" "'
...@@ -65,24 +65,6 @@ import _ from 'lodash' ...@@ -65,24 +65,6 @@ import _ from 'lodash'
export default { export default {
mixins: [commonMixins], mixins: [commonMixins],
name: 'select-plus-component', name: 'select-plus-component',
directives: {
'click-outside': {
bind: (el, binding, vnode) => {
el.clickOutsideEvent = event => {
// here I check that click was outside the el and his childrens
if (!(el === event.target || el.contains(event.target))) {
if (vnode.context && vnode.context.clickOutSide) {
vnode.context.clickOutSide()
}
}
}
document.body.addEventListener('click', el.clickOutsideEvent)
},
unbind: function(el) {
document.body.removeEventListener('click', el.clickOutsideEvent)
}
}
},
props: { props: {
parentType: {} parentType: {}
}, },
...@@ -508,15 +490,6 @@ export default { ...@@ -508,15 +490,6 @@ export default {
} }
}, },
handleClickOutside() { handleClickOutside() {
this.clickOutSide()
},
myFunc(event) {
const e = event || window.event
if (this.$refs.elSelect && !this.$refs.elSelect.$el.contains(e.target)) {
this.clickOutSide()
}
},
clickOutSide() {
this.$refs.elSelect.blur() this.$refs.elSelect.blur()
}, },
mergeCinfig(config1, config2) { mergeCinfig(config1, config2) {
......
...@@ -40,6 +40,8 @@ ...@@ -40,6 +40,8 @@
<template v-else-if="item.showType==='elDatePicker'"> <template v-else-if="item.showType==='elDatePicker'">
<el-date-picker <el-date-picker
ref='currentDom'
v-clickoutside="hidePicker"
clearable clearable
:disabled='getDisabled||isEditable' :disabled='getDisabled||isEditable'
style="width:100%" style="width:100%"
...@@ -55,6 +57,8 @@ ...@@ -55,6 +57,8 @@
</template> </template>
<template v-else-if="item.showType==='elDatePickerDatetime'"> <template v-else-if="item.showType==='elDatePickerDatetime'">
<el-date-picker <el-date-picker
ref='currentDom'
v-clickoutside="hidePicker"
clearable clearable
:disabled='getDisabled||isEditable' :disabled='getDisabled||isEditable'
style="width:100%" style="width:100%"
...@@ -231,7 +235,11 @@ ...@@ -231,7 +235,11 @@
</template> </template>
<script> <script>
import clickOutSide from '../../ucClass/click-out-side'
export default { export default {
directives: {
clickoutside: clickOutSide
},
name: 'dyncFormItemComponentChild_', name: 'dyncFormItemComponentChild_',
props: { props: {
item: {}, item: {},
...@@ -283,6 +291,9 @@ export default { ...@@ -283,6 +291,9 @@ export default {
} }
}, },
methods: { methods: {
hidePicker() {
this.$refs.currentDom.hidePicker()
},
enterInput(val) { enterInput(val) {
this.$emit('enterInput', val) this.$emit('enterInput', val)
} }
......
...@@ -94,7 +94,7 @@ ...@@ -94,7 +94,7 @@
v-else v-else
:key="index" :key="index"
:resizable="columnItem.resizable" :resizable="columnItem.resizable"
:show-overflow-tooltip="columnItem.showOverflow" :show-overflow-tooltip="true"
:prop="columnItem.prop" :prop="columnItem.prop"
:label="columnItem.label" :label="columnItem.label"
:fixed="columnItem.fixed" :fixed="columnItem.fixed"
...@@ -234,7 +234,7 @@ ...@@ -234,7 +234,7 @@
v-else v-else
:key="index" :key="index"
:resizable="column.resizable" :resizable="column.resizable"
:show-overflow-tooltip="column.showOverflow" :show-overflow="true"
:field="column.prop" :field="column.prop"
:title="column.label" :title="column.label"
:fixed="column.fixed" :fixed="column.fixed"
......
export default {
bind(el, binding, vnode) {
el.handler = function(e) {
if (el.contains(e.target)) {
return false
}
// vnode.context[binding.expression] = false
binding.value()
}
el.stopProp = function(event) {
event.stopPropagation()
}
el.addEventListener('click', el.stopProp)
document.body.addEventListener('click', el.handler)
},
unbind(el, binding) {
el.removeEventListener('click', el.stopProp)
document.body.removeEventListener('click', el.handler)
},
install(Vue) {
Vue.directive('clickoutside', {
bind: this.bind,
unbind: this.unbind
})
}
}
//import elementUiMinins from './elementUiMinins' // import elementUiMinins from './elementUiMinins'
import clickOutSide from './click-out-side'
export default { export default {
// mixins:[elementUiMinins], // mixins:[elementUiMinins],
directives: {
clickoutside: clickOutSide
},
props: { props: {
prop: { prop: {
type: String type: String
}, },
formData: { formData: {
type: Object, type: Object,
default () { default() {
return {} return {}
} }
}, },
config: {// 配置项目 config: {// 配置项目
type: Object, type: Object,
default () { default() {
return {} return {}
} }
}, },
...@@ -22,7 +26,7 @@ export default { ...@@ -22,7 +26,7 @@ export default {
}, },
elInfo: { elInfo: {
type: Object, type: Object,
default () { default() {
return {} return {}
} }
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment