<template>
  <div style="height: 100%;">
    <PageSingle
      blank_spacing="48px"
      :is_check="true"
      :is_delete="true"
      :is_watch="true"
      :is_edit="true"
      :is_tool_bar_custom_01="true"
      text_tool_bar_custom_01="设置功能菜单"
      :is_tool_bar_custom_02="true"
      text_tool_bar_custom_02="设置操作权限"
      :is_tool_bar_custom_03="true"
      text_tool_bar_custom_03="设置数据权限"
      :table_name="table_name"
      :filter_data="filter_data"
      @handleCurrentChangeRow="handleCurrentChangeRow"
      @clickCustom01="clickCustom01"
      @clickCustom02="clickCustom02"
      @clickCustom03="clickCustom03"
    ></PageSingle>
    <DialogDoubleTree :show_dialog="is_double_show" 
    table_name="sys_flame_menu" 
    ref='ref_dialog'
    @dialogClose="dialogDoubleClose" 
    @dialogConfig="dialogDoubleConfig"></DialogDoubleTree>
    
    <DialogOperationList 
      :show_dialog="is_operation_list"
      ref="ref_operation_list"
      :role_id="curret_role_id"
      @dialogClose="dialogOperationListClose"
      @dialogConfig="dialogOperationListConfig"
    ></DialogOperationList>
  </div>
</template>

<script>
import system from '../../../../api/system.js';
import _ from 'lodash';
import DialogOperationList from "./components/dialog-operation-list.vue"
export default {
  name: 'Page-role',
  props: {
    // 新建安扭是否可见
    // is_visbile_new: {
    //   type: Boolean,
    //   default: false
    // },
  },
  components: {
    DialogOperationList
  },
  data() {
    return {
      table_name: 'sys_flame_role',
      is_double_show: false,
      is_operation_list:false,
      filter_data: [],
      current_row:null,
      curret_role_id:'0'
    };
  },
  created() {},
  methods: {
    // 自定义一
    clickCustom01() {
      let that = this;
     
      let commit_data = {
        'role_id':that.current_row['flame_id'],
      };
      console.log('aaaa=clickCustom01', commit_data);
      
      system.call_method('sys_flame_menu','getRoleMenu', commit_data, res => {
        if (res.result === true) {
          console.log('getRoleMenu',res);
          
           that.is_double_show = true;
           that.$refs.ref_dialog.setRightData(res.items);
          // that.$message({
          //   type: 'success',
          //   message: '操作成功'
          // });
        } else {
          that.$message({
            type: 'error',
            message: '操作失败'
          });
        }
      });
      // that.$emit('clickExport', true);
    },
    // 自定义操作2
    clickCustom02() {
      let that = this;
      that.is_operation_list = true;
      that.$refs.ref_operation_list.setData(that.curret_role_id);
    },
    dialogOperationListClose() {
      let that = this;
      that.is_operation_list = false;
    },
    dialogOperationListConfig() {
      let that = this;
      that.is_operation_list =false;
    },
    // 自定义操作3
    clickCustom03() {
      let that = this;
      that.show_dialog = true;
      // that.$message({
      //   type: 'info',
      //   message: '目前还没有实现改功能1111'
      // });
      // that.$emit('clickCustom03', true);
    },
    handleCurrentChangeRow(row) {
      let that = this;
      that.current_row = row;
      that.curret_role_id = ''+ row.flame_id;
    },
    dialogDoubleClose() {
      let that = this;
      that.is_double_show = false;
    },
    dialogDoubleConfig(data) {
      let that = this;
      that.is_double_show = false;
      let commit_data ={
        'role_id':that.current_row['flame_id'],
        'menus': _.union(_.map(data,'flame_id')),
      }
      // 写入
      console.log('confirmDialog---=data', commit_data);
      system.call_method('sys_flame_role_ship_menu','AddMenu',commit_data,res =>{
        
      });
      
    }
  }
};
</script>

<style lang="scss" scoped></style>
