<template>
<!-- 权限信息弹出框 -->
<el-dialog :model-value="dialogVisible" :title="title" v-bind="dialogBig" @close="handleCancel" width="600" draggable>
    <div>
        <el-transfer v-model="value" :data="data.permissionList" :titles="['未具备的权限', '已具备的权限']"/>
    </div>
    <template #footer>
      <div class="dialog-footer">
        <el-button @click="handleCancel">取消</el-button>
        <el-button type="primary" @click="handleCancel">
          保存
        </el-button>
      </div>
    </template>
  </el-dialog>

  </template>
  
  <script lang="ts" setup>
  import { ref } from 'vue'
  import { Role } from '@/api/role/interface'
  import { dialogBig } from '@/utils/elementBind'
  const {dialogVisible,data} = defineProps<{
  dialogVisible: boolean;
  title: string;
  data: Role.ResRoleList;
}>()

  // const leftvalue = ref<Role.Permission[]>([])
  // const rightvalue = ref<Role.Permission[]>([])

  // const rightvalue = computed<Role.Permission[]>({
  //   get(){
  //     return data.permissionList?.filter(item => item.disabled) || []
  //     },
  //    set: (value: Role.Permission[]) => {
  //     if (data.permissionList) {
  //       for(let i = 0;i<value.length;i++){
  //         for(let j = 0;j<(data.permissionList?.length);j++){
  //           if(value[i].key === data.permissionList[j].key)
  //           {
  //             data.permissionList[j].disabled = value[i].disabled
  //           }
  //         }
  //       }
  //     }
  //    } 
  // })

  // const leftvalue = computed<Role.Permission[]>({
  //   get(){
  //     return data.permissionList?.filter(item => item.disabled === false) || []
  //     },
  //    set: (value: Role.Permission[]) => {
  //     if (data.permissionList) {
  //       for(let i = 0;i<value.length;i++){
  //         for(let j = 0;j<(data.permissionList?.length);j++){
  //           if(value[i].key === data.permissionList[j].key)
  //           {
  //             data.permissionList[j].disabled = value[i].disabled
  //           }
  //         }
  //       }
  //     }
  //    } 
  // })

  const value = ref()
 
  const emit = defineEmits<{
  (e:'update:visible',value:boolean):void;
  }>();

  const handleCancel = () => {
    emit('update:visible',false)
  }
  </script>