Blame view

antis-ncc-admin/src/views/permission/userRelation/Selector.vue 2.1 KB
03207d5d   wwk   1
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
  <template>
    <el-dialog :title="pageTitle" :close-on-click-modal="false" :close-on-press-escape="false"
      :visible.sync="visible" lock-scroll append-to-body
      class="NCC-dialog NCC-dialog_center transfer-dialog" width="800px">
      <userTransfer v-model="dataForm.userIds" ref="userTransfer" multiple />
      <span slot="footer" class="dialog-footer">
        <el-button @click="visible = false">{{$t('common.cancelButton')}}</el-button>
        <el-button type="primary" :loading="btnLoading" @click="dataFormSubmit()">
          {{$t('common.confirmButton')}}</el-button>
      </span>
    </el-dialog>
  </template>
  <script>
  import { getUserRelationList, createUserRelation } from '@/api/permission/userRelation'
  import userTransfer from '@/components/NCC-userTransfer'
  
  export default {
    components: { userTransfer },
    data() {
      return {
        visible: false,
        btnLoading: false,
        pageTitle: '',
        dataForm: {
          objectId: '',
          objectType: '',
          userIds: []
        },
      }
    },
    methods: {
      init(id, fullName, type) {
        this.visible = true
        this.dataForm.objectId = id
        this.dataForm.objectType = type
        this.dataForm.userIds = []
        this.$nextTick(() => {
          if (type === 'Position') {
            this.pageTitle = this.$t(`position.postMember`) + '- ' + fullName
          } else if (type === 'Role') {
            this.pageTitle = this.$t(`role.roleMember`) + ' - ' + fullName
          }
          this.$refs.userTransfer && (this.$refs.userTransfer.allLoading = true)
          getUserRelationList(this.dataForm.objectId).then(res => {
            this.dataForm.userIds = res.data.ids
            this.$refs.userTransfer && this.$refs.userTransfer.init()
          })
        })
      },
      dataFormSubmit() {
        this.btnLoading = true
        createUserRelation(this.dataForm).then(res => {
          this.$message({
            message: res.msg,
            type: 'success',
            duration: 1500,
            onClose: () => {
              this.visible = false
              this.btnLoading = false
            }
          })
        }).catch(() => {
          this.btnLoading = false
        })
      }
    }
  }
  </script>