<template>
  <div :class="inline ? 'inline' : ''" class="QdmScope">
    <span :style="'width:' + colSpan + 'px;text-align:' + align + ';'"><i v-if="must">*</i>{{ name }}</span>
    <el-input
      v-if="onkeyupNumber"
      :disabled="mindisabled"
      onkeyup="value=value.replace(/[^\d.]/g,'')"
      v-model="newmin"
      @change="inputChange">
    </el-input>
    <el-input
      v-else
      :disabled="mindisabled"
      v-model="newmin"
      @change="inputChange">
    </el-input>
    <i>-</i>
    <el-input
      v-if="onkeyupNumber"
      :disabled="maxdisabled"
      onkeyup="value=value.replace(/[^\d.]/g,'')"
      v-model="newmax"
      @change="inputChange">
    </el-input>
    <el-input
      v-else
      :disabled="maxdisabled"
      v-model="newmax"
      @change="inputChange">
    </el-input>
  </div>
</template>
<script>
export default {
  name: "QdmScope",
  props: {
    name: {
      type: String,
      default: ''
    },
    colSpan: {
      type: Number,
      default: 60
    },
    align: {
    	type: String,
      default: 'right'
    },
    mindisabled: {
      type: Boolean,
      default: false
    },
    maxdisabled: {
      type: Boolean,
      default: false
    },
    min: {
      type: [ Number, String ],
      default: ''
    },
    max: {
      type: [ Number, String ],
      default: ''
    },
    inline: {
      type: Boolean,
      default: false
    },
    must: {
      type: Boolean,
      default: false
    },
    onkeyupNumber: {
      type: Boolean,
      default: true
    }
  },
  data() {
    return {
      newmin: this.min,
      newmax: this.max
    }
  },
  methods: {
    inputChange() {
      this.$emit('scopeReturn', this.newmin, this.newmax)
    }
  },
  watch: {
  	min(val) {
  		this.newmin = val
    },
    max(val) {
      this.newmax = val
    }
  }
}
</script>
<style lang="less">
.inline {
  float: left;
}
.QdmScope {
  margin-bottom: 8px;
  height: 30px;
  line-height: 30px;
  >span {
    display: block;
    height: 30px;
    float: left;
    line-height: 30px;
    padding-right: 8px;
    font-size: 12px;
    >i {
      color: #F5222D;
      margin-right: 5px;
      padding-left: 3px;
    }
  }
  >i {
    float: left;
    margin: 0 10px;
  }
  .el-input {
    float: left;
    width: 100px;
    font-size: 12px;
    line-height: 30px;
    .el-input__inner {
      height: 30px;
      line-height: 30px;
    }
  }
}
</style>