Blame view

ant-design-vue-jeecg/src/views/system/modules/RoleDataruleModal.vue 2.99 KB
肖超群 authored
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
<template>
  <a-drawer
    title="数据规则/按钮权限配置"
    width="365"
    :closable="false"
    @close="onClose"
    :visible="visible"
  >

    <a-tabs defaultActiveKey="1">
      <a-tab-pane tab="数据规则" key="1">

        <a-checkbox-group v-model="dataruleChecked" v-if="dataruleList.length>0">
          <a-row>
            <a-col :span="24" v-for="(item,index) in dataruleList" :key=" 'dr'+index ">
              <a-checkbox :value="item.id">{{ item.ruleName }}</a-checkbox>
            </a-col>

            <a-col :span="24">
              <div style="width: 100%;margin-top: 15px">
                <a-button @click="saveDataruleForRole" type="primary" size="small" icon="save">点击保存</a-button>
              </div>
            </a-col>
          </a-row>
        </a-checkbox-group>
        <div v-else><h3>无配置信息!</h3></div>

      </a-tab-pane>
      <!--<a-tab-pane tab="按钮权限" key="2">敬请期待!!!</a-tab-pane>-->
    </a-tabs>

  </a-drawer>
</template>

<script>
肖超群 authored
36
37
38
import ARow from 'ant-design-vue/es/grid/Row'
import ACol from 'ant-design-vue/es/grid/Col'
import {getAction, postAction} from '@/api/manage'
肖超群 authored
39
肖超群 authored
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
export default {
  name: 'RoleDataruleModal',
  components: {ACol, ARow},
  data() {
    return {
      functionId: '',
      roleId: '',
      visible: false,
      tabList: [{
        key: '1',
        tab: '数据规则',
      }, {
        key: '2',
        tab: '按钮权限',
      }],
      activeTabKey: '1',
      url: {
        datarule: "/sys/role/datarule",
肖超群 authored
58
      },
肖超群 authored
59
60
61
62
63
64
65
66
67
68
69
70
71
      dataruleList: [],
      dataruleChecked: []
    }
  },
  methods: {
    loadData() {
      getAction(`${this.url.datarule}/${this.functionId}/${this.roleId}`).then(res => {
        console.log(res)
        if (res.success) {
          this.dataruleList = res.result.datarule
          let drChecked = res.result.drChecked
          if (drChecked) {
            this.dataruleChecked = drChecked.split(",")
肖超群 authored
72
          }
肖超群 authored
73
74
75
76
77
78
        }
      })
    },
    saveDataruleForRole() {
      if (!this.dataruleChecked || this.dataruleChecked.length == 0) {
        this.$message.warning("请注意,现未勾选任何数据权限!")
肖超群 authored
79
      }
肖超群 authored
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
      let params = {
        permissionId: this.functionId,
        roleId: this.roleId,
        dataRuleIds: this.dataruleChecked.join(",")
      }
      console.log("保存数据权限", params)
      postAction(this.url.datarule, params).then(res => {
        if (res.success) {
          this.$message.success(res.message)
        } else {
          this.$message.error(res.message)
        }
      })
    },
    show(functionId, roleId) {
      this.onReset()
      this.functionId = functionId
      this.roleId = roleId
      this.visible = true
      this.loadData()
    },
    onClose() {
      this.visible = false
      this.onReset()
    },
    onTabChange(key) {
      this.activeTabKey = key
    },
    onReset() {
      this.functionId = ''
      this.roleId = ''
      this.dataruleList = []
      this.dataruleChecked = []
肖超群 authored
113
114
    }
  }
肖超群 authored
115
}
肖超群 authored
116
117
118
119
120
</script>

<style scoped>

</style>