liuxiaolong
2019-05-06 770c069996e1d2979c1170c1639c18b02d07e72f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<template>
    <div class="select-king" ref="selectKing" @blur="isShowOptions=false">
      <el-input v-model="selectVal" @focus="isShowOptions=true"  :placeholder="placeholder" :readonly="true">
        <i slot="suffix" v-show="!isShowOptions" class="el-input__icon fas fa-angle-down"></i>
        <i slot="suffix" v-show="isShowOptions" class="el-input__icon fas fa-angle-up"></i>
      </el-input>
      <!-- <div class="select-king-options-bg" v-show="isShowOptions" @click="isShowOptions=false"></div> -->
      <div class="select-king-options " v-show="isShowOptions">
        <div class="border px-1 my-1 bg-white options">
          <slot></slot>
        </div>
      </div>
    </div>
</template>
<script>
import { Input } from 'element-ui'
export default {
  name: 'speciaButton',
  components: {
    elInput: Input
  },
  data() {
    return {
      selectVal: '',
      isShowOptions: false
    }
  },
  props: {
    placeholder: {
      default: '请选择',
      type: String
    },
 
    isLock: {
      default: true,
      type: Boolean
    }
  },
  computed: {
    orgId() {
      return this.$store.getters.basicUserInfo.orgId
    }
  },
  methods: {
    setLockState() {
      this.$emit('change', this.isLock)
    },
    targetClose(ev) {
      let target = ev.target
      while (target !== this.$refs.selectKing && target !== document.body) {
        target = target.parentNode
      }
      if (target !== this.$refs.selectKing) {
        this.isShowOptions = false
      }
    }
  },
  mounted() {
    /* 空白关闭函数 start */
    document.body.addEventListener('click', this.targetClose)
    /* 空白关闭函数 end */
  },
  destroyed() {
    document.body.removeEventListener('click', this.targetClose)
  }
}
</script>
<style lang="scss">
.select-king {
  float: left;
  .select-king-options-bg {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: 0;
    z-index: 99;
    // background: rgba(255,255,255,0.4)
  }
  .select-king-options {
    position: absolute;
    width: 500px;
    height: 300px;
    z-index: 100;
    .options {
      height: 100%;
      overflow: auto;
      border-radius: 3px;
    }
  }
}
</style>