Blame view

src/components/staff/chooseOrgTree.vue 1.68 KB
6c157c6e   wuxw   优化完成员工认证 员工小区功能
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
  <template>
    <el-dialog
      :title="$t('staffCommunity.chooseOrgTitle')"
      :visible.sync="visible"
      width="60%"
    >
      <el-tree
        ref="orgTree"
        :data="orgs"
        node-key="id"
        show-checkbox
        :props="defaultProps"
        @check-change="handleCheckChange"
      />
      <div slot="footer" class="dialog-footer">
        <el-button @click="visible = false">{{ $t('common.cancel') }}</el-button>
        <el-button type="primary" @click="confirmChoose">{{ $t('common.confirm') }}</el-button>
      </div>
    </el-dialog>
  </template>
  
  <script>
  import { listOrgTree } from '@/api/staff/staffCommunityApi'
24d3590f   wuxw   房屋收费页面开发完成
24
  import { getCommunityId } from '@/api/community/communityApi'
6c157c6e   wuxw   优化完成员工认证 员工小区功能
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
  
  export default {
    name: 'ChooseOrgTree',
    data() {
      return {
        visible: false,
        orgs: [],
        currentOrg: {},
        defaultProps: {
          children: 'children',
          label: 'name'
        }
      }
    },
    methods: {
      open() {
        this.visible = true
        this.loadOrgs()
      },
      async loadOrgs() {
        try {
          const { data } = await listOrgTree({
24d3590f   wuxw   房屋收费页面开发完成
47
            communityId: getCommunityId()
6c157c6e   wuxw   优化完成员工认证 员工小区功能
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
          })
          this.orgs = data
        } catch (error) {
          this.$message.error(this.$t('staffCommunity.fetchOrgError'))
        }
      },
      handleCheckChange(data, checked) {
        if (checked) {
          this.currentOrg = {
            orgId: data.id,
            allOrgName: data.name
          }
        }
      },
      confirmChoose() {
        if (!this.currentOrg.orgId) {
          this.$message.warning(this.$t('staffCommunity.selectOrgTip'))
          return
        }
        this.$emit('switchOrg', this.currentOrg)
        this.visible = false
      }
    }
  }
  </script>
  
  <style scoped>
  .dialog-footer {
    text-align: right;
  }
  </style>