Blame view

ant-design-vue-jeecg/src/components/jeecg/minipop/JInputPop.vue 2.31 KB
肖超群 authored
1
2
3
4
5
6
7
8
9
10
<template>
  <a-popover trigger="contextmenu" v-model="visible" :placement="position" overlayClassName="j-input-pop">
    <!--"(node) => node.parentNode.parentNode"-->
    <div slot="title">
      <span>{{ title }}</span>
      <span style="float: right" title="关闭">
        <a-icon type="close" @click="visible=false"/>
      </span>
    </div>
    <a-input :value="inputContent" :disabled="disabled" @change="handleInputChange" :placeholder="placeholder">
肖超群 authored
11
      <a-icon slot="suffix" type="fullscreen" @click.stop="pop"/>
肖超群 authored
12
13
    </a-input>
    <div slot="content">
肖超群 authored
14
15
      <a-textarea ref="textarea" :value="inputContent" :disabled="disabled" @input="handleInputChange"
                  :style="{ height: height + 'px', width: width + 'px' }"/>
肖超群 authored
16
17
18
19
20
    </div>
  </a-popover>
</template>

<script>
肖超群 authored
21
22
23
24
25
26
27
export default {
  name: 'JInputPop',
  props: {
    title: {
      type: String,
      default: '',
      required: false
肖超群 authored
28
    },
肖超群 authored
29
30
31
32
33
34
35
36
37
    position: {
      type: String,
      default: 'right',
      required: false
    },
    height: {
      type: Number,
      default: 200,
      required: false
肖超群 authored
38
    },
肖超群 authored
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
    width: {
      type: Number,
      default: 150,
      required: false
    },
    value: {
      type: String,
      required: false
    },
    popContainer: {
      type: String,
      default: '',
      required: false
    },
    disabled: {
      type: Boolean,
      default: false,
    },
    placeholder: {
      type: String,
      required: false
    }
肖超群 authored
61
肖超群 authored
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
  },
  data() {
    return {
      visible: false,
      inputContent: ''

    }
  },

  watch: {
    value: {
      immediate: true,
      handler: function () {
        if (this.value && this.value.length > 0) {
          this.inputContent = this.value;
肖超群 authored
77
        }
肖超群 authored
78
      }
肖超群 authored
79
    },
肖超群 authored
80
81
82
83
84
85
86
87
88
  },
  model: {
    prop: 'value',
    event: 'change'
  },
  methods: {
    handleInputChange(event) {
      this.inputContent = event.target.value
      this.$emit('change', this.inputContent)
肖超群 authored
89
    },
肖超群 authored
90
91
92
93
    pop() {
      // disabled 不弹窗
      if (this.disabled) {
        return
肖超群 authored
94
      }
肖超群 authored
95
96
97
98
99
100
101
102
103
104
105
106
      this.visible = true
      this.$nextTick(() => {
        this.$refs.textarea.focus()
      })
    },
    getPopupContainer(node) {
      if (!this.popContainer) {
        return node.parentNode
      } else {
        return document.getElementById(this.popContainer)
      }
肖超群 authored
107
108
    }
  }
肖超群 authored
109
}
肖超群 authored
110
111
112
113
114
</script>

<style scoped>

</style>