epmet pc工作端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

126 lines
2.4 KiB

4 years ago
<template>
3 years ago
<el-form :model="inputForm"
class="demo-form-inline">
<div class="flex-div">
<el-form-item prop="start">
<el-input v-model.trim="inputForm.start"
class="u-item-width-normal"
3 years ago
size="small"
:type="inputType"
clearable
placeholder="请输入"
@change="handleChange" />
</el-form-item>
<!-- <el-form-item prop="end">
<el-input v-model.trim="inputForm.end"
3 years ago
class="wd50"
size="small"
:type="inputType"
clearable
placeholder="请输入"
@change="handleChange"
@blur="handleBlur" />
</el-form-item> -->
3 years ago
</div>
</el-form>
4 years ago
</template>
<script>
export default {
name: 'inputRange',
model: {
prop: 'value',
event: 'change'
},
props: {
value: {
type: Object,
3 years ago
default: () => {
4 years ago
return {
start: '',
end: ''
}
3 years ago
}
4 years ago
},
type: {
type: String,
default: ''
}
},
3 years ago
data () {
4 years ago
let checkAge = (rule, value, callback) => {
3 years ago
// debugger
4 years ago
if (value === '') {
callback(new Error('请输入内容'))
} else {
3 years ago
if (parseInt(value) < parseInt(this.inputForm.start)) {
4 years ago
callback(new Error('结束值不能小于开始值'))
3 years ago
} else {
callback()
4 years ago
}
3 years ago
4 years ago
}
}
return {
3 years ago
inputForm: { ...this.value },
4 years ago
}
},
computed: {
3 years ago
inputType () {
4 years ago
if (this.type == 'num') return 'number'
}
},
watch: {
3 years ago
'value.start' (val) {
console.log(val);
4 years ago
this.inputForm.start = val
},
3 years ago
'value.end' (val) {
4 years ago
this.inputForm.end = val
},
},
methods: {
3 years ago
handleChange (val) {
console.log(this.inputForm);
4 years ago
// if ()
3 years ago
this.$emit('change', { ...this.inputForm })
4 years ago
},
3 years ago
handleBlur () {
4 years ago
}
}
}
</script>
<style lang="scss" scoped>
.flex-div {
display: flex;
align-items: center;
4 years ago
max-width: 200px;
}
// .wd50 {
// // width: 45%;
// }
4 years ago
.demo-form-inline {
4 years ago
::v-deep {
.el-form-item {
flex: 1;
width: 40%;
margin: 0;
}
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
-webkit-appearance: none;
}
3 years ago
input[type="number"] {
4 years ago
-moz-appearance: textfield;
}
4 years ago
}
}
3 years ago
.div_middle {
padding: 0 10px;
3 years ago
}
</style>