yangys
2024-01-13 ea10117a46fbbe7dd831c3816217493d0da01bf9
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<template>
    <div>
      <el-dialog title="用户授权" :visible.sync="isShowing" custom-class="custom-dialog" @close='cancelDialog()'>
        <el-transfer class="large-screen-grant"
          filter-placeholder="请输入城市拼音"
          v-model="value"
          :props="{key: 'roomId',label: 'roomName'}"
          :titles="['未授权列表', '已授权列表']"
          :data="list">
        </el-transfer>
 
        <div class="small-screen-grant">
          <el-checkbox-group v-model="value">
            <el-checkbox v-for="cls in this.list" :label="cls.roomId" :key="cls.roomId">{{cls.roomName}}</el-checkbox>
          </el-checkbox-group>
        </div>
        <div slot="footer" class="dialog-footer">
          <el-button @click="cancelDialog()">取 消</el-button>
          <el-button type="primary" @click="confirm()">授 权</el-button>
        </div>
      </el-dialog>
    </div>
</template>
 
<script>
    export default {
      name: 'grantAuthDialog',
      props: {
        isVisible: {
          type: Boolean,
          default: false
        },
        list: {
          type: Array,
          default: []
        },
        grantList: {
          type: Array,
          default: []
        }
      },
      watch: {
        list(val) {
          // console.log(val)
        },
        isVisible(val) {
          if (!val) {
            this.value = []
          }
          this.isShowing = val
        },
        grantList(val) {
          this.value = val
        }
      },
      // beforeUpdate() {
      //   console.log(this.list)
      //   console.log(window.innerWidth)
      // },
      data() {
        return {
          isShowing: this.isVisible,
          value: this.grantList
        }
      },
      methods: {
        // 取消关闭对话框
        cancelDialog() {
          this.$emit('submit', { action: 'cancel' })
        },
        // 授权确认
        confirm() {
          const arr = JSON.stringify(this.value || [])
          this.$emit('submit', { action: 'confirm', data: arr })
        }
      }
    }
</script>
 
<style scoped>
  .large-screen-grant {
    display: none;
  }
  .small-screen-grant{
    display: block;
  }
  @media only screen and (min-width: 679px) {
    .large-screen-grant {
      display: block;
    }
    .small-screen-grant{
      display: none;
    }
  }
</style>