Blame view

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

<script>
  import JSelectUserByDepModal from './modal/JSelectUserByDepModal'
16
17
18
  export default {
    name: 'JSelectUserByDep',
19
20
21
22
23
24
    components: {JSelectUserByDepModal},
    props: {
      modalWidth: {
        type: Number,
        default: 1250,
        required: false
25
      },
26
27
28
      value: {
        type: String,
        required: false
29
      },
30
      disabled: {
31
32
33
        type: Boolean,
        required: false,
        default: false
34
35
36
37
38
39
      },
      multi: {
        type: Boolean,
        default: true,
        required: false
      },
40
41
42
    },
    data() {
      return {
43
44
        userIds: "",
        userNames: ""
45
46
      }
    },
47
48
    mounted() {
      this.userIds = this.value
49
    },
50
51
52
    watch: {
      value(val) {
        this.userIds = val
53
54
      }
    },
55
56
57
58
    model: {
      prop: 'value',
      event: 'change'
    },
59
    methods: {
60
61
62
      initComp(userNames) {
        this.userNames = userNames
      },
63
64
65
      onSearchDepUser() {
        this.$refs.selectModal.showModal()
      },
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
      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)
81
82
83
84
85
86
87
88
      }
    }
  }
</script>

<style scoped>

</style>