665d1955089434e7249f2f44460845af945b34c9.svn-base 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <template>
  2. <a-drawer
  3. title="数据规则/按钮权限配置"
  4. width="365"
  5. :closable="false"
  6. @close="onClose"
  7. :visible="visible"
  8. >
  9. <a-tabs defaultActiveKey="1">
  10. <a-tab-pane tab="数据规则" key="1">
  11. <a-checkbox-group v-model="dataruleChecked" v-if="dataruleList.length>0">
  12. <a-row>
  13. <a-col :span="24" v-for="(item,index) in dataruleList" :key=" 'dr'+index ">
  14. <a-checkbox :value="item.id">{{ item.ruleName }}</a-checkbox>
  15. </a-col>
  16. <a-col :span="24">
  17. <div style="width: 100%;margin-top: 15px">
  18. <a-button @click="saveDataruleForRole" type="primary" size="small" icon="save">点击保存</a-button>
  19. </div>
  20. </a-col>
  21. </a-row>
  22. </a-checkbox-group>
  23. <div v-else><h3>无配置信息!</h3></div>
  24. </a-tab-pane>
  25. <!--<a-tab-pane tab="按钮权限" key="2">敬请期待!!!</a-tab-pane>-->
  26. </a-tabs>
  27. </a-drawer>
  28. </template>
  29. <script>
  30. import ARow from 'ant-design-vue/es/grid/Row'
  31. import ACol from 'ant-design-vue/es/grid/Col'
  32. import { getAction,postAction } from '@/api/manage'
  33. export default {
  34. name: 'RoleDataruleModal',
  35. components: { ACol, ARow },
  36. data(){
  37. return {
  38. functionId:'',
  39. roleId:'',
  40. visible:false,
  41. tabList: [{
  42. key: '1',
  43. tab: '数据规则',
  44. }, {
  45. key: '2',
  46. tab: '按钮权限',
  47. }],
  48. activeTabKey: '1',
  49. url:{
  50. datarule:"/sys/role/datarule",
  51. },
  52. dataruleList:[],
  53. dataruleChecked:[]
  54. }
  55. },
  56. methods:{
  57. loadData(){
  58. getAction(`${this.url.datarule}/${this.functionId}/${this.roleId}`).then(res=>{
  59. console.log(res)
  60. if(res.success){
  61. this.dataruleList = res.result.datarule
  62. let drChecked = res.result.drChecked
  63. if(drChecked){
  64. this.dataruleChecked = drChecked.split(",")
  65. }
  66. }
  67. })
  68. },
  69. saveDataruleForRole(){
  70. if(!this.dataruleChecked || this.dataruleChecked.length==0){
  71. this.$message.warning("请注意,现未勾选任何数据权限!")
  72. }
  73. let params = {
  74. permissionId:this.functionId,
  75. roleId:this.roleId,
  76. dataRuleIds:this.dataruleChecked.join(",")
  77. }
  78. console.log("保存数据权限",params)
  79. postAction(this.url.datarule,params).then(res=>{
  80. if(res.success){
  81. this.$message.success(res.message)
  82. }else{
  83. this.$message.error(res.message)
  84. }
  85. })
  86. },
  87. show(functionId,roleId){
  88. this.onReset()
  89. this.functionId = functionId
  90. this.roleId = roleId
  91. this.visible=true
  92. this.loadData()
  93. },
  94. onClose(){
  95. this.visible=false
  96. this.onReset()
  97. },
  98. onTabChange (key) {
  99. this.activeTabKey = key
  100. },
  101. onReset(){
  102. this.functionId=''
  103. this.roleId=''
  104. this.dataruleList=[]
  105. this.dataruleChecked=[]
  106. }
  107. }
  108. }
  109. </script>
  110. <style scoped>
  111. </style>