Blame view

ant-design-vue-jeecg/src/components/jeecgbiz/JSelectUserByDep.vue 1.91 KB
1
2
3
<template>
  <div>
    <a-input-search
4
      v-model="userNames"
5
      placeholder="请先选择用户"
6
7
      readOnly
      unselectable="on"
8
9
10
      @search="onSearchDepUser">
      <a-button slot="enterButton" :disabled="disabled">选择用户</a-button>
    </a-input-search>
11
    <j-select-user-by-dep-modal ref="selectModal" :modal-width="modalWidth" :multi="multi" @ok="selectOK" :user-ids="value" @initComp="initComp"/>
12
13
14
15
16
  </div>
</template>

<script>
  import JSelectUserByDepModal from './modal/JSelectUserByDepModal'
17
18
19
  export default {
    name: 'JSelectUserByDep',
20
21
22
23
24
25
    components: {JSelectUserByDepModal},
    props: {
      modalWidth: {
        type: Number,
        default: 1250,
        required: false
26
      },
27
28
29
      value: {
        type: String,
        required: false
30
      },
31
      disabled: {
32
33
34
        type: Boolean,
        required: false,
        default: false
35
36
37
38
39
40
      },
      multi: {
        type: Boolean,
        default: true,
        required: false
      },
41
42
43
    },
    data() {
      return {
44
45
        userIds: "",
        userNames: ""
46
47
      }
    },
48
49
    mounted() {
      this.userIds = this.value
50
    },
51
52
53
    watch: {
      value(val) {
        this.userIds = val
54
55
      }
    },
56
57
58
59
    model: {
      prop: 'value',
      event: 'change'
    },
60
    methods: {
61
62
63
      initComp(userNames) {
        this.userNames = userNames
      },
64
65
66
      onSearchDepUser() {
        this.$refs.selectModal.showModal()
      },
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
      selectOK(rows, idstr) {
        console.log("当前选中用户", rows)
        console.log("当前选中用户ID", idstr)
        if (!rows) {
          this.userNames = ''
          this.userIds = ''
        } else {
          let temp = ''
          for (let item of rows) {
            temp += ',' + item.realname
          }
          this.userNames = temp.substring(1)
          this.userIds = idstr
        }
        this.$emit("change", this.userIds)
82
83
84
85
86
87
88
89
      }
    }
  }
</script>

<style scoped>

</style>