Blame view

src/components/Process/OrgTransfer/index.vue 2.24 KB
4424f41c   monkeyhouyi   网信执法、清单管理静态页面
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
  
  <template>
    <el-dialog :title="title" :close-on-click-modal="false"
      class="NCC-dialog NCC-dialog_center transfer-dialog" lock-scroll append-to-body
      v-bind="$attrs" width="800px" :modal-append-to-body="false" v-on="$listeners" @open="onOpen">
      <userTransfer v-model="selectedData" ref="userTransfer" multiple v-if="type==='user'" />
      <NCCTransfer :loading="loading" :treeData="treeData" v-model="selectedData" :type="type"
        ref="NCCTransfer" v-else />
      <span slot="footer" class="dialog-footer">
        <el-button @click="closeTransfer">{{$t('common.cancelButton')}}</el-button>
        <el-button type="primary" @click="confirm">{{$t('common.confirmButton')}}</el-button>
      </span>
    </el-dialog>
  </template>
  
  <script>
  import NCCTransfer from '@/components/NCC-transfer'
  import userTransfer from '@/components/NCC-userTransfer'
  
  export default {
    name: 'org-transfer',
    components: { NCCTransfer, userTransfer },
    props: {
      value: {
        type: Array,
        default: () => []
      },
      type: {
        type: String,
        default: 'user'
      },
      title: {
        type: String,
        default: '组织机构'
      },
    },
    data() {
      return {
        loading: false,
        treeData: [],
        selectedData: []
      }
    },
    methods: {
      onOpen() {
        this.dataInit()
      },
      closeTransfer() {
        this.$emit('update:visible', false)
      },
      confirm() {
        this.$emit('confirm', this.selectedData)
        this.closeTransfer()
      },
      dataInit() {
        this.loading = true
        this.selectedData = []
        this.$nextTick(async () => {
          if (this.type === 'user') {
            this.selectedData = JSON.parse(JSON.stringify(this.value))
            this.$nextTick(() => {
              this.$refs.userTransfer && this.$refs.userTransfer.init()
            })
          } else {
            let res = null
            this.$refs.NCCTransfer && (this.$refs.NCCTransfer.filterText = '')
            if (this.type == 'position') {
              res = await this.$store.dispatch('base/getPositionTree')
            } else if (this.type == 'role') {
              res = await this.$store.dispatch('base/getRoleTree')
            }
            this.treeData = res
            this.selectedData = this.value
          }
          this.loading = false
        })
      }
    }
  }
  </script>