shikeying
2023-04-07 c192f834c4e092bc7c0f2722c343c25c1be619ab
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
<template>
  <win2 :title="title" @close="close">
    <ztree ref="ztree" :nodes="nodes" />
    <div slot="footer" align="center" class="dialog-footer">
      <my-button-v2 name="取消" site="form" @click="close" />
      <my-button-v2 name="保存" site="form" @click="save" />
    </div>
  </win2>
</template>
 
<script>
import win2 from '@/views/components/win2'
import myButtonV2 from '@/views/components/myButtonV2'
import ztree from '@/views/components/ztree'
import { getUserAuthZTree } from '@/api/common.js'
export default {
  components: { win2, myButtonV2, ztree },
  props: {
    setting: {
      type: Object,
      default: function() {
        return {}
      }
    }
  },
  data() {
    return {
      title: '选择用户',
      nodes: []
    }
  },
  created() {
    this.getInfo()
  },
  methods: {
    getInfo() {
      if (this.setting.businessType && this.setting.businessId) {
        getUserAuthZTree(this.setting).then(res => {
          this.nodes = res.data
        })
      }
    },
    close() {
      this.$emit('close')
    },
    save() {
      const checkedNodes = this.$refs.ztree.getCheckedNodes()
      // 如果是单选,需要判断选择的节点个数
      if (this.setting.isRadio != undefined && this.setting.isRadio && checkedNodes.length > 1) {
        this.$message.info('只能选择一个人员,请检查重试!')
        return
      }
      this.$emit('saveUser', checkedNodes)
      this.close()
    }
  }
}
</script>